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

Can't tell if bytecode instrumentation is working in Hibernate

I am using the example below: https://vladmihalcea.com/hibernate-4-bytecode-enhancement/ for the bytecode ehancement. I am building the content fine but the compiled code is unchanged. i used a decompiler to view the file and it is the same. How do…
user4347600
0
votes
1 answer

Transform classes / methods by annotations

Is there a way to transform/modify classes and methods that are annotated by a custom annotation? #bytecode-manipulation (but for dex) What's the best way to do it? Proxies are not the appropriate way for what I am looking for.
Ben
  • 191
  • 3
  • 13
0
votes
1 answer

Replace type occurrences in bytecode with ByteBuddy

Is it possible with ByteBuddy to replace occurences of some type in bytecode? E. g. if I have a class class MyClass { Foo makeFoo() { return new Foo(); } } I want to transform bytecode of this class so that it is equivalent to class…
leventov
  • 14,760
  • 11
  • 69
  • 98
0
votes
1 answer

Error using ASMifierClassVisitor

I wanted to use ASMifierClassVisitor tool to get the asm code of creating a class but when I use it I get the error java.lang.NoSuchMethodError: org.objectweb.asm.ClassReader.accept(Lorg/objectweb/asm/ClassVisitor;[Lorg/objectweb/asm/Attribute;Z)V …
Jayanga
  • 889
  • 6
  • 15
0
votes
2 answers

Obj C Equivalent to Double.doubleToLongBits

I am porting some Java code to Objective C and know enough bitwise to get a headache. Can someone point me to the objC equivalents to Double.doubleToLongBits and Float.floatToIntBits?
Jim Geldermann
  • 183
  • 3
  • 18
0
votes
1 answer

How to count local variable indexes in MethodVariableAccess?

According to [1], in a method frame, the local variable array contains a reference to the called instance, the parameters and, finally, any other variables used in the method's code. Also, long and double values occupies two local variables. When…
Carlos Melo
  • 3,052
  • 3
  • 37
  • 45
0
votes
1 answer

Java bytecode variable index 0's className is something strange

I use ASM library to generate bytecodes and load them using Unsafe.defineAnonymous as a Class. Both work in most of cases, but after for a short time, it fails. Then I add some debug instructions in the emitted bytecodes to print something, and the…
shijie xu
  • 1,975
  • 21
  • 52
0
votes
1 answer

How to get references in ASM?

Summarization: Using ASM, Given a bytecode class, for each method instruction (MethodInsnNode) I need to get the references that are being used on it. Considering the following class: public void myMethod(){ String str1 = "str12"; String str2 =…
0
votes
0 answers

Instrument Python bytecode in multi-file system

I am looking to automatically instrument all bytecode that is executed from my initial Python script. For instance, I'll have a directory setup like this: + main.py + file1.py +----dir1/dir1_file2.py +----dir1/dir1_file3.py I've been looking over…
erik
  • 3,810
  • 6
  • 32
  • 63
0
votes
1 answer

how to instantiate a different class by Instrumenting / ASM

I am trying to use ASM in a javaagent to change the class that is being constructed (sun/misc/URLClassPath) to another one (fommil/URLClassPath) that inherits from it and overrides all the methods. I know that the target class…
fommil
  • 5,757
  • 8
  • 41
  • 81
0
votes
1 answer

Possible optimize the bytecode sequence

I generate a sequence of bytecode after inline multiple method invocation. At the beginning of inline, I first poped existing variable indexes to a new local variable numbers in case of any exception in the inlined method. This operation results to…
0
votes
2 answers

Using ASM for bytecode analysis

I am evaluating the possibility of using ASM as framework for implementing some bytecode analysis. So far I have been playing with a few examples but there are a couple of things that I need to sort out: 1) I don't see how I can detect a method…
0
votes
0 answers

ASM Analyze MethodNode failure

I am wondering whether I can create an MethodNode directly and then analyze it. Therefore, I write below code to test: ClassNode classNode = new ClassNode(Opcodes.ASM5); classNode.visit(V1_8, ACC_PUBLIC + ACC_SUPER, className, null,…
shijie xu
  • 1,975
  • 21
  • 52
0
votes
3 answers

How to get the return value in asm?

I want to extract the return value that type is org.apache.commons.dbcp.BasicDataSource How can I achieve this in asm? I have to get the instance of the class, org.apache.commons.dbcp.BasicDataSource right after it is created in createDataSource().…
verystrongjoe
  • 3,831
  • 9
  • 35
  • 66
0
votes
1 answer

Modifying python pytecode

Firstly, I would like to say that I know that you shouldn't be doing this in a production environment. Don't worry, it's just to see to what extent I can change python code whilst it's running. I have a function inject_code that takes in a code…
muddyfish
  • 3,530
  • 30
  • 37