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

How to change value of a static field using BCEL?

I want to reset a static field using BCEL, for instance private static final int myValue = 1; to myValue = 2. Using another bytecode library such as ASM is not possible.
s106mo
  • 1,243
  • 2
  • 14
  • 20
0
votes
1 answer

Request for more information on ASM OPCodes

I am learning ASM framework for Byte Code instrumentation and wrote couple of examples to achieve the same.I saw that in most of the examples JVM OPCodes are used for ex:DUP,AASTORE,LSTORE etc but looking at the javadocs of ASM Opcodes i don't see…
VishwanathB
  • 139
  • 2
  • 10
0
votes
1 answer

Why do indexes to constantpool take up different amount of bytes in classfile format

I have been learning about the java class format and i was just wondering why sometimes an opcode with a constant pool entry following takes up two bytes in the class file such as with InvokeStatic, but then op-codes such as ldc with an integer…
Popgalop
  • 737
  • 2
  • 9
  • 26
0
votes
1 answer

Reading bytecode from unloaded classes in external jarfiles

In my Java application, I wish to read bytecode contents from class files that aren't actually loaded, in jar files which also aren't loaded. As in, I need to be able to take any given jarfile, and find all classes inside it, ideally. So take the…
OllieStanley
  • 712
  • 7
  • 25
0
votes
1 answer

Annotation based JMX

How would you implement Spring like annotation based JMX feature. If class is marked by @ManagedResource methods of the class marked with @ManagedOperation are automatically exposed via JMX. I would like to avoid creating interfaces with MBean…
0
votes
2 answers

ASM Bytecode With HttpURLConnection

Using ASM ByteCode library , add a request header (UUID) when a HttpUrlConnection ic created Below is my code - Also am getting the output === > This is Http CONNECT Method!. But dont know how to add a Header? package com.eg.agent; …
Ramesh Subramanian
  • 944
  • 1
  • 12
  • 28
0
votes
1 answer

Wrapping constructor call in the method to the static call using ASM bytecode manipulation

My query is related to bytecode manipulation using ASM. I have one method as follows -- /*Original method code*/ String str ="abs"; // create object of SampleClass2 // constructor calling SampleClass2 sample = new SampleClass2(); …
Ashiq Sayyad
  • 111
  • 2
  • 5
0
votes
1 answer

Utility methods in ASM bytecode library for opcode nature determination?

Are there any utils classes in ASM that allows me to infer from the opcode whether the instruction is some kind of store, load, or whatever? For instance, and considering the following code (from ASM) /** * Visits a zero operand instruction. * *…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
0
votes
2 answers

How to express Java Double Array type (fixing disassembled code)

I have some code that depends on jars that were compiled using Java 1.7. I am currently working on OSX, where I only have access to Java 1.6. I am currently attempting to recompile these jars locally. However, the jars only contained the .class…
etosch
  • 180
  • 7
0
votes
1 answer

Instrumenting bytecode at method level

if(iHandles[f].getInstruction() instanceof IFEQ ) { getFieldInstruction = iHandles[f+1].getInstruction(); System.out.println("found IF"); InstructionList iprint = iFactory.createPrintln("The control is in IF"); …
Daanish
  • 1,061
  • 7
  • 18
  • 29
0
votes
2 answers

Javassist : Bytecode.get() is not working

import javassist.bytecode.Bytecode; import javassist.bytecode.ConstPool; public class Coverage { public static void main(String[] args) { ConstPool cp = new ConstPool("Hello"); byte[] b = new byte[100]; Bytecode bc =…
Daanish
  • 1,061
  • 7
  • 18
  • 29
0
votes
1 answer

How can I copy opcodes from a method to another method in Java Class file using ASM?

Here are some code. static synchronized void q(ua paramua, int paramInt) { try { if (d) { if (paramInt > -16711936); return; } if (q * 514194583 > 0) { if (paramInt > -16711936); abf localabf = new abf(paramua); n.d(localabf,…
SkyDragon
  • 11
  • 1
0
votes
1 answer

adding extra codes at runtime in java

I am developing a library and I need to add extra codes to some of my methods of my objects at run time. there are two points here. first of all, the program I wanted to add extra code, is written before by some body else, and I don't wanted to edit…
saman
  • 199
  • 4
  • 17
0
votes
2 answers

Extracting and executing an arbitrary sequence of Java bytecodes

Given the .class file of Java Class A, is there a way (with BCEL, ASM, etc. for instance) to extract a given bytecode sequence (assuming it's a basic block), place it in a separate location, and then later execute that sequence of…
ChaimKut
  • 2,759
  • 3
  • 38
  • 64
-1
votes
1 answer

Is there any tool to generate the ASM ClassWriter code?

I want to create dynamic java classes, I use a template to generate the source code, and then use jasper jdt to compile. But now, I want to remove the dependency for jdt and create class bytecode with ASM directly. The source code is about 200…
1 2 3
25
26