当前位置: 首页>>代码示例>>Golang>>正文


Golang Frame.ClassLoader方法代码示例

本文整理汇总了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)
}
开发者ID:cretz,项目名称:jvm.go,代码行数:12,代码来源:Package.go

示例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)
}
开发者ID:cretz,项目名称:jvm.go,代码行数:14,代码来源:Class_static.go

示例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)
		}
	}
}
开发者ID:cretz,项目名称:jvm.go,代码行数:16,代码来源:Class.go

示例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)
}
开发者ID:cretz,项目名称:jvm.go,代码行数:16,代码来源:Perf.go

示例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())
}
开发者ID:cretz,项目名称:jvm.go,代码行数:20,代码来源:Class.go

示例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)
}
开发者ID:cretz,项目名称:jvm.go,代码行数:20,代码来源:FileSystem.go

示例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())
}
开发者ID:cretz,项目名称:jvm.go,代码行数:18,代码来源:Proxy.go

示例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)
	}
}
开发者ID:cretz,项目名称:jvm.go,代码行数:27,代码来源:Class_static.go


注:本文中的github.com/zxh0/jvm/go/jvmgo/jvm/rtda.Frame.ClassLoader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。