Question how to Modify static variable through an Agent with AgentBuilder
See original GitHub issueHi Rafael, great api
The Main Class , very simple
user.getLife () returns 10
public class ReflectionOnClass extends JFrame {
private static MyProgram2 user = new MyProgram2();
private JLabel jLabel = new JLabel("X: ");
public ReflectionOnClass() {
jLabel.setText("X: " + user.getLife()); // return 10
setLayout(new FlowLayout());
setPreferredSize(new Dimension(200, 200));
add(jLabel);
setDefaultCloseOperation(3);
setLocationRelativeTo(null);
pack();
setVisible(true);
}
public static void main(String ...blablabla) {
new Thread(ReflectionOnClass::new).start();
}
}
public class MyProgram2 {
private static Usuario USUARIO = new Usuario();
public MyProgram2() {}
public int getLife() {
return USUARIO.getLife();
}
}
public class Usuario {
private int life= 10;
public Usuario() {
}
public int getLife() {
return life;
}
@Override
public String toString() {
return "Hi";
}
}
The Usuario class contains the value that is assigned to JLabel, how could that value change with instrumentation through an Agent?
I need to know which test that you have created could help me to make the modification in runtime.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
java - How to change static variable value using ASM?
The first thing, your agent has to do, is registering a ClassFileTransformer . The first thing, the class file transformer should do in...
Read more >iReasoning SNMP Agent Builder User Guide
the CLASSPATH environment variable. On Windows: If the iReasoning SNMP Agent Builder is installed at. C:\lib\iReasoning\agent, use the command.
Read more >Static Variables in C - GeeksforGeeks
Following are some interesting facts about static variables in C. 1) A static int variable remains in memory while the program is running....
Read more >Easily Create Java Agents with Byte Buddy - InfoQ
In this article Rafael Winterhalter, creator of the bytecode manipulation tool Byte Buddy, provides detailed guidance on how to easily ...
Read more >Static variable and updating variables
It would be nice if we can have a features like below., Creating static variable, without prompting question. Updating existing variable ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Funciona perfecto jefe. Works perfectly boss thanks a lot.
Something happened to me with the project generated in see apparently. the target.jar has a new pom.xml
Boss like that also worked wtf, I had an error in the construction of my project. omggg
This is the structure of my project, with the manifest I do not know if that was what I lacked.
Try with a regular listener, not an installation listener: