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

jsr : Error exists in the bytecode when using javassist to insertAfter

I tried to use javassist add code after method with "insertAfter()". But error reported when running the code: try { CtClass ctClass = ClassPool.getDefault().get(className.replace('/', '.')); CtMethod ctMethod =…
Hao Ma
  • 1
  • 3
0
votes
1 answer

ClassFormatError: Field "_callee__a1" in class has illegal signature "_callee"

Some exception occurs when I try to inline two classes: public class CI_Caller1 { private int _data; private CI_Callee_2 _callee; public CI_Caller1(int data, CI_Callee_2 callee){ _data = data; _callee = callee; …
shijie xu
  • 1,975
  • 21
  • 52
0
votes
1 answer

javassist : cannot parse method body with parameterized Maps/Lists

I am trying to dynamically generate classes in my application and came across with this limitation/bug? with javassist. Seems javassist cannot parse the source-body if it has Maps/List with parameterized types. eg : public static void main(…
0
votes
1 answer

How to rewrite visitMethod to merge two classes into one class using ASM

I am trying to merge class Callee to the class Caller at runtime by ASM APIs. Parts of my code below is copied from 3.1.5(Merging Two Classes into One) in http://asm.ow2.org/current/asm-transformations.pdf . I modified the sample code because i use…
shijie xu
  • 1,975
  • 21
  • 52
0
votes
2 answers

Adding annotations at build time to a Java getter, getX(), when the field x is annotated

I want to create the following Java annotation, and process it at build time: @Target(value = FIELD) interface @AnnotateGetter { Annotation[] value(); } If a field field is annotated with @AnnotateGetter, then all of the Annotations in the…
XDR
  • 4,070
  • 3
  • 30
  • 54
0
votes
2 answers

Using ASM to get the reference returned via ARETURN bytecode instruction

I have a method which returns a value that is generated in another method similar to this: public static FileChannel open() { return provider.newObject(); } So the bytecode of the method roughly looks like this: INVOKEVIRTUAL…
centic
  • 15,565
  • 9
  • 68
  • 125
0
votes
0 answers

Error generating java method using javaassist

I am having some trouble with javaassist. I'm attempting to generate a class on the fly and I'm getting an error that says: no such class: Foo during the compilation step in the generateFooMethod step below. Can anyone help me? try { …
Amir Afghani
  • 37,814
  • 16
  • 84
  • 124
0
votes
1 answer

Calling method of object after every putfield operations using bytecode manipulation library ASM

I am reverse engineering a Java client application of which I'd like to track modifications of certain fields to see what's changed after which action to resolve the obfuscated names. I could probably use a debugger of some kind, but I decided to…
0
votes
2 answers

Intercepting field access using Javassist or ASM

I'm familiar with various ways of intercepting method invocations using proxies, but I'm wondering if there's a way to detect field access / dereferences on some proxy using a library like Javassist or ASM? For example: void…
Josh Stone
  • 4,328
  • 7
  • 29
  • 37
0
votes
3 answers

How to delete break statements only from switch using ASM?

I am using ASM framework to manipulate some java bytecode. I need to delete break statements only from switch instructions. My attempts deleted goto instructions from bytecode, but not only these ones connected with switch (for example all from…
marcin
  • 55
  • 8
0
votes
0 answers

must jdk, cglib and javassist proxies be final?

As far as i know classes generated by cglib are final. why? it doesn't seem to be some fundamental limitation of jvm. is it just an arbitrary decision of cglib creators? is it the case also with jdk and javassist proxies?
piotrek
  • 13,982
  • 13
  • 79
  • 165
0
votes
3 answers

Why is the Java 7 Bytecode Verifier complaining about this Stack Frame?

I have a method which I have altered in a Java 7 (major version 51) class. Using javap, I've looked at the bytecode and the Stack Frame Map. Everything looks fine: public int addOne(int); flags: ACC_PUBLIC Code: stack=2, locals=2, args_size=2 …
Charles Forsythe
  • 1,831
  • 11
  • 12
0
votes
0 answers

WCF - Give Class DataContract during Compile or Runtime

If I have the code: public class Person { public string FirstName { get; set; } public string LastName { get; set; } } How do I convert it to the code below at runtime or compile time? [DataContract] public class Person { [DataMember] …
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
0
votes
2 answers

java.lang.VerifyError with usage of visitJumpInsn

I tried to use asm for BCI and i have a requirement where i am supposed to inject "if condition" ,so i tried using something like below Below is the code snippet..if i comment the jump instruction things work fine..with jump instruction i see…
0
votes
1 answer

Loading an existing java object onto stack using ASM

I am trying to use ASM for my project and hit a performance issue where I am trying to get required object using a static method and its called like 1000 times visitor.visitMethodInsn(Opcodes.INVOKESTATIC, TrackingConstants.TO_HELPER_CLASS,…