Skip to content

Commit 9a19eb6

Browse files
author
Vicente Romero
committedNov 21, 2020
8254105: allow static nested declarations
Reviewed-by: mcimadamore
1 parent 14de791 commit 9a19eb6

25 files changed

+567
-445
lines changed
 

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

+24-23
Original file line numberDiff line numberDiff line change
@@ -383,30 +383,31 @@ public static EnumSet<Flag> asFlagSet(long flags) {
383383
/** Modifier masks.
384384
*/
385385
public static final int
386-
AccessFlags = PUBLIC | PROTECTED | PRIVATE,
387-
LocalClassFlags = FINAL | ABSTRACT | STRICTFP | ENUM | SYNTHETIC,
388-
StaticLocalFlags = LocalClassFlags | STATIC | INTERFACE,
389-
MemberClassFlags = LocalClassFlags | INTERFACE | AccessFlags,
390-
MemberRecordFlags = MemberClassFlags | STATIC,
391-
ClassFlags = LocalClassFlags | INTERFACE | PUBLIC | ANNOTATION,
392-
InterfaceVarFlags = FINAL | STATIC | PUBLIC,
393-
VarFlags = AccessFlags | FINAL | STATIC |
394-
VOLATILE | TRANSIENT | ENUM,
395-
ConstructorFlags = AccessFlags,
396-
InterfaceMethodFlags = ABSTRACT | PUBLIC,
397-
MethodFlags = AccessFlags | ABSTRACT | STATIC | NATIVE |
398-
SYNCHRONIZED | FINAL | STRICTFP,
399-
RecordMethodFlags = AccessFlags | ABSTRACT | STATIC |
400-
SYNCHRONIZED | FINAL | STRICTFP;
386+
AccessFlags = PUBLIC | PROTECTED | PRIVATE,
387+
LocalClassFlags = FINAL | ABSTRACT | STRICTFP | ENUM | SYNTHETIC,
388+
StaticLocalFlags = LocalClassFlags | STATIC | INTERFACE,
389+
MemberClassFlags = LocalClassFlags | INTERFACE | AccessFlags,
390+
MemberStaticClassFlags = MemberClassFlags | STATIC,
391+
ClassFlags = LocalClassFlags | INTERFACE | PUBLIC | ANNOTATION,
392+
InterfaceVarFlags = FINAL | STATIC | PUBLIC,
393+
VarFlags = AccessFlags | FINAL | STATIC |
394+
VOLATILE | TRANSIENT | ENUM,
395+
ConstructorFlags = AccessFlags,
396+
InterfaceMethodFlags = ABSTRACT | PUBLIC,
397+
MethodFlags = AccessFlags | ABSTRACT | STATIC | NATIVE |
398+
SYNCHRONIZED | FINAL | STRICTFP,
399+
RecordMethodFlags = AccessFlags | ABSTRACT | STATIC |
400+
SYNCHRONIZED | FINAL | STRICTFP;
401401
public static final long
402-
ExtendedStandardFlags = (long)StandardFlags | DEFAULT | SEALED | NON_SEALED,
403-
ExtendedMemberClassFlags = (long)MemberClassFlags | SEALED | NON_SEALED,
404-
ExtendedClassFlags = (long)ClassFlags | SEALED | NON_SEALED,
405-
ModifierFlags = ((long)StandardFlags & ~INTERFACE) | DEFAULT | SEALED | NON_SEALED,
406-
InterfaceMethodMask = ABSTRACT | PRIVATE | STATIC | PUBLIC | STRICTFP | DEFAULT,
407-
AnnotationTypeElementMask = ABSTRACT | PUBLIC,
408-
LocalVarFlags = FINAL | PARAMETER,
409-
ReceiverParamFlags = PARAMETER;
402+
ExtendedStandardFlags = (long)StandardFlags | DEFAULT | SEALED | NON_SEALED,
403+
ExtendedMemberClassFlags = (long)MemberClassFlags | SEALED | NON_SEALED,
404+
ExtendedMemberStaticClassFlags = (long) MemberStaticClassFlags | SEALED | NON_SEALED,
405+
ExtendedClassFlags = (long)ClassFlags | SEALED | NON_SEALED,
406+
ModifierFlags = ((long)StandardFlags & ~INTERFACE) | DEFAULT | SEALED | NON_SEALED,
407+
InterfaceMethodMask = ABSTRACT | PRIVATE | STATIC | PUBLIC | STRICTFP | DEFAULT,
408+
AnnotationTypeElementMask = ABSTRACT | PUBLIC,
409+
LocalVarFlags = FINAL | PARAMETER,
410+
ReceiverParamFlags = PARAMETER;
410411

411412
@SuppressWarnings("preview")
412413
public static Set<Modifier> asModifierSet(long flags) {

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

+11-5
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ protected Attr(Context context) {
171171
allowReifiableTypesInInstanceof =
172172
Feature.REIFIABLE_TYPES_INSTANCEOF.allowedInSource(source) &&
173173
(!preview.isPreview(Feature.REIFIABLE_TYPES_INSTANCEOF) || preview.isEnabled());
174+
allowRecords = Feature.RECORDS.allowedInSource(source);
174175
sourceName = source.name;
175176
useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
176177

@@ -207,6 +208,10 @@ protected Attr(Context context) {
207208
*/
208209
boolean allowReifiableTypesInInstanceof;
209210

211+
/** Are records allowed
212+
*/
213+
private final boolean allowRecords;
214+
210215
/**
211216
* Switch: warn about use of variable before declaration?
212217
* RFE: 6425594
@@ -5309,14 +5314,15 @@ private void attribClassBody(Env<AttrContext> env, ClassSymbol c) {
53095314
attribStat(l.head, env);
53105315
// Check that declarations in inner classes are not static (JLS 8.1.2)
53115316
// Make an exception for static constants.
5312-
if (c.owner.kind != PCK &&
5313-
((c.flags() & STATIC) == 0 || c.name == names.empty) &&
5314-
(TreeInfo.flags(l.head) & (STATIC | INTERFACE)) != 0) {
5317+
if (!allowRecords &&
5318+
c.owner.kind != PCK &&
5319+
((c.flags() & STATIC) == 0 || c.name == names.empty) &&
5320+
(TreeInfo.flags(l.head) & (STATIC | INTERFACE)) != 0) {
53155321
Symbol sym = null;
53165322
if (l.head.hasTag(VARDEF)) sym = ((JCVariableDecl) l.head).sym;
53175323
if (sym == null ||
5318-
sym.kind != VAR ||
5319-
((VarSymbol) sym).getConstValue() == null)
5324+
sym.kind != VAR ||
5325+
((VarSymbol) sym).getConstValue() == null)
53205326
log.error(l.head.pos(), Errors.IclsCantHaveStaticDecl(c));
53215327
}
53225328
}

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

+6-9
Original file line numberDiff line numberDiff line change
@@ -1216,23 +1216,20 @@ else if ((sym.owner.flags_field & INTERFACE) != 0)
12161216
implicit |= sym.owner.flags_field & STRICTFP;
12171217
break;
12181218
case TYP:
1219-
if (sym.isLocal()) {
1219+
if (sym.owner.kind.matches(KindSelector.VAL_MTH)) {
12201220
boolean implicitlyStatic = !sym.isAnonymous() &&
12211221
((flags & RECORD) != 0 || (flags & ENUM) != 0 || (flags & INTERFACE) != 0);
12221222
boolean staticOrImplicitlyStatic = (flags & STATIC) != 0 || implicitlyStatic;
1223+
// local statics are allowed only if records are allowed too
12231224
mask = staticOrImplicitlyStatic && allowRecords && (flags & ANNOTATION) == 0 ? StaticLocalFlags : LocalClassFlags;
12241225
implicit = implicitlyStatic ? STATIC : implicit;
1225-
if (staticOrImplicitlyStatic) {
1226-
if (sym.owner.kind == TYP) {
1227-
log.error(pos, Errors.StaticDeclarationNotAllowedInInnerClasses);
1228-
}
1229-
}
12301226
} else if (sym.owner.kind == TYP) {
1231-
mask = (flags & RECORD) != 0 ? MemberRecordFlags : ExtendedMemberClassFlags;
1227+
// statics in inner classes are allowed only if records are allowed too
1228+
mask = ((flags & STATIC) != 0) && allowRecords ? ExtendedMemberStaticClassFlags : ExtendedMemberClassFlags;
12321229
if (sym.owner.owner.kind == PCK ||
1233-
(sym.owner.flags_field & STATIC) != 0)
1230+
(sym.owner.flags_field & STATIC) != 0) {
12341231
mask |= STATIC;
1235-
else if ((flags & ENUM) != 0 || (flags & RECORD) != 0) {
1232+
} else if (!allowRecords && ((flags & ENUM) != 0 || (flags & RECORD) != 0)) {
12361233
log.error(pos, Errors.StaticDeclarationNotAllowedInInnerClasses);
12371234
}
12381235
// Nested interfaces and enums are always STATIC (Spec ???)

‎test/langtools/tools/javac/AnonStaticMember_1.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
/*
2525
* @test
2626
* @bug 4279339
27-
* @summary Verify that an anonymous class cannot contain a static field.
27+
* @summary Verify that an anonymous class can contain a static field only if source >= 16
2828
* @author maddox
2929
*
30-
* @run compile/fail AnonStaticMember_1.java
30+
* @compile/fail/ref=AnonStaticMember_1.out -source 15 -XDrawDiagnostics AnonStaticMember_1.java
31+
* @compile AnonStaticMember_1.java
3132
*/
3233

3334
class AnonStaticMember_1 {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- compiler.warn.source.no.system.modules.path: 15
2+
AnonStaticMember_1.java:36:20: compiler.err.icls.cant.have.static.decl: compiler.misc.anonymous.class: AnonStaticMember_1$1
3+
1 error
4+
1 warning

‎test/langtools/tools/javac/AnonStaticMember_2.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/*
22
* @test /nodynamiccopyright/
33
* @bug 4279339 6969184
4-
* @summary Verify that an anonymous class cannot contain a static method.
4+
* @summary Verify that an anonymous class can contain a static method only if source >= 16
55
* @author maddox
66
*
7-
* @run compile/fail/ref=AnonStaticMember_2.out -XDrawDiagnostics AnonStaticMember_2.java
7+
* @compile/fail/ref=AnonStaticMember_2.out -source 15 -XDrawDiagnostics AnonStaticMember_2.java
8+
* @compile AnonStaticMember_2.java
89
*/
910

1011
class AnonStaticMember_2 {
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
AnonStaticMember_2.java:12:21: compiler.err.icls.cant.have.static.decl: compiler.misc.anonymous.class: AnonStaticMember_2$1
1+
- compiler.warn.source.no.system.modules.path: 15
2+
AnonStaticMember_2.java:13:21: compiler.err.icls.cant.have.static.decl: compiler.misc.anonymous.class: AnonStaticMember_2$1
23
1 error
4+
1 warning

‎test/langtools/tools/javac/InnerNamedConstant_2.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* @summary Verify rejection of illegal static variables in inner classes.
55
* @author William Maddox (maddox)
66
*
7-
* @compile/fail/ref=InnerNamedConstant_2.out -XDrawDiagnostics InnerNamedConstant_2.java
7+
* @compile/fail/ref=InnerNamedConstant_2_A.out -XDrawDiagnostics -source 15 InnerNamedConstant_2.java
8+
* @compile/fail/ref=InnerNamedConstant_2_B.out -XDrawDiagnostics InnerNamedConstant_2.java
89
*/
910

1011
public class InnerNamedConstant_2 {

‎test/langtools/tools/javac/InnerNamedConstant_2.out

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- compiler.warn.source.no.system.modules.path: 15
2+
InnerNamedConstant_2.java:23:20: compiler.err.icls.cant.have.static.decl: InnerNamedConstant_2.Inner2
3+
InnerNamedConstant_2.java:24:29: compiler.err.icls.cant.have.static.decl: InnerNamedConstant_2.Inner2
4+
InnerNamedConstant_2.java:26:13: compiler.err.cant.assign.val.to.final.var: z
5+
InnerNamedConstant_2.java:35:26: compiler.err.icls.cant.have.static.decl: InnerNamedConstant_2.Inner3
6+
4 errors
7+
1 warning
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
InnerNamedConstant_2.java:26:13: compiler.err.cant.assign.val.to.final.var: z
2+
1 error

‎test/langtools/tools/javac/InterfaceInInner.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/*
22
* @test /nodynamiccopyright/
33
* @bug 4063740 6969184
4-
* @summary Interfaces may only be declared in top level classes.
4+
* @summary Interfaces can be declared in inner classes only for source >= 16
55
* @author turnidge
66
*
7-
* @compile/fail/ref=InterfaceInInner.out -XDrawDiagnostics InterfaceInInner.java
7+
* @compile/fail/ref=InterfaceInInner.out -XDrawDiagnostics -source 15 InterfaceInInner.java
8+
* @compile InterfaceInInner.java
89
*/
910
class InterfaceInInner {
1011
InterfaceInInner() {
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
InterfaceInInner.java:12:13: compiler.err.static.declaration.not.allowed.in.inner.classes
1+
- compiler.warn.source.no.system.modules.path: 15
2+
InterfaceInInner.java:13:13: compiler.err.icls.cant.have.static.decl: foo
23
1 error
4+
1 warning

‎test/langtools/tools/javac/T8222035/MinContextOpTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
* @test
2626
* @bug 8222035
2727
* @summary minimal inference context optimization is forcing resolution with incomplete constraints
28-
* @compile/fail/ref=MinContextOpTest.out -XDrawDiagnostics MinContextOpTest.java
28+
* @compile/fail/ref=MinContextOpTest_A.out -XDrawDiagnostics -source 15 MinContextOpTest.java
29+
* @compile/fail/ref=MinContextOpTest_B.out -XDrawDiagnostics MinContextOpTest.java
2930
*/
3031

3132
import java.util.Map;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- compiler.warn.source.no.system.modules.path: 15
2+
MinContextOpTest.java:39:25: compiler.err.mod.not.allowed.here: static
3+
MinContextOpTest.java:45:25: compiler.err.mod.not.allowed.here: static
4+
MinContextOpTest.java:51:34: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: T,K,V,E, (compiler.misc.inconvertible.types: java.util.function.Function<MinContextOpTest.A.T,MinContextOpTest.A.T>, java.util.function.Function<? super MinContextOpTest.A.T,? extends MinContextOpTest.A.T<?>>))
5+
3 errors
6+
1 warning
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
MinContextOpTest.java:38:25: compiler.err.mod.not.allowed.here: static
2-
MinContextOpTest.java:44:25: compiler.err.mod.not.allowed.here: static
3-
MinContextOpTest.java:50:34: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: T,K,V,E, (compiler.misc.inconvertible.types: java.util.function.Function<MinContextOpTest.A.T,MinContextOpTest.A.T>, java.util.function.Function<? super MinContextOpTest.A.T,? extends MinContextOpTest.A.T<?>>))
4-
3 errors
1+
MinContextOpTest.java:51:34: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: T,K,V,E, (compiler.misc.inconvertible.types: java.util.function.Function<MinContextOpTest.A.T,MinContextOpTest.A.T>, java.util.function.Function<? super MinContextOpTest.A.T,? extends MinContextOpTest.A.T<?>>))
2+
1 error

‎test/langtools/tools/javac/diags/examples/EnumsMustBeStatic.java

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323

2424
// key: compiler.err.static.declaration.not.allowed.in.inner.classes
25+
// key: compiler.warn.source.no.system.modules.path
26+
// options: -source 15
2527

2628
class EnumsMustBeStatic {
2729
class Nested {

‎test/langtools/tools/javac/diags/examples/InnerClassCantHaveStatic.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,8 @@
2222
*/
2323

2424
// key: compiler.err.icls.cant.have.static.decl
25+
// key: compiler.warn.source.no.system.modules.path
26+
// options: -source 15
2527

2628
class InnerClassCantHaveStatic {
2729
class Inner {

‎test/langtools/tools/javac/diags/examples/RecordsNotAllowedInInnerClasses.java

-30
This file was deleted.

‎test/langtools/tools/javac/enum/NestedEnum.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/*
22
* @test /nodynamiccopyright/
33
* @bug 5071831
4-
* @summary javac allows enum in an inner class
4+
* @summary javac allows enum in an inner class for source >= 16
55
* @author gafter
66
*
7-
* @compile/fail/ref=NestedEnum.out -XDrawDiagnostics NestedEnum.java
7+
* @compile/fail/ref=NestedEnum.out -XDrawDiagnostics -source 15 NestedEnum.java
8+
* @compile NestedEnum.java
89
*/
910

1011
class NestedEnum {
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
NestedEnum.java:12:9: compiler.err.static.declaration.not.allowed.in.inner.classes
1+
- compiler.warn.source.no.system.modules.path: 15
2+
NestedEnum.java:13:9: compiler.err.static.declaration.not.allowed.in.inner.classes
23
1 error
4+
1 warning

‎test/langtools/tools/javac/enum/T5081785.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/*
22
* @test /nodynamiccopyright/
33
* @bug 5081785
4-
* @summary Empty Enums allowed in non-static contexts
4+
* @summary enums should be allowed in non-static contexts
55
* @author Peter von der Ah\u00e9
6-
* @compile/fail/ref=T5081785.out -XDrawDiagnostics T5081785.java
6+
* @compile/fail/ref=T5081785.out -XDrawDiagnostics -source 15 T5081785.java
7+
* @compile T5081785.java
78
*/
89

910
class A1 {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
T5081785.java:29:9: compiler.err.static.declaration.not.allowed.in.inner.classes
2-
T5081785.java:12:13: compiler.err.static.declaration.not.allowed.in.inner.classes
3-
T5081785.java:19:27: compiler.err.static.declaration.not.allowed.in.inner.classes
4-
T5081785.java:24:31: compiler.err.static.declaration.not.allowed.in.inner.classes
1+
- compiler.warn.source.no.system.modules.path: 15
2+
T5081785.java:30:9: compiler.err.static.declaration.not.allowed.in.inner.classes
3+
T5081785.java:13:13: compiler.err.static.declaration.not.allowed.in.inner.classes
4+
T5081785.java:20:27: compiler.err.static.declaration.not.allowed.in.inner.classes
5+
T5081785.java:25:31: compiler.err.static.declaration.not.allowed.in.inner.classes
56
4 errors
7+
1 warning

‎test/langtools/tools/javac/records/LocalStaticDeclarations.java

+16-17
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
import combo.ComboTask.Result;
4949
import combo.ComboTestHelper;
5050

51+
/** this test checks two thinks:
52+
* 1 - that static declarations are allowed inside inner classes
53+
* 2 - and in addtion that non-static variables can't be captured
54+
* by static contexts
55+
*/
56+
5157
public class LocalStaticDeclarations extends ComboInstance<LocalStaticDeclarations> {
5258

5359
static final String sourceTemplate =
@@ -57,10 +63,12 @@ class Test {
5763
int INSTANCE_FIELD = 0;
5864
static int STATIC_FIELD = 0;
5965
// instance initializer
60-
{ int LOCAL_VARIABLE = 0;
66+
{
67+
int LOCAL_VARIABLE = 0;
6168
#{CONTAINER}
6269
}
6370
Test() {
71+
int LOCAL_VARIABLE = 0;
6472
#{CONTAINER}
6573
}
6674
void m() {
@@ -93,7 +101,7 @@ void m() {
93101
),
94102
RECORD("record CR() { #{STATIC_LOCAL} }"),
95103
CLASS("class CC { #{STATIC_LOCAL} }"),
96-
ENUM("enum CE { #{STATIC_LOCAL} }"),
104+
ENUM("enum CE { CE1; #{STATIC_LOCAL} }"),
97105
LAMBDA("Runnable run = () -> { #{STATIC_LOCAL} };");
98106

99107
String container;
@@ -124,7 +132,6 @@ public String expand(String optParameter) {
124132
}
125133

126134
enum Member implements ComboParameter {
127-
NONE(""),
128135
METHOD("int foo() { return #{EXPR}; }"),
129136
DEFAULT_METHOD("default int foo() { return #{EXPR}; }");
130137

@@ -179,13 +186,13 @@ public void doWork() throws Throwable {
179186
}
180187

181188
boolean notTriviallyIncorrect() {
182-
return decl == StaticLocalDecl.INTERFACE && (member == Member.DEFAULT_METHOD || member == Member.NONE) ||
183-
decl != StaticLocalDecl.INTERFACE && (member == Member.METHOD || member == Member.NONE);
189+
return decl == StaticLocalDecl.INTERFACE && member == Member.DEFAULT_METHOD ||
190+
decl != StaticLocalDecl.INTERFACE && member == Member.METHOD;
184191
}
185192

186193
void check(ComboTask.Result<Iterable<? extends JavaFileObject>> result) {
187194
if (shouldFail()) {
188-
Assert.check(result.hasErrors(), result.compilationInfo());
195+
Assert.check(result.hasErrors(), "unexpected compilation\n" + result.compilationInfo());
189196
if (!expectedDiagFound(result)) {
190197
fail("test failing with unexpected error message\n" + result.compilationInfo());
191198
}
@@ -195,25 +202,17 @@ void check(ComboTask.Result<Iterable<? extends JavaFileObject>> result) {
195202
}
196203

197204
boolean shouldFail() {
198-
return ((container != Container.NO_CONTAINER &&
199-
container != Container.LAMBDA &&
200-
container != Container.ANONYMOUS)) ||
201-
(member != Member.NONE && !acceptableExpr());
205+
return (expr == Expression.LOCAL_VARIABLE || expr == Expression.INSTANCE_FIELD);
202206
}
203207

204208
boolean acceptableExpr() {
205209
return (expr == Expression.LITERAL || expr == Expression.STATIC_FIELD);
206210
}
207211

208212
boolean expectedDiagFound(ComboTask.Result<Iterable<? extends JavaFileObject>> result) {
209-
if ((container == Container.NO_CONTAINER ||
210-
container == Container.LAMBDA ||
211-
container == Container.ANONYMOUS) &&
212-
!acceptableExpr()) {
213+
if (expr == Expression.LOCAL_VARIABLE || expr == Expression.INSTANCE_FIELD) {
213214
return result.containsKey("compiler.err.non-static.cant.be.ref");
214-
} else if (container == Container.ENUM) {
215-
return result.containsKey("compiler.err.enum.constant.expected" );
216215
}
217-
return result.containsKey("compiler.err.static.declaration.not.allowed.in.inner.classes" );
216+
return false;
218217
}
219218
}

‎test/langtools/tools/javac/records/RecordCompilationTests.java

+450-332
Large diffs are not rendered by default.

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Nov 21, 2020

@openjdk-notifier[bot]
Please sign in to comment.