提交 95dff3b9 编写于 作者: D dbuck

8022291: Mac OS: Unexpected JavaLaunchHelper message displaying

Reviewed-by: serb, ksrini
上级 916bcfda
...@@ -1004,32 +1004,6 @@ SetXStartOnFirstThreadArg() ...@@ -1004,32 +1004,6 @@ SetXStartOnFirstThreadArg()
setenv(envVar, "1", 1); setenv(envVar, "1", 1);
} }
/* This class is made for performSelectorOnMainThread when java main
* should be launched on main thread.
* We cannot use dispatch_sync here, because it blocks the main dispatch queue
* which is used inside Cocoa
*/
@interface JavaLaunchHelper : NSObject {
int _returnValue;
}
- (void) launchJava:(NSValue*)argsValue;
- (int) getReturnValue;
@end
@implementation JavaLaunchHelper
- (void) launchJava:(NSValue*)argsValue
{
_returnValue = JavaMain([argsValue pointerValue]);
}
- (int) getReturnValue
{
return _returnValue;
}
@end
// MacOSX we may continue in the same thread // MacOSX we may continue in the same thread
int int
JVMInit(InvocationFunctions* ifn, jlong threadStackSize, JVMInit(InvocationFunctions* ifn, jlong threadStackSize,
...@@ -1039,20 +1013,26 @@ JVMInit(InvocationFunctions* ifn, jlong threadStackSize, ...@@ -1039,20 +1013,26 @@ JVMInit(InvocationFunctions* ifn, jlong threadStackSize,
JLI_TraceLauncher("In same thread\n"); JLI_TraceLauncher("In same thread\n");
// need to block this thread against the main thread // need to block this thread against the main thread
// so signals get caught correctly // so signals get caught correctly
JavaMainArgs args; __block int rslt = 0;
args.argc = argc;
args.argv = argv;
args.mode = mode;
args.what = what;
args.ifn = *ifn;
int rslt;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
{ {
JavaLaunchHelper* launcher = [[[JavaLaunchHelper alloc] init] autorelease]; NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock: ^{
[launcher performSelectorOnMainThread:@selector(launchJava:) JavaMainArgs args;
withObject:[NSValue valueWithPointer:(void*)&args] args.argc = argc;
waitUntilDone:YES]; args.argv = argv;
rslt = [launcher getReturnValue]; args.mode = mode;
args.what = what;
args.ifn = *ifn;
rslt = JavaMain(&args);
}];
/*
* We cannot use dispatch_sync here, because it blocks the main dispatch queue.
* Using the main NSRunLoop allows the dispatch queue to run properly once
* SWT (or whatever toolkit this is needed for) kicks off it's own NSRunLoop
* and starts running.
*/
[op performSelectorOnMainThread:@selector(start) withObject:nil waitUntilDone:YES];
} }
[pool drain]; [pool drain];
return rslt; return rslt;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册