java-bytecode-asm

ASM bytecode instrumentation for method entry / exit

I've created a JVMTI agent that does the following at a high level: onClassLoadHook send the bytecodes for the loaded class to a separate Java process that will instrument the class using ASM get the bytecodes back and load them In my seperate java process that instruments the loaded Java class I do the following : .. .. cr = n...

Bytecode instrumentation generating java verifier error

Hi, I am using ASM in order to do bytecode instrumentation for Java programs. What I'm doing is simple - When instrumenting a method, if the instruction is a PUTFIELD, simply do a DUP_X1 right before the instruction, then visit the PUTFIELD and inject a function call with an argument that includes the DUP'ed stack entry. ...

unboxing using the ASM Java library

I'm using the ASM Java library to replace some reflection. I generate the body of this method: void set(Object object, int fieldIndex, Object value); With this generated method, I can set fields on an object at runtime without using reflection. It works great. However, I found it fails for primitive fields. Here is the relevant part o...

ASM jar - Why my java project has a dependency on this?

I have a Java project and internally it is dependent on asm jar. Strangely, I don't even know why my project somehow is dependent on this library (might be brought in by maven as a transitive dependency)? Can anyone help me know why some one needs asm jar? Thanks in advance ! EDIT: Can you also mention for what purposes/use-cases one ...

Java, ASM org.objectweb.asm.util.CheckClassAdapter causes Unsupported major.minor version 0.0

Hello! I am getting following exception: java.lang.UnsupportedClassVersionError: net/sourceforge/barbecue/BarcodeException : **Unsupported major.minor version 0.0** at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.lang.ClassLoader.defineClass(ClassLoader...

How to inspect the stack using an ASM visitor?

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 i...

ASM (from ObjectWeb) not calculating MaxStack correctly even though ClassWriter( COMPUTE_MAX + COMPUTE_STACK ) is set

I am getting expected ClassVerifyErrors when attempting to load a class i have generated using ASM. On further inspection i can see that the jvm is correct and that the method is talking about has an invalid MAX_STACK value. THe strange thing is am using the auto calculate the stack and max local options so this should not be a problem.....

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

Hiii.... I am developing small spring application. I have to store the details of the student information in the database. I have develop one simpleformcontroller.I have used netbeans + hibernate mapping + spring. when I deploy the project,the following errors is occured. please help me.. Thanks in advance..... My spring-c...

Change root package of Java JAR

I am writing a Java Agent which makes use of the Java ASM library for handling byte code. This is a common library and I want to be sure about the version of ASM which my code is using at runtime. What is the easiest and most automated way to take the ASM classes and process them into a private copy where all the classes have been reloc...

Can ASM method-visitors be used with interfaces?

I need to write a tool that lists the classes that call methods of specified interfaces. It will be used as part of the build process of a large java application consisting of many modules. The goal is to automatically document the dependencies between certain java modules. I found several tools for dependency analysis, but they don't w...

Improving field get and set performance with ASM or Javassist

I would like to avoid reflection in an open source project I am developing. Here I have classes like the following. public class PurchaseOrder { @Property private Customer customer; @Property private String name; } I scan for the @Property annotation to determine what I can set and get from the PurchaseOrder reflectively...

Generating methods with generic types with Asm bytecode generator (ClassWriter)

Defining simple getters and setters is easy using Asm (and fortunately it is even explained in their FAQ). But one thing that is not mentioned, and for which I have been unable to find documentation, is how to implement these using generic type information. I am actually able to determine generic type information itself quite easily (si...

How to check that bytecode operation PUTFIELD is reassigning a field belonging to 'this' object using ObjectWeb ASM?

I am using the ASM bytecode manipulation framework to perform static analysis on Java code. I wish to detect when fields of an object are reassigned, i.e. when this kind of code occurs: class MyObject { private int value; void setValue(int newValue) { this.value = newValue; } } Using the following code (in a class implementing...

Get java.lang.IllegalAccessError when accessing the private field of a outside class via ASM Java Bytecode

Hi, in reflection, the private field can be access via getDeclaredField() and setAccessible(true). How to access the private field of a outside class via Objectweb ASM bytecode API? I set to get the private field from something like, via Field current = sourceObject.getDeclaredField(privateFieldName); Field.setAccessible(true); Type so...

Instrumentation

Hello All, I am new to ASM(byte code manipulation kit) and am using it to instrument java byte code. I want to access the methods of a class and change their access modifiers using ASM. Does someone have an idea about how to achieve this? I know that calling visitMethod would help but do not know how to do that exactly Any information o...