ASM is a Java library used for JVM bytecode manipulation and creation.

learn more… | top users | synonyms (1)

1
vote
0answers
21 views

Getting a FrameNode for an instruction (ASM)

I'm currently trying to use the ASM tree API to insert a frame in the middle of a method as a future jump target. I have tried to use the Analyzer class in order to compute the stack and variable ...
1
vote
0answers
28 views

ASM code not compiling due to “field not visible”

I haven't been able to find anything about this, so I thought I'd ask here: I'm using ASM to change a field in an external library from private to public. The problem, as would be expected, is that ...
19
votes
3answers
2k views

Is “final” final at runtime?

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 ...
0
votes
0answers
32 views

Javaagent. Profiling. klass: 'java/lang/NoClassDefFoundError' when invoke static method from bytecode

I try invoke static method who located in javaagent from application. I inserted method invoke into bytecode: super.visitMethodInsn(Opcodes.INVOKESTATIC, "JProfOps", "aloc", "()V", false); And when ...
26
votes
8answers
87k views

Error : java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)V

I am developing a small Spring application. I have to store the details of the student information in the database. I have developed one SimpleFormController. I have used NetBeans + Hibernate mapping +...
1
vote
1answer
34 views

Understanding local var position in JVM bytecode on finally

I am having trouble understanding variable positioning on ASMified Java bytecode. I have the following Javacode: public class TryCatch { public static void main(String[] args) { String ...
1
vote
1answer
24 views

How does one create an ASM LdcInsnNode that statically adds the current class to the stack?

I'm using the ASM library to modify bytecode created by others. For an arbitrary method in an arbitrary class, I'd like to create an LdcInsnNode that adds the current class to the stack. For example, ...
4
votes
1answer
116 views

Is bytecode manipulation safe

Performing bytecode manipulation using APIs like javaassist modify class files after compilation. But, if the java code is optimized can't the modifications be performed in the wrong place? Are there ...
0
votes
1answer
48 views

Instrument all GETSTATIC and PUTSTATIC bytecode instructions

I need to instrument all getstatic and putstatic bytecode instructions within some classes. I know the basics of Java Agents, what I'm looking for is a framework that allows to add the ...
4
votes
1answer
132 views

Listing all unimplemented methods called from within a method

We have a huge project where many methods have been declared upfront and implementations are in progress. All declared methods have a body which simply throws an exception, say, UnimplException. Now ...
2
votes
3answers
377 views

Replacing a java method invocation from a field with a method call

I am trying to build a mocking framework in java which fits to a specific requirement of a project. The scenario is, I have a method public String returnRandom(){ String randomString = this....
0
votes
1answer
129 views

How to prove that the error is not my Java agent or how to debug it?

One of our clients have contact me complaining that he's getting the following JRE crash while using our Java Agent. According to the error (below) the crash is on the native code since the ...
1
vote
1answer
52 views

ASM Bytecode replacement function not completing

I have a slightly complicated architecture in which I am trying to instrument a class with the JVMTI function RetransformClasses, and event hook ClassLoadFileHook, while using JNI to go up to Java ...
0
votes
1answer
54 views

Replacing full method through ASM

I am trying to write a script that replaces each method body with a basic throw new exception() line. I am in the starting steps of learning ASM so any pointers on where to look would be appreciated. ...
0
votes
1answer
25 views

ASMifier doesn't display enough

I am trying to use ASMifier to understand exactly what is in my .class files. The problem is that the tool omits certain mv.visitXXX. For instance, it doesn't display mv.visitLabel(Label) for line-...
0
votes
2answers
34 views

ASM: find descriptor of a generic type

I am creating a utility based on ASM to generate class on the fly. One of the thing I need is to generate a method signature that has generic type as parameter. E.g. public void setValue(List<...
2
votes
4answers
45 views

Is there a way to tell if a class is an interface?

I'm trying to examine (at a bytecode level, ASM) classes implementing some specific interfaces (in this case, java.sql.Connection) and find that in some cases, the library has another interface ...
1
vote
2answers
61 views

ASM Java bycode muniplation changing a class name

So recently I been trying to simply just change a class name and I just cant . Here is my code InjectorClassNode https://0bin.net/paste/9REMNddwqjm8vRms#hyr4RG3BI36J+kRwMfC2pJoXb7I3+7AwKKzYhhXZQfw ...
0
votes
2answers
32 views

ASM Dynamic Sub Class Creation - NoClassDefFoundError BeanInfo

I am trying to create a sub class dynamically using ASM Framework. I am able to create the class and instantiate it. But when I try to do org.apache.commons.beanutils.BeanUtils.copyProperties(...
1
vote
1answer
49 views

Java 8 lambda expression bytecode consistency

I've been digging through Java lambda expression bytecode as compiled by my OpenJDK compiler, and I'm wondering, can lambda expression bytecode vary by compiler/runtime? I'd like to know that my ...
2
votes
1answer
50 views

Getting verify error when working with asm java

So basicly Im trying to add a simple System.out.println("hey"); at the end of a method. I used the tree API. I do however keep getting this error: java.lang.VerifyError: Expecting a stackmap frame ...
0
votes
0answers
12 views

AdviceAdapter onMethodExit never called

I'm attempting to instrument a cassandra driver and in particular need to modify a ResultSet class to hang on to some information. In order to do this I need to modify the code where the instance is ...
0
votes
1answer
33 views

Java ASM Manipulate IntInsnNodes

I'm kind of new to ASM. I'm trying to disallow int searching in decompilers, so I'm trying to negate a mathematical operation multiple times. Example: int i = 10; --> int i = 2 + 8; I've already ...
1
vote
2answers
66 views

Execute code before @Before method for JUnit test

I need to execute some code before the @Before method of each unit test is executed. The problem is that I also need to know which test (the name is sufficient) will be executed afterwards. I can ...
4
votes
1answer
75 views

Java Bytecode Bad Instruction

I am currently writing a bytecode compiler for my own DSL. However, when executing the bytecode, which I constructed with ASM, I get the following error: Exception in thread "main" java.lang....
0
votes
0answers
25 views

ASM Visitor to remove unreachable code

I'm trying to get a way of detect dead code and remove it from bytecode using ASM. I'm following ASM 4 Guide, and in page 119 is stated a dead code removal visitor as this: public class ...
0
votes
1answer
37 views

ASM ByteCode: prepending visitMethodInsn with another invocation

Suppose I want to call a (logging) method before the invocation of some method of interest. This means that when listening for visitMethodInsn the stack is already populated with the arguments for the ...
1
vote
1answer
30 views

Jasmin JVM setup on Mac OSX

I have downloaded Jasmin JVM for my assembly language course at university. I am currently having some difficulties. How do I write .j files: - I have tried writing the files in textedit and ...
0
votes
1answer
32 views

how to set information on a thread context using ASM?

Each time a new thread is being created / picked out of a threadpool, I want to be able to set some context information about it. I'll appreciate for guidelines about what is the best approach to do ...
0
votes
0answers
26 views

How do Iget information about branches in Java using ASM?

I want to collect some information about branches in ASM such as: Start line End line Branch type (part of "if", a boolean expression in a larger expressions an and/or, while, return, etc). I'll ...
1
vote
2answers
44 views

try to build a decompiler of java bytecode, and don't know in what case the “stack map frame” would not happen to be the “FRAMSAME”

the java code snippet int x4(int a) { if(a>7){ System.out.println("a>7"); } if(a==0){ System.out.println("a==0"); }else if(a>77){ System.out....
1
vote
2answers
42 views

ASM cannot pass 'Type.INT_TYPE' as constant Bootstrap Method Argument

Consider the following code that is meant to generate an invokedynamic instruction using ASM: // BOOTSTRAP = new Handle(-> // CallSite bootstrap(MethodHandles.Lookup caller, String name, ...
3
votes
2answers
62 views

How to load a modified superclass in Java?

I have a class A extends B. I've created a CustomClassLoader extends ClassLoader to use defineClass(className, byte[], offset, length). I've instanciate a new CustomClassLoader(Thread.currentThread()....
0
votes
1answer
48 views

Java bytecode variable index 0's className is something strange

I use ASM library to generate bytecodes and load them using Unsafe.defineAnonymous as a Class. Both work in most of cases, but after for a short time, it fails. Then I add some debug instructions in ...
0
votes
1answer
61 views

How define class after byte code transofrmation with ASM (class file version 0.0)

I cannot load a class after byte code modification with ASM library. Here it is identity transformer and I expect to get modified array with the same size as bytes one, but it 2 times shorter! (439 ...
1
vote
1answer
2k views

get function arguments values using java asm for bytecode instrimentation

I am using asm for inserting a callback function inside each function which is executed. How can I print the arguents values which? I am using MethodAdapter.visitCode to inject my function into each ...
5
votes
2answers
473 views

How to read lambda expression bytecode using ASM

How can I read the bytecode instructions from the body of a lambda expression using ASM?
3
votes
1answer
81 views

Getting VerifyError when adding try/catch block in bytecode through ASM

In my Java agent I’m instrumenting classes using ASM. I'm trying to wrap particular methods with try/catch, plus tracing methodEnter and methodExit. With "-noverify" the code works perfectly. ...
0
votes
1answer
95 views

ASM Bytecode get values passed as arguments on calls of some methods

I'm fighting with ASM since 5 days and I can't get with the solution to my problem. The requirement is to get all values passed as argumentsfrom a method call. I know that there are a lot of tools to ...
8
votes
1answer
4k views

Java method parameters values in ASM

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 ...
0
votes
2answers
43 views

Update existing class definition by source package

I have a jar file which contains 5 classes. I just want to change one logic in that class. BaseClass is the one I need to fix. Please check the following base structure. I just need to remove one ...
0
votes
1answer
50 views

All reflection methods accessing constructor of class generated through ASM throw NoClassDefFoundError if class references primitive type

I am writing an application in which reflected Method objects with specific signatures are unwrapped to regular INVOKEVIRTUAL calls in classes generated through ASM so that those methods can be ...
1
vote
0answers
67 views

ASM: assemble Textifier output into classfile

Does anybody know if any tool/library exists able to assemble output of ASM Textifier into a classfile? So, I have the following code: final ClassReader classReader = new ClassReader(bytes); final ...
-1
votes
1answer
63 views

How to get references in ASM?

Summarization: Using ASM, Given a bytecode class, for each method instruction (MethodInsnNode) I need to get the references that are being used on it. Considering the following class: public void ...
0
votes
1answer
70 views

Modifiying <clinit> with ASM

Hello I have a little problem with ASM. It produces a class with bytecode error: Exception in thread "main" java.lang.VerifyError: Bad instruction Exception Details: Location: me/test/Main.<...
1
vote
2answers
54 views

ASM's Frame class has no generic type

ASM documentation (pdf) says, that Frame class has generic type, providing an example of usage: Frame<BasicValue>. (at p. 119, if needed) When looking at the source, we can see it's declaration ...
0
votes
2answers
373 views

Java asm get “this” object from method variables

I need to know the name of the object which called invokevirtual operation(in the following format - Objectname@object_id). Is it possible given only MethodInsnNode object? I know that it is stored ...
0
votes
1answer
42 views

Splitting InsnList into basic blocks

In the ASM Tree API, I have an InsnList, containing a list of instructions in a method. I want to split this up into basic blocks: a sequence of instructions such that each instruction except the ...
1
vote
1answer
49 views

Retrieving field stored in a class as byte array

I'm experimenting with the ASM library. I have a class stored as a byte[], i.e beginning with CAFEBABE, with a constant pool, etc. I want to load this class and extract a field in a way as ...
1
vote
2answers
365 views

Why does methodvistor.visitMaxs(0,0) crash in Java asm?

I am using Java ASM (4.0) to write a simple compiler. I use the classWriter(COMPUTE_FRAMES) to write a class. It all works well with simple programs, but when I start to nest jumps (e.g. a while ...