Skip to content

Commit 2816de0

Browse files
author
Vicente Romero
committed
Remove parametric nullity and nullable marker
1 parent 0ed7b82 commit 2816de0

File tree

10 files changed

+8
-73
lines changed

10 files changed

+8
-73
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,9 +2197,6 @@ private void addBound(InferenceBound ib, Type bound, Types types, boolean update
21972197
}
21982198
} else {
21992199
Type bound2 = bound.map(toTypeVarMap).baseType();
2200-
if (types.isParametric(qtype)) {
2201-
bound2 = bound2.asNullMarked(bound.getNullMarker());
2202-
}
22032200
List<Type> prevBounds = bounds.get(ib);
22042201
if (bound == qtype) return;
22052202
for (Type b : prevBounds) {

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ public class Types {
107107

108108
/* are nullable and null-restricted types allowed? */
109109
private boolean allowNullRestrictedTypes;
110-
private boolean tvarUnspecifiedNullity;
111110

112111
// <editor-fold defaultstate="collapsed" desc="Instantiating">
113112
public static Types instance(Context context) {
@@ -139,7 +138,6 @@ public String toString() {
139138
Source.Feature.NULL_RESTRICTED_TYPES.allowedInSource(source);
140139
Options options = Options.instance(context);
141140
dumpStacktraceOnError = options.isSet("dev") || options.isSet(DOE);
142-
tvarUnspecifiedNullity = options.isSet("tvarUnspecifiedNullity");
143141
}
144142
// </editor-fold>
145143

@@ -2435,9 +2433,7 @@ public Type visitClassType(ClassType t, Symbol sym) {
24352433
} else {
24362434
ListBuffer<Type> newBaseParams = new ListBuffer<>();
24372435
for (Type tvar : ownerParams) {
2438-
Type baseParam = isParametric(tvar) ?
2439-
baseParams.head :
2440-
baseParams.head.asNullMarked(NullMarker.UNSPECIFIED);
2436+
Type baseParam = baseParams.head.asNullMarked(NullMarker.UNSPECIFIED);
24412437
newBaseParams.add(baseParam);
24422438
baseParams = baseParams.tail;
24432439
}
@@ -5583,22 +5579,12 @@ public Type constantType(LoadableConstant c) {
55835579

55845580
// <editor-fold defaultstate="collapsed" desc="nullability methods">
55855581

5586-
public boolean isNullable(Type type) {
5587-
return type.getNullMarker() == NullMarker.NULLABLE;
5588-
}
5589-
55905582
public boolean isNonNullable(Type type) {
55915583
return type.getNullMarker() == NullMarker.NOT_NULL;
55925584
}
55935585

5594-
public boolean isParametric(Type type) {
5595-
return type.getNullMarker() == NullMarker.PARAMETRIC ||
5596-
(type.hasTag(TYPEVAR) && type.getNullMarker() == NullMarker.UNSPECIFIED && !tvarUnspecifiedNullity);
5597-
}
5598-
55995586
public boolean isNullUnspecified(Type type) {
5600-
return type.getNullMarker() == NullMarker.UNSPECIFIED &&
5601-
(!type.hasTag(TYPEVAR) || tvarUnspecifiedNullity);
5587+
return type.getNullMarker() == NullMarker.UNSPECIFIED;
56025588
}
56035589

56045590
/**

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4818,16 +4818,6 @@ public void visitSelect(JCFieldAccess tree) {
48184818
if (!pkind().contains(KindSelector.TYP_PCK))
48194819
site = capture(site); // Capture field access
48204820

4821-
// check nullness of site
4822-
if (types.isNullable(site)) {
4823-
chk.warnNullableTypes(tree.selected, LintWarnings.AccessingMemberOfNullable);
4824-
}
4825-
4826-
if (types.isParametric(site)) {
4827-
// see JDK-8339087
4828-
//chk.warnNullableTypes(tree.selected, Warnings.AccessingMemberOfParametric);
4829-
}
4830-
48314821
// don't allow T.class T[].class, etc
48324822
if (skind == KindSelector.TYP) {
48334823
Type elt = site;

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4524,10 +4524,6 @@ public void warn(LintCategory lint) {
45244524
} else {
45254525
boolean warned = this.warned;
45264526
if (warned) return;
4527-
if (types.isParametric(expected)) {
4528-
// not sure this is the right warning
4529-
Check.this.warnNullableTypes(pos(), LintWarnings.NarrowingNullnessConversion);
4530-
}
45314527
}
45324528
}
45334529
}

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,13 +1751,6 @@ boolean isFinalOrStrictUninitializedField(VarSymbol sym) {
17511751
classDef.sym.isEnclosedBy((ClassSymbol)sym.owner));
17521752
}
17531753

1754-
boolean isUninitializedNonNullableOrParametricField(VarSymbol sym) {
1755-
return sym.owner.kind == TYP &&
1756-
((sym.flags() & (FINAL | HASINIT | PARAMETER)) == 0 &&
1757-
classDef.sym.isEnclosedBy((ClassSymbol)sym.owner) &&
1758-
(types.isNonNullable(sym.type) || types.isParametric(sym.type)));
1759-
}
1760-
17611754
boolean isUninitializedNonNullableField(VarSymbol sym) {
17621755
return sym.owner.kind == TYP &&
17631756
((sym.flags() & (FINAL | HASINIT | PARAMETER)) == 0 &&
@@ -1866,9 +1859,6 @@ void checkInit(DiagnosticPosition pos, VarSymbol sym, Error errkey) {
18661859
if (isUninitializedNonNullableField(sym)) {
18671860
if (types.isNonNullable(sym.type)) {
18681861
log.error(pos, Errors.NonNullableShouldBeInitialized);
1869-
} else {
1870-
// see JDK-8339087
1871-
//log.warning(pos, Warnings.ParametricShouldBeInitialized);
18721862
}
18731863
} else {
18741864
log.error(pos, errkey);

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,8 @@ Type classSigToType() {
609609
sbp = startSbp;
610610
}
611611
}
612-
case '?': case '!' : case '=': {
613-
char nmChar = (char) c;
614-
nm = (nmChar == '=' ? NullMarker.PARAMETRIC : NullMarker.of(String.valueOf(nmChar)));
612+
case '!' : {
613+
nm = NullMarker.NOT_NULL;
615614
continue;
616615
}
617616
case '<': // generic arguments
@@ -684,9 +683,8 @@ public List<Type> getTypeArguments() {
684683
}
685684
};
686685
char currentCh = (char)signature[sigp];
687-
if (currentCh == '?' || currentCh == '!' || currentCh == '=' ) {
688-
nm = (currentCh == '=' ? NullMarker.PARAMETRIC : NullMarker.of(String.valueOf(currentCh)));
689-
outer = outer.asNullMarked(nm);
686+
if (currentCh == '!' ) {
687+
outer = outer.asNullMarked(NullMarker.NOT_NULL);
690688
sigp++;
691689
}
692690
switch (signature[sigp++]) {

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,15 +2017,7 @@ void setNullMarker(JCExpression exp) {
20172017

20182018
void setNullMarker(JCExpression exp, Token tk) {
20192019
checkSourceLevel(Feature.NULL_RESTRICTED_TYPES);
2020-
((JCNullableTypeExpression)exp).setNullMarker(nullMarker(tk));
2021-
}
2022-
2023-
NullMarker nullMarker(Token tk) {
2024-
return tk.kind == QUES ?
2025-
NullMarker.NULLABLE :
2026-
tk.kind == BANG ?
2027-
NullMarker.NOT_NULL :
2028-
NullMarker.PARAMETRIC;
2020+
((JCNullableTypeExpression)exp).setNullMarker(NullMarker.NOT_NULL);
20292021
}
20302022

20312023
/**

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4388,18 +4388,10 @@ compiler.warn.narrowing.nullness.conversion=\
43884388
compiler.warn.unchecked.nullness.conversion=\
43894389
unchecked nullness conversion
43904390

4391-
# lint: null
4392-
compiler.warn.parametric.should.be.initialized=\
4393-
field of parametric type should be initialized
4394-
43954391
# lint: null
43964392
compiler.warn.accessing.member.of.nullable=\
43974393
accessing member of nullable type
43984394

4399-
# lint: null
4400-
compiler.warn.accessing.member.of.parametric=\
4401-
accessing member of parametric type
4402-
44034395
# lint: null
44044396
compiler.warn.overrides.with.different.nullness.1=\
44054397
overriding method''s return type does not match nullness of overridden method
@@ -4409,4 +4401,4 @@ compiler.warn.overrides.with.different.nullness.2=\
44094401
overriding method''s parameter(s) type(s) do not match nullness of overridden method
44104402

44114403
compiler.err.unsupported.null.restriction=\
4412-
null restriction not supported in this type context
4404+
null restriction not supported in this type context

src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,8 +2925,6 @@ public JCNullableTypeExpression setNullMarker(NullMarker nullMarker) {
29252925

29262926
public enum NullMarker {
29272927
NOT_NULL("!"),
2928-
NULLABLE("?"),
2929-
PARAMETRIC("*"),
29302928
UNSPECIFIED("");
29312929

29322930
private final String typeSuffix;
@@ -2942,8 +2940,6 @@ public String typeSuffix() {
29422940
public static NullMarker of(String typeSuffix) {
29432941
return switch (typeSuffix) {
29442942
case "!" -> NOT_NULL;
2945-
case "?" -> NULLABLE;
2946-
case "*" -> PARAMETRIC;
29472943
case "" -> UNSPECIFIED;
29482944
default -> throw new AssertionError("invalid type suffix " + typeSuffix);
29492945
};

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,6 @@ compiler.warn.proc.use.proc.or.implicit
230230
compiler.misc.feature.null.restricted.types
231231
compiler.warn.accessing.member.of.nullable
232232
compiler.warn.narrowing.nullness.conversion
233-
compiler.warn.accessing.member.of.parametric
234-
compiler.warn.parametric.should.be.initialized
235233
compiler.misc.attribute.must.be.unique # bad class file
236234
compiler.misc.attribute.not.applicable.to.field.type # bad class file
237235
compiler.misc.attribute.only.applicable.to.fields # bad class file

0 commit comments

Comments
 (0)