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

JEP 235: Test Class-File Attributes Generated by javac

    Details

    • Author:
      Mikhail Kondratyev
    • JEP Type:
      Feature
    • Exposure:
      Open
    • Subcomponent:
    • Scope:
      Implementation
    • Discussion:
      compiler dash dev at openjdk dot java dot net
    • Effort:
      M
    • Duration:
      M
    • Alert Status:
       Green
    • JEP Number:
      235

      Description

      Summary

      Write tests to verify the correctness of class-file attributes generated by javac.

      Goals

      Create tests that check that all class-file attributes are generated correctly even if such attributes are not used in a regular compile-and-run scenario. Additionally, document any existing such tests.

      Motivation

      Class-file attributes have insufficient test coverage. Optional attributes and attributes which are not checked by the VM cannot be tested by compiling input sources, running them, and verifying that the compiled program behaves as expected. Lack of coverage leads to possible bugs which only might be detected by external tools, such as debuggers. A special test suite which will analyze class files and test class-file attributes for correctness by some other means is needed.

      Description

      The common way to test files generated by javac is to run the compiled classes and verify that the generated program behaves as expected. This approach does not work for optional class-file attributes, nor for attributes that are not verified by VM, so these two kinds of attributes must be tested by some other means. Tests will be developed which will accept Java source code as input, compile the source, read the class-file attributes of the compiled class files, and verify their correctness.

      Class-file attributes are divided into three groups, according to the JVMS.

      Optional attributes

      These attributes are not critical to the correct operation of javac, the JVM, or the class libraries, but they are used by tools. Testing these attributes is a high priority since they are not consumed by any component of the JDK.

      • SourceFile
      • SourceDebugExtension
      • LineNumberTable
      • LocalVariableTable
      • LocalVariableTypeTable
      • Deprecated

      Attributes not used by the JVM

      These attributes are not used by the JVM but they are used by javac or by the class libraries. Testing these attributes is a medium priority.

      • InnerClasses
      • EnclosingMethod
      • Synthetic
      • Signature
      • RuntimeVisibleAnnotations
      • RuntimeInvisibleAnnotations
      • RuntimeVisibleParameterAnnotations
      • RuntimeInvisibleParameterAnnotations
      • RuntimeVisibleTypeAnnotations
      • RuntimeInvisibleTypeAnnotations
      • AnnotationDefault
      • MethodParameters

      Attributes are used by the JVM

      These attributes are checked by the JVM's byte-code verifier. No further testing needed.

      • ConstantValue
      • Code
      • StackMapTable
      • Exceptions
      • BootstrapMethods

      Testing

      To test these new tests we will check that the tests fail, with an appropriate error message, when run against intentionally-corrupted class files.

        Issue Links

          Activity

          Hide
          jjg Jonathan Gibbons added a comment - - edited
          Under "testing", I think you should say more about how you will verify that the tests work as intended. It is not enough to say that the tests must be run on each platform (and pass.) An empty main program will do that!
          Show
          jjg Jonathan Gibbons added a comment - - edited Under "testing", I think you should say more about how you will verify that the tests work as intended. It is not enough to say that the tests must be run on each platform (and pass.) An empty main program will do that!
          Hide
          jjg Jonathan Gibbons added a comment -
          I believe this is about tests for javac. But the first occurrence of the word "javac" is under "Description" in this text: "The common way to test files generated by javac"

          I suggest trying to get "javac" to appear in a more prominent place.

          For example, how about a JBS Summary of "additional tests for classfile attributes generated by javac" or "improved testing of classfile attributes generated by javac"?

          Show
          jjg Jonathan Gibbons added a comment - I believe this is about tests for javac. But the first occurrence of the word "javac" is under "Description" in this text: "The common way to test files generated by javac" I suggest trying to get "javac" to appear in a more prominent place. For example, how about a JBS Summary of "additional tests for classfile attributes generated by javac" or "improved testing of classfile attributes generated by javac"?
          Hide
          emc Eric Mccorkle added a comment -
          With regard to annotations attributes, take note of the ClassfileInspector test library that was committed along with JDK-8065132
          Show
          emc Eric Mccorkle added a comment - With regard to annotations attributes, take note of the ClassfileInspector test library that was committed along with JDK-8065132
          Hide
          hseigel Harold Seigel added a comment -
          The JVM verifies some of the non-essential attributes. See https://bugs.openjdk.java.net/browse/JDK-8047891 for details.
          Show
          hseigel Harold Seigel added a comment - The JVM verifies some of the non-essential attributes. See https://bugs.openjdk.java.net/browse/JDK-8047891 for details.

            People

            • Assignee:
              eyavits Evgeny Yavits (Inactive)
              Reporter:
              mkondrat Mikhail Kondratyev (Inactive)
              Owner:
              Andrei Eremeev
              Reviewed By:
              Aleksandre Iline, Jonathan Gibbons
              Endorsed By:
              Aleksandre Iline
            • Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:
                Integration Due: