Testing class-file attributes generated by Javac 

The lack of, or insufficient, capability to create tests for class-file attributes was the impetus behind the effort to ensure javac creates a class-file's attributes completely and correctly. This suggests that even if some attributes are not used by the class-file, all class-files should be generated with a complete set of attributes. There also needs to be a way of testing that the class-files were created correctly, in regards to the file's attributes. 

Prior to Java 9, there was no method of testing a class-file's attributes. Running a class and testing the code for anticipated or expected results were the most commonly used method of testing javac generated class-files. This technique falls short of testing to validate the file's attributes.

There are three categories of class-file attributes—attributes used by the JVM, optional attributes, and attributes not used by the JVM.

Attributes used by the JVM include the following:

  • BootstrapMethods
  • Code
  • ConstantValue
  • Exceptions
  • StackMapTable

Optional attributes include the following:

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

Attributes not used by the JVM include the following:

  • AnnotationDefault
  • EnclosingMethod
  • InnerClasses
  • MethodParameters
  • RuntimeInvisibleAnnotations
  • RuntimeInvisibleParameterAnnotations
  • RuntimeInvisibleTypeAnnotations
  • RuntimeVisibleAnnotations
  • RuntimeVisibleParameterAnnotations
  • RuntimeVisibleTypeAnnotations
  • Signature
  • Synthetic
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset