java-bytecode-asm

How to inspect the stack using an ASM visitor?

元气小坏坏 提交于 2019-12-07 21:22:01
问题 I am attempting to use the Java byte code engineering library ASM to perform static analysis. I have the situation where I would like to inspect the variables being assigned to a field. I have MethodVisitor which implements the visitFieldInsn() method. I am specifically looking for the putfield command. That is no problem. The problem is that when I encounter putfield , I want to be able to access the variable that's going to be assigned to the field. Specifically I want to access information

Inserting to InsnList before several nodes

无人久伴 提交于 2019-12-07 19:23:25
I am trying to: 1) Iterate instructions and find all relevant nodes 2) Insert custom code before found nodes I used streams and iterator to make it and insert, which works only for the first node InsnList instructions = methodNode.instructions; InsnList addition = ... //It work: found n nodes for n return instructions Stream<AbstractInsnNode> returnNodes = Stream.iterate(instructions.getFirst(), AbstractInsnNode::getNext).limit(instructions.size()) .filter(n -> returnOpcodes.contains(n.getOpcode())); //It not work: inserted only before first node returnNodes.forEach(n -> instructions

What is vmovdqu doing here?

﹥>﹥吖頭↗ 提交于 2019-12-07 14:32:53
问题 I have a Java loop that looks like this: public void testMethod() { int[] nums = new int[10]; for (int i = 0; i < nums.length; i++) { nums[i] = 0x42; } } The assembly I get is this: 0x00000001296ac845: cmp %r10d,%ebp 0x00000001296ac848: jae 0x00000001296ac8b4 0x00000001296ac84a: movl $0x42,0x10(%rbx,%rbp,4) 0x00000001296ac852: inc %ebp 0x00000001296ac854: cmp %r11d,%ebp 0x00000001296ac857: jl 0x00000001296ac845 0x00000001296ac859: mov %r10d,%r8d 0x00000001296ac85c: add $0xfffffffd,%r8d

Invalid Entry Compressed Size

亡梦爱人 提交于 2019-12-07 03:10:08
问题 I'm using a bytecode library known as ASM to alter classfiles, then I want to write each classfile back into a jar file rather than a folder filled with class files. I do this by running this code: My problem occurs when a ZipException is throw for not being the expected size, i.e. java.util.zip.ZipException: invalid entry compressed size (expected 695 but got 693 bytes) at java.util.zip.ZipOutputStream.closeEntry(Unknown Source) at org.steinburg.client.accessor.Accessor.accessJar(Accessor

How to inspect the stack using an ASM visitor?

做~自己de王妃 提交于 2019-12-06 08:27:48
I am attempting to use the Java byte code engineering library ASM to perform static analysis. I have the situation where I would like to inspect the variables being assigned to a field. I have MethodVisitor which implements the visitFieldInsn() method. I am specifically looking for the putfield command. That is no problem. The problem is that when I encounter putfield , I want to be able to access the variable that's going to be assigned to the field. Specifically I want to access information about the type of the variable. At the moment I really only need to look at what's at the top of the

Best choice? Edit bytecode (asm) or edit java file before compiling

ⅰ亾dé卋堺 提交于 2019-12-06 07:40:14
Goal Detecting where comparisons between and copies of variables are made Inject code near the line where the operation has happened The purpose of the code: everytime the class is ran make a counter increase General purpose: count the amount of comparisons and copies made after execution with certain parameters 2 options Note: I always have a .java file to begin with 1) Edit java file Find comparisons with regex and inject pieces of code near the line And then compile the class (My application uses JavaCompiler) 2)Use ASM Bytecode engineering Also detecting where the events i want to track

ASM Try/Catch Block with an output value

北城余情 提交于 2019-12-06 06:13:41
I am currently trying make my custom compiler allow using try/catch as an expression, i.e. leaving a value on the stack. The type checker and the backend already support this, but the problem seems to be ASM's COMPUTE_FRAMES . With the below code for instrumentation: private void write(MethodWriter writer, boolean expression) { org.objectweb.asm.Label tryStart = new org.objectweb.asm.Label(); org.objectweb.asm.Label tryEnd = new org.objectweb.asm.Label(); org.objectweb.asm.Label endLabel = new org.objectweb.asm.Label(); boolean hasFinally = this.finallyBlock != null; writer.writeLabel(tryStart

Trying to install eclipse Bytecode Outline plugin, missing dependency

橙三吉。 提交于 2019-12-05 21:33:56
I'm trying to install this: http://asm.ow2.org/eclipse/index.html , but I get this error which makes zero sense to me. I'm running eclipse Kepler Service Release 1, build id 20130919-0819. Cannot complete the install because one or more required items could not be found. Software being installed: Bytecode Outline 2.1.0 (de.loskutov.BytecodeOutline.feature.feature.group 2.1.0) Missing requirement: Bytecode Outline 2.1.0 (de.loskutov.BytecodeOutline.feature.feature.group 2.1.0) requires 'org.eclipse.help.appserver 0.0.0' but it could not be found After Eclipse 3.3 "org.eclipse.help.appserver"

What is vmovdqu doing here?

与世无争的帅哥 提交于 2019-12-05 20:34:25
I have a Java loop that looks like this: public void testMethod() { int[] nums = new int[10]; for (int i = 0; i < nums.length; i++) { nums[i] = 0x42; } } The assembly I get is this: 0x00000001296ac845: cmp %r10d,%ebp 0x00000001296ac848: jae 0x00000001296ac8b4 0x00000001296ac84a: movl $0x42,0x10(%rbx,%rbp,4) 0x00000001296ac852: inc %ebp 0x00000001296ac854: cmp %r11d,%ebp 0x00000001296ac857: jl 0x00000001296ac845 0x00000001296ac859: mov %r10d,%r8d 0x00000001296ac85c: add $0xfffffffd,%r8d 0x00000001296ac860: mov $0x80000000,%r9d 0x00000001296ac866: cmp %r8d,%r10d 0x00000001296ac869: cmovl %r9d,

Is “final” final at runtime?

给你一囗甜甜゛ 提交于 2019-12-05 09:14:16
问题 I've been toying with ASM, and I believe I succeeded in adding the final modifier to an instance field of a class; however I then proceeded to instantiate said class and invoke a setter on it, which successfully changed the value of the now-final field. Am I doing something wrong with my bytecode changes, or is final enforced only by the Java compiler? Update: (31 Jul) Here's some code for you. The main parts are a simple POJO with a private int x and private final int y , the