CodeTools proposal: "AsmTools"

Jonathan Gibbons jonathan.gibbons at
Thu Dec 4 22:35:56 UTC 2014


Thank you for this proposal.

I note that the tools will be of more general use than just "VM 
class-loader rejection of invalid classfiles".

I see these tools as being generally useful for generating "atypical" 
class files for testing all OpenJDK tools that consume classfiles, where 
"atypical" includes invalid or malformed class files, and valid 
classfiles containing content in a form not otherwise normally available 
(e.g. from javac.)  For example, the JVM Spec allows multiple 
LineNumberTable attributes, but javac only ever generates a single one.

In addition, these tools will be useful for representing class files in 
a very low level form, but still text, so that such files can be checked 
into a repo.  As a consequence, once these tools are available, it will 
be worth considering the possibility of integrating them into jtreg, so 
that we can include and use very specific class files in unit and 
regression tests.

-- Jon

On 12/04/2014 01:02 PM, Brian Kurotsuchi wrote:
> Name: AsmTools
> Summary: A set of (Java class file) assembler/disassemblers, in order 
> to facilitate the practice of verifying VM class-loader rejection of
> invalid classfiles - for the purpose of OpenJDK development.
> Proposed by: Brian Kurotsuchi, Oracle, Java Conformance Tools team
> Rationale:
> This proposal is to open the Java Assembler Tools (AsmTools) into the
> CodeTools project of OpenJDK. The rationale for this is to provide
> transparency to the process of testing Java Virtual machines.  The
> advantage to promoting standard and methodical negative testing of 
> Java VM class-loading  allows JDK developers to test their own VM and 
> other environmental changes.  Publishing negative tests may also allow 
> external OpenJDK users to contribute new tests for class file 
> rejection that are not currently covered by SQE nor JCK test suites.
> AsmTools consists of 2 sets of assembler/disassemblers:
> Jasm/JDis - an assembler language that provides a Java-like 
> declaration of member signatures, while providing Java VM 
> specification compliant mnemonics for byte-code instructions. Jasm 
> also provides high-level syntax for constructs often found within 
> classfile attributes.   Jasm encoded tests are useful for sequencing 
> byte codes in a way that Javac compiled code might not normally 
> sequence byte-codes.
> JCod/JDec - an assembler language that provides byte-code containers 
> of class-file constructs. JCod encoded tests are useful for testing 
> the well-formedness of class-files, as well as creating collections 
> within a class-file construct that might be size-bounded by a normal 
> Java compiler.   JCod can also be used to 'fuzz' class files in a 
> methodical way that respects class-file constructs.
> AsmTools are completely reflexive - Java binary (.class) files may be
> disassembled into textual representations, which in turn can be
> assembled back to the same binary file.
> AsmTools are developed to support the latest class file formats, in
> lock-step with JDK development.
> Other open source Java assembler tools and binary classfile frameworks 
> exist.  They can be used for the purpose of synthesizing classfiles 
> for VM testing, however:
> a.) they typically are designed to enforce the limits imposed by the 
> VM specification of the class file format.  They are not designed to
> produce classes that violate those limits.
> b.) other assembler tools may not necessarily follow strict Java
> mnemonics as defined in the Java VM spec.
> c.) other assembler tools may not stay in lock-step with the current
> generation of the JDK and VM specifications.
> d.) class file libraries are harder to use for simple manipulations of 
> any given class file.  Typically, one has to create a program in that 
> framework to parse and modify a class for a specific change to a given 
> class.

More information about the code-tools-dev mailing list