• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang rtda.JString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/zxh0/jvm/go/jvmgo/rtda.JString函数的典型用法代码示例。如果您正苦于以下问题:Golang JString函数的具体用法?Golang JString怎么用?Golang JString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了JString函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: i6di_getHostByAddr

//([B)Ljava/lang/String;
//String getHostByAddr(byte[] var1) throws UnknownHostException
func i6di_getHostByAddr(frame *rtda.Frame) {
	vars := frame.LocalVars()
	t := vars.GetRef(1)
	buf := t.GoBytes()
	address := fmt.Sprintf("%d.%d.%d.%d", buf[0], buf[1], buf[2], buf[3])
	if name, err := net.LookupAddr(address); err == nil {
		frame.OperandStack().PushRef(rtda.JString(name[0]))
	} else {
		panic("not found from lookupAllHostAddr")
		frame.OperandStack().PushRef(rtda.JString(""))
	}
}
开发者ID:Rearcher,项目名称:jvm.go,代码行数:14,代码来源:Inet6AddressImpl.go


示例2: getUTF8At0

// private native String getUTF8At0(Object o, int i);
// (Ljava/lang/Object;I)Ljava/lang/String;
func getUTF8At0(frame *rtda.Frame) {
	cp, index := _getPop(frame)
	kUtf8 := cp.GetConstant(index).(*rtc.ConstantUtf8)
	goStr := kUtf8.Str()
	jStr := rtda.JString(goStr)
	frame.OperandStack().PushRef(jStr)
}
开发者ID:zaishihuang,项目名称:jvm.go,代码行数:9,代码来源:ConstantPool.go


示例3: getSystemTimeZoneID

// private static native String getSystemTimeZoneID(String javaHome, String country);
// (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
func getSystemTimeZoneID(frame *rtda.Frame) {
	vars := frame.LocalVars()
	//javaHomeObj := vars.GetRef(0)
	countryObj := vars.GetRef(1)

	//for osx read system timezone
	file, err := os.Open("/usr/share/zoneinfo/zone.tab")

	if err != nil {
		panic(err)
	}

	scanner := bufio.NewScanner(file)
	var timezone string
	for scanner.Scan() {
		line := scanner.Text()
		if line[0] == '#' {
			continue
		}
		zone := strings.Split(line, "\t")
		if zone[0] == rtda.GoString(countryObj) {
			timezone = zone[2]
			break
		}
	}

	location, _ := time.LoadLocation(timezone)
	zoneID := rtda.JString(location.String())
	stack := frame.OperandStack()
	stack.PushRef(zoneID)
}
开发者ID:b-xiang,项目名称:jvm.go,代码行数:33,代码来源:TimeZone.go


示例4: mainThreadNotReady

func mainThreadNotReady(thread *rtda.Thread) bool {
	stack := thread.CurrentFrame().OperandStack()
	if _mainThreadGroup == nil {
		undoExec(thread)
		threadGroupClass := _classLoader.LoadClass("java/lang/ThreadGroup")
		_mainThreadGroup = threadGroupClass.NewObj()
		initMethod := threadGroupClass.GetConstructor("()V")
		stack.PushRef(_mainThreadGroup) // this
		thread.InvokeMethod(initMethod)
		return true
	}
	if thread.JThread() == nil {
		undoExec(thread)
		threadClass := _classLoader.LoadClass("java/lang/Thread")
		mainThreadObj := threadClass.NewObjWithExtra(thread)
		mainThreadObj.SetFieldValue("priority", "I", int32(1))
		thread.HackSetJThread(mainThreadObj)

		initMethod := threadClass.GetConstructor("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V")
		stack.PushRef(mainThreadObj)        // this
		stack.PushRef(_mainThreadGroup)     // group
		stack.PushRef(rtda.JString("main")) // name
		thread.InvokeMethod(initMethod)
		return true
	}
	return false
}
开发者ID:kingljl,项目名称:jvm.go,代码行数:27,代码来源:bootstrap.go


示例5: getVersion0

// private static native String getVersion0();
// ()Ljava/lang/String;
func getVersion0(frame *rtda.Frame) {
	// todo
	version := rtda.JString("0")

	stack := frame.OperandStack()
	stack.PushRef(version)
}
开发者ID:Rearcher,项目名称:jvm.go,代码行数:9,代码来源:VMManagementImpl.go


示例6: getName0

// private native String getName0();
// ()Ljava/lang/String;
func getName0(frame *rtda.Frame) {
	class := _popClass(frame)
	name := class.NameJlsFormat()
	nameObj := rtda.JString(name)

	stack := frame.OperandStack()
	stack.PushRef(nameObj)
}
开发者ID:zaishihuang,项目名称:jvm.go,代码行数:10,代码来源:Class.go


示例7: initProperties

// private static native Properties initProperties(Properties props);
// (Ljava/util/Properties;)Ljava/util/Properties;
func initProperties(frame *rtda.Frame) {
	vars := frame.LocalVars()
	props := vars.GetRef(0)

	stack := frame.OperandStack()
	stack.PushRef(props)

	// public synchronized Object setProperty(String key, String value)
	setPropMethod := props.Class().GetInstanceMethod("setProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;")
	thread := frame.Thread()
	for key, val := range _sysProps() {
		jKey := rtda.JString(key)
		jVal := rtda.JString(val)
		args := []interface{}{props, jKey, jVal}
		thread.InvokeMethodWithShim(setPropMethod, args)
	}
}
开发者ID:zaishihuang,项目名称:jvm.go,代码行数:19,代码来源:System.go


示例8: createArgs

func createArgs() *heap.Object {
	jArgs := make([]*heap.Object, len(_args))
	for i, arg := range _args {
		jArgs[i] = rtda.JString(arg)
	}

	return heap.NewRefArray2(_classLoader.JLStringClass(), jArgs)
}
开发者ID:kingljl,项目名称:jvm.go,代码行数:8,代码来源:bootstrap.go


示例9: _createEnclosintMethodInfo

func _createEnclosintMethodInfo(classLoader *rtc.ClassLoader, emInfo *rtc.EnclosingMethod) *rtc.Obj {
	if emInfo == nil {
		return nil
	}

	enclosingClass := classLoader.LoadClass(emInfo.ClassName())
	enclosingClassObj := enclosingClass.JClass()
	var methodNameObj, methodDescriptorObj *rtc.Obj
	if emInfo.MethodName() != "" {
		methodNameObj = rtda.JString(emInfo.MethodName())
		methodDescriptorObj = rtda.JString(emInfo.MethodDescriptor())
	} else {
		methodNameObj, methodDescriptorObj = nil, nil
	}

	objs := []*rtc.Obj{enclosingClassObj, methodNameObj, methodDescriptorObj}
	return rtc.NewRefArray2(classLoader.JLObjectClass(), objs) // Object[]
}
开发者ID:zaishihuang,项目名称:jvm.go,代码行数:18,代码来源:Class.go


示例10: 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:zaishihuang,项目名称:jvm.go,代码行数:12,代码来源:Package.go


示例11: createStackTraceElementObj

func createStackTraceElementObj(ste *StackTraceElement, frame *rtda.Frame) *heap.Object {
	declaringClass := rtda.JString(ste.declaringClass)
	methodName := rtda.JString(ste.methodName)
	fileName := rtda.JString(ste.fileName)
	lineNumber := int32(ste.lineNumber)

	/*
	   public StackTraceElement(String declaringClass, String methodName,
	           String fileName, int lineNumber)
	*/
	steClass := frame.ClassLoader().LoadClass("java/lang/StackTraceElement")
	steObj := steClass.NewObj()
	// todo: call <init>
	steObj.SetFieldValue("declaringClass", "Ljava/lang/String;", declaringClass)
	steObj.SetFieldValue("methodName", "Ljava/lang/String;", methodName)
	steObj.SetFieldValue("fileName", "Ljava/lang/String;", fileName)
	steObj.SetFieldValue("lineNumber", "I", lineNumber)

	return steObj
}
开发者ID:Rearcher,项目名称:jvm.go,代码行数:20,代码来源:Throwable.go


示例12: canonicalize0

// private native String canonicalize0(String path) throws IOException;
// (Ljava/lang/String;)Ljava/lang/String;
func canonicalize0(frame *rtda.Frame) {
	vars := frame.LocalVars()
	pathStr := vars.GetRef(1)

	// todo
	path := rtda.GoString(pathStr)
	path2 := filepath.Clean(path)
	if path2 != path {
		pathStr = rtda.JString(path2)
	}

	stack := frame.OperandStack()
	stack.PushRef(pathStr)
}
开发者ID:zaishihuang,项目名称:jvm.go,代码行数:16,代码来源:UnixFileSystem.go


示例13: getGenericSignature0

// private native String getGenericSignature0();
// ()Ljava/lang/String;
func getGenericSignature0(frame *rtda.Frame) {
	class := _popClass(frame)
	if class == nil {
		panic("illegal class")
	}

	// Return null for arrays and primatives
	if !class.IsPrimitive() {
		signature := class.Signature()
		if signature == "" {
			frame.OperandStack().PushNull()
		} else {
			frame.OperandStack().PushRef(rtda.JString(signature))
		}
		return
	}

	frame.OperandStack().PushNull()
}
开发者ID:zaishihuang,项目名称:jvm.go,代码行数:21,代码来源:Class.go


示例14: getDeclaredMethods0

// private native Method[] getDeclaredMethods0(boolean publicOnly);
// (Z)[Ljava/lang/reflect/Method;
func getDeclaredMethods0(frame *rtda.Frame) {
	vars := frame.LocalVars()
	classObj := vars.GetThis()
	publicOnly := vars.GetBoolean(1)

	class := classObj.Extra().(*rtc.Class)
	methods := class.GetMethods(publicOnly)
	methodCount := uint(len(methods))

	methodClass := rtc.BootLoader().LoadClass("java/lang/reflect/Method")
	methodArr := methodClass.NewArray(methodCount)

	stack := frame.OperandStack()
	stack.PushRef(methodArr)

	// create method objs
	if methodCount > 0 {
		thread := frame.Thread()
		methodObjs := methodArr.Refs()
		methodConstructor := methodClass.GetConstructor(_methodConstructorDescriptor)
		for i, method := range methods {
			methodObj := methodClass.NewObjWithExtra(method)
			methodObjs[i] = methodObj

			// init methodObj
			thread.InvokeMethodWithShim(methodConstructor, []interface{}{
				methodObj,                                              // this
				classObj,                                               // declaringClass
				rtda.JString(method.Name()),                            // name
				getParameterTypeArr(method),                            // parameterTypes
				getReturnType(method),                                  // returnType
				getExceptionTypeArr(method),                            // checkedExceptions
				int32(method.GetAccessFlags()),                         // modifiers
				int32(method.Slot()),                                   // slot
				getSignatureStr(method.Signature()),                    // signature
				getAnnotationByteArr(method.AnnotationData()),          // annotations
				getAnnotationByteArr(method.ParameterAnnotationData()), // parameterAnnotations
				getAnnotationByteArr(method.AnnotationDefaultData()),   // annotationDefault
			})
		}
	}
}
开发者ID:zaishihuang,项目名称:jvm.go,代码行数:44,代码来源:Class_getDeclaredMethods0.go


示例15: _ldc

func _ldc(frame *rtda.Frame, index uint) {
	stack := frame.OperandStack()
	cp := frame.ConstantPool()
	c := cp.GetConstant(index)

	switch c.(type) {
	case int32:
		stack.PushInt(c.(int32))
	case float32:
		stack.PushFloat(c.(float32))
	case string:
		internedStr := rtda.JString(c.(string))
		stack.PushRef(internedStr)
	case *heap.ConstantClass:
		kClass := c.(*heap.ConstantClass)
		classObj := kClass.Class().JClass()
		stack.PushRef(classObj)
	default:
		// todo
		// ref to MethodType or MethodHandle
		jutil.Panicf("todo: ldc! %v", c)
	}
}
开发者ID:kingljl,项目名称:jvm.go,代码行数:23,代码来源:ldc.go


示例16: getDeclaredFields0

// private native Field[] getDeclaredFields0(boolean publicOnly);
// (Z)[Ljava/lang/reflect/Field;
func getDeclaredFields0(frame *rtda.Frame) {
	vars := frame.LocalVars()
	classObj := vars.GetThis()
	publicOnly := vars.GetBoolean(1)

	class := classObj.Extra().(*heap.Class)
	fields := class.GetFields(publicOnly)
	fieldCount := uint(len(fields))

	fieldClass := heap.BootLoader().LoadClass("java/lang/reflect/Field")
	fieldArr := heap.NewRefArray(fieldClass, fieldCount)

	stack := frame.OperandStack()
	stack.PushRef(fieldArr)

	if fieldCount > 0 {
		thread := frame.Thread()
		fieldObjs := fieldArr.Refs()
		fieldConstructor := fieldClass.GetConstructor(_fieldConstructorDescriptor)
		for i, goField := range fields {
			fieldObj := fieldClass.NewObjWithExtra(goField)
			fieldObjs[i] = fieldObj

			// init fieldObj
			thread.InvokeMethodWithShim(fieldConstructor, []interface{}{
				fieldObj,                                       // this
				classObj,                                       // declaringClass
				rtda.JString(goField.Name()),                   // name
				goField.Type().JClass(),                        // type
				int32(goField.GetAccessFlags()),                // modifiers
				int32(goField.SlotId()),                        // slot
				getSignatureStr(goField.Signature()),           // signature
				getAnnotationByteArr(goField.AnnotationData()), // annotations
			})
		}
	}
}
开发者ID:Rearcher,项目名称:jvm.go,代码行数:39,代码来源:Class_getDeclaredFields0.go


示例17: getSignatureStr

func getSignatureStr(signature string) *heap.Object {
	if signature != "" {
		return rtda.JString(signature)
	}
	return nil
}
开发者ID:kingljl,项目名称:jvm.go,代码行数:6,代码来源:Class_helper.go


示例18: getSignatureStr

func getSignatureStr(signature string) *rtc.Obj {
	if signature != "" {
		return rtda.JString(signature)
	}
	return nil
}
开发者ID:zaishihuang,项目名称:jvm.go,代码行数:6,代码来源:Class_helper.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang rtda.Frame类代码示例发布时间:2022-05-28
下一篇:
Golang rtda.GoString函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap