google / j2objc

A Java to iOS Objective-C translation tool and runtime.
http://j2objc.org
Apache License 2.0
5.99k stars 968 forks source link

dispatch_async and JavaLangThread: Assertion failed #341

Open redwarp opened 10 years ago

redwarp commented 10 years ago

I use GCD (grand central dispatch) in my app to dispatch so stuff in the background

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(queue, ^{ [[self getEngine] doStuff]; });

The thing is that in my doStuff, so code, converted with j2objc is executed, and at some point in this code, a JavaLangThread object is initiated. And every now and then, i get the following:

Assertion failed: (group != nil), function -[JavaLangThread createWithJavaLangThreadGroup:withJavaLangRunnable:withNSString:withLong:withBoolean:], file /Users/tball/tmp/moe_git_clone_github_7854296660712344514/jre_emul/build_result/Classes/java/lang/Thread.m, line 253.

When I say every know and then, I mean that the first time I call doStuff, it works, and the second time, I get the Assertion failed exception thingy.

I'm currently on j2obc 0.9, but I had this problem also with j2objc 0.8.1

foens commented 10 years ago

I can confirm that I have also hit the assertion (group != nil) in j2objc 0.9.3. Mine happens in line 666 in Thread.m.

I also have code running with GCD in the background, and I also create a new thread down there somewhere. It seems to happen every time.

I have tested this on two simulators, iPhone 6 and iPhone 4S.