Documentation ¶
Index ¶
- Constants
- type AttributeInfo
- type ClassFile
- func (this *ClassFile) AccessFlags() uint16
- func (this *ClassFile) ClassName() string
- func (this *ClassFile) ConstantPool() ConstantPool
- func (this *ClassFile) Fields() []*MemberInfo
- func (this *ClassFile) InterfaceNames() []string
- func (this *ClassFile) MajorVersion() uint16
- func (this *ClassFile) Methods() []*MemberInfo
- func (this *ClassFile) MinorVersion() uint16
- func (self *ClassFile) SourceFileAttribute() *SourceFileAttribute
- func (this *ClassFile) SuperClassName() string
- type ClassReader
- type CodeAttribute
- type ConstantClassInfo
- type ConstantDoubleInfo
- type ConstantFieldrefInfo
- type ConstantFloatInfo
- type ConstantInfo
- type ConstantIntegerInfo
- type ConstantInterfaceMethodrefInfo
- type ConstantInvokeDynamicInfo
- type ConstantLongInfo
- type ConstantMemberrefInfo
- type ConstantMethodHandleInfo
- type ConstantMethodTypeInfo
- type ConstantMethodrefInfo
- type ConstantNameAndTypeInfo
- type ConstantPool
- type ConstantStringInfo
- type ConstantUtf8Info
- type ConstantValueAttribute
- type DeprecatedAttribute
- type ExceptionTableEntry
- type ExceptionsAttribute
- type LineNumberTableAttribute
- type LineNumberTableEntry
- type MarkerAttribute
- type MemberInfo
- type SourceFileAttribute
- type SyntheticAttribute
- type UnparsedAttribute
Constants ¶
View Source
const ( CONSTANT_Class = 7 CONSTANT_String = 8 CONSTANT_Fieldref = 9 CONSTANT_Methodref = 10 CONSTANT_InterfaceMethodref = 11 CONSTANT_Integer = 3 CONSTANT_Float = 4 CONSTANT_Long = 5 CONSTANT_Double = 6 CONSTANT_NameAndType = 12 CONSTANT_Utf8 = 1 CONSTANT_MethodHandle = 15 CONSTANT_MethodType = 16 CONSTANT_InvokeDynamic = 18 )
*
常量数据结构如下 cp_info { u1 tag; -> 用来区分常量类型 u2 info[]; }
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttributeInfo ¶
type AttributeInfo interface {
// contains filtered or unexported methods
}
*
属性表,储存了方法的字节码等信息 attribute_info { u2 attribute_name_index; u4 attribute_length; u1 info[attribute_length]; }
type ClassFile ¶
type ClassFile struct {
// contains filtered or unexported fields
}
func (*ClassFile) AccessFlags ¶
func (*ClassFile) ConstantPool ¶
func (this *ClassFile) ConstantPool() ConstantPool
func (*ClassFile) Fields ¶
func (this *ClassFile) Fields() []*MemberInfo
func (*ClassFile) InterfaceNames ¶
func (*ClassFile) MajorVersion ¶
func (*ClassFile) Methods ¶
func (this *ClassFile) Methods() []*MemberInfo
func (*ClassFile) SourceFileAttribute ¶
func (self *ClassFile) SourceFileAttribute() *SourceFileAttribute
func (*ClassFile) SuperClassName ¶
type ClassReader ¶
type ClassReader struct {
// contains filtered or unexported fields
}
*
jvm中定义了u1,u2,u4来表示1,2,4字节的 无 符号整数 相同类型的多条数据一般按表的形式存储在class文件中,由表头和表项构成,表头是u2或者u4整数。 假设表头为10,后面就紧跟着10个表项数据
type CodeAttribute ¶
type CodeAttribute struct {
// contains filtered or unexported fields
}
*
CODE_ATTRIBUTE { u2 attribute_name_index; u4 attribute_length; u2 max_stack; -> 操作数栈的最大深度 u2 max_locals; -> 局部变量表大小 u4 code_length; u1 code[code_length]; u2 exception_table_length; { u2 start_pc; u2 end_pc; u2 handle_pc; u2 catch_type; } exception_table[exception_table_length]; u2 attributes_count; attribute_info attributes[attributes_count] }
func (*CodeAttribute) Code ¶
func (self *CodeAttribute) Code() []byte
func (*CodeAttribute) ExceptionTable ¶
func (self *CodeAttribute) ExceptionTable() []*ExceptionTableEntry
func (*CodeAttribute) LineNumberTableAttribute ¶
func (self *CodeAttribute) LineNumberTableAttribute() *LineNumberTableAttribute
*
找出行号属性
func (*CodeAttribute) MaxLocals ¶
func (self *CodeAttribute) MaxLocals() uint
func (*CodeAttribute) MaxStack ¶
func (self *CodeAttribute) MaxStack() uint
type ConstantClassInfo ¶
type ConstantClassInfo struct {
// contains filtered or unexported fields
}
*
CONSTANT_CLASS_INFO { u1 tag; u2 name_index; }
func (*ConstantClassInfo) Name ¶
func (self *ConstantClassInfo) Name() string
type ConstantDoubleInfo ¶
type ConstantDoubleInfo struct {
// contains filtered or unexported fields
}
*
常量池中double 同样特殊 八字节 CONSTANT_DOUBLE_INFO { u1 tag; u4 high_bytes; u4 low_bytes; }
func (*ConstantDoubleInfo) Value ¶
func (self *ConstantDoubleInfo) Value() float64
type ConstantFieldrefInfo ¶
type ConstantFieldrefInfo struct {
ConstantMemberrefInfo
}
*
字段符号引用 CONSTANT_FIELDREF_INFO { u1 tag; u2 class_index; u2 name_and_type_index; }
type ConstantFloatInfo ¶
type ConstantFloatInfo struct {
// contains filtered or unexported fields
}
*
常量池中float 四字节 CONSTANT_FLOAT_INFO { u1 tag; u4 bytes; }
func (*ConstantFloatInfo) Value ¶
func (self *ConstantFloatInfo) Value() float32
type ConstantInfo ¶
type ConstantInfo interface {
// contains filtered or unexported methods
}
*
constant info类型的接口
type ConstantIntegerInfo ¶
type ConstantIntegerInfo struct {
// contains filtered or unexported fields
}
*
常量池中integer 四字节存储整数常量 CONSTANT_INTEGER_INFO { u1 tag; u4 bytes; }
func (*ConstantIntegerInfo) Value ¶
func (self *ConstantIntegerInfo) Value() int32
type ConstantInterfaceMethodrefInfo ¶
type ConstantInterfaceMethodrefInfo struct {
ConstantMemberrefInfo
}
*
接口方法符号引用 CONSTANT_INTERFACEMETHODREF_INFO { u1 tag; u2 class_index; u2 name_and_type_index; }
type ConstantInvokeDynamicInfo ¶
type ConstantInvokeDynamicInfo struct {
// contains filtered or unexported fields
}
CONSTANT_InvokeDynamic_info { u1 tag; u2 bootstrap_method_attr_index; u2 name_and_type_index; }
type ConstantLongInfo ¶
type ConstantLongInfo struct {
// contains filtered or unexported fields
}
*
常量池中long 特殊一些 八字节,分成高8字节和低8字节 CONSTANT_LONG_INFO { u1 tag; u4 high_bytes; u4 low_bytes; }
func (*ConstantLongInfo) Value ¶
func (self *ConstantLongInfo) Value() int64
type ConstantMemberrefInfo ¶
type ConstantMemberrefInfo struct {
// contains filtered or unexported fields
}
*
ConstantFieldrefInfo、ConstantMethodrefInfo、ConstantInterfaceMethodrefInfo 这三个结构体继承自ConstantMemberrefInfo Go语言没有“继承”的概念,而是通过结构体嵌套的方式实现的
func (*ConstantMemberrefInfo) ClassName ¶
func (self *ConstantMemberrefInfo) ClassName() string
func (*ConstantMemberrefInfo) NameAndDescriptor ¶
func (self *ConstantMemberrefInfo) NameAndDescriptor() (string, string)
type ConstantMethodHandleInfo ¶
type ConstantMethodHandleInfo struct {
// contains filtered or unexported fields
}
CONSTANT_MethodHandle_info { u1 tag; u1 reference_kind; u2 reference_index; }
type ConstantMethodTypeInfo ¶
type ConstantMethodTypeInfo struct {
// contains filtered or unexported fields
}
CONSTANT_MethodType_info { u1 tag; u2 descriptor_index; }
type ConstantMethodrefInfo ¶
type ConstantMethodrefInfo struct {
ConstantMemberrefInfo
}
*
普通(非接口)方法符号引用 CONSTANT_METHODREF_INFO { u1 tag; u2 class_index; u2 name_and_type_index; }
type ConstantNameAndTypeInfo ¶
type ConstantNameAndTypeInfo struct {
// contains filtered or unexported fields
}
*
给出字段或方法的名称和描述符 CONSTANT_NAMEANDTYPE_INFO { u1 tag; u2 name_index; u2 descriptor_index }
type ConstantPool ¶
type ConstantPool []ConstantInfo
*
常量池中主要存放两大类常量:字面量和符号引用 字面量比较接近于 Java 层面的常量概念,如文本字符串、被声明为 final 的常量值等 符号引用总结起来则包括了下面三类常量: 1.类和接口的全限定名(即带有包名的 Class 名,如:org.lxh.test.TestClass) 2.字段的名称和描述符(private、static 等描述符) 3.方法的名称和描述符(private、static 等描述符)
func (ConstantPool) GetConstantInfo ¶
func (self ConstantPool) GetConstantInfo(index uint16) ConstantInfo
*
获取常量信息
type ConstantStringInfo ¶
type ConstantStringInfo struct {
// contains filtered or unexported fields
}
*
string info本身不存储字符串,只存了常量池索引,这个索引指向一个CONSTANT_UTF8_INFO。 CONSTANT_STRING_INFO { u1 tag; u2 string_index; }
func (*ConstantStringInfo) String ¶
func (self *ConstantStringInfo) String() string
type ConstantUtf8Info ¶
type ConstantUtf8Info struct {
// contains filtered or unexported fields
}
*
CONSTANT_UTF8_INFO { u1 tag; u2 length; u1 bytes[length]; }
type ConstantValueAttribute ¶
type ConstantValueAttribute struct {
// contains filtered or unexported fields
}
*
CONSTANTVALUE_ATTRIBUTE { u2 attribute_name_index; u4 attribute_length; u2 constantvalue_index; }
func (*ConstantValueAttribute) ConstantValueIndex ¶
func (self *ConstantValueAttribute) ConstantValueIndex() uint16
type ExceptionTableEntry ¶
type ExceptionTableEntry struct {
// contains filtered or unexported fields
}
*
异常表
func (*ExceptionTableEntry) CatchType ¶
func (self *ExceptionTableEntry) CatchType() uint16
func (*ExceptionTableEntry) EndPc ¶
func (self *ExceptionTableEntry) EndPc() uint16
func (*ExceptionTableEntry) HandlerPc ¶
func (self *ExceptionTableEntry) HandlerPc() uint16
func (*ExceptionTableEntry) StartPc ¶
func (self *ExceptionTableEntry) StartPc() uint16
type ExceptionsAttribute ¶
type ExceptionsAttribute struct {
// contains filtered or unexported fields
}
*
记录方法抛出的异常表 EXCEPTIONS_ATTRIBUTE { u2 attribute_name_index; u4 attribute_length; u2 number_of_exceptions; u2 exception_index_table[number_of_exceptions]; }
func (*ExceptionsAttribute) ExceptionIndexTable ¶
func (self *ExceptionsAttribute) ExceptionIndexTable() []uint16
type LineNumberTableAttribute ¶
type LineNumberTableAttribute struct {
// contains filtered or unexported fields
}
*
存放方法的行号信息,是调试信息 LINE_NUMBER_TABLE_ATTRIBUTE { u2 attribute_name_index; u4 attribute_length; u2 line_number_table_length; { u2 start_pc; u2 lint_number; } line_number_table[line_number_table_length]; }
func (*LineNumberTableAttribute) GetLineNumber ¶
func (self *LineNumberTableAttribute) GetLineNumber(pc int) int
*
这里为什么用了 pc >= entry.startPc ? 紫苑注: 看字节码,行号属性中,startPc 和 startPc 相差并不是1 有的是12 有的差16 lineNumber 也并非递增,也存在lineNumber相等的LineNumberTableEntry 没找到什么规律。。
type LineNumberTableEntry ¶
type LineNumberTableEntry struct {
// contains filtered or unexported fields
}
type MemberInfo ¶
type MemberInfo struct {
// contains filtered or unexported fields
}
*
字段/方法
func (*MemberInfo) AccessFlags ¶
func (this *MemberInfo) AccessFlags() uint16
func (*MemberInfo) CodeAttribute ¶
func (this *MemberInfo) CodeAttribute() *CodeAttribute
func (*MemberInfo) ConstantValueAttribute ¶
func (this *MemberInfo) ConstantValueAttribute() *ConstantValueAttribute
func (*MemberInfo) Descriptor ¶
func (this *MemberInfo) Descriptor() string
func (*MemberInfo) Name ¶
func (this *MemberInfo) Name() string
type SourceFileAttribute ¶
type SourceFileAttribute struct {
// contains filtered or unexported fields
}
*
只会出现在ClassFile结构中,用于指出源文件名 SOURCEFILE_ATTRIBUTE { u2 attribute_name_index; -> 指向一个UTF8常量 u4 attribute_length; -> 必须是2 u2 sourcefile_index; }
func (*SourceFileAttribute) FileName ¶
func (self *SourceFileAttribute) FileName() string
type SyntheticAttribute ¶
type SyntheticAttribute struct {
MarkerAttribute
}
*
用来标记源文件中不存在的、由编译器生成的类成员,主要为了支持嵌套类(内部类)和嵌套接口
type UnparsedAttribute ¶
type UnparsedAttribute struct {
// contains filtered or unexported fields
}
Source Files ¶
- attr_code.go
- attr_constant_value.go
- attr_exceptions.go
- attr_line_number_table.go
- attr_markers.go
- attr_source_file.go
- attr_unparsed.go
- attribute_info.go
- class_file.go
- class_reader.go
- constant_pool.go
- cosntant_info.go
- cp_class.go
- cp_invoke_dynamic.go
- cp_member_ref.go
- cp_name_and_type.go
- cp_numeric.go
- cp_string.go
- cp_utf8.go
- member_info.go
Click to show internal directories.
Click to hide internal directories.