diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java index 614b4cdbb2b..09838056940 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java @@ -139,11 +139,6 @@ public static EnumSet<Flag> asFlagSet(long flags) { */ public static final int EMPTYNOARGCONSTR = 1<<18; - /** - * Flag is set for a reference favoring primitive class. - */ - public static final int REFERENCE_FAVORING = 1<<19; - /** Flag is set for compiler-generated anonymous method symbols * that `own' an initializer block. */ @@ -412,11 +407,6 @@ public static EnumSet<Flag> asFlagSet(long flags) { */ public static final long NON_SEALED = 1L<<63; // ClassSymbols - // Encodings for extended flags stored using attributes - /** - * Flag to indicate that the primitive class is reference default. - */ - public static final int ACC_REF_DEFAULT = 1; /** Modifier masks. */ @@ -511,7 +501,6 @@ public enum Flag { HASINIT(Flags.HASINIT), HASINITBLOCK(Flags.HASINITBLOCK), EMPTYNOARGCONSTR(Flags.EMPTYNOARGCONSTR), - REFERENCE_FAVORING(Flags.REFERENCE_FAVORING), BLOCK(Flags.BLOCK), ENUM(Flags.ENUM), MANDATED(Flags.MANDATED), diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Printer.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Printer.java index 5d4fc9fa4c1..12e63cac066 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Printer.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Printer.java @@ -234,18 +234,16 @@ public String visitClassType(ClassType t, Locale locale) { buf.append(printAnnotations(t)); buf.append(className(t, true, locale)); } + boolean isReferenceProjection; try { - if (t.isReferenceProjection()) { - buf.append('.'); - buf.append(t.tsym.name.table.names.ref); - } else if (t.isValueProjection()) { - buf.append('.'); - buf.append(t.tsym.name.table.names.val); - } + isReferenceProjection = t.isReferenceProjection(); } catch (CompletionFailure cf) { - // don't let missing types capsize the boat. + isReferenceProjection = false; // handle missing types gracefully. + } + if (isReferenceProjection) { + buf.append('.'); + buf.append(t.tsym.name.table.names.ref); } - if (t.getTypeArguments().nonEmpty()) { buf.append('<'); buf.append(visitTypes(t.getTypeArguments(), locale)); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java index bb7f302a5ee..bdd63982323 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java @@ -416,14 +416,6 @@ public boolean isPrivate() { return (flags_field & Flags.AccessFlags) == PRIVATE; } - public boolean isSynthetic() { - return (flags_field & SYNTHETIC) != 0; - } - - public boolean isReferenceFavoringPrimitiveClass() { - return (flags() & REFERENCE_FAVORING) != 0; // bit set only for primitive classes - } - public boolean isPrimitiveClass() { return (flags() & PRIMITIVE_CLASS) != 0; } @@ -1437,7 +1429,7 @@ public void complete() throws CompletionFailure { } finally { if (this.type != null && this.type.hasTag(CLASS)) { ClassType ct = (ClassType) this.type; - ct.flavor = ct.flavor.metamorphose(this.flags_field); + ct.flavor = ct.flavor.metamorphose((this.flags_field & PRIMITIVE_CLASS) != 0); if (!this.type.isIntersection() && this.erasure_field != null && this.erasure_field.hasTag(CLASS)) { ((ClassType) this.erasure_field).flavor = ct.flavor; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java index 2331acbcc82..c42264ba5d6 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java @@ -250,34 +250,18 @@ public Flavor getFlavor() { } /** - * @return true IFF the receiver is a reference projection type of a *value favoring* primitive class - * and false otherwise. + * @return true IFF the receiver is a reference projection of a primitive class type and false + * for primitives or plain references */ public boolean isReferenceProjection() { return false; } /** - * @return true IFF the receiver is a primitive reference type and false otherwise. - */ - public boolean isPrimitiveReferenceType() { - return false; - } - - /** - * @return true IFF the receiver is a value projection of a *reference favoring* primitive class type - * and false otherwise. - */ - public boolean isValueProjection() { - return false; - } - - /** - * Returns the ClassType representing the primitive value type - * of this type, if the class of this type is a primitive class - * null otherwise + * @return the value projection type IFF the receiver is a reference projection of a primitive class type + * and null otherwise */ - public ClassType asValueType() { + public Type valueProjection() { return null; } @@ -1057,8 +1041,8 @@ public enum Flavor { L_TypeOf_L, /** - * A primitive reference type: (Assosiated primitive class could be either - * reference default or value-default) + * Reference projection type of a primitive-favoring aka primitive-default + * plain vanilla primitive class type, */ L_TypeOf_Q, @@ -1087,8 +1071,7 @@ public enum Flavor { Q_TypeOf_X, /** - * As yet unknown projection type of an as yet unknown default provenance class. Is also - * the terminal flavor for package-info/module-info files. + * As yet unknown projection type of an as yet unknown default provenance class. */ X_Typeof_X, @@ -1100,10 +1083,7 @@ public enum Flavor { // We don't seem to need X_Typeof_L or X_Typeof_Q so far. // Transform a larval form into a more evolved form - public Flavor metamorphose(long classFlags) { - - boolean isPrimtiveClass = (classFlags & PRIMITIVE_CLASS) != 0; - boolean isReferenceFavoring = (classFlags & REFERENCE_FAVORING) != 0; + public Flavor metamorphose(boolean isPrimtiveClass) { switch (this) { @@ -1117,9 +1097,9 @@ public Flavor metamorphose(long classFlags) { case L_TypeOf_X: return isPrimtiveClass ? L_TypeOf_Q : L_TypeOf_L; case Q_TypeOf_X: - return isReferenceFavoring ? Q_TypeOf_L : Q_TypeOf_Q; + return isPrimtiveClass ? Q_TypeOf_Q : Q_TypeOf_L; case X_Typeof_X: - return isPrimtiveClass ? (isReferenceFavoring ? L_TypeOf_Q : Q_TypeOf_Q) : L_TypeOf_L; + return isPrimtiveClass ? Q_TypeOf_Q : L_TypeOf_L; default: throw new AssertionError("Unexpected class type flavor"); } @@ -1232,17 +1212,18 @@ public String toString() { appendAnnotationsString(buf); buf.append(className(tsym, true)); } + + boolean isReferenceProjection; try { - if (isReferenceProjection()) { - buf.append('.'); - buf.append(tsym.name.table.names.ref); - } else if (isValueProjection()) { - buf.append('.'); - buf.append(tsym.name.table.names.val); - } + isReferenceProjection = isReferenceProjection(); } catch (CompletionFailure cf) { - // don't let missing types capsize the boat. + isReferenceProjection = false; // handle missing types gracefully. + } + if (isReferenceProjection) { + buf.append('.'); + buf.append(tsym.name.table.names.ref); } + if (getTypeArguments().nonEmpty()) { buf.append('<'); buf.append(getTypeArguments().toString()); @@ -1305,7 +1286,7 @@ public boolean hasErasedSupertypes() { @DefinedBy(Api.LANGUAGE_MODEL) public Type getEnclosingType() { if (outer_field != null && outer_field.isReferenceProjection()) { - outer_field = outer_field.asValueType(); + outer_field = outer_field.valueProjection(); } return outer_field; } @@ -1340,76 +1321,36 @@ public boolean isReference() { @Override public boolean isPrimitiveClass() { - // guard against over-eager and/or inopportune completion - if (tsym != null) { - if (flavor == Flavor.Q_TypeOf_X || tsym.isCompleted()) { - flavor = flavor.metamorphose(tsym.flags()); - } - } - return flavor == Flavor.Q_TypeOf_Q || flavor == Flavor.Q_TypeOf_L; + return !isReferenceProjection() && tsym != null && tsym.isPrimitiveClass(); } @Override public boolean isReferenceProjection() { - // guard against over-eager and/or inopportune completion + // gaurd against over-eager and/or inopportune completion if (tsym != null) { if (flavor == Flavor.L_TypeOf_X || tsym.isCompleted()) { - flavor = flavor.metamorphose(tsym.flags()); - } - } - return flavor == Flavor.L_TypeOf_Q && tsym.type.getFlavor() == Flavor.Q_TypeOf_Q; // discount reference favoring primitives. - } - - @Override - public boolean isPrimitiveReferenceType() { - // guard against over-eager and/or inopportune completion - if (tsym != null) { - if (flavor == Flavor.L_TypeOf_X || tsym.isCompleted()) { - flavor = flavor.metamorphose(tsym.flags()); + flavor = flavor.metamorphose(tsym.isPrimitiveClass()); } } return flavor == Flavor.L_TypeOf_Q; } @Override - public boolean isValueProjection() { - // guard against over-eager and/or inopportune completion - if (tsym != null) { - if (flavor == Flavor.Q_TypeOf_X || tsym.isCompleted()) { - flavor = flavor.metamorphose(tsym.flags()); + public Type valueProjection() { + if (!isReferenceProjection()) + return null; - } - } - return flavor == Flavor.Q_TypeOf_L; - } + if (projection != null) + return projection; - // return the primitive value type *preserving parameterizations* - @Override - public ClassType asValueType() { - if (tsym == null || !tsym.isPrimitiveClass()) - return null; + projection = new ClassType(outer_field, typarams_field, tsym, getMetadata(), Flavor.Q_TypeOf_Q); + projection.allparams_field = allparams_field; + projection.supertype_field = supertype_field; - switch (flavor) { - case Q_TypeOf_L: - case Q_TypeOf_Q: - return this; - case L_TypeOf_Q: - if (projection != null) - return projection; - - projection = new ClassType(outer_field, typarams_field, tsym, getMetadata(), - tsym.isReferenceFavoringPrimitiveClass() ? Flavor.Q_TypeOf_L : Flavor.Q_TypeOf_Q); - projection.allparams_field = allparams_field; - projection.supertype_field = supertype_field; - - projection.interfaces_field = interfaces_field; - projection.all_interfaces_field = all_interfaces_field; - projection.projection = this; - return projection; - default: - Assert.check(false, "Should not get here"); - return null; - } + projection.interfaces_field = interfaces_field; + projection.all_interfaces_field = all_interfaces_field; + projection.projection = this; + return projection; } // return the reference projection type preserving parameterizations 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 042b2167e62..c17b447befc 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 @@ -43,7 +43,6 @@ import com.sun.tools.javac.code.Attribute.RetentionPolicy; import com.sun.tools.javac.code.Lint.LintCategory; import com.sun.tools.javac.code.Source.Feature; -import com.sun.tools.javac.code.Type.ClassType.Flavor; import com.sun.tools.javac.code.Type.UndetVar.InferenceBound; import com.sun.tools.javac.code.TypeMetadata.Entry.Kind; import com.sun.tools.javac.comp.AttrContext; @@ -1211,8 +1210,7 @@ public Boolean visitClassType(ClassType t, Type s) { // If t is an intersection, sup might not be a class type if (!sup.hasTag(CLASS)) return isSubtypeNoCapture(sup, s); return sup.tsym == s.tsym - && (t.tsym != s.tsym || - (t.isReferenceProjection() == s.isReferenceProjection() && t.isValueProjection() == s.isValueProjection())) + && (t.tsym != s.tsym || t.isReferenceProjection() == s.isReferenceProjection()) // Check type variable containment && (!s.isParameterized() || containsTypeRecursive(s, sup)) && isSubtypeNoCapture(sup.getEnclosingType(), @@ -1459,7 +1457,6 @@ public Boolean visitClassType(ClassType t, Type s) { } return t.tsym == s.tsym && t.isReferenceProjection() == s.isReferenceProjection() - && t.isValueProjection() == s.isValueProjection() && visit(getEnclosingType(t), getEnclosingType(s)) && containsTypeEquivalent(t.getTypeArguments(), s.getTypeArguments()); } @@ -1467,7 +1464,7 @@ && visit(getEnclosingType(t), getEnclosingType(s)) private Type getEnclosingType(Type t) { Type et = t.getEnclosingType(); if (et.isReferenceProjection()) { - et = et.asValueType(); + et = et.valueProjection(); } return et; } @@ -2263,7 +2260,7 @@ public Type asSuper(Type t, Symbol sym) { return null; if (t.hasTag(ARRAY)) return syms.identityObjectType; - if (t.hasTag(CLASS) && !t.tsym.isPrimitiveClass() && !t.tsym.isInterface() && !t.tsym.isAbstract()) { + if (t.hasTag(CLASS) && !t.isReferenceProjection() && !t.tsym.isInterface() && !t.tsym.isAbstract()) { return syms.identityObjectType; } if (implicitIdentityType(t)) { @@ -2626,18 +2623,10 @@ public Type visitWildcardType(WildcardType t, Boolean recurse) { public Type visitClassType(ClassType t, Boolean recurse) { // erasure(projection(primitive)) = projection(erasure(primitive)) Type erased = eraseClassType(t, recurse); - Flavor wantedFlavor = t.flavor; - if (t.isIntersection()) { - IntersectionClassType ict = (IntersectionClassType) t; - Type firstExplicitBound = ict.getExplicitComponents().head; - if (firstExplicitBound.hasTag(CLASS)) - wantedFlavor = firstExplicitBound.getFlavor(); - // Todo: Handle Type variable case. - } - if (erased.hasTag(CLASS) && wantedFlavor != erased.getFlavor()) { + if (erased.hasTag(CLASS) && t.flavor != erased.getFlavor()) { erased = new ClassType(erased.getEnclosingType(), List.nil(), erased.tsym, - erased.getMetadata(), wantedFlavor); + erased.getMetadata(), t.flavor); } return erased; } 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 091e51feca3..f50e06f664f 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 @@ -329,7 +329,7 @@ void checkAssignable(DiagnosticPosition pos, VarSymbol v, JCTree base, Env<AttrC withfield operator -This does not result in mutation of final fields; the code generator would implement `copy on write' semantics via the opcode `withfield'. */ - if (env.info.inWithField && v.getKind() == ElementKind.FIELD && (v.flags() & STATIC) == 0 && v.owner.isPrimitiveClass()) { + if (env.info.inWithField && v.getKind() == ElementKind.FIELD && (v.flags() & STATIC) == 0 && types.isPrimitiveClass(v.owner.type)) { if (env.enclClass.sym.outermostClass() == v.owner.outermostClass()) complain = false; } @@ -1331,7 +1331,7 @@ public void visitVarDef(JCVariableDecl tree) { as these can undergo updates via copy on write. */ if (tree.init != null) { - if ((v.flags_field & FINAL) == 0 || ((v.flags_field & STATIC) == 0 && v.owner.isPrimitiveClass()) || + if ((v.flags_field & FINAL) == 0 || ((v.flags_field & STATIC) == 0 && types.isPrimitiveClass(v.owner.type)) || !memberEnter.needsLazyConstValue(tree.init)) { // Not a compile-time constant // Attribute initializer in a new environment @@ -1534,7 +1534,7 @@ public void visitWithField(JCWithField tree) { if (tree.field.type != null && !tree.field.type.isErroneous()) { final Symbol sym = TreeInfo.symbol(tree.field); if (sym == null || sym.kind != VAR || sym.owner.kind != TYP || - (sym.flags() & STATIC) != 0 || !sym.owner.isPrimitiveClass()) { + (sym.flags() & STATIC) != 0 || !types.isPrimitiveClass(sym.owner.type)) { log.error(tree.field.pos(), Errors.PrimitiveClassInstanceFieldExpectedHere); } else { Type ownType = sym.owner.type; @@ -1548,8 +1548,7 @@ public void visitWithField(JCWithField tree) { ownType = fieldAccess.selected.type; break; } - // withfield always evaluates to the primitive value type. - capturedType = capture(ownType.asValueType()); + capturedType = capture(ownType); } } result = check(tree, capturedType, KindSelector.VAL, resultInfo); @@ -2212,7 +2211,7 @@ Type condType(List<DiagnosticPosition> positions, List<Type> condTypes) { // value conversions bring about a convergence. condTypes = condTypes.stream() .map(t -> t.isPrimitive() ? types.boxedClass(t).type - : t.isPrimitiveReferenceType() ? t.asValueType() : t) + : t.isReferenceProjection() ? t.valueProjection() : t) .collect(List.collector()); for (Type type : condTypes) { @@ -2657,11 +2656,11 @@ public void visitApply(JCMethodInvocation tree) { if (symbol != null) { /* Is this an ill conceived attempt to invoke jlO methods not available on primitive class types ?? */ - boolean superCallOnPrimitiveReceiver = env.enclClass.sym.isPrimitiveClass() + boolean superCallOnPrimitiveReceiver = types.isPrimitiveClass(env.enclClass.sym.type) && (tree.meth.hasTag(SELECT)) && ((JCFieldAccess)tree.meth).selected.hasTag(IDENT) && TreeInfo.name(((JCFieldAccess)tree.meth).selected) == names._super; - if (qualifier.tsym.isPrimitiveClass() || superCallOnPrimitiveReceiver) { + if (types.isPrimitiveClass(qualifier) || superCallOnPrimitiveReceiver) { int argSize = argtypes.size(); Name name = symbol.name; switch (name.toString()) { @@ -2880,12 +2879,9 @@ public void visitNewClass(final JCNewClass tree) { resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE; boolean skipNonDiamondPath = false; // Check that it is an instantiation of a class and not a projection type - JCExpression instantiation = clazz; - if (instantiation.hasTag(TYPEAPPLY)) - instantiation = ((JCTypeApply) instantiation).clazz; - if (instantiation.hasTag(SELECT)) { - JCFieldAccess fieldAccess = (JCFieldAccess) instantiation; - if (fieldAccess.selected.type.tsym.isPrimitiveClass() && + if (clazz.hasTag(SELECT)) { + JCFieldAccess fieldAccess = (JCFieldAccess) clazz; + if (fieldAccess.selected.type.isPrimitiveClass() && (fieldAccess.name == names.ref || fieldAccess.name == names.val)) { log.error(tree.pos(), Errors.ProjectionCantBeInstantiated); } @@ -2979,10 +2975,6 @@ else if (!skipNonDiamondPath) { if (tree.constructor != null && tree.constructor.kind == MTH) owntype = clazztype; } - // For primitive classes construction always returns the value type. - if (owntype.tsym.isPrimitiveClass()) { - owntype = owntype.asValueType(); - } result = check(tree, owntype, KindSelector.VAL, resultInfo); InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext(); if (tree.constructorType != null && inferenceContext.free(tree.constructorType)) { @@ -4561,8 +4553,8 @@ private Symbol selectSym(JCFieldAccess tree, // In this case, we have already made sure in // visitSelect that qualifier expression is a type. return syms.getClassField(site, types); - } else if ((name == names.ref || name == names.val) && site.tsym != null && site.tsym.isPrimitiveClass() && isType(location) && resultInfo.pkind.contains(KindSelector.TYP)) { - return site.tsym; // TODO: JDK-8244229: Need more robust handling of .ref and .val reference in source code + } else if (site.isPrimitiveClass() && isType(location) && resultInfo.pkind.contains(KindSelector.TYP) && (name == names.ref || name == names.val)) { + return site.tsym; } else { // We are seeing a plain identifier as selector. Symbol sym = rs.findIdentInType(pos, env, site, name, resultInfo.pkind); @@ -4673,31 +4665,11 @@ Type checkIdInternal(JCTree tree, chk.checkForBadAuxiliaryClassAccess(tree.pos(), env, (ClassSymbol)sym); Type ownOuter = owntype.getEnclosingType(); - // (a) If symbol is a primitive class and its reference/value projection - // is requested via the .ref/.val notation, then adjust the computed type to + // (a) If symbol is a primitive class and its reference projection + // is requested via the .ref notation, then adjust the computed type to // reflect this. - if (sym.isPrimitiveClass()) { - if (sym.isReferenceFavoringPrimitiveClass()) { - Assert.check(owntype.getFlavor() == Flavor.L_TypeOf_Q); - } else { - Assert.check(owntype.getFlavor() == Flavor.Q_TypeOf_Q); - } - if (tree.hasTag(SELECT)) { - Name name = ((JCFieldAccess)tree).name; - if (name == names.ref) { - if (sym.isReferenceFavoringPrimitiveClass()) { - // We should already be good to go with owntype - } else { - owntype = new ClassType(ownOuter, owntype.getTypeArguments(), (TypeSymbol)sym, owntype.getMetadata(), Flavor.L_TypeOf_Q); - } - } else if (name == names.val) { - if (sym.isReferenceFavoringPrimitiveClass()) { - owntype = new ClassType(ownOuter, owntype.getTypeArguments(), (TypeSymbol)sym, owntype.getMetadata(), Flavor.Q_TypeOf_L); - } else { - // We should already be good to go with owntype - } - } - } + if (owntype.isPrimitiveClass() && tree.hasTag(SELECT) && ((JCFieldAccess) tree).name == names.ref) { + owntype = new ClassType(owntype.getEnclosingType(), owntype.getTypeArguments(), (TypeSymbol)sym, owntype.getMetadata(), Flavor.L_TypeOf_Q); } // (b) If the symbol's type is parameterized, erase it @@ -5403,7 +5375,7 @@ public void attribClass(DiagnosticPosition pos, ClassSymbol c) { try { annotate.flush(); attribClass(c); - if (c.isPrimitiveClass()) { + if (types.isPrimitiveClass(c.type)) { final Env<AttrContext> env = typeEnvs.get(c); if (env != null && env.tree != null && env.tree.hasTag(CLASSDEF)) chk.checkNonCyclicMembership((JCClassDecl)env.tree); 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 76fac8fcc26..d2f700d5c0a 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 @@ -805,12 +805,9 @@ Type checkConstructorRefType(JCExpression expr, Type t) { t = types.createErrorType(t); } else { // Projection types may not be mentioned in constructor references - JCExpression instantiation = expr; - if (instantiation.hasTag(TYPEAPPLY)) - instantiation = ((JCTypeApply) instantiation).clazz; - if (instantiation.hasTag(SELECT)) { - JCFieldAccess fieldAccess = (JCFieldAccess) instantiation; - if (fieldAccess.selected.type.tsym.isPrimitiveClass() && + if (expr.hasTag(SELECT)) { + JCFieldAccess fieldAccess = (JCFieldAccess) expr; + if (fieldAccess.selected.type.isPrimitiveClass() && (fieldAccess.name == names.ref || fieldAccess.name == names.val)) { log.error(expr, Errors.ProjectionCantBeInstantiated); t = types.createErrorType(t); @@ -871,7 +868,7 @@ Type checkRefType(DiagnosticPosition pos, Type t, boolean primitiveClassOK) { */ Type checkIdentityType(DiagnosticPosition pos, Type t) { - if (t.isPrimitive() || t.tsym.isPrimitiveClass()) + if (t.isPrimitive() || t.isPrimitiveClass() || t.isReferenceProjection()) return typeTagError(pos, diags.fragment(Fragments.TypeReqIdentity), t); @@ -1372,7 +1369,7 @@ else if ((sym.owner.flags_field & INTERFACE) != 0) mask = implicit = InterfaceVarFlags; else { mask = VarFlags; - if (sym.owner.isPrimitiveClass() && (flags & STATIC) == 0) { + if (types.isPrimitiveClass(sym.owner.type) && (flags & STATIC) == 0) { implicit |= FINAL; } } @@ -1684,15 +1681,12 @@ public void visitSelect(JCFieldAccess tree) { public void visitSelectInternal(JCFieldAccess tree) { if (tree.type.tsym.isStatic() && tree.selected.type.isParameterized() && - (!tree.type.tsym.isPrimitiveClass() || (tree.name != names.ref && tree.name != names.val))) { + (tree.name != names.ref || !tree.type.isReferenceProjection())) { // The enclosing type is not a class, so we are // looking at a static member type. However, the // qualifying expression is parameterized. - - // Tolerate the pseudo-select V.ref/V.val: V<T>.ref/val will be static if V<T> is and - // should not be confused as selecting a static member of a parameterized type. Both - // these constructs are illegal anyway & will be more appropriately complained against shortly. - // Note: the canonicl form is V.ref<T> and V.val<T> not V<T>.ref and V<T>.val + // Tolerate the pseudo-select V.ref: V<T>.ref will be static if V<T> is and + // should not be confused as selecting a static member of a parameterized type. log.error(tree.pos(), Errors.CantSelectStaticClassFromParamType); } else { // otherwise validate the rest of the expression @@ -2756,9 +2750,9 @@ void checkCompatibleSupertypes(DiagnosticPosition pos, Type c) { boolean implementsIdentityObject = types.asSuper(c.referenceProjectionOrSelf(), syms.identityObjectType.tsym) != null; boolean implementsPrimitiveObject = types.asSuper(c.referenceProjectionOrSelf(), syms.primitiveObjectType.tsym) != null; - if (c.tsym.isPrimitiveClass() && implementsIdentityObject) { + if (c.isPrimitiveClass() && implementsIdentityObject) { log.error(pos, Errors.PrimitiveClassMustNotImplementIdentityObject(c)); - } else if (implementsPrimitiveObject && !c.tsym.isPrimitiveClass() && !c.isReferenceProjection() && !c.tsym.isInterface() && !c.tsym.isAbstract()) { + } else if (implementsPrimitiveObject && !c.isPrimitiveClass() && !c.isReferenceProjection() && !c.tsym.isInterface() && !c.tsym.isAbstract()) { log.error(pos, Errors.IdentityClassMustNotImplementPrimitiveObject(c)); } else if (implementsPrimitiveObject && implementsIdentityObject) { log.error(pos, Errors.MutuallyIncompatibleSuperInterfaces(c)); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java index b6531992771..d6aef3578ad 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java @@ -501,7 +501,7 @@ public void visitClassDef(JCClassDecl tree) { c.clearAnnotationMetadata(); ClassType ct = (ClassType)c.type; - ct.flavor = ct.flavor.metamorphose(c.flags_field); + ct.flavor = ct.flavor.metamorphose((c.flags_field & PRIMITIVE_CLASS) != 0); if (owner.kind != PCK && (c.flags_field & STATIC) == 0) { // We are seeing a local or inner class. diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java index 701aeea93d2..4bb7e1673a5 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java @@ -2202,7 +2202,7 @@ public void visitMethodDef(JCMethodDecl tree) { firstadr = nextadr; this.thisExposability = ALLOWED; } else { - if (tree.sym.owner.isPrimitiveClass()) + if (types.isPrimitiveClass(tree.sym.owner.type)) this.thisExposability = BANNED; else this.thisExposability = ALLOWED; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index 5bdfc7bbeea..583681c1120 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -2278,7 +2278,7 @@ class generation model, but seems to be required ... Todo: Investigate to see if a defect should be reported against runtime lambda machinery */ boolean receiverIsReferenceProjection() { - return tree.getQualifierExpression().type.isPrimitiveReferenceType(); + return tree.getQualifierExpression().type.isReferenceProjection(); } /** 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 43ddff079ab..36aa31fd7c8 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 @@ -1136,8 +1136,6 @@ JCExpression access(Symbol sym, JCExpression tree, JCExpression enclOp, boolean // Make sure not to lose type fidelity due to symbol sharing between projections boolean requireReferenceProjection = tree.hasTag(SELECT) && ((JCFieldAccess) tree).name == names.ref && tree.type.isReferenceProjection(); - boolean requireValueProjection = - tree.hasTag(SELECT) && ((JCFieldAccess) tree).name == names.val && tree.type.isValueProjection(); // Convert type idents to // <flat name> or <package name> . <flat name> Name flatname = Convert.shortName(sym.flatName()); @@ -1155,16 +1153,12 @@ JCExpression access(Symbol sym, JCExpression tree, JCExpression enclOp, boolean ((JCIdent) tree).name = flatname; if (requireReferenceProjection) { tree.setType(tree.type.referenceProjection()); - } else if (requireValueProjection) { - tree.setType(tree.type.asValueType()); } } else { ((JCFieldAccess) tree).selected = base; ((JCFieldAccess) tree).name = flatname; if (requireReferenceProjection) { tree.setType(tree.type.referenceProjection()); - } else if (requireValueProjection) { - tree.setType(tree.type.asValueType()); } } } @@ -2526,8 +2520,7 @@ JCTree generateRecordMethod(JCClassDecl tree, Name name, List<VarSymbol> vars, M syms.typeDescriptorType).appendList(staticArgTypes), staticArgsValues, bootstrapName, name, false); - Type receiverType = tree.sym.type.isPrimitiveReferenceType() ? tree.sym.type.asValueType() : tree.sym.type; - VarSymbol _this = new VarSymbol(SYNTHETIC, names._this, receiverType, tree.sym); + VarSymbol _this = new VarSymbol(SYNTHETIC, names._this, tree.sym.type, tree.sym); JCMethodInvocation proxyCall; if (!isEquals) { @@ -2611,9 +2604,8 @@ JCFieldAccess makeIndyQualifier( bootstrapName, staticArgTypes, List.nil()); MethodType indyType = msym.type.asMethodType(); - Type receiverType = tree.sym.type.isPrimitiveReferenceType() ? tree.sym.type.asValueType() : tree.sym.type; indyType = new MethodType( - isStatic ? List.nil() : indyType.argtypes.prepend(receiverType), + isStatic ? List.nil() : indyType.argtypes.prepend(tree.sym.type), indyType.restype, indyType.thrown, syms.methodClass @@ -4110,7 +4102,7 @@ public void visitSelect(JCFieldAccess tree) { * always the "primary" mirror - representing the primitive reference runtime type - thereby * always matching the behavior of Object::getClass */ - boolean needPrimaryMirror = tree.name == names._class && tree.selected.type.isPrimitiveReferenceType(); + boolean needPrimaryMirror = tree.name == names._class && tree.selected.type.isReferenceProjection(); tree.selected = translate(tree.selected); if (needPrimaryMirror && tree.selected.type.isPrimitiveClass()) { tree.selected.setType(tree.selected.type.referenceProjection()); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java index 963f80739db..372fd7f4f58 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -292,7 +292,7 @@ public void visitVarDef(JCVariableDecl tree) { */ if (tree.init != null) { v.flags_field |= HASINIT; - if ((v.flags_field & FINAL) != 0 && ((v.flags_field & STATIC) != 0 || !v.owner.isPrimitiveClass()) && + if ((v.flags_field & FINAL) != 0 && ((v.flags_field & STATIC) != 0 || !types.isPrimitiveClass(v.owner.type)) && needsLazyConstValue(tree.init)) { Env<AttrContext> initEnv = getInitEnv(tree, env); initEnv.info.enclVar = v; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java index bc64acb5b72..8c77511f28c 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -427,7 +427,7 @@ public boolean isAccessible(Env<AttrContext> env, Type site, Symbol sym, boolean // A type is accessible in a reference projection if it was // accessible in the value projection. if (site.isReferenceProjection()) - site = site.asValueType(); + site = site.valueProjection(); } try { switch ((short)(sym.flags() & AccessFlags)) { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java index 36a66438a33..e2fce83ae9c 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -1276,19 +1276,6 @@ protected void read(Symbol sym, int attrLen) { } } }, - new AttributeReader(names.JavaFlags, V61, CLASS_ATTRIBUTE) { - @Override - protected boolean accepts(AttributeKind kind) { - return super.accepts(kind) && allowPrimitiveClasses; - } - protected void read(Symbol sym, int attrLen) { - if (sym.kind == TYP) { - int extendedFlags = nextChar(); - if ((extendedFlags & ACC_REF_DEFAULT) != 0) - ((ClassSymbol)sym).flags_field |= REFERENCE_FAVORING; - } - } - } }; for (AttributeReader r: readers) 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 7fbff3b3254..38f7732e437 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 @@ -352,12 +352,6 @@ int writeFlagAttrs(long flags) { endAttr(alenIdx); acount++; } - if ((flags & REFERENCE_FAVORING) != 0) { - int alenIdx = writeAttr(names.JavaFlags); - databuf.appendChar(ACC_REF_DEFAULT); - endAttr(alenIdx); - acount++; - } return acount; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java index 511262a512d..0a92f963df7 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -1066,7 +1066,7 @@ private int initCode(JCMethodDecl tree, Env<GenContext> env, boolean fatcode) { // If method is not static, create a new local variable address // for `this'. if ((tree.mods.flags & STATIC) == 0) { - Type selfType = meth.owner.isPrimitiveClass() ? meth.owner.type.asValueType() : meth.owner.type; + Type selfType = meth.owner.type; if (meth.isConstructor() && selfType != syms.objectType) selfType = UninitializedType.uninitializedThis(selfType); code.setDefined( @@ -2286,7 +2286,7 @@ public void visitTypeCast(JCTypeCast tree) { // primitive reference conversion is a nop when we bifurcate the primitive class, as the VM sees a subtyping relationship. if (!tree.clazz.type.isPrimitive() && !types.isSameType(tree.expr.type, tree.clazz.type) && - (!tree.clazz.type.isReferenceProjection() || !types.isSameType(tree.clazz.type.asValueType(), tree.expr.type) || true) && + (!tree.clazz.type.isReferenceProjection() || !types.isSameType(tree.clazz.type.valueProjection(), tree.expr.type) || true) && !types.isSubtype(tree.expr.type, tree.clazz.type)) { checkDimension(tree.pos(), tree.clazz.type); if (types.isPrimitiveClass(tree.clazz.type)) { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolWriter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolWriter.java index 0db15000957..101ebcb9109 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolWriter.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolWriter.java @@ -120,8 +120,8 @@ int putClass(Type t) { result in two different CONSTANT_Class_info strucures in the pool. These are indistinguishable at the class file level. Hence we coalesce them here. */ - if (t.tsym.isPrimitiveClass()) - t = t.asValueType(); + if (t.isReferenceProjection()) + t = t.valueProjection(); return pool.writeIfNeeded(types.erasure(t)); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/TransPrimitiveClass.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/TransPrimitiveClass.java index 160276a7312..a71ce8dc4ac 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/TransPrimitiveClass.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/TransPrimitiveClass.java @@ -33,7 +33,6 @@ import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Type.ClassType; -import com.sun.tools.javac.code.Type.ClassType.Flavor; import com.sun.tools.javac.code.Type.MethodType; import com.sun.tools.javac.code.Types; import com.sun.tools.javac.tree.JCTree; @@ -190,10 +189,7 @@ public void visitMethodDef(JCMethodDecl tree) { is passed as an argument into the <init> method, the primitive static factory must allocate the instance that forms the `product' by itself. We do that by injecting a prologue here. */ - ClassType productType = (ClassType) currentClass.sym.erasure(types); - if (currentClass.sym.isReferenceFavoringPrimitiveClass()) - productType = new ClassType(productType.getEnclosingType(), List.nil(), productType.tsym, productType.getMetadata(), Flavor.Q_TypeOf_L); - VarSymbol product = currentMethod.factoryProduct = new VarSymbol(0, names.dollarValue, productType, currentMethod.sym); // TODO: owner needs rewiring + VarSymbol product = currentMethod.factoryProduct = new VarSymbol(0, names.dollarValue, currentClass.sym.type, currentMethod.sym); // TODO: owner needs rewiring JCExpression rhs; final Name name = TreeInfo.name(call.meth); @@ -201,9 +197,9 @@ public void visitMethodDef(JCMethodDecl tree) { if (names._super.equals(name)) { // "initial" constructor. // Synthesize code to allocate factory "product" via: V $this = V.default; Assert.check(symbol.type.getParameterTypes().size() == 0); - final JCExpression type = make.Type(productType); + final JCExpression type = make.Type(currentClass.type); rhs = make.DefaultValue(type); - rhs.type = productType; + rhs.type = currentClass.type; } else { // This must be a chained call of form `this(args)'; Mutate it into a factory invocation i.e V $this = V.init(args); Assert.check(TreeInfo.name(TreeInfo.firstConstructorCall(tree).meth) == names._this); @@ -336,11 +332,11 @@ public void visitSelect(JCFieldAccess fieldAccess) { case MTH: case VAR: if (sym.isStatic() && sitesym != null && sitesym.kind == TYP) { - fieldAccess.selected = make.Type(types.erasure(selectedType.asValueType())); + fieldAccess.selected = make.Type(types.erasure(selectedType.valueProjection())); } break; case TYP: - fieldAccess.selected = make.Type(types.erasure(selectedType.asValueType())); + fieldAccess.selected = make.Type(types.erasure(selectedType.valueProjection())); break; } } @@ -351,7 +347,7 @@ public void visitSelect(JCFieldAccess fieldAccess) { // Translate a reference style instance creation attempt on a primitive class to a static factory call. @Override public void visitNewClass(JCNewClass tree) { - if (tree.clazz.type.tsym.isPrimitiveClass()) { + if (types.isPrimitiveClass(tree.clazz.type)) { // Enclosing instances or anonymous classes should have been eliminated by now. Assert.check(tree.encl == null && tree.def == null); tree.args = translate(tree.args); @@ -384,13 +380,13 @@ private boolean isInstanceMemberAccess(Symbol symbol) { private MethodSymbol getPrimitiveObjectFactory(MethodSymbol init) { Assert.check(init.name.equals(names.init)); - Assert.check(init.owner.isPrimitiveClass()); + Assert.check(types.isPrimitiveClass(init.owner.type)); MethodSymbol factory = init2factory.get(init); if (factory != null) return factory; MethodType factoryType = new MethodType(init.type.getParameterTypes(), - init.owner.type.asValueType(), + init.owner.type, init.type.getThrownTypes(), init.owner.type.tsym); factory = new MethodSymbol(init.flags_field | STATIC, @@ -400,7 +396,7 @@ private MethodSymbol getPrimitiveObjectFactory(MethodSymbol init) { factory.params = init.params; // Re-patch the return type on the erased method type, or code generation will fail factory.erasure_field = new MethodType(init.erasure(types).getParameterTypes(), - init.owner.type.asValueType(), + init.owner.type, init.type.getThrownTypes(), init.owner.type.tsym); factory.setAttributes(init); 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 2c1a37c17a0..9f73c93fd1b 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 @@ -2371,7 +2371,7 @@ JCExpression creator(int newpos, List<JCExpression> typeArgs) { case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT: case DOUBLE: case BOOLEAN: if (mods.flags != 0) { - long badModifiers = (mods.flags & Flags.PRIMITIVE_CLASS) != 0 ? mods.flags & ~(Flags.FINAL | Flags.REFERENCE_FAVORING) : mods.flags; + long badModifiers = (mods.flags & Flags.PRIMITIVE_CLASS) != 0 ? mods.flags & ~Flags.FINAL : mods.flags; log.error(token.pos, Errors.ModNotAllowedHere(asFlagSet(badModifiers))); } if (typeArgs == null) { @@ -2442,7 +2442,7 @@ else if (typeArgs != null) { } return e; } else if (token.kind == LPAREN) { - long badModifiers = mods.flags & ~(Flags.PRIMITIVE_CLASS | Flags.FINAL | Flags.REFERENCE_FAVORING); + long badModifiers = mods.flags & ~(Flags.PRIMITIVE_CLASS | Flags.FINAL); if (badModifiers != 0) log.error(token.pos, Errors.ModNotAllowedHere(asFlagSet(badModifiers))); // handle type annotations for instantiations and anonymous classes @@ -2451,7 +2451,7 @@ else if (typeArgs != null) { } JCNewClass newClass = classCreatorRest(newpos, null, typeArgs, t, mods.flags); if ((newClass.def == null) && (mods.flags != 0)) { - badModifiers = (mods.flags & Flags.PRIMITIVE_CLASS) != 0 ? mods.flags & ~(Flags.FINAL | Flags.REFERENCE_FAVORING) : mods.flags; + badModifiers = (mods.flags & Flags.PRIMITIVE_CLASS) != 0 ? mods.flags & ~Flags.FINAL : mods.flags; log.error(newClass.pos, Errors.ModNotAllowedHere(asFlagSet(badModifiers))); } return newClass; @@ -4017,16 +4017,6 @@ protected JCClassDecl classDeclaration(JCModifiers mods, Comment dc) { accept(CLASS); Name name = typeName(); - if ((mods.flags & Flags.PRIMITIVE_CLASS) != 0) { - if (token.kind == DOT) { - final Token pastDot = S.token(1); - if (pastDot.kind == IDENTIFIER && pastDot.name() == names.val) { - nextToken(); nextToken(); // discard .val - mods.flags |= Flags.REFERENCE_FAVORING; - } - } - } - List<JCTypeParameter> typarams = typeParametersOpt(); JCExpression extending = null; @@ -4052,15 +4042,6 @@ protected JCClassDecl recordDeclaration(JCModifiers mods, Comment dc) { nextToken(); mods.flags |= Flags.RECORD; Name name = typeName(); - if ((mods.flags & Flags.PRIMITIVE_CLASS) != 0) { - if (token.kind == DOT) { - final Token pastDot = S.token(1); - if (pastDot.kind == IDENTIFIER && pastDot.name() == names.val) { - nextToken(); nextToken(); // discard .val - mods.flags |= Flags.REFERENCE_FAVORING; - } - } - } List<JCTypeParameter> typarams = typeParametersOpt(); @@ -4496,7 +4477,6 @@ protected boolean isRecordStart() { if (token.kind == IDENTIFIER && token.name() == names.record && (peekToken(TokenKind.IDENTIFIER, TokenKind.LPAREN) || peekToken(TokenKind.IDENTIFIER, TokenKind.EOF) || - peekToken(TokenKind.IDENTIFIER, TokenKind.DOT) || peekToken(TokenKind.IDENTIFIER, TokenKind.LT))) { checkSourceLevel(Feature.RECORDS); return true; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java index 2669590949a..fdd1cf98541 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java @@ -853,7 +853,7 @@ public JCExpression Type(Type t) { default: { if (t.isReferenceProjection()) { // For parameterized types, we want V.ref<A1 ... An> not V<A1 ... An>.ref - JCExpression vp = Type(t.asValueType()); + JCExpression vp = Type(t.valueProjection()); if (vp.hasTag(Tag.TYPEAPPLY)) { // vp now is V<A1 ... An>, build V.ref<A1 ... An> JCFieldAccess f = (JCFieldAccess) Select(((JCTypeApply) vp).clazz, t.tsym); @@ -864,19 +864,6 @@ public JCExpression Type(Type t) { f.name = names.ref; tp = f; } - } else if (t.isValueProjection()) { - // For parameterized types, we want V.val<A1 ... An> not V<A1 ... An>.val - JCExpression vp = Type(t.referenceProjection()); - if (vp.hasTag(Tag.TYPEAPPLY)) { - // vp now is V<A1 ... An>, build V.val<A1 ... An> - JCFieldAccess f = (JCFieldAccess) Select(((JCTypeApply) vp).clazz, t.tsym); - f.name = names.val; - tp = TypeApply(f, ((JCTypeApply) vp).arguments); - } else { - JCFieldAccess f = (JCFieldAccess) Select(vp, t.tsym); - f.name = names.val; - tp = f; - } } else { Type outer = t.getEnclosingType(); JCExpression clazz = outer.hasTag(CLASS) && t.tsym.owner.kind == TYP diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java index ce38f23e02b..d1382791ad2 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java @@ -145,7 +145,6 @@ public static Names instance(Context context) { public final Name Enum; public final Name Exceptions; public final Name InnerClasses; - public final Name JavaFlags; public final Name LineNumberTable; public final Name LocalVariableTable; public final Name LocalVariableTypeTable; @@ -340,7 +339,6 @@ public Names(Context context) { Exceptions = fromString("Exceptions"); InnerClasses = fromString("InnerClasses"); LineNumberTable = fromString("LineNumberTable"); - JavaFlags = fromString("JavaFlags"); LocalVariableTable = fromString("LocalVariableTable"); LocalVariableTypeTable = fromString("LocalVariableTypeTable"); MethodParameters = fromString("MethodParameters"); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/AccessFlags.java b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/AccessFlags.java index 569e62212be..c53f595a8df 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/AccessFlags.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/AccessFlags.java @@ -39,7 +39,6 @@ */ public class AccessFlags { public static final int ACC_PUBLIC = 0x0001; // class, inner, field, method - public static final int ACC_REF_DEFAULT = 0x0001; // javac extra public static final int ACC_PRIVATE = 0x0002; // inner, field, method public static final int ACC_PROTECTED = 0x0004; // inner, field, method public static final int ACC_STATIC = 0x0008; // inner, field, method @@ -61,7 +60,7 @@ public class AccessFlags { public static final int ACC_MANDATED = 0x8000; // method parameter public static final int ACC_MODULE = 0x8000; // class - public static enum Kind { Class, InnerClass, Field, Method, JavacExtra} + public static enum Kind { Class, InnerClass, Field, Method} AccessFlags(ClassReader cr) throws IOException { this(cr.readUnsignedShort()); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java index ca874322683..3ab3fce1863 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java @@ -48,7 +48,6 @@ public abstract class Attribute { public static final String EnclosingMethod = "EnclosingMethod"; public static final String Exceptions = "Exceptions"; public static final String InnerClasses = "InnerClasses"; - public static final String JavaFlags = "JavaFlags"; public static final String LineNumberTable = "LineNumberTable"; public static final String LocalVariableTable = "LocalVariableTable"; public static final String LocalVariableTypeTable = "LocalVariableTypeTable"; @@ -125,7 +124,6 @@ protected void init() { standardAttributes.put(EnclosingMethod, EnclosingMethod_attribute.class); standardAttributes.put(Exceptions, Exceptions_attribute.class); standardAttributes.put(InnerClasses, InnerClasses_attribute.class); - standardAttributes.put(JavaFlags, JavaFlags_attribute.class); standardAttributes.put(LineNumberTable, LineNumberTable_attribute.class); standardAttributes.put(LocalVariableTable, LocalVariableTable_attribute.class); standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class); @@ -193,7 +191,6 @@ public interface Visitor<R,P> { R visitEnclosingMethod(EnclosingMethod_attribute attr, P p); R visitExceptions(Exceptions_attribute attr, P p); R visitInnerClasses(InnerClasses_attribute attr, P p); - R visitJavaFlags(JavaFlags_attribute attr, P p); R visitLineNumberTable(LineNumberTable_attribute attr, P p); R visitLocalVariableTable(LocalVariableTable_attribute attr, P p); R visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, P p); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java index e5e99e9f42c..a24fb837f43 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java @@ -474,12 +474,6 @@ public Void visitInnerClasses(InnerClasses_attribute attr, ClassOutputStream out return null; } - @Override - public Void visitJavaFlags(JavaFlags_attribute attr, ClassOutputStream out) { - out.writeShort(attr.extendedFlags); - return null; - } - protected void writeInnerClassesInfo(InnerClasses_attribute.Info info, ClassOutputStream out) { out.writeShort(info.inner_class_info_index); out.writeShort(info.outer_class_info_index); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/JavaFlags_attribute.java b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/JavaFlags_attribute.java deleted file mode 100644 index 46d70cb8de7..00000000000 --- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/JavaFlags_attribute.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2021, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package com.sun.tools.classfile; - -import java.io.IOException; - -public class JavaFlags_attribute extends Attribute { - - JavaFlags_attribute(ClassReader cr, int name_index, int length) throws IOException { - super(name_index, length); - extendedFlags = cr.readUnsignedShort(); - } - - public int getExtendedFlags() { - return extendedFlags; - } - - public <R, D> R accept(Visitor<R, D> visitor, D data) { - return visitor.visitJavaFlags(this, data); - } - - public final int extendedFlags; -} diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java index b6faaf58ed1..67dbaebe827 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java @@ -48,7 +48,6 @@ import com.sun.tools.classfile.Exceptions_attribute; import com.sun.tools.classfile.InnerClasses_attribute; import com.sun.tools.classfile.InnerClasses_attribute.Info; -import com.sun.tools.classfile.JavaFlags_attribute; import com.sun.tools.classfile.LineNumberTable_attribute; import com.sun.tools.classfile.LocalVariableTable_attribute; import com.sun.tools.classfile.LocalVariableTypeTable_attribute; @@ -355,16 +354,6 @@ public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) { return null; } - @Override - public Void visitJavaFlags(JavaFlags_attribute attr, Void unused) { - println("Extended Flags:"); - indent(+1); - if ((attr.extendedFlags & ACC_REF_DEFAULT) != 0) - println("ACC_REF_DEFAULT"); - indent(-1); - return null; - } - String getInnerName(ConstantPool constant_pool, InnerClasses_attribute.Info info) { try { return info.getInnerName(constant_pool); diff --git a/test/langtools/lib/annotations/annotations/classfile/ClassfileInspector.java b/test/langtools/lib/annotations/annotations/classfile/ClassfileInspector.java index 0fcf63c31c9..5327e869b1c 100644 --- a/test/langtools/lib/annotations/annotations/classfile/ClassfileInspector.java +++ b/test/langtools/lib/annotations/annotations/classfile/ClassfileInspector.java @@ -1371,11 +1371,6 @@ public Void visitPermittedSubclasses(PermittedSubclasses_attribute attr, T p) { public Void visitRecord(Record_attribute attr, T p) { return null; } - - @Override - public Void visitJavaFlags(JavaFlags_attribute attr, T p) { - return null; - } } private static final Attribute.Visitor<Void, ExpectedTypeAnnotation> typeAnnoMatcher diff --git a/test/langtools/tools/javac/MethodParameters/AttributeVisitor.java b/test/langtools/tools/javac/MethodParameters/AttributeVisitor.java index 79da39ec06d..d2e2fa7b620 100644 --- a/test/langtools/tools/javac/MethodParameters/AttributeVisitor.java +++ b/test/langtools/tools/javac/MethodParameters/AttributeVisitor.java @@ -66,5 +66,4 @@ class AttributeVisitor<R, P> implements Attribute.Visitor<R, P> { public R visitSynthetic(Synthetic_attribute attr, P p) { return null; } public R visitPermittedSubclasses(PermittedSubclasses_attribute attr, P p) { return null; } public R visitRecord(Record_attribute attr, P p) { return null; } - public R visitJavaFlags(JavaFlags_attribute attr, P p) { return null; } } diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ArrayCreationWithQuestion.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ArrayCreationWithQuestion.java deleted file mode 100644 index 01024fe6af9..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ArrayCreationWithQuestion.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2019, 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 8222634 - * @summary Check array creation with V and V.ref - * @modules jdk.compiler/com.sun.tools.javac.util jdk.jdeps/com.sun.tools.javap - * @compile ArrayCreationWithQuestion.java - * @run main/othervm -Xverify:none ArrayCreationWithQuestion - * @modules jdk.compiler - */ - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.Paths; - -public class ArrayCreationWithQuestion { - - static primitive class VT.val { - VT[] a1 = new VT[42]; - VT[] a2 = new VT[42]; - VT.val[] a3 = new VT.val[42]; - VT.val[] a4 = new VT.val[42]; - } - - public static void main(String[] args) { - new ArrayCreationWithQuestion().run(); - } - - void run() { - String [] params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "ArrayCreationWithQuestion$VT.class").toString() }; - runCheck(params, new String [] { - " 6: anewarray #1 // class ArrayCreationWithQuestion$VT", - " 17: anewarray #1 // class ArrayCreationWithQuestion$VT", - " 28: anewarray #10 // class \"QArrayCreationWithQuestion$VT;\"", - " 39: anewarray #10 // class \"QArrayCreationWithQuestion$VT;\"", - }); - - } - - void runCheck(String [] params, String [] expectedOut) { - StringWriter s; - String out; - - try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { - com.sun.tools.javap.Main.run(params, pw); - out = s.toString(); - } - int errors = 0; - for (String eo: expectedOut) { - if (!out.contains(eo)) { - System.err.println("Match not found for string: " + eo); - errors++; - } - } - if (errors > 0) { - throw new AssertionError("Unexpected javap output: " + out); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ArrayRelationsTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ArrayRelationsTest.java deleted file mode 100644 index 428cbe29634..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ArrayRelationsTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2021, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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 8222402 - * @summary LW2 array support in javac - * @run main/othervm ArrayRelationsTest - */ - -public primitive class ArrayRelationsTest.val { - - int x = 42; - - public static void main(String [] args) { - ArrayRelationsTest [] la = new ArrayRelationsTest[10]; - ArrayRelationsTest.val [] qa = new ArrayRelationsTest.val[10]; - boolean cce = false; - try { - qa = (ArrayRelationsTest.val[]) (Object []) (new String [10]); - } catch (ClassCastException e) { - cce = true; - } - if (!cce) { - throw new AssertionError("Missing CCE"); - } - la = qa; - ArrayRelationsTest.ref[] la2 = qa; - ArrayRelationsTest.val [] qa2 = (ArrayRelationsTest.val []) la2; - boolean npe = false; - try { - la2[0] = null; - } catch (NullPointerException e) { - npe = true; - } - if (!npe) { - throw new AssertionError("Missing NPE"); - } - npe = false; - Object [] oa = qa; - try { - oa[0] = null; - } catch (NullPointerException e) { - npe = true; - } - if (!npe) { - throw new AssertionError("Missing NPE"); - } - - // round trip; - Object o = oa = la = qa; - qa = (ArrayRelationsTest.val[]) (la = (ArrayRelationsTest.ref []) (oa = (Object []) o)); - qa [0] = new ArrayRelationsTest(); - - npe = false; - try { - la[0] = null; - } catch (NullPointerException e) { - npe = true; - } - if (!npe) { - throw new AssertionError("Missing NPE"); - } - - la = new ArrayRelationsTest.ref [10]; - - cce = false; - try { - qa = (ArrayRelationsTest.val[]) la; - } catch (ClassCastException c) { - cce = true; - } - if (!cce) { - throw new AssertionError("Unexpected CCE behavior"); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/BoxValCastTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/BoxValCastTest.java deleted file mode 100644 index dbfd1990088..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/BoxValCastTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2018, 2020, 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 8214421 8221545 8222792 - * @summary Q<->L mixing should be OK for upcasts and should use checkcasts for downcasts. - * @modules jdk.compiler/com.sun.tools.javac.util jdk.jdeps/com.sun.tools.javap - * @compile BoxValCastTest.java - * @run main/othervm -Xverify:none BoxValCastTest - * @modules jdk.compiler - */ - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.Paths; - -public class BoxValCastTest { - - static primitive class VT.val { - int f = 0; - static final VT vtbox = (VT) new VT(); // no binary cast - static VT.val vt = (VT.val) vtbox; // binary cast - static VT box = vt; // no binary cast - static VT box2 = (VT.val) box; // binary cast - static VT box3 = id(new VT()); // no binary cast + no binary cast - - static VT.val id(VT vtb) { - return (VT.val) vtb; // binary - } - } - - public static void main(String[] args) { - new BoxValCastTest().run(); - } - - void run() { - String [] params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "BoxValCastTest$VT.class").toString() }; - runCheck(params, new String [] { - - "checkcast #7 // class \"QBoxValCastTest$VT;\"" - - }); - - } - - void runCheck(String [] params, String [] expectedOut) { - StringWriter s; - String out; - - try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { - com.sun.tools.javap.Main.run(params, pw); - out = s.toString(); - } - int errors = 0; - for (String eo: expectedOut) { - if (!out.contains(eo)) { - System.err.println("Match not found for string: " + eo); - errors++; - } - } - if (errors > 0) { - throw new AssertionError("Unexpected javap output: " + out); - } - String [] splits = out.split("checkcast #7", -1); - if (splits.length != 4) { - throw new AssertionError("Unexpected javap output: " + splits.length); - } - splits = out.split("checkcast", -1); - if (splits.length != 9) { - throw new AssertionError("Unexpected javap output: " + splits.length); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CastNullCheckTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CastNullCheckTest.java deleted file mode 100644 index 539bd692190..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CastNullCheckTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2018, 2020, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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 8215110 - * @summary Check that casting to a value type involves a null check. - * - * @compile -XDallowWithFieldOperator Point.java - * @compile -XDallowWithFieldOperator CastNullCheckTest.java - * @run main/othervm CastNullCheckTest - */ - -public class CastNullCheckTest { - - final primitive class XX.val { - final int x = 10; - } - - public static void main(String... args) { - int caught = 0; - - Object o = null; - try { - XX.val x = (XX.val) o; - } catch (NullPointerException npe) { - caught++; - } - - try { - Point.val p = (Point.val) o; - } catch (NullPointerException npe) { - caught++; - } - - o = Point.val.default; - try { - Point.val p = (Point.val) o; - } catch (NullPointerException npe) { - caught++; - } - if (caught != 2) - throw new AssertionError("Wrong NPE count: " + caught); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckCyclicMembership.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckCyclicMembership.java deleted file mode 100644 index 0a6ea1802aa..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckCyclicMembership.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @summary Value types may not declare fields of its own type either directly or indirectly. - * - * @compile/fail/ref=CheckCyclicMembership.out -XDrawDiagnostics CheckCyclicMembership.java - */ - -final primitive class CheckCyclicMembership.val { - class InnerRef { - CheckCyclicMembership.val ccm; - } - primitive final class InnerValue.val { - final CheckCyclicMembership.val ccm = CheckCyclicMembership.val.default; // Error. - } - final CheckCyclicMembership.val ccm = CheckCyclicMembership.val.default; // Error. - final int i = 10; - final String s = "blah"; - final InnerRef ir = new InnerRef(); // OK. - final InnerValue.val iv = InnerValue.val.default; // Error -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckCyclicMembership.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckCyclicMembership.out deleted file mode 100644 index 77cfe6706a2..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckCyclicMembership.out +++ /dev/null @@ -1,4 +0,0 @@ -CheckCyclicMembership.java:13:41: compiler.err.cyclic.primitive.class.membership: CheckCyclicMembership.InnerValue -CheckCyclicMembership.java:15:37: compiler.err.cyclic.primitive.class.membership: CheckCyclicMembership -CheckCyclicMembership.java:19:26: compiler.err.cyclic.primitive.class.membership: CheckCyclicMembership -3 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFieldDescriptors.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFieldDescriptors.java deleted file mode 100644 index 5b7d2bb754e..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFieldDescriptors.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2019, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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 8222634 - * @summary Check field descriptors in class file - * @modules jdk.jdeps/com.sun.tools.classfile - * @run main/othervm CheckFieldDescriptors - */ - -import com.sun.tools.classfile.*; - -public primitive class CheckFieldDescriptors.val { - - int x = 10; - - - public static void main(String[] args) throws Exception { - ClassFile cls = ClassFile.read(CheckFieldDescriptors.class.getResourceAsStream("CheckFieldDescriptorsAuxilliary.class")); - - Field [] flds = cls.fields; - int fCount = 0; - for (Field fld : flds) { - if (fld.getName(cls.constant_pool).equals("f1")) { - fCount++; - if (!fld.descriptor.getValue(cls.constant_pool).equals("QCheckFieldDescriptors;")) - throw new Exception("Bad descriptor for field1"); - } else if (fld.getName(cls.constant_pool).equals("f2")) { - fCount++; - if (!fld.descriptor.getValue(cls.constant_pool).equals("LCheckFieldDescriptors;")) - throw new Exception("Bad descriptor for field2"); - } else if (fld.getName(cls.constant_pool).equals("f3")) { - fCount++; - if (!fld.descriptor.getValue(cls.constant_pool).equals("LCheckFieldDescriptors;")) - throw new Exception("Bad descriptor for field3"); - } else if (fld.getName(cls.constant_pool).equals("a1")) { - fCount++; - if (!fld.descriptor.getValue(cls.constant_pool).equals("[LCheckFieldDescriptors;")) - throw new Exception("Bad descriptor for field4"); - } else if (fld.getName(cls.constant_pool).equals("a2")) { - fCount++; - if (!fld.descriptor.getValue(cls.constant_pool).equals("[LCheckFieldDescriptors;")) - throw new Exception("Bad descriptor for field5"); - } else if (fld.getName(cls.constant_pool).equals("a3")) { - fCount++; - if (!fld.descriptor.getValue(cls.constant_pool).equals("[QCheckFieldDescriptors;")) - throw new Exception("Bad descriptor for field6"); - } else if (fld.getName(cls.constant_pool).equals("a4")) { - fCount++; - if (!fld.descriptor.getValue(cls.constant_pool).equals("[QCheckFieldDescriptors;")) - throw new Exception("Bad descriptor for field7"); - } - } - if (fCount != 7) { - throw new Exception("Bad descriptor for field3"); - } - } -} - -class CheckFieldDescriptorsAuxilliary { - - CheckFieldDescriptors.val f1; - CheckFieldDescriptors f2; - CheckFieldDescriptors f3; - - CheckFieldDescriptors[] a1 = new CheckFieldDescriptors[42]; - CheckFieldDescriptors[] a2 = new CheckFieldDescriptors[42]; - CheckFieldDescriptors.val[] a3 = new CheckFieldDescriptors.val[42]; - CheckFieldDescriptors.val[] a4 = new CheckFieldDescriptors.val[42]; -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableCycles.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableCycles.java deleted file mode 100644 index 6f0ff9d2951..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableCycles.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @summary Check for cycles through fields declared flattenable. - * - * @compile/fail/ref=CheckFlattenableCycles.out -XDrawDiagnostics CheckFlattenableCycles.java - */ - -final primitive class CheckFlattenableCycles.val { - class InnerRef { - CheckFlattenableCycles.val cfc; - } - primitive final class InnerValue.val { - final CheckFlattenableCycles.val cfc = CheckFlattenableCycles.val.default; // Error. - } - final CheckFlattenableCycles.val cfc = CheckFlattenableCycles.val.default; // Error. - final int i = 10; - final String s = "blah"; - final InnerRef ir = new InnerRef(); // OK. - final InnerValue.val iv = InnerValue.val.default; // Error -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableCycles.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableCycles.out deleted file mode 100644 index 9a7be46168f..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableCycles.out +++ /dev/null @@ -1,4 +0,0 @@ -CheckFlattenableCycles.java:13:46: compiler.err.cyclic.primitive.class.membership: CheckFlattenableCycles.InnerValue -CheckFlattenableCycles.java:15:38: compiler.err.cyclic.primitive.class.membership: CheckFlattenableCycles -CheckFlattenableCycles.java:19:30: compiler.err.cyclic.primitive.class.membership: CheckFlattenableCycles -3 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableFlagFromClass.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableFlagFromClass.java deleted file mode 100644 index c46c20ff708..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableFlagFromClass.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8197911 - * @summary Check that valueness is deduced from class files and has the appropriate effect. - * @compile FlattenableFlagFromClass.java - * @compile/fail/ref=CheckFlattenableFlagFromClass.out -XDrawDiagnostics CheckFlattenableFlagFromClass.java - */ - -public class CheckFlattenableFlagFromClass { - void foo(FlattenableFlagFromClass f) { - f.v = null; // Error. - f.va[0] = null; // Error. - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableFlagFromClass.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableFlagFromClass.out deleted file mode 100644 index 62493043978..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckFlattenableFlagFromClass.out +++ /dev/null @@ -1,3 +0,0 @@ -CheckFlattenableFlagFromClass.java:11:15: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableFlagFromClass.V.val) -CheckFlattenableFlagFromClass.java:12:19: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableFlagFromClass.V.val) -2 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckMultiDimensionalArrayStore.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckMultiDimensionalArrayStore.java deleted file mode 100644 index 020ad236d4e..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckMultiDimensionalArrayStore.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @summary Check null store into multidimensional array - * @compile/fail/ref=CheckMultiDimensionalArrayStore.out -XDrawDiagnostics -XDdev CheckMultiDimensionalArrayStore.java - */ - -public class CheckMultiDimensionalArrayStore { - - primitive final class V { - - class Y { // null usage inside class Y are NOT problematic. - V.ref [][][] va = new V.ref[][][] {{{ null }}}; - V.ref [][] va2 = {{ null }}; - void foo() { - va = new V.ref[][][] {{{ null }}}; - va[0][0][0] = null; - } - } - - class Z { // null usage inside class Z ARE ALL problematic. - V [][][] va = new V[][][] {{{ null }}}; - V [][] va2 = {{ null }}; - void foo() { - va = new V[][][] {{{ null }}}; - va[0][0][0] = null; - } - } - } - - primitive final class R.val { - - class Y { // null usage inside class Y NOT problematic. - R [][][] va = new R[][][] {{{ null }}}; - R [][] va2 = {{ null }}; - void foo() { - va = new R[][][] {{{ null }}}; - va[0][0][0] = null; - } - } - - class Z { // null usage inside class Z ARE ALL problematic. - R.val [][][] va = new R.val[][][] {{{ null }}}; - R.val [][] va2 = {{ null }}; - void foo() { - va = new R.val[][][] {{{ null }}}; - va[0][0][0] = null; - } - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckMultiDimensionalArrayStore.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckMultiDimensionalArrayStore.out deleted file mode 100644 index 10882b31111..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckMultiDimensionalArrayStore.out +++ /dev/null @@ -1,9 +0,0 @@ -CheckMultiDimensionalArrayStore.java:21:43: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckMultiDimensionalArrayStore.V) -CheckMultiDimensionalArrayStore.java:22:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckMultiDimensionalArrayStore.V) -CheckMultiDimensionalArrayStore.java:24:38: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckMultiDimensionalArrayStore.V) -CheckMultiDimensionalArrayStore.java:25:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckMultiDimensionalArrayStore.V) -CheckMultiDimensionalArrayStore.java:42:51: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckMultiDimensionalArrayStore.R.val) -CheckMultiDimensionalArrayStore.java:43:34: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckMultiDimensionalArrayStore.R.val) -CheckMultiDimensionalArrayStore.java:45:42: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckMultiDimensionalArrayStore.R.val) -CheckMultiDimensionalArrayStore.java:46:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckMultiDimensionalArrayStore.R.val) -8 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullAssign.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullAssign.java deleted file mode 100644 index c58978a8298..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullAssign.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @summary Assignment of null to value types should be disallowed. - * - * @compile/fail/ref=CheckNullAssign.out -XDrawDiagnostics CheckNullAssign.java - */ - -final primitive class CheckNullAssign.val { - CheckNullAssign.val foo(CheckNullAssign.val cna) { - // All of the below involve subtype/assignability checks and should be rejected. - cna = null; - foo(null); - if (null instanceof CheckNullAssign.val) {} - return null; - } - boolean b = null instanceof CheckNullAssign; // OK. -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullAssign.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullAssign.out deleted file mode 100644 index 1e15bf47bce..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullAssign.out +++ /dev/null @@ -1,5 +0,0 @@ -CheckNullAssign.java:11:15: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullAssign.val) -CheckNullAssign.java:12:9: compiler.err.cant.apply.symbol: kindname.method, foo, CheckNullAssign.val, compiler.misc.type.null, kindname.class, CheckNullAssign, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullAssign.val)) -CheckNullAssign.java:13:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullAssign.val) -CheckNullAssign.java:14:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullAssign.val) -4 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullCastable.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullCastable.java deleted file mode 100644 index cefb54b456c..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullCastable.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @summary null cannot be casted to and compared with value types. - * - * @compile/fail/ref=CheckNullCastable.out -XDrawDiagnostics CheckNullCastable.java - */ - -primitive final class CheckNullCastable.val { - void foo(CheckNullCastable.val cnc) { - CheckNullCastable.val cncl = (CheckNullCastable.val) null; - if (cnc != null) {}; - if (null != cnc) {}; - } - int x = 10; -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullCastable.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullCastable.out deleted file mode 100644 index a3565c3ff2a..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckNullCastable.out +++ /dev/null @@ -1,4 +0,0 @@ -CheckNullCastable.java:10:62: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullCastable.val) -CheckNullCastable.java:11:17: compiler.err.incomparable.types: CheckNullCastable.val, compiler.misc.type.null -CheckNullCastable.java:12:18: compiler.err.incomparable.types: compiler.misc.type.null, CheckNullCastable.val -3 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckQuestionInMessages.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckQuestionInMessages.java deleted file mode 100644 index 0c8779f9719..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckQuestionInMessages.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8222790 - * @summary javac diagnostics don't discriminate between inline types and there nullable projection types. - * - * @compile/fail/ref=CheckQuestionInMessages.out -XDrawDiagnostics CheckQuestionInMessages.java - */ - -import java.util.List; - -primitive class X.val { - List<X.ref> ls = new Object() {}; - X.ref[] xa = new Object[10]; // no support for Object.ref yet, but they are the same. -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckQuestionInMessages.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckQuestionInMessages.out deleted file mode 100644 index 6a6d16bf8f5..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckQuestionInMessages.out +++ /dev/null @@ -1,3 +0,0 @@ -CheckQuestionInMessages.java:12:22: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: java.lang.Object, java.util.List<X>) -CheckQuestionInMessages.java:13:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Object[], X[]) -2 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSeparateCompile.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSeparateCompile.java deleted file mode 100644 index 5772553fcb0..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSeparateCompile.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * @summary Check separate compilation - * @compile CheckSeparateCompile0.java - * @compile CheckSeparateCompile.java - * @run main/othervm -XX:+EnableValhalla CheckSeparateCompile - */ - -public class CheckSeparateCompile { - public static void main(String[] args) { - if (new CheckSeparateCompile0().new O().new M().new I().foo().i != 890) - throw new AssertionError("Broken"); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSeparateCompile0.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSeparateCompile0.java deleted file mode 100644 index 50f29ca8a61..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSeparateCompile0.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2018, 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. - */ - -/** - * @summary Test seperate compilation - */ - -public class CheckSeparateCompile0 { - int x = 123; - public class O { - int o = 456; - public class M { - int m = 789; - public primitive class I { - int i = 890; - I() { - - } - I foo() { - return this; - } - } - public String toString() { - return "o = " + o + " m = " + m + " x = " + x; - } - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSynchronized.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSynchronized.java deleted file mode 100644 index 811a7589fb4..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSynchronized.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @summary Check behavior of synzhronized key word on primitive class instances and methods. - * - * @compile/fail/ref=CheckSynchronized.out -XDrawDiagnostics CheckSynchronized.java - */ - -primitive final class CheckSynchronized.val implements java.io.Serializable { - synchronized void foo() { // <<-- ERROR, no monitor associated with `this' - } - void goo() { - synchronized(this) {} // <<-- ERROR, no monitor associated with `this' - } - synchronized static void zoo(CheckSynchronized.val cs) { // OK, static method. - synchronized(cs) { // <<-- ERROR, no monitor associated with primitive class instance. - } - - CheckSynchronized.ref csr = cs; - synchronized(csr) { - // Error, no identity. - } - - synchronized(x) { - // Error, no identity. - } - - Object o = cs; - synchronized(o) { - // Error BUT not discernible at compile time - } - java.io.Serializable jis = cs; - synchronized(jis) { - // Error BUT not discernible at compile time - } - } - static int x = 10; -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSynchronized.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSynchronized.out deleted file mode 100644 index 18ed47baf90..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/CheckSynchronized.out +++ /dev/null @@ -1,6 +0,0 @@ -CheckSynchronized.java:9:23: compiler.err.mod.not.allowed.here: synchronized -CheckSynchronized.java:12:9: compiler.err.type.found.req: CheckSynchronized, (compiler.misc.type.req.identity) -CheckSynchronized.java:15:9: compiler.err.type.found.req: CheckSynchronized.val, (compiler.misc.type.req.identity) -CheckSynchronized.java:19:9: compiler.err.type.found.req: CheckSynchronized, (compiler.misc.type.req.identity) -CheckSynchronized.java:23:9: compiler.err.type.found.req: int, (compiler.misc.type.req.identity) -5 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralNegativeTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralNegativeTest.java deleted file mode 100644 index d9a51c125f3..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralNegativeTest.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8244796 8244799 - * @summary Value class literal tests - * @compile/fail/ref=ClassLiteralNegativeTest.out -XDrawDiagnostics ClassLiteralNegativeTest.java - */ - -final primitive class ClassLiteralNegativeTest.val { - Class<ClassLiteralNegativeTest.val> c1 = null; // error - Class<? extends ClassLiteralNegativeTest.val> c2 = null; // error - Class<? super ClassLiteralNegativeTest.val> c3 = null; // error -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralNegativeTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralNegativeTest.out deleted file mode 100644 index 4f382923b1e..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralNegativeTest.out +++ /dev/null @@ -1,4 +0,0 @@ -ClassLiteralNegativeTest.java:9:35: compiler.err.type.found.req: ClassLiteralNegativeTest.val, (compiler.misc.type.req.ref) -ClassLiteralNegativeTest.java:10:11: compiler.err.type.found.req: ClassLiteralNegativeTest.val, (compiler.misc.type.req.ref) -ClassLiteralNegativeTest.java:11:11: compiler.err.type.found.req: ClassLiteralNegativeTest.val, (compiler.misc.type.req.ref) -3 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralTypingNegativeTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralTypingNegativeTest.java deleted file mode 100644 index 0a98629fc80..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralTypingNegativeTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8221323 - * @summary Javac should support class literals for projection types. - * @compile/fail/ref=ClassLiteralTypingNegativeTest.out -XDrawDiagnostics ClassLiteralTypingNegativeTest.java - */ - -public class ClassLiteralTypingNegativeTest { - - public static primitive class Foo.val { - final int value = 0; - - public static void main(String[] args) { - Class<? extends Foo> cFooRef = Foo.val.class; // Error - cFooRef = ((Foo.val) new Foo()).getClass(); // OK - cFooRef = Foo.class; // OK. - cFooRef = Foo.val.class; // Error. - Foo.val xv = new Foo(); - cFooRef = xv.getClass(); // OK - Foo xr = new Foo(); - cFooRef = xr.getClass(); // OK. - } - } - - interface I {} - - public static primitive class Bar.val implements I { - final int value = 0; - - public static void main(String[] args) { - Class<? extends Bar> cBarRef = Bar.val.class; // Error - cBarRef = ((Bar.val) new Bar()).getClass(); // OK - cBarRef = Bar.class; // OK. - cBarRef = Bar.val.class; // Error. - Bar.val xv = new Bar(); - cBarRef = xv.getClass(); // OK. - Bar xr = new Bar(); - cBarRef = xr.getClass(); // OK. - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralTypingNegativeTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralTypingNegativeTest.out deleted file mode 100644 index 16c1b79125a..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ClassLiteralTypingNegativeTest.out +++ /dev/null @@ -1,5 +0,0 @@ -ClassLiteralTypingNegativeTest.java:14:51: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class<compiler.misc.type.captureof: 1, ? extends java.lang.Object>, java.lang.Class<? extends ClassLiteralTypingNegativeTest.Foo>) -ClassLiteralTypingNegativeTest.java:17:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class<compiler.misc.type.captureof: 1, ? extends java.lang.Object>, java.lang.Class<? extends ClassLiteralTypingNegativeTest.Foo>) -ClassLiteralTypingNegativeTest.java:31:51: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class<compiler.misc.type.captureof: 1, ? extends java.lang.Object&ClassLiteralTypingNegativeTest.I>, java.lang.Class<? extends ClassLiteralTypingNegativeTest.Bar>) -ClassLiteralTypingNegativeTest.java:34:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class<compiler.misc.type.captureof: 1, ? extends java.lang.Object&ClassLiteralTypingNegativeTest.I>, java.lang.Class<? extends ClassLiteralTypingNegativeTest.Bar>) -4 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConditionalTypeTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConditionalTypeTest.java deleted file mode 100644 index aa4f10eb325..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConditionalTypeTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8244513 - * @summary Test conditional expression typing involving inlines. - * @compile/fail/ref=ConditionalTypeTest.out -XDrawDiagnostics ConditionalTypeTest.java - */ - -final class ConditionalTypeTest { - interface I {} - static primitive class Node.val implements I {} - static void foo(int i) { - var ret1 = (i == 0) ? new XNodeWrapper() : new Node(); - ret1 = "String cannot be assigned to I"; - var ret2 = (i == 0) ? 10 : new XNodeWrapper(); - ret2 = "String can be assigned to I"; - var ret3 = (i == 0) ? new XNodeWrapper() : 10; - ret3 = "String can be assigned to Object"; - var ret4 = (i == 0) ? new XNodeWrapper() : new ConditionalTypeTest(); - ret4 = "String can be assigned to Object"; - var ret5 = (i == 0) ? Integer.valueOf(10) : new ConditionalTypeTest(); - ret5 = "String can be assigned to Object"; - - var ret6 = (i == 0) ? new Node() : new Node(); - ret6 = "String cannot be assigned to Node.val"; - - var ret7 = (i == 0) ? (Node.ref) new Node() : (Node.ref) null; - ret7 = "String cannot be assigned to Node.ref"; - - var ret8 = (i == 0) ? new Node() : (Node.ref) null; - ret8 = "String cannot be assigned to Node.val"; - - var ret9 = (i == 0) ? (Node.ref) new Node() : new Node(); - ret9 = "String cannot be assigned to Node.val"; - } - static primitive class XNodeWrapper.val implements I {} -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConditionalTypeTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConditionalTypeTest.out deleted file mode 100644 index f5b0f7e0827..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConditionalTypeTest.out +++ /dev/null @@ -1,6 +0,0 @@ -ConditionalTypeTest.java:13:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, ConditionalTypeTest.I) -ConditionalTypeTest.java:24:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, ConditionalTypeTest.Node.val) -ConditionalTypeTest.java:27:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, ConditionalTypeTest.Node) -ConditionalTypeTest.java:30:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, ConditionalTypeTest.Node.val) -ConditionalTypeTest.java:33:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, ConditionalTypeTest.Node.val) -5 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConsumeUnifiedClass.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConsumeUnifiedClass.java deleted file mode 100644 index a49f8ebe05d..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConsumeUnifiedClass.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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 8266466 - * @summary Enhance javac to consume unified primitive class files - * @compile -XDallowWithFieldOperator Point.java Rectangle.java - * @compile/fail/ref=ConsumeUnifiedClass.out -XDrawDiagnostics ConsumeUnifiedClass.java - */ - -public primitive class ConsumeUnifiedClass { - public static void main(String [] args) { - Rectangle r = new Rectangle(null, null); // Check method type decoding, should error - r = Rectangle.from(null, null); // OK. - Rectangle.origin = null; // Check field type decoding, should error - Rectangle.origin = Point.makePoint(0, 0); // OK - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConsumeUnifiedClass.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConsumeUnifiedClass.out deleted file mode 100644 index bf92e1065ea..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ConsumeUnifiedClass.out +++ /dev/null @@ -1,3 +0,0 @@ -ConsumeUnifiedClass.java:36:23: compiler.err.cant.apply.symbol: kindname.constructor, Rectangle, Point.val,Point.val, compiler.misc.type.null,compiler.misc.type.null, kindname.class, Rectangle, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.null, Point.val)) -ConsumeUnifiedClass.java:38:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, Point.val) -2 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/DefaultNonInlines.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/DefaultNonInlines.java deleted file mode 100644 index 2dfc6f2d945..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/DefaultNonInlines.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2018, 2020, 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 Check default values for non-inline types - * @bug 8237067 - * @summary [lworld] Provide linguistic support to denote default values. - * @run main/othervm -Dtest.compiler.opts=-release=13 DefaultNonInlines - */ - -public class DefaultNonInlines { - - static primitive class Val.val { - public int v = 42; - } - - static <T> void checkDefaultT(Class<T> clazz) throws Exception { - while (T.default != null) - throw new AssertionError("Generic object should default to null"); - } - - public static void main(String[] args) throws Exception { - // Default value is set by inline class constructor - while (Val.val.default.v != int.default) - throw new AssertionError("inline object fields should default to defaults"); - - while ((new Val()).v != 42) - throw new AssertionError("inline object fields should default to whatever constructor says"); - - // Simple reference default is just null - while (String.default != null) - throw new AssertionError("reference object should default to null"); - - // Reference default checked in method above - checkDefaultT(String.class); - - // Array type - different syntactically - while (int[].default != null) - throw new AssertionError("arrays should default to null"); - - while (boolean.default != false) - throw new AssertionError("boolean should default to false"); - - while (char.default != '\0') - throw new AssertionError("char should default to '\0'"); - - while (int.default != 0) - throw new AssertionError("int should default to 0"); - - while (byte.default != 0) - throw new AssertionError("byte should default to 0"); - - while (short.default != 0) - throw new AssertionError("short should default to 0"); - - while (long.default != 0L) - throw new AssertionError("long should default to 0L"); - - while (float.default != 0.0F) - throw new AssertionError("float should default to 0.0F"); - - while (double.default != 0.0D) - throw new AssertionError("double should default to 0.0D"); - - // Note: The while loops above implicitly test that the SomeType.default does not - // return a constant expression. - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ExplicitLambdaWithNullableTypes.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ExplicitLambdaWithNullableTypes.java deleted file mode 100644 index 82ad94913e9..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ExplicitLambdaWithNullableTypes.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2019, 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 8229537 - * @summary [lworld] Poor interaction between explicit lambda parameters and nullable projection types. - * @compile -XDallowWithFieldOperator ExplicitLambdaWithNullableTypes.java - * @run main/othervm ExplicitLambdaWithNullableTypes - */ - -import java.util.List; -import java.util.ArrayList; -import java.util.function.*; -import java.util.NoSuchElementException; - -primitive class OptionalInt.val { - // private static final OptionalInt EMPTY = OptionalInt.default; - - private boolean isPresent = false; - private int v = 0; - - public static OptionalInt.val empty() { - return OptionalInt.val.default; - } - - public static OptionalInt.val of(int val) { - OptionalInt.val self = OptionalInt.val.default; - self = __WithField(self.v, val); - self = __WithField(self.isPresent, true); - return self; - } - - public int getAsInt() { - if (!isPresent) - throw new NoSuchElementException("No value present"); - - return v; - } - - public boolean isPresent() { - return isPresent; - } - - public void ifPresent(IntConsumer consumer) { - if (isPresent) - consumer.accept(v); - } - - public int orElse(int other) { - return isPresent ? v : other; - } -} - -public final class ExplicitLambdaWithNullableTypes { - - public static void main(String[] args) { - List<OptionalInt.ref> opts = new ArrayList<>(); - for (int i=0; i < 5; i++) { - opts.add(OptionalInt.of(i)); - opts.add(OptionalInt.empty()); - opts.add(null); - } - - Integer total = opts.stream() - .map((OptionalInt.ref o) -> { - if (o == null) - return 0; - - OptionalInt.val op = (OptionalInt.val)o; - return op.orElse(0); - }) - .reduce(0, (x, y) -> x + y); - - if (total != 10) { - throw new AssertionError("Incorrect output: " + total); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ExplicitLambdaWithNullableTypes2.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ExplicitLambdaWithNullableTypes2.java deleted file mode 100644 index 266ba68e57f..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ExplicitLambdaWithNullableTypes2.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2019, 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 8229537 - * @summary [lworld] Poor interaction between explicit lambda parameters and nullable projection types. - * @compile -XDallowWithFieldOperator ExplicitLambdaWithNullableTypes2.java - * @run main/othervm ExplicitLambdaWithNullableTypes2 - */ - -import java.util.List; -import java.util.ArrayList; -import java.util.function.*; -import java.util.NoSuchElementException; -import java.util.stream.*; - -primitive class OptionalInt.val { - // private static final OptionalInt EMPTY = OptionalInt.default; - - private boolean isPresent = false; - private int v = 0; - - public static OptionalInt.val empty() { - return OptionalInt.val.default; - } - - public static OptionalInt.val of(int val) { - OptionalInt.val self = OptionalInt.val.default; - self = __WithField(self.v, val); - self = __WithField(self.isPresent, true); - return self; - } - - public int getAsInt() { - if (!isPresent) - throw new NoSuchElementException("No value present"); - - return v; - } - - public boolean isPresent() { - return isPresent; - } - - public void ifPresent(IntConsumer consumer) { - if (isPresent) - consumer.accept(v); - } - - public int orElse(int other) { - return isPresent ? v : other; - } -} - -public final class ExplicitLambdaWithNullableTypes2 { - - public static void main(String[] args) { - List<OptionalInt.ref> opts = new ArrayList<>(); - for (int i=0; i < 5; i++) { - opts.add(OptionalInt.of(i)); - opts.add(OptionalInt.empty()); - opts.add(null); - } - - Stream<OptionalInt.ref> soi = opts.stream(); - ToIntFunction<OptionalInt.ref> f = (OptionalInt.ref o) -> { - if (o == null) return 0; - OptionalInt.val op = (OptionalInt.val)o; - return op.orElse(0); - }; - - IntStream sint = soi.mapToInt(f); - int total = sint.reduce(0, (x, y) -> x + y); - - if (total != 10) { - throw new AssertionError("Incorrect output: " + total); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ExplicitLambdaWithNullableTypes3.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ExplicitLambdaWithNullableTypes3.java deleted file mode 100644 index a99b36eca99..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ExplicitLambdaWithNullableTypes3.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2019, 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 8229537 - * @summary [lworld] Poor interaction between explicit lambda parameters and nullable projection types. - * @compile -XDallowWithFieldOperator ExplicitLambdaWithNullableTypes3.java - * @run main/othervm ExplicitLambdaWithNullableTypes3 - */ - -import java.util.List; -import java.util.ArrayList; -import java.util.function.*; -import java.util.NoSuchElementException; -import java.util.stream.*; - -primitive class OptionalInt.val { - // private static final OptionalInt EMPTY = OptionalInt.default; - - private boolean isPresent = false; - private int v = 0; - - public static OptionalInt.val empty() { - return OptionalInt.val.default; - } - - public static OptionalInt.val of(int val) { - OptionalInt.val self = OptionalInt.val.default; - self = __WithField(self.v, val); - self = __WithField(self.isPresent, true); - return self; - } - - public int getAsInt() { - if (!isPresent) - throw new NoSuchElementException("No value present"); - - return v; - } - - public boolean isPresent() { - return isPresent; - } - - public void ifPresent(IntConsumer consumer) { - if (isPresent) - consumer.accept(v); - } - - public int orElse(int other) { - return isPresent ? v : other; - } -} - -public final class ExplicitLambdaWithNullableTypes3 { - - public static void main(String[] args) { - List<OptionalInt.ref> opts = new ArrayList<>(); - for (int i=0; i < 5; i++) { - opts.add(OptionalInt.of(i)); - opts.add(OptionalInt.empty()); - opts.add(null); - } - - Stream<OptionalInt.ref> soi = opts.stream(); - ToIntFunction<OptionalInt.ref> f = o -> { - if (o == null) return 0; - OptionalInt.val op = (OptionalInt.val)o; - return op.orElse(0); - }; - - IntStream sint = soi.mapToInt(f); - int total = sint.reduce(0, (x, y) -> x + y); - - if (total != 10) { - throw new AssertionError("Incorrect output: " + total); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/FlattenableFlagFromClass.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/FlattenableFlagFromClass.java deleted file mode 100644 index f6399c28cc7..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/FlattenableFlagFromClass.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2021, 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. - */ - -public class FlattenableFlagFromClass { - - public primitive final class V.val { - final int x = 10; - } - - public V.val v; - public V.val[] va; -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/FlattenableNegativeTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/FlattenableNegativeTest.java deleted file mode 100644 index a5e69120df1..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/FlattenableNegativeTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8197911 - * @summary Test Javac's treatment of null assignment to value instances - * @compile/fail/ref=FlattenableNegativeTest.out -XDallowWithFieldOperator -XDrawDiagnostics -XDdev FlattenableNegativeTest.java - */ - -public class FlattenableNegativeTest { - primitive final class V.val { - final int x = 10; - - primitive final class X.val { - final V.val v = null; // Error: initialization illegal - final V.val v2 = v; // OK, null not constant propagated. - - V.val foo(X.val x) { - x = __WithField(x.v, null); // Error: withfield attempt is illegal. - return x.v; - } - } - V.val foo(X.val x) { - x = __WithField(x.v, null); // withfield attempt is illegal - return x.v; - } - - class Y { - V.val v; - V.val [] va = { null }; // Illegal array initialization - V.val [] va2 = new V.val[] { null }; // Illegal array initialization - void foo(X.val x) { - x = __WithField(x.v, null); // illegal withfield attempt - v = null; // illegal assignment. - va[0] = null; // Illegal. - va = new V.val[] { null }; // Illegal - } - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/FlattenableNegativeTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/FlattenableNegativeTest.out deleted file mode 100644 index 1f105f81d1e..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/FlattenableNegativeTest.out +++ /dev/null @@ -1,10 +0,0 @@ -FlattenableNegativeTest.java:13:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableNegativeTest.V.val) -FlattenableNegativeTest.java:17:38: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableNegativeTest.V.val) -FlattenableNegativeTest.java:22:34: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableNegativeTest.V.val) -FlattenableNegativeTest.java:28:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableNegativeTest.V.val) -FlattenableNegativeTest.java:29:42: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableNegativeTest.V.val) -FlattenableNegativeTest.java:31:38: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableNegativeTest.V.val) -FlattenableNegativeTest.java:32:21: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableNegativeTest.V.val) -FlattenableNegativeTest.java:33:25: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableNegativeTest.V.val) -FlattenableNegativeTest.java:34:36: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, FlattenableNegativeTest.V.val) -9 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericInlineTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericInlineTest.java deleted file mode 100644 index c18627c6633..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericInlineTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8237072 - * @summary Test various relationships between a value type and its reference projection. - * @compile/fail/ref=GenericInlineTest.out -XDrawDiagnostics GenericInlineTest.java - */ - -abstract class Low<T, U> {} -abstract class Mid<T, U> extends Low<U, T> {} -abstract class High<T, U> extends Mid<U, T> {} - -primitive -class GenericInlineTest.val<T, U> extends High<U, T> { - - int x = 0; - - void foo() { - - GenericInlineTest.val<String, Integer> g = new GenericInlineTest<String, Integer>(); - - High<String, Integer> h1 = g; // error. - - High<Integer, String> h2 = g; // Ok. - - Mid<String, Integer> m1 = g; // Ok - - Mid<Integer, String> m2 = g; // error. - - Low<String, Integer> l1 = g; // error. - - Low<Integer, String> l2 = g; // Ok. - - g = l2; // error. - g = (GenericInlineTest.val<String, Integer>) l2; // OK. - - GenericInlineTest<String, Integer> r1 = g; // ok. - GenericInlineTest.ref<Integer, String> r2 = g; // error - - g = r1; // ok. - g = r2; // error. - g = (GenericInlineTest.val<String, Integer>) r2; // still error. - - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericInlineTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericInlineTest.out deleted file mode 100644 index 9fe1c17dbea..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericInlineTest.out +++ /dev/null @@ -1,8 +0,0 @@ -GenericInlineTest.java:21:36: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: GenericInlineTest.val<java.lang.String,java.lang.Integer>, High<java.lang.String,java.lang.Integer>) -GenericInlineTest.java:27:35: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: GenericInlineTest.val<java.lang.String,java.lang.Integer>, Mid<java.lang.Integer,java.lang.String>) -GenericInlineTest.java:29:35: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: GenericInlineTest.val<java.lang.String,java.lang.Integer>, Low<java.lang.String,java.lang.Integer>) -GenericInlineTest.java:33:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: Low<java.lang.Integer,java.lang.String>, GenericInlineTest.val<java.lang.String,java.lang.Integer>) -GenericInlineTest.java:37:53: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: GenericInlineTest.val<java.lang.String,java.lang.Integer>, GenericInlineTest<java.lang.Integer,java.lang.String>) -GenericInlineTest.java:40:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: GenericInlineTest<java.lang.Integer,java.lang.String>, GenericInlineTest.val<java.lang.String,java.lang.Integer>) -GenericInlineTest.java:41:54: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: GenericInlineTest<java.lang.Integer,java.lang.String>, GenericInlineTest.val<java.lang.String,java.lang.Integer>) -7 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericsAndValues5.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericsAndValues5.java deleted file mode 100644 index 27967382723..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericsAndValues5.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2019, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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 8230121 - * @summary Javac does not properly parse nullable projection types of parameterized inline types - * @compile GenericsAndValues5.java - * @run main/othervm GenericsAndValues5 - */ - -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.function.Function; -import java.util.List; -import java.util.ArrayList; - -primitive class Optional.val<T> { - private T value; - - @SuppressWarnings("unchecked") - public static <T> Optional.val<T> empty() { - return (Optional.val<T>) Optional.val.default; - } - - private Optional(T value) { - this.value = value; - } - - public static <T> Optional.val<T> of(T value) { - if (value == null) - return empty(); - return new Optional<T>(value); - } - - public T get() { - if (value == null) - throw new NoSuchElementException("No value present"); - return value; - } - - public boolean isPresent() { - return value != null; - } - - public T orElse(T other) { - return value != null ? value : other; - } - - public <U> Optional.val<U> map(Function<? super T, ? extends U> mapper) { - Objects.requireNonNull(mapper); - if (!isPresent()) - return empty(); - else - return Optional.of(mapper.apply(value)); - } - - @Override - public String toString() { - return value != null ? String.format("Optional[%s]", value) : "Optional.empty"; - } -} - -public final class GenericsAndValues5 { - - public static void main(String[] args) { - - List<Optional.ref<Integer>> opts = new ArrayList<>(); - for (int i=0; i < 6; i++) { - Optional.val<Integer> oi = Optional.of(i); - opts.add((Optional.ref<Integer>)oi); - Optional.val<Integer> oe = Optional.empty(); - opts.add((Optional.ref<Integer>)oe); - } - - Integer total = opts.stream() - .map((Optional.ref<Integer> o) -> { - Optional.val<Integer> op = (Optional.val<Integer>)o; - return op.orElse(0); - }) - .reduce(0, (x, y) -> x + y); - - if (total != 15) { - throw new AssertionError("Incorrect output: " + total); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericsWithQuestion.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericsWithQuestion.java deleted file mode 100644 index 6bb0809ff9f..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericsWithQuestion.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8221545 - * @summary Test Generics with ? - * @compile/fail/ref=GenericsWithQuestion.out -XDrawDiagnostics GenericsWithQuestion.java - */ - -import java.util.HashMap; - -public class GenericsWithQuestion { - - primitive class V.val { - int x = 10; - } - - HashMap<V, V>good1; - HashMap<V.ref, GenericsWithQuestion.V.ref>good2; - HashMap<V.val, V.val> bad1; // error; - HashMap<V.ref, V.val> bad2; // error - HashMap<V.val, V.ref> bad3; // error -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericsWithQuestion.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericsWithQuestion.out deleted file mode 100644 index 2a4621951e7..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/GenericsWithQuestion.out +++ /dev/null @@ -1,5 +0,0 @@ -GenericsWithQuestion.java:18:14: compiler.err.type.found.req: GenericsWithQuestion.V.val, (compiler.misc.type.req.ref) -GenericsWithQuestion.java:18:21: compiler.err.type.found.req: GenericsWithQuestion.V.val, (compiler.misc.type.req.ref) -GenericsWithQuestion.java:19:21: compiler.err.type.found.req: GenericsWithQuestion.V.val, (compiler.misc.type.req.ref) -GenericsWithQuestion.java:20:14: compiler.err.type.found.req: GenericsWithQuestion.V.val, (compiler.misc.type.req.ref) -4 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/MalformedParameterizedType.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/MalformedParameterizedType.java deleted file mode 100644 index 2b9dfa5f8b9..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/MalformedParameterizedType.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8244231 - * @summary Javac should reject P<T>.{ref,val} preferring P.{ref,val}<T> instead - * @compile/fail/ref=MalformedParameterizedType.out -XDrawDiagnostics MalformedParameterizedType.java - */ - -final class MalformedParameterizedType { - - static primitive class P<T> {} - static primitive class RDP.val<T> {} - - P.ref<String> pr1; // OK - P.val<String> pv1; // OK - - P<String>.ref pr2; // Malformed - P<String>.val pv2; // Malformed - - RDP.ref<String> rdpr1; // OK - RDP.val<String> rdpv1; // OK - - RDP<String>.ref rdpr2; // Malformed - RDP<String>.val rdpv2; // Malformed -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/MalformedParameterizedType.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/MalformedParameterizedType.out deleted file mode 100644 index a6ff710f123..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/MalformedParameterizedType.out +++ /dev/null @@ -1,5 +0,0 @@ -MalformedParameterizedType.java:16:14: compiler.err.improperly.formed.type.param.missing -MalformedParameterizedType.java:17:14: compiler.err.improperly.formed.type.param.missing -MalformedParameterizedType.java:22:16: compiler.err.improperly.formed.type.param.missing -MalformedParameterizedType.java:23:16: compiler.err.improperly.formed.type.param.missing -4 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/NoCrashTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/NoCrashTest.java deleted file mode 100644 index b836a367e29..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/NoCrashTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2020, 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 8237072 - * @summary Test compiler on various constructs it had issues with. - */ - -import java.util.ArrayList; -import java.util.Arrays; - -public class NoCrashTest { - - interface I {} - static class C implements I {} - static primitive final class V.val implements I { int x = 0; } - - static void triggerNPE(V.ref [] vra) { - vra[0] = null; - } - - static String foo(V.val[] va) { - return "array of nonnull v's"; - } - - static String foo(Object [] oa) { - return "array of nullable o's"; - } - - static public void main(String[] args) { - I arg = args.length == 0 ? new V() : new C(); - V.val [] xs = new V.val[0]; - Object [] os = new Object [0]; - Object [] o = args.length == 0 ? xs : os; - Object o2 = (o == null) ? new V() : new Object(); - - triggerNPE(new V.ref[1]); // NO NPE. - try { - triggerNPE(new V.val[1]); - throw new RuntimeException("Should not get here!"); - } catch (NullPointerException npe) { - // all is well. - } - - V.val [] v = new V.val[0]; - if (!foo((V.ref []) v).equals("array of nullable o's")) - throw new AssertionError("Broken"); - - ArrayList<V.ref> vList = new ArrayList<V.ref>(Arrays.asList(new V.ref[10])); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/OverloadingPhaseTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/OverloadingPhaseTest.java deleted file mode 100644 index 55ef3b59f17..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/OverloadingPhaseTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8237072 - * @summary Test various relationships between a value type and its reference projection. - * @compile/fail/ref=OverloadingPhaseTest.out -XDrawDiagnostics OverloadingPhaseTest.java - */ - -public class OverloadingPhaseTest { - - static primitive class V.val { - int x = 0; - } - - static String roo(V v, int i) { - return "Phase 1"; - } - - static String roo(V v, Integer i) { - return "Phase 2"; - } - - public static void main(String args) { - V.val o = new V(); - String result; - - if (!(result = roo(o, 0)).equals("phase 2")) - throw new AssertionError("Broken: got " + result); - if (!(result = roo(o, Integer.valueOf(0))).equals("phase 2")) - throw new AssertionError("Broken: got " + result); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/OverloadingPhaseTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/OverloadingPhaseTest.out deleted file mode 100644 index f75fe35cf00..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/OverloadingPhaseTest.out +++ /dev/null @@ -1,3 +0,0 @@ -OverloadingPhaseTest.java:26:24: compiler.err.ref.ambiguous: roo, kindname.method, roo(OverloadingPhaseTest.V,int), OverloadingPhaseTest, kindname.method, roo(OverloadingPhaseTest.V,java.lang.Integer), OverloadingPhaseTest -OverloadingPhaseTest.java:28:24: compiler.err.ref.ambiguous: roo, kindname.method, roo(OverloadingPhaseTest.V,int), OverloadingPhaseTest, kindname.method, roo(OverloadingPhaseTest.V,java.lang.Integer), OverloadingPhaseTest -2 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ParameterizedDefault.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ParameterizedDefault.java deleted file mode 100644 index 13199ac2f8f..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ParameterizedDefault.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018, 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 8210906 8215109 - * @summary [lworld] default value creation should not impose raw types on users. - * @run main/othervm ParameterizedDefault - */ - -public primitive class ParameterizedDefault.val<E> { - E value; - ParameterizedDefault(E value) { this.value = value; } - static String foo (Object p) { - return ("Object version"); - } - static String foo (String p) { - return ("String version"); - } - static String foo (java.util.Date p) { - return ("Date version"); - } - public static void main(String [] args) { - var foo = ParameterizedDefault.val.default; - var soo = ParameterizedDefault.val<String>.default; - if (!foo(foo.value).equals("Object version") || - !foo(soo.value).equals("String version") || - !foo(ParameterizedDefault.val<java.util.Date>.default.value).equals("Date version")) - throw new AssertionError("Broken"); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/Point.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/Point.java deleted file mode 100644 index 646dc380550..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/Point.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2014, 2020, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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 - * @summary Test basic syntax of values - * - * @compile -XDallowWithFieldOperator Point.java - */ - -primitive class Point.val { - static final Point origin = makePoint(10, 20); - static final Point origin2 = makePoint(10, 20); - int x; - int y; - Point () { - x = 10; - y = 20; - } - static Point.val makePoint(int x, int y) { - Point.val p = Point.val.default; - p = __WithField(p.x, x); - p = __WithField(p.y, y); - return p; - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectedArrayDotClass.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectedArrayDotClass.java deleted file mode 100644 index dc76448e72e..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectedArrayDotClass.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2019, 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 8222722 - * @summary Javac fails to compile V?[].class (syntax dead) - * @modules jdk.compiler/com.sun.tools.javac.util jdk.jdeps/com.sun.tools.javap - * @compile ProjectedArrayDotClass.java - * @run main/othervm -Xverify:none ProjectedArrayDotClass - * @modules jdk.compiler - */ - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.Paths; - -public class ProjectedArrayDotClass { - - static primitive class VT.val { - int x = 42; - public static void main(String[] args) { - System.out.println(VT[].class); - System.out.println(VT.val[].class); - System.out.println(ProjectedArrayDotClass.VT[].class); - System.out.println(ProjectedArrayDotClass.VT.val[].class); - } - } - - public static void main(String[] args) { - new ProjectedArrayDotClass().run(); - } - - void run() { - String [] params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "ProjectedArrayDotClass$VT.class").toString() }; - runCheck(params, new String [] { - " 3: ldc #13 // class \"[LProjectedArrayDotClass$VT;\"", - " 11: ldc #21 // class \"[QProjectedArrayDotClass$VT;\"", - " 19: ldc #13 // class \"[LProjectedArrayDotClass$VT;\"", - " 27: ldc #21 // class \"[QProjectedArrayDotClass$VT;\"", - }); - - } - - void runCheck(String [] params, String [] expectedOut) { - StringWriter s; - String out; - - try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { - com.sun.tools.javap.Main.run(params, pw); - out = s.toString(); - } - int errors = 0; - for (String eo: expectedOut) { - if (!out.contains(eo)) { - System.err.println("Match not found for string: " + eo); - errors++; - } - } - if (errors > 0) { - throw new AssertionError("Unexpected javap output: " + out); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectionInstantiationTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectionInstantiationTest.java deleted file mode 100644 index 3bb5df1edba..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectionInstantiationTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8244561 8250997 - * @summary Javac should not allow instantiation of V.ref or V.val - * @compile/fail/ref=ProjectionInstantiationTest.out -XDrawDiagnostics ProjectionInstantiationTest.java - */ -import java.util.function.Supplier; - -final class ProjectionInstantiationTest { - - static primitive class ValDefault {} - - static primitive class RefDefault.val<T> {} - - public static void main(String[] args) { - - // Next two instantiations are good. - var v1 = new ValDefault(); - var v2 = new RefDefault<>(); - - v1 = v2; - - // Next four instantiations are problematic - new ValDefault.ref(); - new RefDefault.ref<>(); - new ValDefault.val(); - new RefDefault.val<>(); - - // Next two references are good. - voo(ValDefault::new); - roo(RefDefault::new); - - // Next four references are problematic - voo(ValDefault.ref::new); - voo(ValDefault.val::new); - roo(RefDefault.ref::new); - roo(RefDefault.val::new); - } - - static void voo(Supplier<ValDefault.ref> sx) { - sx.get(); - } - - static void roo(Supplier<RefDefault.ref> sx) { - sx.get(); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectionInstantiationTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectionInstantiationTest.out deleted file mode 100644 index f1b71e31d92..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectionInstantiationTest.out +++ /dev/null @@ -1,10 +0,0 @@ -ProjectionInstantiationTest.java:21:14: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: ProjectionInstantiationTest.RefDefault.val<java.lang.Object>, ProjectionInstantiationTest.ValDefault) -ProjectionInstantiationTest.java:24:9: compiler.err.projection.cant.be.instantiated -ProjectionInstantiationTest.java:25:9: compiler.err.projection.cant.be.instantiated -ProjectionInstantiationTest.java:26:9: compiler.err.projection.cant.be.instantiated -ProjectionInstantiationTest.java:27:9: compiler.err.projection.cant.be.instantiated -ProjectionInstantiationTest.java:34:23: compiler.err.projection.cant.be.instantiated -ProjectionInstantiationTest.java:35:23: compiler.err.projection.cant.be.instantiated -ProjectionInstantiationTest.java:36:23: compiler.err.projection.cant.be.instantiated -ProjectionInstantiationTest.java:37:23: compiler.err.projection.cant.be.instantiated -9 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectionRelationsTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectionRelationsTest.java deleted file mode 100644 index b2a513bb93a..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProjectionRelationsTest.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (c) 2020, 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 8237072 - * @summary Test various relationships between a value type and its reference projection. - * @library /tools/lib - * @modules jdk.compiler/com.sun.tools.javac.api - * jdk.compiler/com.sun.tools.javac.code - * jdk.compiler/com.sun.tools.javac.util - */ - -import java.io.StringWriter; -import javax.tools.JavaFileObject; -import javax.tools.ToolProvider; -import javax.lang.model.element.Element; -import com.sun.source.util.JavacTask; -import com.sun.tools.javac.api.JavacTool; -import com.sun.tools.javac.code.Type; -import com.sun.tools.javac.code.Types; -import com.sun.tools.javac.code.Symtab; -import com.sun.tools.javac.code.Symbol; -import com.sun.tools.javac.code.Symbol.ClassSymbol; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Assert; -import com.sun.tools.javac.util.List; -import com.sun.tools.javac.util.Names; - -import toolbox.ToolBox; - -public class ProjectionRelationsTest { - - private static final ToolBox tb = new ToolBox(); - - enum Relation { - SUBTYPING, - CASTING, - ASSIGNING, - } - - public static void main(String... args) throws Exception { - String code = "primitive class C.val {\n" + - " C cref = new C();\n" + - " C.val [] ca = null;\n" + - " C [] cra = null;\n" + - " Object[] oa = null;\n" + - "}\n"; - List<JavaFileObject> files = List.of(new ToolBox.JavaSource(code)); - - JavacTool compiler = (JavacTool) ToolProvider.getSystemJavaCompiler(); - StringWriter out = new StringWriter(); - - Context context = new Context(); - - JavacTask task = (JavacTask) compiler.getTask(out, null, null, List.of("-XDinlinesAreIslands"), null, files, context); - Iterable<? extends Element> elements = task.analyze(); - if (elements == null || !elements.iterator().hasNext()) { - throw new RuntimeException("Didn't compile alright!"); - } - - Names names = Names.instance(context); - - ClassSymbol valueCls = (ClassSymbol) elements.iterator().next(); - Type vType = valueCls.type.asValueType(); - Type vDotRefType = valueCls.members().findFirst(names.fromString("cref")).type; - Type vArrayType = valueCls.members().findFirst(names.fromString("ca")).type; - Type vRefArrayType = valueCls.members().findFirst(names.fromString("cra")).type; - Type jlOArrayType = valueCls.members().findFirst(names.fromString("oa")).type; - - for (Relation relation : Relation.values()) { - testRelation(context, relation, vType, vDotRefType); - testRelation(context, relation, vArrayType, vRefArrayType, jlOArrayType); - } - } - - static void testRelation(Context context, Relation relation, Type vType, Type vDotRefType) { - Types types = Types.instance(context); - Symtab syms = Symtab.instance(context); - Type intType = syms.intType; - Type objectType = syms.objectType; - Type integerType = types.boxedTypeOrType(syms.intType); - Type stringType = syms.stringType; - - System.out.println("Testing relation " + relation + " between " + - vType.tsym.name + " and " + vDotRefType.tsym.name); - switch (relation) { - case SUBTYPING: - - // self check - Assert.check(types.isSubtype(vType, vType)); - Assert.check(types.isSubtype(vDotRefType, vDotRefType)); - - Assert.check(types.isSubtype(vType, vDotRefType) == - types.isSubtype(intType, integerType)); - Assert.check(types.isSubtype(vDotRefType, vType) == - types.isSubtype(integerType, intType)); - - Assert.check(types.isSubtype(vType, objectType) == - types.isSubtype(intType, objectType)); - Assert.check(types.isSubtype(objectType, vType) == - types.isSubtype(objectType, intType)); - - Assert.check(types.isSubtype(vDotRefType, objectType) == - types.isSubtype(integerType, objectType)); - Assert.check(types.isSubtype(objectType, vDotRefType) == - types.isSubtype(objectType, integerType)); - - // check against a totally unrelated class. - Assert.check(types.isSubtype(vType, stringType) == - types.isSubtype(intType, stringType)); - Assert.check(types.isSubtype(stringType, vType) == - types.isSubtype(stringType, intType)); - - Assert.check(types.isSubtype(vDotRefType, stringType) == - types.isSubtype(integerType, stringType)); - Assert.check(types.isSubtype(stringType, vDotRefType) == - types.isSubtype(stringType, integerType)); - break; - - case CASTING: - - // self check - Assert.check(types.isCastable(vType, vType)); - Assert.check(types.isCastable(vDotRefType, vDotRefType)); - - Assert.check(types.isCastable(vType, vDotRefType) == - types.isCastable(intType, integerType)); - Assert.check(types.isCastable(vDotRefType, vType) == - types.isCastable(integerType, intType)); - Assert.check(types.isCastable(vType, objectType) == - types.isCastable(intType, objectType)); - Assert.check(types.isCastable(objectType, vType) == - types.isCastable(objectType, intType)); - Assert.check(types.isCastable(vDotRefType, objectType) == - types.isCastable(integerType, objectType)); - Assert.check(types.isCastable(objectType, vDotRefType) == - types.isCastable(objectType, integerType)); - // check against a totally unrelated class. - Assert.check(types.isCastable(vType, stringType) == - types.isCastable(intType, stringType)); - Assert.check(types.isCastable(stringType, vType) == - types.isCastable(stringType, intType)); - - Assert.check(types.isCastable(vDotRefType, stringType) == - types.isCastable(integerType, stringType)); - Assert.check(types.isCastable(stringType, vDotRefType) == - types.isCastable(stringType, integerType)); - break; - - case ASSIGNING: - - // self check - Assert.check(types.isAssignable(vType, vType)); - Assert.check(types.isAssignable(vDotRefType, vDotRefType)); - - Assert.check(types.isAssignable(vType, vDotRefType) == - types.isAssignable(intType, integerType)); - Assert.check(types.isAssignable(vDotRefType, vType) == - types.isAssignable(integerType, intType)); - Assert.check(types.isAssignable(vType, objectType) == - types.isAssignable(intType, objectType)); - Assert.check(types.isAssignable(objectType, vType) == - types.isAssignable(objectType, intType)); - Assert.check(types.isAssignable(vDotRefType, objectType) == - types.isAssignable(integerType, objectType)); - Assert.check(types.isAssignable(objectType, vDotRefType) == - types.isAssignable(objectType, integerType)); - // check against a totally unrelated class. - Assert.check(types.isAssignable(vType, stringType) == - types.isAssignable(intType, stringType)); - Assert.check(types.isAssignable(stringType, vType) == - types.isAssignable(stringType, intType)); - - Assert.check(types.isAssignable(vDotRefType, stringType) == - types.isAssignable(integerType, stringType)); - Assert.check(types.isAssignable(stringType, vDotRefType) == - types.isAssignable(stringType, integerType)); - break; - } - } - - static void testRelation(Context context, Relation relation, Type vArrayType, Type vDotRefArrayType, Type objectArrayType) { - Types types = Types.instance(context); - Symtab syms = Symtab.instance(context); - - System.out.println("Testing relation " + relation + " between " + - vArrayType.tsym.name + " and " + vDotRefArrayType.tsym.name); - switch (relation) { - case SUBTYPING: - - /* check against self */ - Assert.check(types.isSubtype(vArrayType, vArrayType)); - Assert.check(types.isSubtype(vDotRefArrayType, vDotRefArrayType)); - - /* check against valid supers */ - Assert.check(types.isSubtype(vArrayType, vDotRefArrayType)); - Assert.check(types.isSubtype(vArrayType, objectArrayType)); - Assert.check(types.isSubtype(vArrayType, syms.objectType)); - Assert.check(types.isSubtype(vDotRefArrayType, objectArrayType)); - Assert.check(types.isSubtype(vDotRefArrayType, syms.objectType)); - - /* check negative cases */ - Assert.check(!types.isSubtype(vDotRefArrayType, vArrayType)); - Assert.check(!types.isSubtype(objectArrayType, vArrayType)); - Assert.check(!types.isSubtype(objectArrayType, vDotRefArrayType)); - - break; - - case CASTING: - - /* check self cast */ - Assert.check(types.isCastable(vArrayType, vArrayType)); - Assert.check(types.isCastable(vDotRefArrayType, vDotRefArrayType)); - - /* check widening cast of V */ - Assert.check(types.isCastable(vArrayType, vDotRefArrayType)); - Assert.check(types.isCastable(vArrayType, objectArrayType)); - Assert.check(types.isCastable(vArrayType, syms.objectType)); - - /* check cast of V.ref to supers */ - Assert.check(types.isCastable(vDotRefArrayType, objectArrayType)); - Assert.check(types.isCastable(vDotRefArrayType, syms.objectType)); - - /* check downcasts */ - Assert.check(types.isCastable(vDotRefArrayType, vArrayType)); - Assert.check(types.isCastable(objectArrayType, vArrayType)); - Assert.check(types.isCastable(objectArrayType, vDotRefArrayType)); - Assert.check(types.isCastable(syms.objectType, vArrayType)); - Assert.check(types.isCastable(syms.objectType, vDotRefArrayType)); - - break; - - case ASSIGNING: - - /* check self */ - Assert.check(types.isAssignable(vArrayType, vArrayType)); - Assert.check(types.isAssignable(vDotRefArrayType, vDotRefArrayType)); - - /* check widening */ - Assert.check(types.isAssignable(vArrayType, vDotRefArrayType)); - Assert.check(types.isAssignable(vArrayType, objectArrayType)); - Assert.check(types.isAssignable(vArrayType, syms.objectType)); - - /* check more widening */ - Assert.check(types.isAssignable(vDotRefArrayType, objectArrayType)); - Assert.check(types.isAssignable(vDotRefArrayType, syms.objectType)); - - /* misc */ - Assert.check(!types.isAssignable(vDotRefArrayType, vArrayType)); - Assert.check(!types.isAssignable(objectArrayType, vArrayType)); - Assert.check(!types.isAssignable(objectArrayType, vDotRefArrayType)); - Assert.check(!types.isAssignable(syms.objectType, vArrayType)); - Assert.check(!types.isAssignable(syms.objectType, vDotRefArrayType)); - - break; - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProperTypeApplySelectTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProperTypeApplySelectTest.java deleted file mode 100644 index f354fc716ac..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ProperTypeApplySelectTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2020, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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 8244559 - * @summary Check that javac transforms Types to AST nodes properly. - * @run main ProperTypeApplySelectTest - */ - -import java.util.List; - -public class ProperTypeApplySelectTest { - - static String out = ""; - - primitive static class Foo.val<V> { - int x; - Foo(int x) { this.x = x; } - } - - static void m(Foo.val foo) { - out += "inline"; - } - static void m(Foo.ref foo) { - out += "ref"; - } - - public static void main(String[] args) { - List<Foo.ref<Integer>> list = List.of(new Foo<Integer>(3)); - list.stream().forEach(e -> m(e)); - if (!out.equals("ref")) - throw new AssertionError("Unexpected: " + out); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/QTypeTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/QTypeTest.java deleted file mode 100644 index 2e93267343a..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/QTypeTest.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2018, 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 8212563 - * @summary Check that javac emits Q types for values as needed - * @modules jdk.compiler/com.sun.tools.javac.util jdk.jdeps/com.sun.tools.javap - * @compile QTypedValue.java - * @run main/othervm -Xverify:none QTypeTest - * @modules jdk.compiler - */ - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.Paths; - -public class QTypeTest { - - public static void main(String[] args) { - new QTypeTest().run(); - } - - void run() { - String [] params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "QTypedValue.class").toString() }; - runCheck(params, new String [] { - "final primitive class QTypedValue", - " flags: (0x0130) ACC_FINAL, ACC_SUPER, ACC_PRIMITIVE", - " this_class: #1 // QTypedValue", - " #1 = Class #2 // QTypedValue", - " #2 = Utf8 QTypedValue", - " #3 = Class #4 // \"QQTypedValue;\"", - " #4 = Utf8 QQTypedValue;", - " #5 = Fieldref #1.#6 // QTypedValue.f1:[QQTypedValue;", - " #8 = Utf8 [QQTypedValue;", - " #9 = Fieldref #1.#10 // QTypedValue.f2:[QQTypedValue;", - " #12 = Class #13 // \"[[[QQTypedValue;\"", - " #13 = Utf8 [[[QQTypedValue;", - " #14 = Fieldref #1.#15 // QTypedValue.f3:[[[QQTypedValue;", - " #17 = Fieldref #1.#18 // QTypedValue.f4:[[[QQTypedValue;", - " #27 = Utf8 (QQTypedValue;I)V", - " #21 = NameAndType #22:#23 // \"<init>\":()QQTypedValue;", - " #25 = NameAndType #26:#27 // foo:(QQTypedValue;I)V", - " #6 = NameAndType #7:#8 // f1:[QQTypedValue;", - " #10 = NameAndType #11:#8 // f2:[QQTypedValue;", - " #15 = NameAndType #16:#13 // f3:[[[QQTypedValue;", - " #18 = NameAndType #19:#13 // f4:[[[QQTypedValue;", - " final QTypedValue[] f1;", - " descriptor: [QQTypedValue;", - " flags: (0x0010) ACC_FINAL", - " final QTypedValue[] f2;", - " descriptor: [QQTypedValue;", - " flags: (0x0010) ACC_FINAL", - " final QTypedValue[][][] f3;", - " descriptor: [[[QQTypedValue;", - " flags: (0x0010) ACC_FINAL", - " final QTypedValue[][][] f4;", - " descriptor: [[[QQTypedValue;", - " flags: (0x0010) ACC_FINAL", - " void foo(QTypedValue, int);", - " descriptor: (QQTypedValue;I)V", - " flags: (0x0000)", - " Code:", - " stack=3, locals=12, args_size=3", - " 0: aload_0", - " 1: invokestatic #20 // Method \"<init>\":()QQTypedValue;", - " 4: bipush 10", - " 6: invokevirtual #24 // Method foo:(QQTypedValue;I)V", - " 9: iload_2", - " 10: ifne 34", - " 13: iconst_0", - " 14: istore 8", - " 16: dconst_0", - " 17: dstore 9", - " 19: invokestatic #20 // Method \"<init>\":()QQTypedValue;", - " 22: astore_3", - " 23: iload 8", - " 25: ifne 29", - " 28: return", - " 29: invokestatic #20 // Method \"<init>\":()QQTypedValue;", - " 32: astore 11", - " 34: return", - " StackMapTable: number_of_entries = 2", - " frame_type = 255 /* full_frame */", - " offset_delta = 29", - " locals = [ class \"QQTypedValue;\", class \"QQTypedValue;\", int, class \"QQTypedValue;\", top, top, top, top, int, double ]", - " stack = []", - " frame_type = 255 /* full_frame */", - " offset_delta = 4", - " locals = [ class \"QQTypedValue;\", class \"QQTypedValue;\", int ]", - " stack = []", - "static QTypedValue QTypedValue();", - " descriptor: ()QQTypedValue;", - " flags: (0x0008) ACC_STATIC", - " Code:", - " stack=2, locals=1, args_size=0", - " 0: defaultvalue #1 // class QTypedValue", - " 3: astore_0", - " 4: bipush 10", - " 6: anewarray #3 // class \"QQTypedValue;\"", - " 9: aload_0", - " 10: swap", - " 11: withfield #5 // Field f1:[QQTypedValue;", - " 14: astore_0", - " 15: bipush 10", - " 17: anewarray #3 // class \"QQTypedValue;\"", - " 20: aload_0", - " 21: swap", - " 22: withfield #9 // Field f2:[QQTypedValue;", - " 25: astore_0", - " 26: bipush 10", - " 28: bipush 10", - " 30: multianewarray #12, 2 // class \"[[[QQTypedValue;\"", - " 34: aload_0", - " 35: swap", - " 36: withfield #14 // Field f3:[[[QQTypedValue;", - " 39: astore_0", - " 40: bipush 10", - " 42: bipush 10", - " 44: multianewarray #12, 2 // class \"[[[QQTypedValue;\"", - " 48: aload_0", - " 49: swap", - " 50: withfield #17 // Field f4:[[[QQTypedValue;", - " 53: astore_0", - " 54: aload_0", - " 55: areturn", - }, new String [] { - }); - - } - - void runCheck(String [] params, String [] expectedOut, String [] unexpectedOut) { - StringWriter s; - String out; - - try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { - com.sun.tools.javap.Main.run(params, pw); - out = s.toString(); - } - int errors = 0; - for (String eo: expectedOut) { - if (!out.contains(eo)) { - System.err.println("Match not found for string: " + eo); - errors++; - } - } - for (String eo: unexpectedOut) { - if (out.contains(eo)) { - System.err.println("Unexpected output found for string: " + eo); - errors++; - } - } - if (errors > 0) { - throw new AssertionError("Unexpected javap output: " + out); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/QTypedValue.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/QTypedValue.java deleted file mode 100644 index 32ebec2280e..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/QTypedValue.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2018, 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. - */ - -primitive class QTypedValue.val { - - QTypedValue.val [] f1 = new QTypedValue.val[10]; - QTypedValue.val [] f2 = new QTypedValue.val[10]; - - QTypedValue.val [][][] f3 = new QTypedValue.val[10][10][]; - QTypedValue.val [][][] f4 = new QTypedValue.val[10][10][]; - - void foo(QTypedValue.val x, int i) { - foo(new QTypedValue(), 10); - QTypedValue.val x1, x2, x4, x5, x6; - if (i == 0) { - int j = 0; double d = 0.0; - x1 = new QTypedValue(); - if (j == 0) - return; - QTypedValue.val x9 = new QTypedValue(); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/Rectangle.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/Rectangle.java deleted file mode 100644 index 8b911acdd97..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/Rectangle.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -public primitive class Rectangle.val { - - Point.val topLeft, bottomRight; - - static Point.val origin; - - static Rectangle.val from (Point.ref topLeft, Point.ref bottomRight) { - return new Rectangle(topLeft, bottomRight); - } - - Rectangle (Point.val topLeft, Point.val bottomRight) { - this.topLeft = topLeft; - this.bottomRight = bottomRight; - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/StreamsTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/StreamsTest.java deleted file mode 100644 index 6d354b326c1..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/StreamsTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2020, 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 8244982 - * @summary Javac has trouble compiling method references - * @run main StreamsTest - */ - -import java.util.Arrays; - -public class StreamsTest { - - public static primitive class X.val { - - String data; - - X(String data) { - this.data = data; - } - - String data() { return data; } - - static String accumulate = ""; - - static void accumulate(String s) { - accumulate += s; - } - - static String streamedData() { - - X.val [] xs = new X.val[] { - new X("Streams "), - new X("test "), - new X("passed OK!") - }; - - Arrays.stream(xs) - .map(X.ref::data) - .filter(p -> p != null) - .forEach(X::accumulate); - - return accumulate; - } - } - - public static void main(String [] args) { - if (!X.streamedData().equals("Streams test passed OK!")) - throw new AssertionError("Unexpected data in stream"); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TreeCopierTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TreeCopierTest.java deleted file mode 100644 index 8aadbe6c926..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TreeCopierTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8244231 - * @summary Test that tree copier is able to handle reference and value projection types. - * @compile/fail/ref=TreeCopierTest.out -XDrawDiagnostics TreeCopierTest.java - */ - - -final class TreeCopierTest { - - static primitive class RefDefault.val {} - static primitive class GenericRefDefault.val<T> {} - - static primitive class ValDefault {} - static primitive class GenericValDefault<T> {} - - public static void main(String[] args) { - - var v1 = (RefDefault.val) new RefDefault(); - var v2 = (GenericRefDefault.val<Object>) new GenericRefDefault<>(); - v1 = v2; - - var v3 = (ValDefault.ref) new ValDefault(); - var v4 = (GenericValDefault.ref<Object>) new GenericValDefault<>(); - v3 = v4; - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TreeCopierTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TreeCopierTest.out deleted file mode 100644 index d1afdcff5f3..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TreeCopierTest.out +++ /dev/null @@ -1,3 +0,0 @@ -TreeCopierTest.java:21:14: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TreeCopierTest.GenericRefDefault.val<java.lang.Object>, TreeCopierTest.RefDefault.val) -TreeCopierTest.java:25:14: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TreeCopierTest.GenericValDefault.ref<java.lang.Object>, TreeCopierTest.ValDefault.ref) -2 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TypeRelationsNegativeTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TypeRelationsNegativeTest.java deleted file mode 100644 index 4b6b95773ad..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TypeRelationsNegativeTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8222792 - * @summary Javac should enforce the latest relationship rules between an inline type and its nullable projection - * @compile/fail/ref=TypeRelationsNegativeTest.out -XDrawDiagnostics TypeRelationsNegativeTest.java - */ - -final primitive class TypeRelationsNegativeTest.val { - - void foo() { - TypeRelationsNegativeTest.val x = null; // error - TypeRelationsNegativeTest xq = null; - - xq = x; - xq = (TypeRelationsNegativeTest) x; - xq = (TypeRelationsNegativeTest.val) x; - x = xq; - x = (TypeRelationsNegativeTest) xq; - x = (TypeRelationsNegativeTest.val) xq; - - TypeRelationsNegativeTest.val [] xa = new TypeRelationsNegativeTest.val[] { null }; // error - TypeRelationsNegativeTest [] xqa = new TypeRelationsNegativeTest.ref[] { null }; - - xqa = xa; - xqa = (TypeRelationsNegativeTest[]) xa; - xa = xqa;// error - xa = (TypeRelationsNegativeTest.val []) xqa; - } - int x = 10; -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TypeRelationsNegativeTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TypeRelationsNegativeTest.out deleted file mode 100644 index 34796fb9f87..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TypeRelationsNegativeTest.out +++ /dev/null @@ -1,4 +0,0 @@ -TypeRelationsNegativeTest.java:11:43: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, TypeRelationsNegativeTest.val) -TypeRelationsNegativeTest.java:21:85: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, TypeRelationsNegativeTest.val) -TypeRelationsNegativeTest.java:26:14: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TypeRelationsNegativeTest[], TypeRelationsNegativeTest.val[]) -3 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TypeRelationsTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TypeRelationsTest.java deleted file mode 100644 index 218729be672..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/TypeRelationsTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2019, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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 8222792 - * @summary Javac should enforce the latest relationship rules between an inline type and its nullable projection - * @run main/othervm TypeRelationsTest - */ - -public primitive class TypeRelationsTest.val { - - int x = 42; - - static boolean foo(TypeRelationsTest.val x, TypeRelationsTest xq, boolean nullPassed) { - TypeRelationsTest.val xl; - TypeRelationsTest xql; - boolean npe = false; - - xl = x; - xl = (TypeRelationsTest.val) x; - try { - xl = (TypeRelationsTest.val) xq; - } catch (NullPointerException e) { - npe = true; - } - - xql = x; - xql = (TypeRelationsTest) x; - xql = xq; - xql = (TypeRelationsTest) xq; - return npe; - } - - static String foo(Object o) { - return "Object"; - } - - static String foo(TypeRelationsTest.val x) { - return "TypeRelationsTest.val"; - } - - static String foo(TypeRelationsTest xq) { - return "TypeRelationsTest.ref"; - } - - public static void main(String [] args) { - if (foo(new TypeRelationsTest(), new TypeRelationsTest(), false)) - throw new AssertionError("Unexpected NPE"); - if (!foo(new TypeRelationsTest(), null, true)) - throw new AssertionError("Missing NPE"); - - TypeRelationsTest.val x = new TypeRelationsTest(); - TypeRelationsTest xq = null; - if (!foo(x).equals("TypeRelationsTest.val")) - throw new AssertionError("Wrong overload"); - if (!foo(xq).equals("TypeRelationsTest.ref")) - throw new AssertionError("Wrong overload"); - if (!foo((TypeRelationsTest) x).equals("TypeRelationsTest.ref")) - throw new AssertionError("Wrong overload"); - - boolean npe = false; - try { - foo((TypeRelationsTest.val) xq); - } catch (NullPointerException e) { - npe = true; - } - if (!npe) { - throw new AssertionError("Missing NPE"); - } - xq = x; - if (!foo((TypeRelationsTest) xq).equals("TypeRelationsTest.ref")) - throw new AssertionError("Wrong overload"); - checkArrays(); - } - - static void checkArrays() { - TypeRelationsTest.val [] xa = new TypeRelationsTest.val[10]; - TypeRelationsTest [] xqa; - Object [] oa; - Object o; - - o = oa = xqa = xa; - xa = (TypeRelationsTest.val []) (xqa = (TypeRelationsTest[]) (oa = (Object []) o)); - xa[0] = new TypeRelationsTest(); // OK, after round trip back and forth. - - - xqa = (TypeRelationsTest[]) xa; - boolean npe = false; - try { - xqa[0] = null; - } catch (NullPointerException e) { - npe = true; - } - if (!npe) { - throw new AssertionError("Missing NPE"); - } - npe = false; - - oa = xa; - try { - oa[0] = null; - } catch (NullPointerException e) { - npe = true; - } - if (!npe) { - throw new AssertionError("Missing NPE"); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/UnifiedPrimitiveClassBytecodeTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/UnifiedPrimitiveClassBytecodeTest.java deleted file mode 100644 index 0e0aee3c379..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/UnifiedPrimitiveClassBytecodeTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2021, 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 8265423 - * @summary Experimental support for generating a single class file per primitive class - * @modules jdk.compiler/com.sun.tools.javac.util jdk.jdeps/com.sun.tools.javap - * @run main UnifiedPrimitiveClassBytecodeTest - * @modules jdk.compiler - */ - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.Paths; - -public class UnifiedPrimitiveClassBytecodeTest { - - public primitive class X.val { - - X xr = null; - - public void foo(X[] xra, X.val[] xa) { - xa = new X.val[10]; - xra = new X[10]; - xra[0] = xa[0]; - xa[1] = xra[0]; - Class<?> c = X.val.class; - c = X.class; - } - } - - public static void main(String[] args) { - new UnifiedPrimitiveClassBytecodeTest().run(); - } - - void run() { - String [] params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "UnifiedPrimitiveClassBytecodeTest$X.class").toString() }; - runCheck(params, new String [] { - - // check field - "final UnifiedPrimitiveClassBytecodeTest$X xr;", - "descriptor: LUnifiedPrimitiveClassBytecodeTest$X;", - "flags: (0x0010) ACC_FINAL", - - // check method - "public void foo(UnifiedPrimitiveClassBytecodeTest$X[], UnifiedPrimitiveClassBytecodeTest$X[]);", - "descriptor: ([LUnifiedPrimitiveClassBytecodeTest$X;[QUnifiedPrimitiveClassBytecodeTest$X;)V", - " 0: bipush 10", - " 2: anewarray #11 // class \"QUnifiedPrimitiveClassBytecodeTest$X;\"", - " 5: astore_2", - " 6: bipush 10", - " 8: anewarray #1 // class UnifiedPrimitiveClassBytecodeTest$X", - "11: astore_1", - "12: aload_1", - "13: iconst_0", - "14: aload_2", - "15: iconst_0", - "16: aaload", - "17: checkcast #1 // class UnifiedPrimitiveClassBytecodeTest$X", - "20: aastore", - "21: aload_2", - "22: iconst_1", - "23: aload_1", - "24: iconst_0", - "25: aaload", - "26: checkcast #11 // class \"QUnifiedPrimitiveClassBytecodeTest$X;\"", - "29: aastore", - "30: ldc #11 // class \"QUnifiedPrimitiveClassBytecodeTest$X;\"", - "32: astore_3", - "33: ldc #1 // class UnifiedPrimitiveClassBytecodeTest$X", - "35: astore_3", - "36: return", - }); - } - - void runCheck(String [] params, String [] expectedOut) { - StringWriter s; - String out; - - try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { - com.sun.tools.javap.Main.run(params, pw); - out = s.toString(); - } - int errors = 0; - for (String eo: expectedOut) { - if (!out.contains(eo)) { - System.err.println("Match not found for string: " + eo); - errors++; - } - } - if (errors > 0) { - throw new AssertionError("Unexpected javap output: " + out); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueBootstrapMethodsTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueBootstrapMethodsTest.java deleted file mode 100644 index 35ea435896d..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueBootstrapMethodsTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * @summary test value bootstrap methods - * @run main/othervm -Dvalue.bsm.salt=1 ValueBootstrapMethodsTest - */ - -import java.util.List; -import java.util.Objects; - -public class ValueBootstrapMethodsTest { - - public static final primitive class Value.val { - private final int i; - private final double d; - private final String s; - private final List<String> l; - Value(int i, double d, String s, String... items) { - this.i = i; - this.d = d; - this.s = s; - this.l = List.of(items); - } - - private List<Object> values() { - return List.of(Value.val.class, i, d, s, l); - } - - public int localHashCode() { - return values().hashCode(); - } - - public String localToString() { - System.out.println(l); - return String.format("%s@%s", Value.class.getName(), Integer.toHexString(localHashCode())); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Value) { - Value v = (Value)obj; - return this.i == v.i && this.d == v.d && - Objects.equals(this.s, v.s) && - Objects.equals(this.l, this.l); - } - return false; - } - } - - private static void assertEquals(Object o1, Object expected) { - if (!Objects.equals(o1, expected)) { - throw new RuntimeException(o1 + " expected: " + expected); - } - } - - public static void main(String... args) throws Throwable { - - Value.val value = new Value(10, 5.03, "foo", "bar", "goo"); - - assertEquals(value.localHashCode(), value.hashCode()); - assertEquals(value.localToString(), value.toString()); - - // verify ifacmp and the overridden equals method - - // same instance - if (value != value || !value.equals(value)) { - throw new RuntimeException("expected == and equals"); - } - - // value and v2 are of different values - Value.val v2 = new Value(20, 5.03, "foo", "bar", "goo"); - if (value == v2 || value.equals(v2)) { - throw new RuntimeException("expected != and unequals"); - } - - // v2 and v3 are of different values but Value::equals - // returns true because v2::l and v3::l field contain the same elements - Value.val v3 = new Value(20, 5.03, "foo", "bar", "goo"); - if (v2 == v3 || !v2.equals(v3)) { - throw new RuntimeException("expected != and equals"); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueCreationTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueCreationTest.java deleted file mode 100644 index 67d2d23a01c..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueCreationTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * @summary Check code generation for value creation ops - * @modules jdk.compiler/com.sun.tools.javac.util jdk.jdeps/com.sun.tools.javap - * @compile ValueCreationTest.java - * @run main/othervm -Xverify:none ValueCreationTest - * @modules jdk.compiler - */ - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.Paths; - -public class ValueCreationTest { - - primitive - static final class Point.val { - - final int x; - final int y; - - Point (int x, int y) { - this.x = x; - this.y = y; - } - - public static void main(String [] args) { - Point.val p = new Point(10, 20); - } - } - - public static void main(String[] args) { - new ValueCreationTest().run(); - } - - void run() { - String [] params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "ValueCreationTest$Point.class").toString() }; - runCheck(params, new String [] { - - "0: defaultvalue #1 // class ValueCreationTest$Point", - "3: astore_2", - "4: iload_0", - "5: aload_2", - "6: swap", - "7: withfield #3 // Field x:I", - "10: astore_2", - "11: iload_1", - "12: aload_2", - "13: swap", - "14: withfield #7 // Field y:I", - "17: astore_2", - "18: aload_2", - "19: areturn" - }); - - } - - void runCheck(String [] params, String [] expectedOut) { - StringWriter s; - String out; - - try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { - com.sun.tools.javap.Main.run(params, pw); - out = s.toString(); - } - int errors = 0; - for (String eo: expectedOut) { - if (!out.contains(eo)) { - System.err.println("Match not found for string: " + eo); - errors++; - } - } - if (errors > 0) { - throw new AssertionError("Unexpected javap output: " + out); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueOverGenericsTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueOverGenericsTest.java deleted file mode 100644 index dad54386e3d..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueOverGenericsTest.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @summary Value types cannot parameterize generic types (except under experimental mode) - * @compile/fail/ref=ValueOverGenericsTest.out -XDrawDiagnostics ValueOverGenericsTest.java - * - */ - -import java.util.ArrayList; -import java.io.Serializable; - -primitive class ValueOverGenericsTest.val { - int x = 10; - ArrayList<ValueOverGenericsTest.val> ax = null; - void foo(ArrayList<? extends ValueOverGenericsTest.val> p) { - new <ValueOverGenericsTest.val> ArrayList<Object>(); - this.<ValueOverGenericsTest.val>foo(null); - Object o = (ValueOverGenericsTest.val & Serializable) null; - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueOverGenericsTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueOverGenericsTest.out deleted file mode 100644 index 58833cd385c..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValueOverGenericsTest.out +++ /dev/null @@ -1,7 +0,0 @@ -ValueOverGenericsTest.java:13:36: compiler.err.type.found.req: ValueOverGenericsTest.val, (compiler.misc.type.req.ref) -ValueOverGenericsTest.java:14:24: compiler.err.type.found.req: ValueOverGenericsTest.val, (compiler.misc.type.req.ref) -ValueOverGenericsTest.java:15:35: compiler.err.type.found.req: ValueOverGenericsTest.val, (compiler.misc.type.req.ref) -ValueOverGenericsTest.java:16:36: compiler.err.type.found.req: ValueOverGenericsTest.val, (compiler.misc.type.req.ref) -ValueOverGenericsTest.java:17:42: compiler.err.type.found.req: ValueOverGenericsTest.val, (compiler.misc.type.req.ref) -ValueOverGenericsTest.java:17:63: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, ValueOverGenericsTest.val&java.io.Serializable) -6 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValuesAsRefs.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValuesAsRefs.java deleted file mode 100644 index a50e7042856..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/ValuesAsRefs.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2018, 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 8251116 - * @summary Test that values code like a class - i.e are accepted in some places where only references used be, when suitable reference projection is used. - @compile ValuesAsRefs.java - * @run main/othervm ValuesAsRefs - */ -import java.util.ArrayList; - -public final primitive class ValuesAsRefs.val { - - final ArrayList<? extends ValuesAsRefs> ao = null; // values can be wildcard bounds. - - final primitive class I.val implements java.io.Serializable { - final int y = 42; - } - - void foo() { - I.val i = this.new I(); // values can be enclosing instances. - i = ValuesAsRefs.I.val.default; - Object o = (I & java.io.Serializable) i; // values can be used in intersection casts - } - <T> void goo() { - this.<ValuesAsRefs>goo(); // values can be type arguments to generic method calls - } - - public static void main(String [] args) { - Object o = null; - ArrayList<ValuesAsRefs.I> aloi = new ArrayList<>(); // values can be type arguments. - boolean OK = false; - try { - aloi.add((ValuesAsRefs.I.val) o); - } catch (NullPointerException npe) { - OK = true; - } - if (!OK) - throw new AssertionError("Missing NPE"); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldAccessorTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldAccessorTest.java deleted file mode 100644 index 8236182e3a1..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldAccessorTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018, 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 8206147 - * @summary WithField operation on a private inner field should be enclosed in a suitable accessor method. - * @compile -XDallowWithFieldOperator WithFieldAccessorTest.java - * @run main/othervm WithFieldAccessorTest - */ - -public class WithFieldAccessorTest { - - public static final primitive class V.val { - private final int i; - V() { - this.i = 0; - } - - public static V.val make(int i) { - V.val v = V.val.default; - v = __WithField(v.i, i); - return v; - } - } - - public static void main(String... args) throws Throwable { - V.val v = __WithField(V.make(10).i, 20); - if (v.i != 20) - throw new AssertionError("Withfield didn't work!"); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOfExplicitSelector.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOfExplicitSelector.java deleted file mode 100644 index dcb445a63f9..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOfExplicitSelector.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * @summary Check code generation for value creation ops - * @modules jdk.compiler/com.sun.tools.javac.util jdk.jdeps/com.sun.tools.javap - * @compile -XDallowWithFieldOperator WithFieldOfExplicitSelector.java - * @run main/othervm -Xverify:none WithFieldOfExplicitSelector - * @modules jdk.compiler - */ - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.Paths; - -public class WithFieldOfExplicitSelector { - - final primitive class X.val { - - final int i; - - X() { - i = 10; - } - - X.val getX(int i, Integer in) { - X.val xl = __WithField(this.i, i); - xl = __WithField(xl.i, in); - return xl; - } - } - - public static void main(String[] args) { - new WithFieldOfExplicitSelector().run(); - } - - void run() { - String [] params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "WithFieldOfExplicitSelector$X.class").toString() }; - runCheck(params, new String [] { - - "0: iload_1", - "1: aload_0", - "2: swap", - "3: withfield #7 // Field i:I", - "6: astore_3", - "7: aload_2", - "8: invokevirtual #11 // Method java/lang/Integer.intValue:()I", - "11: aload_3", - "12: swap", - "13: withfield #7 // Field i:I", - "16: astore_3", - "17: aload_3", - "18: areturn" - }); - } - - void runCheck(String [] params, String [] expectedOut) { - StringWriter s; - String out; - - try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { - com.sun.tools.javap.Main.run(params, pw); - out = s.toString(); - } - int errors = 0; - for (String eo: expectedOut) { - if (!out.contains(eo)) { - System.err.println("Match not found for string: " + eo); - errors++; - } - } - if (errors > 0) { - throw new AssertionError("Unexpected javap output: " + out); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOfGenericType.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOfGenericType.java deleted file mode 100644 index 2b5531d71e9..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOfGenericType.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018, 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 8205686 8215109 - * @summary __WithField seems to have trouble if the value type is a generic type. - * @compile -XDrawDiagnostics -XDdev -XDallowWithFieldOperator WithFieldOfGenericType.java - * @run main/othervm WithFieldOfGenericType - */ - -public final primitive class WithFieldOfGenericType.val<E> { - private final boolean value; - - public static <E> WithFieldOfGenericType.val<E> create() { - WithFieldOfGenericType.val<E> bug = WithFieldOfGenericType.val.default; - bug = __WithField(bug.value, true); - return bug; - } - - private WithFieldOfGenericType() { - value = false; - throw new AssertionError(); - } - - public static void main(String[] args) { - WithFieldOfGenericType.val<String> w = create(); - if (w.value != true) - throw new AssertionError("Withfield didn't work!"); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOfImplicitThis.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOfImplicitThis.java deleted file mode 100644 index 5dbd9ceabba..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOfImplicitThis.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * @summary Check code generation for value creation ops - * @modules jdk.compiler/com.sun.tools.javac.util jdk.jdeps/com.sun.tools.javap - * @compile -XDallowWithFieldOperator WithFieldOfImplicitThis.java - * @run main/othervm -Xverify:none WithFieldOfImplicitThis - * @modules jdk.compiler - */ - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.Paths; - -public class WithFieldOfImplicitThis { - - final primitive class X.val { - - final int x; - - X() { - x = 10; - } - - X.val getX(Integer xVal, int xi) { - X.val xl = X.val.default; - xl = __WithField(x, xi); - xl = __WithField(x, xVal); - return xl; - } - } - - public static void main(String[] args) { - new WithFieldOfImplicitThis().run(); - } - - void run() { - String [] params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "WithFieldOfImplicitThis$X.class").toString() }; - runCheck(params, new String [] { - - "0: defaultvalue #1 // class WithFieldOfImplicitThis$X", - "3: astore_3", - "4: aload_0", - "5: iload_2", - "6: withfield #7 // Field x:I", - "9: astore_3", - "10: aload_0", - "11: aload_1", - "12: invokevirtual #11 // Method java/lang/Integer.intValue:()I", - "15: withfield #7 // Field x:I", - "18: astore_3", - "19: aload_3", - "20: areturn" - }); - } - - void runCheck(String [] params, String [] expectedOut) { - StringWriter s; - String out; - - try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { - com.sun.tools.javap.Main.run(params, pw); - out = s.toString(); - } - int errors = 0; - for (String eo: expectedOut) { - if (!out.contains(eo)) { - System.err.println("Match not found for string: " + eo); - errors++; - } - } - if (errors > 0) { - throw new AssertionError("Unexpected javap output: " + out); - } - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOperatorTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOperatorTest.java deleted file mode 100644 index 94ae6b3e326..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOperatorTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @summary Verify that various errors related to __WithField operator are caught. - * @compile/fail/ref=WithFieldOperatorTest.out -XDallowWithFieldOperator -XDrawDiagnostics -XDdev WithFieldOperatorTest.java - */ - -public class WithFieldOperatorTest { - static int xs; - int ifld; - class Y {} - public final primitive class V.val { int x = 10; } - - public final primitive class X.val { - - final int x; - final V.val v; - - X() { - x = 10; - v = V.val.default; - } - - X.val getX(int xVal, WithFieldOperatorTest wfot) { - X.val x = X.val.default; - x = __WithField(new Y(), null); // not a variable at all. - x = __WithField(wfot.xs, 10); // not an instance field. - x = __WithField(wfot.ifld, 10); // not a field of value type - x = __WithField(xVal, xVal); // not a field - x = __WithField(this, this); // not a field - x = __WithField(X.this, this); // not a field - x = __WithField(x.x, 12.0); // float cannot be assigned to int - x = __WithField(x.v, null); // null cannot be assigned to value - return x; - } - } -} - -class WithFieldOperatorTest_aux { - void foo(WithFieldOperatorTest.X.val x) { - x = __WithField(x.x, 10); // outside the nest - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOperatorTest.out b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOperatorTest.out deleted file mode 100644 index 7433be8b102..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldOperatorTest.out +++ /dev/null @@ -1,10 +0,0 @@ -WithFieldOperatorTest.java:25:29: compiler.err.unexpected.type: kindname.variable, kindname.value -WithFieldOperatorTest.java:26:33: compiler.err.primitive.class.instance.field.expected.here -WithFieldOperatorTest.java:27:33: compiler.err.primitive.class.instance.field.expected.here -WithFieldOperatorTest.java:28:29: compiler.err.primitive.class.instance.field.expected.here -WithFieldOperatorTest.java:29:29: compiler.err.cant.assign.val.to.this -WithFieldOperatorTest.java:30:30: compiler.err.cant.assign.val.to.this -WithFieldOperatorTest.java:31:34: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, int) -WithFieldOperatorTest.java:32:34: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, WithFieldOperatorTest.V.val) -WithFieldOperatorTest.java:40:26: compiler.err.cant.assign.val.to.final.var: x -9 errors diff --git a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldRuntimeTest.java b/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldRuntimeTest.java deleted file mode 100644 index 34e0214373f..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/RefDefault/WithFieldRuntimeTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * @summary Test withfield behavior at runtime. - * @compile -XDallowWithFieldOperator WithFieldRuntimeTest.java - * @run main/othervm WithFieldRuntimeTest - */ - -public final primitive class WithFieldRuntimeTest.val { - - final int x = 10; - - static void foo(WithFieldRuntimeTest.val x) { - if (x.x != 0) - throw new AssertionError("Expected default value, found something else."); - x = __WithField(x.x, 20); - if (x.x != 20) - throw new AssertionError("Expected updated value, found something else."); - } - - public static void main(String [] args) { - WithFieldRuntimeTest.val x = WithFieldRuntimeTest.val.default; - foo(x); - } -} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/TestReflectiveMirrors.java b/test/langtools/tools/javac/valhalla/lworld-values/TestReflectiveMirrors.java index 78466fb5e1f..79ec977184a 100644 --- a/test/langtools/tools/javac/valhalla/lworld-values/TestReflectiveMirrors.java +++ b/test/langtools/tools/javac/valhalla/lworld-values/TestReflectiveMirrors.java @@ -32,23 +32,10 @@ public class TestReflectiveMirrors { - static primitive class RefDefault.val {} static primitive class ValDefault {} public static void main(String [] args) { - if (RefDefault.class != new RefDefault().getClass()) { - throw new AssertionError("Wrong mirror"); - } - - if (RefDefault.ref.class != new RefDefault().getClass()) { - throw new AssertionError("Wrong mirror"); - } - - if (RefDefault.val.class != new RefDefault().getClass().asValueType()) { - throw new AssertionError("Wrong mirror"); - } - if (ValDefault.class != new ValDefault().getClass()) { throw new AssertionError("Wrong mirror"); } @@ -61,18 +48,6 @@ public static void main(String [] args) { throw new AssertionError("Wrong mirror"); } - if (TestReflectiveMirrors.RefDefault.class != new RefDefault().getClass()) { - throw new AssertionError("Wrong mirror"); - } - - if (TestReflectiveMirrors.RefDefault.ref.class != new RefDefault().getClass()) { - throw new AssertionError("Wrong mirror"); - } - - if (TestReflectiveMirrors.RefDefault.val.class != new RefDefault().getClass().asValueType()) { - throw new AssertionError("Wrong mirror"); - } - if (TestReflectiveMirrors.ValDefault.class != new ValDefault().getClass()) { throw new AssertionError("Wrong mirror"); } diff --git a/test/langtools/tools/javac/valhalla/lworld-values/records/RefFlavoredRecord.java b/test/langtools/tools/javac/valhalla/lworld-values/records/RefFlavoredRecord.java deleted file mode 100644 index a287591b226..00000000000 --- a/test/langtools/tools/javac/valhalla/lworld-values/records/RefFlavoredRecord.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021, 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 8271583 - * @summary [lworld] primitive records can't be reference favoring - * @run main/othervm RefFlavoredRecord - */ - -public primitive record RefFlavoredRecord.val(int theInteger, String theString) { - public static void main(String[] args) { - RefFlavoredRecord rec = RefFlavoredRecord.default; - if (rec != null) { - throw new AssertionError("Ref-favoring record .default should be null?"); - } - - if (! new RefFlavoredRecord(42, "Fortytwo").equals(new RefFlavoredRecord(42, "Fortytwo"))) { - throw new AssertionError("Records should be equal"); - } - } -}