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
0
votes
1 answer

Creating a new field with asm 4

This is the code im using String fieldName = "lock"; String fieldType = "Ljava/util/concurrent/locks/Lock;"; Object initValue = new ReentrantLock(); cw.visitField(ACC_PUBLIC, fieldName, fieldType, null, initValue).visitEnd(); Im…
clienthax
  • 1,211
  • 2
  • 8
  • 12
0
votes
1 answer

Request for more information on ASM OPCodes

I am learning ASM framework for Byte Code instrumentation and wrote couple of examples to achieve the same.I saw that in most of the examples JVM OPCodes are used for ex:DUP,AASTORE,LSTORE etc but looking at the javadocs of ASM Opcodes i don't see…
VishwanathB
  • 139
  • 2
  • 10
0
votes
1 answer

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

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…
0
votes
1 answer

What kind of values might the debug parameter of visitSource in ASM ClassVisitor receive?

The visitCode method in asm's ClassVisitor accepts a debug parameter typed as a String public final void visitSource(final String file, final String debug) According to the JavaDoc debug - additional debug information to compute the…
henry
  • 5,923
  • 29
  • 46
0
votes
1 answer

Suitable input type for java bytecode generator in asm lib

Creating a java compiler. Using jflex - lexical analysis, cup - parsing and asm- bytecode generation. jlex output is a scanner object. We create a parser object to do the parsing. What should we pass to the bytecode generation. Is there any bytecode…
0
votes
1 answer

Can I pass className and methodName at runtime to ClassVisitor() and methodVisitor() in ASM parser after started the server?

I have started learning (I am new to this) , ASM API for a compiler project . I am using java Instrumentation and ASM ByteCode Library for developing a Javaagent. I am passing classname and method name through properties.My goal is to change my…
0
votes
0 answers

How to use the ASM AdviceAdapter with the Tree API?

I was wondering whether it is possible to use an AdviceAdapter with the ASM Tree API. I tried the following, however the heap space runs out of memory. @Override public void modify(ClassReader cr, ClassWriter cw) throws Exception { ClassNode cn…
nrainer
  • 2,542
  • 2
  • 23
  • 35
0
votes
1 answer

Save byte array as .class

I am using ASM to transform a java class. Instead of loading the byte array into memory, I would like to save the resulting byte array to a .class file. The ASM manual says this is possible, but does not give an example. How can I do this?
zaz
  • 445
  • 1
  • 6
  • 12
0
votes
1 answer

ASM 4.1 visitLdcInsn Illegal type in constant pool

I am using ASM 4.1. I understand that the method visitLdcInsn requires version 49 or higher, however I am wondering how I could get visitLdcInsn to work with version 49 and lower. I know a solution is for people to compile with a higher version, but…
Steve
  • 1,145
  • 1
  • 11
  • 25
0
votes
1 answer

ASM 4.0, renaming Methods in ClassNode

Alright, so. I'm trying to rename methods in a ClassNode in ASM 4.0. This is my renaming class: public class RenameVisitor extends ClassVisitor { private String newName,oldName; public RenameVisitor(String newName,String oldName){ …
Chris Shafer
  • 68
  • 1
  • 6
0
votes
3 answers

What if a native class/method only defined in a newer Java version?

As far as i know, during the compile time of Java, only the class/method signatures are recorded. The actual implementations are binded until the running time, in the JVM. Let's imagine there is a native Java class called MyClass. And in Java…
midnite
  • 5,157
  • 7
  • 38
  • 52
0
votes
2 answers

Java asm compiler

I'm building a complier in Java using asm library. So far I can print to the output only integers. I want to do the same thing with strings. Any ideas?
Tony
  • 489
  • 2
  • 5
  • 22
0
votes
1 answer

How does one compute the equality of two integers on the JVM *without* branching?

On the JVM, is there a way to compute whether two integers are the same without using a branching instruction? Is there a way to cleverly use the ixor instruction to do so? If there is a way, is it even worth using instead of the branching version?
Tespa42
  • 567
  • 4
  • 12
0
votes
1 answer

Detect if the method in an invoke instruction is native, or not, in ASM/java bytecode

Is there a way to know if the method in an invoke instruction in bytecode is a native method or not? I am looking for an ASM specific solution. The visitMethodInsn(int opcode, String owner, String name, …
vijay
  • 2,646
  • 2
  • 23
  • 37
0
votes
1 answer

Java byte code instrumentation with an external library

I am using ASM with java agents. I have the following problem. Whenever I see a "PUTFIELD" instruction within a method call, I want call a method from my agent library. if (opcode == PUTFIELD) { …
janiss
  • 1
  • 2