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

Adding a field to Java class

Looked at using CGLib, ASM, BCEL (aspect) and Javassist to add a field to a class during runtime.... Just to get my head straight it looks like these bytecode manipulators don't update the actual class rather allow the user to only dump the…
Matthew Campbell
  • 1,864
  • 3
  • 24
  • 51
3
votes
3 answers

Dynamically editing/creating classes in Java Android

I am looking for a way to dynamically define classes and instantiate them in Android, at runtime. From my understanding, this is already done in Android, I just need some help figuring it out. I can a similiar result in Javascript and PHP. I know…
Jonathan
  • 5,495
  • 4
  • 38
  • 53
3
votes
1 answer

How to get class Constructor parameteres using Apache BCEL?

I 'm able to get methods using BCEL but is it possible to get constructors of a class using the same library?
Feras Odeh
  • 9,136
  • 20
  • 77
  • 121
3
votes
1 answer

How to push integer on Stack in BCEL

I am facing a problem in context of pushing a integer on stack in BCEL. I have a method _square of someClass i.e. "mathClass" ilist = new InstructionList(); ilist.append(InstructionConstants.ALOAD_0); ilist.append(new…
zaree
  • 641
  • 2
  • 6
  • 15
3
votes
1 answer

After update to Java8, getting error during JiBX bind - [bind] java.lang.IllegalStateException: Error loading class java.lang.CharSequence

On my machine, I updated from Java 1.6 to Java 1.8. Now, while doing build getting below JiBXException in JiBX binding compilation. bind: [echo] Running JiBX binding compiler [bind] Error running binding compiler [bind]…
Jatin Gupta
  • 33
  • 1
  • 10
3
votes
5 answers

Is BCEL == monkeypatching for java?

a colleague pointed me the other day to BCEL which , as best I can tell from his explanation and a quick read, a way to modify at run time the byte code. My first thought was that it sounded dangerous, and my second thought was that it sounded…
shsteimer
  • 28,436
  • 30
  • 79
  • 95
3
votes
3 answers

How to get bytecode of cglib proxy class instance?

I'm trying to get bytecode of cglib enhanced object this way using BCEL: package app; import cglib.MyInterceptor; import net.sf.cglib.proxy.Enhancer; import org.apache.bcel.Repository; import org.apache.bcel.classfile.JavaClass; import…
corvax
  • 1,095
  • 1
  • 10
  • 35
3
votes
0 answers

Replacing a class with BCEL

I'm writing some code where I want to use BCEL to substitute all calls to methods of SomeClass with calls to methods of SomeOtherClass. Right now, from my understanding, I can do this by: iterating over the instruction list finding all…
Gian Luca Scoccia
  • 725
  • 1
  • 8
  • 26
2
votes
2 answers

How to verify Java Bytecode before injecting into the JVM?

I'm trying to verify "on the fly" generated bytecode! I already had several attempts, one attempt was to compile my classes in runtime with the eclipse compiler another was to compile from memory as mentioned here: Compile From Memory First results…
Evils
  • 857
  • 3
  • 12
  • 31
2
votes
5 answers

Is it possible to store a byte array(raw data) in a java class file?

I'm using Apache BCEL to dynamically create java classes that will each have its own associated image. These generated class implement the following interface: interface ImageOwner { byte[] getImage(); } When dynamically implementing the…
Thiago Padilha
  • 4,590
  • 5
  • 44
  • 69
2
votes
1 answer

Can we push a Custom Type Object on Stack Operand in BCEL?

In BCEL we can push primitive types on Operand Stack. BUT now I want to know if it is possible to push a Custom Type Object on Stack in BCEL? I am giving some code so that it can explain the Problem Context class Automobile { public void…
zaree
  • 641
  • 2
  • 6
  • 15
2
votes
1 answer

extract variable names using BCEL library

hi i am using bcel library to read byte code. I needed to extract the variables names. Any idea how to do it?
2
votes
1 answer

Renaming Things

How do I rename things using BCEL? So far what I do is go through each method in a class and create a new NameAndType constant in the constant pool, then I replace the old NameAndType constant with that one int nameRef = cpg.addNameAndType(newName,…
Contra
  • 1,691
  • 15
  • 14
2
votes
1 answer

Determining the Efferent coupling between objects (CBO Metric) using the parsed byte-code generated by BCEL

I have built a program, which takes in a provided ".class" file and parses it using the BCEL, I've learnt how to calculate the LCOM4 value now. Now I would like to know how to calculate the CBO(Coupling between object) value of the class file. I've…
2
votes
1 answer

Illegal constant pool index for method signature when creating a simple class file

I want to create a simple compiler which generates Java Bytecode. For generating the code I am using the Apache BCEL library. However, I failed in creating a simple class with a main method that does nothing. I use the following code (I know that it…
Lukas
  • 756
  • 7
  • 20
1
2
3
8 9