386 questions
5 votes
2 answers
295 views
How to make an existing class (present in jar file) implement Serializable at runtime (by javassist, bytebuddy, etc)?
I have a class in the source code class BillPughSingleton { private BillPughSingleton() { System.out.println("BillPughSingleton private constructor called"); } // Lớp ...
0 votes
0 answers
21 views
How to ensure instrumented class is packaged in the APK
I have this custom gradle plugin to replace the implementation of a class. When I build the apk I do see that the original class is modified as expected. However, the class packaged in the apk is ...
1 vote
0 answers
44 views
Is there a way to generate invokedynamic bytecode using BCEL?
I want to generate invokedynamic bytecode using BCEL library. Using BCEL I want to generate a class file which calls a bootstrap method using invokedynamic opcode. I can see BCEL has INVOKEDYNAMIC ...
0 votes
2 answers
152 views
Java bytecode not in .class file
I'm working on a personal project just for fun, a new programming languages (just because there are not enough). I m going to make it run on JVM but I need to store some metadata in the compiled file. ...
0 votes
0 answers
139 views
How to inject a method into a class at runtime without ASM?
In past versions of the bytecode manipulation framework Mixin, there was a method called prepareConfigs(MixinEnvironment). A nonstandard, but very commonly-used, way to bootstrap Mixins at a certain ...
0 votes
1 answer
269 views
How is string concatenation handled in Java bytecode compilation?
public class TestException extends Exception { public TestException(String msg) { super("This is the message: " + msg); } } The above code is compiled to: public class ...
0 votes
0 answers
92 views
How to create a transforming class loader
I am trying to make a class loader which transforms the class bytes of the class being loaded using some kind of class transformer. Suppose I have the following code: static class Test { void foo(); ...
1 vote
1 answer
103 views
Detect modified bytecode at runtime
There are a number of tools(e.g. JavaAssist, ASM) to re-generate bytecodes at runtime for various purposes. One case is Application permformance Management(APM), which provides agents to rewrite ...
0 votes
1 answer
355 views
Use java agent with manipulated java bytecode (ASM)
I am trying to figure out how ASM works, with the help of A Guide to Java Bytecode Manipulation with ASM. I followed the tutorial and created an 'extra' static field for the Integer class. Here is the ...
0 votes
0 answers
409 views
Java ASM bytecode manipulation - add code to constructor of a library class
I have code to insert instructions into the constructor of a class from a third party library (okhttp3.OkHttpClient in this case). Disassembled class shows the added line. However, I am not sure how ...
0 votes
1 answer
694 views
Java ASM ClassReader fails with java.io.IOException: Class not found
I am trying to instrument OkHttpClient builder class. However, I am not able to create ClassReader in the first place. import org.objectweb.asm.ClassReader; ... // this works meaning dependency from ...
0 votes
1 answer
658 views
Java ASM: Bad local variable type (dload) Type top (current frame, locals[5]) is not assignable to double
I am trying to generate Java bytecode using the Java Asm library (I am basically trying to create yet another JVM programming language) Here is the code I am compiling float f = 2f float f2 = new ...
3 votes
1 answer
1k views
Use proxies with Hibernate runtime bytecode enhancement
I'm using Spring Boot 2.7.5 with Hibernate 5.6.12.Final and apply bytecode enhancement at build-time via hibernate-enhance-maven-plugin. It works great and prevents eagerly fetching @OneToOne ...
0 votes
0 answers
2k views
Java Agent "java.lang.UnsupportedOperationException: class redefinition failed: attempted to change method modifiers"
I am trying to change the method access modifier through an agent via javassist, however, I get an error. So, is it possible to change the access modifier via java agent and how to fix it? Is there ...
-1 votes
1 answer
86 views
Encoding a .json file for a bytecode vm
I'm trying to make a Bytecode VM in python just for fun, as a hobby project, but i have a problem, how i can encode a json file like this: { "code": [["0xf2", "Hello"], [...