今天在排查问题时,想看看生产上面的包里面代码是怎样的,具体流程如下:
随便找个包(commons-beanutils-1.7.0.jar)
1 解压jar包
jar -xvf commons-beanutils-1.7.0.jar
2 使用javap命令查看class文件内容
javap -v -p DoubleArrayConverter.class
输出如下:
public final class org.apache.commons.beanutils.converters.DoubleArrayConverter extends org.apache.commons.beanutils.converters.AbstractArrayConverter
minor version: 0
major version: 46
flags: ACC_PUBLIC, ACC_FINAL, ACC_SUPER
Constant pool:
#1 = Methodref #28.#58 // org/apache/commons/beanutils/converters/AbstractArrayConverter."<init>":()V
#2 = Fieldref #27.#59 // org/apache/commons/beanutils/converters/DoubleArrayConverter.defaultValue:Ljava/lang/Object;
#3 = Fieldref #27.#60 // org/apache/commons/beanutils/converters/DoubleArrayConverter.useDefault:Z
#4 = Fieldref #27.#59 // org/apache/commons/beanutils/converters/DoubleArrayConverter.defaultValue:Ljava/lang/Object;
#5 = Fieldref #27.#60 // org/apache/commons/beanutils/converters/DoubleArrayConverter.useDefault:Z
#6 = Fieldref #27.#60 // org/apache/commons/beanutils/converters/DoubleArrayConverter.useDefault:Z
#7 = Fieldref #27.#59 // org/apache/commons/beanutils/converters/DoubleArrayConverter.defaultValue:Ljava/lang/Object;
#8 = Class #61 // org/apache/commons/beanutils/ConversionException
#9 = String #62 // No value specified
#10 = Methodref #8.#63 // org/apache/commons/beanutils/ConversionException."<init>":(Ljava/lang/String;)V
#11 = Fieldref #27.#64 // org/apache/commons/beanutils/converters/DoubleArrayConverter.model:[D
#12 = Methodref #65.#66 // java/lang/Object.getClass:()Ljava/lang/Class;
#13 = Fieldref #28.#67 // org/apache/commons/beanutils/converters/AbstractArrayConverter.strings:[Ljava/lang/String;
#14 = Class #47 // "[Ljava/lang/String;"
#15 = Methodref #68.#69 // java/lang/Double.parseDouble:(Ljava/lang/String;)D
#16 = Class #70 // java/lang/Exception
#17 = Fieldref #27.#60 // org/apache/commons/beanutils/converters/DoubleArrayConverter.useDefault:Z
#18 = Fieldref #27.#59 // org/apache/commons/beanutils/converters/DoubleArrayConverter.defaultValue:Ljava/lang/Object;
#19 = Methodref #65.#71 // java/lang/Object.toString:()Ljava/lang/String;
#20 = Methodref #8.#72 // org/apache/commons/beanutils/ConversionException."<init>":(Ljava/lang/String;Ljava/lang/Throwable;)V
#21 = Methodref #27.#73 // org/apache/commons/beanutils/converters/DoubleArrayConverter.parseElements:(Ljava/lang/String;)Ljava/util/List;
#22 = InterfaceMethodref #74.#75 // java/util/List.size:()I
#23 = InterfaceMethodref #74.#76 // java/util/List.get:(I)Ljava/lang/Object;
#24 = Class #77 // java/lang/String
#25 = Fieldref #27.#60 // org/apache/commons/beanutils/converters/DoubleArrayConverter.useDefault:Z
#26 = Fieldref #27.#59 // org/apache/commons/beanutils/converters/DoubleArrayConverter.defaultValue:Ljava/lang/Object;
#27 = Class #78 // org/apache/commons/beanutils/converters/DoubleArrayConverter
#28 = Class #79 // org/apache/commons/beanutils/converters/AbstractArrayConverter
#29 = Utf8 model
#30 = Utf8 [D
#31 = Utf8 <init>
#32 = Utf8 ()V
#33 = Utf8 Code
#34 = Utf8 LineNumberTable
#35 = Utf8 LocalVariableTable
#36 = Utf8 this
#37 = Utf8 Lorg/apache/commons/beanutils/converters/DoubleArrayConverter;
#38 = Utf8 (Ljava/lang/Object;)V
#39 = Utf8 defaultValue
#40 = Utf8 Ljava/lang/Object;
#41 = Utf8 convert
#42 = Utf8 (Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/Object;
#43 = Utf8 type
#44 = Utf8 Ljava/lang/Class;
#45 = Utf8 value
#46 = Utf8 values
#47 = Utf8 [Ljava/lang/String;
#48 = Utf8 results
#49 = Utf8 i
#50 = Utf8 I
#51 = Utf8 e
#52 = Utf8 Ljava/lang/Exception;
#53 = Utf8 list
#54 = Utf8 Ljava/util/List;
#55 = Utf8 <clinit>
#56 = Utf8 SourceFile
#57 = Utf8 DoubleArrayConverter.java
#58 = NameAndType #31:#32 // "<init>":()V
#59 = NameAndType #39:#40 // defaultValue:Ljava/lang/Object;
#60 = NameAndType #80:#81 // useDefault:Z
#61 = Utf8 org/apache/commons/beanutils/ConversionException
#62 = Utf8 No value specified
#63 = NameAndType #31:#82 // "<init>":(Ljava/lang/String;)V
#64 = NameAndType #29:#30 // model:[D
#65 = Class #83 // java/lang/Object
#66 = NameAndType #84:#85 // getClass:()Ljava/lang/Class;
#67 = NameAndType #86:#47 // strings:[Ljava/lang/String;
#68 = Class #87 // java/lang/Double
#69 = NameAndType #88:#89 // parseDouble:(Ljava/lang/String;)D
#70 = Utf8 java/lang/Exception
#71 = NameAndType #90:#91 // toString:()Ljava/lang/String;
#72 = NameAndType #31:#92 // "<init>":(Ljava/lang/String;Ljava/lang/Throwable;)V
#73 = NameAndType #93:#94 // parseElements:(Ljava/lang/String;)Ljava/util/List;
#74 = Class #95 // java/util/List
#75 = NameAndType #96:#97 // size:()I
#76 = NameAndType #98:#99 // get:(I)Ljava/lang/Object;
#77 = Utf8 java/lang/String
#78 = Utf8 org/apache/commons/beanutils/converters/DoubleArrayConverter
#79 = Utf8 org/apache/commons/beanutils/converters/AbstractArrayConverter
#80 = Utf8 useDefault
#81 = Utf8 Z
#82 = Utf8 (Ljava/lang/String;)V
#83 = Utf8 java/lang/Object
#84 = Utf8 getClass
#85 = Utf8 ()Ljava/lang/Class;
#86 = Utf8 strings
#87 = Utf8 java/lang/Double
#88 = Utf8 parseDouble
#89 = Utf8 (Ljava/lang/String;)D
#90 = Utf8 toString
#91 = Utf8 ()Ljava/lang/String;
#92 = Utf8 (Ljava/lang/String;Ljava/lang/Throwable;)V
#93 = Utf8 parseElements
#94 = Utf8 (Ljava/lang/String;)Ljava/util/List;
#95 = Utf8 java/util/List
#96 = Utf8 size
#97 = Utf8 ()I
#98 = Utf8 get
#99 = Utf8 (I)Ljava/lang/Object;
{
private static double[] model;
descriptor: [D
flags: ACC_PRIVATE, ACC_STATIC
public org.apache.commons.beanutils.converters.DoubleArrayConverter();
descriptor: ()V
flags: ACC_PUBLIC
Code:
stack=2, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method org/apache/commons/beanutils/converters/AbstractArrayConverter."<init>":()V
4: aload_0
5: aconst_null
6: putfield #2 // Field defaultValue:Ljava/lang/Object;
9: aload_0
10: iconst_0
11: putfield #3 // Field useDefault:Z
14: return
LineNumberTable:
line 47: 0
line 49: 4
line 50: 9
line 52: 14
LocalVariableTable:
Start Length Slot Name Signature
0 15 0 this Lorg/apache/commons/beanutils/converters/DoubleArrayConverter;
public org.apache.commons.beanutils.converters.DoubleArrayConverter(java.lang.Object);
descriptor: (Ljava/lang/Object;)V
flags: ACC_PUBLIC
Code:
stack=2, locals=2, args_size=2
0: aload_0
1: invokespecial #1 // Method org/apache/commons/beanutils/converters/AbstractArrayConverter."<init>":()V
4: aload_0
5: aload_1
6: putfield #4 // Field defaultValue:Ljava/lang/Object;
9: aload_0
10: iconst_1
11: putfield #5 // Field useDefault:Z
14: return
LineNumberTable:
line 61: 0
line 63: 4
line 64: 9
line 66: 14
LocalVariableTable:
Start Length Slot Name Signature
0 15 0 this Lorg/apache/commons/beanutils/converters/DoubleArrayConverter;
0 15 1 defaultValue Ljava/lang/Object;
public java.lang.Object convert(java.lang.Class, java.lang.Object);
descriptor: (Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/Object;
flags: ACC_PUBLIC
Code:
stack=4, locals=6, args_size=3
0: aload_2
1: ifnonnull 26
4: aload_0
5: getfield #6 // Field useDefault:Z
8: ifeq 16
11: aload_0
12: getfield #7 // Field defaultValue:Ljava/lang/Object;
15: areturn
16: new #8 // class org/apache/commons/beanutils/ConversionException
19: dup
20: ldc #9 // String No value specified
22: invokespecial #10 // Method org/apache/commons/beanutils/ConversionException."<init>":(Ljava/lang/String;)V
25: athrow
26: getstatic #11 // Field model:[D
29: invokevirtual #12 // Method java/lang/Object.getClass:()Ljava/lang/Class;
32: aload_2
33: invokevirtual #12 // Method java/lang/Object.getClass:()Ljava/lang/Class;
36: if_acmpne 41
39: aload_2
40: areturn
41: getstatic #13 // Field org/apache/commons/beanutils/converters/AbstractArrayConverter.strings:[Ljava/lang/String;
44: invokevirtual #12 // Method java/lang/Object.getClass:()Ljava/lang/Class;
47: aload_2
48: invokevirtual #12 // Method java/lang/Object.getClass:()Ljava/lang/Class;
51: if_acmpne 122
54: aload_2
55: checkcast #14 // class "[Ljava/lang/String;"
58: astore_3
59: aload_3
60: arraylength
61: newarray double
63: astore 4
65: iconst_0
66: istore 5
68: goto 86
71: aload 4
73: iload 5
75: aload_3
76: iload 5
78: aaload
79: invokestatic #15 // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
82: dastore
83: iinc 5, 1
86: iload 5
88: aload_3
89: arraylength
90: if_icmplt 71
93: aload 4
95: areturn
96: astore_3
97: aload_0
98: getfield #17 // Field useDefault:Z
101: ifeq 109
104: aload_0
105: getfield #18 // Field defaultValue:Ljava/lang/Object;
108: areturn
109: new #8 // class org/apache/commons/beanutils/ConversionException
112: dup
113: aload_2
114: invokevirtual #19 // Method java/lang/Object.toString:()Ljava/lang/String;
117: aload_3
118: invokespecial #20 // Method org/apache/commons/beanutils/ConversionException."<init>":(Ljava/lang/String;Ljava/lang/Throwable;)V
121: athrow
122: aload_0
123: aload_2
124: invokevirtual #19 // Method java/lang/Object.toString:()Ljava/lang/String;
127: invokevirtual #21 // Method parseElements:(Ljava/lang/String;)Ljava/util/List;
130: astore_3
131: aload_3
132: invokeinterface #22, 1 // InterfaceMethod java/util/List.size:()I
137: newarray double
139: astore 4
141: iconst_0
142: istore 5
144: goto 169
147: aload 4
149: iload 5
151: aload_3
152: iload 5
154: invokeinterface #23, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
159: checkcast #24 // class java/lang/String
162: invokestatic #15 // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
165: dastore
166: iinc 5, 1
169: iload 5
171: aload 4
173: arraylength
174: if_icmplt 147
177: aload 4
179: areturn
180: astore_3
181: aload_0
182: getfield #25 // Field useDefault:Z
185: ifeq 193
188: aload_0
189: getfield #26 // Field defaultValue:Ljava/lang/Object;
192: areturn
193: new #8 // class org/apache/commons/beanutils/ConversionException
196: dup
197: aload_2
198: invokevirtual #19 // Method java/lang/Object.toString:()Ljava/lang/String;
201: aload_3
202: invokespecial #20 // Method org/apache/commons/beanutils/ConversionException."<init>":(Ljava/lang/String;Ljava/lang/Throwable;)V
205: athrow
Exception table:
from to target type
54 95 96 Class java/lang/Exception
122 179 180 Class java/lang/Exception
LineNumberTable:
line 94: 0
line 95: 4
line 96: 11
line 98: 16
line 103: 26
line 104: 39
line 108: 41
line 110: 54
line 111: 59
line 112: 65
line 113: 71
line 112: 83
line 115: 93
line 117: 96
line 118: 104
line 120: 109
line 128: 122
line 129: 131
line 130: 141
line 131: 147
line 130: 166
line 133: 177
line 135: 180
line 136: 188
line 138: 193
LocalVariableTable:
Start Length Slot Name Signature
0 206 0 this Lorg/apache/commons/beanutils/converters/DoubleArrayConverter;
0 206 1 type Ljava/lang/Class;
0 206 2 value Ljava/lang/Object;
59 37 3 values [Ljava/lang/String;
65 31 4 results [D
68 28 5 i I
97 25 3 e Ljava/lang/Exception;
131 49 3 list Ljava/util/List;
141 39 4 results [D
144 36 5 i I
181 25 3 e Ljava/lang/Exception;
static {};
descriptor: ()V
flags: ACC_STATIC
Code:
stack=1, locals=0, args_size=0
0: iconst_0
1: newarray double
3: putstatic #11 // Field model:[D
6: return
LineNumberTable:
line 75: 0
}
SourceFile: "DoubleArrayConverter.java"