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

ASM 4 (Java Library) tutorials?

I have recently been working with the Java library 'ASM', which is for modification of bytecode at runtime, in case people didn't know, and I have not been able to find a single tutorial on ASM 4. Except the official manual for ASM 4, which…
OllieStanley
  • 712
  • 7
  • 25
10
votes
2 answers

Java method parameters values in ASM

I am trying to get the values of a Java program's method's parameters. I am using ASM to instrument the bytecode and getting these values. However, I'm running into some troubles. Here is the visitCode() method used to instrument the code. What it…
Adel
  • 441
  • 1
  • 5
  • 14
10
votes
1 answer

What are GeneratedMethodAccessor1,2,etc and why might they not be found?

I'm getting stack traces like this: java.lang.NoClassDefFoundError: sun/reflect/GeneratedMethodAccessor1 at sun.reflect.GeneratedMethodAccessor1.(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native…
Adam Lewis
  • 933
  • 7
  • 9
9
votes
2 answers

Is it possible to do bytecode manipulation when using OSGi?

I'm making an application server and in it I need to use some bytecode manipulation (e.g. inserting custom equals and hashCode methods to classes annotated with @Entity). Now I give the JVM a Java Agent (the -javaagent option) which does bytecode…
Esko Luontola
  • 73,184
  • 17
  • 117
  • 128
9
votes
1 answer

How can Spring match query parameter only by formal parameter name?

Suppose I have the following code snippet: @RequestMapping(method = RequestMethod.GET) public List
getArticles(@RequestParam int offset, @RequestParam int limit) { ... } How can Spring match the HTTP…
9
votes
1 answer

Javap output: difference static {} and public {}

I have two example class files, one from an example Java app and one from an example C app (compiled to bytecode using LLJVM). Looking at their outputs, I can see through javap -c -p that for initializing the (static) fields, the Java app shows the…
Sven
  • 173
  • 8
9
votes
1 answer

How to create a dynamic proxy using ByteBuddy

In Java it is possible to create dynamic proxies using an implementation of InvocationHandler. Despite JVM optimizations, using reflection will always have some overhead invoking a method. To try to solve this problem, I tried to use ByteBuddy to…
Carlos Melo
  • 3,052
  • 3
  • 37
  • 45
9
votes
2 answers

Overriding the default type() metaclass before Python runs

Here be dragons. You've been warned. I'm thinking about creating a new library that will attempt to help write a better test suite. In order to do that one of the features is a feature that verifies that any object that is being used which isn't…
the_drow
  • 18,571
  • 25
  • 126
  • 193
8
votes
3 answers

Reference vs. Precise Reference in Dalvik Verifier

I am writing instrumentation on Dalvik bytecode which performs some logging for various method call entries. Specifically, at various method call sites, I will insert a set of instructions which collects up the parameters, puts them in an Object[]…
Kristopher Micinski
  • 7,572
  • 3
  • 29
  • 34
8
votes
1 answer

How to copy resource files in classes folder with gradle?

Enviroment I am using a third party lib which requires bytecode instrumentation. The tool which does the bytecode instrumentation requires some description files and those files have to be in the same folder structure like the compiled .class files.…
Jan
  • 1,004
  • 6
  • 23
8
votes
1 answer

Remapper variables during bytecode method inlining by ASM

I am doing an online bytecode method inlining optimization using ASM. My changes are based on the example 3.2.6 Inline Method (http://asm.ow2.org/current/asm-transformations.pdf). The test example (inline callee's calculate(int,int) at Caller::test)…
shijie xu
  • 1,975
  • 21
  • 52
8
votes
2 answers

Java BuilderTestPattern - how to avoid boilerplate?

I have a lot of value objects in my project. I'm using project lombok to eliminate some boilerplate, so my value objects look like the following one: @Value @Accessors(fluent = true) public class ValueObject { private final String firstProp; …
slnowak
  • 1,839
  • 3
  • 23
  • 37
8
votes
4 answers

Does JAXB use bytecode instrumentation?

Someone where i work noticed (in stacktrace) that when running the jvm with -javaagent:spring-instrumentation.jar my JAXB annotated classes have strange new methods in them which we didn't write: e.g.…
Yuval Rimar
  • 1,055
  • 12
  • 22
8
votes
1 answer

Reassembling Python bytecode to the original code?

This might be a silly question, but, given the output of, say.. >>> from dis import dis >>> def myfunc(x): ... print x ** 2 ... >>> dis(myfunc) 2 0 LOAD_FAST 0 (x) 3 LOAD_CONST 1 (2) …
dbr
  • 165,801
  • 69
  • 278
  • 343
8
votes
1 answer

Why doesn't the Java 7 byteode verifier choke on this?

I'm working on code that calculates entries in the StackFrameMap (SFM). The goal is to be able to generate (SFM) entries that make the Java 7 bytecode verifier happy. Following a TDD methodology, I started by creating bogus SMF entries for the…
Charles Forsythe
  • 1,831
  • 11
  • 12
1
2
3
25 26