ASM method attribute and code order

Discussion in 'Java' started by MarlonBrando, Oct 15, 2009.

  1. MarlonBrando

    MarlonBrando Guest

    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/Long;)Ljava/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..
     
    MarlonBrando, Oct 15, 2009
    #1
    1. Advertising

  2. On 15 Paź, 15:42, MarlonBrando <> wrote:
    > the asm-guider.pdf said: [This means that annotations and attributes,
    > if any, must be visited first, followed
    > by the method’s bytecode]
    >


    >
    > plz help me..


    I am not sure whether I understand fully your problem, but the way I
    see it the order of attributes is not important.
     
    Marcin Rze¼nicki, Oct 15, 2009
    #2
    1. Advertising

  3. On 15 Paź, 15:42, MarlonBrando <> wrote:
    > the asm-guider.pdf said: [This means that annotations and attributes,
    > if any, must be visited first, followed
    > by the method’s bytecode]


    >
    > plz help me..


    Google ate my reply. :)
    I am not sure if I understand fully your problem, but the way I see it
    the order of attributes is not important.
     
    Marcin Rze¼nicki, Oct 15, 2009
    #3
  4. MarlonBrando

    Jeff Higgins Guest


    > Google ate my reply. :)

    And burped it back up. Yuck. :)
     
    Jeff Higgins, Oct 15, 2009
    #4
  5. On 15 Paź, 16:27, Jeff Higgins <> wrote:
    > > Google ate my reply. :)

    >
    > And burped it back up. Yuck. :)


    Nasty stinky Google dog :)
     
    Marcin Rzeźnicki, Oct 15, 2009
    #5
  6. MarlonBrando

    MarlonBrando Guest

    On 10月15æ—¥, 下åˆ10æ—¶07分, Marcin Rzeźnicki <>
    wrote:
    > On 15 Paź, 15:42, MarlonBrando <> wrote:
    >
    > > the asm-guider.pdf said: [This means that annotations and attributes,
    > > if any, must be visited first, followed
    > > by the method’s bytecode]

    >
    > > plz help me..

    >
    > I am not sure whether I understand fully your problem, but the way I
    > see it the order of attributes is not important.
     
    MarlonBrando, Oct 15, 2009
    #6
  7. MarlonBrando

    MarlonBrando Guest

    On 10ÔÂ15ÈÕ, ÏÂÎç9ʱ42·Ö, MarlonBrando <> wrote:
    > 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/Long;)Ljava/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..


    order is not problem.

    i wrote a interface in bytecode. oops
     
    MarlonBrando, Oct 15, 2009
    #7
  8. On 15 Paź, 16:45, MarlonBrando <> wrote:
    > On 10月15æ—¥, 下åˆ9æ—¶42分, MarlonBrando <> wrote:


    >
    > > plz help me..

    >
    > order is not problem.
    >


    So how can I help you, sir? :)
     
    Marcin Rze¼nicki, Oct 15, 2009
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nico Vrouwe

    OOP and inline asm in VC++ 6

    Nico Vrouwe, Jul 29, 2003, in forum: C++
    Replies:
    2
    Views:
    456
    Nico Vrouwe
    Jul 29, 2003
  2. LordBlue

    Asm code to C code

    LordBlue, Aug 15, 2003, in forum: C Programming
    Replies:
    2
    Views:
    507
    Pieter Droogendijk
    Aug 15, 2003
  3. R

    linking asm and c procedures

    R, Apr 12, 2004, in forum: C Programming
    Replies:
    1
    Views:
    984
    Joona I Palaste
    Apr 12, 2004
  4. Joris

    C++ produced ASM code

    Joris, Aug 9, 2005, in forum: C++
    Replies:
    3
    Views:
    378
    Joris
    Aug 9, 2005
  5. Gernot Frisch

    asm code for ARM (very simple)

    Gernot Frisch, Sep 4, 2008, in forum: C++
    Replies:
    7
    Views:
    550
    Jorgen Grahn
    Sep 16, 2008
Loading...

Share This Page