Re: inner class problem

Nikolas Nehmer <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Organization FB Informatik, TU Kaiserslautern, GERMANY
Message-ID <31947175.1292241530356.OPEN-XCHANGE.WebMail.tomcat@groupmail.informatik.uni-kl.de>
Hi,

uups replied to the wrong mail.

obviously the following verifier call leads to a non instrumented inner
class sometimes. I fixed a little bug in my instrumentation code. The
example from my previous mail now works properly. But in a more complex
scenario I still have a problem. If I add a call to the internal asm
verifier the inner class is just not instrumented. If I leave it out,
the example works - i.e. the Java verifier obviously does not have any
problems with the bytecode. Any ideas where this bug might come from?

// add byte code verifier
StringWriter stringWriter = new StringWriter();
CheckClassAdapter.verify(new ClassReader(classWriter.toByteArray()),
false, new PrintWriter(stringWriter));
         if (stringWriter.getBuffer().length() > 0) {
            logger.severe(stringWriter.toString());   
         }


Nikolas

Am Do 09.12.2010 17:33 schrieb Nikolas Nehmer
<[email protected]>:

>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
>
>--
>Dipl.-Inf. Nikolas Nehmer,
>Dept. of Computer Science. University of Kaiserslautern
>P.O. Box 3049, 67653 Kaiserslautern, Germany.
>room 36/308, phone: +49 (0) 631 - 205 2644, fax: +49 (0) 631 - 205 3299
>mail: [email protected]
>
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.