1

is there any expert in this community who have worked with BCEL and can guide me about invocation of method using BCEL just like we use to do with java reflection.

Note:to support your answer any sort of book or web reference will become a great source of help.

Now i have seen a interface named Visitor containing method visitInvokeInstruction() Now is there a way so that i can invoke these instruction(that formed a method on stack).

Hope this piece of code give u people a lot of explanation what i want.

thanks in advance

zaree
  • 641
  • 2
  • 6
  • 15
  • I'm pretty sure if such a way exists it will use reflection internally, so why not use it in the first place? – Sean Patrick Floyd May 10 '11 at 08:04
  • I am looking at your code, looks like you are writing a proxy class that measures the time needed for method execution in the proxied class, am I correct?. – Tassos Bassoukos May 10 '11 at 16:56
  • @Tassos Bassoukos, yes u r quit right but this code is incomplete and it does not execute the method that's the key probelm i need to solve out – zaree May 11 '11 at 05:02

1 Answers1

1

The best way is to use BCELifier, a class that comes with BCEL that takes a classfile and emits source code that uses BCEL to emit that classfile - essentially it decompiles the classfile not into bytecodes or the original Java source, but the BCEL code required to emit that.

In your case, just write a simple, dummy class that contains the code you want to produce, then run BCELifier and check the results.

Tassos Bassoukos
  • 16,017
  • 2
  • 36
  • 40
  • can you give any small example to support your answer kindly – zaree May 10 '11 at 09:13
  • @zaree - [BCELifier](http://tim.oreilly.com/pub/a/onjava/2003/10/22/bcel.html?page=2) – McDowell May 10 '11 at 09:20
  • @McDowell your link elaborate BCEL quit positively,BUT all the same there is nothing on invoking a method.I will post some code kindly view it and then gave me some more guidelines – zaree May 10 '11 at 10:45