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

    Details

      Description

      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


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

      My test driver starts out like

      @BadAnnotationSuperinterfaces(42)
      @BadAnnotationSuper(42)
      @BadAnnotationMethodMods(42)
      @BadAnnotationParamCount(42)
      @BadAnnotationThrows(42)
      @BadAnnotationReturnType(42)
      @BadAnnotationHashCode(42)
      // @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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated: