src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
changeset 49197 cc2673fa8c20
parent 48945 6e6c777a37a2
child 54339 f69a2f675f19
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Mar 09 11:36:12 2018 +0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Mar 09 09:42:10 2018 +0100
@@ -47,11 +47,8 @@
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 
-import com.sun.tools.javac.code.ClassFinder.BadEnclosingMethodAttr;
-import com.sun.tools.javac.code.Directive.RequiresFlag;
 import com.sun.tools.javac.code.Kinds.Kind;
 import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
-import com.sun.tools.javac.code.Scope.WriteableScope;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.comp.Attr;
 import com.sun.tools.javac.comp.AttrContext;
@@ -68,6 +65,7 @@
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
+import com.sun.tools.javac.code.Scope.WriteableScope;
 import static com.sun.tools.javac.code.Symbol.OperatorSymbol.AccessCode.FIRSTASGOP;
 import static com.sun.tools.javac.code.TypeTag.CLASS;
 import static com.sun.tools.javac.code.TypeTag.FORALL;
@@ -645,6 +643,14 @@
         }
     }
 
+    public void apiComplete() throws CompletionFailure {
+        try {
+            complete();
+        } catch (CompletionFailure cf) {
+            cf.dcfh.handleAPICompletionFailure(cf);
+        }
+    }
+
     /** True if the symbol represents an entity that exists.
      */
     public boolean exists() {
@@ -668,6 +674,7 @@
 
     @DefinedBy(Api.LANGUAGE_MODEL)
     public Set<Modifier> getModifiers() {
+        apiComplete();
         return Flags.asModifierSet(flags());
     }
 
@@ -682,6 +689,7 @@
      */
     @Override @DefinedBy(Api.LANGUAGE_MODEL)
     public List<Attribute.Compound> getAnnotationMirrors() {
+        apiComplete();
         return getRawAttributes();
     }
 
@@ -806,13 +814,11 @@
             if (kind == TYP && type.hasTag(TYPEVAR)) {
                 return list;
             }
+            apiComplete();
             for (Symbol sym : members().getSymbols(NON_RECURSIVE)) {
-                try {
-                    if (sym != null && (sym.flags() & SYNTHETIC) == 0 && sym.owner == this) {
-                        list = list.prepend(sym);
-                    }
-                } catch (BadEnclosingMethodAttr badEnclosingMethod) {
-                    // ignore the exception
+                sym.apiComplete();
+                if ((sym.flags() & SYNTHETIC) == 0 && sym.owner == this && sym.kind != ERR) {
+                    list = list.prepend(sym);
                 }
             }
             return list;
@@ -991,7 +997,7 @@
 
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public java.util.List<Directive> getDirectives() {
-            complete();
+            apiComplete();
             completeUsesProvides();
             return Collections.unmodifiableList(directives);
         }
@@ -1315,9 +1321,11 @@
         /** Complete the elaboration of this symbol's definition.
          */
         public void complete() throws CompletionFailure {
+            Completer origCompleter = completer;
             try {
                 super.complete();
             } catch (CompletionFailure ex) {
+                ex.dcfh.classSymbolCompleteFailed(this, origCompleter);
                 // quiet error recovery
                 flags_field |= (PUBLIC|STATIC);
                 this.type = new ErrorType(this, Type.noType);
@@ -1327,7 +1335,7 @@
 
         @DefinedBy(Api.LANGUAGE_MODEL)
         public List<Type> getInterfaces() {
-            complete();
+            apiComplete();
             if (type instanceof ClassType) {
                 ClassType t = (ClassType)type;
                 if (t.interfaces_field == null) // FIXME: shouldn't be null
@@ -1342,7 +1350,7 @@
 
         @DefinedBy(Api.LANGUAGE_MODEL)
         public Type getSuperclass() {
-            complete();
+            apiComplete();
             if (type instanceof ClassType) {
                 ClassType t = (ClassType)type;
                 if (t.supertype_field == null) // FIXME: shouldn't be null
@@ -1383,6 +1391,7 @@
 
         @DefinedBy(Api.LANGUAGE_MODEL)
         public ElementKind getKind() {
+            apiComplete();
             long flags = flags();
             if ((flags & ANNOTATION) != 0)
                 return ElementKind.ANNOTATION_TYPE;
@@ -1396,13 +1405,14 @@
 
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public Set<Modifier> getModifiers() {
+            apiComplete();
             long flags = flags();
             return Flags.asModifierSet(flags & ~DEFAULT);
         }
 
         @DefinedBy(Api.LANGUAGE_MODEL)
         public NestingKind getNestingKind() {
-            complete();
+            apiComplete();
             if (owner.kind == PCK)
                 return NestingKind.TOP_LEVEL;
             else if (name.isEmpty())
@@ -2116,13 +2126,15 @@
 
     public static class CompletionFailure extends RuntimeException {
         private static final long serialVersionUID = 0;
+        public final DeferredCompletionFailureHandler dcfh;
         public Symbol sym;
 
         /** A diagnostic object describing the failure
          */
         public JCDiagnostic diag;
 
-        public CompletionFailure(Symbol sym, JCDiagnostic diag) {
+        public CompletionFailure(Symbol sym, JCDiagnostic diag, DeferredCompletionFailureHandler dcfh) {
+            this.dcfh = dcfh;
             this.sym = sym;
             this.diag = diag;
 //          this.printStackTrace();//DEBUG