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.

538 questions
10
votes
1 answer

How to debug a Java agent

At the moment there is possibility to run JVM with an agent: -javaagent:somejar.jar this way in order to run the Java agent I have wrote as an I have to put it into a jar. therefore it is limited in debugging. Is there a technique for debugging a…
user2850243
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,923
  • 29
  • 46
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
  • 9,146
  • 20
  • 70
  • 126
8
votes
2 answers

Specify java agent inside 'fat jar'?

I am using the jetty-alpn-agent to add ALPN support to my project, but all I can find is instructions on how to run it from the .m2 folder, which makes me need to deploy two jar:s instead of just my one uber-jar, making it less portable. Is is…
8
votes
2 answers

Setting javaagent for particular task in Gradle

This is my run configuration. task run << { jvmArgs "-javaagent:/home/audrius/org.springframework.instrument-3.0.5.RELEASE.jar" jettyRun.execute() } but it gives me: Could not find method jvmArgs() How do you set javaagent for jettyRun?
Maladec VampaYa
  • 351
  • 3
  • 21
6
votes
1 answer

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…
Jacob
6
votes
1 answer

How to use Java agent with native compiled spring boot application

Together with our SpringBoot (3.0.3) application we are using Application Insights (Azure) for monitoring. Currently we are trying to compile the application natively with the GraalVM. That works quite well and gives us a lot of benefits (startup…
6
votes
1 answer

How to test a ClassFileTransformer / javaagent?

I implemented a ClassFileTransformer for a javaagent using ASM. Because it has some bugs, I want to write a JUnit test case for it. How do I do this? Using pseudo-code I thought along the lines: // Have a test class as subject public static class…
roesslerj
  • 2,611
  • 5
  • 30
  • 44
6
votes
2 answers

How to speed up runtime Java code instrumentation?

I made a Java agent which is attached to a JVM during runtime and instruments all the loaded project classes and inserts some logging statements. There are 11k classes in total. I measured the total time taken by the transform method of my…
Nfff3
  • 321
  • 8
  • 24
6
votes
1 answer

How to integrate Spring Instrument javaagent in ALL JUnit tests

I am writing unit tests on a large project which I need to pass JVM arguments to, those are my JVM arguments built into the Eclipse run configuration for that project : --module-path lib/javafx-sdk-13.0.2/lib…
Martin
  • 1,977
  • 5
  • 30
  • 67
6
votes
3 answers

Jolokia - Origin null is not allowed to call this agent

{"stacktrace":"java.lang.Exception: Origin null is not allowed to call this agent\n\tat org.jolokia.http.HttpRequestHandler.handleThrowable(HttpRequestHandler.java:242)\n\tat …
dandan
  • 121
  • 1
  • 8
6
votes
1 answer

Adding a class to the class path with a Java Agent

I'm using a Java Agent and Javassist to add some logging to some JDK classes. Essentially when the system loads some TLS classes, Javassist will add some additional bytecode to them to help me debug some connection problems. Here's the problem,…
Jonathan S. Fisher
  • 8,189
  • 6
  • 46
  • 84
6
votes
1 answer

Maven test and -Javaagent argument

I have a simple java project with on Junit test case that has the current architecture: pom.xml src/main/java/com/Example.Java src/test/java/com/ExampleTest.java The contents of pom.xml are as follow:
SFD
  • 565
  • 7
  • 18
6
votes
2 answers

How can Spring AspectJ weaving work without the -javaagent vm option?

I understand Spring avoids using the -javaagent vm option in order to get its AspectJ load time weaving to work and relies instead on a classloader to start the agent. I thought that the Java specification dictated that the only way to use a Java…
balteo
  • 23,602
  • 63
  • 219
  • 412
6
votes
3 answers

Using Instrumentation to record unhandled exception

I was trying to debug java application using instrumentation. The problem with current system are Hardly written any log statements Poor exception handling This made very difficult to trace root cause of broken functionality. To handle the…
Satheesh Cheveri
  • 3,621
  • 3
  • 27
  • 46
1
2
3
35 36