classfile

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 类或者接口的符号引用
	CONSTANT_Class = 7
	// 字段的符号引用
	CONSTANT_Fieldref = 9
	// 类中方法的符号引用
	CONSTANT_Methodref = 10
	// 接口中方法的符号引用
	CONSTANT_InterfaceMethodref = 11
	// 字符串类型字面量
	CONSTANT_String = 8
	// 整形字面量
	CONSTANT_Integer = 3
	// 浮点数字面量
	CONSTANT_Float = 4
	// 长整形字面量
	CONSTANT_Long = 5
	// 双精度浮点型字面量
	CONSTANT_Double = 6
	// 字段或者方法的部分符号引用
	CONSTANT_NameAndType = 12
	// UTF-8编码的字符串
	CONSTANT_Utf8 = 1
	// 方法句柄
	CONSTANT_MethodHandle = 15
	// 方法类型
	CONSTANT_MethodType = 16
	// 动态方法调用点
	CONSTANT_InvokeDynamic = 18
)

tag 常量一般都由两个部分组成,tag和信息 tag用来区分常量类型

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeInfo

type AttributeInfo interface {
	// contains filtered or unexported methods
}

type ClassFile

type ClassFile struct {
	// contains filtered or unexported fields
}

class文件的映射类

func Parse

func Parse(classData []byte) (cf *ClassFile, err error)

将[]byte解析成ClassFile结构体

func (*ClassFile) AccessFlags

func (self *ClassFile) AccessFlags() uint16

解析类访问标志

func (*ClassFile) ClassName

func (self *ClassFile) ClassName() string

在二进制文件中,类名信息存储的是索引,指向了常量池中的位置

func (*ClassFile) ConstantPool

func (self *ClassFile) ConstantPool() ConstantPool

解析常量池

func (*ClassFile) Fields

func (self *ClassFile) Fields() []*MemberInfo

func (*ClassFile) InterfaceNames

func (self *ClassFile) InterfaceNames() []string

在二进制文件中,接口存储的是索引,指向了常量池中的位置

func (*ClassFile) MajorVersion

func (self *ClassFile) MajorVersion() uint16

解析主版本

func (*ClassFile) Methods

func (self *ClassFile) Methods() []*MemberInfo

func (*ClassFile) MinorVersion

func (self *ClassFile) MinorVersion() uint16

解析次版本

func (*ClassFile) SuperClassName

func (self *ClassFile) SuperClassName() string

在二进制文件中,超类信息存储的是索引,指向了常量池中的位置

type ClassReader

type ClassReader struct {
	// contains filtered or unexported fields
}

类加载器,读取class文件的二进制数据到ClassReader中

type CodeAttribute

type CodeAttribute struct {
	// contains filtered or unexported fields
}

方法属性表

func (CodeAttribute) Code added in v1.5.0

func (self CodeAttribute) Code() []byte

func (CodeAttribute) MaxLocals added in v1.5.0

func (self CodeAttribute) MaxLocals() uint

局部变量表最大值

func (CodeAttribute) MaxStack added in v1.5.0

func (self CodeAttribute) MaxStack() uint

操作数栈最大大小

type ConstantClassInfo

type ConstantClassInfo struct {
	// contains filtered or unexported fields
}

常量池中类信息结构

func (*ConstantClassInfo) Name

func (self *ConstantClassInfo) Name() string

type ConstantDoubleInfo

type ConstantDoubleInfo struct {
	// contains filtered or unexported fields
}

func (*ConstantDoubleInfo) Value added in v1.6.0

func (self *ConstantDoubleInfo) Value() float64

type ConstantFieldrefInfo

type ConstantFieldrefInfo struct{ ConstantMemberrefInfo }

type ConstantFloatInfo

type ConstantFloatInfo struct {
	// contains filtered or unexported fields
}

常量池中的浮点数类型

func (*ConstantFloatInfo) Value added in v1.6.0

func (self *ConstantFloatInfo) Value() float32

type ConstantInfo

type ConstantInfo interface {
	// contains filtered or unexported methods
}

常量信息

type ConstantIntegerInfo

type ConstantIntegerInfo struct {
	// contains filtered or unexported fields
}

常量池中的整数类型

func (*ConstantIntegerInfo) Value added in v1.6.0

func (self *ConstantIntegerInfo) Value() int32

type ConstantInterfaceMethodrefInfo

type ConstantInterfaceMethodrefInfo struct{ ConstantMemberrefInfo }

type ConstantInvokeDynamicInfo

type ConstantInvokeDynamicInfo struct {
	BootstrapMethodAttrIndex uint16
	NameAndTypeIndex         uint16
}
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
}

常量池中的长整形类型

func (*ConstantLongInfo) Value added in v1.6.0

func (self *ConstantLongInfo) Value() int64

type ConstantMemberrefInfo

type ConstantMemberrefInfo struct {
	// contains filtered or unexported fields
}

func (*ConstantMemberrefInfo) ClassName

func (self *ConstantMemberrefInfo) ClassName() string

获取类名

func (*ConstantMemberrefInfo) NameAndDescriptor

func (self *ConstantMemberrefInfo) NameAndDescriptor() (string, string)

获取描述符

type ConstantMethodHandleInfo

type ConstantMethodHandleInfo struct {
	ReferenceKind  uint8
	ReferenceIndex uint16
}
CONSTANT_MethodHandle_info {
    u1 tag;
    u1 reference_kind;
    u2 reference_index;
}

type ConstantMethodTypeInfo

type ConstantMethodTypeInfo struct {
	DescriptorIndex uint16
}
CONSTANT_MethodType_info {
    u1 tag;
    u2 descriptor_index;
}

type ConstantMethodrefInfo

type ConstantMethodrefInfo struct{ ConstantMemberrefInfo }

type ConstantNameAndTypeInfo

type ConstantNameAndTypeInfo struct {
	// contains filtered or unexported fields
}

type ConstantPool

type ConstantPool []ConstantInfo

常量池 数组类型

type ConstantStringInfo

type ConstantStringInfo struct {
	// contains filtered or unexported fields
}

func (*ConstantStringInfo) String

func (self *ConstantStringInfo) String() string

输出常量池中字符串的值

type ConstantUtf8Info

type ConstantUtf8Info struct {
	// contains filtered or unexported fields
}

符号引用的指针都会指向常量池中的索引 索引对应的数据用本utf8结构显示

type ConstantValueAttribute

type ConstantValueAttribute struct {
	// contains filtered or unexported fields
}

func (*ConstantValueAttribute) ConstantValueIndex

func (self *ConstantValueAttribute) ConstantValueIndex() uint16

type DeprecatedAttribute

type DeprecatedAttribute struct{ MarkerAttribute }

@Derecated 注解可以标示方法或者类已经过期

type ExceptionTableEntry

type ExceptionTableEntry struct {
	// contains filtered or unexported fields
}

受检查异常结构

type ExceptionsAttribute

type ExceptionsAttribute struct {
	// contains filtered or unexported fields
}

func (*ExceptionsAttribute) ExceptionIndexTable

func (self *ExceptionsAttribute) ExceptionIndexTable() []uint16

type LineNumberTableAttribute

type LineNumberTableAttribute struct {
	// contains filtered or unexported fields
}

type LineNumberTableEntry

type LineNumberTableEntry struct {
	// contains filtered or unexported fields
}

type LocalVariableTableAttribute

type LocalVariableTableAttribute struct {
	// contains filtered or unexported fields
}

type LocalVariableTableAttributeEntry

type LocalVariableTableAttributeEntry struct {
	// contains filtered or unexported fields
}

type MarkerAttribute

type MarkerAttribute struct{}

type MemberInfo

type MemberInfo struct {
	// contains filtered or unexported fields
}

字段表

func (*MemberInfo) AccessFlags

func (self *MemberInfo) AccessFlags() uint16

func (*MemberInfo) CodeAttribute added in v1.5.0

func (self *MemberInfo) CodeAttribute() *CodeAttribute

获取方法的Code属性

func (*MemberInfo) ConstantValueAttribute added in v1.6.0

func (self *MemberInfo) ConstantValueAttribute() *ConstantValueAttribute

func (*MemberInfo) Descriptor

func (self *MemberInfo) Descriptor() string

获取字段或方法的描述符

func (*MemberInfo) Name

func (self *MemberInfo) Name() string

获取方法或字段名称

type SourceFileAttribute

type SourceFileAttribute struct {
	// contains filtered or unexported fields
}

source_file属性只会出现在classfile目录中

func (*SourceFileAttribute) FileName

func (self *SourceFileAttribute) FileName() string

type SyntheticAttribute

type SyntheticAttribute struct{ MarkerAttribute }

标记源文件不存在,由编译器生成的类成员

type UnparsedAttribute

type UnparsedAttribute struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL