| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
I have a Java Cocoa app, a timer, that depends on the system clock (System.currentTimeMillis()). It happens that when you awake from sleep, for the first few seconds (about 10 on my 400 MHz Pismo), the clock is in the past -- it ticks from the time it was put to sleep. And, then, suddenly, it jumps.
<snip>
I haven't done tons of JNI work, so here are my questions:
1. Is there a way to get an NSSelector inside the JVM and get it to an Obj-C @selector in native code?
2. Is it even possible to mix Obj-C code into the .jnilib?
3. Failing these, what's the recommended route for JVM callbacks using JNI? Am I better off using JDirect?
You can't use JDirect in a Cocoa application, so that's out.
I've found the IOKit hooks for sleep and wake, and have C code that works dandily with these. So now I just need a way to notify the Java code from the native code "hey, the system woke up" or "the system is going to sleep now", and then I can check to see whether we got any state changes while in never-never land and perform appropriate fixes if the clock jumps. But this seems a lot less obvious than calling C code from Java. Any help greatly appreciated!
| References: | |
| >JNI and NSSelector (From: "Nathan V. Roberts" <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.