bytecode-manipulation

Java Bytecode Manipulation Library Suggestions

妖精的绣舞 提交于 2019-11-30 06:51:56
I'm looking for a well-maintained Java bytecode manipulation library with an intuitive API. There seem to be quite a lot of them out there. Any suggestions on which ones to try? The best answer to your question will be governed by your specific needs and objectives; if you can expand upon what you're trying to accomplish, I can perhaps offer a more tailored response. In lieu of that, however, in my experience, ASM offers probably the best combination of maturity, flexibility, and ease-of-use: It's under relatively active development: even though the latest release is from June 2009, developers

How can you extend Java to introduce passing by reference?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 00:00:39
Java is pass-by-value. How could you modify the language to introduce passing by reference (or some equivalent behavior)? Take for example something like public static void main(String[] args) { String variable = "'previous String reference'"; passByReference(ref variable); System.out.println(variable); // I want this to print 'new String reference' } public static void passByReference(ref String someString) { someString = "'new String reference'"; } which (without the ref ) compiles to the following bytecode public static void main(java.lang.String[]); Code: 0: ldc #2 // String 'previous

Dynamic Java Bytecode Manipulation Framework Comparison

孤街浪徒 提交于 2019-11-29 20:18:46
There are some frameworks out there for dynamic bytecode generation, manipulation and weaving (BCEL, CGLIB, javassist, ASM, MPS). I want to learn about them, but since I don't have much time to know all the details about all of them, I would like to see a sort of comparison chart saying the advantages and disadvantages of one versus the others and an explanation of why. Here in SO, I found a lot of questions asking something similar, and the answers normally said "you can use cglib or ASM", or "javassist is better than cglib", or "BCEL is old and is dying" or "ASM is the best because it gives

Stand-alone Bytecode Verifier

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 02:18:55
In my bytecode instrumentation project, I stumble frequently on VerifyErrors. However, the default java Verifier gives little information on which instruction resulted in the error (it only gives the method and a small message). Is there any stand-alone bytecode verifier which provides with a little more advanced help in locating the error, at least the precise instruction location? Thank you. As with any project involving JVM bytecode, I would first check to see whether the BCEL has anything that might be useful for you. Also, perhaps FindBugs may help - though I'm not sure whether it assumes

Is it possible to inject code in an android application?

好久不见. 提交于 2019-11-29 00:28:23
I would like to inject code in an android application at runtime. I have tried to use dx tool to generate a dexfile in the sdcard but when i want to instantiate, it fails. Are there any tools to inject code generating new dalvik bytecode? I am studing some libraries, aspecjt or guice for android. Is it better to work with a script language? Thanks people :) No, it is not possible. Android application permissions would not work if that was possible. Dexmaker is new and designed just for this. Here's part of the example from the project website: DexMaker dexMaker = new DexMaker(); // Generate a

Java method parameters values in ASM

心不动则不痛 提交于 2019-11-28 23:49:52
I am trying to get the values of a Java program's method's parameters. I am using ASM to instrument the bytecode and getting these values. However, I'm running into some troubles. Here is the visitCode() method used to instrument the code. What it is doing is : Create an empty array to store the collected parameters. For each parameter, load its value into the array. Send this array to my agent's OnMethodEntry method (which where the values will be used). . @Override public void visitCode() { int paramLength = paramTypes.length; // Create array with length equal to number of parameters mv

How can you extend Java to introduce passing by reference?

Deadly 提交于 2019-11-28 21:03:14
问题 Java is pass-by-value. How could you modify the language to introduce passing by reference (or some equivalent behavior)? Take for example something like public static void main(String[] args) { String variable = "'previous String reference'"; passByReference(ref variable); System.out.println(variable); // I want this to print 'new String reference' } public static void passByReference(ref String someString) { someString = "'new String reference'"; } which (without the ref ) compiles to the

Dynamic Java Bytecode Manipulation Framework Comparison

半城伤御伤魂 提交于 2019-11-28 16:20:09
问题 There are some frameworks out there for dynamic bytecode generation, manipulation and weaving (BCEL, CGLIB, javassist, ASM, MPS). I want to learn about them, but since I don't have much time to know all the details about all of them, I would like to see a sort of comparison chart saying the advantages and disadvantages of one versus the others and an explanation of why. Here in SO, I found a lot of questions asking something similar, and the answers normally said "you can use cglib or ASM",

Java method parameters values in ASM

空扰寡人 提交于 2019-11-27 15:03:48
问题 I am trying to get the values of a Java program's method's parameters. I am using ASM to instrument the bytecode and getting these values. However, I'm running into some troubles. Here is the visitCode() method used to instrument the code. What it is doing is : Create an empty array to store the collected parameters. For each parameter, load its value into the array. Send this array to my agent's OnMethodEntry method (which where the values will be used). . @Override public void visitCode() {

Is there a java classfile / bytecode editor to edit instructions? [closed]

吃可爱长大的小学妹 提交于 2019-11-27 11:28:51
Is there a utility (or eclipse plugin) for editing java class files ? I'd like to manipulate the bytecode of a java class file without recompiling it nor having a complete buildpath. E.g. to rename methods, add/delete instructions, change constants etc. The only utilities I found are: classeditor but it's very limited in functionality ( e.g. renaming of things and manipulating instructions isn't possible ). jbe doesn't save changes (maybe because class verifying fails - before I made any changes, although the class runs perfectly) (jbe initially had a classpath issue, adding the class path to