Skip to content
Permalink
Browse files

Automatic merge of jdk:master into master

  • Loading branch information
duke
duke committed Jul 31, 2020
2 parents 35ef3a1 + 0f5e57a commit faddcb25e7465fdd9a92a6f54cfa358ecebd1c83
@@ -381,7 +381,7 @@ public static String toString(long flags) {
public static final int
AccessFlags = PUBLIC | PROTECTED | PRIVATE,
LocalClassFlags = FINAL | ABSTRACT | STRICTFP | ENUM | SYNTHETIC,
StaticLocalFlags = LocalClassFlags | STATIC | INTERFACE | ANNOTATION,
StaticLocalFlags = LocalClassFlags | STATIC | INTERFACE,
MemberClassFlags = LocalClassFlags | INTERFACE | AccessFlags,
MemberRecordFlags = MemberClassFlags | STATIC,
ClassFlags = LocalClassFlags | INTERFACE | PUBLIC | ANNOTATION,
@@ -1220,7 +1220,7 @@ else if ((sym.owner.flags_field & INTERFACE) != 0)
boolean implicitlyStatic = !sym.isAnonymous() &&
((flags & RECORD) != 0 || (flags & ENUM) != 0 || (flags & INTERFACE) != 0);
boolean staticOrImplicitlyStatic = (flags & STATIC) != 0 || implicitlyStatic;
mask = staticOrImplicitlyStatic && allowRecords ? StaticLocalFlags : LocalClassFlags;
mask = staticOrImplicitlyStatic && allowRecords && (flags & ANNOTATION) == 0 ? StaticLocalFlags : LocalClassFlags;
implicit = implicitlyStatic ? STATIC : implicit;
if (staticOrImplicitlyStatic) {
if (sym.owner.kind == TYP) {
@@ -1,10 +1,10 @@
/**
* @test /nodynamiccopyright/
* @bug 5012028 6384539 8074364
* @bug 5012028 6384539 8074364 8250741
* @summary javac crash when declare an annotation type illegally
*
* @compile/fail/ref=IllegalAnnotation.out -XDrawDiagnostics IllegalAnnotation.java
* @compile --enable-preview -source ${jdk.version} IllegalAnnotation.java
* @compile/fail/ref=IllegalAnnotation.out -XDrawDiagnostics --enable-preview -source ${jdk.version} IllegalAnnotation.java
*/
class IllegalAnnotation {
{
@@ -78,7 +78,6 @@ static void foo() {
enum Container implements ComboParameter {
NO_CONTAINER("#{STATIC_LOCAL}"),
INTERFACE("interface CI { #{STATIC_LOCAL} }"),
ANNOTATION("@interface CA { #{STATIC_LOCAL} }"),
ANONYMOUS(
"""
new Object() {
@@ -112,7 +111,6 @@ public String expand(String optParameter) {
enum StaticLocalDecl implements ComboParameter {
ENUM("enum E { E1; #{MEMBER} }"),
RECORD("record R() { #{MEMBER} }"),
ANNOTATION("@interface A { #{MEMBER} }"),
INTERFACE("interface I { #{MEMBER} }");

String localDecl;
@@ -184,9 +182,7 @@ public void doWork() throws Throwable {

boolean notTriviallyIncorrect() {
return decl == StaticLocalDecl.INTERFACE && (member == Member.DEFAULT_METHOD || member == Member.NONE) ||
decl != StaticLocalDecl.INTERFACE && (member == Member.METHOD || member == Member.NONE) &&
((decl != StaticLocalDecl.ANNOTATION) ||
(decl == StaticLocalDecl.ANNOTATION && member == Member.NONE));
decl != StaticLocalDecl.INTERFACE && (member == Member.METHOD || member == Member.NONE);
}

void check(ComboTask.Result<Iterable<? extends JavaFileObject>> result) {
@@ -218,11 +214,7 @@ boolean expectedDiagFound(ComboTask.Result<Iterable<? extends JavaFileObject>> r
!acceptableExpr()) {
return result.containsKey("compiler.err.non-static.cant.be.ref");
} else if (container == Container.ENUM) {
if (decl == StaticLocalDecl.ANNOTATION) {
return result.containsKey("compiler.err.expected");
} else {
return result.containsKey("compiler.err.enum.constant.expected" );
}
return result.containsKey("compiler.err.enum.constant.expected" );
}
return result.containsKey("compiler.err.static.declaration.not.allowed.in.inner.classes" );
}

0 comments on commit faddcb2

Please sign in to comment.
You can’t perform that action at this time.