< prev index next >

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

Print this page
rev 54093 : 8177068: incomplete classpath causes NPE in Flow
Summary: Undo completions that failed during speculative attribution, so that the appropriate CompletionFailures are thrown again and properly reported.
Reviewed-by: vromero


  69         }
  70         public void handleAPICompletionFailure(CompletionFailure cf) {
  71             //ignore
  72         }
  73         public void classSymbolCompleteFailed(ClassSymbol sym, Completer origCompleter) {
  74             class2Flip.put(sym, new FlipSymbolDescription(sym, new DeferredCompleter(origCompleter) {
  75                 @Override public void complete(Symbol sym) throws CompletionFailure {
  76                     class2Flip.remove(sym);
  77                     super.complete(sym);
  78                 }
  79             }));
  80         }
  81         public void classSymbolRemoved(ClassSymbol sym) {
  82             class2Flip.remove(sym);
  83         }
  84         public void uninstall() {
  85             class2Flip.values().forEach(f -> f.flip());
  86         }
  87     };
  88 




















  89     public final Handler javacCodeHandler = new Handler() {
  90         public void install() {
  91         }
  92         public void handleAPICompletionFailure(CompletionFailure cf) {
  93             throw cf;
  94         }
  95         public void classSymbolCompleteFailed(ClassSymbol sym, Completer origCompleter) {}
  96         public void classSymbolRemoved(ClassSymbol sym) {}
  97         public void uninstall() {
  98         }
  99     };
 100 
 101     private Handler handler = javacCodeHandler;
 102 
 103     protected DeferredCompletionFailureHandler(Context context) {
 104         context.put(deferredCompletionFailureHandlerKey, this);
 105     }
 106 
 107     public Handler setHandler(Handler h) {
 108         if (h == handler) return handler;




  69         }
  70         public void handleAPICompletionFailure(CompletionFailure cf) {
  71             //ignore
  72         }
  73         public void classSymbolCompleteFailed(ClassSymbol sym, Completer origCompleter) {
  74             class2Flip.put(sym, new FlipSymbolDescription(sym, new DeferredCompleter(origCompleter) {
  75                 @Override public void complete(Symbol sym) throws CompletionFailure {
  76                     class2Flip.remove(sym);
  77                     super.complete(sym);
  78                 }
  79             }));
  80         }
  81         public void classSymbolRemoved(ClassSymbol sym) {
  82             class2Flip.remove(sym);
  83         }
  84         public void uninstall() {
  85             class2Flip.values().forEach(f -> f.flip());
  86         }
  87     };
  88 
  89     public final Handler speculativeCodeHandler = new Handler() {
  90         private final Map<ClassSymbol, FlipSymbolDescription> class2Flip = new HashMap<>();
  91 
  92         public void install() {
  93         }
  94         public void handleAPICompletionFailure(CompletionFailure cf) {
  95             throw cf;
  96         }
  97         public void classSymbolCompleteFailed(ClassSymbol sym, Completer origCompleter) {
  98             class2Flip.put(sym, new FlipSymbolDescription(sym, new DeferredCompleter(origCompleter)));
  99         }
 100         public void classSymbolRemoved(ClassSymbol sym) {
 101             class2Flip.remove(sym);
 102         }
 103         public void uninstall() {
 104             class2Flip.values().forEach(f -> f.flip());
 105             class2Flip.clear();
 106         }
 107     };
 108 
 109     public final Handler javacCodeHandler = new Handler() {
 110         public void install() {
 111         }
 112         public void handleAPICompletionFailure(CompletionFailure cf) {
 113             throw cf;
 114         }
 115         public void classSymbolCompleteFailed(ClassSymbol sym, Completer origCompleter) {}
 116         public void classSymbolRemoved(ClassSymbol sym) {}
 117         public void uninstall() {
 118         }
 119     };
 120 
 121     private Handler handler = javacCodeHandler;
 122 
 123     protected DeferredCompletionFailureHandler(Context context) {
 124         context.put(deferredCompletionFailureHandlerKey, this);
 125     }
 126 
 127     public Handler setHandler(Handler h) {
 128         if (h == handler) return handler;


< prev index next >