8246704: --release => \"unknown enum constant PreviewFeature$Feature.TEXT_BLOCKS\"
Use a synthetic annotation instead of inaccessible jdk.internal.PreviewFeature in ct.sym, and avoid resolving that annotation, to prevent errors being printed for the inaccessible types. Reviewed-by: jlaskey
This commit is contained in:
parent
42d3bad0b1
commit
31c511e6a5
@ -1067,10 +1067,23 @@ public class CreateSymbols {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Annotation createAnnotation(List<CPInfo> constantPool, AnnotationDescription desc) {
|
private Annotation createAnnotation(List<CPInfo> constantPool, AnnotationDescription desc) {
|
||||||
|
String annotationType = desc.annotationType;
|
||||||
|
|
||||||
|
if (PREVIEW_FEATURE_ANNOTATION.equals(annotationType)) {
|
||||||
|
//the non-public PreviewFeature annotation will not be available in ct.sym,
|
||||||
|
//replace with purely synthetic javac-internal annotation:
|
||||||
|
annotationType = PREVIEW_FEATURE_ANNOTATION_INTERNAL;
|
||||||
|
}
|
||||||
|
|
||||||
return new Annotation(null,
|
return new Annotation(null,
|
||||||
addString(constantPool, desc.annotationType),
|
addString(constantPool, annotationType),
|
||||||
createElementPairs(constantPool, desc.values));
|
createElementPairs(constantPool, desc.values));
|
||||||
}
|
}
|
||||||
|
//where:
|
||||||
|
private static final String PREVIEW_FEATURE_ANNOTATION =
|
||||||
|
"Ljdk/internal/PreviewFeature;";
|
||||||
|
private static final String PREVIEW_FEATURE_ANNOTATION_INTERNAL =
|
||||||
|
"Ljdk/internal/PreviewFeature+Annotation;";
|
||||||
|
|
||||||
private element_value_pair[] createElementPairs(List<CPInfo> constantPool, Map<String, Object> annotationAttributes) {
|
private element_value_pair[] createElementPairs(List<CPInfo> constantPool, Map<String, Object> annotationAttributes) {
|
||||||
element_value_pair[] pairs = new element_value_pair[annotationAttributes.size()];
|
element_value_pair[] pairs = new element_value_pair[annotationAttributes.size()];
|
||||||
|
@ -217,6 +217,7 @@ public class Symtab {
|
|||||||
public final Type elementTypeType;
|
public final Type elementTypeType;
|
||||||
public final Type functionalInterfaceType;
|
public final Type functionalInterfaceType;
|
||||||
public final Type previewFeatureType;
|
public final Type previewFeatureType;
|
||||||
|
public final Type previewFeatureInternalType;
|
||||||
public final Type typeDescriptorType;
|
public final Type typeDescriptorType;
|
||||||
public final Type recordType;
|
public final Type recordType;
|
||||||
|
|
||||||
@ -580,6 +581,7 @@ public class Symtab {
|
|||||||
stringConcatFactory = enterClass("java.lang.invoke.StringConcatFactory");
|
stringConcatFactory = enterClass("java.lang.invoke.StringConcatFactory");
|
||||||
functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
|
functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
|
||||||
previewFeatureType = enterClass("jdk.internal.PreviewFeature");
|
previewFeatureType = enterClass("jdk.internal.PreviewFeature");
|
||||||
|
previewFeatureInternalType = enterSyntheticAnnotation("jdk.internal.PreviewFeature+Annotation");
|
||||||
typeDescriptorType = enterClass("java.lang.invoke.TypeDescriptor");
|
typeDescriptorType = enterClass("java.lang.invoke.TypeDescriptor");
|
||||||
recordType = enterClass("java.lang.Record");
|
recordType = enterClass("java.lang.Record");
|
||||||
|
|
||||||
|
@ -1429,6 +1429,9 @@ public class ClassReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (proxy.type.tsym.flatName() == syms.previewFeatureInternalType.tsym.flatName()) {
|
||||||
|
sym.flags_field |= PREVIEW_API;
|
||||||
|
setFlagIfAttributeTrue(proxy, sym, names.essentialAPI, PREVIEW_ESSENTIAL_API);
|
||||||
} else {
|
} else {
|
||||||
if (proxy.type.tsym == syms.annotationTargetType.tsym) {
|
if (proxy.type.tsym == syms.annotationTargetType.tsym) {
|
||||||
target = proxy;
|
target = proxy;
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* @test /nodynamiccopyright/
|
||||||
|
* @bug 8246704
|
||||||
|
* @summary Verify preview APIs are reported correctly when using --release.
|
||||||
|
* @compile/fail/ref=PreviewAPIsWithRelease.out -XDrawDiagnostics --release 14 PreviewAPIsWithRelease.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.sun.source.tree.Tree.Kind;
|
||||||
|
|
||||||
|
public class PreviewAPIsWithRelease {
|
||||||
|
void test() {
|
||||||
|
"".stripIndent();
|
||||||
|
Kind r = Kind.RECORD;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
PreviewAPIsWithRelease.java:12:11: compiler.err.is.preview: stripIndent()
|
||||||
|
PreviewAPIsWithRelease.java:13:22: compiler.warn.is.preview: RECORD
|
||||||
|
1 error
|
||||||
|
1 warning
|
Loading…
x
Reference in New Issue
Block a user