Пример #1
0
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
}
Пример #2
0
func jlSystemNotReady(thread *rtda.Thread) bool {
	sysClass := _classLoader.LoadClass("java/lang/System")
	propsField := sysClass.GetStaticField("props", "Ljava/util/Properties;")
	props := propsField.GetStaticValue()
	if props == nil {
		undoExec(thread)
		initSys := sysClass.GetStaticMethod("initializeSystemClass", "()V")
		thread.InvokeMethod(initSys)
		return true
	}
	return false
}