首页 > 代码库 > java class文件解析(二)
java class文件解析(二)
继常量池后继续解析,代码如下:
short tempShort = stream.readShort();
System.out.print("access_flags----->");
String value = http://www.mamicode.com/UtilMap.getClassAccessMap().get(Long.valueOf(tempShort&0x0001));
if(null!=value)
{System.out.print(value+" ");}
value = http://www.mamicode.com/UtilMap.getClassAccessMap().get(Long.valueOf(tempShort&0x0010));
if(null!=value){System.out.print(value+" ");}
value = http://www.mamicode.com/UtilMap.getClassAccessMap().get(Long.valueOf(tempShort&0x0020));
if(null!=value)
{
System.out.print(value+" ");
}
value = http://www.mamicode.com/UtilMap.getClassAccessMap().get(Long.valueOf(tempShort&0x0200));
if(null!=value)
{
System.out.print(value+" ");
}
System.out.println();
value = http://www.mamicode.com/UtilMap.getClassAccessMap().get(Long.valueOf(tempShort&0x0400));
if(null!=value)
{
System.out.print(value+" ");
}
tempShort = stream.readShort();
System.out.println("this_class----->"+getUtfValue(tempMap,tempShort));
tempShort = stream.readShort();
System.out.println("super_class----->"+getUtfValue(tempMap,tempShort));
tempShort = stream.readShort();
System.out.println("interface_count----->"+tempShort);
if(tempShort>0)
{
System.out.println("interfaces----->");
}
for(int i=0;i<tempShort;i++) //读取interfaces
{
short temp = stream.readShort();
System.out.println(getClassValue(tempMap,temp));
}
tempShort = stream.readShort();
System.out.println("field_count----->"+tempShort);
if(tempShort>0)
{
System.out.println("fields----->");
}
for(int i=0;i<tempShort;i++) //读取fields
{
System.out.println(readFieldInfo(tempMap,stream));
}
tempShort = stream.readShort();
System.out.println("method_count----->"+tempShort);
if(tempShort>0)
{
System.out.println("methods----->");
}
for(int i=0;i<tempShort;i++)
{
System.out.println(readMethodInfo(tempMap,stream));
}
short attributeCount = stream.readShort();
System.out.println("attribute_count----->"+attributeCount);
if(attributeCount>0)
{
System.out.println("attributes----->");
}
for(int i=0;i<attributeCount;i++)
{
System.out.println(readAttributeInfo(tempMap,stream));
}
System.out.println(-1==stream.read(new byte[1])?"结束":"还有数据");
public static String readMethodInfo(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
StringBuilder sb = new StringBuilder();
short accessFlags = stream.readShort();
short nameIndex = stream.readShort();
short descriptionIndex = stream.readShort();
short attrubuteCount = stream.readShort();
sb.append("(access_flags:");//
String value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0007));
if(null!=value)
{
sb.append(value).append(" ");
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0008));
if(null!=value)
{
sb.append(value).append(" ");
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0010));
if(null!=value)
{
sb.append(value).append(" ");
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0020));
if(null!=value)
{
sb.append(value).append(" ");
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0100));
if(null!=value)
{
sb.append(value).append(" ");
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0400));
if(null!=value)
{
sb.append(value).append(" ");
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0800));
if(null!=value)
{
sb.append(value).append(" ");
}
sb.append(",name:").append(getUtfValue(tempMap, nameIndex));
sb.append(",discription:").append(getUtfValue(tempMap, descriptionIndex));
sb.append(",attrubute_count:").append(attrubuteCount);
if(attrubuteCount>0)
{
sb.append(",attrubute_info:(");
for(int i=0;i<attrubuteCount;i++)
{
sb.append(readAttributeInfo(tempMap,stream));
}
sb.append(")");
}
sb.append(")");
return sb.toString();
}
public static String readFieldInfo(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
StringBuilder sb = new StringBuilder();
short accessFlags = stream.readShort();
short nameIndex = stream.readShort();
short descriptionIndex = stream.readShort();
short attrubuteCount = stream.readShort();
sb.append("(access_flags:");//
String value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0007));
if(null!=value)
{
sb.append(value).append(" ");
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0008));
if(null!=value)
{
sb.append(value).append(" ");
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0010));
if(null!=value)
{
sb.append(value).append(" ");
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0040));
if(null!=value)
{
sb.append(value).append(" ");
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(accessFlags&0x0080));
if(null!=value)
{
sb.append(value).append(" ");
}
sb.append(",name:").append(getUtfValue(tempMap, nameIndex));
sb.append(",discription:").append(getUtfValue(tempMap, descriptionIndex));
sb.append(",attrubute_count:").append(attrubuteCount);
if(attrubuteCount>0)
{
sb.append(",attrubute_info:(");
for(int i=0;i<attrubuteCount;i++)
{
sb.append(readAttributeInfo(tempMap,stream));
}
sb.append(")");
}
sb.append(")");
return sb.toString();
}
public static String readCode(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
StringBuilder sb = new StringBuilder();
short maxStack = stream.readShort();
sb.append(",max_stack:").append(maxStack);
short maxLocals = stream.readShort();
sb.append(",max_locals:").append(maxLocals);
int codeLength = stream.readInt();
sb.append(",code_length:").append(codeLength);
if(codeLength>0)
{
byte[] b = new byte[codeLength];
stream.read(b);
sb.append(",code:").append(new String(b));
}
short exceptionLength = stream.readShort();
sb.append(",exception_table_length:").append(exceptionLength);
if(exceptionLength>0)
{
sb.append(",exception_table:(");
for(int i=0;i<exceptionLength;i++)
{
short startPc = stream.readShort();
short endPc = stream.readShort();
short handerPc = stream.readShort();
short catchType = stream.readShort();
if(i>0)
{
sb.append(",");
}
sb.append("(start_pc:").append(startPc);
sb.append("end_pc:").append(endPc);
sb.append("hander_pc:").append(handerPc);
sb.append("catch_type:").append(getClassValue(tempMap, catchType)).append(")");
}
sb.append(")");
}
short attributeCount = stream.readShort();
sb.append(",attribute_count:").append(attributeCount);
if(attributeCount>0)
{
sb.append(",attributes:(");
for(int i=0;i<attributeCount;i++)
{
if(i>0)
{
sb.append(",");
}
sb.append(readAttributeInfo(tempMap,stream));
}
sb.append(")");
}
return sb.toString();
}
public static String readAttributeInfo(Map<String,ClassBean> tempMap,DataInputStream stream)throws IOException
{
StringBuilder sb = new StringBuilder();
short attributeNameIndex = stream.readShort();
int attributeLength = stream.readInt();
String attributeName = getUtfValue(tempMap, attributeNameIndex);
sb.append("( attribute_name:").append(attributeName);
sb.append(",attribute_length:").append(attributeLength);
if(attributeLength>0)
{
if("ConstantValue".equals(attributeName))
{
sb.append(",constants_values:").append(getClassValue(tempMap,stream.readShort()));
}
else if("Deprecated".equals(attributeName))
{
;
}
else if("Synthetic".equals(attributeName))
{
}
else if("Code".equals(attributeName))
{
sb.append(",").append(readCode(tempMap,stream));
}
else if("Exceptions".equals(attributeName))
{
sb.append(",").append(readException(tempMap,stream));
}
else if("InnerClasses".equals(attributeName))
{
sb.append(",").append(readInnerClasses(tempMap,stream));
}
else if("LineNumberTable".equals(attributeName))
{
sb.append(",").append(readLineNumberTable(tempMap,stream));
}
else if("LocalVariableTable".equals(attributeName))
{
sb.append(",").append(readLocalVariableTable(tempMap,stream));
}
else if("SourceFile".equals(attributeName))
{
sb.append(",sourcefile:").append(getUtfValue(tempMap, stream.readShort()));;
}
else if("Signature".equals(attributeName))
{
sb.append(",Signature:").append(getUtfValue(tempMap, stream.readShort())).append(")");
}
else
{
sb.append("未知:").append(stream.read(new byte[attributeLength]));
}
}
sb.append(")");
return sb.toString();
}
public static String readSourceFile(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
return "";
}
public static String readLocalVariableTable(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
StringBuilder sb = new StringBuilder();
short variableTableLength = stream.readShort();
sb.append(",local_variable_table_Length:").append(variableTableLength);
if(variableTableLength>0)
{
sb.append(",local_variable_info:(");
for(int i=0;i<variableTableLength;i++)
{
short startPc = stream.readShort();
short length = stream.readShort();
short nameIndex = stream.readShort();
short descriptionIndex = stream.readShort();
short index = stream.readShort();
if(i>0)
{
sb.append(",");
}
sb.append("(start_pc:").append(startPc);
sb.append(",length:").append(length);
sb.append(",name_Index:").append(getUtfValue(tempMap, nameIndex));
sb.append(",description_Index:").append(getUtfValue(tempMap, descriptionIndex));
sb.append(",index:").append(index).append(")");
}
}
return sb.toString();
}
public static String readLineNumberTable(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
StringBuilder sb = new StringBuilder();
short lineTableLength = stream.readShort();
sb.append(",line_number_table_Length:").append(lineTableLength);
if(lineTableLength>0)
{
sb.append(",line_number_info:(");
for(int i=0;i<lineTableLength;i++)
{
short startPc = stream.readShort();
short lineNumber = stream.readShort();
if(i>0)
{
sb.append(",");
}
sb.append("(start_pc:").append(startPc);
sb.append(",line_number:").append(lineNumber).append(")");
}
sb.append(")");
}
return sb.toString();
}
public static String readInnerClasses(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
StringBuilder sb = new StringBuilder();
short numberClasses = stream.readShort();
sb.append(",number_classed:").append(numberClasses);
if(numberClasses>0)
{
sb.append(",classes:(");
for(int i=0;i<numberClasses;i++)
{
if(i>0)
{
sb.append(",");
}
sb.append(readInnerClassesInfo(tempMap,stream));
}
sb.append(")");
}
return sb.toString();
}
public static String readInnerClassesInfo(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
StringBuilder sb = new StringBuilder();
short innerClassInfoIndex = stream.readShort();
short outterClassInfoIndex = stream.readShort();
short innerNameIndex = stream.readShort();
short innerClassAccessFlags = stream.readShort();
sb.append("(inner_class_info:").append(getClassValue(tempMap, innerClassInfoIndex));
sb.append(",outter_class_info:").append(0!=outterClassInfoIndex?getClassValue(tempMap, outterClassInfoIndex):"无");
sb.append(",inner_name_index:").append(0!=innerNameIndex?getUtfValue(tempMap, innerNameIndex):"无");
sb.append(",");
String value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(innerClassAccessFlags&0x000F));
if(null!=value)
{
sb.append(value);
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(innerClassAccessFlags&0x00F0));
if(null!=value)
{
sb.append(" ").append(value);
}
value = http://www.mamicode.com/UtilMap.getAccessFlagsMap().get(Long.valueOf(innerClassAccessFlags&0x0F00));
if(null!=value)
{
sb.append(" ").append(value);
}
sb.append(")");
return sb.toString();
}
public static String readException(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
StringBuilder sb = new StringBuilder();
short numberException = stream.readShort();
sb.append(",number_exception:").append(numberException);
if(numberException>0)
{
sb.append(",exception_index_table:(");
for(int i=0;i<numberException;i++)
{
if(i>0)
{
sb.append(",");
}
sb.append(getClassValue(tempMap, stream.readShort()));
}
sb.append(")");
}
return sb.toString();
}
public static String readDeprecated(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
StringBuilder sb = new StringBuilder();
short attributeNameIndex = stream.readShort();
int attributeLength = stream.readInt();
sb.append("( attribute_name:").append(getUtfValue(tempMap, attributeNameIndex));
sb.append(",attribute_length:").append(attributeLength).append(")");
return sb.toString();
}
public static String readExceptionAttribute(Map<String,ClassBean> tempMap,DataInputStream stream) throws IOException
{
StringBuilder sb = new StringBuilder();
int exceptionLenght= stream.readShort();
sb.append("exception_lenght(").append(exceptionLenght).append(")");
short nameIndex ;
short numberException;
if(exceptionLenght>0)
{
sb.append("(");
for(int k=0;k<exceptionLenght;k++)
{
nameIndex = stream.readShort();
sb.append(getUtfValue(tempMap, nameIndex)+"||");
stream.readInt();
numberException = stream.readShort();
sb.append("(");
for(int i=0;i<numberException;i++)
{
sb.append(getClassValue(tempMap, stream.readShort())).append("||");
}
sb.append(")");
}
sb.append(")");
}
return sb.toString();
}
package readClass.util;
import java.util.HashMap;
import java.util.Map;
public class UtilMap
{
private static Map<String,String> constantMap = new HashMap<String,String>();
private static Map<Long,String> classAccessMap = new HashMap<Long,String>();
private static Map<Long,String> accessFlagsMap = new HashMap<Long,String>();
static
{
constantMap.put("1", "constant_utf-8");
constantMap.put("3", "constant_integer-info");
constantMap.put("4", "constant_float-info");
constantMap.put("5", "constant_double-info");
constantMap.put("6", "constant_Long-info");
constantMap.put("7", "constant_class-info");
constantMap.put("8", "constant_string-info");
constantMap.put("9", "constant_fieldRef-info");
constantMap.put("10", "constant_methodRef-info");
constantMap.put("11", "constant_interfaceRef-info");
constantMap.put("12", "constant_NameAndTypeRef-info");
classAccessMap.put(1l, "public");
classAccessMap.put(1*16l, "final");
classAccessMap.put(2*16l, "invokespecial");
classAccessMap.put(2*16*16l, "interface");
classAccessMap.put(4*16*16l, "abstract");
accessFlagsMap.put(1l, "public");
accessFlagsMap.put(2l, "private");
accessFlagsMap.put(4l, "protected");
accessFlagsMap.put(8l, "static");
accessFlagsMap.put(16l, "final");
accessFlagsMap.put(2*16l, "synchronized");
accessFlagsMap.put(4*16l, "volatile");
accessFlagsMap.put(8*16l, "transient");
accessFlagsMap.put(1*16*16l, "native");
accessFlagsMap.put(2*16*16l, "interface");
accessFlagsMap.put(4*16*16l, "abstract");
accessFlagsMap.put(8*16*16l, "abstract");
}
public static Map<String, String> getConstantMap() {
return constantMap;
}
public static void setConstantMap(Map<String, String> constantMap) {
UtilMap.constantMap = constantMap;
}
public static Map<Long, String> getClassAccessMap() {
return classAccessMap;
}
public static void setClassAccessMap(Map<Long, String> classAccessMap) {
UtilMap.classAccessMap = classAccessMap;
}
public static Map<Long, String> getAccessFlagsMap() {
return accessFlagsMap;
}
public static void setAccessFlagsMap(Map<Long, String> accessFlagsMap) {
UtilMap.accessFlagsMap = accessFlagsMap;
}
}
最后总输出如下:
access_flags----->public invokespecial
this_class----->readClass/exampleClass/ExampleClass
super_class----->java/lang/Object
interface_count----->1
interfaces----->
java/lang/Comparable
field_count----->6
fields----->
(access_flags:private ,name:id,discription:Ljava/lang/Long;,attrubute_count:0)
(access_flags:private ,name:name,discription:Ljava/lang/String;,attrubute_count:0)
(access_flags:private static ,name:staticId,discription:Ljava/lang/Long;,attrubute_count:0)
(access_flags:private ,name:k,discription:I,attrubute_count:0)
(access_flags:private ,name:AAA,discription:Ljava/lang/Double;,attrubute_count:0)
(access_flags:private static final ,name:CONSTANTS,discription:Ljava/lang/String;,attrubute_count:1,attrubute_info:(( attribute_name:ConstantValue,attribute_length:2,constants_values:constants)))
method_count----->11
methods----->
(access_flags:public ,name:<init>,discription:()V,attrubute_count:1,attrubute_info:(( attribute_name:Code,attribute_length:94,,max_stack:4,max_locals:1,code_length:36,code:,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:22,,line_number_table_Length:5,line_number_info:((start_pc:0,line_number:7),(start_pc:4,line_number:10),(start_pc:20,line_number:12),(start_pc:25,line_number:13),(start_pc:35,line_number:7))),( attribute_name:LocalVariableTable,attribute_length:12,,local_variable_table_Length:1,local_variable_info:((start_pc:0,length:36,name_Index:this,description_Index:LreadClass/exampleClass/ExampleClass;,index:0))))))
(access_flags:public ,name:getId,discription:()Ljava/lang/Long;,attrubute_count:1,attrubute_info:(( attribute_name:Code,attribute_length:47,,max_stack:1,max_locals:1,code_length:5,code:*?8?,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:6,,line_number_table_Length:1,line_number_info:((start_pc:0,line_number:16))),( attribute_name:LocalVariableTable,attribute_length:12,,local_variable_table_Length:1,local_variable_info:((start_pc:0,length:5,name_Index:this,description_Index:LreadClass/exampleClass/ExampleClass;,index:0))))))
(access_flags:public ,name:setId,discription:(Ljava/lang/Long;)V,attrubute_count:1,attrubute_info:(( attribute_name:Code,attribute_length:62,,max_stack:2,max_locals:2,code_length:6,code:*+?8?,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:10,,line_number_table_Length:2,line_number_info:((start_pc:0,line_number:20),(start_pc:5,line_number:21))),( attribute_name:LocalVariableTable,attribute_length:22,,local_variable_table_Length:2,local_variable_info:((start_pc:0,length:6,name_Index:this,description_Index:LreadClass/exampleClass/ExampleClass;,index:0),(start_pc:0,length:6,name_Index:id,description_Index:Ljava/lang/Long;,index:1))))))
(access_flags:public ,name:getName,discription:()Ljava/lang/String;,attrubute_count:1,attrubute_info:(( attribute_name:Code,attribute_length:47,,max_stack:1,max_locals:1,code_length:5,code:*?$?,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:6,,line_number_table_Length:1,line_number_info:((start_pc:0,line_number:24))),( attribute_name:LocalVariableTable,attribute_length:12,,local_variable_table_Length:1,local_variable_info:((start_pc:0,length:5,name_Index:this,description_Index:LreadClass/exampleClass/ExampleClass;,index:0))))))
(access_flags:public ,name:setName,discription:(Ljava/lang/String;)V,attrubute_count:1,attrubute_info:(( attribute_name:Code,attribute_length:62,,max_stack:2,max_locals:2,code_length:6,code:*+?$?,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:10,,line_number_table_Length:2,line_number_info:((start_pc:0,line_number:28),(start_pc:5,line_number:29))),( attribute_name:LocalVariableTable,attribute_length:22,,local_variable_table_Length:2,local_variable_info:((start_pc:0,length:6,name_Index:this,description_Index:LreadClass/exampleClass/ExampleClass;,index:0),(start_pc:0,length:6,name_Index:name,description_Index:Ljava/lang/String;,index:1))))))
(access_flags:public ,name:getStaticId,discription:()Ljava/lang/Long;,attrubute_count:1,attrubute_info:(( attribute_name:Code,attribute_length:46,,max_stack:1,max_locals:1,code_length:4,code:???,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:6,,line_number_table_Length:1,line_number_info:((start_pc:0,line_number:33))),( attribute_name:LocalVariableTable,attribute_length:12,,local_variable_table_Length:1,local_variable_info:((start_pc:0,length:4,name_Index:this,description_Index:LreadClass/exampleClass/ExampleClass;,index:0))))))
(access_flags:public ,name:setStaticId,discription:(Ljava/lang/Long;)V,attrubute_count:1,attrubute_info:(( attribute_name:Code,attribute_length:61,,max_stack:1,max_locals:2,code_length:5,code:+???,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:10,,line_number_table_Length:2,line_number_info:((start_pc:0,line_number:37),(start_pc:4,line_number:38))),( attribute_name:LocalVariableTable,attribute_length:22,,local_variable_table_Length:2,local_variable_info:((start_pc:0,length:5,name_Index:this,description_Index:LreadClass/exampleClass/ExampleClass;,index:0),(start_pc:0,length:5,name_Index:staticId,description_Index:Ljava/lang/Long;,index:1))))))
(access_flags:public ,name:getAAA,discription:()Ljava/lang/Double;,attrubute_count:2,attrubute_info:(( attribute_name:Exceptions,attribute_length:4,,number_exception:1,exception_index_table:(java/lang/Exception))( attribute_name:Code,attribute_length:47,,max_stack:1,max_locals:1,code_length:5,code:*?0?,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:6,,line_number_table_Length:1,line_number_info:((start_pc:0,line_number:41))),( attribute_name:LocalVariableTable,attribute_length:12,,local_variable_table_Length:1,local_variable_info:((start_pc:0,length:5,name_Index:this,description_Index:LreadClass/exampleClass/ExampleClass;,index:0))))))
(access_flags:public ,name:setAAA,discription:(Ljava/lang/Double;)V,attrubute_count:1,attrubute_info:(( attribute_name:Code,attribute_length:62,,max_stack:2,max_locals:2,code_length:6,code:*+?0?,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:10,,line_number_table_Length:2,line_number_info:((start_pc:0,line_number:45),(start_pc:5,line_number:46))),( attribute_name:LocalVariableTable,attribute_length:22,,local_variable_table_Length:2,local_variable_info:((start_pc:0,length:6,name_Index:this,description_Index:LreadClass/exampleClass/ExampleClass;,index:0),(start_pc:0,length:6,name_Index:aAA,description_Index:Ljava/lang/Double;,index:1))))))
(access_flags:public static ,name:getConstants,discription:()Ljava/lang/String;,attrubute_count:1,attrubute_info:(( attribute_name:Code,attribute_length:35,,max_stack:1,max_locals:0,code_length:3,code:?,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:6,,line_number_table_Length:1,line_number_info:((start_pc:0,line_number:49))),( attribute_name:LocalVariableTable,attribute_length:2,,local_variable_table_Length:0)))))
(access_flags:public ,name:compareTo,discription:(Ljava/lang/Object;)I,attrubute_count:1,attrubute_info:(( attribute_name:Code,attribute_length:54,,max_stack:1,max_locals:2,code_length:2,code:?,exception_table_length:0,attribute_count:2,attributes:(( attribute_name:LineNumberTable,attribute_length:6,,line_number_table_Length:1,line_number_info:((start_pc:0,line_number:55))),( attribute_name:LocalVariableTable,attribute_length:22,,local_variable_table_Length:2,local_variable_info:((start_pc:0,length:2,name_Index:this,description_Index:LreadClass/exampleClass/ExampleClass;,index:0),(start_pc:0,length:2,name_Index:o,description_Index:Ljava/lang/Object;,index:1))))))
attribute_count----->2
attributes----->
( attribute_name:SourceFile,attribute_length:2,sourcefile:ExampleClass.java)
( attribute_name:Signature,attribute_length:2,Signature:Ljava/lang/Object;Ljava/lang/Comparable<Ljava/lang/Object;>;))
结束
java class文件解析(二)