Skip to content

Commit 25a3ae8

Browse files
author
Srikanth Adayapalam
committed
8255727: [lworld] Withdraw support for @java.lang.ValueBased
1 parent 2b18bce commit 25a3ae8

25 files changed

+7
-384
lines changed

src/java.base/share/classes/java/lang/ValueBased.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@ public static EnumSet<Flag> asFlagSet(long flags) {
139139
*/
140140
public static final int EMPTYNOARGCONSTR = 1<<18;
141141

142-
/** Flag is set for a value based class.
143-
*/
144-
public static final int VALUEBASED = 1<<19;
145-
146142
/** Flag is set for compiler-generated anonymous method symbols
147143
* that `own' an initializer block.
148144
*/
@@ -531,7 +527,6 @@ public enum Flag {
531527
HAS_RESOURCE(Flags.HAS_RESOURCE),
532528
POTENTIALLY_AMBIGUOUS(Flags.POTENTIALLY_AMBIGUOUS),
533529
ANONCONSTR_BASED(Flags.ANONCONSTR_BASED),
534-
VALUEBASED(Flags.VALUEBASED),
535530
NAME_FILLED(Flags.NAME_FILLED),
536531
PREVIEW_API(Flags.PREVIEW_API),
537532
PREVIEW_ESSENTIAL_API(Flags.PREVIEW_ESSENTIAL_API),

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ public static Symtab instance(Context context) {
222222
public final Type previewFeatureInternalType;
223223
public final Type typeDescriptorType;
224224
public final Type recordType;
225-
public final Type valueBasedType;
226225
public final Type identityObjectType;
227226

228227
/** The symbol representing the length field of an array.
@@ -597,7 +596,6 @@ public <R, P> R accept(ElementVisitor<R, P> v, P p) {
597596
previewFeatureInternalType = enterSyntheticAnnotation("jdk.internal.PreviewFeature+Annotation");
598597
typeDescriptorType = enterClass("java.lang.invoke.TypeDescriptor");
599598
recordType = enterClass("java.lang.Record");
600-
valueBasedType = enterClass("java.lang.ValueBased");
601599
identityObjectType = enterClass("java.lang.IdentityObject");
602600

603601
synthesizeEmptyInterfaceIfMissing(autoCloseableType);

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ public boolean isConvertible(Type t, Type s, Warner warn) {
611611
if (tValue != sValue) {
612612
return tValue ?
613613
isSubtype(t.referenceProjection(), s) :
614-
(!t.hasTag(BOT) || isValueBased(s)) && isSubtype(t, s.referenceProjection());
614+
!t.hasTag(BOT) && isSubtype(t, s.referenceProjection());
615615
}
616616

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

1014-
public boolean isValueBased(Type t) {
1015-
return allowValueBasedClasses && t != null && t.tsym != null && (t.tsym.flags() & Flags.VALUEBASED) != 0;
1016-
}
1017-
10181014
// <editor-fold defaultstate="collapsed" desc="isSubtype">
10191015
/**
10201016
* Is t an unchecked subtype of s?
@@ -1145,7 +1141,7 @@ public Boolean visitType(Type t, Type s) {
11451141
return isSubtypeNoCapture(t.getUpperBound(), s);
11461142
case BOT:
11471143
return
1148-
s.hasTag(BOT) || (s.hasTag(CLASS) && (!isValue(s) || isValueBased(s))) ||
1144+
s.hasTag(BOT) || (s.hasTag(CLASS) && !isValue(s)) ||
11491145
s.hasTag(ARRAY) || s.hasTag(TYPEVAR);
11501146
case WILDCARD: //we shouldn't be here - avoids crash (see 7034495)
11511147
case NONE:

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public class Check {
9696
private final Profile profile;
9797
private final Preview preview;
9898
private final boolean warnOnAnyAccessToMembers;
99-
private final boolean allowValueBasedClasses;
10099

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

@@ -614,9 +612,6 @@ Type checkType(final DiagnosticPosition pos, final Type found, final Type req, f
614612
if (req.hasTag(NONE))
615613
return found;
616614
if (checkContext.compatible(found, req, checkContext.checkWarner(pos, found, req))) {
617-
if (found.hasTag(BOT) && types.isValueBased(req)) {
618-
log.warning(pos, Warnings.SuspiciousMixOfNullWithValueBasedClass(req));
619-
}
620615
return found;
621616
} else {
622617
if (found.isNumeric() && req.isNumeric()) {
@@ -639,13 +634,6 @@ Type checkCastable(DiagnosticPosition pos, Type found, Type req) {
639634
}
640635
Type checkCastable(DiagnosticPosition pos, Type found, Type req, CheckContext checkContext) {
641636
if (types.isCastable(found, req, castWarner(pos, found, req))) {
642-
if (types.isValueBased(req)) {
643-
if (found.hasTag(BOT)) {
644-
log.warning(pos, Warnings.SuspiciousMixOfNullWithValueBasedClass(req));
645-
} else if (!types.isValueBased(found)) {
646-
log.warning(pos, Warnings.PotentialNullPollution(found));
647-
}
648-
}
649637
return req;
650638
} else {
651639
checkContext.report(pos, diags.fragment(Fragments.InconvertibleTypes(found, req)));
@@ -3266,13 +3254,6 @@ private void validateAnnotation(JCAnnotation a, JCTree declarationTree, Symbol s
32663254
log.error(a.pos(), Errors.BadFunctionalIntfAnno1(Fragments.NotAFunctionalIntf(s)));
32673255
}
32683256
}
3269-
if (a.annotationType.type.tsym == syms.valueBasedType.tsym) {
3270-
if (s.isInterface() || s.isEnum()) {
3271-
log.error(a.pos(), Errors.BadValueBasedAnno);
3272-
} else if (allowValueBasedClasses) {
3273-
s.flags_field |= VALUEBASED;
3274-
}
3275-
}
32763257
}
32773258

32783259
public void validateTypeAnnotation(JCAnnotation a, boolean isTypeParameter) {

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import static com.sun.tools.javac.code.TypeTag.VOID;
5555
import static com.sun.tools.javac.comp.Flow.ThisExposability.ALLOWED;
5656
import static com.sun.tools.javac.comp.Flow.ThisExposability.BANNED;
57-
import static com.sun.tools.javac.comp.Flow.ThisExposability.DISCOURAGED;
5857
import static com.sun.tools.javac.tree.JCTree.Tag.*;
5958

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

16681666
/**
@@ -1897,8 +1895,6 @@ void checkEmbryonicThisExposure(JCTree node) {
18971895
if (!inits.isMember(sym.adr)) {
18981896
if (this.thisExposability == BANNED) {
18991897
log.error(node, Errors.ThisExposedPrematurely);
1900-
} else {
1901-
log.warning(node, Warnings.ThisExposedPrematurely);
19021898
}
19031899
return; // don't flog a dead horse.
19041900
}
@@ -2126,9 +2122,7 @@ public void visitMethodDef(JCMethodDecl tree) {
21262122
firstadr = nextadr;
21272123
this.thisExposability = ALLOWED;
21282124
} else {
2129-
if (types.isValueBased(tree.sym.owner.type))
2130-
this.thisExposability = DISCOURAGED;
2131-
else if (types.isValue(tree.sym.owner.type))
2125+
if (types.isValue(tree.sym.owner.type))
21322126
this.thisExposability = BANNED;
21332127
else
21342128
this.thisExposability = ALLOWED;

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ public class ClassReader {
125125
*/
126126
public boolean saveParameterNames;
127127

128-
/** Switch: Should javac recongnize and handle value based classes specially ?
129-
*/
130-
private boolean allowValueBasedClasses;
131-
132128
/**
133129
* The currently selected profile.
134130
*/
@@ -286,7 +282,6 @@ protected ClassReader(Context context) {
286282
Feature.SEALED_CLASSES.allowedInSource(source);
287283

288284
saveParameterNames = options.isSet(PARAMETERS);
289-
allowValueBasedClasses = options.isSet("allowValueBasedClasses");
290285

291286
profile = Profile.instance(context);
292287

@@ -1479,8 +1474,6 @@ else if (proxy.type.tsym.flatName() == syms.profileType.tsym.flatName()) {
14791474
target = proxy;
14801475
} else if (proxy.type.tsym == syms.repeatableType.tsym) {
14811476
repeatable = proxy;
1482-
} else if (allowValueBasedClasses && sym.kind == TYP && proxy.type.tsym == syms.valueBasedType.tsym) {
1483-
sym.flags_field |= VALUEBASED;
14841477
} else if (proxy.type.tsym == syms.deprecatedType.tsym) {
14851478
sym.flags_field |= (DEPRECATED | DEPRECATED_ANNOTATION);
14861479
setFlagIfAttributeTrue(proxy, sym, names.forRemoval, DEPRECATED_REMOVAL);
@@ -2789,7 +2782,9 @@ long adjustClassFlags(long flags) {
27892782
}
27902783
if ((flags & ACC_INLINE) != 0) {
27912784
flags &= ~ACC_INLINE;
2792-
flags |= allowInlineTypes ? VALUE : allowValueBasedClasses ? VALUEBASED : 0;
2785+
if (allowInlineTypes) {
2786+
flags |= VALUE;
2787+
}
27932788
}
27942789
return flags & ~ACC_SUPER; // SUPER and SYNCHRONIZED bits overloaded
27952790
}

src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3764,26 +3764,12 @@ compiler.err.value.may.not.extend=\
37643764
compiler.err.value.instance.field.expected.here=\
37653765
withfield operator requires an instance field of an inline class here
37663766

3767-
compiler.err.bad.value.based.anno=\
3768-
Unexpected @ValueBased annotation
3769-
3770-
# 0: type
3771-
compiler.warn.suspicious.mix.of.null.with.value.based.class=\
3772-
Suspicious mix of null with value based class {0}
3773-
3774-
# 0: type
3775-
compiler.warn.potential.null.pollution=\
3776-
Potential null pollution from nullable type {0}
3777-
37783767
compiler.err.with.field.operator.disallowed=\
37793768
WithField operator is allowed only with -XDallowWithFieldOperator
37803769

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

3784-
compiler.warn.this.exposed.prematurely=\
3785-
value based type instance should not be passed around before being fully initialized
3786-
37873773
# 0: type
37883774
compiler.err.generic.parameterization.with.value.type=\
37893775
Inferred type {0} involves generic parameterization by an inline type

test/langtools/tools/javac/diags/examples.not-yet.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ compiler.err.preview.without.source.or.release
206206
compiler.err.cyclic.value.type.membership
207207
compiler.err.value.does.not.support
208208
compiler.err.value.may.not.extend
209-
compiler.warn.potential.null.pollution
210209
compiler.err.this.exposed.prematurely
211-
compiler.warn.this.exposed.prematurely
212210
compiler.err.inline.type.must.not.implement.identity.object
213211
compiler.err.concrete.supertype.for.inline.class
214212
compiler.err.super.class.cannot.be.inner

test/langtools/tools/javac/diags/examples/BadValueBasedAnno.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)