本文整理汇总了Golang中github.com/zxh0/jvm/go/jvmgo/rtda.GoString函数的典型用法代码示例。如果您正苦于以下问题:Golang GoString函数的具体用法?Golang GoString怎么用?Golang GoString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GoString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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)
}
示例2: raf_open
// private native void open(String name, int mode) throws FileNotFoundException;
// (Ljava/lang/String;)V
func raf_open(frame *rtda.Frame) {
vars := frame.LocalVars()
this := vars.GetThis()
name := vars.GetRef(1)
mode := vars.GetInt(2) //flag
flag := 0
if mode&1 > 0 {
flag |= os.O_RDONLY
}
//write
if mode&2 > 0 {
flag |= os.O_RDWR | os.O_CREATE
}
if mode&4 > 0 {
flag |= os.O_SYNC | os.O_CREATE
}
if mode&8 > 0 {
//TODO:O_DSYNC
flag |= os.O_SYNC | os.O_CREATE
}
goName := rtda.GoString(name)
if goFile, err := os.OpenFile(goName, flag, 0660); err != nil {
frame.Thread().ThrowFileNotFoundException(goName)
} else {
this.SetExtra(goFile)
}
}
示例3: i6di_lookupAllHostAddr
//(Ljava/lang/String;)[Ljava/net/InetAddress;
func i6di_lookupAllHostAddr(frame *rtda.Frame) {
vars := frame.LocalVars()
host := rtda.GoString(vars.GetRef(1))
address, _ := net.LookupHost(host)
constructorCount := uint(len(address))
inetAddress := heap.BootLoader().LoadClass("java/net/InetAddress")
inetAddressArr := inetAddress.NewArray(constructorCount)
stack := frame.OperandStack()
stack.PushRef(inetAddressArr)
//TODO
//getByName descriptor:(Ljava/lang/String;)Ljava/net/InetAddress;
//if constructorCount > 0 {
// thread := frame.Thread()
// constructorObjs := inetAddressArr.Refs()
// inetAddressGetByNameMethod := inetAddress.GetStaticMethod("getByName", "(Ljava/lang/String;)Ljava/net/InetAddress;")
// fmt.Println(constructorObjs[0])
// fmt.Println(inetAddressGetByNameMethod)
// fmt.Println(thread)
// thread.InvokeMethodWithShim(inetAddressGetByNameMethod, []interface{}{
// constructorObjs[0],
// rtda.JString(host),
// })
//}
}
示例4: intern
// public native String intern();
// ()Ljava/lang/String;
func intern(frame *rtda.Frame) {
vars := frame.LocalVars()
jStr := vars.GetThis()
goStr := rtda.GoString(jStr)
internedStr := rtda.InternString(goStr, jStr)
stack := frame.OperandStack()
stack.PushRef(internedStr)
}
示例5: 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)
}
示例6: open
// private static native long open(String name, int mode, long lastModified,
// boolean usemmap) throws IOException;
// (Ljava/lang/String;IJZ)J
func open(frame *rtda.Frame) {
vars := frame.LocalVars()
nameObj := vars.GetRef(0)
name := rtda.GoString(nameObj)
jzfile, err := openZip(name)
if err != nil {
// todo
panic("IOException!" + err.Error())
}
stack := frame.OperandStack()
stack.PushLong(jzfile)
}
示例7: open
// private native void open(String name) throws FileNotFoundException;
// (Ljava/lang/String;)V
func open(frame *rtda.Frame) {
vars := frame.LocalVars()
this := vars.GetThis()
name := vars.GetRef(1)
goName := rtda.GoString(name)
goFile, err := os.Open(goName)
if err != nil {
frame.Thread().ThrowFileNotFoundException(goName)
return
}
this.SetExtra(goFile)
}
示例8: 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)
}
示例9: net_bind0
// private static native void bind0(FileDescriptor fd, boolean preferIPv6, boolean useExclBind, InetAddress addr,int port)
func net_bind0(frame *rtda.Frame) {
vars := frame.LocalVars()
this := vars.GetThis()
address := vars.GetRef(3)
port := vars.Get(4)
holder := address.GetFieldValue("holder", "Ljava/net/InetAddress$InetAddressHolder;").(*heap.Object)
hostNameObj := holder.GetFieldValue("hostName", "Ljava/lang/String;").(*heap.Object)
hostName := rtda.GoString(hostNameObj)
laddr := fmt.Sprintf("%s:%d", hostName, port)
listen, err := net.Listen("tcp", laddr)
if err != nil {
frame.Thread().ThrowIOException(err.Error())
}
this.SetExtra(listen)
}
示例10: findBootstrapClass
// private native Class<?> findBootstrapClass(String name);
// (Ljava/lang/String;)Ljava/lang/Class;
func findBootstrapClass(frame *rtda.Frame) {
vars := frame.LocalVars()
//this := vars.GetThis()
name := vars.GetRef(1)
className := rtc.DotToSlash(rtda.GoString(name))
class := rtc.BootLoader().LoadClass(className)
// todo: init class?
stack := frame.OperandStack()
stack.PushRef(class.JClass())
// todo
if r := recover(); r != nil {
frame.OperandStack().PushRef(nil)
}
}
示例11: defineClass1
// private native Class<?> defineClass1(String name, byte[] b, int off, int len,
// ProtectionDomain pd, String source);
// (Ljava/lang/String;[BIILjava/security/ProtectionDomain;Ljava/lang/String;)Ljava/lang/Class;
func defineClass1(frame *rtda.Frame) {
vars := frame.LocalVars()
this := vars.GetThis()
name := vars.GetRef(1)
byteArr := vars.GetRef(2)
off := vars.GetInt(3)
_len := vars.GetInt(4)
// pd := vars.GetRef(5)
// source := vars.GetRef(6)
goBytes := byteArr.GoBytes()
goBytes = goBytes[off : off+_len]
println(this.Extra())
panic(rtda.GoString(name))
}
示例12: _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 = heap.DotToSlash(name)
data := byteArr.GoBytes()
data = data[off : off+_len]
// todo
class := frame.ClassLoader().DefineClass(name, data)
stack := frame.OperandStack()
stack.PushRef(class.JClass())
}
示例13: findLoadedClass0
// private native final Class<?> findLoadedClass0(String name);
// (Ljava/lang/String;)Ljava/lang/Class;
func findLoadedClass0(frame *rtda.Frame) {
vars := frame.LocalVars()
this := vars.GetThis()
name := vars.GetRef(1)
className := rtc.DotToSlash(rtda.GoString(name))
if isAppClassLoader(this) {
class := rtc.BootLoader().FindLoadedClass(className)
if class != nil {
frame.OperandStack().PushRef(class.JClass())
} else {
frame.OperandStack().PushRef(nil)
}
return
}
// todo
frame.OperandStack().PushRef(nil)
}
示例14: 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)
}
}
示例15: _getPath
func _getPath(fileObj *rtc.Obj) string {
pathStr := fileObj.GetFieldValue("path", "Ljava/lang/String;").(*rtc.Obj)
return rtda.GoString(pathStr)
}