Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The result of Fallback loses some bytecode information #880

Closed
meiMingle opened this issue Nov 18, 2024 · 2 comments
Closed

The result of Fallback loses some bytecode information #880

meiMingle opened this issue Nov 18, 2024 · 2 comments

Comments

@meiMingle
Copy link
Contributor

https://repo1.maven.org/maven2/com/taobao/arthas/arthas-core/4.0.3/arthas-core-4.0.3.jar
Class: com.taobao.arthas.core.Arthas
Method: attachAgent
By comparing the results below, we can see that Fallback loses the bytecode information before L0.

This is the result of Fallback Decompiler:

  private void attachAgent(Configure configure) throws Exception {
        /*
        L0
         LINENUMBER 122 L0
         ALOAD 3
         ALOAD 7
         NEW java/lang/StringBuilder
         DUP
         INVOKESPECIAL java/lang/StringBuilder.<init> ()V
         ALOAD 1
        L31
         LINENUMBER 123 L31
         INVOKEVIRTUAL com/taobao/arthas/core/config/Configure.getArthasCore ()Ljava/lang/String;
         INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
         LDC ";"
         INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
         ALOAD 1
         INVOKEVIRTUAL com/taobao/arthas/core/config/Configure.toString ()Ljava/lang/String;
         INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
         INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String;
        L32
         LINENUMBER 122 L32
         INVOKEVIRTUAL com/sun/tools/attach/VirtualMachine.loadAgent (Ljava/lang/String;Ljava/lang/String;)V
        L1
         LINENUMBER 143 L1
         GOTO L5
        L2
         LINENUMBER 124 L2
        FRAME FULL [com/taobao/arthas/core/Arthas com/taobao/arthas/core/config/Configure com/sun/tools/attach/VirtualMachineDescriptor com/sun/tools/attach/VirtualMachine java/util/Properties java/lang/String java/lang/String java/lang/String] [java/io/IOException]
         ASTORE 8
        L33
         LINENUMBER 125 L33
         ALOAD 8
         INVOKEVIRTUAL java/io/IOException.getMessage ()Ljava/lang/String;
         IFNULL L34
         ALOAD 8
         INVOKEVIRTUAL java/io/IOException.getMessage ()Ljava/lang/String;
         LDC "Non-numeric value found"
         INVOKEVIRTUAL java/lang/String.contains (Ljava/lang/CharSequence;)Z
         IFEQ L34
        L35
         LINENUMBER 126 L35
         ALOAD 8
         INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/Throwable;)V
        L36
         LINENUMBER 127 L36
         LDC "It seems to use the lower version of JDK to attach the higher version of JDK."
         INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/String;)V
        L37
         LINENUMBER 128 L37
         LDC "This error message can be ignored, the attach may have been successful, and it will still try to connect."
         INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/String;)V
         GOTO L38
        L34
         LINENUMBER 131 L34
        FRAME APPEND [java/io/IOException]
         ALOAD 8
         ATHROW
        L38
         LINENUMBER 143 L38
        FRAME CHOP 1
         GOTO L5
        L3
         LINENUMBER 133 L3
        FRAME SAME1 com/sun/tools/attach/AgentLoadException
         ASTORE 8
        L39
         LINENUMBER 134 L39
         LDC "0"
         ALOAD 8
         INVOKEVIRTUAL com/sun/tools/attach/AgentLoadException.getMessage ()Ljava/lang/String;
         INVOKEVIRTUAL java/lang/String.equals (Ljava/lang/Object;)Z
         IFEQ L40
        L41
         LINENUMBER 136 L41
         ALOAD 8
         INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/Throwable;)V
        L42
         LINENUMBER 137 L42
         LDC "It seems to use the higher version of JDK to attach the lower version of JDK."
         INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/String;)V
        L43
         LINENUMBER 138 L43
         LDC "This error message can be ignored, the attach may have been successful, and it will still try to connect."
         INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/String;)V
         GOTO L5
        L40
         LINENUMBER 141 L40
        FRAME APPEND [com/sun/tools/attach/AgentLoadException]
         ALOAD 8
         ATHROW
        L5
         LINENUMBER 145 L5
        FRAME FULL [com/taobao/arthas/core/Arthas com/taobao/arthas/core/config/Configure com/sun/tools/attach/VirtualMachineDescriptor com/sun/tools/attach/VirtualMachine] []
         ACONST_NULL
         ALOAD 3
         IF_ACMPEQ L44
        L45
         LINENUMBER 146 L45
         ALOAD 3
         INVOKEVIRTUAL com/sun/tools/attach/VirtualMachine.detach ()V
         GOTO L44
        L6
         LINENUMBER 145 L6
        FRAME SAME1 java/lang/Throwable
         ASTORE 9
        L7
         ACONST_NULL
         ALOAD 3
         IF_ACMPEQ L46
        L47
         LINENUMBER 146 L47
         ALOAD 3
         INVOKEVIRTUAL com/sun/tools/attach/VirtualMachine.detach ()V
        L46
         LINENUMBER 148 L46
        FRAME FULL [com/taobao/arthas/core/Arthas com/taobao/arthas/core/config/Configure com/sun/tools/attach/VirtualMachineDescriptor com/sun/tools/attach/VirtualMachine T T T T T java/lang/Throwable] []
         ALOAD 9
         ATHROW
        L44
         LINENUMBER 149 L44
        FRAME FULL [com/taobao/arthas/core/Arthas com/taobao/arthas/core/config/Configure com/sun/tools/attach/VirtualMachineDescriptor com/sun/tools/attach/VirtualMachine] []
         RETURN
        L48
         LOCALVARIABLE pid Ljava/lang/String; L13 L14 5
         LOCALVARIABLE descriptor Lcom/sun/tools/attach/VirtualMachineDescriptor; L12 L14 4
         LOCALVARIABLE e Ljava/io/IOException; L33 L38 8
         LOCALVARIABLE ex Lcom/sun/tools/attach/AgentLoadException; L39 L5 8
         LOCALVARIABLE targetSystemProperties Ljava/util/Properties; L20 L5 4
         LOCALVARIABLE targetJavaVersion Ljava/lang/String; L21 L5 5
         LOCALVARIABLE currentJavaVersion Ljava/lang/String; L22 L5 6
         LOCALVARIABLE arthasAgentPath Ljava/lang/String; L29 L5 7
         LOCALVARIABLE this Lcom/taobao/arthas/core/Arthas; L8 L48 0
         LOCALVARIABLE configure Lcom/taobao/arthas/core/config/Configure; L8 L48 1
         LOCALVARIABLE virtualMachineDescriptor Lcom/sun/tools/attach/VirtualMachineDescriptor; L9 L48 2
         LOCALVARIABLE virtualMachine Lcom/sun/tools/attach/VirtualMachine; L4 L48 3
         MAXSTACK = 6
         MAXLOCALS = 10
        */
        throw new RuntimeException("Stub method");
    }

This is the result of Byte Code Analyzer

 private attachAgent(Lcom/taobao/arthas/core/config/Configure;)V throws java/lang/Exception
    TRYCATCHBLOCK L0 L1 L2 java/io/IOException
    TRYCATCHBLOCK L0 L1 L3 com/sun/tools/attach/AgentLoadException
    TRYCATCHBLOCK L4 L5 L6 null
    TRYCATCHBLOCK L6 L7 L6 null
   L8
    LINENUMBER 89 L8
    ACONST_NULL
    ASTORE 2
   L9
    LINENUMBER 90 L9
    INVOKESTATIC com/sun/tools/attach/VirtualMachine.list ()Ljava/util/List;
    INVOKEINTERFACE java/util/List.iterator ()Ljava/util/Iterator; (itf)
    ASTORE 3
   L10
   FRAME APPEND [com/sun/tools/attach/VirtualMachineDescriptor java/util/Iterator]
    ALOAD 3
    INVOKEINTERFACE java/util/Iterator.hasNext ()Z (itf)
    IFEQ L11
    ALOAD 3
    INVOKEINTERFACE java/util/Iterator.next ()Ljava/lang/Object; (itf)
    CHECKCAST com/sun/tools/attach/VirtualMachineDescriptor
    ASTORE 4
   L12
    LINENUMBER 91 L12
    ALOAD 4
    INVOKEVIRTUAL com/sun/tools/attach/VirtualMachineDescriptor.id ()Ljava/lang/String;
    ASTORE 5
   L13
    LINENUMBER 92 L13
    ALOAD 5
    ALOAD 1
    INVOKEVIRTUAL com/taobao/arthas/core/config/Configure.getJavaPid ()J
    INVOKESTATIC java/lang/Long.toString (J)Ljava/lang/String;
    INVOKEVIRTUAL java/lang/String.equals (Ljava/lang/Object;)Z
    IFEQ L14
   L15
    LINENUMBER 93 L15
    ALOAD 4
    ASTORE 2
   L16
    LINENUMBER 94 L16
    GOTO L11
   L14
    LINENUMBER 96 L14
   FRAME SAME
    GOTO L10
   L11
    LINENUMBER 97 L11
   FRAME CHOP 1
    ACONST_NULL
    ASTORE 3
   L4
    LINENUMBER 99 L4
    ACONST_NULL
    ALOAD 2
    IF_ACMPNE L17
   L18
    LINENUMBER 100 L18
    NEW java/lang/StringBuilder
    DUP
    INVOKESPECIAL java/lang/StringBuilder.<init> ()V
    LDC ""
    INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
    ALOAD 1
    INVOKEVIRTUAL com/taobao/arthas/core/config/Configure.getJavaPid ()J
    INVOKEVIRTUAL java/lang/StringBuilder.append (J)Ljava/lang/StringBuilder;
    INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String;
    INVOKESTATIC com/sun/tools/attach/VirtualMachine.attach (Ljava/lang/String;)Lcom/sun/tools/attach/VirtualMachine;
    ASTORE 3
    GOTO L19
   L17
    LINENUMBER 102 L17
   FRAME APPEND [com/sun/tools/attach/VirtualMachine]
    ALOAD 2
    INVOKESTATIC com/sun/tools/attach/VirtualMachine.attach (Lcom/sun/tools/attach/VirtualMachineDescriptor;)Lcom/sun/tools/attach/VirtualMachine;
    ASTORE 3
   L19
    LINENUMBER 105 L19
   FRAME SAME
    ALOAD 3
    INVOKEVIRTUAL com/sun/tools/attach/VirtualMachine.getSystemProperties ()Ljava/util/Properties;
    ASTORE 4
   L20
    LINENUMBER 106 L20
    ALOAD 4
    INVOKESTATIC com/taobao/arthas/common/JavaVersionUtils.javaVersionStr (Ljava/util/Properties;)Ljava/lang/String;
    ASTORE 5
   L21
    LINENUMBER 107 L21
    INVOKESTATIC com/taobao/arthas/common/JavaVersionUtils.javaVersionStr ()Ljava/lang/String;
    ASTORE 6
   L22
    LINENUMBER 108 L22
    ALOAD 5
    IFNULL L23
    ALOAD 6
    IFNULL L23
   L24
    LINENUMBER 109 L24
    ALOAD 5
    ALOAD 6
    INVOKEVIRTUAL java/lang/String.equals (Ljava/lang/Object;)Z
    IFNE L23
   L25
    LINENUMBER 110 L25
    LDC "Current VM java version: {} do not match target VM java version: {}, attach may fail."
    ICONST_2
    ANEWARRAY java/lang/Object
    DUP
    ICONST_0
    ALOAD 6
    AASTORE
    DUP
    ICONST_1
    ALOAD 5
    AASTORE
    INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/String;[Ljava/lang/Object;)V
   L26
    LINENUMBER 112 L26
    LDC "Target VM JAVA_HOME is {}, arthas-boot JAVA_HOME is {}, try to set the same JAVA_HOME."
    ICONST_2
    ANEWARRAY java/lang/Object
    DUP
    ICONST_0
    ALOAD 4
    LDC "java.home"
   L27
    LINENUMBER 113 L27
    INVOKEVIRTUAL java/util/Properties.getProperty (Ljava/lang/String;)Ljava/lang/String;
    AASTORE
    DUP
    ICONST_1
    LDC "java.home"
    INVOKESTATIC java/lang/System.getProperty (Ljava/lang/String;)Ljava/lang/String;
    AASTORE
   L28
    LINENUMBER 112 L28
    INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/String;[Ljava/lang/Object;)V
   L23
    LINENUMBER 117 L23
   FRAME APPEND [java/util/Properties java/lang/String java/lang/String]
    ALOAD 1
    INVOKEVIRTUAL com/taobao/arthas/core/config/Configure.getArthasAgent ()Ljava/lang/String;
    ASTORE 7
   L29
    LINENUMBER 119 L29
    ALOAD 1
    ALOAD 7
    INVOKESTATIC com/taobao/arthas/core/Arthas.encodeArg (Ljava/lang/String;)Ljava/lang/String;
    INVOKEVIRTUAL com/taobao/arthas/core/config/Configure.setArthasAgent (Ljava/lang/String;)V
   L30
    LINENUMBER 120 L30
    ALOAD 1
    ALOAD 1
    INVOKEVIRTUAL com/taobao/arthas/core/config/Configure.getArthasCore ()Ljava/lang/String;
    INVOKESTATIC com/taobao/arthas/core/Arthas.encodeArg (Ljava/lang/String;)Ljava/lang/String;
    INVOKEVIRTUAL com/taobao/arthas/core/config/Configure.setArthasCore (Ljava/lang/String;)V
   L0
    LINENUMBER 122 L0
    ALOAD 3
    ALOAD 7
    NEW java/lang/StringBuilder
    DUP
    INVOKESPECIAL java/lang/StringBuilder.<init> ()V
    ALOAD 1
   L31
    LINENUMBER 123 L31
    INVOKEVIRTUAL com/taobao/arthas/core/config/Configure.getArthasCore ()Ljava/lang/String;
    INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
    LDC ";"
    INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
    ALOAD 1
    INVOKEVIRTUAL com/taobao/arthas/core/config/Configure.toString ()Ljava/lang/String;
    INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
    INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String;
   L32
    LINENUMBER 122 L32
    INVOKEVIRTUAL com/sun/tools/attach/VirtualMachine.loadAgent (Ljava/lang/String;Ljava/lang/String;)V
   L1
    LINENUMBER 143 L1
    GOTO L5
   L2
    LINENUMBER 124 L2
   FRAME FULL [com/taobao/arthas/core/Arthas com/taobao/arthas/core/config/Configure com/sun/tools/attach/VirtualMachineDescriptor com/sun/tools/attach/VirtualMachine java/util/Properties java/lang/String java/lang/String java/lang/String] [java/io/IOException]
    ASTORE 8
   L33
    LINENUMBER 125 L33
    ALOAD 8
    INVOKEVIRTUAL java/io/IOException.getMessage ()Ljava/lang/String;
    IFNULL L34
    ALOAD 8
    INVOKEVIRTUAL java/io/IOException.getMessage ()Ljava/lang/String;
    LDC "Non-numeric value found"
    INVOKEVIRTUAL java/lang/String.contains (Ljava/lang/CharSequence;)Z
    IFEQ L34
   L35
    LINENUMBER 126 L35
    ALOAD 8
    INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/Throwable;)V
   L36
    LINENUMBER 127 L36
    LDC "It seems to use the lower version of JDK to attach the higher version of JDK."
    INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/String;)V
   L37
    LINENUMBER 128 L37
    LDC "This error message can be ignored, the attach may have been successful, and it will still try to connect."
    INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/String;)V
    GOTO L38
   L34
    LINENUMBER 131 L34
   FRAME APPEND [java/io/IOException]
    ALOAD 8
    ATHROW
   L38
    LINENUMBER 143 L38
   FRAME CHOP 1
    GOTO L5
   L3
    LINENUMBER 133 L3
   FRAME SAME1 com/sun/tools/attach/AgentLoadException
    ASTORE 8
   L39
    LINENUMBER 134 L39
    LDC "0"
    ALOAD 8
    INVOKEVIRTUAL com/sun/tools/attach/AgentLoadException.getMessage ()Ljava/lang/String;
    INVOKEVIRTUAL java/lang/String.equals (Ljava/lang/Object;)Z
    IFEQ L40
   L41
    LINENUMBER 136 L41
    ALOAD 8
    INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/Throwable;)V
   L42
    LINENUMBER 137 L42
    LDC "It seems to use the higher version of JDK to attach the lower version of JDK."
    INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/String;)V
   L43
    LINENUMBER 138 L43
    LDC "This error message can be ignored, the attach may have been successful, and it will still try to connect."
    INVOKESTATIC com/taobao/arthas/common/AnsiLog.warn (Ljava/lang/String;)V
    GOTO L5
   L40
    LINENUMBER 141 L40
   FRAME APPEND [com/sun/tools/attach/AgentLoadException]
    ALOAD 8
    ATHROW
   L5
    LINENUMBER 145 L5
   FRAME FULL [com/taobao/arthas/core/Arthas com/taobao/arthas/core/config/Configure com/sun/tools/attach/VirtualMachineDescriptor com/sun/tools/attach/VirtualMachine] []
    ACONST_NULL
    ALOAD 3
    IF_ACMPEQ L44
   L45
    LINENUMBER 146 L45
    ALOAD 3
    INVOKEVIRTUAL com/sun/tools/attach/VirtualMachine.detach ()V
    GOTO L44
   L6
    LINENUMBER 145 L6
   FRAME SAME1 java/lang/Throwable
    ASTORE 9
   L7
    ACONST_NULL
    ALOAD 3
    IF_ACMPEQ L46
   L47
    LINENUMBER 146 L47
    ALOAD 3
    INVOKEVIRTUAL com/sun/tools/attach/VirtualMachine.detach ()V
   L46
    LINENUMBER 148 L46
   FRAME FULL [com/taobao/arthas/core/Arthas com/taobao/arthas/core/config/Configure com/sun/tools/attach/VirtualMachineDescriptor com/sun/tools/attach/VirtualMachine T T T T T java/lang/Throwable] []
    ALOAD 9
    ATHROW
   L44
    LINENUMBER 149 L44
   FRAME FULL [com/taobao/arthas/core/Arthas com/taobao/arthas/core/config/Configure com/sun/tools/attach/VirtualMachineDescriptor com/sun/tools/attach/VirtualMachine] []
    RETURN
   L48
    LOCALVARIABLE pid Ljava/lang/String; L13 L14 5
    LOCALVARIABLE descriptor Lcom/sun/tools/attach/VirtualMachineDescriptor; L12 L14 4
    LOCALVARIABLE e Ljava/io/IOException; L33 L38 8
    LOCALVARIABLE ex Lcom/sun/tools/attach/AgentLoadException; L39 L5 8
    LOCALVARIABLE targetSystemProperties Ljava/util/Properties; L20 L5 4
    LOCALVARIABLE targetJavaVersion Ljava/lang/String; L21 L5 5
    LOCALVARIABLE currentJavaVersion Ljava/lang/String; L22 L5 6
    LOCALVARIABLE arthasAgentPath Ljava/lang/String; L29 L5 7
    LOCALVARIABLE this Lcom/taobao/arthas/core/Arthas; L8 L48 0
    LOCALVARIABLE configure Lcom/taobao/arthas/core/config/Configure; L8 L48 1
    LOCALVARIABLE virtualMachineDescriptor Lcom/sun/tools/attach/VirtualMachineDescriptor; L9 L48 2
    LOCALVARIABLE virtualMachine Lcom/sun/tools/attach/VirtualMachine; L4 L48 3
    MAXSTACK = 6
    MAXLOCALS = 10
@meiMingle
Copy link
Contributor Author

@Col-E Should this code be removed?
image

@Col-E
Copy link
Owner

Col-E commented Nov 24, 2024

a68b8c1 👍

@Col-E Col-E closed this as completed Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants