Mercurial > hg > openjdk > icedtea > jdk7 > jdk
changeset 5429:2a08d45743f4
Merge
author | lana |
---|---|
date | Fri, 22 Jun 2012 10:06:23 -0700 |
parents | e29190d52ead (current diff) f1e9d1264ce6 (diff) |
children | 61a496db0378 |
files | |
diffstat | 10 files changed, 100 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/LWCToolkit.m Thu Jun 21 19:27:09 2012 -0700 +++ b/src/macosx/native/sun/awt/LWCToolkit.m Fri Jun 22 10:06:23 2012 -0700 @@ -33,6 +33,7 @@ #import "ThreadUtilities.h" #import "AWT_debug.h" #import "CSystemColors.h" +#import "NSApplicationAWT.h" #import "sun_lwawt_macosx_LWCToolkit.h" @@ -47,7 +48,7 @@ return eventCount; } -+ (void) eventCountPlusPlus{ ++ (void) eventCountPlusPlus{ eventCount++; } @@ -79,7 +80,6 @@ @end - /* * Class: sun_lwawt_macosx_LWCToolkit * Method: nativeSyncQueue @@ -90,12 +90,22 @@ { int currentEventNum = [AWTToolkit getEventCount]; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){}]; - + NSApplication* sharedApp = [NSApplication sharedApplication]; + if ([sharedApp isKindOfClass:[NSApplicationAWT class]]) { + NSApplicationAWT* theApp = (NSApplicationAWT*)sharedApp; + [theApp postDummyEvent]; + [theApp waitForDummyEvent]; + } else { + // could happen if we are embedded inside SWT application, + // in this case just spin a single empty block through + // the event loop to give it a chance to process pending events + [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){}]; + } + if (([AWTToolkit getEventCount] - currentEventNum) != 0) { return JNI_TRUE; } - + return JNI_FALSE; }
--- a/src/macosx/native/sun/awt/awt.m Thu Jun 21 19:27:09 2012 -0700 +++ b/src/macosx/native/sun/awt/awt.m Fri Jun 22 10:06:23 2012 -0700 @@ -70,33 +70,35 @@ JNIEnv *env = [ThreadUtilities getJNIEnv]; - // Add CFRunLoopObservers to call into AWT so that AWT knows that the - // AWT thread (which is the AppKit main thread) is alive. This way AWT - // will not automatically shutdown. - busyObserver = CFRunLoopObserverCreate( - NULL, // CFAllocator - kCFRunLoopAfterWaiting, // CFOptionFlags - true, // repeats - NSIntegerMax, // order - &BusyObserver, // CFRunLoopObserverCallBack - NULL); // CFRunLoopObserverContext + if (!headless) { + // Add CFRunLoopObservers to call into AWT so that AWT knows that the + // AWT thread (which is the AppKit main thread) is alive. This way AWT + // will not automatically shutdown. + busyObserver = CFRunLoopObserverCreate( + NULL, // CFAllocator + kCFRunLoopAfterWaiting, // CFOptionFlags + true, // repeats + NSIntegerMax, // order + &BusyObserver, // CFRunLoopObserverCallBack + NULL); // CFRunLoopObserverContext - notBusyObserver = CFRunLoopObserverCreate( - NULL, // CFAllocator - kCFRunLoopBeforeWaiting, // CFOptionFlags - true, // repeats - NSIntegerMin, // order - &NotBusyObserver, // CFRunLoopObserverCallBack - NULL); // CFRunLoopObserverContext + notBusyObserver = CFRunLoopObserverCreate( + NULL, // CFAllocator + kCFRunLoopBeforeWaiting, // CFOptionFlags + true, // repeats + NSIntegerMin, // order + &NotBusyObserver, // CFRunLoopObserverCallBack + NULL); // CFRunLoopObserverContext - CFRunLoopRef runLoop = [[NSRunLoop currentRunLoop] getCFRunLoop]; - CFRunLoopAddObserver(runLoop, busyObserver, kCFRunLoopDefaultMode); - CFRunLoopAddObserver(runLoop, notBusyObserver, kCFRunLoopDefaultMode); + CFRunLoopRef runLoop = [[NSRunLoop currentRunLoop] getCFRunLoop]; + CFRunLoopAddObserver(runLoop, busyObserver, kCFRunLoopDefaultMode); + CFRunLoopAddObserver(runLoop, notBusyObserver, kCFRunLoopDefaultMode); - CFRelease(busyObserver); - CFRelease(notBusyObserver); + CFRelease(busyObserver); + CFRelease(notBusyObserver); - if (!headless) setBusy(YES); + setBusy(YES); + } // Set the java name of the AppKit main thread appropriately. jclass threadClass = NULL;
--- a/src/macosx/native/sun/osxapp/NSApplicationAWT.h Thu Jun 21 19:27:09 2012 -0700 +++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.h Fri Jun 22 10:06:23 2012 -0700 @@ -28,13 +28,16 @@ @interface NSApplicationAWT : NSApplication { NSString *fApplicationName; - BOOL fUseDefaultIcon; NSWindow *eventTransparentWindow; + NSTimeInterval dummyEventTimestamp; + NSConditionLock* seenDummyEventLock; } - (void) finishLaunching; - (void) registerWithProcessManager; - (void) setDockIconWithEnv:(JNIEnv *)env; +- (void) postDummyEvent; +- (void) waitForDummyEvent; + (void) runAWTLoopWithApp:(NSApplication*)app;
--- a/src/macosx/native/sun/osxapp/NSApplicationAWT.m Thu Jun 21 19:27:09 2012 -0700 +++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.m Fri Jun 22 10:06:23 2012 -0700 @@ -32,7 +32,6 @@ #import "ThreadUtilities.h" #import "QueuingApplicationDelegate.h" - static BOOL sUsingDefaultNIB = YES; static NSString *SHARED_FRAMEWORK_BUNDLE = @"/System/Library/Frameworks/JavaVM.framework"; static id <NSApplicationDelegate> applicationDelegate = nil; @@ -52,7 +51,8 @@ AWT_ASSERT_APPKIT_THREAD; fApplicationName = nil; - fUseDefaultIcon = NO; + dummyEventTimestamp = 0.0; + seenDummyEventLock = nil; // NSApplication will call _RegisterApplication with the application's bundle, but there may not be one. // So, we need to call it ourselves to ensure the app is set up properly. @@ -147,10 +147,6 @@ if (appName != NULL) { fApplicationName = [NSString stringWithUTF8String:appName]; unsetenv(envVar); - - // If this environment variable was set we were launched from the command line, so we - // should use a generic app icon if one wasn't set. - fUseDefaultIcon = YES; } // If it wasn't specified as an argument, see if it was specified as a system property. @@ -163,6 +159,7 @@ char mainClassEnvVar[80]; snprintf(mainClassEnvVar, sizeof(mainClassEnvVar), "JAVA_MAIN_CLASS_%d", getpid()); char *mainClass = getenv(mainClassEnvVar); + if (mainClass != NULL) { fApplicationName = [NSString stringWithUTF8String:mainClass]; unsetenv(mainClassEnvVar); @@ -171,9 +168,6 @@ if (lastPeriod.location != NSNotFound) { fApplicationName = [fApplicationName substringFromIndex:lastPeriod.location + 1]; } - // If this environment variable was set we were launched from the command line, so we - // should use a generic app icon if one wasn't set. - fUseDefaultIcon = YES; } } @@ -266,7 +260,7 @@ // If the icon file wasn't specified as an argument and we need to get an icon // we'll use the generic java app icon. NSString *defaultIconPath = [NSString stringWithFormat:@"%@%@", SHARED_FRAMEWORK_BUNDLE, @"/Resources/GenericApp.icns"]; - if (fUseDefaultIcon && (theIconPath == nil)) { + if (([NSApp applicationIconImage] == nil) && (theIconPath == nil)) { theIconPath = defaultIconPath; } @@ -333,6 +327,45 @@ return event; } +// NSTimeInterval has microseconds precision +#define TS_EQUAL(ts1, ts2) (fabs((ts1) - (ts2)) < 1e-6) + +- (void)sendEvent:(NSEvent *)event +{ + if ([event type] == NSApplicationDefined && TS_EQUAL([event timestamp], dummyEventTimestamp)) { + [seenDummyEventLock lockWhenCondition:NO]; + [seenDummyEventLock unlockWithCondition:YES]; + } else { + [super sendEvent:event]; + } +} + +- (void)postDummyEvent { + seenDummyEventLock = [[NSConditionLock alloc] initWithCondition:NO]; + dummyEventTimestamp = [NSProcessInfo processInfo].systemUptime; + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined + location: NSMakePoint(0,0) + modifierFlags: 0 + timestamp: dummyEventTimestamp + windowNumber: 0 + context: nil + subtype: 0 + data1: 0 + data2: 0]; + [NSApp postEvent: event atStart: NO]; + [pool drain]; +} + +- (void)waitForDummyEvent { + [seenDummyEventLock lockWhenCondition:YES]; + [seenDummyEventLock unlock]; + [seenDummyEventLock release]; + + seenDummyEventLock = nil; +} + @end
--- a/src/share/classes/java/util/HashMap.java Thu Jun 21 19:27:09 2012 -0700 +++ b/src/share/classes/java/util/HashMap.java Fri Jun 22 10:06:23 2012 -0700 @@ -221,6 +221,7 @@ ? Integer.parseInt(altThreshold) : ALTERNATE_HASHING_THRESHOLD_DEFAULT; + // disable alternative hashing if -1 if(threshold == -1) { threshold = Integer.MAX_VALUE; }
--- a/src/share/classes/java/util/Hashtable.java Thu Jun 21 19:27:09 2012 -0700 +++ b/src/share/classes/java/util/Hashtable.java Fri Jun 22 10:06:23 2012 -0700 @@ -171,7 +171,7 @@ * This value may be overridden by defining the system property * {@code java.util.althashing.threshold}. A property value of {@code 1} * forces alternative hashing to be used at all times whereas - * {@code 2147483648 } ({@code Integer.MAX_VALUE}) value ensures that + * {@code -1 } value ensures that * alternative hashing is never used. */ static final int ALTERNATE_HASHING_THRESHOLD_DEFAULT = 512; @@ -195,8 +195,9 @@ try { threshold = (null != altThreshold) ? Integer.parseInt(altThreshold) - : 1; + : ALTERNATE_HASHING_THRESHOLD_DEFAULT; + // disable alternative hashing if -1 if(threshold == -1) { threshold = Integer.MAX_VALUE; }
--- a/src/share/classes/java/util/WeakHashMap.java Thu Jun 21 19:27:09 2012 -0700 +++ b/src/share/classes/java/util/WeakHashMap.java Fri Jun 22 10:06:23 2012 -0700 @@ -218,6 +218,7 @@ ? Integer.parseInt(altThreshold) : ALTERNATE_HASHING_THRESHOLD_DEFAULT; + // disable alternative hashing if -1 if(threshold == -1) { threshold = Integer.MAX_VALUE; } @@ -356,7 +357,7 @@ if (useAltHashing) { h = hashSeed; if (k instanceof String) { - return h ^ sun.misc.Hashing.stringHash32((String) k); + return sun.misc.Hashing.stringHash32((String) k); } else { h ^= k.hashCode(); }
--- a/src/share/classes/java/util/concurrent/ConcurrentHashMap.java Thu Jun 21 19:27:09 2012 -0700 +++ b/src/share/classes/java/util/concurrent/ConcurrentHashMap.java Fri Jun 22 10:06:23 2012 -0700 @@ -198,6 +198,7 @@ ? Integer.parseInt(altThreshold) : 1; + // disable alternative hashing if -1 if(threshold == -1) { threshold = Integer.MAX_VALUE; }
--- a/src/share/classes/sun/net/spi/DefaultProxySelector.java Thu Jun 21 19:27:09 2012 -0700 +++ b/src/share/classes/sun/net/spi/DefaultProxySelector.java Fri Jun 22 10:06:23 2012 -0700 @@ -111,7 +111,7 @@ static class NonProxyInfo { // Default value for nonProxyHosts, this provides backward compatibility // by excluding localhost and its litteral notations. - static final String defStringVal = "localhost|127.*|[::1]"; + static final String defStringVal = "localhost|127.*|[::1]|0.0.0.0|[::0]"; String hostsSource; RegexpPool hostsPool;
--- a/src/solaris/native/sun/awt/awt_LoadLibrary.c Thu Jun 21 19:27:09 2012 -0700 +++ b/src/solaris/native/sun/awt/awt_LoadLibrary.c Fri Jun 22 10:06:23 2012 -0700 @@ -110,7 +110,7 @@ /* Check if toolkit is specified in env variable */ #ifdef MACOSX envvar = getenv("AWT_TOOLKIT"); - if ((envvar && strstr(envvar, "XToolkit")) || AWTIsHeadless()) { + if (envvar && strstr(envvar, "XToolkit")) { #endif fmanager = (*env)->NewStringUTF(env, "sun.awt.X11FontManager"); tk = "/xawt/libmawt"; @@ -127,11 +127,15 @@ } /* Calculate library name to load */ +#ifndef MACOSX if (AWTIsHeadless()) { strcpy(p, "/headless/libmawt"); } else if (tk) { +#endif strcpy(p, tk); +#ifndef MACOSX } +#endif #ifdef MACOSX strcat(p, ".dylib");