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

Problem with javac mis-compiling class files when an "interesting" annotation-ish class file is present



      From Joe Darcy:

      In the course of working on 8035781: Improve equality for annotations, Alex suggested another scenario for the regression test: make sure a runtime error is thrown in an annotation type has a mismatch between the declared return type of a method and the default value stored for the method. A good news / bad news situation resulted.

      The good new is the core reflection runtime already properly rejects such types by throwing an error. The bad news is that javac mis-generates the class file for a source files containing a annotation of such a corrupt type

      I've attached the asm-generated class files which corresponds to the pseudo code

            public @interface BadAnnotationDefault {
                int value();
                String badValue() default -1; // Type mismatch of default

      My test driver starts out like

      // @BadAnnotationDefault(42)
      public class TestMalformedHandling {
          // Make sure reading each of the annotations above throws an AnnotationFormatError...

      and when @BadAnnotationDefault all eight of those annotations seem to be written out as @BadAnnotationDefault.


          Issue Links



              • Assignee:
                jjg Jonathan Gibbons
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: