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

Is it possible to enforce bytecode typechecks in the JVM compilers?

So I just debugged a segfault (C2 compiler crashing for certain methods). The error message was # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x00007f478a832e6c, pid=7673, tid=139944974104320 # # JRE…
User1291
  • 7,664
  • 8
  • 51
  • 108
0
votes
0 answers

adding throw of a new RuntimeException

So I'm trying to insert a RuntimeException in soot and I've written a method to help me do just that: private static final RefType STRING_TYPE = RefType.v("java.lang.String"); private static final RefType ERROR_TYPE =…
User1291
  • 7,664
  • 8
  • 51
  • 108
0
votes
2 answers

cglib - creating class proxy in OSGi results in NoClassDefFoundError

OK so this is some kind of theoretical question for you guys. I am experimenting with cglib's Enchancer - creating a proxy for a class. My code is running in a Felix OSGi container. The hierarchy looks kind of similar to that: // Bundle A; //…
mdzh
  • 1,030
  • 2
  • 17
  • 34
0
votes
1 answer

ASM parameter numbering

Let's say I have a dummy class public class B { public Object run(long v, String f){ if(v == 2) { if(f.equals("x")) { return new Object(); } } return null; } } asmifier will…
User1291
  • 7,664
  • 8
  • 51
  • 108
0
votes
1 answer

Can I instrument outgoing method/constructor calls with ByteBuddy?

I have a project where I was using Javassist to log outgoing method/constructor calls with code like this: CtMethod cm = ... ; cm.instrument( new ExprEditor() { public void edit(MethodCall m) throws CannotCompileException …
0
votes
1 answer

Illegal constant pool index error in grails

I have a grails application that i have deployed on my linode box. It was running fine for a few days but now gives this error on all pages: Caused by: java.lang.VerifyError: (class: org/codehaus/groovy/runtime/InvokerInvocationException, method:…
mkoryak
  • 57,086
  • 61
  • 201
  • 257
0
votes
2 answers

How to access runtime information in @Advice.OnMethodEnter/Exit ?

I am using Bytebuddy to instrument methods. Is there any way of getting hold of runtime information as e.g. the thread id of the instrumented method/constructor ? I couldn't find a way to gain access to this information using @Advice.*
Ben
  • 191
  • 3
  • 13
0
votes
1 answer

classPool.get(className) throws RuntimeException cannot find class

I am trying to write a simple instrumentation agent using Javassist. public class Agent implements ClassFileTransformer { protected Instrumentation instrumentation; protected ClassPool classPool; public Agent(Instrumentation…
isapir
  • 21,295
  • 13
  • 115
  • 116
0
votes
1 answer

Create Framework for raw data or Binary read and write

I am working on one project in which data has to read in binary format but one can put into a structure format. In java Structure is not available. I have send the data in byte array. It also has some structure. For Example Packet int length int…
Kamahire
  • 2,149
  • 3
  • 21
  • 50
0
votes
1 answer

Javassist seems to generate invalid field access code

I am trying to augment some code with additional functionality during startup of my application. The whole setup itself is working fine, but there is one point where I think javassist might generate bad code. I am doing this on a specific method on…
Florian Loch
  • 809
  • 7
  • 12
0
votes
1 answer

Undefined Method for the type AgentBuilder.Default ByteBuddy

The method rebase(( type) -> {}) is undefined for the type AgentBuilder.Default public static void premain(String arg, Instrumentation inst){ new AgentBuilder.Default() .rebase(type ->…
codejava
  • 13
  • 6
0
votes
2 answers

Call superclass method from interceptor bytebuddy

We have an obfuscated class that we need to enhance with bytebuddy. We basically need to redefine one method. Subclassing seemed to not have worked (the code is not executed). Rebasing works but in our intercepted method we need to call the…
kosta5
  • 1,129
  • 3
  • 14
  • 36
0
votes
0 answers

Fetch deserialized variable added at runtime using javassist

I want to fetch the variable(extra field) added to a serialized class at runtime. For example Class A { String name; } int travId=123; "travId" is a extra field added to Class A using javassist,before the object of class A is serialized. While…
s s
  • 286
  • 2
  • 14
0
votes
2 answers

Prtining method arguments using byte buddy API

I am working on a project where I need access method arguments during execution. Is it possible to print method arguments using byte buddy framework? any sample code on this using javaagent is highly appreciated.
ravi k
  • 31
  • 4
0
votes
1 answer

Dynamically generate a single function (without subfunctions), representing a binary expression tree, at run time with Byte Buddy

Introduction I want to compare some libraries for generating code at run time. At the moment I touched the surface of Javassist and Byte Buddy. As a proof of concept I am trying to solve a small problem, which is a starting point for a more complex…