ObjectWeb Consortium
Search ObjectWeb Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | architecture List | Febuary 2004 Index

<--  Date Index  --> <--  Thread Index  -->

Re: [asm] JDK 1.5 support (and what I've done with ASM and Log4J)


inigosurguy@xxxxxxxxxxx wrote:
> Hi,
>
> First of all, thank you for ASM. I've just started using it, and
> I've already found it easier to use than BCEL, as well as a lot
> smaller.
>
> I've written a ClassFileTransformer using ASM to remove Log4J
> method calls at class load time, if they are below a specified
> logging threshold. eg, to remove all "debug" level Log4J calls, so
> you can happily put slow method calls in your logging without
> worrying about the performance penalty. The code is available at
> http://www.surguy.net/articles/removing-log-messages.xml
>
> (ClassFileTransformers are part of the new JDK 1.5 instrumentation
> package; they  allow you to hook in your own transformation code to
> change the bytecode of classes as they are loaded - perfect for
> ASM!)
>
> Which brings me to my question - is there any way of making ASM
> work with method-local and anonymous inner classes in JDK 1.5? When
> compiling with "-target 1.5", the local classes come out with names
> like "SomeClass+1.class" rather than the "SomeClass$1.class" in JDK
> 1.4, and when ASM alters them, then it causes ClassFormatErrors
> when those altered classes are loaded.
>
> Specifically, for my tests, I'm getting a:
>
> java.lang.ClassFormatError: Field "this" has illegal signature
> "Lnet/surguy/logfilter/DoesLogging+1;"
>
> Comparing the ASM-altered class file, and the original class file
> (decompiled with the JDK 1.5 javap):
>
> -------------
> The original source for the anonymous inner class

... [ skipped source ] ...

> ------------------
>
> You should also be able to duplicate this by downloading my source
> from the web page I've linked above, removing the
> "isJDK15InnerClass" check, and running the tests.
>
> Any ideas?

the problem may come from class version numbers (see 
ClassReader.getVersion() and ClassWriter(boolean,int,int)): the 
default version used to write classes is 45.3.

Eric




<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 1999-2005, ObjectWeb Consortium | contact | webmaster.