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

How to change class reference of a class in the constant pool using ASM library?

I am trying to change the class reference of a lambda class in it's constant pool. I've found a way to change it's name, but I need to change the class reference too since it remains the same (e.g. CapturingClass$$Lambda$counter). I want the class…
0
votes
1 answer

Use java agent with manipulated java bytecode (ASM)

I am trying to figure out how ASM works, with the help of A Guide to Java Bytecode Manipulation with ASM. I followed the tutorial and created an 'extra' static field for the Integer class. Here is the simplified logic of the Instrumentation…
Jacob van Lingen
  • 8,989
  • 7
  • 48
  • 78
0
votes
0 answers

Java ASM bytecode manipulation - add code to constructor of a library class

I have code to insert instructions into the constructor of a class from a third party library (okhttp3.OkHttpClient in this case). Disassembled class shows the added line. However, I am not sure how to make rest of the code to use this instrumented…
rysv
  • 2,416
  • 7
  • 30
  • 48
0
votes
1 answer

Java ASM ClassReader fails with java.io.IOException: Class not found

I am trying to instrument OkHttpClient builder class. However, I am not able to create ClassReader in the first place. import org.objectweb.asm.ClassReader; ... // this works meaning dependency from gradle is satisfied okhttp3.OkHttpClient.Builder…
rysv
  • 2,416
  • 7
  • 30
  • 48
0
votes
1 answer

Java ASM: Bad local variable type (dload) Type top (current frame, locals[5]) is not assignable to double

I am trying to generate Java bytecode using the Java Asm library (I am basically trying to create yet another JVM programming language) Here is the code I am compiling float f = 2f float f2 = new Float(2f) Float f3 = f2 println(f2) double d =…
0
votes
0 answers

Java Agent "java.lang.UnsupportedOperationException: class redefinition failed: attempted to change method modifiers"

I am trying to change the method access modifier through an agent via javassist, however, I get an error. So, is it possible to change the access modifier via java agent and how to fix it? Is there any other way to influence the bytecode in…
Question_283
  • 11
  • 1
  • 4
0
votes
1 answer

Exchange testInstrumentationRunner with a runner derived from class not available at compile time

I want to use a custom testInstrumentationRunner for overriding the newInstance method in order to use a custom application: class UiTestJUnitRunner : AllureAndroidJUnitRunner() { override fun newApplication(cl: ClassLoader, className: String,…
0
votes
1 answer

visitMethod in MethodVisitor ASM not visiting method in Scala

I am building a Java agent that should manipulate bytecode using the ASM library. I need to add instructions at the beginning of the specific method. I managed to do that by creating agent following: public class JavaAgent { public static void…
0
votes
1 answer

Where to find pyc bytecode structure information

I'm trying to make a decoder for .pyc files, and need to figure out how the structure is. I have found several suggestions but they all use the marshal module to load the code and then dis to disassemble it. I have found a few simple explanations of…
Ephreal
  • 1,835
  • 2
  • 18
  • 35
0
votes
1 answer

Class Retransformation with Bytebuddy Agent

I am writing a Java agent with ByteBuddy API. Therefore, I want to get in touch with the method delegation of classes that are alredy loaded using the retransformation capabilities of the Bytebuddy DSL. When I start the application with the…
Hector Lorenzo
  • 141
  • 3
  • 11
0
votes
1 answer

Accessing the generated code with bytecode manipulation

I'm currently working on a Java library and I want to add some public static final String fields using bytecode manipulation which just hold some info about an entity. e.g.Customer.TABLE_NAME. I want to be able to access these fields before compile…
aminbhst
  • 75
  • 7
0
votes
1 answer

Incompatible magic value 0 ASM

I have a .class file that is being generated using ASM core API in the following way: public void createEmptyClassWithinPackage(String packageName, String className){ /* Creating ClassWriter object that creates class in bytecode representation …
0
votes
1 answer

"LinkageError: attempted duplicate class definition" when dynamically instrumenting java classes with ASM

I wrote a javaagent by myself to dynamically instrumenting the java classes with ASM (I am not using the COMPUTE_MAXS or COMPUTE_FRAMES of ASM, I do that manually by myself). Actually, I am just trying to use a big try-catch block for…
Instein
  • 2,484
  • 1
  • 9
  • 14
0
votes
0 answers

Can not intercept Android view method call using Byte Buddy and Android Buddy. How can I do that?

I want to intercept android view class method call. For example inside view class there is a method name getHeight(). So when from my code obj.getHeight() will call I want to intercept that and want to return an arbitary value. I can intercept my…
0
votes
0 answers

How to directly modify strings within LuaJIT Bytecode?

I found out from my earlier questions in regards to editing bytecode through reddit and other forums, as well as from what I heard from my peers in discord, that decompiling and recompiling code would only lead to more problems than it solves, and…
ITmaster
  • 29
  • 7