Questions tagged [bcel]

Apache Byte Code Engineering Library, an open-source library for inspecting and manipulating Java byte code files (.class files)

For details see: http://jakarta.apache.org/bcel/

123 questions
17
votes
5 answers

Create simple POJO classes (bytecode) at runtime (dynamically)

I've the following scenario.. I am writing some tool that run user-entered query against the database and return the result.. The simplest way is to return the result as: List but I need to take this a step further. I need to create (at…
Muhammad Hewedy
  • 29,102
  • 44
  • 127
  • 219
12
votes
2 answers

Change classloader

I'm trying to switch the class loader at runtime: public class Test { public static void main(String[] args) throws Exception { final InjectingClassLoader classLoader = new InjectingClassLoader(); …
Chris
  • 830
  • 2
  • 9
  • 20
12
votes
2 answers

Adding code to a Java class w/ Instrumentation: ASM or BCEL?

I am writing a game engine/library in which I have an event dispatcher class which dispatches events by calling listener methods of "registered" event handler classes. One can register an event handler/listener with the event dispatcher by calling…
user1299784
  • 2,019
  • 18
  • 30
11
votes
2 answers

What bytecode library when controlling line numbers?

I need to generate new classes (via generation of java byte code) from existing classes. I will analyse the body (expressions) of the methods of a class. The expressions will determine what code I will generate. For me it is importand to set the…
Arne Deutsch
  • 14,629
  • 5
  • 53
  • 72
11
votes
4 answers

Post-compilation removal of annotations from byte code

We are using a library that contains beans that are annotated with JAXB annotations. nothing in the way we use these classes depends on JAXB. in other words, we don't need JAXB and do not depend on the annotations. However, because the annotations…
Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134
6
votes
3 answers

Ant loadproperties failed (bcel error?)

I'm working on a simple build script that should get some constants from a java class file and use them as the version numbers in my file names. I use Eclipse and its own Ant, but put bcel-5.2.jar in my libs folder and into the classpath for the Ant…
cringe
  • 13,401
  • 15
  • 69
  • 102
6
votes
3 answers

How can one tell if a local variable is 'final' from Java bytecode? (Related to BCEL)

Where is information such as if a local variable is "final" stored in Java bytecode? I know that for fields (global variables) and methods these are found in the access flag bits, but cannot seem to find the equivalent in the local variable table. I…
ET13
  • 427
  • 6
  • 23
6
votes
2 answers

BCI library for Java in C

I am looking for a BCI (Bytecode Instrumentation) library for Java in C or C++, to use in a JVMTI agent. Best case scenario would be something like ASM or BCEL in pure C. The closest thing I have found so far is only a demo java_crw_demo written by…
vektor
  • 3,312
  • 8
  • 41
  • 71
5
votes
1 answer

How is the Java Service Provide API supposed to work?

It seems like everybody has had an unpleasant brush with the Java Service Provider, that thing you can do with a file named like META-INF/services/com.example.Interface, but that nobody uses except for trying to load the right XML parser. I'm…
jonathan-stafford
  • 11,647
  • 1
  • 17
  • 11
5
votes
1 answer

Injecting code in an existing method using BCEL

For my thesis research I need to inject a piece of code to a definable method in a test suite of which I do not have the source ( the DaCapo benchmark suite in this case, http://dacapobench.org/ ). Previous research, on which this part of my thesis…
Peter
  • 620
  • 6
  • 13
5
votes
3 answers

Create a BCEL JavaClass object from arbitrary .class file

I'm playing around with BCEL. I'm not using it to generate bytecode, but instead I'm trying to inspect the structure of existing compiled classes. I need to be able to point to an arbitrary .class file anywhere on my hard drive and load a JavaClass…
Mike Deck
  • 18,045
  • 16
  • 68
  • 92
4
votes
1 answer

Make Java compiler include symbolic constant field reference in class file - possible?

It is well known that the Java compiler pulls in constant field values from other classes at compile time. The resulting class file does not contain a Constant Pool entry (of any type) for such constants. Q: can the compiler be told to do just that?…
mgaert
  • 2,338
  • 21
  • 27
4
votes
1 answer

Bytecode: LOOKUPSWITCH and TABLESWITCH

I am currently instrumenting bytecode using BCEL. In the BCEL API, the two instructions types LOOKUPSWITCH and TABLESWITCH (package org.apache.bcel.generic) are implementing interface StackProducer. I know that these two instructions pop the operand…
H-H
  • 4,431
  • 6
  • 33
  • 41
4
votes
1 answer

BCEL Pass "this" parameter

I have public class SecondClass{ MainClass main; public SecondClass(MainClass main){ this.main=main; } .... } And in MainClass (.class file) have aMethod public class MainClass(){ public…
Toan PV
  • 201
  • 1
  • 7
4
votes
3 answers

Replacing statically referenced method in Java

I have a class like below with a method that just returns a String, but I want to modify what it returns from another class, without hardcoding it myself. public class Name { public static String getName() { return "MyName"; } } Is…
Kaikz
  • 171
  • 1
  • 1
  • 9
1
2 3
8 9