Re: ASM-based class transformation affect class loading?

Eugene Kuleshov <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
  Have you specified COMPUTE_FRAMES flag in the ClassWriter's accept()
method? If so, remove it, or overwrite its getCommonSuperClass(..)
method that won't load classes.

  regards,
  Eugene


On Tue, Aug 3, 2010 at 11:48 AM, Sai Zhang <[email protected]> wrote:
> Hi all:
>
> I met a strange problem when using ASM to transform my client code at load
> time (excluding all JDK code already).
>
> It seems that my transformer is highly likely to affect the class loading
> process. Please refer to the simple code below
> for illustration:
>
> Here is my simple ClassFileTransformer for load time class transformation,
> all transformation operations are
> in the treeAPITransform(byte[]) method. It is actually a fairly simple
> intra-method transformation based on the "tree api"
> of ASM (just adding tracing method at the begin/end of each method call)
>
>
> @Override
>     public byte[] transform(ClassLoader loader, String className,  Class<?>
> clazz, ProtectionDomain domain,   byte[] bytes) {
>          //code omitted here, for excluding all JDK classes
>
>            /*I print each loaded class for debugging */
> (1)   System.err.println("---- load class: " + className);
>
>         try {
> (2)          return this.treeAPITransform(bytes);   //my simple
> transformation implementation
>         } catch (Exception e) {
>             e.printStackTrace();
>             return null;
>         }
>     }
>
> The weird thing is that statement (1) does not print out some obviously
> loaded classes (which has definitely been initialized and executed).
> If I remove statement (2), or change that to "return null", every thing OK.
> all classes loaded are printed out at statement (1).
> I feel very confused on this point. I am wondering will ASM-based
> intra-method transformation affect the class loading? or
> did I instrument some extra classes by accident? or I should not use the
> tree api? or there is any tricks on this point?
> P.S. I use the ClassCheckerAdapter in ASM to check the validity of
> transformed bytecode after transformation. and no error messages
> are issued.
> thanks. Any comments are highly appreciated!!!
> -Sai
>
> --
> You receive this message as a subscriber of the [email protected] mailing list.
> To unsubscribe: mailto:[email protected]
> For general help: mailto:[email protected]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.