diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java index 14a4cdde570..f7770c931e3 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java @@ -212,6 +212,7 @@ public boolean isPreview(Feature feature) { case SUPER_INIT -> true; case PRIMITIVE_PATTERNS -> true; case VALUE_CLASSES -> true; + case NULL_RESTRICTED_TYPES -> true; //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing). //When real preview features will be added, this method can be implemented to return 'true' //for those selected features, and 'false' for all the others. diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java index 6b91add8773..ed24ea2cae6 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java @@ -270,6 +270,7 @@ public enum Feature { PRIMITIVE_PATTERNS(JDK23, Fragments.FeaturePrimitivePatterns, DiagKind.PLURAL), SUPER_INIT(JDK22, Fragments.FeatureSuperInit, DiagKind.NORMAL), VALUE_CLASSES(JDK22, Fragments.FeatureValueClasses, DiagKind.PLURAL), + NULL_RESTRICTED_TYPES(JDK23, Fragments.FeatureNullRestrictedTypes, DiagKind.PLURAL), ; enum DiagKind { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java index 908fcbf0959..28ef254aae2 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java @@ -99,7 +99,8 @@ public class Types { public final Warner noWarnings; - private boolean enableNullRestrictedTypes; + /* are nullable and null-restricted types allowed? */ + private boolean allowNullRestrictedTypes; // public static Types instance(Context context) { @@ -126,8 +127,9 @@ public String toString() { return "NO_WARNINGS"; } }; - Options options = Options.instance(context); - enableNullRestrictedTypes = options.isSet("enableNullRestrictedTypes"); + Preview preview = Preview.instance(context); + allowNullRestrictedTypes = (!preview.isPreview(Source.Feature.NULL_RESTRICTED_TYPES) || preview.isEnabled()) && + Source.Feature.NULL_RESTRICTED_TYPES.allowedInSource(source); } // @@ -1086,7 +1088,7 @@ public final boolean isSubtypeNoCapture(Type t, Type s) { } public boolean isSubtype(Type t, Type s, boolean capture) { if (t.equalsIgnoreMetadata(s)) { - if (enableNullRestrictedTypes) { + if (allowNullRestrictedTypes) { new NullabilityComparator((t1, t2) -> hasNarrowerNullability(t1, t2)).visit(s, t); } return true; @@ -1208,7 +1210,7 @@ public Boolean visitClassType(ClassType t, Type s) { && (!s.isParameterized() || containsTypeRecursive(s, sup)) && isSubtypeNoCapture(sup.getEnclosingType(), s.getEnclosingType()); - if (result && enableNullRestrictedTypes) { + if (result && allowNullRestrictedTypes) { new NullabilityComparator((t1, t2) -> hasNarrowerNullability(t1, t2)).visit(s, t); } return result; @@ -1488,7 +1490,7 @@ public Boolean visitClassType(ClassType t, Type s) { boolean equal = t.tsym == s.tsym && visit(t.getEnclosingType(), s.getEnclosingType()) && containsTypeEquivalent(t.getTypeArguments(), s.getTypeArguments()); - if (equal && enableNullRestrictedTypes) { + if (equal && allowNullRestrictedTypes) { new NullabilityComparator((t1, t2) -> !hasSameNullability(t1, t2)).visit(s, t); } return equal; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index eb36a1033b3..5d69aa89ba8 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -183,7 +183,8 @@ protected Attr(Context context) { unknownTypeInfo = new ResultInfo(KindSelector.TYP, Type.noType); unknownTypeExprInfo = new ResultInfo(KindSelector.VAL_TYP, Type.noType); recoveryInfo = new RecoveryInfo(deferredAttr.emptyDeferredAttrContext); - enableNullRestrictedTypes = options.isSet("enableNullRestrictedTypes"); + allowNullRestrictedTypes = (!preview.isPreview(Source.Feature.NULL_RESTRICTED_TYPES) || preview.isEnabled()) && + Source.Feature.NULL_RESTRICTED_TYPES.allowedInSource(source); } /** Switch: reifiable types in instanceof enabled? @@ -215,7 +216,7 @@ protected Attr(Context context) { /** Are null-restricted types allowed */ - private final boolean enableNullRestrictedTypes; + private final boolean allowNullRestrictedTypes; /** Check kind and type of given tree against protokind and prototype. * If check succeeds, store type in tree and return it. @@ -743,8 +744,7 @@ public Type attribType(JCTree tree, Env env) { */ Type attribType(JCTree tree, Env env, Type pt) { Type result = attribTree(tree, env, new ResultInfo(KindSelector.TYP, pt)); - if (enableNullRestrictedTypes && - tree instanceof JCNullableTypeExpression nullableTypeExpression && + if (allowNullRestrictedTypes && tree instanceof JCNullableTypeExpression nullableTypeExpression && nullableTypeExpression.getNullMarker() != NullMarker.UNSPECIFIED) { result = tree.type = result.addMetadata(new TypeMetadata.NullMarker(nullableTypeExpression.getNullMarker())); } @@ -1183,7 +1183,7 @@ public void visitMethodDef(JCMethodDecl tree) { for (List l = tree.thrown; l.nonEmpty(); l = l.tail) chk.checkType(l.head.pos(), l.head.type, syms.throwableType); - if (enableNullRestrictedTypes && tree.sym.isImplicitConstructor()) { + if (allowNullRestrictedTypes && tree.sym.isImplicitConstructor()) { if (tree.body == null) { tree.body = make.Block(0, List.nil()); } else { @@ -1362,7 +1362,7 @@ public void visitVarDef(JCVariableDecl tree) { log.error(tree, Errors.IllegalRecordComponentName(v)); } } - if (enableNullRestrictedTypes) { + if (allowNullRestrictedTypes) { Type elemOrType = result; while (!elemOrType.hasTag(ERROR) && types.elemtype(elemOrType) != null) { elemOrType = types.elemtype(elemOrType); @@ -2960,7 +2960,7 @@ else if (!skipNonDiamondPath) { if (tree.constructor != null && tree.constructor.kind == MTH) { owntype = clazztype; - if (enableNullRestrictedTypes && owntype.getMetadata(TypeMetadata.NullMarker.class) == null) { + if (allowNullRestrictedTypes && owntype.getMetadata(TypeMetadata.NullMarker.class) == null) { owntype = owntype.addMetadata(new TypeMetadata.NullMarker(NullMarker.NOT_NULL)); // constructor invocations are always null restricted } } @@ -5433,8 +5433,7 @@ public void attribClass(DiagnosticPosition pos, ClassSymbol c) { attribClass(c); if (c.type.isValueClass()) { final Env env = typeEnvs.get(c); - if (enableNullRestrictedTypes && - env != null && env.tree != null && env.tree.hasTag(CLASSDEF) && TreeInfo.getImplicitConstructor(((JCClassDecl)env.tree).defs) != null) + if (allowNullRestrictedTypes && env != null && env.tree != null && env.tree.hasTag(CLASSDEF) && TreeInfo.getImplicitConstructor(((JCClassDecl)env.tree).defs) != null) chk.checkNonCyclicMembership((JCClassDecl)env.tree); } } catch (CompletionFailure ex) { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index 410e4f249c1..a132be0ecd8 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -183,7 +183,8 @@ protected Check(Context context) { allowSealed = Feature.SEALED_CLASSES.allowedInSource(source); allowValueClasses = (!preview.isPreview(Feature.VALUE_CLASSES) || preview.isEnabled()) && Feature.VALUE_CLASSES.allowedInSource(source); - enableNullRestrictedTypes = options.isSet("enableNullRestrictedTypes"); + allowNullRestrictedTypes = (!preview.isPreview(Source.Feature.NULL_RESTRICTED_TYPES) || preview.isEnabled()) && + Source.Feature.NULL_RESTRICTED_TYPES.allowedInSource(source); } /** Character for synthetic names @@ -231,9 +232,10 @@ protected Check(Context context) { */ private final boolean allowValueClasses; - /** Are null-restricted types allowed + /** Are null restricted types allowed */ - private final boolean enableNullRestrictedTypes; + private final boolean allowNullRestrictedTypes; + /* ************************************************************************* * Errors and Warnings **************************************************************************/ @@ -313,7 +315,7 @@ public void warnUnchecked(DiagnosticPosition pos, Warning warnKey) { * @param warnKey A warning key. */ public void warnNullableTypes(DiagnosticPosition pos, Warning warnKey) { - if (enableNullRestrictedTypes && lint.isEnabled(LintCategory.NULL)) { + if (allowNullRestrictedTypes && lint.isEnabled(LintCategory.NULL)) { log.warning(LintCategory.NULL, pos, warnKey); } } @@ -816,7 +818,7 @@ void checkConstraintsOfValueClass(JCClassDecl tree, ClassSymbol c) { } void checkConstraintsOfValueClassesWithImplicitConst(JCClassDecl classDecl, ClassSymbol c) { - if (enableNullRestrictedTypes) { + if (allowNullRestrictedTypes) { JCMethodDecl implicitConstructor = TreeInfo.getImplicitConstructor(classDecl.defs); if (implicitConstructor != null) { Type encl = c.type.getEnclosingType(); @@ -2794,7 +2796,7 @@ void checkCompatibleSupertypes(DiagnosticPosition pos, Type c) { boolean implementsLooselyConsistentValue = false; try { - implementsLooselyConsistentValue = allowValueClasses && enableNullRestrictedTypes ? types.asSuper(c, syms.looselyConsistentValueType.tsym) != null : false; + implementsLooselyConsistentValue = allowValueClasses && allowNullRestrictedTypes ? types.asSuper(c, syms.looselyConsistentValueType.tsym) != null : false; } catch (CompletionFailure cf) { // ignore } @@ -4571,7 +4573,7 @@ public NullnessWarner(DiagnosticPosition pos) { @Override public void warn(LintCategory lint) { - if (enableNullRestrictedTypes) { + if (allowNullRestrictedTypes) { boolean warned = this.warned; super.warn(lint); if (warned) return; // suppress redundant diagnostics diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java index 383064fb29b..abb2c04af88 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java @@ -104,7 +104,7 @@ public static Lower instance(Context context) { private final boolean useMatchException; private final HashMap typePairToName; private final boolean allowValueClasses; - private final boolean enableNullRestrictedTypes; + private final boolean allowNullRestrictedTypes; @SuppressWarnings("this-escape") protected Lower(Context context) { @@ -139,7 +139,8 @@ protected Lower(Context context) { typePairToName = TypePairs.initialize(syms); this.allowValueClasses = (!preview.isPreview(Feature.VALUE_CLASSES) || preview.isEnabled()) && Feature.VALUE_CLASSES.allowedInSource(source); - enableNullRestrictedTypes = options.isSet("enableNullRestrictedTypes"); + this.allowNullRestrictedTypes = (!preview.isPreview(Source.Feature.NULL_RESTRICTED_TYPES) || preview.isEnabled()) && + Source.Feature.NULL_RESTRICTED_TYPES.allowedInSource(source); } /** The currently enclosing class. @@ -4401,7 +4402,7 @@ public void visitNewArray(JCNewArray tree) { noOfDims++; } tree.elems = translate(tree.elems, types.elemtype(tree.type)); - if (!enableNullRestrictedTypes || tree.elemtype == null || !originalElemType.type.isNonNullable()) { + if (!allowNullRestrictedTypes || tree.elemtype == null || !originalElemType.type.isNonNullable()) { result = tree; } else { Symbol elemClass = syms.getClassField(tree.elemtype.type, types); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java index c106f5bb7c5..7723bd4f70d 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java @@ -83,7 +83,7 @@ public class ClassWriter extends ClassFile { /** Switch: are null-restricted types allowed */ - private boolean enableNullRestrictedTypes; + private boolean allowNullRestrictedTypes; /** Switch: generate CharacterRangeTable attribute. */ @@ -197,7 +197,8 @@ protected ClassWriter(Context context) { dumpInnerClassModifiers = modifierFlags.indexOf('i') != -1; dumpMethodModifiers = modifierFlags.indexOf('m') != -1; } - enableNullRestrictedTypes = options.isSet("enableNullRestrictedTypes"); + allowNullRestrictedTypes = (!preview.isPreview(Source.Feature.NULL_RESTRICTED_TYPES) || preview.isEnabled()) && + Source.Feature.NULL_RESTRICTED_TYPES.allowedInSource(source); } public void addExtraAttributes(ToIntFunction addExtraAttributes) { @@ -959,7 +960,7 @@ int writePermittedSubclassesIfNeeded(ClassSymbol csym) { /** Write "ImplicitCreation" attribute. */ int writeImplicitCreationIfNeeded(ClassSymbol csym) { - if (enableNullRestrictedTypes && csym.isValueClass() && csym.hasImplicitConstructor()) { + if (allowNullRestrictedTypes && csym.isValueClass() && csym.hasImplicitConstructor()) { int alenIdx = writeAttr(names.ImplicitCreation); int flags = /*ACC_DEFAULT |*/ (csym.isSubClass(syms.looselyConsistentValueType.tsym, types) ? ACC_NON_ATOMIC : 0); databuf.appendChar(flags); @@ -972,9 +973,12 @@ int writeImplicitCreationIfNeeded(ClassSymbol csym) { /** Write "NullRestricted" attribute. */ int writeNullRestrictedIfNeeded(Symbol sym) { - if (enableNullRestrictedTypes && sym.kind == VAR && sym.type.isNonNullable() && !sym.type.hasTag(ARRAY)) { + if (allowNullRestrictedTypes && sym.kind == VAR && sym.type.isNonNullable() && !sym.type.hasTag(ARRAY)) { int alenIdx = writeAttr(names.NullRestricted); endAttr(alenIdx); + if (preview.isPreview(Source.Feature.VALUE_CLASSES)) { + preview.markUsesPreview(null); + } return 1; } return 0; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java index 94425fbb60e..5ae81e85507 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -195,7 +195,8 @@ protected JavacParser(ParserFactory fac, this.allowSealedTypes = Feature.SEALED_CLASSES.allowedInSource(source); this.allowValueClasses = (!preview.isPreview(Feature.VALUE_CLASSES) || preview.isEnabled()) && Feature.VALUE_CLASSES.allowedInSource(source); - this.enableNullRestrictedTypes = fac.options.isSet("enableNullRestrictedTypes"); + this.allowNullRestrictedTypes = (!preview.isPreview(Feature.NULL_RESTRICTED_TYPES) || preview.isEnabled()) && + Feature.NULL_RESTRICTED_TYPES.allowedInSource(source); } /** Construct a parser from an existing parser, with minimal overhead. @@ -221,7 +222,8 @@ protected JavacParser(JavacParser parser, this.allowSealedTypes = Feature.SEALED_CLASSES.allowedInSource(source); this.allowValueClasses = (!preview.isPreview(Feature.VALUE_CLASSES) || preview.isEnabled()) && Feature.VALUE_CLASSES.allowedInSource(source); - this.enableNullRestrictedTypes = parser.enableNullRestrictedTypes; + this.allowNullRestrictedTypes = (!preview.isPreview(Feature.NULL_RESTRICTED_TYPES) || preview.isEnabled()) && + Feature.NULL_RESTRICTED_TYPES.allowedInSource(source); } protected AbstractEndPosTable newEndPosTable(boolean keepEndPositions) { @@ -269,7 +271,7 @@ protected DocCommentTable newDocCommentTable(boolean keepDocComments, ParserFact /** Switch: are null-restricted types allowed? */ - boolean enableNullRestrictedTypes; + boolean allowNullRestrictedTypes; /** The type of the method receiver, as specified by a first "this" parameter. */ @@ -707,7 +709,7 @@ public JCExpression qualident(boolean allowAnnos) { t = toP(F.at(tyannos.head.pos).AnnotatedType(tyannos, t)); } } - if (enableNullRestrictedTypes && EMOTIONAL_QUALIFIER.test(token.kind)) { + if (allowNullRestrictedTypes && EMOTIONAL_QUALIFIER.test(token.kind)) { setNullMarker(t); nextToken(); } @@ -1185,7 +1187,7 @@ JCExpression term2Rest(JCExpression t, int minprec) { JCModifiers mods = optFinal(0); int typePos = token.pos; JCExpression type = unannotatedType(false, NOQUES | TYPE); - if (enableNullRestrictedTypes && token.kind == QUES && EMOTIONAL_QUALIFIER.test(token.kind)) { + if (allowNullRestrictedTypes && token.kind == QUES && EMOTIONAL_QUALIFIER.test(token.kind)) { if (peekToken(IDENTIFIER, COMMA) || peekToken(IDENTIFIER, SEMI) || peekToken(IDENTIFIER, RPAREN) || peekToken(IDENTIFIER, INSTANCEOF_INFIX)) { setNullMarker(type); @@ -1518,7 +1520,7 @@ protected JCExpression term3() { t = lambdaExpressionOrStatement(false, false, pos); } else { t = toP(F.at(token.pos).Ident(ident())); - if (enableNullRestrictedTypes && EMOTIONAL_QUALIFIER.test(token.kind) && (peekToken(LBRACKET) || peekToken(LT))) { + if (allowNullRestrictedTypes && EMOTIONAL_QUALIFIER.test(token.kind) && (peekToken(LBRACKET) || peekToken(LT))) { emotionalMarkersOK = true; selectTypeMode(); setNullMarker(t); @@ -1543,7 +1545,7 @@ protected JCExpression term3() { if (annos.nonEmpty()) { t = toP(F.at(pos).AnnotatedType(annos, t)); } - if (enableNullRestrictedTypes && EMOTIONAL_QUALIFIER.test(token.kind)) { + if (allowNullRestrictedTypes && EMOTIONAL_QUALIFIER.test(token.kind)) { setNullMarker(t); nextToken(); } @@ -1674,7 +1676,7 @@ protected JCExpression term3() { } } if (typeArgs != null) illegal(); - if (enableNullRestrictedTypes && EMOTIONAL_QUALIFIER.test(token.kind) && (token.kind == QUES || token.kind == BANG || (token.kind == STAR))) { + if (allowNullRestrictedTypes && EMOTIONAL_QUALIFIER.test(token.kind) && (token.kind == QUES || token.kind == BANG || (token.kind == STAR))) { if (peekToken(LBRACKET) || peekToken(LT) || emotionalMarkersOK) { selectTypeMode(); setNullMarker(t); @@ -1800,7 +1802,7 @@ JCExpression term3Rest(JCExpression t, List typeArgs) { int pos1 = token.pos; final List annos = typeAnnotationsOpt(); - if (enableNullRestrictedTypes && isMode(TYPE) && typeArgs == null && EMOTIONAL_QUALIFIER.test(token.kind) && + if (allowNullRestrictedTypes && isMode(TYPE) && typeArgs == null && EMOTIONAL_QUALIFIER.test(token.kind) && (t instanceof JCIdent || t instanceof JCFieldAccess || t instanceof JCArrayTypeTree)) { setNullMarker(t); selectTypeMode(); @@ -1814,7 +1816,7 @@ JCExpression term3Rest(JCExpression t, List typeArgs) { nextToken(); t = bracketsOpt(t); t = toP(F.at(pos1).TypeArray(t)); - if (enableNullRestrictedTypes && isMode(TYPE) && EMOTIONAL_QUALIFIER.test(token.kind)) { + if (allowNullRestrictedTypes && isMode(TYPE) && EMOTIONAL_QUALIFIER.test(token.kind)) { setNullMarker(t); nextToken(); } @@ -1907,6 +1909,7 @@ void setNullMarker(JCExpression exp) { } void setNullMarker(JCExpression exp, Token tk) { + checkSourceLevel(Feature.NULL_RESTRICTED_TYPES); ((JCNullableTypeExpression)exp).setNullMarker( tk.kind == QUES ? NullMarker.NULLABLE : @@ -2047,14 +2050,14 @@ ParensResult analyzeParens() { if (peekToken(lookahead, LAX_IDENTIFIER)) { // Identifier, Identifier/'_'/'assert'/'enum' -> explicit lambda return ParensResult.EXPLICIT_LAMBDA; - } else if (enableNullRestrictedTypes && (peekToken(lookahead, EMOTIONAL_QUALIFIER, LAX_IDENTIFIER, COMMA) || + } else if (allowNullRestrictedTypes && (peekToken(lookahead, EMOTIONAL_QUALIFIER, LAX_IDENTIFIER, COMMA) || peekToken(lookahead, EMOTIONAL_QUALIFIER, LAX_IDENTIFIER, RPAREN, ARROW))) { // Identifier, '!'/'?', Identifier/'_'/'assert'/'enum', ','/')' -> explicit lambda return ParensResult.EXPLICIT_LAMBDA; - } else if (enableNullRestrictedTypes && peekToken(lookahead, EMOTIONAL_QUALIFIER, RPAREN)) { + } else if (allowNullRestrictedTypes && peekToken(lookahead, EMOTIONAL_QUALIFIER, RPAREN)) { // this must be a cast with emotional type return ParensResult.CAST; - } else if (enableNullRestrictedTypes && (peekToken(lookahead, EMOTIONAL_QUALIFIER, GENERIC_TYPE_END) || + } else if (allowNullRestrictedTypes && (peekToken(lookahead, EMOTIONAL_QUALIFIER, GENERIC_TYPE_END) || peekToken(lookahead, EMOTIONAL_QUALIFIER, LT) || peekToken(lookahead, EMOTIONAL_QUALIFIER, COMMA) || peekToken(lookahead, EMOTIONAL_QUALIFIER, LBRACKET)) ) { @@ -2084,13 +2087,13 @@ ParensResult analyzeParens() { // '[', ']', Identifier/'_'/'assert'/'enum' -> explicit lambda return ParensResult.EXPLICIT_LAMBDA; } else if (peekToken(lookahead, RBRACKET, RPAREN) || - (enableNullRestrictedTypes && peekToken(lookahead, RBRACKET, EMOTIONAL_QUALIFIER, RPAREN)) || + (allowNullRestrictedTypes && peekToken(lookahead, RBRACKET, EMOTIONAL_QUALIFIER, RPAREN)) || peekToken(lookahead, RBRACKET, AMP)) { // '[', ']', ')' -> cast // '[', ']', '!', ')' -> cast // '[', ']', '&' -> cast (intersection type) return ParensResult.CAST; - } else if (enableNullRestrictedTypes && peekToken(lookahead, RBRACKET, EMOTIONAL_QUALIFIER)) { + } else if (allowNullRestrictedTypes && peekToken(lookahead, RBRACKET, EMOTIONAL_QUALIFIER)) { //consume the ']' and the '!' and skip type = true; lookahead++; @@ -2114,7 +2117,7 @@ ParensResult analyzeParens() { depth--; if (depth == 0) { if (peekToken(lookahead, RPAREN) || - (enableNullRestrictedTypes && peekToken(lookahead, EMOTIONAL_QUALIFIER, RPAREN)) || + (allowNullRestrictedTypes && peekToken(lookahead, EMOTIONAL_QUALIFIER, RPAREN)) || peekToken(lookahead, AMP)) { // '>', ')' -> cast // '>', '&' -> cast @@ -2517,7 +2520,7 @@ private JCExpression bracketsOpt(JCExpression t, int pos = token.pos; nextToken(); t = bracketsOptCont(t, pos, nextLevelAnnotations); - } else if (enableNullRestrictedTypes && EMOTIONAL_QUALIFIER.test(token.kind) && peekToken(LBRACKET)) { + } else if (allowNullRestrictedTypes && EMOTIONAL_QUALIFIER.test(token.kind) && peekToken(LBRACKET)) { Token nullMarker = token; nextToken(); int pos = token.pos; @@ -3475,13 +3478,13 @@ PatternResult analyzePattern(int lookahead) { } } else if (typeDepth == 0 && parenDepth == 0 && (peekToken(lookahead, tk -> tk == ARROW || tk == COMMA))) { return PatternResult.EXPRESSION; - } else if (typeDepth == 0 && enableNullRestrictedTypes && + } else if (typeDepth == 0 && allowNullRestrictedTypes && ((peekToken(lookahead, EMOTIONAL_QUALIFIER, LAX_IDENTIFIER, COMMA) || peekToken(lookahead, EMOTIONAL_QUALIFIER, LAX_IDENTIFIER, ARROW) || peekToken(lookahead, EMOTIONAL_QUALIFIER, LAX_IDENTIFIER, COLON))) ) { // this is a type test pattern return PatternResult.PATTERN; - } else if ( enableNullRestrictedTypes && + } else if ( allowNullRestrictedTypes && (peekToken(lookahead, EMOTIONAL_QUALIFIER, GENERIC_TYPE_END) || peekToken(lookahead, EMOTIONAL_QUALIFIER, LT) || peekToken(lookahead, EMOTIONAL_QUALIFIER, COMMA)) ) { @@ -3503,7 +3506,7 @@ PatternResult analyzePattern(int lookahead) { } break; case BANG: - if (enableNullRestrictedTypes && !peekToken(lookahead, LPAREN)) break; + if (allowNullRestrictedTypes && !peekToken(lookahead, LPAREN)) break; case DOT, QUES, EXTENDS, SUPER, COMMA: break; case LT: typeDepth++; break; case GTGTGT: typeDepth--; @@ -3685,7 +3688,7 @@ protected JCModifiers modifiersOpt(JCModifiers partial) { flag = Flags.VALUE_CLASS; break; } - if (enableNullRestrictedTypes && isImplicitModifier()) { + if (isImplicitModifier()) { flag = Flags.IMPLICIT; break; } @@ -3963,7 +3966,7 @@ Source restrictedTypeNameStartingAtSource(Name name, int pos, boolean shouldWarn } } if (name == names.implicit) { - if (enableNullRestrictedTypes && allowValueClasses) { + if (allowValueClasses) { return Source.JDK23; } else if (shouldWarn) { log.warning(pos, Warnings.RestrictedTypeNotAllowedPreview(name, Source.JDK18)); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index 601dfa84406..45ae8f0aa0b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -3240,8 +3240,8 @@ compiler.misc.feature.implicit.classes=\ compiler.misc.feature.super.init=\ statements before super() -compiler.misc.feature.bang.types=\ - bang types +compiler.misc.feature.null.restricted.types=\ + nullable and null restricted types compiler.warn.underscore.as.identifier=\ as of release 9, ''_'' is a keyword, and may not be used as an identifier diff --git a/test/langtools/jdk/javadoc/doclet/testValueClasses/TestValueClasses.java b/test/langtools/jdk/javadoc/doclet/testValueClasses/TestValueClasses.java index a211e92d86d..bedad142931 100644 --- a/test/langtools/jdk/javadoc/doclet/testValueClasses/TestValueClasses.java +++ b/test/langtools/jdk/javadoc/doclet/testValueClasses/TestValueClasses.java @@ -115,7 +115,6 @@ public value class ValueClassWithImplicitConst { javadoc("-d", base.resolve("out").toString(), "--enable-preview", "-source", String.valueOf(Runtime.version().feature()), "-sourcepath", src.toString(), - "-XDenableNullRestrictedTypes", "p"); checkExit(Exit.OK); diff --git a/test/langtools/tools/javac/diags/examples.not-yet.txt b/test/langtools/tools/javac/diags/examples.not-yet.txt index 7217d485ee0..61838c708e9 100644 --- a/test/langtools/tools/javac/diags/examples.not-yet.txt +++ b/test/langtools/tools/javac/diags/examples.not-yet.txt @@ -224,7 +224,7 @@ compiler.warn.restricted.method compiler.misc.feature.value.classes #nullable types -compiler.misc.feature.bang.types +compiler.misc.feature.null.restricted.types compiler.warn.accessing.member.of.nullable compiler.warn.narrowing.nullness.conversion compiler.warn.non.nullable.should.be.initialized diff --git a/test/langtools/tools/javac/diags/examples/CantBeNonNullableType.java b/test/langtools/tools/javac/diags/examples/CantBeNonNullableType.java index 555081660f8..3a994a9cb53 100644 --- a/test/langtools/tools/javac/diags/examples/CantBeNonNullableType.java +++ b/test/langtools/tools/javac/diags/examples/CantBeNonNullableType.java @@ -23,7 +23,9 @@ // key: compiler.err.type.cant.be.null.restricted // key: compiler.err.type.cant.be.null.restricted.2 -// options: -XDenableNullRestrictedTypes +// key: compiler.note.preview.filename +// key: compiler.note.preview.recompile +// options: --enable-preview -source ${jdk.version} public class CantBeNonNullableType { String! s; diff --git a/test/langtools/tools/javac/diags/examples/CantImplementInterface.java b/test/langtools/tools/javac/diags/examples/CantImplementInterface.java index 4d96649fc97..7d57528ed7a 100644 --- a/test/langtools/tools/javac/diags/examples/CantImplementInterface.java +++ b/test/langtools/tools/javac/diags/examples/CantImplementInterface.java @@ -22,7 +22,7 @@ */ // key: compiler.err.cant.implement.interface -// options: --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes +// options: --enable-preview -source ${jdk.version} class CantImplementInterface implements LooselyConsistentValue { } diff --git a/test/langtools/tools/javac/diags/examples/ImplicitConstructorWithBody.java b/test/langtools/tools/javac/diags/examples/ImplicitConstructorWithBody.java index 2f9df889c4e..870294f7f0e 100644 --- a/test/langtools/tools/javac/diags/examples/ImplicitConstructorWithBody.java +++ b/test/langtools/tools/javac/diags/examples/ImplicitConstructorWithBody.java @@ -24,7 +24,7 @@ // key: compiler.err.implicit.const.cant.have.body // key: compiler.note.preview.filename // key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes +// options: --enable-preview -source ${jdk.version} value class ImplicitConstructorWithBody { public implicit ImplicitConstructorWithBody() {} diff --git a/test/langtools/tools/javac/diags/examples/ImplicitMustBeInValueClass.java b/test/langtools/tools/javac/diags/examples/ImplicitMustBeInValueClass.java index a8002eb39d4..cc5b2a35da1 100644 --- a/test/langtools/tools/javac/diags/examples/ImplicitMustBeInValueClass.java +++ b/test/langtools/tools/javac/diags/examples/ImplicitMustBeInValueClass.java @@ -24,7 +24,7 @@ // key: compiler.err.implicit.const.must.be.declared.in.value.class // key: compiler.note.preview.filename // key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes +// options: --enable-preview -source ${jdk.version} class ImplicitMustBeInValueClass { public implicit ImplicitMustBeInValueClass(); diff --git a/test/langtools/tools/javac/diags/examples/ImplicitMustBePublic.java b/test/langtools/tools/javac/diags/examples/ImplicitMustBePublic.java index 63d701cffd6..dbdace0636b 100644 --- a/test/langtools/tools/javac/diags/examples/ImplicitMustBePublic.java +++ b/test/langtools/tools/javac/diags/examples/ImplicitMustBePublic.java @@ -24,7 +24,7 @@ // key: compiler.err.implicit.const.must.be.public // key: compiler.note.preview.filename // key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes +// options: --enable-preview -source ${jdk.version} value class ImplicitMustBePublic { implicit ImplicitMustBePublic(); diff --git a/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCannotBeInner.java b/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCannotBeInner.java index 17283d04d3b..f2fb1732539 100644 --- a/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCannotBeInner.java +++ b/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCannotBeInner.java @@ -24,7 +24,7 @@ // key: compiler.err.value.class.with.implicit.cannot.be.inner // key: compiler.note.preview.filename // key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes +// options: --enable-preview -source ${jdk.version} class ValueClassWithImplicitCannotBeInner { value class V { diff --git a/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCantDeclareInitBlock.java b/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCantDeclareInitBlock.java index 8652ce2656d..22814c87139 100644 --- a/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCantDeclareInitBlock.java +++ b/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCantDeclareInitBlock.java @@ -24,7 +24,7 @@ // key: compiler.err.value.class.with.implicit.declares.init.block // key: compiler.note.preview.filename // key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes +// options: --enable-preview -source ${jdk.version} value class ValueClassWithImplicitCantDeclareInitBlock { int i; diff --git a/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCantHaveFieldInit.java b/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCantHaveFieldInit.java index 19a6536356d..ddab5b694a7 100644 --- a/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCantHaveFieldInit.java +++ b/test/langtools/tools/javac/diags/examples/ValueClassWithImplicitCantHaveFieldInit.java @@ -24,7 +24,7 @@ // key: compiler.err.value.class.with.implicit.instance.field.initializer // key: compiler.note.preview.filename // key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes -XDenableNullRestrictedTypes +// options: --enable-preview -source ${jdk.version} value class ValueClassWithImplicitCantHaveFieldInit { int i = 0; diff --git a/test/langtools/tools/javac/nullability/NullRestrictedAttrTest.java b/test/langtools/tools/javac/nullability/NullRestrictedAttrTest.java new file mode 100644 index 00000000000..23c0c625111 --- /dev/null +++ b/test/langtools/tools/javac/nullability/NullRestrictedAttrTest.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8338766 + * @summary [lw5] remove option enableNullRestrictedTypes and make null-restricted types a preview feature + * @library /tools/lib + * @modules + * jdk.compiler/com.sun.tools.javac.code + * jdk.compiler/com.sun.tools.javac.util + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.file + * jdk.compiler/com.sun.tools.javac.main + * jdk.jdeps/com.sun.tools.classfile + * @build toolbox.ToolBox toolbox.JavacTask + * @run main NullRestrictedAttrTest + * @ignore support for the NullRestricted attribute is missing in javap, class library etc + */ + +import java.nio.file.Path; +import java.nio.file.Paths; + +import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.util.Assert; +import com.sun.tools.classfile.ClassFile; + +import toolbox.TestRunner; +import toolbox.ToolBox; +import toolbox.JavacTask; +import toolbox.Task; + +public class NullRestrictedAttrTest extends TestRunner { + ToolBox tb = new ToolBox(); + + public NullRestrictedAttrTest() { + super(System.err); + } + + protected void runTests() throws Exception { + runTests(m -> new Object[] { Paths.get(m.getName()) }); + } + + Path[] findJavaFiles(Path... paths) throws Exception { + return tb.findJavaFiles(paths); + } + + public static void main(String... args) throws Exception { + new NullRestrictedAttrTest().runTests(); + } + + @Test + public void testLoadableDescField(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + value class V { + public implicit V(); + } + class Test { + V! v1; + void m(V! v) { + v1 = v; + } + } + """); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + new toolbox.JavacTask(tb) + .options("--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .outdir(classes) + .files(findJavaFiles(src)) + .run() + .writeAll(); + Path classFilePath = classes.resolve("Test.class"); + ClassFile classFile = ClassFile.read(classFilePath.toFile()); + Assert.check(classFile.minor_version == 65535); + Assert.check(classFile.attributes.get("NullRestricted") != null); + } +} diff --git a/test/langtools/tools/javac/nullability/NullabilityParsingTest.java b/test/langtools/tools/javac/nullability/NullabilityParsingTest.java index 87dfeaf0436..7a2d480289e 100644 --- a/test/langtools/tools/javac/nullability/NullabilityParsingTest.java +++ b/test/langtools/tools/javac/nullability/NullabilityParsingTest.java @@ -27,7 +27,7 @@ * @test * @enablePreview * @summary Smoke test for parsing of bang types - * @compile -XDenableNullRestrictedTypes NullabilityParsingTest.java + * @compile NullabilityParsingTest.java */ import java.util.function.*; diff --git a/test/langtools/tools/javac/nullability/RuntimeNullChecks.java b/test/langtools/tools/javac/nullability/RuntimeNullChecks.java index d0c5c5587c8..dafa268b855 100644 --- a/test/langtools/tools/javac/nullability/RuntimeNullChecks.java +++ b/test/langtools/tools/javac/nullability/RuntimeNullChecks.java @@ -32,7 +32,7 @@ * jdk.jdeps/com.sun.tools.classfile * @build toolbox.ToolBox toolbox.JavacTask * @run main RuntimeNullChecks - * @ignore 8316628 + * @ignore */ import java.util.*; diff --git a/test/langtools/tools/javac/valhalla/value-objects/CanonicalCtorTest.java b/test/langtools/tools/javac/valhalla/value-objects/CanonicalCtorTest.java index 86653de6470..1003b7aae0c 100644 --- a/test/langtools/tools/javac/valhalla/value-objects/CanonicalCtorTest.java +++ b/test/langtools/tools/javac/valhalla/value-objects/CanonicalCtorTest.java @@ -24,7 +24,7 @@ /** * @test * @bug 8208067 - * @compile --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes CanonicalCtorTest.java + * @compile --enable-preview -source ${jdk.version} CanonicalCtorTest.java * @summary Verify that instance methods are callable from ctor after all instance fields are DA. */ diff --git a/test/langtools/tools/javac/valhalla/value-objects/classfile/implicit_creation_attr/CheckImplicitCreationAttrIsUnique.java b/test/langtools/tools/javac/valhalla/value-objects/classfile/implicit_creation_attr/CheckImplicitCreationAttrIsUnique.java index 114bac630fd..b82182576ee 100644 --- a/test/langtools/tools/javac/valhalla/value-objects/classfile/implicit_creation_attr/CheckImplicitCreationAttrIsUnique.java +++ b/test/langtools/tools/javac/valhalla/value-objects/classfile/implicit_creation_attr/CheckImplicitCreationAttrIsUnique.java @@ -5,7 +5,7 @@ * jdk.compiler/com.sun.tools.javac.util * @library /tools/lib * @compile DuplicateImplicitCreationAttr.jcod - * @compile/fail/ref=CheckImplicitCreationAttrIsUnique.out --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes -XDrawDiagnostics CheckImplicitCreationAttrIsUnique.java + * @compile/fail/ref=CheckImplicitCreationAttrIsUnique.out --enable-preview -source ${jdk.version} -XDrawDiagnostics CheckImplicitCreationAttrIsUnique.java */ public class CheckImplicitCreationAttrIsUnique { diff --git a/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/attr_is_unique/CheckNullRestrictedAttrIsUnique.java b/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/attr_is_unique/CheckNullRestrictedAttrIsUnique.java index 95eb02cbfa2..541e0037586 100644 --- a/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/attr_is_unique/CheckNullRestrictedAttrIsUnique.java +++ b/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/attr_is_unique/CheckNullRestrictedAttrIsUnique.java @@ -4,8 +4,8 @@ * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.javac.util * @library /tools/lib - * @compile --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes ValueClass.jcod DuplicateNullRestrictedAttr.jcod - * @compile/fail/ref=CheckNullRestrictedAttrIsUnique.out --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes -XDrawDiagnostics CheckNullRestrictedAttrIsUnique.java + * @compile --enable-preview -source ${jdk.version} ValueClass.jcod DuplicateNullRestrictedAttr.jcod + * @compile/fail/ref=CheckNullRestrictedAttrIsUnique.out --enable-preview -source ${jdk.version} -XDrawDiagnostics CheckNullRestrictedAttrIsUnique.java */ public class CheckNullRestrictedAttrIsUnique { diff --git a/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/check_field_type/CheckFieldTypeTest.java b/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/check_field_type/CheckFieldTypeTest.java index 9cfa880dd68..ded6268682f 100644 --- a/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/check_field_type/CheckFieldTypeTest.java +++ b/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/check_field_type/CheckFieldTypeTest.java @@ -4,8 +4,8 @@ * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.javac.util * @library /tools/lib - * @compile --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes NullRestrictedOnPrimitive.jcod - * @compile/fail/ref=CheckFieldTypeTest.out --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes -XDrawDiagnostics CheckFieldTypeTest.java + * @compile --enable-preview -source ${jdk.version} NullRestrictedOnPrimitive.jcod + * @compile/fail/ref=CheckFieldTypeTest.out --enable-preview -source ${jdk.version} -XDrawDiagnostics CheckFieldTypeTest.java */ public class CheckFieldTypeTest { diff --git a/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/check_field_type/CheckFieldTypeTest2.java b/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/check_field_type/CheckFieldTypeTest2.java index 02fb0f81157..2065a28fc63 100644 --- a/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/check_field_type/CheckFieldTypeTest2.java +++ b/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/check_field_type/CheckFieldTypeTest2.java @@ -4,8 +4,8 @@ * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.javac.util * @library /tools/lib - * @compile --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes NullRestrictedOnArray.jcod - * @compile/fail/ref=CheckFieldTypeTest2.out --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes -XDrawDiagnostics CheckFieldTypeTest2.java + * @compile --enable-preview -source ${jdk.version} NullRestrictedOnArray.jcod + * @compile/fail/ref=CheckFieldTypeTest2.out --enable-preview -source ${jdk.version} -XDrawDiagnostics CheckFieldTypeTest2.java */ public class CheckFieldTypeTest2 { diff --git a/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/only_on_fields/NullRestrictedAttrOnlyOnFields.java b/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/only_on_fields/NullRestrictedAttrOnlyOnFields.java index 7a3e8111a57..e4006d81851 100644 --- a/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/only_on_fields/NullRestrictedAttrOnlyOnFields.java +++ b/test/langtools/tools/javac/valhalla/value-objects/classfile/null_restricted_attr/only_on_fields/NullRestrictedAttrOnlyOnFields.java @@ -4,8 +4,8 @@ * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.javac.util * @library /tools/lib - * @compile --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes NullRestrictedOnMethod.jcod - * @compile/fail/ref=NullRestrictedAttrOnlyOnFields.out --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes -XDrawDiagnostics NullRestrictedAttrOnlyOnFields.java + * @compile --enable-preview -source ${jdk.version} NullRestrictedOnMethod.jcod + * @compile/fail/ref=NullRestrictedAttrOnlyOnFields.out --enable-preview -source ${jdk.version} -XDrawDiagnostics NullRestrictedAttrOnlyOnFields.java */ public class NullRestrictedAttrOnlyOnFields { diff --git a/test/langtools/tools/javac/valhalla/value-objects/cycles/CheckForCyclesAtClassLoadingTimeTest.java b/test/langtools/tools/javac/valhalla/value-objects/cycles/CheckForCyclesAtClassLoadingTimeTest.java index b2e3b6dc958..e6d363163ea 100644 --- a/test/langtools/tools/javac/valhalla/value-objects/cycles/CheckForCyclesAtClassLoadingTimeTest.java +++ b/test/langtools/tools/javac/valhalla/value-objects/cycles/CheckForCyclesAtClassLoadingTimeTest.java @@ -2,8 +2,8 @@ * @test /nodynamiccopyright/ * @bug 8314165 * @summary check for illegal circularity at class loading time - * @compile --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes CyclicValueClass.jcod - * @compile/fail/ref=CheckForCyclesAtClassLoadingTimeTest.out --enable-preview -source ${jdk.version} -XDenableNullRestrictedTypes -XDrawDiagnostics CheckForCyclesAtClassLoadingTimeTest.java + * @compile --enable-preview -source ${jdk.version} CyclicValueClass.jcod + * @compile/fail/ref=CheckForCyclesAtClassLoadingTimeTest.out --enable-preview -source ${jdk.version} -XDrawDiagnostics CheckForCyclesAtClassLoadingTimeTest.java * @ignore */ class CheckForCyclesAtClassLoadingTimeTest {