Questions tagged [javaagents]

A Java agent allows for the instrumentation of a Java application by using another Java program that is specified on the command line.

All Java classes concerned with instrumentation are collected in the java.lang.instrument package. The package description defines the layout of a Java agent as follows:

An agent is deployed as a JAR file. An attribute in the JAR file manifest specifies the agent class which will be loaded to start the agent. For implementations that support a command-line interface, an agent is started by specifying an option on the command-line. Implementations may also support a mechanism to start agents some time after the VM has started. For example, an implementation may provide a mechanism that allows a tool to attach to a running application, and initiate the loading of the tool's agent into the running application. The details as to how the load is initiated, is implementation dependent.

448 questions
84
votes
4 answers

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

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…
Flueras Bogdan
  • 8,411
  • 8
  • 30
  • 30
56
votes
2 answers

Tutorials about javaagents

I'd like to learn something about javaagents, but researching is not easy. Most of result refers to JADE. I know java agent can mean two things: An agent programmed in Java being an incarnation of the agent concept of distributed systems. A…
alicjasalamon
  • 3,753
  • 11
  • 37
  • 63
26
votes
4 answers

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…
Paul Keeble
  • 1,192
  • 2
  • 11
  • 16
21
votes
4 answers

How can I add a Javaagent to a JVM without stopping the JVM?

I wish to profile a Java application without stopping the application. Can I add a Javaagent somehow while the application is running?
yazz.com
  • 52,748
  • 62
  • 227
  • 363
16
votes
1 answer

How do I pass arguments to a Java instrumentation agent?

How do I pass arguments to a java.lang.instrument instrumentation agent? The documentation simply states: -javaagent:jarpath[=options] What options can I select?
Duncan Jones
  • 59,308
  • 24
  • 169
  • 227
16
votes
1 answer

Cassandra:The stack size specified is too small, Specify at least 228k

I'm getting this error when starting cassandra after upgrade. Any idea? # cassandra -f xss = -ea -javaagent:/usr/share/cassandra/lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms1920M -Xmx1920M -Xmn200M…
Harikrishnan
  • 8,629
  • 9
  • 75
  • 119
14
votes
3 answers

C++ jump to other method execution

In my C++ JNI-Agent project i am implementing a function which would be given a variable number of parameters and would pass the execution to the other function: // address of theOriginalFunction public static void* originalfunc; void*…
Aksim Elnik
  • 405
  • 3
  • 23
14
votes
3 answers

Specify javaagent argument with Maven exec plugin

I have a similar question to: this previous question I am converting a Java project using Netbeans to Maven. In order to launch the program, one of the command-line arguments we need is the -javaagent setting.…
David I.
  • 4,659
  • 3
  • 24
  • 33
13
votes
3 answers

Relocating AspectJ packages in a Java agent

I'm using AspectJ to monitor field access and field modify. I have a gradle project that compiles the two aspects and package that jar together with the aspectjrt and aspectjweaver in a shaded jar using gradle shadow plugin. the agent is still…
Shalom938
  • 854
  • 1
  • 10
  • 20
12
votes
3 answers

Difference between redefine and retransform in javaagent

When packing a jar file with custom java agent, you can add the following properties: Can-Redefine-Classes Can-Retransform-Classes What is the difference between those two? If redefinition happens before class is loaded and retransformation after,…
Average Joe
  • 583
  • 3
  • 15
11
votes
3 answers

Adding -javaagent to Tomcat 6 server, where do I put it and in what format?

I´m trying to install an application health monitoring application that can monitor J2EE web transactions and I need to put a javaagent into my Tomcat somehow but am not clear on exactly how to do this, I am using Linux and have been instructed by…
Rick
  • 15,305
  • 33
  • 106
  • 160
11
votes
5 answers

How to put classes for javaagent in the classpath

I am trying to develop a javaagent that would instrument code with help of asm-4. For now I'm stucked with a pretty basic problem, the classloader for the javaagent doesn't see asm dependencies and therefor fails. Do I have to provide a…
Leon
  • 989
  • 1
  • 8
  • 24
10
votes
1 answer

What is the use of agentmain method in java instrumentation

I done some java bytecode instrumentation with -javaagent argument and premain method. But this is the first time i hear about agentmain method. I have some questions about this method. Here follows it. Both premain and agentmain method have same…
Anish Antony
  • 847
  • 2
  • 15
  • 33
8
votes
2 answers

Can a JVM retrieve a list of agents that have been loaded into it via the attach api?

Is it possible to get a list of agents loaded into the current JVM by the Java 1.6 attach api? If so how? Agents loaded at launch can be determined via RuntimeMXBean but I can't see a way to get a handle on ones added after launch.
henry
  • 5,153
  • 25
  • 40
8
votes
1 answer

transforming class has no effect

Based on this tutorial I try to get a java agent to work. https://www.baeldung.com/java-instrumentation#loading-a-java-agent I do get [Agent] Transforming class TestApplication I have no errors, but I can't see any effect of transforming the…
clankill3r
  • 7,935
  • 16
  • 62
  • 110
1
2 3
29 30