diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java index f3550d2a817..c72ceec3f4e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -861,6 +861,7 @@ public void compile(List sourceFileObjects, delegateCompiler.close(); elapsed_msec = delegateCompiler.elapsed_msec; } catch (Abort ex) { + correctDelegateCompilerIfNeed(); if (devVerbose) ex.printStackTrace(System.err); } finally { @@ -869,6 +870,23 @@ public void compile(List sourceFileObjects, } } + /** + * If processAnnotations abort in a certain round, + * delegateCompiler is likely to be null, + * resulting in a compilation failure, + * but Javac considers it successful, + * so it may be necessary to find the final delegateCompiler compiler used here + */ + private void correctDelegateCompilerIfNeed() { + if(delegateCompiler != null){ + return; + } + Context procContext = procEnvImpl.getContext(); + if(procContext != context){ + delegateCompiler = JavaCompiler.instance(procContext); + } + } + /** * The phases following annotation processing: attribution, * desugar, and finally code generation.