Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8130493

javac silently ignores malformed annotation processor class

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 8u45, 9
    • Fix Version/s: tbd_major
    • Component/s: tools
    • Labels:
      None

      Description

      javac silently swallows malformed class files in an annotation processor and returns with exit code 0. Instead, javac should report the error and return with an non-0 exit code.

      dsimon@kurz ~/JDK-8130493> java -version
      java version "1.9.0-ea"
      Java(TM) SE Runtime Environment (build 1.9.0-ea-b59)
      Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b59, mixed mode)
      dsimon@kurz ~/JDK-8130493> javac *.java
      dsimon@kurz ~/JDK-8130493> java SilentProcessor
      dsimon@kurz ~/JDK-8130493> javac -processorpath ap.jar -implicit:none Annotated.java
      running SilentProcessor on [Silent]
      running SilentProcessor on []
      dsimon@kurz ~/JDK-8130493> java SilentProcessor truncate
      dsimon@kurz ~/JDK-8130493> javac -processorpath ap.jar -implicit:none Annotated.java
      dsimon@kurz ~/JDK-8130493> echo $status
      0
      dsimon@kurz ~/JDK-8130493> javac -verbose -processorpath ap.jar -implicit:none Annotated.java
      [parsing started RegularFileObject[Annotated.java]]
      [parsing completed 15ms]
      [search path for source files: .]
      [search path for class files: JRT_MARKER_FILE,/Library/Java/JavaVirtualMachines/jdk1.9.0.jdk/Contents/Home/lib/jfxrt.jar,.]
      [loading [/java.base/java/lang/Object.class]]
      [loading [/java.base/java/lang/String.class]]
      [loading RegularFileObject[./Silent.class]]
      [loading [/java.base/java/lang/annotation/Annotation.class]]
      Round 1:
      input files: {Annotated}
      annotations: [Silent]
      last round: false
      [total 152ms]
      dsimon@kurz ~/JDK-8130493> echo $status
      0
      dsimon@kurz ~/JDK-8130493> javac -XDdev -processorpath ap.jar -implicit:none Annotated.java
      com.sun.tools.javac.util.Abort: java.lang.ClassFormatError: Truncated class file
      at com.sun.tools.javac.processing.JavacProcessingEnvironment$ServiceIterator.next(JavacProcessingEnvironment.java:377)
      at com.sun.tools.javac.processing.JavacProcessingEnvironment$ServiceIterator.next(JavacProcessingEnvironment.java:338)
      at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:609)
      at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:700)
      at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2000(JavacProcessingEnvironment.java:93)
      at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1023)
      at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1130)
      at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1141)
      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:832)
      at com.sun.tools.javac.main.Main.compile(Main.java:252)
      at com.sun.tools.javac.main.Main.compile(Main.java:141)
      at com.sun.tools.javac.Main.compile(Main.java:56)
      at com.sun.tools.javac.Main.main(Main.java:42)
      Caused by: java.lang.ClassFormatError: Truncated class file
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:759)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:370)
      at com.sun.tools.javac.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:254)
      at com.sun.tools.javac.util.ServiceLoader$1.next(ServiceLoader.java:336)
      at com.sun.tools.javac.processing.JavacProcessingEnvironment$ServiceIterator.next(JavacProcessingEnvironment.java:372)
      ... 12 more
      dsimon@kurz ~/JDK-8130493> echo $status
      0

        Attachments

        1. Annotated.java
          0.1 kB
        2. JDK-8130493.diff
          1.0 kB
        3. Silent.java
          0.0 kB
        4. SilentProcessor.java
          2 kB

          Issue Links

            Activity

              People

              Assignee:
              jlahoda Jan Lahoda
              Reporter:
              dnsimon Douglas Simon
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: