8054556: javac should report the error for default usage as the primary error
authorpgovereau
Fri, 15 Aug 2014 11:02:14 -0400
changeset 26106 8af1fa613176
parent 26105 30e8bff3803b
child 26107 a4a156a33c94
8054556: javac should report the error for default usage as the primary error Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
langtools/test/tools/javac/annotations/neg/Z3.java
langtools/test/tools/javac/annotations/neg/Z3.out
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Aug 14 14:17:17 2014 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Aug 15 11:02:14 2014 -0400
@@ -919,14 +919,14 @@
                 // Empty bodies are only allowed for
                 // abstract, native, or interface methods, or for methods
                 // in a retrofit signature class.
-                if (isDefaultMethod || (tree.sym.flags() & (ABSTRACT | NATIVE)) == 0 &&
-                    !relax)
-                    log.error(tree.pos(), "missing.meth.body.or.decl.abstract");
                 if (tree.defaultValue != null) {
                     if ((owner.flags() & ANNOTATION) == 0)
                         log.error(tree.pos(),
                                   "default.allowed.in.intf.annotation.member");
                 }
+                if (isDefaultMethod || (tree.sym.flags() & (ABSTRACT | NATIVE)) == 0 &&
+                    !relax)
+                    log.error(tree.pos(), "missing.meth.body.or.decl.abstract");
             } else if ((tree.sym.flags() & ABSTRACT) != 0 && !isDefaultMethod) {
                 if ((owner.flags() & INTERFACE) != 0) {
                     log.error(tree.body.pos(), "intf.meth.cant.have.body");
--- a/langtools/test/tools/javac/annotations/neg/Z3.java	Thu Aug 14 14:17:17 2014 +0200
+++ b/langtools/test/tools/javac/annotations/neg/Z3.java	Fri Aug 15 11:02:14 2014 -0400
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 4865660
+ * @bug 4865660 8054556
  * @summary implement "metadata" (attribute interfaces and program annotations)
  * @author gafter
  *
--- a/langtools/test/tools/javac/annotations/neg/Z3.out	Thu Aug 14 14:17:17 2014 +0200
+++ b/langtools/test/tools/javac/annotations/neg/Z3.out	Fri Aug 15 11:02:14 2014 -0400
@@ -1,2 +1,2 @@
-Z3.java:13:11: compiler.err.missing.meth.body.or.decl.abstract
+Z3.java:13:11: compiler.err.default.allowed.in.intf.annotation.member
 1 error