8054556: javac should report the error for default usage as the primary error

Reviewed-by: jjg
This commit is contained in:
Paul Govereau 2014-08-15 11:02:14 -04:00
parent b9781a6764
commit 7cb1497762
3 changed files with 5 additions and 5 deletions

View File

@ -919,14 +919,14 @@ public class Attr extends JCTree.Visitor {
// 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");

View File

@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
* @bug 4865660
* @bug 4865660 8054556
* @summary implement "metadata" (attribute interfaces and program annotations)
* @author gafter
*

View File

@ -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