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
2
votes
2 answers

Change all class references in a compiled class

I am trying to modify a compiled class (source code is not available) which, for example, I want to change all references to java.lang.Object to some.packageName.SomeClass. By references I mean: Field types Methods return types Methods argument…
Juan Garcia
  • 714
  • 6
  • 23
2
votes
2 answers

How can i get javaclass (org.apache.bcel.classfile.JavaClass) from a normal class(java.lang.class) object

I have a .class file which can be class loaded to class object (`java lang`). I need to convert the class object to a BCEL intermediate Java class (org.apache.bcel.classfile.JavaClass) object. How do I do this?
JITHIN_PATHROSE
  • 1,134
  • 4
  • 14
  • 29
2
votes
1 answer

Getting "java.lang.NoClassDefFoundError" on running with javaagent

I am trying to instrument a jar file (main.jar) with javaagent.jar using BCEL. basically where ever I find any aload in bytecode, I m trying to insert a function call to a static function called Fun() in class "someclass" using if (opcode…
rahulk
  • 175
  • 3
  • 15
2
votes
1 answer

Instrument intermediary local method call within a method body

I know (at least using either BCEL, or ASM, for instance), it is possible to somehow access local variables of a method... but, I need something more, what I would like is: to get the type of such a variable (or a way to convert from the…
strexxx
  • 11
  • 1
2
votes
2 answers

Trace every instruction in java bytecode using BCEL

I am using BCEL for ByteCode generation, I just want to print out (println) before every line in the static methods of the input class. I tried instrumentation using BCEL but it result in different form of errors. It says Exception in thread "main"…
Sarmad
  • 21
  • 3
2
votes
1 answer

VerifyError: Stack size too large (what does it mean?)

I'm fairly new to Java bytecode. I'm using BCEL to generate bytecode, but I get an error message when I try to use the generated code. (In hindsight, it looks like ObjectWeb ASM is more advanced and more commonly used than BCEL.) Here is the error…
user1324109
  • 451
  • 4
  • 10
2
votes
0 answers

Tomcat class load exception after bytecode injection

I inject a invoke statement(cajolingMe.cajoleMe();) to One of the webgoat's class(HammerHead.class). This method is a static method that called from a jar file which crated by fat-jar. I copy that jar to lib directory of [webgoat][3] web…
2
votes
1 answer

How do I get the line number of the source code from a byte offset in java?

I am manipulating a .class file. I am using the InstrutionHandle package to get the instructions one at a time. I have the byte offset of the instruction via getPosition() method , can i get the source line number from the byte offset?
Daanish
  • 1,061
  • 7
  • 18
  • 29
2
votes
0 answers

How to use Instrumentation to get variable values?

I'm currently trying to develop a java agent to get stack traces with the name of the called method and values passed by the method. I have a simple application which creates some instances of different objects and plays with them to test my java…
kdelemme
  • 333
  • 1
  • 7
  • 20
1
vote
2 answers

missing classes in classfiles constant pool

i am using bytecode analysis to get all imported classes of a classfile (with BCEL). Now, when i read the constant pool, not all imported classes are mentioned as CONSTANT_Class (see spec) but only as CONSTANT_Utf8. My question now: Am i not able to…
wrm
  • 1,898
  • 13
  • 24
1
vote
3 answers

Is there anything that will index java source, but also include information from the compiled bytecode?

I need to search a large code base, and I'd like to get results to searches like: 'Which classes call method X()' and 'Give me the concrete implementers of interface Y' The kind of handy stuff you can do in eclipse, but which unfortunately isn't…
BigBen
  • 1,162
  • 2
  • 11
  • 22
1
vote
1 answer

Can't see the changes made by BCEL

I'm trying to change main method of my Test class using BCEL. I simply want to add System.out.println("This is added by BCEL at runtime") to the beginning of the main(). Although I don't receive exception and InstructionList shows my commands, my…
Konstantin Milyutin
  • 11,946
  • 11
  • 59
  • 85
1
vote
1 answer

getSuperClass() throws Exception but getSuperclassName() returns the name of the super class

System.out.println(javaClass.getSuperclassName()); JavaClass javaClass1 = javaClass.getSuperClass(); the first line output the name of the class: RestController The second line throws Exception: java.lang.ClassNotFoundException: Exception while…
YasSir
  • 15
  • 2
1
vote
1 answer

JAVA BCEL NEWARRAY getType Basic Type

How do I in BCEL check for this.. Say the bytecode in java is newarray 10 (int) I got this already done for visitor instruction instanceof NEWARRAY public boolean visit(Instruction instr) { return instr instanceof NEWARRAY; } But I also have…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
1
vote
2 answers

How to remove/shrink 'import some.clazz.SomeClass;' statement by means of bytecode manipulation library/framework in Java?

I have the following class: package some.clazz.client; import some.clazz.SomeClass; public class SomeClassClient { ... public SomeClass getProc(); ... } I've removed/shrunk/deleted this getProc() Java…
1 2
3
8 9