javaagents

What are some interesting uses for Java Agents?

Starting with Java 5 there's an option to add Java Agents to the class loader. Have you written any Agents? have you used any Agents? What are interesting uses of Agents? ...

Debugger won't work with JMockit

Hopefully an easy question here for someone..... I'm using RAD 7.5.2, and am writing Junit tests. I was writing them just fine with JUnit 3, and then I wanted to mock up some function calls. So I loaded up jmockit 0.9.7 and Junit 4.6. I also include -javaagent:jmockit.jar as a VM argument. When I "Run As Junit Test", it goes along w...

How do I start my Java program with more than one java agent ?

Hello, I'm aware of how to start a java progam with a java agent: java -javaagent:myAgent.jar MyJavaProgram But what if I want to add 2 or more java agents to instrument my program? I do not want to reinvoke the java -javaagent:... for every agent I have to load in JVM. I've tried something like this : java -javaagent:agentA.jar, a...

Javaagent class unloading

I have a java agent which instruments bytecode. I am using the attach apis in java 6 to allow users to dynamically load the agent and instrument and deinstrument code using my java agent. I am using the Boot-Class-Path manifest attribute to make sure my javagent classes are in the boot classpath so that my users can instrument classes li...

Starting a Java agent after program start

Is it possible to insert a javaagent after virtual machine start from within the same VM? Lets say for example we have an agent in a jar myagent.jar with the appropriate meta data set-up and an agentmain method already implemented. Now the users program calls an API call which should result in the insertion of the agent so that it can r...

Problem using -javaagent with Linux 64 bit tomcat

I m using -javagent agent.jar to instrument java classes in tomcat.While using -javaagent:,in manifest file of the jar we will mention the premain class which gets called first and from there we can start instrumenting Byte code . From my Premain class(which get first called ) I add shutdownhook class to JVM. Runtim...

An equivalent of -javaagent in C#? Or: ways to use a java framework in C#.

Hi everyone. This is probably something I should be able to figure out by myself, but I'm not having much luck so I figured I'd ask. The issue: I'm translating a system from java to C# and they use a java framework that I'd really like to use, since it takes care of the most complex parts of the system, which I would otherwise have to ...

Does a java agent run in a separate thread?

I feel that this is something I should know, but does a java agent (specified with -javaagent) run in a separate thread? I've read that a Java agent is a pluggable library that runs embedded in a JVM and intercepts the classloading process, but I want to make sure: does it really intercept them (which sounds like it's running in another ...

Using metamorphic code to reduce boilerplate

Has anyone seen metamorphic code -- that is, code that generates and runs instructions (including IL and Java Bytecode, as well as native code) -- used to reduce boilerplate code? Regardless of the application or language, typically one has some database code to get rows from the database and return a list of objects. Of course, there ...