< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java

Print this page
rev 48841 : imported patch 8187950

@@ -45,15 +45,12 @@
 import javax.lang.model.element.TypeParameterElement;
 import javax.lang.model.element.VariableElement;
 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;
 import com.sun.tools.javac.comp.Env;
 import com.sun.tools.javac.jvm.*;

@@ -66,10 +63,11 @@
 
 import static com.sun.tools.javac.code.Flags.*;
 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;
 import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
 import static com.sun.tools.javac.jvm.ByteCodes.iadd;

@@ -632,10 +630,18 @@
             completer = Completer.NULL_COMPLETER;
             c.complete(this);
         }
     }
 
+    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() {
         return true;
     }

@@ -655,10 +661,11 @@
         return ElementKind.OTHER;       // most unkind
     }
 
     @DefinedBy(Api.LANGUAGE_MODEL)
     public Set<Modifier> getModifiers() {
+        apiComplete();
         return Flags.asModifierSet(flags());
     }
 
     @DefinedBy(Api.LANGUAGE_MODEL)
     public Name getSimpleName() {

@@ -669,10 +676,11 @@
      * This is the implementation for {@code
      * javax.lang.model.element.Element.getAnnotationMirrors()}.
      */
     @Override @DefinedBy(Api.LANGUAGE_MODEL)
     public List<Attribute.Compound> getAnnotationMirrors() {
+        apiComplete();
         return getRawAttributes();
     }
 
 
     // TODO: getEnclosedElements should return a javac List, fix in FilteredMemberList

@@ -793,18 +801,16 @@
         public java.util.List<Symbol> getEnclosedElements() {
             List<Symbol> list = List.nil();
             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) {
+                sym.apiComplete();
+                if ((sym.flags() & SYNTHETIC) == 0 && sym.owner == this && sym.kind != ERR) {
                         list = list.prepend(sym);
                     }
-                } catch (BadEnclosingMethodAttr badEnclosingMethod) {
-                    // ignore the exception
-                }
             }
             return list;
         }
 
         public AnnotationTypeMetadata getAnnotationTypeMetadata() {

@@ -978,11 +984,11 @@
             return ElementKind.MODULE;
         }
 
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public java.util.List<Directive> getDirectives() {
-            complete();
+            apiComplete();
             completeUsesProvides();
             return Collections.unmodifiableList(directives);
         }
 
         public void completeUsesProvides() {

@@ -1302,23 +1308,25 @@
         }
 
         /** 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);
                 throw ex;
             }
         }
 
         @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
                     t.interfaces_field = List.nil();
                 if (t.all_interfaces_field != null)

@@ -1329,11 +1337,11 @@
             }
         }
 
         @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
                     t.supertype_field = Type.noType;
                 // An interface has no superclass; its supertype is Object.

@@ -1370,10 +1378,11 @@
         }
 
 
         @DefinedBy(Api.LANGUAGE_MODEL)
         public ElementKind getKind() {
+            apiComplete();
             long flags = flags();
             if ((flags & ANNOTATION) != 0)
                 return ElementKind.ANNOTATION_TYPE;
             else if ((flags & INTERFACE) != 0)
                 return ElementKind.INTERFACE;

@@ -1383,17 +1392,18 @@
                 return ElementKind.CLASS;
         }
 
         @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())
                 return NestingKind.ANONYMOUS;
             else if (owner.kind == MTH)

@@ -2103,17 +2113,19 @@
         }
     }
 
     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
         }
 
< prev index next >