heap

package
v0.0.0-...-a6a931b Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACC_PUBLIC       = 0x0001 // class field method
	ACC_PRIVATE      = 0x0002 // field method
	ACC_PROTECTED    = 0x0004 // field method
	ACC_STATIC       = 0x0008 // field method
	ACC_FINAL        = 0x0010 // class field method
	ACC_SUPER        = 0x0020 // class
	ACC_SYNCHRONIZED = 0x0020 // method
	ACC_VOLATILE     = 0x0040 // field
	ACC_BRIDGE       = 0x0040 // method
	ACC_TRANSIENT    = 0x0080 // field
	ACC_VARARGS      = 0x0080 // method
	ACC_NATIVE       = 0x0100 // method
	ACC_INTERFACE    = 0x0200 // class
	ACC_ABSTRACT     = 0x0400 // class method
	ACC_STRICT       = 0x0800 // method
	ACC_SYNTHETIC    = 0x1000 // class field method
	ACC_ANNOTATION   = 0x2000 // class
	ACC_ENUM         = 0x4000 // class field
)

类,方法,字段的访问权限

Variables

This section is empty.

Functions

func ArrayCopy

func ArrayCopy(src, dst *Object, srcPos, dstPos, length int32)

func GoString

func GoString(jStr *Object) string

GoString java.lang.String -> go string

Types

type Class

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

Class 类数据结构体 * 当Java虚拟机加载到类之后,会解析类文件将数据放入方法区中,也就是说我们需要定义一个结构体来存放类的相关信息。 定义Class类来存放解析类文件的信息。

name, superClassName and interfaceNames are all binary names(jvms8-4.2.1)

func (*Class) ArrayClass

func (self *Class) ArrayClass() *Class

func (*Class) ComponentClass

func (self *Class) ComponentClass() *Class

func (*Class) ConstantPool

func (self *Class) ConstantPool() *ConstantPool

func (*Class) GetClinitMethod

func (self *Class) GetClinitMethod() *Method

func (*Class) GetInstanceMethod

func (self *Class) GetInstanceMethod(name, descriptor string) *Method

func (*Class) GetMainMethod

func (self *Class) GetMainMethod() *Method

func (*Class) GetPackageName

func (self *Class) GetPackageName() string

func (*Class) GetRefVar

func (self *Class) GetRefVar(fieldName, fieldDescriptor string) *Object

func (*Class) InitStarted

func (self *Class) InitStarted() bool

func (*Class) IsAbstract

func (self *Class) IsAbstract() bool

func (*Class) IsAnnotation

func (self *Class) IsAnnotation() bool

func (*Class) IsArray

func (self *Class) IsArray() bool

func (*Class) IsEnum

func (self *Class) IsEnum() bool

func (*Class) IsFinal

func (self *Class) IsFinal() bool

func (*Class) IsImplements

func (self *Class) IsImplements(iface *Class) bool

IsImplements self implements iface

func (*Class) IsInterface

func (self *Class) IsInterface() bool

func (*Class) IsJioSerializable

func (self *Class) IsJioSerializable() bool

func (*Class) IsJlCloneable

func (self *Class) IsJlCloneable() bool

func (*Class) IsJlObject

func (self *Class) IsJlObject() bool

func (*Class) IsPrimitive

func (self *Class) IsPrimitive() bool

func (*Class) IsPublic

func (self *Class) IsPublic() bool

func (*Class) IsSubClassOf

func (self *Class) IsSubClassOf(other *Class) bool

IsSubClassOf self extends c

func (*Class) IsSuper

func (self *Class) IsSuper() bool

func (*Class) IsSuperClassOf

func (self *Class) IsSuperClassOf(other *Class) bool

IsSuperClassOf c extends self

func (*Class) IsSynthetic

func (self *Class) IsSynthetic() bool

func (*Class) JClass

func (self *Class) JClass() *Object

func (*Class) JavaName

func (self *Class) JavaName() string

func (*Class) Loader

func (self *Class) Loader() *ClassLoader

func (*Class) Name

func (self *Class) Name() string

getters

func (*Class) NewArray

func (self *Class) NewArray(count uint) *Object

func (*Class) NewObject

func (self *Class) NewObject() *Object

func (*Class) SetRefVar

func (self *Class) SetRefVar(fieldName, fieldDescriptor string, ref *Object)

func (*Class) StartInit

func (self *Class) StartInit()

func (*Class) StaticVars

func (self *Class) StaticVars() Slots

func (*Class) SuperClass

func (self *Class) SuperClass() *Class

type ClassLoader

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

ClassLoader

class names:

  • primitive types: boolean, byte, int ...
  • primitive arrays: [Z, [B, [I ...
  • non-array classes: java/lang/Object ...
  • array classes: [Ljava/lang/Object; ...

func NewClassLoader

func NewClassLoader(cp *classpath.Classpath, verboseFlag bool) *ClassLoader

func (*ClassLoader) LoadClass

func (self *ClassLoader) LoadClass(name string) *Class

type ClassMember

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

ClassMember 字段与方法的堆区数据结构

func (*ClassMember) Class

func (self *ClassMember) Class() *Class

func (*ClassMember) Descriptor

func (self *ClassMember) Descriptor() string

func (*ClassMember) IsFinal

func (self *ClassMember) IsFinal() bool

func (*ClassMember) IsPrivate

func (self *ClassMember) IsPrivate() bool

func (*ClassMember) IsProtected

func (self *ClassMember) IsProtected() bool

func (*ClassMember) IsPublic

func (self *ClassMember) IsPublic() bool

func (*ClassMember) IsStatic

func (self *ClassMember) IsStatic() bool

func (*ClassMember) IsSynthetic

func (self *ClassMember) IsSynthetic() bool

func (*ClassMember) Name

func (self *ClassMember) Name() string

getters

type ClassRef

type ClassRef struct {
	SymRef
}

ClassRef 类符号引用

type Constant

type Constant interface{}

type ConstantPool

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

func (*ConstantPool) GetConstant

func (self *ConstantPool) GetConstant(index uint) Constant

type Field

type Field struct {
	ClassMember
	// contains filtered or unexported fields
}

Field 直接对 ClassMember 进行封装

func (*Field) ConstValueIndex

func (self *Field) ConstValueIndex() uint

func (*Field) IsEnum

func (self *Field) IsEnum() bool

func (*Field) IsTransient

func (self *Field) IsTransient() bool

func (*Field) IsVolatile

func (self *Field) IsVolatile() bool

func (*Field) SlotId

func (self *Field) SlotId() uint

type FieldRef

type FieldRef struct {
	MemberRef
	// contains filtered or unexported fields
}

func (*FieldRef) ResolvedField

func (self *FieldRef) ResolvedField() *Field

type InterfaceMethodRef

type InterfaceMethodRef struct {
	MemberRef
	// contains filtered or unexported fields
}

func (*InterfaceMethodRef) ResolvedInterfaceMethod

func (self *InterfaceMethodRef) ResolvedInterfaceMethod() *Method

type MemberRef

type MemberRef struct {
	SymRef
	// contains filtered or unexported fields
}

func (*MemberRef) Descriptor

func (self *MemberRef) Descriptor() string

func (*MemberRef) Name

func (self *MemberRef) Name() string

type Method

type Method struct {
	ClassMember
	// contains filtered or unexported fields
}

func LookupMethodInClass

func LookupMethodInClass(class *Class, name, descriptor string) *Method

func (*Method) ArgSlotCount

func (self *Method) ArgSlotCount() uint

func (*Method) Code

func (self *Method) Code() []byte

func (*Method) IsAbstract

func (self *Method) IsAbstract() bool

func (*Method) IsBridge

func (self *Method) IsBridge() bool

func (*Method) IsNative

func (self *Method) IsNative() bool

func (*Method) IsStrict

func (self *Method) IsStrict() bool

func (*Method) IsSynchronized

func (self *Method) IsSynchronized() bool

func (*Method) IsVarargs

func (self *Method) IsVarargs() bool

func (*Method) MaxLocals

func (self *Method) MaxLocals() uint

func (*Method) MaxStack

func (self *Method) MaxStack() uint

getters

type MethodDescriptor

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

type MethodDescriptorParser

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

type MethodRef

type MethodRef struct {
	MemberRef
	// contains filtered or unexported fields
}

func (*MethodRef) ResolvedMethod

func (self *MethodRef) ResolvedMethod() *Method

type Object

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

func InternString

func InternString(jStr *Object) *Object

func JString

func JString(loader *ClassLoader, goStr string) *Object

func (*Object) ArrayLength

func (self *Object) ArrayLength() int32

func (*Object) Bytes

func (self *Object) Bytes() []int8

func (*Object) Chars

func (self *Object) Chars() []uint16

func (*Object) Class

func (self *Object) Class() *Class

func (*Object) Clone

func (self *Object) Clone() *Object

func (*Object) Doubles

func (self *Object) Doubles() []float64

func (*Object) Extra

func (self *Object) Extra() interface{}

func (*Object) Fields

func (self *Object) Fields() Slots

func (*Object) Floats

func (self *Object) Floats() []float32

func (*Object) GetRefVar

func (self *Object) GetRefVar(name, descriptor string) *Object

func (*Object) Ints

func (self *Object) Ints() []int32

func (*Object) IsInstanceOf

func (self *Object) IsInstanceOf(class *Class) bool

func (*Object) Longs

func (self *Object) Longs() []int64

func (*Object) Refs

func (self *Object) Refs() []*Object

func (*Object) SetExtra

func (self *Object) SetExtra(extra interface{})

func (*Object) SetRefVar

func (self *Object) SetRefVar(name, descriptor string, ref *Object)

func (*Object) Shorts

func (self *Object) Shorts() []int16

type Slot

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

type Slots

type Slots []Slot

func (Slots) GetDouble

func (self Slots) GetDouble(index uint) float64

func (Slots) GetFloat

func (self Slots) GetFloat(index uint) float32

func (Slots) GetInt

func (self Slots) GetInt(index uint) int32

func (Slots) GetLong

func (self Slots) GetLong(index uint) int64

func (Slots) GetRef

func (self Slots) GetRef(index uint) *Object

func (Slots) SetDouble

func (self Slots) SetDouble(index uint, val float64)

SetDouble double consumes two slots

func (Slots) SetFloat

func (self Slots) SetFloat(index uint, val float32)

func (Slots) SetInt

func (self Slots) SetInt(index uint, val int32)

func (Slots) SetLong

func (self Slots) SetLong(index uint, val int64)

SetLong long consumes two slots

func (Slots) SetRef

func (self Slots) SetRef(index uint, ref *Object)

type SymRef

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

func (*SymRef) ResolvedClass

func (self *SymRef) ResolvedClass() *Class

Jump to

Keyboard shortcuts

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