Questions tagged [bytecode-manipulation]

Low level Virtual Machine bytecode manipulations. Including creating/modifying/optimizing/etc bytecode for various VMs. For example JVM, Python VM, Lua VM, etc.

Why?

Using some VM based programming languages for period of time usually leads to realising that some parts of the code aren't translated into bytecode efficiently, might be optimized for the specific VM even more or we just need some functionality which isn't implemented into standard bytecode compiler/interpreter/etc, like:

  • bytecode encryption
  • bytecode linkage
  • etc.

Links:

More about bytecode:

383 questions
114
votes
5 answers

Is it possible to view bytecode of Class file?

Possible Duplicate: Is there a java classfile / bytecode editor to edit instructions? Java source code is compiled into bytecode, which is actually in the class file. Is it possible to view bytecode of a compiled class? If it is possible, can it…
Abhishek Jain
  • 6,296
  • 7
  • 26
  • 34
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…
36
votes
4 answers

Is there a java classfile / bytecode editor to edit instructions?

Is there a utility (or eclipse plugin) for editing java class files? I'd like to manipulate the bytecode of a java class file without recompiling it nor having a complete buildpath. E.g. to rename methods, add/delete instructions, change constants…
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
28
votes
11 answers

How can you extend Java to introduce passing by reference?

Java is pass-by-value. How could you modify the language to introduce passing by reference (or some equivalent behavior)? Take for example something like public static void main(String[] args) { String variable = "'previous String reference'"; …
19
votes
2 answers

How does the Erlang compiler handle pattern matching? What does it output?

I just asked a question about how the Erlang compiler implements pattern matching, and I got some great responses, one of which is the compiled bytecode (obtained with a parameter passed to the c() directive): {function, match, 1, 2}. {label,1}. …
deepblue
  • 8,426
  • 13
  • 48
  • 60
17
votes
3 answers

Serialization without reflection in compiled classes

Due to the limitation on the client JVM, I can not use any of the popular serializers due to the fact that reflection is not supported. I am looking for a tool that perform byte-code manipulation to achieve serialization by injecting writer and…
17
votes
1 answer

Is there Scala aware high level byte-code manipulation tool like Javassist?

I am looking for a high level bytecode manipulation tool like Javassist, but that understands some of Scala peculiarities. Lower level bytecode manipulation tools should be relatively agnostic, but for my use cases something at the level of…
Daniel Mahler
  • 7,653
  • 5
  • 51
  • 90
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
15
votes
5 answers

Change string constant in a compiled class

I need to change a string constant in a deployed Java program, i.e. the value inside the compiled .class-files. It can be restarted, but not easily recompiled (though it's an inconvenient option if this question yields no answers). Is this…
Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301
13
votes
3 answers

Differences in java bytecode produced by Oracle's and Eclipse's compilers

Our project does some Java bytecode instrumentation. And we stumbled upon some strange behavior. Suppose the following code snippet: public void a() { new Integer(2); } Oracle's javac compiles the above into the following bytecode: 0: …
Nikem
  • 5,716
  • 3
  • 32
  • 59
13
votes
3 answers

Java Bytecode Manipulation Library Suggestions

I'm looking for a well-maintained Java bytecode manipulation library with an intuitive API. There seem to be quite a lot of them out there. Any suggestions on which ones to try?
Daniel
  • 10,115
  • 3
  • 44
  • 62
12
votes
3 answers

Inserting bytes in the middle of binary file

I want to add some string in the middle of image metadata block. Under some specific marker. I have to do it on bytes level since .NET has no support for custom metadata fields. The block is built like 1C 02 XX YY YY ZZ ZZ ZZ ... where XX is the ID…
yosh
  • 3,245
  • 7
  • 55
  • 84
12
votes
1 answer

Bytecode analysis in Java

I am working on a Bytecode analysis project, for which I am using ASM. Everything is going good, I am able to parse, get class and method informations successfully. But I am stuck in understanding bytecode representation for Generics. Here is the…
Pradeep Simha
  • 17,683
  • 18
  • 56
  • 107
11
votes
2 answers

What bytecode library when controlling line numbers?

I need to generate new classes (via generation of java byte code) from existing classes. I will analyse the body (expressions) of the methods of a class. The expressions will determine what code I will generate. For me it is importand to set the…
Arne Deutsch
  • 14,629
  • 5
  • 53
  • 72
11
votes
3 answers

Injecting a Java method _before_ another method is called

I am using ASM and want to rewrite something like: someMethod().targetMethod(args...) to: someMethod().injectedMethod(arg).targetMethod(args...) The trouble is that I don't know what the method before is, I only know the target method (so finding…
David
  • 171
  • 10
1
2 3
25 26