text
stringlengths
9
39.2M
dir
stringlengths
25
226
lang
stringclasses
163 values
created_date
timestamp[s]
updated_date
timestamp[s]
repo_name
stringclasses
751 values
repo_full_name
stringclasses
752 values
star
int64
1.01k
183k
len_tokens
int64
1
18.5M
```go package loads import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Load float from local variable type FLOAD struct{ base.Index8Instruction } func (self *FLOAD) Execute(frame *rtda.Frame) { _fload(frame, self.Index) } type FLOAD_0 struct{ base.NoOperandsInstruction } func (self *FLOAD_0) Execut...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/loads/fload.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
263
```go package classfile /* CONSTANT_MethodHandle_info { u1 tag; u1 reference_kind; u2 reference_index; } */ type ConstantMethodHandleInfo struct { referenceKind uint8 referenceIndex uint16 } func (self *ConstantMethodHandleInfo) readInfo(reader *ClassReader) { self.referenceKind = reader.readUint8() ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/cp_invoke_dynamic.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
241
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Set field in object type PUT_FIELD struct{ base.Index16Instruction } func (self *PUT_FIELD) Execute(frame *rtda.Frame) { currentMethod := frame.Method() currentClass := currentMethod.Class() cp...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/putfield.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
453
```go package references import "reflect" import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Throw exception or error type ATHROW struct{ base.NoOperandsInstruction } func (self *ATHROW) Execute(frame *rtda.Frame) { ex := frame.OperandStack().PopRef() if ex == nil { p...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/athrow.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
373
```go package comparisons import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Compare long type LCMP struct{ base.NoOperandsInstruction } func (self *LCMP) Execute(frame *rtda.Frame) { stack := frame.OperandStack() v2 := stack.PopLong() v1 := stack.PopLong() if v1 > v2 { stack.PushInt(1) } else ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/comparisons/lcmp.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
123
```go package main func main() { cmd := parseCmd() if cmd.versionFlag { println("version 0.0.1") } else if cmd.helpFlag || cmd.class == "" { printUsage() } else { newJVM(cmd).start() } } ```
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/main.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
61
```go package classfile /* Exceptions_attribute { u2 attribute_name_index; u4 attribute_length; u2 number_of_exceptions; u2 exception_index_table[number_of_exceptions]; } */ type ExceptionsAttribute struct { exceptionIndexTable []uint16 } func (self *ExceptionsAttribute) readInfo(reader *ClassReader)...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_exceptions.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
104
```go package conversions import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Convert int to byte type I2B struct{ base.NoOperandsInstruction } func (self *I2B) Execute(frame *rtda.Frame) { stack := frame.OperandStack() i := stack.PopInt() b := int32(int8(i)) stack.PushInt(b) } // Convert int to c...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/conversions/i2x.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
392
```go package stores import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Store long into local variable type LSTORE struct{ base.Index8Instruction } func (self *LSTORE) Execute(frame *rtda.Frame) { _lstore(frame, uint(self.Index)) } type LSTORE_0 struct{ base.NoOperandsInstruction } func (self *LSTO...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/stores/lstore.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
265
```go package classfile /* 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 handler_pc; u2 catch_type; } exception_table...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_code.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
583
```go package classfile /* InnerClasses_attribute { u2 attribute_name_index; u4 attribute_length; u2 number_of_classes; { u2 inner_class_info_index; u2 outer_class_info_index; u2 inner_name_index; u2 inner_class_access_flags; } classes[number_of_classes]; } */ type InnerCl...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_inner_classes.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
238
```go package classfile /* CONSTANT_Fieldref_info { u1 tag; u2 class_index; u2 name_and_type_index; } CONSTANT_Methodref_info { u1 tag; u2 class_index; u2 name_and_type_index; } CONSTANT_InterfaceMethodref_info { u1 tag; u2 class_index; u2 name_and_type_index; } */ type ConstantFiel...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/cp_member_ref.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
241
```go package classfile var ( _attrDeprecated = &DeprecatedAttribute{} _attrSynthetic = &SyntheticAttribute{} ) /* attribute_info { u2 attribute_name_index; u4 attribute_length; u1 info[attribute_length]; } */ type AttributeInfo interface { readInfo(reader *ClassReader) } func readAttributes(reader *...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attribute_info.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
496
```go package classfile /* CONSTANT_String_info { u1 tag; u2 string_index; } */ type ConstantStringInfo struct { cp ConstantPool stringIndex uint16 } func (self *ConstantStringInfo) readInfo(reader *ClassReader) { self.stringIndex = reader.readUint16() } func (self *ConstantStringInfo) String() st...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/cp_string.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
90
```go package native import "jvmgo/ch11/rtda" type NativeMethod func(frame *rtda.Frame) var registry = map[string]NativeMethod{} func emptyNativeMethod(frame *rtda.Frame) { // do nothing } func Register(className, methodName, methodDescriptor string, method NativeMethod) { key := className + "~" + methodName + "...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/registry.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
177
```go package classfile /* LocalVariableTypeTable_attribute { u2 attribute_name_index; u4 attribute_length; u2 local_variable_type_table_length; { u2 start_pc; u2 length; u2 name_index; u2 signature_index; u2 index; } local_variable_type_table[local_variable_type_t...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_local_variable_type_table.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
267
```go package lang import "fmt" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" const jlThrowable = "java/lang/Throwable" type StackTraceElement struct { fileName string className string methodName string lineNumber int } func (self *StackTraceElement) String() string { ret...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Throwable.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
406
```go package lang import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" /* Constructor(Class<T> declaringClass, Class<?>[] parameterTypes, Class<?>[] checkedExceptions, int modifiers, int slot, String signature, ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Class_getDeclaredConstructors0.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
573
```go package lang import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" const jlString = "java/lang/String" func init() { native.Register(jlString, "intern", "()Ljava/lang/String;", intern) } // public native String intern(); // ()Ljava/lang/String; func intern(frame *rtda.Frame) { th...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/String.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
121
```go package lang import "runtime" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" const jlRuntime = "java/lang/Runtime" func init() { native.Register(jlRuntime, "availableProcessors", "()I", availableProcessors) } // public native int availableProcessors(); // ()I func availableProcessors(frame *rtda.Frame) ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Runtime.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
108
```go package lang import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" func init() { native.Register("java/lang/Thread", "currentThread", "()Ljava/lang/Thread;", currentThread) native.Register("java/lang/Thread", "setPriority0", "(I)V", setPriority0) native.Register("java/lang/Thread", "isAlive", "()Z", isAlive) ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Thread.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
383
```go package lang import "runtime" import "time" import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" const jlSystem = "java/lang/System" func init() { native.Register(jlSystem, "arraycopy", "(Ljava/lang/Object;ILjava/lang/Object;II)V", arraycopy) ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/System.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
1,262
```go package lang import "unsafe" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" const jlObject = "java/lang/Object" func init() { native.Register(jlObject, "getClass", "()Ljava/lang/Class;", getClass) native.Register(jlObject, "hashCode", "()I", hashCode) native.Register(jlObject, "clone", "()Ljava/lang/Ob...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Object.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
325
```go package lang import "math" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" const jlDouble = "java/lang/Double" func init() { native.Register(jlDouble, "doubleToRawLongBits", "(D)J", doubleToRawLongBits) native.Register(jlDouble, "longBitsToDouble", "(J)D", longBitsToDouble) } // public static native lon...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Double.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
226
```go package lang import "math" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" const jlFloat = "java/lang/Float" func init() { native.Register(jlFloat, "floatToRawIntBits", "(F)I", floatToRawIntBits) native.Register(jlFloat, "intBitsToFloat", "(I)F", intBitsToFloat) } // public static native int floatToRawI...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Float.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
225
```go package lang import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" /* Method(Class<?> declaringClass, String name, Class<?>[] parameterTypes, Class<?> returnType, Class<?>[] checkedExceptions, int modifiers, int slot, String...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Class_getDeclaredMethods0.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
647
```go package lang import "unsafe" import "jvmgo/ch11/rtda/heap" // []*Class => Class[] func toClassArr(loader *heap.ClassLoader, classes []*heap.Class) *heap.Object { arrLen := len(classes) classArrClass := loader.LoadClass("java/lang/Class").ArrayClass() classArr := classArrClass.NewArray(uint(arrLen)) if arr...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Class_helper.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
268
```go package lang import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" /* Field(Class<?> declaringClass, String name, Class<?> type, int modifiers, int slot, String signature, byte[] annotations) */ const _fieldConstructorDescriptor = "" + ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Class_getDeclaredFields0.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
524
```go package security import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" func init() { native.Register("java/security/AccessController", "doPrivileged", "(Ljava/security/PrivilegedAction;)Ljava/lang/Object;", doPrivileged) native.Register("java/security/AccessController", "do...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/security/AccessController.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
337
```go package io import "path/filepath" import "os" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" const unixfs = "java/io/UnixFileSystem" func init() { native.Register(unixfs, "canonicalize0", "(Ljava/lang/String;)Ljava/lang/String;", canonicalize0) native.Register(unixfs, "getB...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/io/UnixFileSystem.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
478
```go package lang import "strings" import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" const jlClass = "java/lang/Class" func init() { native.Register(jlClass, "getPrimitiveClass", "(Ljava/lang/String;)Ljava/lang/Class;", getPrimitiveClass) nativ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/lang/Class.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
1,441
```go package io import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" const fd = "java/io/FileDescriptor" func init() { native.Register(fd, "set", "(I)J", set) } // private static native long set(int d); // (I)J func set(frame *rtda.Frame) { // todo frame.OperandStack().PushLong(0) } ```
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/io/FileDescriptor.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
93
```go package atomic import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" func init() { native.Register("java/util/concurrent/atomic/AtomicLong", "VMSupportsCS8", "()Z", vmSupportsCS8) } func vmSupportsCS8(frame *rtda.Frame) { frame.OperandStack().PushBoolean(false) } ```
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/util/concurrent/atomic/AtomicLong.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
84
```go package io import "os" import "unsafe" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" const fos = "java/io/FileOutputStream" func init() { native.Register(fos, "writeBytes", "([BIIZ)V", writeBytes) } // private native void writeBytes(byte b[], int off, int len, boolean append) throws IOException; // ([B...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/java/io/FileOutputStream.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
238
```go package io import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" func init() { native.Register("sun/io/Win32ErrorMode", "setErrorMode", "(J)J", setErrorMode) } func setErrorMode(frame *rtda.Frame) { // todo frame.OperandStack().PushLong(0) } ```
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/sun/io/Win32ErrorMode.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
79
```go package reflect import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" func init() { native.Register("sun/reflect/Reflection", "getCallerClass", "()Ljava/lang/Class;", getCallerClass) native.Register("sun/reflect/Reflection", "getClassAccessFlags", "(Ljava/lang/Class;)I", getClassAc...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/sun/reflect/Reflection.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
279
```go package reflect import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" func init() { native.Register("sun/reflect/NativeConstructorAccessorImpl", "newInstance0", "(Ljava/lang/reflect/Constructor;[Ljava/lang/Object;)Ljava/lang/Object;", newInstanc...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/sun/reflect/NativeConstructorAccessorImpl.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
708
```go package misc var _allocated = map[int64][]byte{} var _nextAddress = int64(64) // not zero! func allocate(size int64) (address int64) { mem := make([]byte, size) address = _nextAddress _allocated[address] = mem _nextAddress += size return } func reallocate(address, size int64) int64 { if size == 0 { ret...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/sun/misc/malloc.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
290
```go package misc import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" func init() { native.Register("sun/misc/VM", "initialize", "()V", initialize) } // private static native void initialize(); // ()V func initialize(frame *rtda.Frame) { classLoader := frame.Method().Class()....
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/sun/misc/VM.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
130
```go package misc import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" const miscUnsafe = "sun/misc/Unsafe" func init() { native.Register(miscUnsafe, "arrayBaseOffset", "(Ljava/lang/Class;)I", arrayBaseOffset) native.Register(miscUnsafe, "arrayIndexScale", "(Ljava/lang/Class;)I", arra...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/sun/misc/Unsafe.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
1,639
```go package misc import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" func init() { native.Register("sun/misc/URLClassPath", "getLookupCacheURLs", "(Ljava/lang/ClassLoader;)[Ljava/net/URL;", getLookupCacheURLs) } // private static native URL[] getLookupCacheURLs(ClassLoader var0); // (Ljava/lang/ClassLoader;)[Ljav...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/sun/misc/URLClassPath.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
118
```go package misc import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" func init() { _signal(findSignal, "findSignal", "(Ljava/lang/String;)I") _signal(handle0, "handle0", "(IJ)J") } func _signal(method func(frame *rtda.Frame), name, desc string) { native.Register("sun/misc/Signal", name, desc, method) } // priv...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/sun/misc/Signal.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
234
```go package rtda import "jvmgo/ch11/rtda/heap" /* JVM Thread pc Stack Frame LocalVars OperandStack */ type Thread struct { pc int // the address of the instruction currently being executed stack *Stack // todo } func NewThread() *Thread { return &Thread{ stack: newStack(102...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/thread.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
275
```go package misc import "math" import "encoding/binary" import "jvmgo/ch11/native" import "jvmgo/ch11/rtda" func init() { _unsafe(allocateMemory, "allocateMemory", "(J)J") _unsafe(reallocateMemory, "reallocateMemory", "(JJ)J") _unsafe(freeMemory, "freeMemory", "(J)V") _unsafe(addressSize, "addressSize", "()I") ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/native/sun/misc/Unsafe_mem.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
1,902
```go package rtda import "math" import "jvmgo/ch11/rtda/heap" type OperandStack struct { size uint slots []Slot } func newOperandStack(maxStack uint) *OperandStack { if maxStack > 0 { return &OperandStack{ slots: make([]Slot, maxStack), } } return nil } func (self *OperandStack) PushInt(val int32) { ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/operand_stack.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
666
```go package rtda import "math" import "jvmgo/ch11/rtda/heap" type LocalVars []Slot func newLocalVars(maxLocals uint) LocalVars { if maxLocals > 0 { return make([]Slot, maxLocals) } return nil } func (self LocalVars) SetInt(index uint, val int32) { self[index].num = val } func (self LocalVars) GetInt(index u...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/local_vars.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
459
```go package rtda import "jvmgo/ch11/rtda/heap" type Slot struct { num int32 ref *heap.Object } ```
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/slot.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
33
```go package rtda import "jvmgo/ch11/rtda/heap" // stack frame type Frame struct { lower *Frame // stack is implemented as linked list localVars LocalVars operandStack *OperandStack thread *Thread method *heap.Method nextPC int // the next instruction after the call } func newFrame...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/frame.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
272
```go package rtda // jvm stack type Stack struct { maxSize uint size uint _top *Frame // stack is implemented as linked list } func newStack(maxSize uint) *Stack { return &Stack{ maxSize: maxSize, } } func (self *Stack) push(frame *Frame) { if self.size >= self.maxSize { panic("java.lang.StackOverfl...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/jvm_stack.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
303
```go package rtda import "jvmgo/ch11/rtda/heap" func NewShimFrame(thread *Thread, ops *OperandStack) *Frame { return &Frame{ thread: thread, method: heap.ShimReturnMethod(), operandStack: ops, } } //func newAthrowFrame(thread *Thread, ex *heap.Object, initArgs []interface{}) *Frame { // // stack...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/shim_frames.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
203
```go package heap // symbolic reference type SymRef struct { cp *ConstantPool className string class *Class } func (self *SymRef) ResolvedClass() *Class { if self.class == nil { self.resolveClassRef() } return self.class } // jvms8 5.4.3.1 func (self *SymRef) resolveClassRef() { d := self.cp.cla...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/cp_symref.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
129
```go package heap import "jvmgo/ch11/classfile" type MethodRef struct { MemberRef method *Method } func newMethodRef(cp *ConstantPool, refInfo *classfile.ConstantMethodrefInfo) *MethodRef { ref := &MethodRef{} ref.cp = cp ref.copyMemberRefInfo(&refInfo.ConstantMemberrefInfo) return ref } func (self *MethodRe...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/cp_methodref.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
277
```go package heap import "fmt" import "jvmgo/ch11/classfile" type Constant interface{} type ConstantPool struct { class *Class consts []Constant } func newConstantPool(class *Class, cfCp classfile.ConstantPool) *ConstantPool { cpCount := len(cfCp) consts := make([]Constant, cpCount) rtCp := &ConstantPool{cla...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/constant_pool.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
517
```go package heap import "strings" import "jvmgo/ch11/classfile" // name, superClassName and interfaceNames are all binary names(jvms8-4.2.1) type Class struct { accessFlags uint16 name string // thisClassName superClassName string interfaceNames []string constantPool *ConstantPool...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/class.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
1,576
```go package heap import "jvmgo/ch11/classfile" type FieldRef struct { MemberRef field *Field } func newFieldRef(cp *ConstantPool, refInfo *classfile.ConstantFieldrefInfo) *FieldRef { ref := &FieldRef{} ref.cp = cp ref.copyMemberRefInfo(&refInfo.ConstantMemberrefInfo) return ref } func (self *FieldRef) Resol...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/cp_fieldref.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
308
```go package heap // jvms8 6.5.instanceof // jvms8 6.5.checkcast func (self *Class) IsAssignableFrom(other *Class) bool { s, t := other, self if s == t { return true } if !s.IsArray() { if !s.IsInterface() { // s is class if !t.IsInterface() { // t is not interface return s.IsSubClassOf(t) ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/class_hierarchy.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
568
```go package heap import "jvmgo/ch11/classfile" type ClassRef struct { SymRef } func newClassRef(cp *ConstantPool, classInfo *classfile.ConstantClassInfo) *ClassRef { ref := &ClassRef{} ref.cp = cp ref.className = classInfo.Name() return ref } ```
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/cp_classref.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
68
```go package heap import "strings" type MethodDescriptorParser struct { raw string offset int parsed *MethodDescriptor } func parseMethodDescriptor(descriptor string) *MethodDescriptor { parser := &MethodDescriptorParser{} return parser.parse(descriptor) } func (self *MethodDescriptorParser) parse(descript...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/method_descriptor_parser.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
675
```go package heap import "jvmgo/ch11/classfile" type ClassMember struct { accessFlags uint16 name string descriptor string signature string annotationData []byte // RuntimeVisibleAnnotations_attribute class *Class } func (self *ClassMember) copyMemberInfo(memberInfo *classfile.M...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/class_member.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
458
```go package heap import "unicode/utf16" var internedStrings = map[string]*Object{} // todo // go string -> java.lang.String func JString(loader *ClassLoader, goStr string) *Object { if internedStr, ok := internedStrings[goStr]; ok { return internedStr } chars := stringToUtf16(goStr) jChars := &Object{loader...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/string_pool.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
342
```go package heap var primitiveTypes = map[string]string{ "void": "V", "boolean": "Z", "byte": "B", "short": "S", "int": "I", "long": "J", "char": "C", "float": "F", "double": "D", } // [XXX -> [[XXX // int -> [I // XXX -> [LXXX; func getArrayClassName(className string) string { return...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/class_name_helper.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
387
```go package heap import "jvmgo/ch11/classfile" type MemberRef struct { SymRef name string descriptor string } func (self *MemberRef) copyMemberRefInfo(refInfo *classfile.ConstantMemberrefInfo) { self.className = refInfo.ClassName() self.name, self.descriptor = refInfo.NameAndDescriptor() } func (self *...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/cp_memberref.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
107
```go package heap type Object struct { class *Class data interface{} // Slots for Object, []int32 for int[] ... extra interface{} } // create normal (non-array) object func newObject(class *Class) *Object { return &Object{ class: class, data: newSlots(class.instanceSlotCount), } } // getters & setters fu...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/object.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
374
```go package heap type MethodDescriptor struct { parameterTypes []string returnType string } func (self *MethodDescriptor) addParameterType(t string) { pLen := len(self.parameterTypes) if pLen == cap(self.parameterTypes) { s := make([]string, pLen, pLen+4) copy(s, self.parameterTypes) self.parameterTyp...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/method_descriptor.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
97
```go package heap import "jvmgo/ch11/classfile" type Method struct { ClassMember maxStack uint maxLocals uint code []byte exceptionTable ExceptionTable // todo: rename lineNumberTable *classfile.LineNumberTableAttribute exceptions *...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/method.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
1,317
```go package heap import "fmt" import "jvmgo/ch11/classfile" import "jvmgo/ch11/classpath" /* class names: - primitive types: boolean, byte, int ... - primitive arrays: [Z, [B, [I ... - non-array classes: java/lang/Object ... - array classes: [Ljava/lang/Object; ... */ type ClassLoader struct { cp ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/class_loader.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
1,520
```go package heap import "jvmgo/ch11/classfile" type ExceptionTable []*ExceptionHandler type ExceptionHandler struct { startPc int endPc int handlerPc int catchType *ClassRef } func newExceptionTable(entries []*classfile.ExceptionTableEntry, cp *ConstantPool) ExceptionTable { table := make([]*ExceptionH...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/exception_table.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
315
```go package heap 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_SYNCHR...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/access_flags.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
278
```go package heap func LookupMethodInClass(class *Class, name, descriptor string) *Method { for c := class; c != nil; c = c.superClass { for _, method := range c.methods { if method.name == name && method.descriptor == descriptor { return method } } } return nil } func lookupMethodInInterfaces(iface...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/method_lookup.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
164
```go package heap import "math" type Slot struct { num int32 ref *Object } type Slots []Slot func newSlots(slotCount uint) Slots { if slotCount > 0 { return make([]Slot, slotCount) } return nil } func (self Slots) SetInt(index uint, val int32) { self[index].num = val } func (self Slots) GetInt(index uint)...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/slots.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
373
```go package heap import "jvmgo/ch11/classfile" type InterfaceMethodRef struct { MemberRef method *Method } func newInterfaceMethodRef(cp *ConstantPool, refInfo *classfile.ConstantInterfaceMethodrefInfo) *InterfaceMethodRef { ref := &InterfaceMethodRef{} ref.cp = cp ref.copyMemberRefInfo(&refInfo.ConstantMembe...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/cp_interface_methodref.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
300
```go package heap var ( _shimClass = &Class{name: "~shim"} _returnCode = []byte{0xb1} // return _athrowCode = []byte{0xbf} // athrow _returnMethod = &Method{ ClassMember: ClassMember{ accessFlags: ACC_STATIC, name: "<return>", class: _shimClass, }, code: _returnCode, } _athrowMeth...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/shim_methods.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
280
```go package heap func (self *Object) Bytes() []int8 { return self.data.([]int8) } func (self *Object) Shorts() []int16 { return self.data.([]int16) } func (self *Object) Ints() []int32 { return self.data.([]int32) } func (self *Object) Longs() []int64 { return self.data.([]int64) } func (self *Object) Chars() []...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/array_object.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
783
```go package heap import "jvmgo/ch11/classfile" type Field struct { ClassMember constValueIndex uint slotId uint } func newFields(class *Class, cfFields []*classfile.MemberInfo) []*Field { fields := make([]*Field, len(cfFields)) for i, cfField := range cfFields { fields[i] = &Field{} fields[i].cla...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/field.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
326
```go package heap func (self *Class) IsArray() bool { return self.name[0] == '[' } func (self *Class) ComponentClass() *Class { componentClassName := getComponentClassName(self.name) return self.loader.LoadClass(componentClassName) } func (self *Class) NewArray(count uint) *Object { if !self.IsArray() { panic...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/array_class.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
305
```go package classpath import "os" import "strings" // :(linux/unix) or ;(windows) const pathListSeparator = string(os.PathListSeparator) type Entry interface { // className: fully/qualified/ClassName.class readClass(className string) ([]byte, Entry, error) String() string } func newEntry(path string) Entry { ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classpath/entry.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
168
```go package heap func (self *Object) Clone() *Object { return &Object{ class: self.class, data: self.cloneData(), } } func (self *Object) cloneData() interface{} { switch self.data.(type) { case []int8: elements := self.data.([]int8) elements2 := make([]int8, len(elements)) copy(elements2, elements) ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/rtda/heap/object_clone.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
423
```go package classpath import "errors" import "strings" type CompositeEntry []Entry func newCompositeEntry(pathList string) CompositeEntry { compositeEntry := []Entry{} for _, path := range strings.Split(pathList, pathListSeparator) { entry := newEntry(path) compositeEntry = append(compositeEntry, entry) } ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classpath/entry_composite.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
202
```go package classpath import "archive/zip" import "errors" import "io/ioutil" import "path/filepath" type ZipEntry struct { absPath string zipRC *zip.ReadCloser } func newZipEntry(path string) *ZipEntry { absPath, err := filepath.Abs(path) if err != nil { panic(err) } return &ZipEntry{absPath, nil} } f...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classpath/entry_zip.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
374
```go package classpath import "os" import "path/filepath" import "strings" func newWildcardEntry(path string) CompositeEntry { baseDir := path[:len(path)-1] // remove * compositeEntry := []Entry{} walkFn := func(path string, info os.FileInfo, err error) error { if err != nil { return err } if info.IsDir...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classpath/entry_wildcard.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
168
```go package classpath import "io/ioutil" import "path/filepath" type DirEntry struct { absDir string } func newDirEntry(path string) *DirEntry { absDir, err := filepath.Abs(path) if err != nil { panic(err) } return &DirEntry{absDir} } func (self *DirEntry) readClass(className string) ([]byte, Entry, error)...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classpath/entry_dir.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
131
```go package classpath import "os" import "path/filepath" type Classpath struct { bootClasspath Entry extClasspath Entry userClasspath Entry } func Parse(jreOption, cpOption string) *Classpath { cp := &Classpath{} cp.parseBootAndExtClasspath(jreOption) cp.parseUserClasspath(cpOption) return cp } func (self...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classpath/classpath.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
476
```go package main import "flag" import "fmt" import "os" // java [-options] class [args...] type Cmd struct { helpFlag bool versionFlag bool cpOption string XjreOption string class string args []string } func parseCmd() *Cmd { cmd := &Cmd{} flag.Usage = printUsage flag.BoolVar(&cmd.hel...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/cmd.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
254
```go package classfile /* EnclosingMethod_attribute { u2 attribute_name_index; u4 attribute_length; u2 class_index; u2 method_index; } */ type EnclosingMethodAttribute struct { cp ConstantPool classIndex uint16 methodIndex uint16 } func (self *EnclosingMethodAttribute) readInfo(reader *C...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/attr_enclosing_method.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
170
```go package classfile /* field_info { u2 access_flags; u2 name_index; u2 descriptor_index; u2 attributes_count; attribute_info attributes[attributes_count]; } method_info { u2 access_flags; u2 name_index; u2 ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/member_info.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
326
```go package main import "fmt" import _ "jvmgo/ch04/classfile" import _ "jvmgo/ch04/classpath" import "jvmgo/ch04/rtda" func main() { cmd := parseCmd() if cmd.versionFlag { fmt.Println("version 0.0.1") } else if cmd.helpFlag || cmd.class == "" { printUsage() } else { startJVM(cmd) } } func startJVM(cmd ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/main.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
397
```go package classfile /* CONSTANT_MethodHandle_info { u1 tag; u1 reference_kind; u2 reference_index; } */ type ConstantMethodHandleInfo struct { referenceKind uint8 referenceIndex uint16 } func (self *ConstantMethodHandleInfo) readInfo(reader *ClassReader) { self.referenceKind = reader.readUint8() ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/cp_invoke_dynamic.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
241
```go package classfile /* BootstrapMethods_attribute { u2 attribute_name_index; u4 attribute_length; u2 num_bootstrap_methods; { u2 bootstrap_method_ref; u2 num_bootstrap_arguments; u2 bootstrap_arguments[num_bootstrap_arguments]; } bootstrap_methods[num_bootstrap_methods]; } */ ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/attr_bootstrap_methods.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
184
```go package classfile import "fmt" type ConstantPool []ConstantInfo func readConstantPool(reader *ClassReader) ConstantPool { cpCount := int(reader.readUint16()) cp := make([]ConstantInfo, cpCount) // The constant_pool table is indexed from 1 to constant_pool_count - 1. for i := 1; i < cpCount; i++ { cp[i] ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/constant_pool.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
421
```go package classfile /* Exceptions_attribute { u2 attribute_name_index; u4 attribute_length; u2 number_of_exceptions; u2 exception_index_table[number_of_exceptions]; } */ type ExceptionsAttribute struct { exceptionIndexTable []uint16 } func (self *ExceptionsAttribute) readInfo(reader *ClassReader)...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/attr_exceptions.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
104
```go package classfile /* LineNumberTable_attribute { u2 attribute_name_index; u4 attribute_length; u2 line_number_table_length; { u2 start_pc; u2 line_number; } line_number_table[line_number_table_length]; } */ type LineNumberTableAttribute struct { lineNumberTable []*LineNumberTableEn...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/attr_line_number_table.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
255
```go package classfile /* CONSTANT_NameAndType_info { u1 tag; u2 name_index; u2 descriptor_index; } */ type ConstantNameAndTypeInfo struct { nameIndex uint16 descriptorIndex uint16 } func (self *ConstantNameAndTypeInfo) readInfo(reader *ClassReader) { self.nameIndex = reader.readUint16() self.d...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/cp_name_and_type.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
88
```go package classfile /* Deprecated_attribute { u2 attribute_name_index; u4 attribute_length; } */ type DeprecatedAttribute struct { MarkerAttribute } /* Synthetic_attribute { u2 attribute_name_index; u4 attribute_length; } */ type SyntheticAttribute struct { MarkerAttribute } type MarkerAttribut...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/attr_markers.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
90
```go package classfile /* attribute_info { u2 attribute_name_index; u4 attribute_length; u1 info[attribute_length]; } */ type UnparsedAttribute struct { name string length uint32 info []byte } func (self *UnparsedAttribute) readInfo(reader *ClassReader) { self.info = reader.readBytes(self.length)...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/attr_unparsed.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
96
```go package classfile /* CONSTANT_Class_info { u1 tag; u2 name_index; } */ type ConstantClassInfo struct { cp ConstantPool nameIndex uint16 } func (self *ConstantClassInfo) readInfo(reader *ClassReader) { self.nameIndex = reader.readUint16() } func (self *ConstantClassInfo) Name() string { return...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/cp_class.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
90
```go package classfile // Constant pool tags 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...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/constant_info.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
468
```go package classfile import "math" /* CONSTANT_Integer_info { u1 tag; u4 bytes; } */ type ConstantIntegerInfo struct { val int32 } func (self *ConstantIntegerInfo) readInfo(reader *ClassReader) { bytes := reader.readUint32() self.val = int32(bytes) } func (self *ConstantIntegerInfo) Value() int32 { re...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/cp_numeric.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
341
```go package classfile /* SourceFile_attribute { u2 attribute_name_index; u4 attribute_length; u2 sourcefile_index; } */ type SourceFileAttribute struct { cp ConstantPool sourceFileIndex uint16 } func (self *SourceFileAttribute) readInfo(reader *ClassReader) { self.sourceFileIndex = reade...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/attr_source_file.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
101
```go package classfile import "fmt" /* ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/class_file.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
787
```go package classfile /* ConstantValue_attribute { u2 attribute_name_index; u4 attribute_length; u2 constantvalue_index; } */ type ConstantValueAttribute struct { constantValueIndex uint16 } func (self *ConstantValueAttribute) readInfo(reader *ClassReader) { self.constantValueIndex = reader.readUint16...
/content/code_sandbox/v1/code/go/src/jvmgo/ch04/classfile/attr_constant_value.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
95