本文整理汇总了Golang中github.com/zxh0/jvm/go/jvmgo/jvm/rtda.Frame.ClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Golang Frame.ClassLoader方法的具体用法?Golang Frame.ClassLoader怎么用?Golang Frame.ClassLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zxh0/jvm/go/jvmgo/jvm/rtda.Frame
的用法示例。
在下文中一共展示了Frame.ClassLoader方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getSystemPackage0
// private static native String getSystemPackage0(String name);
// (Ljava/lang/String;)Ljava/lang/String;
func getSystemPackage0(frame *rtda.Frame) {
// vars := frame.LocalVars()
// name := vars.GetRef(0)
sysPkg := frame.ClassLoader().JLObjectClass().LoadedFrom().String()
sysPkgObj := rtda.JString(sysPkg)
stack := frame.OperandStack()
stack.PushRef(sysPkgObj)
}
示例2: getPrimitiveClass
// static native Class<?> getPrimitiveClass(String name);
// (Ljava/lang/String;)Ljava/lang/Class;
func getPrimitiveClass(frame *rtda.Frame) {
vars := frame.LocalVars()
nameObj := vars.GetRef(0)
name := rtda.GoString(nameObj)
classLoader := frame.ClassLoader()
class := classLoader.GetPrimitiveClass(name)
classObj := class.JClass()
stack := frame.OperandStack()
stack.PushRef(classObj)
}
示例3: getEnclosingMethod0
// private native Object[] getEnclosingMethod0();
// ()[Ljava/lang/Object;
func getEnclosingMethod0(frame *rtda.Frame) {
class := _popClass(frame)
if class.IsPrimitive() {
frame.OperandStack().PushNull()
} else {
emInfo := class.EnclosingMethod()
emInfoObj := _createEnclosintMethodInfo(frame.ClassLoader(), emInfo)
if emInfoObj == nil || rtc.ArrayLength(emInfoObj) == 0 {
frame.OperandStack().PushNull()
} else {
frame.OperandStack().PushRef(emInfoObj)
}
}
}
示例4: createLong
// public native ByteBuffer createLong(String name, int variability, int units, long value);
// (Ljava/lang/String;IIJ)Ljava/nio/ByteBuffer;
func createLong(frame *rtda.Frame) {
bbClass := frame.ClassLoader().LoadClass("java/nio/ByteBuffer")
if bbClass.InitializationNotStarted() {
frame.RevertNextPC()
frame.Thread().InitClass(bbClass)
return
}
stack := frame.OperandStack()
stack.PushInt(8)
allocate := bbClass.GetStaticMethod("allocate", "(I)Ljava/nio/ByteBuffer;")
frame.Thread().InvokeMethod(allocate)
}
示例5: getDeclaringClass0
// private native Class<?> getDeclaringClass0();
// ()Ljava/lang/Class;
func getDeclaringClass0(frame *rtda.Frame) {
class := _popClass(frame)
if class.IsArray() || class.IsPrimitive() {
frame.OperandStack().PushRef(nil)
return
}
lastDollerIndex := strings.LastIndex(class.Name(), "$")
if lastDollerIndex < 0 {
frame.OperandStack().PushRef(nil)
return
}
// todo
declaringClassName := class.Name()[:lastDollerIndex]
declaringClass := frame.ClassLoader().LoadClass(declaringClassName)
frame.OperandStack().PushRef(declaringClass.JClass())
}
示例6: getFileSystem
// public static native FileSystem getFileSystem()
// ()Ljava/io/FileSystem;
func getFileSystem(frame *rtda.Frame) {
thread := frame.Thread()
unixFsClass := frame.ClassLoader().LoadClass("java/io/UnixFileSystem")
if unixFsClass.InitializationNotStarted() {
frame.SetNextPC(thread.PC()) // undo getFileSystem
thread.InitClass(unixFsClass)
return
}
stack := frame.OperandStack()
unixFsObj := unixFsClass.NewObj()
stack.PushRef(unixFsObj)
// call <init>
stack.PushRef(unixFsObj) // this
constructor := unixFsClass.GetDefaultConstructor()
thread.InvokeMethod(constructor)
}
示例7: _loadClass
func _loadClass(frame *rtda.Frame) {
vars := frame.LocalVars()
//loader := vars.GetRef(0)
nameObj := vars.GetRef(1)
byteArr := vars.GetRef(2)
off := vars.GetInt(3)
_len := vars.GetInt(4)
name := rtda.GoString(nameObj)
name = rtc.DotToSlash(name)
data := byteArr.GoBytes()
data = data[off : off+_len]
// todo
class := frame.ClassLoader().DefineClass(name, data)
stack := frame.OperandStack()
stack.PushRef(class.JClass())
}
示例8: forName0
// private static native Class<?> forName0(String name, boolean initialize,
// ClassLoader loader,
// Class<?> caller)
// throws ClassNotFoundException;
// (Ljava/lang/String;ZLjava/lang/ClassLoader;Ljava/lang/Class;)Ljava/lang/Class;
func forName0(frame *rtda.Frame) {
vars := frame.LocalVars()
jName := vars.GetRef(0)
initialize := vars.GetBoolean(1)
//jLoader := vars.GetRef(2)
goName := rtda.GoString(jName)
goName = jutil.ReplaceAll(goName, ".", "/")
goClass := frame.ClassLoader().LoadClass(goName)
jClass := goClass.JClass()
if initialize && goClass.InitializationNotStarted() {
// undo forName0
thread := frame.Thread()
frame.SetNextPC(thread.PC())
// init class
thread.InitClass(goClass)
} else {
stack := frame.OperandStack()
stack.PushRef(jClass)
}
}