100 101 @end 102 103 @interface JavaRunnable : NSObject { } 104 @property jobject runnable; 105 - (id)initWithRunnable:(jobject)gRunnable; 106 - (void)perform; 107 @end 108 109 @implementation JavaRunnable 110 @synthesize runnable = _runnable; 111 112 - (id)initWithRunnable:(jobject)gRunnable { 113 if (self = [super init]) { 114 self.runnable = gRunnable; 115 } 116 return self; 117 } 118 119 - (void)dealloc { 120 JNIEnv *env = [ThreadUtilities getJNIEnv]; 121 if (self.runnable) { 122 (*env)->DeleteGlobalRef(env, self.runnable); 123 } 124 [super dealloc]; 125 } 126 127 - (void)perform { 128 JNIEnv* env = [ThreadUtilities getJNIEnv]; 129 static JNF_CLASS_CACHE(sjc_Runnable, "java/lang/Runnable"); 130 static JNF_MEMBER_CACHE(jm_Runnable_run, sjc_Runnable, "run", "()V"); 131 JNFCallVoidMethod(env, self.runnable, jm_Runnable_run); 132 [self release]; 133 } 134 @end 135 136 void setBusy(BOOL busy) { 137 AWT_ASSERT_APPKIT_THREAD; 138 139 JNIEnv *env = [ThreadUtilities getJNIEnv]; 140 static JNF_CLASS_CACHE(jc_AWTAutoShutdown, "sun/awt/AWTAutoShutdown"); 141 142 if (busy) { 143 static JNF_STATIC_MEMBER_CACHE(jm_notifyBusyMethod, jc_AWTAutoShutdown, "notifyToolkitThreadBusy", "()V"); 144 JNFCallStaticVoidMethod(env, jm_notifyBusyMethod); 145 } else { 146 static JNF_STATIC_MEMBER_CACHE(jm_notifyFreeMethod, jc_AWTAutoShutdown, "notifyToolkitThreadFree", "()V"); 147 JNFCallStaticVoidMethod(env, jm_notifyFreeMethod); 148 } | 100 101 @end 102 103 @interface JavaRunnable : NSObject { } 104 @property jobject runnable; 105 - (id)initWithRunnable:(jobject)gRunnable; 106 - (void)perform; 107 @end 108 109 @implementation JavaRunnable 110 @synthesize runnable = _runnable; 111 112 - (id)initWithRunnable:(jobject)gRunnable { 113 if (self = [super init]) { 114 self.runnable = gRunnable; 115 } 116 return self; 117 } 118 119 - (void)dealloc { 120 JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; 121 if (self.runnable) { 122 (*env)->DeleteGlobalRef(env, self.runnable); 123 } 124 [super dealloc]; 125 } 126 127 - (void)perform { 128 JNIEnv* env = [ThreadUtilities getJNIEnvUncached]; 129 static JNF_CLASS_CACHE(sjc_Runnable, "java/lang/Runnable"); 130 static JNF_MEMBER_CACHE(jm_Runnable_run, sjc_Runnable, "run", "()V"); 131 JNFCallVoidMethod(env, self.runnable, jm_Runnable_run); 132 [self release]; 133 } 134 @end 135 136 void setBusy(BOOL busy) { 137 AWT_ASSERT_APPKIT_THREAD; 138 139 JNIEnv *env = [ThreadUtilities getJNIEnv]; 140 static JNF_CLASS_CACHE(jc_AWTAutoShutdown, "sun/awt/AWTAutoShutdown"); 141 142 if (busy) { 143 static JNF_STATIC_MEMBER_CACHE(jm_notifyBusyMethod, jc_AWTAutoShutdown, "notifyToolkitThreadBusy", "()V"); 144 JNFCallStaticVoidMethod(env, jm_notifyBusyMethod); 145 } else { 146 static JNF_STATIC_MEMBER_CACHE(jm_notifyFreeMethod, jc_AWTAutoShutdown, "notifyToolkitThreadFree", "()V"); 147 JNFCallStaticVoidMethod(env, jm_notifyFreeMethod); 148 } |