< prev index next >

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

Print this page
rev 48841 : [mq]: 8187950

@@ -61,10 +61,12 @@
 
 import static javax.tools.StandardLocation.*;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.CompletionFailure;
 import com.sun.tools.javac.main.DelegatingJavaFileManager;
 
 import com.sun.tools.javac.util.Dependencies.CompletionCause;
 
 /**

@@ -129,10 +131,12 @@
 
     /** Factory for diagnostics
      */
     JCDiagnostic.Factory diagFactory;
 
+    final DeferredCompletionFailureHandler dcfh;
+
     /** Can be reassigned from outside:
      *  the completer to be used for ".java" files. If this remains unassigned
      *  ".java" files will not be loaded.
      */
     public Completer sourceCompleter = Completer.NULL_COMPLETER;

@@ -183,10 +187,11 @@
         fileManager = context.get(JavaFileManager.class);
         dependencies = Dependencies.instance(context);
         if (fileManager == null)
             throw new AssertionError("FileManager initialization error");
         diagFactory = JCDiagnostic.Factory.instance(context);
+        dcfh = DeferredCompletionFailureHandler.instance(context);
 
         log = Log.instance(context);
         annotate = Annotate.instance(context);
 
         Options options = Options.instance(context);

@@ -215,10 +220,12 @@
             useCtProps = false;
         }
         jrtIndex = useCtProps && JRTIndex.isAvailable() ? JRTIndex.getSharedInstance() : null;
 
         profile = Profile.instance(context);
+        cachedCompletionFailure = new CompletionFailure(null, (JCDiagnostic) null, dcfh);
+        cachedCompletionFailure.setStackTrace(new StackTraceElement[0]);
     }
 
 
 /************************************************************************
  * Temporary ct.sym replacement

@@ -291,11 +298,11 @@
             try {
                 fillIn(p);
             } catch (IOException ex) {
                 JCDiagnostic msg =
                         diagFactory.fragment(Fragments.ExceptionMessage(ex.getLocalizedMessage()));
-                throw new CompletionFailure(sym, msg).initCause(ex);
+                throw new CompletionFailure(sym, msg, dcfh).initCause(ex);
             }
         }
         if (!reader.filling)
             annotate.flush(); // finish attaching annotations
     }

@@ -330,11 +337,11 @@
      */
     void fillIn(ClassSymbol c) {
         if (completionFailureName == c.fullname) {
             JCDiagnostic msg =
                     diagFactory.fragment(Fragments.UserSelectedCompletionFailure);
-            throw new CompletionFailure(c, msg);
+            throw new CompletionFailure(c, msg, dcfh);
         }
         currentOwner = c;
         JavaFileObject classfile = c.classfile;
         if (classfile != null) {
             JavaFileObject previousClassFile = currentClassFile;

@@ -395,23 +402,19 @@
                                                        JCDiagnostic diag) {
             if (!cacheCompletionFailure) {
                 // log.warning("proc.messager",
                 //             Log.getLocalizedString("class.file.not.found", c.flatname));
                 // c.debug.printStackTrace();
-                return new CompletionFailure(c, diag);
+                return new CompletionFailure(c, diag, dcfh);
             } else {
                 CompletionFailure result = cachedCompletionFailure;
                 result.sym = c;
                 result.diag = diag;
                 return result;
             }
         }
-        private final CompletionFailure cachedCompletionFailure =
-            new CompletionFailure(null, (JCDiagnostic) null);
-        {
-            cachedCompletionFailure.setStackTrace(new StackTraceElement[0]);
-        }
+        private final CompletionFailure cachedCompletionFailure;
 
 
     /** Load a toplevel class with given fully qualified name
      *  The class is entered into `classes' only if load was successful.
      */

@@ -773,12 +776,12 @@
      */
     public static class BadClassFile extends CompletionFailure {
         private static final long serialVersionUID = 0;
 
         public BadClassFile(TypeSymbol sym, JavaFileObject file, JCDiagnostic diag,
-                JCDiagnostic.Factory diagFactory) {
-            super(sym, createBadClassFileDiagnostic(file, diag, diagFactory));
+                JCDiagnostic.Factory diagFactory, DeferredCompletionFailureHandler dcfh) {
+            super(sym, createBadClassFileDiagnostic(file, diag, diagFactory), dcfh);
         }
         // where
         private static JCDiagnostic createBadClassFileDiagnostic(
                 JavaFileObject file, JCDiagnostic diag, JCDiagnostic.Factory diagFactory) {
             String key = (file.getKind() == JavaFileObject.Kind.SOURCE

@@ -789,10 +792,10 @@
 
     public static class BadEnclosingMethodAttr extends BadClassFile {
         private static final long serialVersionUID = 0;
 
         public BadEnclosingMethodAttr(TypeSymbol sym, JavaFileObject file, JCDiagnostic diag,
-                JCDiagnostic.Factory diagFactory) {
-            super(sym, file, diag, diagFactory);
+                JCDiagnostic.Factory diagFactory, DeferredCompletionFailureHandler dcfh) {
+            super(sym, file, diag, diagFactory, dcfh);
         }
     }
 }
< prev index next >