-
Notifications
You must be signed in to change notification settings - Fork 2
/
Object.go
42 lines (36 loc) · 1.11 KB
/
Object.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package lang
import "unsafe"
import "../../../native"
import "../../../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/Object;", clone)
}
// public final native Class<?> getClass();
// ()Ljava/lang/Class;
func getClass(frame *rtda.Frame) {
this := frame.LocalVars().GetThis()
class := this.Class().JClass()
frame.OperandStack().PushRef(class)
}
// public native int hashCode();
// ()I
func hashCode(frame *rtda.Frame) {
this := frame.LocalVars().GetThis()
hash := int32(uintptr(unsafe.Pointer(this)))
frame.OperandStack().PushInt(hash)
}
// protected native Object clone() throws CloneNotSupportedException;
// ()Ljava/lang/Object;
//func clone(frame *rtda.Frame) {
// this := frame.LocalVars().GetThis()
//
// cloneable := this.Class().Loader().LoadClass("java/lang/Cloneable")
// if !this.Class().IsImplements(cloneable) {
// panic("java.lang.CloneNotSupportedException")
// }
//
// frame.OperandStack().PushRef(this.Clone())
//}