src/share/classes/com/sun/tools/javac/comp/Attr.java

changeset 629
0fe472f4a332
parent 615
36c4ec4525b4
child 630
237f3bd52242
equal deleted inserted replaced
623:6318230cdb82 629:0fe472f4a332
673 673
674 chk.checkVarargMethodDecl(tree); 674 chk.checkVarargMethodDecl(tree);
675 675
676 // Check that type parameters are well-formed. 676 // Check that type parameters are well-formed.
677 chk.validate(tree.typarams, localEnv); 677 chk.validate(tree.typarams, localEnv);
678 if ((owner.flags() & ANNOTATION) != 0 &&
679 tree.typarams.nonEmpty())
680 log.error(tree.typarams.head.pos(),
681 "intf.annotation.members.cant.have.type.params");
682 678
683 // Check that result type is well-formed. 679 // Check that result type is well-formed.
684 chk.validate(tree.restype, localEnv); 680 chk.validate(tree.restype, localEnv);
685 if ((owner.flags() & ANNOTATION) != 0) 681
682 // annotation method checks
683 if ((owner.flags() & ANNOTATION) != 0) {
684 // annotation method cannot have throws clause
685 if (tree.thrown.nonEmpty()) {
686 log.error(tree.thrown.head.pos(),
687 "throws.not.allowed.in.intf.annotation");
688 }
689 // annotation method cannot declare type-parameters
690 if (tree.typarams.nonEmpty()) {
691 log.error(tree.typarams.head.pos(),
692 "intf.annotation.members.cant.have.type.params");
693 }
694 // validate annotation method's return type (could be an annotation type)
686 chk.validateAnnotationType(tree.restype); 695 chk.validateAnnotationType(tree.restype);
687 696 // ensure that annotation method does not clash with members of Object/Annotation
688 if ((owner.flags() & ANNOTATION) != 0)
689 chk.validateAnnotationMethod(tree.pos(), m); 697 chk.validateAnnotationMethod(tree.pos(), m);
690 698
691 // Check that all exceptions mentioned in the throws clause extend 699 // if default value is an annotation, check it is a well-formed
692 // java.lang.Throwable. 700 // annotation value (e.g. no duplicate values, no missing values, etc.)
693 if ((owner.flags() & ANNOTATION) != 0 && tree.thrown.nonEmpty()) 701 chk.validateAnnotationDefaultValue(tree.defaultValue);
694 log.error(tree.thrown.head.pos(), 702 }
695 "throws.not.allowed.in.intf.annotation"); 703
696 for (List<JCExpression> l = tree.thrown; l.nonEmpty(); l = l.tail) 704 for (List<JCExpression> l = tree.thrown; l.nonEmpty(); l = l.tail)
697 chk.checkType(l.head.pos(), l.head.type, syms.throwableType); 705 chk.checkType(l.head.pos(), l.head.type, syms.throwableType);
698 706
699 if (tree.body == null) { 707 if (tree.body == null) {
700 // Empty bodies are only allowed for 708 // Empty bodies are only allowed for

mercurial