JDK-8218152 : [javac] fails and exits with no error if a bad annotation processor provided
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u192,11.0.1,12,13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-01-31
  • Updated: 2019-12-02
  • Resolved: 2019-04-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12 JDK 13 Other
11.0.4Fixed 12.0.2Fixed 13 b19Fixed openjdk8u222Fixed
Related Reports
Duplicate :  
Relates :  
Description
There is an issue where javac fails and exits with no error if a bad annotation processor provided within a jar file is on the classpath.

Background: an Annotation Processor class can be packaged in a jar file and is identified by a special text file inside the jar named: META-INF/services/javax.annotation.processing.Processor. This text file has only one line, specifying the class name of the annotation process class to run. When javac runs, it checks all jars on the classpath and if it finds the special text file in any jar file, then it attempts to run the class listed there.

The issue here is that when the annotation processor class can't be executed, javac catches the exception and exits without reporting on the reason for the exit. Examples of reasons why the annotation processor can't be executed include:

* the annotation processor class is compiled for a higher version of Java than the javac is running, giving UnsupportedClassVersionError.
* the annotation processor class file is corrupt so can't be loaded.

In either of the above cases javac will swallow the error and exit without telling the user why it failed to compile the java source code as expected.

Testcase
   put HelloWorld.java in current directory, edit <path_to_jar> and run:
         javac -cp .:<path_to_jar>/bad.annotation.processor.jar HelloWorld.java

Instead of producing HelloWorld.class as expected, javac exits silently.

Here, bad.annotation.processor.jar is a file that was created to contain:
      META-INF/services/javax.annotation.processing.Processor <<-- text file to list bad class
     bad/notaclass.class <<-- dummy file, can't be loaded as a java class


This fails on jdk8u as well as jdk11-jdk13

Comments
Fix Request This issue causes termination of the javac command without any errors reported. This has been resolved in jdk/jdk and it would be great to have the same fix in other versions. This is a low risk change and tests are provided. I am requesting that this be fixed in jdk8u, jdk11u and jdk12u. The fix imports cleanly on jdk11u and jdk12u but jdk8u requires some slight differences due to differences in the test framework. A request for a review of the jdk8u changes has been made on the mailing list here: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2019-May/001074.html There are tests provided to cover the scenario where the javac executable failed.
01-05-2019