The disassembled code (using javap -c) of http://lpaste.net/338173 looks like this: http://lpaste.net/338175 , on the third column, there is 200 as an argument to "sipush" how can I get this from a class file using javassist?
sipush
is a bytecode which takes a single two byte argument which is a number to push onto the operand stack. In Javassist, you can iterate over all bytecode of a method via the CodeAttribute
that is available from the CtMethod
's MethodInfo
. In your case, it would be the first byte code, but you can check that you reached Opcode.SIPUSH
. Once you iterated to this instruction you can read the 2 byte argument via the s16bitAt
method from the iterator. The method takes a zero-based index. In your case, this makes the argument zero for sipush
, returning 200
as a value.