javaagents

Javassist's CtMethod.insertAt(line,src) instruments code at the wrong bytecode position

限于喜欢 提交于 2020-01-16 18:34:55
问题 My goal is to insert a little bit of instrumentation code at the beginning of each basic block of code. It seems like a fairly simple task with Javaassist's ControlFlow.Block and CtMethod.insertAt(). Here's the relevant chunk of code so far (it's located in the transform function): ControlFlow flow=new ControlFlow(m); //m is the CtMethod currently being instrumented Block[] blockArray=flow.basicBlocks(); for(Block thisbb : blockArray){ //Dynamically Update Method Statistics String blockUpdate

JNI: intercepting native methods outputs

╄→гoц情女王★ 提交于 2020-01-15 07:06:27
问题 currently i am working on a project where i need to intercept the results of java native method calls for further analysis. There are multiple ways to achieve that but the way of my choice is: at native binding time, re-bind the addresses of java native methods to the address of my own wrapper-function, which would call the initial native function by itself and then return its result while intercepting the returned variable. The wrapper function should be generic, meaning it would handle the

Look at the source code of a Java class modified by a Java Agent

假装没事ソ 提交于 2020-01-15 03:20:05
问题 I need to see how a Java Agent modified my initial class, so I can understand what the code does. build.gradle configurations { jar.archiveName = 'agent2.jar' } jar { manifest { attributes( "Premain-Class": "com.training.agentexample.Agent", "Can-Redefine-Classes": false, "Can-Set-Native-Method-Prefix": false ) } //Fat jar with all dependencies. from { (configurations.runtime).collect { it.isDirectory() ? it : zipTree(it) } } } dependencies { compile group: 'org.javassist', name: 'javassist',

How to put classes for javaagent in the classpath

喜夏-厌秋 提交于 2020-01-10 18:23:36
问题 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 jar-with-dependencies (aka maven build plugin) which contains all the needed classes by the agent, or is there another way to add classes to the java agent? Referencing the jar asm-all.jar directly in the classpath didn't help. Building jar-with-dependencies

How to put classes for javaagent in the classpath

瘦欲@ 提交于 2020-01-10 18:22:07
问题 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 jar-with-dependencies (aka maven build plugin) which contains all the needed classes by the agent, or is there another way to add classes to the java agent? Referencing the jar asm-all.jar directly in the classpath didn't help. Building jar-with-dependencies

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

廉价感情. 提交于 2020-01-01 07:41:11
问题 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 -XX:+HeapDumpOnOutOfMemoryError -Xss180k The stack size specified is too small, Specify at least 228k Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. 回答1: I have fixed it by editing file /etc/cassandra

How to log(debug) javaagent with agent options

一笑奈何 提交于 2019-12-25 06:54:12
问题 I set up my javaagent in the like this: -javaagent:/usr/pkg/tomcat/lib/aspectjweaver-1.7.3.jar But it does not work, so I would be interested to have a look at the logs. What can I add to javaagent if I want to get log messages? (stacktrace, which classes were loaded etc...) I beleive "options" should be used for this. The documentation says: implementations with a command-line interface, an agent is started by adding this option to the command-line: -javaagent:jarpath[=options] jarpath is

How to start aspectj loadtime weaver agent without restarting jvm / how to start loadtime weaver in code?

删除回忆录丶 提交于 2019-12-25 00:18:53
问题 Is there any way to start the AspectJ loadtime weaver during the application is running? Means without restarting the JVM and adding -javaagent:... ? I tried https://stackoverflow.com/a/35775792/3880225 but without any success. 回答1: Yes, you can do that, I implemented this capability myself for AspectJ and it was included since version 1.8.7, see release notes for an example. But please note that weaving will only work for classes loaded after you have activated the weaver. 来源: https:/

how to resolve java result 1 errors

社会主义新天地 提交于 2019-12-24 17:15:47
问题 How to resolve 1 particular flavor of 'java result 1' in the context of using JVMTI agents? 回答1: Here's how I resolved an issue in my context: The server is run through an ANT script with jvm configured with an agent (the property name 'agentfile' below is associated with a value pointing to the agent library) Now, I would get the error 'java result 1' whenever the server was run, without any indication of the actual error. Here's how this issue was debugged. 1) The agent was turned off (i.e.

Alter value of a static field during class loading using a Java agent

南楼画角 提交于 2019-12-24 12:13:19
问题 We have a java process that calls some method of class X. Class X has timeout static field which decides how long thread should wait for in case of some error. Now, I want to change that value without changing my java process (I don't want deployment, and this change is experimental). How can I use java agent to change this timeout value to say 1 minute (1*60*1000) Class X { .... // timeout = 5 minutes private static long timeout = 5*60*1000; .... } In short, how to write java agent to change