Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8255727: [lworld] Withdraw support for @java.lang.ValueBased #250

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

This file was deleted.

@@ -139,10 +139,6 @@ public static String toString(long flags) {
*/
public static final int EMPTYNOARGCONSTR = 1<<18;

/** Flag is set for a value based class.
*/
public static final int VALUEBASED = 1<<19;

/** Flag is set for compiler-generated anonymous method symbols
* that `own' an initializer block.
*/
@@ -531,7 +527,6 @@ public static boolean isConstant(Symbol.VarSymbol symbol) {
HAS_RESOURCE(Flags.HAS_RESOURCE),
POTENTIALLY_AMBIGUOUS(Flags.POTENTIALLY_AMBIGUOUS),
ANONCONSTR_BASED(Flags.ANONCONSTR_BASED),
VALUEBASED(Flags.VALUEBASED),
NAME_FILLED(Flags.NAME_FILLED),
PREVIEW_API(Flags.PREVIEW_API),
PREVIEW_ESSENTIAL_API(Flags.PREVIEW_ESSENTIAL_API),
@@ -222,7 +222,6 @@ public static Symtab instance(Context context) {
public final Type previewFeatureInternalType;
public final Type typeDescriptorType;
public final Type recordType;
public final Type valueBasedType;
public final Type identityObjectType;

/** The symbol representing the length field of an array.
@@ -597,7 +596,6 @@ public String toString() {
previewFeatureInternalType = enterSyntheticAnnotation("jdk.internal.PreviewFeature+Annotation");
typeDescriptorType = enterClass("java.lang.invoke.TypeDescriptor");
recordType = enterClass("java.lang.Record");
valueBasedType = enterClass("java.lang.ValueBased");
identityObjectType = enterClass("java.lang.IdentityObject");

synthesizeEmptyInterfaceIfMissing(autoCloseableType);
@@ -611,7 +611,7 @@ public boolean isConvertible(Type t, Type s, Warner warn) {
if (tValue != sValue) {
return tValue ?
isSubtype(t.referenceProjection(), s) :
(!t.hasTag(BOT) || isValueBased(s)) && isSubtype(t, s.referenceProjection());
!t.hasTag(BOT) && isSubtype(t, s.referenceProjection());
}

boolean tPrimitive = t.isPrimitive();
@@ -1011,10 +1011,6 @@ public boolean isValue(Type t) {
return t != null && t.tsym != null && (t.tsym.flags_field & Flags.VALUE) != 0;
}

public boolean isValueBased(Type t) {
return allowValueBasedClasses && t != null && t.tsym != null && (t.tsym.flags() & Flags.VALUEBASED) != 0;
}

// <editor-fold defaultstate="collapsed" desc="isSubtype">
/**
* Is t an unchecked subtype of s?
@@ -1145,7 +1141,7 @@ public Boolean visitType(Type t, Type s) {
return isSubtypeNoCapture(t.getUpperBound(), s);
case BOT:
return
s.hasTag(BOT) || (s.hasTag(CLASS) && (!isValue(s) || isValueBased(s))) ||
s.hasTag(BOT) || (s.hasTag(CLASS) && !isValue(s)) ||
s.hasTag(ARRAY) || s.hasTag(TYPEVAR);
case WILDCARD: //we shouldn't be here - avoids crash (see 7034495)
case NONE:
@@ -96,7 +96,6 @@
private final Profile profile;
private final Preview preview;
private final boolean warnOnAnyAccessToMembers;
private final boolean allowValueBasedClasses;

// The set of lint options currently in effect. It is initialized
// from the context, and then is set/reset as needed by Attr as it
@@ -137,7 +136,6 @@ protected Check(Context context) {
source = Source.instance(context);
target = Target.instance(context);
warnOnAnyAccessToMembers = options.isSet("warnOnAccessToMembers");
allowValueBasedClasses = options.isSet("allowValueBasedClasses");
Target target = Target.instance(context);
syntheticNameChar = target.syntheticNameChar();

@@ -614,9 +612,6 @@ Type checkType(final DiagnosticPosition pos, final Type found, final Type req, f
if (req.hasTag(NONE))
return found;
if (checkContext.compatible(found, req, checkContext.checkWarner(pos, found, req))) {
if (found.hasTag(BOT) && types.isValueBased(req)) {
log.warning(pos, Warnings.SuspiciousMixOfNullWithValueBasedClass(req));
}
return found;
} else {
if (found.isNumeric() && req.isNumeric()) {
@@ -639,13 +634,6 @@ Type checkCastable(DiagnosticPosition pos, Type found, Type req) {
}
Type checkCastable(DiagnosticPosition pos, Type found, Type req, CheckContext checkContext) {
if (types.isCastable(found, req, castWarner(pos, found, req))) {
if (types.isValueBased(req)) {
if (found.hasTag(BOT)) {
log.warning(pos, Warnings.SuspiciousMixOfNullWithValueBasedClass(req));
} else if (!types.isValueBased(found)) {
log.warning(pos, Warnings.PotentialNullPollution(found));
}
}
return req;
} else {
checkContext.report(pos, diags.fragment(Fragments.InconvertibleTypes(found, req)));
@@ -3266,13 +3254,6 @@ private void validateAnnotation(JCAnnotation a, JCTree declarationTree, Symbol s
log.error(a.pos(), Errors.BadFunctionalIntfAnno1(Fragments.NotAFunctionalIntf(s)));
}
}
if (a.annotationType.type.tsym == syms.valueBasedType.tsym) {
if (s.isInterface() || s.isEnum()) {
log.error(a.pos(), Errors.BadValueBasedAnno);
} else if (allowValueBasedClasses) {
s.flags_field |= VALUEBASED;
}
}
}

public void validateTypeAnnotation(JCAnnotation a, boolean isTypeParameter) {
@@ -54,7 +54,6 @@
import static com.sun.tools.javac.code.TypeTag.VOID;
import static com.sun.tools.javac.comp.Flow.ThisExposability.ALLOWED;
import static com.sun.tools.javac.comp.Flow.ThisExposability.BANNED;
import static com.sun.tools.javac.comp.Flow.ThisExposability.DISCOURAGED;
import static com.sun.tools.javac.tree.JCTree.Tag.*;

/** This pass implements dataflow analysis for Java programs though
@@ -1662,7 +1661,6 @@ public void visitClassDef(JCClassDecl tree) {
enum ThisExposability {
ALLOWED, // Normal Object classes - NOP
BANNED, // Value types - Error
DISCOURAGED // Value based types - Warning
}

/**
@@ -1897,8 +1895,6 @@ void checkEmbryonicThisExposure(JCTree node) {
if (!inits.isMember(sym.adr)) {
if (this.thisExposability == BANNED) {
log.error(node, Errors.ThisExposedPrematurely);
} else {
log.warning(node, Warnings.ThisExposedPrematurely);
}
return; // don't flog a dead horse.
}
@@ -2126,9 +2122,7 @@ public void visitMethodDef(JCMethodDecl tree) {
firstadr = nextadr;
this.thisExposability = ALLOWED;
} else {
if (types.isValueBased(tree.sym.owner.type))
this.thisExposability = DISCOURAGED;
else if (types.isValue(tree.sym.owner.type))
if (types.isValue(tree.sym.owner.type))
this.thisExposability = BANNED;
else
this.thisExposability = ALLOWED;
@@ -125,10 +125,6 @@
*/
public boolean saveParameterNames;

/** Switch: Should javac recongnize and handle value based classes specially ?
*/
private boolean allowValueBasedClasses;

/**
* The currently selected profile.
*/
@@ -286,7 +282,6 @@ protected ClassReader(Context context) {
Feature.SEALED_CLASSES.allowedInSource(source);

saveParameterNames = options.isSet(PARAMETERS);
allowValueBasedClasses = options.isSet("allowValueBasedClasses");

profile = Profile.instance(context);

@@ -1479,8 +1474,6 @@ else if (proxy.type.tsym.flatName() == syms.profileType.tsym.flatName()) {
target = proxy;
} else if (proxy.type.tsym == syms.repeatableType.tsym) {
repeatable = proxy;
} else if (allowValueBasedClasses && sym.kind == TYP && proxy.type.tsym == syms.valueBasedType.tsym) {
sym.flags_field |= VALUEBASED;
} else if (proxy.type.tsym == syms.deprecatedType.tsym) {
sym.flags_field |= (DEPRECATED | DEPRECATED_ANNOTATION);
setFlagIfAttributeTrue(proxy, sym, names.forRemoval, DEPRECATED_REMOVAL);
@@ -2789,7 +2782,9 @@ long adjustClassFlags(long flags) {
}
if ((flags & ACC_INLINE) != 0) {
flags &= ~ACC_INLINE;
flags |= allowInlineTypes ? VALUE : allowValueBasedClasses ? VALUEBASED : 0;
if (allowInlineTypes) {
flags |= VALUE;
}
}
return flags & ~ACC_SUPER; // SUPER and SYNCHRONIZED bits overloaded
}
@@ -3764,26 +3764,12 @@ compiler.err.value.may.not.extend=\
compiler.err.value.instance.field.expected.here=\
withfield operator requires an instance field of an inline class here

compiler.err.bad.value.based.anno=\
Unexpected @ValueBased annotation

# 0: type
compiler.warn.suspicious.mix.of.null.with.value.based.class=\
Suspicious mix of null with value based class {0}

# 0: type
compiler.warn.potential.null.pollution=\
Potential null pollution from nullable type {0}

compiler.err.with.field.operator.disallowed=\
WithField operator is allowed only with -XDallowWithFieldOperator

compiler.err.this.exposed.prematurely=\
Inine type instance should not be passed around before being fully initialized

compiler.warn.this.exposed.prematurely=\
value based type instance should not be passed around before being fully initialized

# 0: type
compiler.err.generic.parameterization.with.value.type=\
Inferred type {0} involves generic parameterization by an inline type
@@ -206,9 +206,7 @@ compiler.err.preview.without.source.or.release
compiler.err.cyclic.value.type.membership
compiler.err.value.does.not.support
compiler.err.value.may.not.extend
compiler.warn.potential.null.pollution
compiler.err.this.exposed.prematurely
compiler.warn.this.exposed.prematurely
compiler.err.inline.type.must.not.implement.identity.object
compiler.err.concrete.supertype.for.inline.class
compiler.err.super.class.cannot.be.inner

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -29,13 +29,12 @@
* @summary Check that casting to a value type involves a null check.
*
* @compile -XDallowWithFieldOperator Point.java
* @compile -XDallowValueBasedClasses -XDallowWithFieldOperator CastNullCheckTest.java
* @compile -XDallowWithFieldOperator CastNullCheckTest.java
* @run main/othervm CastNullCheckTest
*/

public class CastNullCheckTest {

@ValueBased
final inline class XX {
final int x = 10;
}