Write tests to verify the correctness of class-file attributes generated
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.
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.
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.
These attributes are not critical to the correct operation of
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.
Attributes not used by the JVM
These attributes are not used by the JVM but they are used by
by the class libraries. Testing these attributes is a medium priority.
Attributes are used by the JVM
These attributes are checked by the JVM's byte-code verifier. No further testing needed.
To test these new tests we will check that the tests fail, with an appropriate error message, when run against intentionally-corrupted class files.