Can I see dynamically modified bytecodes?

Cay Horstmann <[email protected]> Fri, 09 Jun 2006 21:10:16 -0700
Newsgroups gmane.comp.java.jswat.user
Message-ID <[email protected]>
I am trying to use JSwat to study how JPA modifies byte codes on the 
fly. For example when I launch the GlassFish implementation as

java -classpath 
.:/usr/local/glassfish-persistence/toplink-essentials.jar:/usr/local/glassfish/javadb/lib/derbyclient.jar 
-javaagent:/usr/local/glassfish-persistence/toplink-essentials-agent.jar 
elvis/client/Client

then the following class is modified by the Toplink agent:

@Entity
public class Question implements Serializable {
     . . .
     private Choice answer;

     @OneToOne(fetch=FetchType.LAZY)
     public Choice getAnswer() {
         return answer;
     }
     . . .
     public String toString() {
         return getClass().getName() + "[id=" + id
                 + ",answer=" + answer"]";
     }
}

Fields are added, which I can observe, and the getAnswer method is 
changed, which I can't observe. Tracing through makes the cursor jump 
crazily through the source.

I'd like to step through that method, a byte code at a time, if that is 
possible. Like assembly mode in gcc. Or, if that's not doable, at least 
I'd like to see the bytecodes.

I realize a JVM debugger isn't the same as a C debugger, so this may be 
asking too much. But I thought I'd ask.

Thanks,

Cay


-- 

Cay S. Horstmann | http://horstmann.com | mailto:[email protected]