ASM 4 RC1 released
I'm proud with Eric and Eugene to announce the release of ASM4 RC1.
This release is available to download here:
So what's new ?
- Full support of Java 7.
Because Java 7 introduces several changes in the bytecode format,
all other versions of ASM aren't able to deal with this new format.
That why I strongly recommend you to use ASM4.
- Overhaul of the support of invokedynamic to support the new encoding
and bootstrap method arguments.
Practically, this means that invokedynamic doesn't trigger a call to
MethodVisitor.visitMethodInsn but use a specific new method:
visitInvokeDynamicInsn(String name, String desc, MethodHandle bsm, Object... args)
- Two new constants org.objectweb.asm.MethodHandle and org.objectweb.asm.MethodType
can be used either in visitLdcInsn() or as last arguments of visitInvokeDynamicInsn.
org.objectweb.asm.MethodHandle encodes a constant method handle and
org.objectweb.asm.MethodType encodes a constant method type.
Here is the snippet of how generate an instruction invokedynamic foo()V that will
call as bootstrap method bootstrapName with two bootstrap constants "bar" and 3.
MethodVisitor mv = ...
[prettify]MethodHandle bootstrap = new
MethodHandle(Opcodes.MH_GETSTATIC, "BoostrapClass", "boostrapName",
mv.visitInvokeDynamicInsn("foo", "()V", bootstrap, "bar", 3);[/prettify]
- ASM4 API has been generified to use generics and varargs
but almost all jars are still small and 1.2 compatible.
In fact, there is a trick, the API is 1.5 compatible but the bytecode is downgraded
to be 1.2 compatible using a bytecode rewriter (our own dog food).
To use the 1.5 compatible API you have to compile using all/asm-debug-all-*.jar
which is 1.5 compatible and also contains the debug information.
When running you can use all/asm-all-*.jar or several asm-*jar depending on your usage.
Except all/asm-debug-all-*.jar all other jars are 1.2 compatible and optimized.
If you want debug information at runtime you have to use all/asm-debug-all-*.jar.
ASM4 API has been generified to be as compatible as possible with 3.3 API.
So some methods now return an array of parametrized type which are not type safe
(not less than before in fact) if you store something in it.
The other solution should have been to use a List instead of an array
but this introduces too many non-compatible changes.
The package org.asm.tree.analysis is now fully typesafe but during that process,
we have changed some signatures in Interpreter subtypes so if your code
uses an ad-hoc interpreter it has to be updated.
Related Topics >>