8181464: Invalid lambda in annotation causes NPE in Lint.augment
authorvromero
Tue, 13 Jun 2017 11:21:09 -0700
changeset 45500 365640343c55
parent 45499 16e055f785ef
child 45501 a13e5e2ee35e
8181464: Invalid lambda in annotation causes NPE in Lint.augment Reviewed-by: mcimadamore
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
langtools/test/tools/javac/8002286/T8002286.out
langtools/test/tools/javac/T8181464/Anno.java
langtools/test/tools/javac/T8181464/Anno2.java
langtools/test/tools/javac/T8181464/AnnoProcessor.java
langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest1.java
langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest1.out
langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest2.java
langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest2.out
langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest3.java
langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest3.out
langtools/test/tools/javac/annotations/neg/AnonSubclass.out
langtools/test/tools/javac/annotations/neg/Z15.out
langtools/test/tools/javac/annotations/neg/pkg/package-info.out
langtools/test/tools/javac/diags/examples.not-yet.txt
langtools/test/tools/javac/diags/examples/AnnoValueMustBeClassLiteral.java
langtools/test/tools/javac/diags/examples/AnnotationMustBeConstant.java
langtools/test/tools/javac/diags/examples/AnnotationMustBeConstant2.java
langtools/test/tools/javac/diags/examples/AttrMustBeConstant.java
langtools/test/tools/javac/diags/examples/EnumAnnoValueMustBeEnumConst.java
langtools/test/tools/javac/diags/examples/EnumAnnoValueMustBeEnumConst2.java
langtools/test/tools/javac/processing/errors/EnsureAnnotationTypeMismatchException/Source.out
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Tue Jun 13 11:21:09 2017 -0700
@@ -42,6 +42,7 @@
 import com.sun.tools.javac.util.List;
 
 import javax.tools.JavaFileObject;
+
 import java.util.*;
 
 import static com.sun.tools.javac.code.Flags.SYNTHETIC;
@@ -56,8 +57,10 @@
 import static com.sun.tools.javac.tree.JCTree.Tag.ASSIGN;
 import static com.sun.tools.javac.tree.JCTree.Tag.IDENT;
 import static com.sun.tools.javac.tree.JCTree.Tag.NEWARRAY;
+
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
 
+
 /** Enter annotations onto symbols and types (and trees).
  *
  *  This is also a pseudo stage in the compiler taking care of scheduling when annotations are
@@ -565,6 +568,20 @@
             return new Attribute.Error(((JCAnnotation)tree).annotationType.type);
         }
 
+        MemberEnter.InitTreeVisitor initTreeVisitor = new MemberEnter.InitTreeVisitor() {
+            // the methods below are added to allow class literals on top of constant expressions
+            @Override
+            public void visitTypeIdent(JCPrimitiveTypeTree that) {}
+
+            @Override
+            public void visitTypeArray(JCArrayTypeTree that) {}
+        };
+        tree.accept(initTreeVisitor);
+        if (!initTreeVisitor.result) {
+            log.error(tree.pos(), Errors.ExpressionNotAllowableAsAnnotationValue);
+            return new Attribute.Error(syms.errType);
+        }
+
         if (expectedElementType.isPrimitive() ||
                 (types.isSameType(expectedElementType, syms.stringType) && !expectedElementType.hasTag(TypeTag.ERROR))) {
             return getAnnotationPrimitiveValue(expectedElementType, tree, env);
@@ -614,12 +631,6 @@
             }
         }
 
-        // Class literals look like field accesses of a field named class
-        // at the tree level
-        if (TreeInfo.name(tree) != names._class) {
-            log.error(tree.pos(), "annotation.value.must.be.class.literal");
-            return new Attribute.Error(syms.errType);
-        }
         return new Attribute.Class(types,
                 (((JCFieldAccess) tree).selected).type);
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Jun 13 11:21:09 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -345,7 +345,7 @@
                            Tag.LT, Tag.LE, Tag.GT, Tag.GE, Tag.EQ, Tag.NE,
                            Tag.BITAND, Tag.BITXOR, Tag.BITOR, Tag.AND, Tag.OR);
 
-        private boolean result = true;
+        boolean result = true;
 
         @Override
         public void visitTree(JCTree tree) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Jun 13 11:21:09 2017 -0700
@@ -129,15 +129,15 @@
 compiler.err.annotation.value.must.be.annotation=\
     annotation value must be an annotation
 
-compiler.err.annotation.value.must.be.class.literal=\
-    annotation value must be a class literal
-
 compiler.err.annotation.value.must.be.name.value=\
     annotation values must be of the form ''name=value''
 
 compiler.err.annotation.value.not.allowable.type=\
     annotation value not of an allowable type
 
+compiler.err.expression.not.allowable.as.annotation.value=\
+    expression not allowed as annotation value
+
 compiler.err.anon.class.impl.intf.no.args=\
     anonymous class implements interface; cannot have arguments
 
--- a/langtools/test/tools/javac/8002286/T8002286.out	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/test/tools/javac/8002286/T8002286.out	Tue Jun 13 11:21:09 2017 -0700
@@ -1,3 +1,2 @@
 T8002286.java:8:22: compiler.err.cant.resolve.location.args: kindname.method, value, , , (compiler.misc.location: kindname.annotation, T8002286.Anno, null)
-T8002286.java:8:11: compiler.err.cant.resolve.location.args: kindname.method, nonExistent, , , (compiler.misc.location: kindname.class, T8002286, null)
-2 errors
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8181464/Anno.java	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+@interface Anno {
+    Class<?> value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8181464/Anno2.java	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+@interface Anno2 {
+    String value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8181464/AnnoProcessor.java	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.TypeElement;
+
+@SupportedAnnotationTypes("*")
+public class AnnoProcessor extends AbstractProcessor {
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest1.java	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,11 @@
+/* @test /nodynamiccopyright/
+ * @bug 8181464
+ * @summary Invalid lambda in annotation causes NPE in Lint.augment
+ * @modules java.compiler
+ *          jdk.compiler
+ * @compile Anno.java AnnoProcessor.java
+ * @compile/fail/ref=LambdaInAnnotationsCausesNPETest1.out -XDrawDiagnostics -processor AnnoProcessor -proc:only LambdaInAnnotationsCausesNPETest1.java
+ */
+
+@Anno(value = x -> x)
+class LambdaInAnnotationsCausesNPETest1 {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest1.out	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,2 @@
+LambdaInAnnotationsCausesNPETest1.java:10:15: compiler.err.expression.not.allowable.as.annotation.value
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest2.java	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,11 @@
+/* @test /nodynamiccopyright/
+ * @bug 8181464
+ * @summary Invalid lambda in annotation causes NPE in Lint.augment
+ * @modules java.compiler
+ *          jdk.compiler
+ * @compile Anno.java AnnoProcessor.java
+ * @compile/fail/ref=LambdaInAnnotationsCausesNPETest2.out -XDrawDiagnostics -processor AnnoProcessor -proc:only LambdaInAnnotationsCausesNPETest2.java
+ */
+
+@Anno(value = (String x) -> x)
+class LambdaInAnnotationsCausesNPETest2 {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest2.out	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,2 @@
+LambdaInAnnotationsCausesNPETest2.java:10:15: compiler.err.expression.not.allowable.as.annotation.value
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest3.java	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,15 @@
+/* @test /nodynamiccopyright/
+ * @bug 8181464
+ * @summary Invalid lambda in annotation causes NPE in Lint.augment
+ * @modules java.compiler
+ *          jdk.compiler
+ * @compile Anno2.java AnnoProcessor.java
+ * @compile/fail/ref=LambdaInAnnotationsCausesNPETest3.out -XDrawDiagnostics -processor AnnoProcessor -proc:only LambdaInAnnotationsCausesNPETest3.java
+ */
+
+@Anno2(value = LambdaInAnnotationsCausesNPETest3.m(x -> x))
+class LambdaInAnnotationsCausesNPETest3 {
+    static String m(Class<?> target) {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8181464/LambdaInAnnotationsCausesNPETest3.out	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,2 @@
+LambdaInAnnotationsCausesNPETest3.java:10:51: compiler.err.expression.not.allowable.as.annotation.value
+1 error
--- a/langtools/test/tools/javac/annotations/neg/AnonSubclass.out	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/test/tools/javac/annotations/neg/AnonSubclass.out	Tue Jun 13 11:21:09 2017 -0700
@@ -1,2 +1,2 @@
-AnonSubclass.java:10:15: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: java.lang.Object, java.lang.String)
+AnonSubclass.java:10:15: compiler.err.expression.not.allowable.as.annotation.value
 1 error
--- a/langtools/test/tools/javac/annotations/neg/Z15.out	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/test/tools/javac/annotations/neg/Z15.out	Tue Jun 13 11:21:09 2017 -0700
@@ -1,2 +1,2 @@
-Z15.java:11:36: compiler.err.attribute.value.must.be.constant
+Z15.java:11:36: compiler.err.expression.not.allowable.as.annotation.value
 1 error
--- a/langtools/test/tools/javac/annotations/neg/pkg/package-info.out	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/test/tools/javac/annotations/neg/pkg/package-info.out	Tue Jun 13 11:21:09 2017 -0700
@@ -1,2 +1,2 @@
-package-info.java:11:20: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: java.lang.Object, java.lang.String)
+package-info.java:11:20: compiler.err.expression.not.allowable.as.annotation.value
 1 error
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt	Tue Jun 13 11:21:09 2017 -0700
@@ -1,7 +1,7 @@
 compiler.err.already.annotated                          # internal compiler error?
 compiler.err.already.defined.this.unit                  # seems to be masked by compiler.err.duplicate.class
-compiler.err.annotation.value.not.allowable.type        # cannot happen: precluded by complete type-specific tests
 compiler.err.bad.functional.intf.anno                   # seems to be masked by compiler.err.annotation.type.not.applicable
+compiler.err.annotation.value.not.allowable.type        # should be detected in advance by the annotation value visitor
 compiler.err.cant.read.file                             # (apt.JavaCompiler?)
 compiler.err.cant.select.static.class.from.param.type
 compiler.err.dc.unterminated.string                     # cannot happen
--- a/langtools/test/tools/javac/diags/examples/AnnoValueMustBeClassLiteral.java	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/test/tools/javac/diags/examples/AnnoValueMustBeClassLiteral.java	Tue Jun 13 11:21:09 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// key: compiler.err.annotation.value.must.be.class.literal
+// key: compiler.err.expression.not.allowable.as.annotation.value
 
 @interface Anno {
     Class value();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/AnnotationMustBeConstant.java	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.expression.not.allowable.as.annotation.value
+
+import java.util.function.*;
+
+@interface Anno {
+    String value();
+}
+
+@Anno(value = AnnotationMustBeConstant.m(x -> x))
+class AnnotationMustBeConstant {
+    static String m(Function<String, String> f) {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/AnnotationMustBeConstant2.java	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.attribute.value.must.be.constant
+
+@T(a = AnnotationMustBeConstant2.x)
+@interface T {
+    int a();
+}
+
+class AnnotationMustBeConstant2 {
+    static int x;
+}
--- a/langtools/test/tools/javac/diags/examples/AttrMustBeConstant.java	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/test/tools/javac/diags/examples/AttrMustBeConstant.java	Tue Jun 13 11:21:09 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// key: compiler.err.attribute.value.must.be.constant
+// key: compiler.err.expression.not.allowable.as.annotation.value
 
 @interface Anno {
     String value();
--- a/langtools/test/tools/javac/diags/examples/EnumAnnoValueMustBeEnumConst.java	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/test/tools/javac/diags/examples/EnumAnnoValueMustBeEnumConst.java	Tue Jun 13 11:21:09 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// key: compiler.err.enum.annotation.must.be.enum.constant
+// key: compiler.err.expression.not.allowable.as.annotation.value
 
 enum E { A, B, C }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/EnumAnnoValueMustBeEnumConst2.java	Tue Jun 13 11:21:09 2017 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.enum.annotation.must.be.enum.constant
+
+enum E {
+    A,
+    B;
+
+    public static final E e = A;
+}
+
+@interface Anno {
+    E value();
+}
+
+@Anno(E.e)
+class EnumAnnoValueMustBeEnumConstant { }
--- a/langtools/test/tools/javac/processing/errors/EnsureAnnotationTypeMismatchException/Source.out	Fri Jun 09 21:34:47 2017 +0000
+++ b/langtools/test/tools/javac/processing/errors/EnsureAnnotationTypeMismatchException/Source.out	Tue Jun 13 11:21:09 2017 -0700
@@ -3,5 +3,5 @@
 Generated.java:4:22: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, E)
 Generated.java:5:37: compiler.err.annotation.not.valid.for.type: int
 Generated.java:6:32: compiler.err.annotation.value.not.allowable.type
-Generated.java:7:35: compiler.err.annotation.value.must.be.class.literal
+Generated.java:7:35: compiler.err.expression.not.allowable.as.annotation.value
 6 errors