Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

Commit a7a18c4

Browse files
committed
README.textile
1 parent 4804b2e commit a7a18c4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.textile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
h1. BytecodeParser
2+
3+
p. BytecodeParser is a java library that can help you statically to parse java bytecode by extracting as much information as possible. It is based upon "javassist":http://www.csg.is.titech.ac.jp/~chiba/javassist/.
4+
5+
p. It can also statically analyze each method's frame, for particular purposes like retrieving the names of the local variable names given as parameters of a method call (its original purpose), check if all the frames are reachable, etc.
6+
7+
p. BytecodeParser simulates the stack operations made by the opcodes in the CodeAttribute. It can give you the state of the stack before and after the frame is run.
8+
9+
p. BytecodeParser is released under the "LGPL, version 3":http://www.gnu.org/licenses/lgpl.html.
10+
11+
h2. How to use it
12+
13+
bc. ClassPool cp = ClassPool.getDefault();
14+
CtClass ctClass = cp.get("org.project.MyClass");
15+
for(CtBehavior behavior : ctClass.getDeclaredMethods()) {
16+
StackAnalyzer parser = new StackAnalyzer(behavior);
17+
Frames frames = parser.analyze();
18+
FrameIterator iterator = frames.iterator();
19+
while(iterator.hasNext()) {
20+
Frame frame = iterator.next();
21+
// you can get some extended information about this frame with frame.decodedOp
22+
// you can also get the state of the stack before or after this frame with frame.stackBefore and frame.stackAfter
23+
}
24+
}

0 commit comments

Comments
 (0)