javac throws a CompletionFailure due to bug 6550655

Rémi Forax forax at univ-mlv.fr
Mon Apr 18 17:00:13 PDT 2011


Hi compiler guys,
During a stupid refactoring I've fallen into bug 6550655
   http://bugs.sun.com/view_bug.do?bug_id=6550655
which is quite popular.

The problem is that for asking if the symbol is an annotation
the code use expected.tsym.flags() that triggers a ClassReader.complete
that fails because the class file doesn't exist.
So a CompletionFailureException is thrown (ClassReader:2232)
and never catch.

I haven't change the code in ClassReader:2232 even if it creates
a diagnostic fragment which seems not used,
but maybe I'm wrong about that ?

Rémi

--- a/src/share/classes/com/sun/tools/javac/comp/Annotate.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Annotate.java
@@ -212,7 +212,14 @@
              return new Attribute.Class(types,
                                         (((JCFieldAccess) 
tree).selected).type);
          }
-        if ((expected.tsym.flags() & Flags.ANNOTATION) != 0) {
+        long flags;
+        try {
+            flags = expected.tsym.flags();
+        } catch(CompletionFailure e) {
+            log.error(tree.pos(), "cant.resolve", "class", 
e.sym.flatName());
+            return new Attribute.Error(expected);
+        }
+        if ((flags & Flags.ANNOTATION) != 0) {
              if (tree.getTag() != JCTree.ANNOTATION) {
                  log.error(tree.pos(), 
"annotation.value.must.be.annotation");
                  expected = syms.errorType;




More information about the compiler-dev mailing list