Questions tagged [java-bytecode-asm]

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

ASM is a Java bytecode manipulation and analysis framework. It provides a library to read, write, transform, and analyze compiled Java classes, directly in the binary form of byte arrays. Its API allows easy access to class items such as annotations, fields, and methods. Instructions in methods can be analyzed, removed, or inserted as necessary. Output classes can be saved into files, or loaded dynamically by a ClassLoader.

Website: http://asm.ow2.org/

Document: ASM 4.0 A Java bytecode engineering library

798 questions
56
votes
0 answers

Method invocation instruction (invokevirtual/invokestatic) is substituted by some unexpected instructions

I have been investigating this error for a whole three days, but still no progress. I hope I can get some tips from here. What I am trying to do is to inline a MethodNode into a MethodHandle Call Site (#5, #17, and #30) with ASM library. For…
shijie xu
  • 1,975
  • 21
  • 52
42
votes
3 answers

Dynamic Java Bytecode Manipulation Framework Comparison

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…
30
votes
9 answers

Error : java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(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 + Spring. When I deploy the project, the…
Hitesh Solanki
  • 403
  • 2
  • 5
  • 9
25
votes
3 answers

Understanding javap's output for the Constant Pool

When running javap on a very simple HelloWorld application I have some confusion on the output around the constant pool. Test Code public class TestClass { public static void main(String[] args) { System.out.println("hello world"); …
Andrew White
  • 52,720
  • 19
  • 113
  • 137
24
votes
3 answers

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 successfully changed the value of the now-final…
Ryan Stewart
  • 126,015
  • 21
  • 180
  • 199
22
votes
1 answer

Is it possible to store secrets on the stack in java?

In Java the old way of storing a secret, such as a password, was to use char[] as you could overwrite its data when you were done with it. However this has since been shown to be insecure as the garbage collector will copy things around as it…
Ben Burns
  • 14,978
  • 4
  • 35
  • 56
19
votes
5 answers

Alias Analysis in Java

Can somebody point me to a framework or an implementation of alias analysis for Java. I looked at the asm framework but it only provides data flow analysis and control flow analysis. Update: Just curious but does anyone know if Findbugs does alias…
pdeva
  • 43,605
  • 46
  • 133
  • 171
16
votes
2 answers

For vs. Doseq (and Method Code Too Large)

user=> (def r (range 1)) user=> (for [a r, b r, c r, d r, e r, f r, g r, h r :when (and (= 0 a) (not= 1 b))] (list a b c d e f g h)) ((0 0 0 0 0 0 0 0)) user=> (doseq [a r, b r, c r, d r, e r, f r, g r, h r :when (and (= 0 a) (not= 1 b))] …
galdre
  • 2,319
  • 17
  • 31
15
votes
5 answers

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…
ng.
  • 7,099
  • 1
  • 38
  • 42
15
votes
1 answer

ASM 5: when initializing a ClassWriter, what is the difference between COMPUTE_MAXS and COMPUTE_FRAMES?

I am the maintainer of grappa. This package generates parsers at runtime from Java code by using ASM to generate a class extending your parser class. I have already migrated from ASM 4 to ASM 5, and from generating JVM 1.5 bytecode to generating JVM…
fge
  • 119,121
  • 33
  • 254
  • 329
14
votes
2 answers

Generating a 'Hello, World!' class with the Java ASM library

I have started messing around with the ASM API for a compiler project I am working on. However, I am finding that the documentation is less than clear for a newcomer in many places and I thought having a good solid example of generating a class that…
seadowg
  • 4,215
  • 6
  • 35
  • 43
13
votes
2 answers

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…
StaxMan
  • 113,358
  • 34
  • 211
  • 239
13
votes
2 answers

How can I add code to message before every return?

I'm currently trying to generate code through the wonderfully crafted java-asm library (Version 4). More specifically, I want to append code to the end of a method, just before every return call. I sucessfully am able to add code BEFORE the…
nanoquack
  • 949
  • 2
  • 9
  • 26
13
votes
1 answer

Using Groovy on Android

With the advent of ASMDEX (ASM for dex files) and dexmaker, shouldn't it be possible to port Groovy to Android? Both frameworks allow the generation of dex bytecode at runtime. As I understand it, it is impossible to modify dex classes from the APK…
Dirk Jäckel
  • 2,979
  • 3
  • 29
  • 47
12
votes
3 answers

Java: Getting Bytecode of Class at Runtime from within the Same JVM

Related to: Is there a way to obtain the bytecode for a class at runtime? I'm adding durability to Clojure, and I'm finally at the point where I'm ready to add functions. In Clojure, functions are byte compiled into classes with invoke methods…
jennykwan
  • 2,631
  • 1
  • 22
  • 33
1
2 3
53 54