M
MarlonBrando
the asm-guider.pdf said: [This means that annotations and attributes,
if any, must be visited first, followed
by the method’s bytecode]
but when i use it, for example
MethodVisitor mv = new CheckMethodAdapter(cw.visitMethod(
ACC_PUBLIC, "get" + Helper.capitalize(property),
"()Ljava/lang/String;", null, null));
mv.visitAttribute(new MethodAttribute(cw));
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, Type.getType(clazz)
.getInternalName(), property, Type
.getDescriptor(AtomicLong.class));
// mv.visitInsn(LCONST_0);
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getType
(AtomicLong.class)
.getInternalName(), "get", "()J");
mv.visitMethodInsn(INVOKESTATIC, Type.getType(Long.class)
.getInternalName(), "valueOf", "(J)Ljava/lang/
Long;");
mv.visitMethodInsn(INVOKESTATIC, Type.getType
(MonitorUtil.class)
.getInternalName(), "getFormatedMonitor",
"(Ljava/lang/LongLjava/lang/String;");
mv.visitInsn(ARETURN);
mv.visitMaxs(2, 1);
mv.visitEnd();
i found the code order and the attribute order are reverse, using the
bytecode tool [jclasslib]
just looked like this:
...............Methods
+ [o] <init>
- [1] getState
- [0]
org.aspectj.weaver.MethodDeclarationLineNumber
- [1] code
however, it should be :
- [1] getState
- [0] code
- [1]
org.aspectj.weaver.MethodDeclarationLineNumber
plz help me..
if any, must be visited first, followed
by the method’s bytecode]
but when i use it, for example
MethodVisitor mv = new CheckMethodAdapter(cw.visitMethod(
ACC_PUBLIC, "get" + Helper.capitalize(property),
"()Ljava/lang/String;", null, null));
mv.visitAttribute(new MethodAttribute(cw));
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, Type.getType(clazz)
.getInternalName(), property, Type
.getDescriptor(AtomicLong.class));
// mv.visitInsn(LCONST_0);
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getType
(AtomicLong.class)
.getInternalName(), "get", "()J");
mv.visitMethodInsn(INVOKESTATIC, Type.getType(Long.class)
.getInternalName(), "valueOf", "(J)Ljava/lang/
Long;");
mv.visitMethodInsn(INVOKESTATIC, Type.getType
(MonitorUtil.class)
.getInternalName(), "getFormatedMonitor",
"(Ljava/lang/LongLjava/lang/String;");
mv.visitInsn(ARETURN);
mv.visitMaxs(2, 1);
mv.visitEnd();
i found the code order and the attribute order are reverse, using the
bytecode tool [jclasslib]
just looked like this:
...............Methods
+ [o] <init>
- [1] getState
- [0]
org.aspectj.weaver.MethodDeclarationLineNumber
- [1] code
however, it should be :
- [1] getState
- [0] code
- [1]
org.aspectj.weaver.MethodDeclarationLineNumber
plz help me..