Re: inner class problem

Rémi Forax <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
Usually it means there is an exception (Throwable) is thrown in your 
Transformer
and received by the VM.
In that case hotspot doesn't use the transformer anymore.
So java -verbose:class
should print that the class is loaded but the class is not
transmitted to your transformer.

Surrounding the code in the transformer with a try/cath Throwable
which printStackTrace should solve your problem.

Rémi

On 12/09/2010 05:33 PM, Nikolas Nehmer wrote:
> Hi all,
>
> I have a problem regarding the following example:
>
> public class Demo2 {
>
>     InnerClass i;
>     int x;
>
>     Demo2() {
>         i = new InnerClass();
>     }
>
>     public static void main(String[] args) {
>         Demo2 demo = new Demo2();
>     }
>
>     class InnerClass {
>
>         InnerClass() {
>         }
>     }
> }
>
>
> My instrumentation adds some logging calls, i.e. in case of variable 
> assignments like i = new InnerClass(); it calls a static logging 
> facility. So far so good, but ins this special case, the inner class 
> is just not instrumented. I'm using load-time instrumentation based on 
> a Java agent. If I just add some debug System.out.printlns to the 
> agent (instead of the instrumentation calls), either Demo2 and 
> Demo2$InnerClass are passed to the agent. If I add the 
> instrumentation, only the outer class is instrumented, the inner class 
> is not even passed to the agent! Nevertheless the app is running - 
> i.e. Demo2 is instantiated, the inner class is instantiated and for 
> the outer class my logging calls are executed. The application 
> terminates normally.
> To sumarize:
> - The instrumented app runs without exception!
> - For the outer class the instrumentation works! i.e. for i = new 
> InnerClass(); a logging call is added
> - For the inner class there is NO call to the agent's transform(...) 
> method!
>
> Any ideas why the transform method might not be called for the inner 
> class?
>
> Btw. the following example works completely!!! The only difference is 
> splitting up the example in two classes!
>
> public class Demo {
>    public static void main(String[] args) {
>        MyComponent comp = new MyComponent();
>    }
> }
>
> public class MyComponent {
>    InnerClass i;
>
>    public MyComponent() {
>         i = new InnerClass();
>    }
>
>    static class InnerClass {}
> }
>
>
> Best regards
> Nikolas
>
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.