changeset 2592:383432f1719c

8054556: javac should report the error for default usage as the primary error Reviewed-by: jjg
author pgovereau
date Fri, 15 Aug 2014 11:02:14 -0400
parents 9e8cbfac9b6b
children 035b01d356ee
files src/share/classes/com/sun/tools/javac/comp/Attr.java test/tools/javac/annotations/neg/Z3.java test/tools/javac/annotations/neg/Z3.out
diffstat 3 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Aug 14 14:17:17 2014 +0200
+++ b/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/test/tools/javac/annotations/neg/Z3.java	Thu Aug 14 14:17:17 2014 +0200
+++ b/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/test/tools/javac/annotations/neg/Z3.out	Thu Aug 14 14:17:17 2014 +0200
+++ b/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