diff --git a/src/macosx/classes/sun/awt/SunToolkitSubclass.java b/src/macosx/classes/sun/awt/SunToolkitSubclass.java deleted file mode 100644 index 5669b5b54c63c8703a15722b3ab40f25cd03c322..0000000000000000000000000000000000000000 --- a/src/macosx/classes/sun/awt/SunToolkitSubclass.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.awt; - -// This class exists only so we can flush the PostEventQueue for the right AppContext -// The default flushPendingEvents only flushes the thread-local context, which is wrong. -// c.f. 3746956 -public abstract class SunToolkitSubclass extends SunToolkit { - public static void flushPendingEvents(AppContext appContext) { - flushLock.lock(); - PostEventQueue postEventQueue = (PostEventQueue)appContext.get("PostEventQueue"); - if (postEventQueue != null) { - postEventQueue.flush(); - } - flushLock.unlock(); - } -} diff --git a/src/macosx/classes/sun/font/CFontManager.java b/src/macosx/classes/sun/font/CFontManager.java index 5caca1e2a95edc4697573b4168ab5bf046b405c5..a37fd81c0c4be1c0d7c25308c2280c2fd32f2e8c 100644 --- a/src/macosx/classes/sun/font/CFontManager.java +++ b/src/macosx/classes/sun/font/CFontManager.java @@ -37,6 +37,7 @@ import java.util.Vector; import javax.swing.plaf.FontUIResource; import sun.awt.FontConfiguration; +import sun.awt.HeadlessToolkit; import sun.lwawt.macosx.*; public class CFontManager extends SunFontManager { @@ -342,9 +343,14 @@ public class CFontManager extends SunFontManager { @Override public String getFontPath(boolean noType1Fonts) { // In the case of the Cocoa toolkit, since we go through NSFont, we dont need to register /Library/Fonts - if (Toolkit.getDefaultToolkit() instanceof LWCToolkit) { + Toolkit tk = Toolkit.getDefaultToolkit(); + if (tk instanceof HeadlessToolkit) { + tk = ((HeadlessToolkit)tk).getUnderlyingToolkit(); + } + if (tk instanceof LWCToolkit) { return ""; } + // X11 case return "/Library/Fonts"; } diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java index 059ef01f3c7fb7c76a8bdadc9abea0ce7cb541a4..d874b26fb701febfeed16a8e4f18c4822f611396 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java @@ -134,7 +134,7 @@ final class CPlatformResponder { boolean postsTyped = false; char testChar = KeyEvent.CHAR_UNDEFINED; - char testDeadChar = 0; + boolean isDeadChar = (chars!= null && chars.length() == 0); if (isFlagsChangedEvent) { int[] in = new int[] {modifierFlags, keyCode}; @@ -150,14 +150,18 @@ final class CPlatformResponder { testChar = chars.charAt(0); } - int[] in = new int[] {testChar, testDeadChar, modifierFlags, keyCode}; - int[] out = new int[2]; // [jkeyCode, jkeyLocation] + int[] in = new int[] {testChar, isDeadChar ? 1 : 0, modifierFlags, keyCode}; + int[] out = new int[3]; // [jkeyCode, jkeyLocation, deadChar] postsTyped = NSEvent.nsToJavaKeyInfo(in, out); if (!postsTyped) { testChar = KeyEvent.CHAR_UNDEFINED; } + if(isDeadChar){ + testChar = (char) out[2]; + } + jkeyCode = out[0]; jkeyLocation = out[1]; jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index ea44e5fe9f6e6d9d4be471157134fbe4db2b3c8a..23df4fbf9eb20545feb970eef99d38cf4961a620 100644 --- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -536,7 +536,7 @@ public class LWCToolkit extends LWToolkit { SunToolkit.postEvent(appContext, invocationEvent); // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock - sun.awt.SunToolkitSubclass.flushPendingEvents(appContext); + SunToolkit.flushPendingEvents(appContext); } else { // This should be the equivalent to EventQueue.invokeAndWait ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent); @@ -561,7 +561,7 @@ public class LWCToolkit extends LWToolkit { SunToolkit.postEvent(appContext, invocationEvent); // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock - sun.awt.SunToolkitSubclass.flushPendingEvents(appContext); + SunToolkit.flushPendingEvents(appContext); } else { // This should be the equivalent to EventQueue.invokeAndWait ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent); diff --git a/src/macosx/native/sun/awt/AWTEvent.h b/src/macosx/native/sun/awt/AWTEvent.h index f69a4196effd58223875210915996e574b9a625f..f813b8c7d004500319054a2142d48247585f5c0d 100644 --- a/src/macosx/native/sun/awt/AWTEvent.h +++ b/src/macosx/native/sun/awt/AWTEvent.h @@ -33,5 +33,7 @@ void DeliverJavaKeyEvent(JNIEnv *env, NSEvent *event, jobject peer); void DeliverJavaMouseEvent(JNIEnv *env, NSEvent *event, jobject peer); void SendAdditionalJavaEvents(JNIEnv *env, NSEvent *nsEvent, jobject peer); jint GetJavaMouseModifiers(NSInteger button, NSUInteger modifierFlags); +jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods); +NSUInteger JavaModifiersToNsKeyModifiers(jint javaModifiers, BOOL isExtMods); #endif /* __AWTEVENT_H */ diff --git a/src/macosx/native/sun/awt/AWTEvent.m b/src/macosx/native/sun/awt/AWTEvent.m index 66dfa978a3665630b6176317176b57147fc93fab..85c9fa9718ef47e3cc38f219244dc9e9e2dee44e 100644 --- a/src/macosx/native/sun/awt/AWTEvent.m +++ b/src/macosx/native/sun/awt/AWTEvent.m @@ -26,6 +26,7 @@ #import #import #import +#include #import "LWCToolkit.h" #import "ThreadUtilities.h" @@ -244,6 +245,7 @@ static struct _nsKeyToJavaModifier //NSUInteger cgsRightMask; unsigned short leftKeyCode; unsigned short rightKeyCode; + jint javaExtMask; jint javaMask; jint javaKey; } @@ -254,6 +256,7 @@ const nsKeyToJavaModifierTable[] = 0, 0, 0, // no Java equivalent + 0, // no Java equivalent java_awt_event_KeyEvent_VK_CAPS_LOCK }, { @@ -263,6 +266,7 @@ const nsKeyToJavaModifierTable[] = 56, 60, java_awt_event_InputEvent_SHIFT_DOWN_MASK, + java_awt_event_InputEvent_SHIFT_MASK, java_awt_event_KeyEvent_VK_SHIFT }, { @@ -272,6 +276,7 @@ const nsKeyToJavaModifierTable[] = 59, 62, java_awt_event_InputEvent_CTRL_DOWN_MASK, + java_awt_event_InputEvent_CTRL_MASK, java_awt_event_KeyEvent_VK_CONTROL }, { @@ -281,6 +286,7 @@ const nsKeyToJavaModifierTable[] = 58, 61, java_awt_event_InputEvent_ALT_DOWN_MASK, + java_awt_event_InputEvent_ALT_MASK, java_awt_event_KeyEvent_VK_ALT }, { @@ -290,6 +296,7 @@ const nsKeyToJavaModifierTable[] = 55, 54, java_awt_event_InputEvent_META_DOWN_MASK, + java_awt_event_InputEvent_META_MASK, java_awt_event_KeyEvent_VK_META }, // NSNumericPadKeyMask @@ -298,10 +305,11 @@ const nsKeyToJavaModifierTable[] = 0, 0, 0, // no Java equivalent + 0, // no Java equivalent java_awt_event_KeyEvent_VK_HELP }, // NSFunctionKeyMask - {0, 0, 0, 0, 0} + {0, 0, 0, 0, 0, 0} }; /* @@ -371,26 +379,67 @@ NsCharToJavaChar(unichar nsChar, NSUInteger modifiers) return nsChar; } +static unichar NsGetDeadKeyChar(unsigned short keyCode) +{ + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + CFDataRef uchr = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr); + // Carbon modifiers should be used instead of NSEvent modifiers + UInt32 modifierKeyState = (GetCurrentEventKeyModifiers() >> 8) & 0xFF; + + if (keyboardLayout) { + UInt32 deadKeyState = 0; + UniCharCount maxStringLength = 255; + UniCharCount actualStringLength = 0; + UniChar unicodeString[maxStringLength]; + + // get the deadKeyState + OSStatus status = UCKeyTranslate(keyboardLayout, + keyCode, kUCKeyActionDown, modifierKeyState, + LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, + &deadKeyState, + maxStringLength, + &actualStringLength, unicodeString); + + if (status == noErr && deadKeyState != 0) { + // Press SPACE to get the dead key char + status = UCKeyTranslate(keyboardLayout, + kVK_Space, kUCKeyActionDown, 0, + LMGetKbdType(), 0, + &deadKeyState, + maxStringLength, + &actualStringLength, unicodeString); + + if (status == noErr && actualStringLength > 0) { + return unicodeString[0]; + } + } + } + return 0; +} + /* * This is the function that uses the table above to take incoming * NSEvent keyCodes and translate to the Java virtual key code. */ static void -NsCharToJavaVirtualKeyCode(unichar ch, unichar deadChar, +NsCharToJavaVirtualKeyCode(unichar ch, BOOL isDeadChar, NSUInteger flags, unsigned short key, - jint *keyCode, jint *keyLocation, BOOL *postsTyped) + jint *keyCode, jint *keyLocation, BOOL *postsTyped, unichar *deadChar) { static size_t size = sizeof(keyTable) / sizeof(struct _key); NSInteger offset; - if (deadChar) { + if (isDeadChar) { + unichar testDeadChar = NsGetDeadKeyChar(key); const struct CharToVKEntry *map; for (map = charToDeadVKTable; map->c != 0; ++map) { - if (deadChar == map->c) { + if (testDeadChar == map->c) { *keyCode = map->javaKey; *postsTyped = NO; // TODO: use UNKNOWN here? *keyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN; + *deadChar = testDeadChar; return; } } @@ -491,25 +540,51 @@ NsKeyModifiersToJavaKeyInfo(NSUInteger nsFlags, unsigned short eventKeyCode, /* * This returns the java modifiers for a key NSEvent. */ -static jint -NsKeyModifiersToJavaModifiers(NSUInteger nsFlags) +jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods) { jint javaModifiers = 0; const struct _nsKeyToJavaModifier* cur; for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) { if ((cur->nsMask & nsFlags) != 0) { - javaModifiers |= cur->javaMask; + javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask; } } return javaModifiers; } +/* + * This returns the NSEvent flags for java key modifiers. + */ +NSUInteger JavaModifiersToNsKeyModifiers(jint javaModifiers, BOOL isExtMods) +{ + NSUInteger nsFlags = 0; + const struct _nsKeyToJavaModifier* cur; + + for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) { + jint mask = isExtMods? cur->javaExtMask : cur->javaMask; + if ((mask & javaModifiers) != 0) { + nsFlags |= cur->nsMask; + } + } + + // special case + jint mask = isExtMods? java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK : + java_awt_event_InputEvent_ALT_GRAPH_MASK; + + if ((mask & javaModifiers) != 0) { + nsFlags |= NSAlternateKeyMask; + } + + return nsFlags; +} + + jint GetJavaMouseModifiers(NSInteger button, NSUInteger modifierFlags) { // Mousing needs the key modifiers - jint modifiers = NsKeyModifiersToJavaModifiers(modifierFlags); + jint modifiers = NsKeyModifiersToJavaModifiers(modifierFlags, YES); /* @@ -590,7 +665,7 @@ Java_sun_lwawt_macosx_event_NSEvent_nsToJavaKeyModifiers JNF_COCOA_ENTER(env); - jmodifiers = NsKeyModifiersToJavaModifiers(modifierFlags); + jmodifiers = NsKeyModifiersToJavaModifiers(modifierFlags, YES); JNF_COCOA_EXIT(env); @@ -615,20 +690,22 @@ JNF_COCOA_ENTER(env); // in = [testChar, testDeadChar, modifierFlags, keyCode] jchar testChar = (jchar)data[0]; - jchar testDeadChar = (jchar)data[1]; + BOOL isDeadChar = (data[1] != 0); jint modifierFlags = data[2]; jshort keyCode = (jshort)data[3]; jint jkeyCode = java_awt_event_KeyEvent_VK_UNDEFINED; jint jkeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN; + jchar testDeadChar = 0; - NsCharToJavaVirtualKeyCode((unichar)testChar, (unichar)testDeadChar, + NsCharToJavaVirtualKeyCode((unichar)testChar, isDeadChar, (NSUInteger)modifierFlags, (unsigned short)keyCode, - &jkeyCode, &jkeyLocation, &postsTyped); + &jkeyCode, &jkeyLocation, &postsTyped, &testDeadChar); // out = [jkeyCode, jkeyLocation]; (*env)->SetIntArrayRegion(env, outData, 0, 1, &jkeyCode); (*env)->SetIntArrayRegion(env, outData, 1, 1, &jkeyLocation); + (*env)->SetIntArrayRegion(env, outData, 2, 1, (jint *)&testDeadChar); (*env)->ReleaseIntArrayElements(env, inData, data, 0); @@ -685,12 +762,12 @@ Java_sun_lwawt_macosx_event_NSEvent_nsToJavaChar (JNIEnv *env, jclass cls, char nsChar, jint modifierFlags) { jchar javaChar = 0; - + JNF_COCOA_ENTER(env); - + javaChar = NsCharToJavaChar(nsChar, modifierFlags); JNF_COCOA_EXIT(env); - + return javaChar; } diff --git a/src/macosx/native/sun/awt/AWTWindow.m b/src/macosx/native/sun/awt/AWTWindow.m index f0d689b546ec05c17f4e3f91cc939cbcf21c3bae..2e2b854f35b7930ae7dc871baf51c4346a7ca453 100644 --- a/src/macosx/native/sun/awt/AWTWindow.m +++ b/src/macosx/native/sun/awt/AWTWindow.m @@ -178,8 +178,8 @@ AWT_NS_WINDOW_IMPLEMENTATION [self.nsWindow setDocumentEdited:IS(bits, DOCUMENT_MODIFIED)]; } - if ([self.nsWindow respondsToSelector:@selector(toggleFullScreen:)]) { - if (IS(mask, FULLSCREENABLE)) { + if (IS(mask, FULLSCREENABLE) && [self.nsWindow respondsToSelector:@selector(toggleFullScreen:)]) { + if (IS(bits, FULLSCREENABLE)) { [self.nsWindow setCollectionBehavior:(1 << 7) /*NSWindowCollectionBehaviorFullScreenPrimary*/]; } else { [self.nsWindow setCollectionBehavior:NSWindowCollectionBehaviorDefault]; diff --git a/src/macosx/native/sun/awt/CDragSource.m b/src/macosx/native/sun/awt/CDragSource.m index cbfe6270cebd424bae5fd4a869d7928f001a8a55..ef7b09a6edc7e46356b0388f3cedd09ea1920f95 100644 --- a/src/macosx/native/sun/awt/CDragSource.m +++ b/src/macosx/native/sun/awt/CDragSource.m @@ -460,7 +460,7 @@ static BOOL sNeedsEnter; } // Convert fModifiers (extModifiers) to NS: - NSUInteger modifiers = [DnDUtilities mapJavaExtModifiersToNSKeyModifiers:fModifiers]; + NSUInteger modifiers = JavaModifiersToNsKeyModifiers(fModifiers, TRUE); // Just a dummy value ... NSInteger eventNumber = 0; @@ -658,7 +658,7 @@ JNF_COCOA_ENTER(env); } // b) drag actions (key modifiers) have changed: - jint modifiers = [DnDUtilities currentJavaExtKeyModifiers]; + jint modifiers = NsKeyModifiersToJavaModifiers([NSEvent modifierFlags], YES); if (fDragKeyModifiers != modifiers) { NSDragOperation currentOp = [DnDUtilities nsDragOperationForModifiers:[NSEvent modifierFlags]]; NSDragOperation allowedOp = [DnDUtilities mapJavaDragOperationToNS:fSourceActions] & currentOp; diff --git a/src/macosx/native/sun/awt/CMenuItem.m b/src/macosx/native/sun/awt/CMenuItem.m index aa0c2ab03a2ee75502e6c7ace363dbd307bceb78..7751f3555b94b08565a7b39d6c79418559b82005 100644 --- a/src/macosx/native/sun/awt/CMenuItem.m +++ b/src/macosx/native/sun/awt/CMenuItem.m @@ -70,6 +70,18 @@ AWT_ASSERT_APPKIT_THREAD; JNIEnv *env = [ThreadUtilities getJNIEnv]; JNF_COCOA_ENTER(env); + // If we are called as a result of user pressing a shorcut, do nothing, + // because AVTView has already sent corresponding key event to the Java + // layer from performKeyEquivalent + NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent]; + if ([currEvent type] == NSKeyDown) { + NSString *menuKey = [sender keyEquivalent]; + NSString *eventKey = [currEvent characters]; + if ([menuKey isEqualToString:eventKey]) { + return; + } + } + if (fIsCheckbox) { static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem"); static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V"); @@ -83,14 +95,8 @@ JNF_COCOA_ENTER(env); static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem"); static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event) - NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent]; NSUInteger modifiers = [currEvent modifierFlags]; - jint javaModifiers = 0; - - if ((modifiers & NSCommandKeyMask) != 0) javaModifiers |= java_awt_Event_META_MASK; - if ((modifiers & NSShiftKeyMask) != 0) javaModifiers |= java_awt_Event_SHIFT_MASK; - if ((modifiers & NSControlKeyMask) != 0) javaModifiers |= java_awt_Event_CTRL_MASK; - if ((modifiers & NSAlternateKeyMask) != 0) javaModifiers |= java_awt_Event_ALT_MASK; + jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO); JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event) } @@ -117,10 +123,7 @@ AWT_ASSERT_NOT_APPKIT_THREAD; modifiers &= ~java_awt_event_KeyEvent_SHIFT_MASK; } - if ((modifiers & java_awt_event_KeyEvent_SHIFT_MASK) != 0) modifierMask |= NSShiftKeyMask; - if ((modifiers & java_awt_event_KeyEvent_CTRL_MASK) != 0) modifierMask |= NSControlKeyMask; - if ((modifiers & java_awt_event_KeyEvent_ALT_MASK) != 0) modifierMask |= NSAlternateKeyMask; - if ((modifiers & java_awt_event_KeyEvent_META_MASK) != 0) modifierMask |= NSCommandKeyMask; + modifierMask = JavaModifiersToNsKeyModifiers(modifiers, NO); } [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ diff --git a/src/macosx/native/sun/awt/CTextPipe.m b/src/macosx/native/sun/awt/CTextPipe.m index dbf0e01a7152c9c21b8925a0099a3ed635d99092..bfe9ad6262fc2597ad31f4cd50036da2067dbf2b 100644 --- a/src/macosx/native/sun/awt/CTextPipe.m +++ b/src/macosx/native/sun/awt/CTextPipe.m @@ -239,9 +239,22 @@ void JavaCT_DrawTextUsingQSD(JNIEnv *env, const QuartzSDOps *qsdo, const AWTStri CGContextSetTextMatrix(cgRef, CGAffineTransformIdentity); // resets the damage from CoreText NSString *string = [NSString stringWithCharacters:chars length:length]; + /* + The calls below were used previously but for unknown reason did not + render using the right font (see bug 7183516) when attribString is not + initialized with font dictionary attributes. It seems that "options" + in CTTypesetterCreateWithAttributedStringAndOptions which contains the + font dictionary is ignored. + NSAttributedString *attribString = [[NSAttributedString alloc] initWithString:string]; CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedStringAndOptions((CFAttributedStringRef) attribString, (CFDictionaryRef) ctsDictionaryFor(nsFont, JRSFontStyleUsesFractionalMetrics(strike->fStyle))); + */ + NSAttributedString *attribString = [[NSAttributedString alloc] + initWithString:string + attributes:ctsDictionaryFor(nsFont, JRSFontStyleUsesFractionalMetrics(strike->fStyle))]; + + CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedString((CFAttributedStringRef) attribString); CFRange range = {0, length}; CTLineRef lineRef = CTTypesetterCreateLine(typeSetterRef, range); diff --git a/src/macosx/native/sun/awt/DnDUtilities.h b/src/macosx/native/sun/awt/DnDUtilities.h index 24b4847c01be4d7f53b2908c934038f64e152d67..fe56f7161a9ddd231ea6c1a82bdf6c680c31cfda 100644 --- a/src/macosx/native/sun/awt/DnDUtilities.h +++ b/src/macosx/native/sun/awt/DnDUtilities.h @@ -42,7 +42,6 @@ + (jint)narrowJavaDropActions:(jint)actions; // Mouse and key modifiers mapping: -+ (NSUInteger)mapJavaExtModifiersToNSKeyModifiers:(jint)modifiers; + (NSUInteger)mapJavaExtModifiersToNSMouseDownButtons:(jint)modifiers; + (NSUInteger)mapJavaExtModifiersToNSMouseUpButtons:(jint)modifiers; @@ -50,9 +49,6 @@ + (jint)extractJavaExtKeyModifiersFromJavaExtModifiers:(jint)modifiers; + (jint)extractJavaExtMouseModifiersFromJavaExtModifiers:(jint)modifiers; -// Get the current keyboard modifier keys as java modifiers (for operationChanged) -+ (jint)currentJavaExtKeyModifiers; - // Getting the state of the current Drag + (NSDragOperation)nsDragOperationForModifiers:(NSUInteger)modifiers; + (jint) javaKeyModifiersForNSDragOperation:(NSDragOperation)dragOp; diff --git a/src/macosx/native/sun/awt/DnDUtilities.m b/src/macosx/native/sun/awt/DnDUtilities.m index a998c03340786352743042ce17767533c292c127..f6371563d3eed73fbae2de83e10f6b730d4176dc 100644 --- a/src/macosx/native/sun/awt/DnDUtilities.m +++ b/src/macosx/native/sun/awt/DnDUtilities.m @@ -161,28 +161,6 @@ There are several problems with Drag and Drop - notably, the mismatch between Ja } // Mouse and key modifiers mapping: -+ (NSUInteger)mapJavaExtModifiersToNSKeyModifiers:(jint)modifiers -{ - NSUInteger result = 0; - - if ((modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK) != 0) - result |= NSShiftKeyMask; - - if ((modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK) != 0) - result |= NSControlKeyMask; - - if ((modifiers & java_awt_event_InputEvent_META_DOWN_MASK) != 0) - result |= NSCommandKeyMask; - - if ((modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK) != 0) - result |= NSAlternateKeyMask; - - if ((modifiers & java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK) != 0) - result |= NSAlternateKeyMask; - - return result; -} - + (NSUInteger)mapJavaExtModifiersToNSMouseDownButtons:(jint)modifiers { NSUInteger result = NSLeftMouseDown; @@ -245,32 +223,6 @@ There are several problems with Drag and Drop - notably, the mismatch between Ja return modifiers & mask; } - -+ (jint)currentJavaExtKeyModifiers -{ - NSUInteger modifiers = [NSEvent modifierFlags]; - jint jmodifiers = 0; - - if(modifiers & NSShiftKeyMask) { - jmodifiers |= java_awt_event_InputEvent_SHIFT_DOWN_MASK; - } - - if(modifiers & NSControlKeyMask) { - jmodifiers |= java_awt_event_InputEvent_CTRL_DOWN_MASK; - } - - if(modifiers & NSAlternateKeyMask) { - jmodifiers |= java_awt_event_InputEvent_ALT_DOWN_MASK; - } - - if(modifiers & NSCommandKeyMask) { - jmodifiers |= java_awt_event_InputEvent_META_DOWN_MASK; - } - - return jmodifiers; -} - - + (NSDragOperation) nsDragOperationForModifiers:(NSUInteger)modifiers { // Java first diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java index 6fe38ab7592a4128aed6e95f663a444a60c88587..7d5e237948cd2f0f7def3ef0e04c7ccef3cc8c1a 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -644,6 +644,9 @@ public class WindowsLookAndFeel extends BasicLookAndFeel "released SPACE", "released" }), + "Caret.width", + new DesktopProperty("win.caret.width", null), + "CheckBox.font", ControlFont, "CheckBox.interiorBackground", WindowBackgroundColor, "CheckBox.background", ControlBackgroundColor, diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java index a4a298261359c5592b3d3268b298be95b8cc6e25..78754b5c72b44acbf5b92ef305643ba6a73f727c 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java @@ -883,7 +883,7 @@ class PackageWriter extends BandStructure { avHiBits &= (1L< defMap = allLayouts.get(i); - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) Map.Entry[] layoutsAndCounts = new Map.Entry[defMap.size()]; defMap.entrySet().toArray(layoutsAndCounts); diff --git a/src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java b/src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java index 7f469d2d471907afc7bcc3818427002695f84040..f74060fef698c137b8fccddff80b375d3d21aab2 100644 --- a/src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java +++ b/src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java @@ -32,14 +32,15 @@ import static javax.management.openmbean.SimpleType.*; import com.sun.jmx.remote.util.EnvHelp; -import java.beans.ConstructorProperties; import java.io.InvalidObjectException; +import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.ref.WeakReference; import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.GenericArrayType; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; @@ -1129,14 +1130,56 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory { to getters. */ private static final class CompositeBuilderViaConstructor extends CompositeBuilder { + static class AnnotationHelper { + private static Class constructorPropertiesClass; + private static Method valueMethod; + static { + findConstructorPropertiesClass(); + } + + @SuppressWarnings("unchecked") + private static void findConstructorPropertiesClass() { + try { + constructorPropertiesClass = (Class) + Class.forName("java.beans.ConstructorProperties", false, + DefaultMXBeanMappingFactory.class.getClassLoader()); + valueMethod = constructorPropertiesClass.getMethod("value"); + } catch (ClassNotFoundException cnf) { + // java.beans not present + } catch (NoSuchMethodException e) { + // should not reach here + throw new InternalError(e); + } + } + + static boolean isAvailable() { + return constructorPropertiesClass != null; + } + + static String[] getPropertyNames(Constructor constr) { + if (!isAvailable()) + return null; + + Annotation a = constr.getAnnotation(constructorPropertiesClass); + if (a == null) return null; + + try { + return (String[]) valueMethod.invoke(a); + } catch (InvocationTargetException e) { + throw new InternalError(e); + } catch (IllegalAccessException e) { + throw new InternalError(e); + } + } + } CompositeBuilderViaConstructor(Class targetClass, String[] itemNames) { super(targetClass, itemNames); } String applicable(Method[] getters) throws InvalidObjectException { - - final Class propertyNamesClass = ConstructorProperties.class; + if (!AnnotationHelper.isAvailable()) + return "@ConstructorProperties annotation not available"; Class targetClass = getTargetClass(); Constructor[] constrs = targetClass.getConstructors(); @@ -1145,7 +1188,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory { List> annotatedConstrList = newList(); for (Constructor constr : constrs) { if (Modifier.isPublic(constr.getModifiers()) - && constr.getAnnotation(propertyNamesClass) != null) + && AnnotationHelper.getPropertyNames(constr) != null) annotatedConstrList.add(constr); } @@ -1174,8 +1217,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory { // so we can test unambiguity. Set getterIndexSets = newSet(); for (Constructor constr : annotatedConstrList) { - String[] propertyNames = - constr.getAnnotation(propertyNamesClass).value(); + String[] propertyNames = AnnotationHelper.getPropertyNames(constr); Type[] paramTypes = constr.getGenericParameterTypes(); if (paramTypes.length != propertyNames.length) { diff --git a/src/share/classes/com/sun/management/VMOption.java b/src/share/classes/com/sun/management/VMOption.java index 48ce0d956b2090b6bc048638394e8a9b5459cf7a..96530072fff4c1fe27279d90201f5da7409cc43d 100644 --- a/src/share/classes/com/sun/management/VMOption.java +++ b/src/share/classes/com/sun/management/VMOption.java @@ -178,7 +178,7 @@ public class VMOption { return "VM option: " + getName() + " value: " + value + " " + " origin: " + origin + " " + - (writeable ? "(read-only)" : "(read-write)"); + (writeable ? "(read-write)" : "(read-only)"); } /** diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java b/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java index 308d517a2c47f6f4bb5091725ca1bebab0317604..d1ebe5fc730502dd1a2cd81ea1bc03d36145f8d6 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java @@ -153,8 +153,8 @@ public final class Init { break; } } - for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) { - if (!(el instanceof Element)) { + for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) { + if (el.getNodeType() != Node.ELEMENT_NODE) { continue; } String tag=el.getLocalName(); diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java index 77024c23403e7703f4af64bedcee83270424be8b..2f5f28904d201966daf089e668960caa62fb5a8c 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java @@ -205,7 +205,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi { try { NameSpaceSymbTable ns=new NameSpaceSymbTable(); int nodeLevel=NODE_BEFORE_DOCUMENT_ELEMENT; - if (rootNode instanceof Element) { + if (rootNode != null && rootNode.getNodeType() == Node.ELEMENT_NODE) { //Fills the nssymbtable with the definitions of the parent of the root subnode getParentNameSpaces((Element)rootNode,ns); nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT; @@ -335,7 +335,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi { return; sibling=parentNode.getNextSibling(); parentNode=parentNode.getParentNode(); - if (!(parentNode instanceof Element)) { + if (parentNode !=null && parentNode.getNodeType() != Node.ELEMENT_NODE) { documentLevel=NODE_AFTER_DOCUMENT_ELEMENT; parentNode=null; } @@ -391,7 +391,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi { return; boolean currentNodeIsVisible = false; NameSpaceSymbTable ns=new NameSpaceSymbTable(); - if (currentNode instanceof Element) + if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE) getParentNameSpaces((Element)currentNode,ns); Node sibling=null; Node parentNode=null; @@ -512,7 +512,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi { return; sibling=parentNode.getNextSibling(); parentNode=parentNode.getParentNode(); - if (!(parentNode instanceof Element)) { + if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) { parentNode=null; documentLevel=NODE_AFTER_DOCUMENT_ELEMENT; } @@ -594,18 +594,14 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi { final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) { List parents=new ArrayList(10); Node n1=el.getParentNode(); - if (!(n1 instanceof Element)) { + if (n1 == null || n1.getNodeType() != Node.ELEMENT_NODE) { return; } //Obtain all the parents of the elemnt - Element parent=(Element) n1; - while (parent!=null) { - parents.add(parent); - Node n=parent.getParentNode(); - if (!(n instanceof Element )) { - break; - } - parent=(Element)n; + Node parent = n1; + while (parent!=null && parent.getNodeType() == Node.ELEMENT_NODE) { + parents.add((Element)parent); + parent = parent.getParentNode(); } //Visit them in reverse order. ListIterator it=parents.listIterator(parents.size()); diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java index 8479835c901b80e0e287bcf432bcc5395061bb1e..b8be1a505ed35aacb458fd515352e41b6da09c11 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java @@ -1445,7 +1445,7 @@ public class XMLCipher { // The de-serialiser returns a fragment whose children we need to // take on. - if (sourceParent instanceof Document) { + if (sourceParent != null && sourceParent.getNodeType() == Node.DOCUMENT_NODE) { // If this is a content decryption, this may have problems diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java index 80674426281400324ada70ad15881315f3c5f4b2..fec12b3b1bf5422f315d54ff51507c05ea4b8adc 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java @@ -283,7 +283,7 @@ public class RetrievalMethodResolver extends KeyResolverSpi { Element e=null; while (it.hasNext()) { Node currentNode=it.next(); - if (currentNode instanceof Element) { + if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE) { e=(Element)currentNode; break; } @@ -292,14 +292,14 @@ public class RetrievalMethodResolver extends KeyResolverSpi { List parents=new ArrayList(10); //Obtain all the parents of the elemnt - do { + while (e != null) { parents.add(e); Node n=e.getParentNode(); - if (!(n instanceof Element )) { + if (n == null || n.getNodeType() != Node.ELEMENT_NODE) { break; } e=(Element)n; - } while (e!=null); + } //Visit them in reverse order. ListIterator it2=parents.listIterator(parents.size()-1); Element ele=null; diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java index 2fba84559687d56f3a5078b1af070a95157a2378..4ee51ac92ab69456362cfb0aa5c5ed7abf49c62c 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java @@ -225,7 +225,7 @@ public class IdResolver { } while (sibling==null && parentNode!=null) { sibling=parentNode.getNextSibling(); parentNode=parentNode.getParentNode(); - if (!(parentNode instanceof Element)) { + if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) { parentNode=null; } } diff --git a/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java b/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java index f2a72f6a4adb5bbb5ad9e29ad2697009d8dde9b7..36612ad80804503f1947ac969a496457d4aad9a4 100644 --- a/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java +++ b/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ import javax.naming.*; import java.io.*; import java.math.*; import java.util.*; -import java.beans.*; import javax.sql.rowset.*; @@ -83,12 +82,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { */ private ResultSetMetaData resMD; - /** - * The property that helps to fire the property changed event when certain - * properties are changed in the JdbcRowSet object. This property - * is being added to satisfy Rave requirements. - */ - private PropertyChangeSupport propertyChangeSupport; /** * The Vector holding the Match Columns @@ -145,7 +138,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { throw new RuntimeException(ioe); } - propertyChangeSupport = new PropertyChangeSupport(this); initParams(); @@ -268,7 +260,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { throw new RuntimeException(ioe); } - propertyChangeSupport = new PropertyChangeSupport(this); initParams(); // set the defaults @@ -343,7 +334,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { throw new RuntimeException(ioe); } - propertyChangeSupport = new PropertyChangeSupport(this); initParams(); @@ -360,10 +350,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { setMaxRows(0); setMaxFieldSize(0); - // to ensure connection to a db call connect now - // and associate a conn with "this" object - // in this case. - conn = connect(); setParams(); setReadOnly(true); @@ -435,7 +421,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { throw new RuntimeException(ioe); } - propertyChangeSupport = new PropertyChangeSupport(this); initParams(); @@ -620,12 +605,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { } - // An alternate solution is required instead of having the - // connect method as protected. - // This is a work around to assist Rave Team - // :ah - - protected Connection connect() throws SQLException { + private Connection connect() throws SQLException { // Get a JDBC connection. @@ -4056,9 +4036,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { // Added as per Rave requirements if( conn.getHoldability() != HOLD_CURSORS_OVER_COMMIT) { - ResultSet oldVal = rs; rs = null; - // propertyChangeSupport.firePropertyChange("ResultSet",oldVal,rs); } } @@ -4119,9 +4097,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { // Makes the result ste handle null after rollback // Added as per Rave requirements - ResultSet oldVal = rs; rs = null; - // propertyChangeSupport.firePropertyChange("ResultSet", oldVal,rs); } @@ -4247,12 +4223,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { rs = resultSet; } - - // Over riding the setCommand from BaseRowSet for - // firing the propertyChangeSupport Event for - // Rave requirements when this property's value - // changes. - /** * Sets this JdbcRowSet object's command property to * the given String object and clears the parameters, if any, @@ -4277,28 +4247,19 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { * @see #getCommand */ public void setCommand(String command) throws SQLException { - String oldVal; if (getCommand() != null) { if(!getCommand().equals(command)) { - oldVal = getCommand(); super.setCommand(command); ps = null; rs = null; - propertyChangeSupport.firePropertyChange("command", oldVal,command); } } else { super.setCommand(command); - propertyChangeSupport.firePropertyChange("command", null,command); } } - // Over riding the setDataSourceName from BaseRowSet for - // firing the propertyChangeSupport Event for - // Rave requirements when this property's values - // changes. - /** * Sets the dataSourceName property for this JdbcRowSet * object to the given logical name and sets this JdbcRowSet object's @@ -4329,28 +4290,20 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { * @see #getDataSourceName */ public void setDataSourceName(String dsName) throws SQLException{ - String oldVal; if(getDataSourceName() != null) { if(!getDataSourceName().equals(dsName)) { - oldVal = getDataSourceName(); super.setDataSourceName(dsName); conn = null; ps = null; rs = null; - propertyChangeSupport.firePropertyChange("dataSourceName",oldVal,dsName); } } else { super.setDataSourceName(dsName); - propertyChangeSupport.firePropertyChange("dataSourceName",null,dsName); } } - // Over riding the setUrl from BaseRowSet for - // firing the propertyChangeSupport Event for - // Rave requirements when this property's values - // changes. /** * Sets the Url property for this JdbcRowSet object @@ -4394,29 +4347,20 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { */ public void setUrl(String url) throws SQLException { - String oldVal; if(getUrl() != null) { if(!getUrl().equals(url)) { - oldVal = getUrl(); super.setUrl(url); conn = null; ps = null; rs = null; - propertyChangeSupport.firePropertyChange("url", oldVal, url); } } else { super.setUrl(url); - propertyChangeSupport.firePropertyChange("url", null, url); } } - // Over riding the setUsername from BaseRowSet for - // firing the propertyChangeSupport Event for - // Rave requirements when this property's values - // changes. - /** * Sets the username property for this JdbcRowSet object * to the given user name. Because it @@ -4438,29 +4382,20 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { * @see #getUsername */ public void setUsername(String uname) { - String oldVal; if( getUsername() != null) { if(!getUsername().equals(uname)) { - oldVal = getUsername(); super.setUsername(uname); conn = null; ps = null; rs = null; - propertyChangeSupport.firePropertyChange("username",oldVal,uname); } } else{ super.setUsername(uname); - propertyChangeSupport.firePropertyChange("username",null,uname); } } - // Over riding the setPassword from BaseRowSet for - // firing the propertyChangeSupport Event for - // Rave requirements when this property's values - // changes. - /** * Sets the password property for this JdbcRowSet object * to the given String object. Because it @@ -4481,21 +4416,17 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { * that must be supplied to the database to create a connection */ public void setPassword(String password) { - String oldVal; if ( getPassword() != null) { if(!getPassword().equals(password)) { - oldVal = getPassword(); super.setPassword(password); conn = null; ps = null; rs = null; - propertyChangeSupport.firePropertyChange("password",oldVal,password); } } else{ super.setPassword(password); - propertyChangeSupport.firePropertyChange("password",null,password); } } @@ -4528,7 +4459,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { if(oldVal != type) { super.setType(type); - propertyChangeSupport.firePropertyChange("type",oldVal,type); } } @@ -4561,78 +4491,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { if(oldVal != concur) { super.setConcurrency(concur); - propertyChangeSupport.firePropertyChange("concurrency",oldVal,concur); - } - - } - - /** - * Sets the transaction isolation property for this JDBC RowSet object to the given - * constant. The DBMS will use this transaction isolation level for - * transactions if it can. - *

- * For RowSet implementations such as - * the CachedRowSet that operate in a disconnected environment, - * the SyncProvider object being used - * offers complementary locking and data integrity options. The - * options described below are pertinent only to connected RowSet - * objects (JdbcRowSet objects). - * - * @param transIso one of the following constants, listed in ascending order: - * Connection.TRANSACTION_NONE, - * Connection.TRANSACTION_READ_UNCOMMITTED, - * Connection.TRANSACTION_READ_COMMITTED, - * Connection.TRANSACTION_REPEATABLE_READ, or - * Connection.TRANSACTION_SERIALIZABLE - * @throws SQLException if the given parameter is not one of the Connection - * constants - * @see javax.sql.rowset.spi.SyncFactory - * @see javax.sql.rowset.spi.SyncProvider - * @see #getTransactionIsolation - */ - public void setTransactionIsolation(int transIso) throws SQLException { - - int oldVal; - - try { - oldVal = getTransactionIsolation(); - }catch(NullPointerException ex) { - oldVal = 0; - } - - if(oldVal != transIso) { - super.setTransactionIsolation(transIso); - propertyChangeSupport.firePropertyChange("transactionIsolation",oldVal,transIso); - } - - } - - /** - * Sets the maximum number of rows that this RowSet object may contain to - * the given number. If this limit is exceeded, the excess rows are - * silently dropped. - * - * @param mRows an int indicating the current maximum number - * of rows; zero means that there is no limit - * @throws SQLException if an error occurs internally setting the - * maximum limit on the number of rows that a JDBC RowSet object - * can contain; or if max is less than 0; or - * if max is less than the fetchSize of the - * RowSet - */ - public void setMaxRows(int mRows) throws SQLException { - - int oldVal; - - try { - oldVal = getMaxRows(); - }catch(NullPointerException ex) { - oldVal = 0; - } - - if(oldVal != mRows) { - super.setMaxRows(mRows); - propertyChangeSupport.firePropertyChange("maxRows",oldVal,mRows); } } diff --git a/src/share/classes/com/sun/security/auth/callback/DialogCallbackHandler.java b/src/share/classes/com/sun/security/auth/callback/DialogCallbackHandler.java index 47809df2a0c521dce1c9d76f0236bc98b0c8514d..b0491ea564cac68266dd01ca5bae0b66c34bc93e 100644 --- a/src/share/classes/com/sun/security/auth/callback/DialogCallbackHandler.java +++ b/src/share/classes/com/sun/security/auth/callback/DialogCallbackHandler.java @@ -52,7 +52,9 @@ import javax.swing.JTextField; * This can be used by a JAAS application to instantiate a * CallbackHandler * @see javax.security.auth.callback + * @deprecated This class will be removed in a future release. */ +@Deprecated public class DialogCallbackHandler implements CallbackHandler { /* -- Fields -- */ diff --git a/src/share/classes/java/awt/EventQueue.java b/src/share/classes/java/awt/EventQueue.java index 5c38e466f84da9d7c619d56fb4d90d1ad9d27377..5ba9756a1af5ce61bc7a6948eac10b867e767eac 100644 --- a/src/share/classes/java/awt/EventQueue.java +++ b/src/share/classes/java/awt/EventQueue.java @@ -1046,6 +1046,10 @@ public class EventQueue { } final boolean detachDispatchThread(EventDispatchThread edt, boolean forceDetach) { + /* + * Minimize discard possibility for non-posted events + */ + SunToolkit.flushPendingEvents(); /* * This synchronized block is to secure that the event dispatch * thread won't die in the middle of posting a new event to the @@ -1060,11 +1064,8 @@ public class EventQueue { /* * Don't detach the thread if any events are pending. Not * sure if it's a possible scenario, though. - * - * Fix for 4648733. Check both the associated java event - * queue and the PostEventQueue. */ - if (!forceDetach && (peekEvent() != null) || !SunToolkit.isPostEventQueueEmpty()) { + if (!forceDetach && (peekEvent() != null)) { return false; } dispatchThread = null; diff --git a/src/share/classes/java/beans/IndexedPropertyDescriptor.java b/src/share/classes/java/beans/IndexedPropertyDescriptor.java index ed45609c1f0624510df8afbe1db79aa95db40af4..d3f16d2901e0a1cef2be8fdf07ec845d96a5dc18 100644 --- a/src/share/classes/java/beans/IndexedPropertyDescriptor.java +++ b/src/share/classes/java/beans/IndexedPropertyDescriptor.java @@ -495,6 +495,16 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { indexedReadMethodName = old.indexedReadMethodName; } + void updateGenericsFor(Class type) { + super.updateGenericsFor(type); + try { + setIndexedPropertyType(findIndexedPropertyType(getIndexedReadMethod0(), getIndexedWriteMethod0())); + } + catch (IntrospectionException exception) { + setIndexedPropertyType(null); + } + } + /** * Returns a hash code value for the object. * See {@link java.lang.Object#hashCode} for a complete description. diff --git a/src/share/classes/java/beans/Introspector.java b/src/share/classes/java/beans/Introspector.java index 54a5e49915a510c7f97cc2abe769b038093f74d2..48e7e3be4a1e30321d53226a39ffe1ce62e14ebe 100644 --- a/src/share/classes/java/beans/Introspector.java +++ b/src/share/classes/java/beans/Introspector.java @@ -574,26 +574,25 @@ public class Introspector { // replace existing property descriptor // only if we have types to resolve // in the context of this.beanClass - try { - String name = pd.getName(); - Method read = pd.getReadMethod(); - Method write = pd.getWriteMethod(); - boolean cls = true; - if (read != null) cls = cls && read.getGenericReturnType() instanceof Class; - if (write != null) cls = cls && write.getGenericParameterTypes()[0] instanceof Class; - if (pd instanceof IndexedPropertyDescriptor) { - IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor)pd; - Method readI = ipd.getIndexedReadMethod(); - Method writeI = ipd.getIndexedWriteMethod(); - if (readI != null) cls = cls && readI.getGenericReturnType() instanceof Class; - if (writeI != null) cls = cls && writeI.getGenericParameterTypes()[1] instanceof Class; - if (!cls) { - pd = new IndexedPropertyDescriptor(this.beanClass, name, read, write, readI, writeI); - } - } else if (!cls) { - pd = new PropertyDescriptor(this.beanClass, name, read, write); + Method read = pd.getReadMethod(); + Method write = pd.getWriteMethod(); + boolean cls = true; + if (read != null) cls = cls && read.getGenericReturnType() instanceof Class; + if (write != null) cls = cls && write.getGenericParameterTypes()[0] instanceof Class; + if (pd instanceof IndexedPropertyDescriptor) { + IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; + Method readI = ipd.getIndexedReadMethod(); + Method writeI = ipd.getIndexedWriteMethod(); + if (readI != null) cls = cls && readI.getGenericReturnType() instanceof Class; + if (writeI != null) cls = cls && writeI.getGenericParameterTypes()[1] instanceof Class; + if (!cls) { + pd = new IndexedPropertyDescriptor(ipd); + pd.updateGenericsFor(this.beanClass); } - } catch ( IntrospectionException e ) { + } + else if (!cls) { + pd = new PropertyDescriptor(pd); + pd.updateGenericsFor(this.beanClass); } } list.add(pd); diff --git a/src/share/classes/java/beans/PropertyDescriptor.java b/src/share/classes/java/beans/PropertyDescriptor.java index e5b42631fbe69ad53f8e4c0fafe6d3ffd7bc25a4..c03149c0574803b70cc656468718225c0266f6a4 100644 --- a/src/share/classes/java/beans/PropertyDescriptor.java +++ b/src/share/classes/java/beans/PropertyDescriptor.java @@ -632,6 +632,16 @@ public class PropertyDescriptor extends FeatureDescriptor { constrained = old.constrained; } + void updateGenericsFor(Class type) { + setClass0(type); + try { + setPropertyType(findPropertyType(getReadMethod0(), getWriteMethod0())); + } + catch (IntrospectionException exception) { + setPropertyType(null); + } + } + /** * Returns the property type that corresponds to the read and write method. * The type precedence is given to the readMethod. diff --git a/src/share/classes/java/io/FilePermission.java b/src/share/classes/java/io/FilePermission.java index a5781f3fb00a82a956f621660219452ed95893a2..b2ba8bdf7523dd0036be3e84798689313a5c6099 100644 --- a/src/share/classes/java/io/FilePermission.java +++ b/src/share/classes/java/io/FilePermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,10 +31,6 @@ import java.util.List; import java.util.ArrayList; import java.util.Vector; import java.util.Collections; -import java.io.ObjectStreamField; -import java.io.ObjectOutputStream; -import java.io.ObjectInputStream; -import java.io.IOException; import sun.security.util.SecurityConstants; /** @@ -424,7 +420,7 @@ public final class FilePermission extends Permission implements Serializable { /** * Converts an actions String to an actions mask. * - * @param action the action string. + * @param actions the action string. * @return the actions mask. */ private static int getMask(String actions) { @@ -435,7 +431,9 @@ public final class FilePermission extends Permission implements Serializable { if (actions == null) { return mask; } - // Check against use of constants (used heavily within the JDK) + + // Use object identity comparison against known-interned strings for + // performance benefit (these values are used heavily within the JDK). if (actions == SecurityConstants.FILE_READ_ACTION) { return READ; } else if (actions == SecurityConstants.FILE_WRITE_ACTION) { @@ -531,7 +529,7 @@ public final class FilePermission extends Permission implements Serializable { switch(a[i-matchlen]) { case ',': seencomma = true; - /*FALLTHROUGH*/ + break; case ' ': case '\r': case '\n': case '\f': case '\t': break; @@ -798,7 +796,7 @@ implements Serializable { * @return an enumeration of all the FilePermission objects. */ - public Enumeration elements() { + public Enumeration elements() { // Convert Iterator into Enumeration synchronized (this) { return Collections.enumeration(perms); @@ -843,7 +841,6 @@ implements Serializable { /* * Reads in a Vector of FilePermissions and saves them in the perms field. */ - @SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // Don't call defaultReadObject() @@ -852,6 +849,7 @@ implements Serializable { ObjectInputStream.GetField gfields = in.readFields(); // Get the one we want + @SuppressWarnings("unchecked") Vector permissions = (Vector)gfields.get("permissions", null); perms = new ArrayList<>(permissions.size()); perms.addAll(permissions); diff --git a/src/share/classes/java/lang/AbstractStringBuilder.java b/src/share/classes/java/lang/AbstractStringBuilder.java index eb38da21c0abc1d0e69e41fae57af217ce7e93ab..94585f86e50ad417d40ed22e121db196b5565f5a 100644 --- a/src/share/classes/java/lang/AbstractStringBuilder.java +++ b/src/share/classes/java/lang/AbstractStringBuilder.java @@ -96,6 +96,8 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { * * If the {@code minimumCapacity} argument is nonpositive, this * method takes no action and simply returns. + * Note that subsequent operations on this object can reduce the + * actual capacity below that requested here. * * @param minimumCapacity the minimum desired capacity. */ diff --git a/src/share/classes/java/lang/management/LockInfo.java b/src/share/classes/java/lang/management/LockInfo.java index b8c2fb5317fb6e9176dd4b634e1ef0ca92c40888..41c135ca5e121fc1d31edd6809e4bad214def6ee 100644 --- a/src/share/classes/java/lang/management/LockInfo.java +++ b/src/share/classes/java/lang/management/LockInfo.java @@ -27,7 +27,7 @@ package java.lang.management; import javax.management.openmbean.CompositeData; import java.util.concurrent.locks.*; -import java.beans.ConstructorProperties; +import sun.management.LockInfoCompositeData; /** * Information about a lock. A lock can be a built-in object monitor, @@ -44,8 +44,7 @@ import java.beans.ConstructorProperties; * *

MXBean Mapping

* LockInfo is mapped to a {@link CompositeData CompositeData} - * as specified in the - * type mapping rules of {@linkplain javax.management.MXBean MXBeans}. + * as specified in the {@link #from from} method. * * @see java.util.concurrent.locks.AbstractOwnableSynchronizer * @see java.util.concurrent.locks.Condition @@ -66,7 +65,6 @@ public class LockInfo { * @param identityHashCode the {@link System#identityHashCode * identity hash code} of the lock object. */ - @ConstructorProperties({"className", "identityHashCode"}) public LockInfo(String className, int identityHashCode) { if (className == null) { throw new NullPointerException("Parameter className cannot be null"); @@ -102,6 +100,50 @@ public class LockInfo { return identityHashCode; } + /** + * Returns a {@code LockInfo} object represented by the + * given {@code CompositeData}. + * The given {@code CompositeData} must contain the following attributes: + *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + *
Attribute NameType
classNamejava.lang.String
identityHashCodejava.lang.Integer
+ *
+ * + * @param cd {@code CompositeData} representing a {@code LockInfo} + * + * @throws IllegalArgumentException if {@code cd} does not + * represent a {@code LockInfo} with the attributes described + * above. + * @return a {@code LockInfo} object represented + * by {@code cd} if {@code cd} is not {@code null}; + * {@code null} otherwise. + * + * @since 1.8 + */ + public static LockInfo from(CompositeData cd) { + if (cd == null) { + return null; + } + + if (cd instanceof LockInfoCompositeData) { + return ((LockInfoCompositeData) cd).getLockInfo(); + } else { + return LockInfoCompositeData.toLockInfo(cd); + } + } + /** * Returns a string representation of a lock. The returned * string representation consists of the name of the class of the diff --git a/src/share/classes/java/lang/management/ThreadInfo.java b/src/share/classes/java/lang/management/ThreadInfo.java index a68850f6fd857d39ac68ee2159697601523836c2..d64effd69e26d9b45b6873a55cc850a305529b9b 100644 --- a/src/share/classes/java/lang/management/ThreadInfo.java +++ b/src/share/classes/java/lang/management/ThreadInfo.java @@ -696,9 +696,7 @@ public class ThreadInfo { * lockInfo * javax.management.openmbean.CompositeData * - the mapped type for {@link LockInfo} as specified in the - * - * type mapping rules of - * {@linkplain javax.management.MXBean MXBeans}. + * {@link LockInfo#from} method. *

* If cd does not contain this attribute, * the LockInfo object will be constructed from @@ -766,10 +764,7 @@ public class ThreadInfo { * lockedSynchronizers * javax.management.openmbean.CompositeData[] * whose element type is the mapped type for - * {@link LockInfo} as specified in the - * - * type mapping rules of - * {@linkplain javax.management.MXBean MXBeans}. + * {@link LockInfo} as specified in the {@link LockInfo#from} method. *

* If cd does not contain this attribute, * this attribute will be set to an empty array. @@ -830,7 +825,6 @@ public class ThreadInfo { * @since 1.6 */ public LockInfo[] getLockedSynchronizers() { - // represents an return lockedSynchronizers; } diff --git a/src/share/classes/java/lang/reflect/Constructor.java b/src/share/classes/java/lang/reflect/Constructor.java index fbf300b7fac34dfb57051cab3dc67d0c4adb3870..d84e373a7b50d7ee7c2836e38f22f858940a3a35 100644 --- a/src/share/classes/java/lang/reflect/Constructor.java +++ b/src/share/classes/java/lang/reflect/Constructor.java @@ -182,7 +182,7 @@ public final class Constructor extends Executable { * @since 1.5 */ @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public TypeVariable>[] getTypeParameters() { if (getSignature() != null) { return (TypeVariable>[])getGenericInfo().getTypeParameters(); diff --git a/src/share/classes/java/lang/reflect/Method.java b/src/share/classes/java/lang/reflect/Method.java index b940e23de42bd2b7bd98c309a2c36f8c27b2e7b6..068d864e96e861c0ab6f59c1d71c5ab7363a900b 100644 --- a/src/share/classes/java/lang/reflect/Method.java +++ b/src/share/classes/java/lang/reflect/Method.java @@ -194,7 +194,7 @@ public final class Method extends Executable { * @since 1.5 */ @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public TypeVariable[] getTypeParameters() { if (getGenericSignature() != null) return (TypeVariable[])getGenericInfo().getTypeParameters(); diff --git a/src/share/classes/java/net/SocketPermission.java b/src/share/classes/java/net/SocketPermission.java index b20563bc9dc63f87b01b1e12e88e4ce821c7ff03..da9abee01f644c47dee9e1c3cbd6da88c0adaa94 100644 --- a/src/share/classes/java/net/SocketPermission.java +++ b/src/share/classes/java/net/SocketPermission.java @@ -467,7 +467,6 @@ implements java.io.Serializable * @param action the action string * @return the action mask */ - @SuppressWarnings("fallthrough") private static int getMask(String action) { if (action == null) { @@ -480,7 +479,8 @@ implements java.io.Serializable int mask = NONE; - // Check against use of constants (used heavily within the JDK) + // Use object identity comparison against known-interned strings for + // performance benefit (these values are used heavily within the JDK). if (action == SecurityConstants.SOCKET_RESOLVE_ACTION) { return RESOLVE; } else if (action == SecurityConstants.SOCKET_CONNECT_ACTION) { @@ -568,7 +568,7 @@ implements java.io.Serializable switch(a[i-matchlen]) { case ',': seencomma = true; - /*FALLTHROUGH*/ + break; case ' ': case '\r': case '\n': case '\f': case '\t': break; diff --git a/src/share/classes/java/nio/channels/AsynchronousFileChannel.java b/src/share/classes/java/nio/channels/AsynchronousFileChannel.java index c47ba4255a9a5c5d2b82ffc75de21090c3462409..ba24eb113cfe8e5a749452f2202f6c0ce07f0f85 100644 --- a/src/share/classes/java/nio/channels/AsynchronousFileChannel.java +++ b/src/share/classes/java/nio/channels/AsynchronousFileChannel.java @@ -248,7 +248,7 @@ public abstract class AsynchronousFileChannel return provider.newAsynchronousFileChannel(file, options, executor, attrs); } - @SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction + @SuppressWarnings({"unchecked", "rawtypes"}) // generic array construction private static final FileAttribute[] NO_ATTRIBUTES = new FileAttribute[0]; /** diff --git a/src/share/classes/java/nio/channels/FileChannel.java b/src/share/classes/java/nio/channels/FileChannel.java index 1a6dc5fec85f964612ae59d6e9e9a6ee61b0c56c..f18f03e39c9fc05594eed9faaf63b3392b88d056 100644 --- a/src/share/classes/java/nio/channels/FileChannel.java +++ b/src/share/classes/java/nio/channels/FileChannel.java @@ -287,7 +287,7 @@ public abstract class FileChannel return provider.newFileChannel(path, options, attrs); } - @SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction + @SuppressWarnings({"unchecked", "rawtypes"}) // generic array construction private static final FileAttribute[] NO_ATTRIBUTES = new FileAttribute[0]; /** diff --git a/src/share/classes/java/util/ArrayDeque.java b/src/share/classes/java/util/ArrayDeque.java index 8a9a0ee7b8b16665353d25581d28ba17efbf412f..476b223329856ae31ea3f9e8e2e84f2419b45c6b 100644 --- a/src/share/classes/java/util/ArrayDeque.java +++ b/src/share/classes/java/util/ArrayDeque.java @@ -121,6 +121,7 @@ public class ArrayDeque extends AbstractCollection * * @param numElements the number of elements to hold */ + @SuppressWarnings("unchecked") private void allocateElements(int numElements) { int initialCapacity = MIN_INITIAL_CAPACITY; // Find the best power of two to hold elements. @@ -152,10 +153,11 @@ public class ArrayDeque extends AbstractCollection int newCapacity = n << 1; if (newCapacity < 0) throw new IllegalStateException("Sorry, deque too big"); - Object[] a = new Object[newCapacity]; + @SuppressWarnings("unchecked") + E[] a = (E[]) new Object[newCapacity]; System.arraycopy(elements, p, a, 0, r); System.arraycopy(elements, 0, a, r, p); - elements = (E[])a; + elements = a; head = 0; tail = n; } @@ -182,6 +184,7 @@ public class ArrayDeque extends AbstractCollection * Constructs an empty array deque with an initial capacity * sufficient to hold 16 elements. */ + @SuppressWarnings("unchecked") public ArrayDeque() { elements = (E[]) new Object[16]; } @@ -793,6 +796,7 @@ public class ArrayDeque extends AbstractCollection * this deque * @throws NullPointerException if the specified array is null */ + @SuppressWarnings("unchecked") public T[] toArray(T[] a) { int size = size(); if (a.length < size) diff --git a/src/share/classes/java/util/Arrays.java b/src/share/classes/java/util/Arrays.java index d0c3a60a05a41f50982c1871112d27657cf0b196..c4dde9bbedfd1cd330c650fe9fdb7041f1829ade 100644 --- a/src/share/classes/java/util/Arrays.java +++ b/src/share/classes/java/util/Arrays.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -560,7 +560,7 @@ public class Arrays { * off is the offset to generate corresponding low, high in src * To be removed in a future release. */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) private static void mergeSort(Object[] src, Object[] dest, int low, @@ -747,7 +747,7 @@ public class Arrays { * off is the offset into src corresponding to low in dest * To be removed in a future release. */ - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) private static void mergeSort(Object[] src, Object[] dest, int low, int high, int off, @@ -2832,6 +2832,7 @@ public class Arrays { * @return a list view of the specified array */ @SafeVarargs + @SuppressWarnings("varargs") public static List asList(T... a) { return new ArrayList<>(a); } diff --git a/src/share/classes/java/util/Collections.java b/src/share/classes/java/util/Collections.java index 533260326809ccf919f30c0c31eff90a20db657c..58eae6f950969366280567ddf9c3db7d2b597f5f 100644 --- a/src/share/classes/java/util/Collections.java +++ b/src/share/classes/java/util/Collections.java @@ -213,7 +213,7 @@ public class Collections { * @throws IllegalArgumentException (optional) if the comparator is * found to violate the {@link Comparator} contract */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public static void sort(List list, Comparator c) { Object[] a = list.toArray(); Arrays.sort(a, (Comparator)c); @@ -418,7 +418,7 @@ public class Collections { * @throws UnsupportedOperationException if the specified list or * its list-iterator does not support the set operation. */ - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public static void reverse(List list) { int size = list.size(); if (size < REVERSE_THRESHOLD || list instanceof RandomAccess) { @@ -497,7 +497,7 @@ public class Collections { * @throws UnsupportedOperationException if the specified list or its * list-iterator does not support the set operation. */ - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public static void shuffle(List list, Random rnd) { int size = list.size(); if (size < SHUFFLE_THRESHOLD || list instanceof RandomAccess) { @@ -535,7 +535,7 @@ public class Collections { * || j < 0 || j >= list.size()). * @since 1.4 */ - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public static void swap(List list, int i, int j) { // instead of using a raw type here, it's possible to capture // the wildcard but it will require a call to a supplementary @@ -669,7 +669,7 @@ public class Collections { * @throws NoSuchElementException if the collection is empty. * @see Comparable */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public static T min(Collection coll, Comparator comp) { if (comp==null) return (T)min((Collection) coll); @@ -740,7 +740,7 @@ public class Collections { * @throws NoSuchElementException if the collection is empty. * @see Comparable */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public static T max(Collection coll, Comparator comp) { if (comp==null) return (T)max((Collection) coll); @@ -1403,7 +1403,7 @@ public class Collections { extends UnmodifiableSet> { private static final long serialVersionUID = 7854390611657943733L; - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) UnmodifiableEntrySet(Set> s) { // Need to cast to raw in order to work around a limitation in the type system super((Set)s); @@ -3172,7 +3172,7 @@ public class Collections { * * @see #emptySet() */ - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public static final Set EMPTY_SET = new EmptySet<>(); /** @@ -3271,10 +3271,13 @@ public class Collections { return new EmptySortedSet<>(); } - public Comparator comparator() { + @Override + public Comparator comparator() { return null; } + @Override + @SuppressWarnings("unchecked") public SortedSet subSet(Object fromElement, Object toElement) { Objects.requireNonNull(fromElement); Objects.requireNonNull(toElement); @@ -3294,6 +3297,7 @@ public class Collections { return emptySortedSet(); } + @Override public SortedSet headSet(Object toElement) { Objects.requireNonNull(toElement); @@ -3304,6 +3308,7 @@ public class Collections { return emptySortedSet(); } + @Override public SortedSet tailSet(Object fromElement) { Objects.requireNonNull(fromElement); @@ -3314,10 +3319,12 @@ public class Collections { return emptySortedSet(); } + @Override public E first() { throw new NoSuchElementException(); } + @Override public E last() { throw new NoSuchElementException(); } @@ -3328,7 +3335,7 @@ public class Collections { * * @see #emptyList() */ - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public static final List EMPTY_LIST = new EmptyList<>(); /** @@ -3402,7 +3409,7 @@ public class Collections { * @see #emptyMap() * @since 1.3 */ - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public static final Map EMPTY_MAP = new EmptyMap<>(); /** @@ -3685,6 +3692,7 @@ public class Collections { return a; } + @SuppressWarnings("unchecked") public T[] toArray(T[] a) { final int n = this.n; if (a.length < n) { @@ -3731,6 +3739,7 @@ public class Collections { * the Comparable interface. * @see Comparable */ + @SuppressWarnings("unchecked") public static Comparator reverseOrder() { return (Comparator) ReverseComparator.REVERSE_ORDER; } diff --git a/src/share/classes/java/util/ComparableTimSort.java b/src/share/classes/java/util/ComparableTimSort.java index ae1ab6a1e817b30e5b3c2d324160cb76076802d2..dd7cb3a80ecb4a91fc8863635f58512941b0ba16 100644 --- a/src/share/classes/java/util/ComparableTimSort.java +++ b/src/share/classes/java/util/ComparableTimSort.java @@ -208,7 +208,7 @@ class ComparableTimSort { * @param start the index of the first element in the range that is * not already known to be sorted ({@code lo <= start <= hi}) */ - @SuppressWarnings({ "fallthrough", "rawtypes", "unchecked" }) + @SuppressWarnings({"fallthrough", "rawtypes", "unchecked"}) private static void binarySort(Object[] a, int lo, int hi, int start) { assert lo <= start && start <= hi; if (start == lo) @@ -277,7 +277,7 @@ class ComparableTimSort { * @return the length of the run beginning at the specified position in * the specified array */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) private static int countRunAndMakeAscending(Object[] a, int lo, int hi) { assert lo < hi; int runHi = lo + 1; @@ -612,7 +612,7 @@ class ComparableTimSort { * (must be aBase + aLen) * @param len2 length of second run to be merged (must be > 0) */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) private void mergeLo(int base1, int len1, int base2, int len2) { assert len1 > 0 && len2 > 0 && base1 + len1 == base2; @@ -729,7 +729,7 @@ class ComparableTimSort { * (must be aBase + aLen) * @param len2 length of second run to be merged (must be > 0) */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) private void mergeHi(int base1, int len1, int base2, int len2) { assert len1 > 0 && len2 > 0 && base1 + len1 == base2; diff --git a/src/share/classes/java/util/Currency.java b/src/share/classes/java/util/Currency.java index 11291d6b1e4670696355570550cfcddc68f32fe5..45e5747f069c79d382cd81707cfa08ea5a14a3b8 100644 --- a/src/share/classes/java/util/Currency.java +++ b/src/share/classes/java/util/Currency.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,8 @@ import java.io.IOException; import java.io.Serializable; import java.security.AccessController; import java.security.PrivilegedAction; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.regex.Pattern; @@ -60,7 +62,14 @@ import sun.util.logging.PlatformLogger; * and the ISO 4217 currency data respectively. The value part consists of * three ISO 4217 values of a currency, i.e., an alphabetic code, a numeric * code, and a minor unit. Those three ISO 4217 values are separated by commas. - * The lines which start with '#'s are considered comment lines. For example, + * The lines which start with '#'s are considered comment lines. An optional UTC + * timestamp may be specified per currency entry if users need to specify a + * cutover date indicating when the new data comes into effect. The timestamp is + * appended to the end of the currency properties and uses a comma as a separator. + * If a UTC datestamp is present and valid, the JRE will only use the new currency + * properties if the current UTC date is later than the date specified at class + * loading time. The format of the timestamp must be of ISO 8601 format : + * {@code 'yyyy-MM-dd'T'HH:mm:ss'}. For example, *

* * #Sample currency properties
@@ -69,6 +78,20 @@ import sun.util.logging.PlatformLogger; *

* will supersede the currency data for Japan. * + *

+ * + * #Sample currency properties with cutover date
+ * JP=JPZ,999,0,2014-01-01T00:00:00 + *
+ *

+ * will supersede the currency data for Japan if {@code Currency} class is loaded after + * 1st January 2014 00:00:00 GMT. + *

+ * Where syntactically malformed entries are encountered, the entry is ignored + * and the remainder of entries in file are processed. For instances where duplicate + * country code entries exist, the behavior of the Currency information for that + * {@code Currency} is undefined and the remainder of entries in file are processed. + * * @since 1.4 */ public final class Currency implements Serializable { @@ -100,7 +123,6 @@ public final class Currency implements Serializable { private static ConcurrentMap instances = new ConcurrentHashMap<>(7); private static HashSet available; - // Class data: currency data obtained from currency.data file. // Purpose: // - determine valid country codes @@ -235,7 +257,9 @@ public final class Currency implements Serializable { } Set keys = props.stringPropertyNames(); Pattern propertiesPattern = - Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])"); + Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*" + + "([0-3])\\s*,?\\s*(\\d{4}-\\d{2}-\\d{2}T\\d{2}:" + + "\\d{2}:\\d{2})?"); for (String key : keys) { replaceCurrencyData(propertiesPattern, key.toUpperCase(Locale.ROOT), @@ -645,29 +669,38 @@ public final class Currency implements Serializable { * consists of "three-letter alphabet code", "three-digit numeric code", * and "one-digit (0,1,2, or 3) default fraction digit". * For example, "JPZ,392,0". - * @throws + * An optional UTC date can be appended to the string (comma separated) + * to allow a currency change take effect after date specified. + * For example, "JP=JPZ,999,0,2014-01-01T00:00:00" has no effect unless + * UTC time is past 1st January 2014 00:00:00 GMT. */ private static void replaceCurrencyData(Pattern pattern, String ctry, String curdata) { if (ctry.length() != 2) { // ignore invalid country code - String message = new StringBuilder() - .append("The entry in currency.properties for ") - .append(ctry).append(" is ignored because of the invalid country code.") - .toString(); - info(message, null); + info("currency.properties entry for " + ctry + + " is ignored because of the invalid country code.", null); return; } Matcher m = pattern.matcher(curdata); - if (!m.find()) { + if (!m.find() || (m.group(4) == null && countOccurrences(curdata, ',') >= 3)) { // format is not recognized. ignore the data - String message = new StringBuilder() - .append("The entry in currency.properties for ") - .append(ctry) - .append(" is ignored because the value format is not recognized.") - .toString(); - info(message, null); + // if group(4) date string is null and we've 4 values, bad date value + info("currency.properties entry for " + ctry + + " ignored because the value format is not recognized.", null); + return; + } + + try { + if (m.group(4) != null && !isPastCutoverDate(m.group(4))) { + info("currency.properties entry for " + ctry + + " ignored since cutover date has not passed :" + curdata, null); + return; + } + } catch (IndexOutOfBoundsException | NullPointerException | ParseException ex) { + info("currency.properties entry for " + ctry + + " ignored since exception encountered :" + ex.getMessage(), null); return; } @@ -695,6 +728,26 @@ public final class Currency implements Serializable { setMainTableEntry(ctry.charAt(0), ctry.charAt(1), entry); } + private static boolean isPastCutoverDate(String s) + throws IndexOutOfBoundsException, NullPointerException, ParseException { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ROOT); + format.setTimeZone(TimeZone.getTimeZone("UTC")); + format.setLenient(false); + long time = format.parse(s.trim()).getTime(); + return System.currentTimeMillis() > time; + + } + + private static int countOccurrences(String value, char match) { + int count = 0; + for (char c : value.toCharArray()) { + if (c == match) { + ++count; + } + } + return count; + } + private static void info(String message, Throwable t) { PlatformLogger logger = PlatformLogger.getLogger("java.util.Currency"); if (logger.isLoggable(PlatformLogger.INFO)) { diff --git a/src/share/classes/java/util/HashMap.java b/src/share/classes/java/util/HashMap.java index 4687905e428ef22a2483cebc982a8accc8db6b7c..9990a6ef68c188b257d40791c87f388b02e96f25 100644 --- a/src/share/classes/java/util/HashMap.java +++ b/src/share/classes/java/util/HashMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -230,7 +230,7 @@ public class HashMap this.loadFactor = loadFactor; threshold = (int)Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1); - table = new Entry[capacity]; + table = new Entry[capacity]; init(); } @@ -1078,7 +1078,7 @@ public class HashMap capacity <<= 1; } - table = new Entry[capacity]; + table = new Entry[capacity]; threshold = (int) Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1); init(); // Give subclass a chance to do its thing. diff --git a/src/share/classes/java/util/JumboEnumSet.java b/src/share/classes/java/util/JumboEnumSet.java index 5db15bbdace54d1c1ad58cd6f643abfa9a4fdf5f..d2f3e83f7b1db1bfb6f10e1f1ff3dac7398d66aa 100644 --- a/src/share/classes/java/util/JumboEnumSet.java +++ b/src/share/classes/java/util/JumboEnumSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -121,6 +121,7 @@ class JumboEnumSet> extends EnumSet { unseen = elements[0]; } + @Override public boolean hasNext() { while (unseen == 0 && unseenIndex < elements.length - 1) unseen = elements[++unseenIndex]; @@ -128,6 +129,7 @@ class JumboEnumSet> extends EnumSet { } @Override + @SuppressWarnings("unchecked") public E next() { if (!hasNext()) throw new NoSuchElementException(); @@ -138,6 +140,7 @@ class JumboEnumSet> extends EnumSet { + Long.numberOfTrailingZeros(lastReturned)]; } + @Override public void remove() { if (lastReturned == 0) throw new IllegalStateException(); diff --git a/src/share/classes/java/util/PriorityQueue.java b/src/share/classes/java/util/PriorityQueue.java index bb9c114dd681f070e47a2a7fefbedab669f48c8d..dd67a0c5ba4d3c0908586443a3d86292873a82d3 100644 --- a/src/share/classes/java/util/PriorityQueue.java +++ b/src/share/classes/java/util/PriorityQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -330,6 +330,7 @@ public class PriorityQueue extends AbstractQueue return true; } + @SuppressWarnings("unchecked") public E peek() { if (size == 0) return null; diff --git a/src/share/classes/java/util/PropertyPermission.java b/src/share/classes/java/util/PropertyPermission.java index c89b28bf4d2425edd6a45e97f90ac3cabed54846..aed6f5c48c7709163f6986ae541bf5cfe6de53f8 100644 --- a/src/share/classes/java/util/PropertyPermission.java +++ b/src/share/classes/java/util/PropertyPermission.java @@ -246,7 +246,8 @@ public final class PropertyPermission extends BasicPermission { return mask; } - // Check against use of constants (used heavily within the JDK) + // Use object identity comparison against known-interned strings for + // performance benefit (these values are used heavily within the JDK). if (actions == SecurityConstants.PROPERTY_READ_ACTION) { return READ; } if (actions == SecurityConstants.PROPERTY_WRITE_ACTION) { diff --git a/src/share/classes/java/util/PropertyResourceBundle.java b/src/share/classes/java/util/PropertyResourceBundle.java index c7fe3b460a19be0b0c27841fe23c71282cf73d69..98ebd3b0f419241a4a3844133d42076d0bac0df3 100644 --- a/src/share/classes/java/util/PropertyResourceBundle.java +++ b/src/share/classes/java/util/PropertyResourceBundle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -125,6 +125,7 @@ public class PropertyResourceBundle extends ResourceBundle { * @throws IOException if an I/O error occurs * @throws NullPointerException if stream is null */ + @SuppressWarnings({"unchecked", "rawtypes"}) public PropertyResourceBundle (InputStream stream) throws IOException { Properties properties = new Properties(); properties.load(stream); @@ -143,6 +144,7 @@ public class PropertyResourceBundle extends ResourceBundle { * @throws NullPointerException if reader is null * @since 1.6 */ + @SuppressWarnings({"unchecked", "rawtypes"}) public PropertyResourceBundle (Reader reader) throws IOException { Properties properties = new Properties(); properties.load(reader); diff --git a/src/share/classes/java/util/jar/JarVerifier.java b/src/share/classes/java/util/jar/JarVerifier.java index 5c80d5013db337c4be80e9dc80998dacc9f5953c..a455fb1f2f7c2786086734205aff87cfa2e2ed3b 100644 --- a/src/share/classes/java/util/jar/JarVerifier.java +++ b/src/share/classes/java/util/jar/JarVerifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -325,6 +325,7 @@ class JarVerifier { * the given file in the jar. * @deprecated */ + @Deprecated public java.security.cert.Certificate[] getCerts(String name) { return mapSignersToCertArray(getCodeSigners(name)); diff --git a/src/share/classes/java/util/jar/Pack200.java b/src/share/classes/java/util/jar/Pack200.java index bb7cc2b47fef6551ad7f9121bfe600fe2063c863..0f28a14b5272e35b6d3032483627c5d3a59fbf06 100644 --- a/src/share/classes/java/util/jar/Pack200.java +++ b/src/share/classes/java/util/jar/Pack200.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003,2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003,2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -726,13 +726,13 @@ public abstract class Pack200 { private static final String PACK_PROVIDER = "java.util.jar.Pack200.Packer"; private static final String UNPACK_PROVIDER = "java.util.jar.Pack200.Unpacker"; - private static Class packerImpl; - private static Class unpackerImpl; + private static Class packerImpl; + private static Class unpackerImpl; private synchronized static Object newInstance(String prop) { String implName = "(unknown)"; try { - Class impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl; + Class impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl; if (impl == null) { // The first time, we must decide which class to use. implName = java.security.AccessController.doPrivileged( diff --git a/src/share/classes/java/util/zip/package.html b/src/share/classes/java/util/zip/package.html index 829a5e26da7184d65ecbdc472d9383d1ffb255d5..c934e4f5c9fafa4da868941fd70fe96c045f38db 100644 --- a/src/share/classes/java/util/zip/package.html +++ b/src/share/classes/java/util/zip/package.html @@ -2,7 +2,7 @@ ", 5); + println(); + --indentLevel; + } + if (format.getChildPolicy(elementName) == + IIOMetadataFormat.CHILD_POLICY_REPEAT) { + int minChildren = format.getElementMinChildren(elementName); + if (minChildren != 0) { + indent(); + println(" "); + } + int maxChildren = format.getElementMaxChildren(elementName); + if (maxChildren != Integer.MAX_VALUE) { + indent(); + println(" "); + } + } + } + + private void printAttributeInfo(IIOMetadataFormat format, + String elementName, + String attrName) { + indent(); + print(""); + + String description = format.getAttributeDescription(elementName, + attrName, + null); + if (description != null) { + ++indentLevel; + indent(); + printWrapped("", 5); + println(); + --indentLevel; + } + + int dataType = format.getAttributeDataType(elementName, attrName); + + switch (attrValueType) { + case IIOMetadataFormat.VALUE_ARBITRARY: + indent(); + println(" "); + break; + + case IIOMetadataFormat.VALUE_RANGE: + case IIOMetadataFormat.VALUE_RANGE_MIN_INCLUSIVE: + case IIOMetadataFormat.VALUE_RANGE_MAX_INCLUSIVE: + case IIOMetadataFormat.VALUE_RANGE_MIN_MAX_INCLUSIVE: + indent(); + println(" "); + + boolean minInclusive = + (attrValueType & + IIOMetadataFormat.VALUE_RANGE_MIN_INCLUSIVE_MASK) != 0; + boolean maxInclusive = + (attrValueType & + IIOMetadataFormat.VALUE_RANGE_MAX_INCLUSIVE_MASK) != 0; + indent(); + println(" "); + String maxValue = + format.getAttributeMaxValue(elementName, attrName); + // Hack: don't print "infinite" max values + if (dataType != IIOMetadataFormat.DATATYPE_INTEGER || + !maxValue.equals(maxInteger)) { + indent(); + println(" "); + } + break; + + case IIOMetadataFormat.VALUE_LIST: + indent(); + println(" "); + + int minLength = + format.getAttributeListMinLength(elementName, attrName); + if (minLength != 0) { + indent(); + println(" "); + } + int maxLength = + format.getAttributeListMaxLength(elementName, attrName); + if (maxLength != Integer.MAX_VALUE) { + indent(); + println(" "); + } + break; + } + } + + private void printObjectInfo(IIOMetadataFormat format, + String elementName) { + int objectType = format.getObjectValueType(elementName); + if (objectType == IIOMetadataFormat.VALUE_NONE) { + return; + } + + Class objectClass = format.getObjectClass(elementName); + if (objectClass != null) { + indent(); + if (objectType == IIOMetadataFormat.VALUE_LIST) { + println(" "); + } else { + println(" "); + } + + Object defaultValue = format.getObjectDefaultValue(elementName); + if (defaultValue != null) { + indent(); + println(" "); + } + + switch (objectType) { + case IIOMetadataFormat.VALUE_RANGE: + indent(); + println(" "); + indent(); + println(" "); + break; + + case IIOMetadataFormat.VALUE_ENUMERATION: + Object[] enums = format.getObjectEnumerations(elementName); + for (int i = 0; i < enums.length; i++) { + indent(); + println(" "); + } + break; + + case IIOMetadataFormat.VALUE_LIST: + int minLength = format.getObjectArrayMinLength(elementName); + if (minLength != 0) { + indent(); + println(" "); + } + int maxLength = format.getObjectArrayMaxLength(elementName); + if (maxLength != Integer.MAX_VALUE) { + indent(); + println(" "); + } + break; + } + } + } + + // Set of elements that have been printed already + Set printedElements = new HashSet(); + + // Set of elements that have been scheduled to be printed + Set scheduledElements = new HashSet(); + + private void print(IIOMetadataFormat format, + String elementName) { + // Don't print elements more than once + if (printedElements.contains(elementName)) { + return; + } + printedElements.add(elementName); + + // Add the unscheduled children of this node to a list, + // and mark them as scheduled + List children = new ArrayList(); + String[] childNames = format.getChildNames(elementName); + if (childNames != null) { + for (int i = 0; i < childNames.length; i++) { + String childName = childNames[i]; + if (!scheduledElements.contains(childName)) { + children.add(childName); + scheduledElements.add(childName); + } + } + } + + printElementInfo(format, elementName); + printObjectInfo(format, elementName); + + ++indentLevel; + String[] attrNames = format.getAttributeNames(elementName); + for (int i = 0; i < attrNames.length; i++) { + printAttributeInfo(format, elementName, attrNames[i]); + } + + // Recurse on child nodes + Iterator iter = children.iterator(); + while (iter.hasNext()) { + print(format, (String)iter.next()); + } + --indentLevel; + } + + public static void main(String[] args) { + IIOMetadataFormat format = null; + if (args.length == 0 || args[0].equals("javax_imageio_1.0")) { + format = IIOMetadataFormatImpl.getStandardFormatInstance(); + } else { + IIORegistry registry = IIORegistry.getDefaultInstance(); + Iterator iter = registry.getServiceProviders(ImageReaderSpi.class, + false); + while (iter.hasNext()) { + ImageReaderSpi spi = (ImageReaderSpi)iter.next(); + if (args[0].equals + (spi.getNativeStreamMetadataFormatName())) { + System.out.print(spi.getDescription(null)); + System.out.println(": native stream format"); + format = spi.getStreamMetadataFormat(args[0]); + break; + } + + String[] extraStreamFormatNames = + spi.getExtraStreamMetadataFormatNames(); + if (extraStreamFormatNames != null && + Arrays.asList(extraStreamFormatNames). + contains(args[0])) { + System.out.print(spi.getDescription(null)); + System.out.println(": extra stream format"); + format = spi.getStreamMetadataFormat(args[0]); + break; + } + + if (args[0].equals + (spi.getNativeImageMetadataFormatName())) { + System.out.print(spi.getDescription(null)); + System.out.println(": native image format"); + format = spi.getImageMetadataFormat(args[0]); + break; + } + + String[] extraImageFormatNames = + spi.getExtraImageMetadataFormatNames(); + if (extraImageFormatNames != null && + Arrays.asList(extraImageFormatNames).contains(args[0])) { + System.out.print(spi.getDescription(null)); + System.out.println(": extra image format"); + format = spi.getImageMetadataFormat(args[0]); + break; + } + } + } + + if (format == null) { + System.err.println("Unknown format: " + args[0]); + System.exit(0); + } + + MetadataFormatPrinter printer = new MetadataFormatPrinter(System.out); + printer.print(format); + } +} diff --git a/test/javax/imageio/metadata/ObjectArrayMaxLength.java b/test/javax/imageio/metadata/ObjectArrayMaxLength.java new file mode 100644 index 0000000000000000000000000000000000000000..e18bd8b522f7d8ff473672e0776c59b42e5f4deb --- /dev/null +++ b/test/javax/imageio/metadata/ObjectArrayMaxLength.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4406353 + * @run main ObjectArrayMaxLength + * @summary Tests the getObjectArrayMaxLength method of + * IIOMetadataFormatImpl + */ + +import javax.imageio.ImageTypeSpecifier; +import javax.imageio.metadata.IIOMetadataFormat; +import javax.imageio.metadata.IIOMetadataFormatImpl; + +class MyIIOMetadataFormatImpl extends IIOMetadataFormatImpl { + + MyIIOMetadataFormatImpl() { + super("root", CHILD_POLICY_EMPTY); + addObjectValue("root", byte.class, 123, 321); + } + + public boolean canNodeAppear(String nodeName, ImageTypeSpecifier type) { + return true; + } +} + +public class ObjectArrayMaxLength { + + public static void main(String[] args) { + IIOMetadataFormat f = new MyIIOMetadataFormatImpl(); + if (f.getObjectArrayMaxLength("root") != 321) { + throw new RuntimeException + ("Bad value for getObjectArrayMaxLength!"); + } + } +} diff --git a/test/javax/imageio/metadata/RegisteredFormatsTest.java b/test/javax/imageio/metadata/RegisteredFormatsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..785bfc6e1bfc44661b7d96fd27aae7dcd677e029 --- /dev/null +++ b/test/javax/imageio/metadata/RegisteredFormatsTest.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 5017991 + * @summary This test verifies two things: + * a) we can get MetadataFormat classes for + * each registered metadata format. + * b) all metadata formats for standard plugins + * are registered. + * @run main RegisteredFormatsTest + */ + +import javax.imageio.spi.IIORegistry; +import javax.imageio.spi.ImageReaderSpi; +import javax.imageio.metadata.IIOMetadataFormat; +import java.util.Iterator; +import java.util.Hashtable; +import java.util.Enumeration; + +public class RegisteredFormatsTest { + + private static Hashtable fmts; + + public static void main(String[] args) { + fmts = new Hashtable(); + + fmts.put("javax_imageio_jpeg_stream_1.0", Boolean.FALSE); + fmts.put("javax_imageio_jpeg_image_1.0", Boolean.FALSE); + fmts.put("javax_imageio_png_1.0", Boolean.FALSE); + fmts.put("javax_imageio_bmp_1.0", Boolean.FALSE); + fmts.put("javax_imageio_wbmp_1.0", Boolean.FALSE); + fmts.put("javax_imageio_gif_stream_1.0", Boolean.FALSE); + fmts.put("javax_imageio_gif_image_1.0", Boolean.FALSE); + + IIORegistry registry = IIORegistry.getDefaultInstance(); + Iterator iter = registry.getServiceProviders(ImageReaderSpi.class, + false); + while(iter.hasNext()) { + ImageReaderSpi spi = (ImageReaderSpi)iter.next(); + String fmt_name; + fmt_name = spi.getNativeStreamMetadataFormatName(); + testStreamMetadataFormat(spi, fmt_name); + + fmt_name = spi.getNativeImageMetadataFormatName(); + testImageMetadataFormat(spi, fmt_name); + + String[] fmt_names; + fmt_names = spi.getExtraStreamMetadataFormatNames(); + for (int i=0; fmt_names != null && i < fmt_names.length; i++) { + testStreamMetadataFormat(spi, fmt_names[i]); + } + + fmt_names = spi.getExtraImageMetadataFormatNames(); + for (int i=0; fmt_names != null && i < fmt_names.length; i++) { + testImageMetadataFormat(spi, fmt_names[i]); + } + } + Enumeration keys = fmts.keys(); + while (keys.hasMoreElements()) { + String key = (String)keys.nextElement(); + boolean val = ((Boolean)fmts.get(key)).booleanValue(); + if (!val) { + throw new RuntimeException("Test failed: format " + + key + "is not registered."); + } + } + } + + private static void testStreamMetadataFormat(ImageReaderSpi spi, + String fmt_name) { + if (fmt_name == null) { + return; + } + try { + testMetadataFormat(spi.getStreamMetadataFormat(fmt_name), + fmt_name); + } catch (Exception e) { + throw new RuntimeException("Test failed for " + fmt_name, + e); + } + } + + private static void testImageMetadataFormat(ImageReaderSpi spi, + String fmt_name) { + if (fmt_name == null) { + return; + } + try { + testMetadataFormat(spi.getImageMetadataFormat(fmt_name), + fmt_name); + } catch (Exception e) { + throw new RuntimeException("Test failed for " + fmt_name, + e); + } + } + private static void testMetadataFormat(IIOMetadataFormat fmt, + String fmt_name) { + System.out.print(fmt_name + "..."); + if (fmt != null) { + fmts.put(fmt_name, Boolean.TRUE); + System.out.println("Ok"); + } else { + throw new RuntimeException("Test failed for " + fmt_name); + } + } +} diff --git a/test/javax/imageio/metadata/RemoveElement.java b/test/javax/imageio/metadata/RemoveElement.java new file mode 100644 index 0000000000000000000000000000000000000000..c85e22b7520d792e2c625e58659f60c9b9c5860a --- /dev/null +++ b/test/javax/imageio/metadata/RemoveElement.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4432628 7186799 + * @run main RemoveElement + * @summary Checks if ImageMetadataFormatImpl.removeElement properly + * removes the element from its parent's child list. + */ + +import javax.imageio.metadata.IIOMetadataFormatImpl; +import javax.imageio.metadata.IIOMetadataFormat; +import javax.imageio.ImageTypeSpecifier; + +public class RemoveElement { + + public static void main(String[] args) { + String elem = "elem2"; + int policy = IIOMetadataFormat.CHILD_POLICY_SOME; + MyFormatImpl fmt = new MyFormatImpl("root", 1, 10); + fmt.addElement("elem1", "root", policy); + fmt.addElement(elem, "root", policy); + fmt.removeElement("elem1"); + + boolean gotIAE = false; + try { + fmt.getChildPolicy("elem1"); + } catch (IllegalArgumentException e) { + gotIAE = true; + } + if (!gotIAE) { + throw new RuntimeException("Element is still present!"); + } + String[] chNames = fmt.getChildNames("root"); + if (chNames.length != 1) { + throw new RuntimeException("Root still has more than 1 child!"); + } + if (!elem.equals(chNames[0])) { + throw new RuntimeException("Root's remaining child is incorrect!"); + } + } + + static class MyFormatImpl extends IIOMetadataFormatImpl { + + MyFormatImpl(String root, int minChildren, int maxChildren) { + super(root, minChildren, maxChildren); + } + + public void addElement(String elementName, + String parentName, + int childPolicy) { + super.addElement(elementName, parentName, childPolicy); + } + + public void removeElement(String elementName) { + super.removeElement(elementName); + } + + public boolean canNodeAppear(String elementName, + ImageTypeSpecifier imageType) { + return true; + } + } + +} diff --git a/test/javax/imageio/metadata/SetAttributeNode.java b/test/javax/imageio/metadata/SetAttributeNode.java new file mode 100644 index 0000000000000000000000000000000000000000..4d09b87d427df0abd9363e36d7ad9bb3bcd0ae69 --- /dev/null +++ b/test/javax/imageio/metadata/SetAttributeNode.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4507256 + * @run main SetAttributeNode + * @summary Tests the functionality of IIOMetadataNode.setAttributeNode(). + * Four separate tests are involved: + * 1) Tests whether a DOMException.INUSE_ATTRIBUTE_ERR is thrown if newAttr + * is already an attribute of another Element object. + * 2) Tests whether setAttributeNode() returns the old attribute if it is + * replaced. + * 3) Tests whether setAttributeNode() returns null if the new attribute is + * not replacing an existing attribute. + * 4) Tests whether the new attribute successfully replaces an existing one. + */ + +import javax.imageio.metadata.IIOMetadataNode; +import org.w3c.dom.Attr; +import org.w3c.dom.DOMException; +import org.w3c.dom.Element; +import org.w3c.dom.TypeInfo; + +public class SetAttributeNode { + + public static void test1() { + IIOMetadataNode parent = new IIOMetadataNode("parent"); + IIOMetadataNode elem = new IIOMetadataNode("elem"); + + MyAttrNode attrNode = new MyAttrNode("name", "value"); + elem.setAttributeNode(attrNode); + attrNode.setOwnerElement(elem); + + try { + parent.setAttributeNode(attrNode); + } catch (DOMException e) { + if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) { + throw new RuntimeException("Test 1 failed: " + + "Invalid exception code: " + + e.code); + } + return; + } + + throw new RuntimeException("Test 1 failed: DOMException not thrown"); + } + + public static void test2() { + String name = "attr"; + String oldValue = "old value"; + String newValue = "new value"; + Attr retAttr; + + IIOMetadataNode parent = new IIOMetadataNode("parent"); + MyAttrNode attrNode1 = new MyAttrNode(name, oldValue); + MyAttrNode attrNode2 = new MyAttrNode(name, newValue); + + retAttr = parent.setAttributeNode(attrNode1); + retAttr = parent.setAttributeNode(attrNode2); + + String actName = retAttr.getNodeName(); + String actValue = retAttr.getValue(); + + if (!actName.equals(name) || !actValue.equals(oldValue)) { + throw new RuntimeException("Test 2 failed: Invalid attribute " + + "returned: " + + "(name: " + actName + + ", value: " + actValue + ")"); + } + } + + public static void test3() { + IIOMetadataNode parent = new IIOMetadataNode("parent"); + MyAttrNode attrNode = new MyAttrNode("name", "value"); + Attr retAttr = parent.setAttributeNode(attrNode); + + if (retAttr != null) { + throw new RuntimeException("Test 3 failed: Return value is " + + "non-null"); + } + } + + public static void test4() { + String name = "name"; + String correctValue = "correct value"; + String wrongValue = "wrong value"; + + IIOMetadataNode parent = new IIOMetadataNode("parent"); + MyAttrNode attrNode1 = new MyAttrNode(name, wrongValue); + MyAttrNode attrNode2 = new MyAttrNode(name, correctValue); + + parent.setAttributeNode(attrNode1); + parent.setAttributeNode(attrNode2); + + Attr actAttr = parent.getAttributeNode(name); + String actValue = actAttr.getValue(); + + if (!actValue.equals(correctValue)) { + throw new RuntimeException("Test 4 failed: Return value is: " + + actValue); + } + } + + public static void main(String[] args) { + test1(); + test2(); + test3(); + test4(); + } +} + +class MyAttrNode extends IIOMetadataNode implements Attr { + + private Element owner; + private String name; + private String value; + + public MyAttrNode(String name, String value) { + this.name = name; + this.value = value; + } + + public Element getOwnerElement() { + return owner; + } + + public void setOwnerElement(Element owner) { + this.owner = owner; + } + + public String getName() { + return name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public boolean getSpecified() { + return false; + } + + public TypeInfo getSchemaTypeInfo() { + return null; + } + + public boolean isId() { + return false; + } +} diff --git a/test/javax/management/remote/mandatory/notif/ListenerScaleTest.java b/test/javax/management/remote/mandatory/notif/ListenerScaleTest.java index 4a278c39cb00e086c1e01f491716bbe1a6c33f77..b6cd2999bb1983c4eadafe76fe13aa60281dfaad 100644 --- a/test/javax/management/remote/mandatory/notif/ListenerScaleTest.java +++ b/test/javax/management/remote/mandatory/notif/ListenerScaleTest.java @@ -45,7 +45,7 @@ * * As usual with timing-sensitive tests, we could potentially get * sporadic failures. We fail if the ratio of the time with many - * MBeans to the time with just one MBean is more than 100. With the + * MBeans to the time with just one MBean is more than 500. With the * fix in place, it is usually less than 1, presumably because some * code was being interpreted during the first measurement but had * been compiled by the second. @@ -176,7 +176,7 @@ public class ListenerScaleTest { long manyMBeansTime = timeNotif(mbs); System.out.println("Time with many MBeans: " + manyMBeansTime + "ns"); double ratio = (double) manyMBeansTime / singleMBeanTime; - if (ratio > 100.0) + if (ratio > 500.0) throw new Exception("Failed: ratio=" + ratio); System.out.println("Test passed: ratio=" + ratio); } diff --git a/test/javax/swing/JMenuItem/6438430/bug6438430.java b/test/javax/swing/JMenuItem/6438430/bug6438430.java new file mode 100644 index 0000000000000000000000000000000000000000..47f679db4f54b199b3570f8c0ca7ac013eca8ee0 --- /dev/null +++ b/test/javax/swing/JMenuItem/6438430/bug6438430.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6438430 + * @summary Tests that submenu title doesn't overlap with submenu indicator + * in JPopupMenu + * @author Mikhail Lapshin + * @run main/othervm -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel bug6438430 + * @run main/othervm -Dswing.defaultlaf=com.sun.java.swing.plaf.motif.MotifLookAndFeel bug6438430 + */ + +import javax.swing.JMenuItem; +import javax.swing.JMenu; +import javax.swing.JCheckBoxMenuItem; + +public class bug6438430 { + public static void main(String[] args) { + JMenu subMenu1 = new JMenu("Long-titled Sub Menu"); + subMenu1.add(new JMenuItem("SubMenu Item")); + JMenuItem checkBoxMenuItem1 = new JCheckBoxMenuItem("CheckBox"); + + JMenu menu1 = new JMenu("It works always"); + menu1.add(checkBoxMenuItem1); + menu1.add(subMenu1); + + // Simulate DefaultMenuLayout calls. + // The latest traversed menu item must be the widest. + checkBoxMenuItem1.getPreferredSize(); + int width1 = subMenu1.getPreferredSize().width; + System.out.println("width1 = " + width1); + + + JMenu subMenu2 = new JMenu("Long-titled Sub Menu"); + subMenu2.add(new JMenuItem("SubMenu Item")); + JMenuItem checkBoxMenuItem2 = new JCheckBoxMenuItem("CheckBox"); + + JMenu menu2 = new JMenu("It did not work before the fix"); + menu2.add(subMenu2); + menu2.add(checkBoxMenuItem2); + + // Simulate DefaultMenuLayout calls. + // The latest traversed menu item must be the widest. + subMenu2.getPreferredSize(); + int width2 = checkBoxMenuItem2.getPreferredSize().width; + System.out.println("width2 = " + width2); + + if (width1 != width2) { + throw new RuntimeException( "Submenu title and submenu indicator " + + "overlap on JMenuItem!" ); + } + + System.out.println("Test passed"); + } +} diff --git a/test/sun/misc/URLClassPath/ClassnameCharTest.java b/test/sun/misc/URLClassPath/ClassnameCharTest.java index f5daad9cce6be8f3ec2e61337083db48d6f819b5..330ec329e34e27cfbac10158e99756c64656d33d 100644 --- a/test/sun/misc/URLClassPath/ClassnameCharTest.java +++ b/test/sun/misc/URLClassPath/ClassnameCharTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,75 +21,97 @@ * questions. */ -/** - * See ClassnameCharTest.sh for details. +/* @test + * @bug 4957669 5017871 + * @compile -XDignore.symbol.file=true ClassnameCharTest.java + * @run main ClassnameCharTest + * @summary cannot load class names containing some JSR 202 characters; + * plugin does not escape unicode character in http request */ import java.io.*; import java.net.*; -import java.security.*; +import java.util.jar.*; +import com.sun.net.httpserver.*; import sun.applet.AppletClassLoader; -public class ClassnameCharTest implements HttpCallback { - private static String FNPrefix; - private String[] respBody = new String[52]; - private byte[][] bufs = new byte[52][8*1024]; - private static MessageDigest md5; - private static byte[] file1Mac, file2Mac; - public void request (HttpTransaction req) { - try { - String filename = req.getRequestURI().getPath(); - System.out.println("getRequestURI = "+req.getRequestURI()); - System.out.println("filename = "+filename); - FileInputStream fis = new FileInputStream(FNPrefix+filename); - req.setResponseEntityBody(fis); - req.sendResponse(200, "OK"); - req.orderlyClose(); - } catch (IOException e) { - e.printStackTrace(); - } - } +public class ClassnameCharTest { + static String FNPrefix = System.getProperty("test.src", ".") + File.separator; + static File classesJar = new File(FNPrefix + "testclasses.jar"); static HttpServer server; - public static void test () throws Exception { + public static void realMain(String[] args) throws Exception { + server = HttpServer.create(new InetSocketAddress(0), 0); + server.createContext("/", new HttpHandler() { + @Override + public void handle(HttpExchange exchange) { + try { + String filename = exchange.getRequestURI().getPath(); + System.out.println("getRequestURI = " + exchange.getRequestURI()); + System.out.println("filename = " + filename); + try (FileInputStream fis = new FileInputStream(classesJar); + JarInputStream jis = new JarInputStream(fis)) { + JarEntry entry; + while ((entry = jis.getNextJarEntry()) != null) { + if (filename.endsWith(entry.getName())) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buf = new byte[8092]; + int count = 0; + while ((count = jis.read(buf)) != -1) + baos.write(buf, 0, count); + exchange.sendResponseHeaders(200, baos.size()); + try (OutputStream os = exchange.getResponseBody()) { + baos.writeTo(os); + } + return; + } + } + fail("Failed to find " + filename); + } + } catch (IOException e) { + unexpected(e); + } + } + }); + server.start(); try { - - FNPrefix = System.getProperty("test.classes", ".")+"/"; - server = new HttpServer (new ClassnameCharTest(), 1, 10, 0); - System.out.println ("Server: listening on port: " + server.getLocalPort()); - URL base = new URL("http://localhost:"+server.getLocalPort()); + URL base = new URL("http://localhost:" + server.getAddress().getPort()); + System.out.println ("Server: listening on " + base); MyAppletClassLoader acl = new MyAppletClassLoader(base); - Class class1 = acl.findClass("fo o"); - System.out.println("class1 = "+class1); + Class class1 = acl.findClass("fo o"); + System.out.println("class1 = " + class1); + pass(); // can't test the following class unless platform in unicode locale // Class class2 = acl.findClass("\u624b\u518c"); // System.out.println("class2 = "+class2); - } catch (Exception e) { - if (server != null) { - server.terminate(); - } - throw e; + } finally { + server.stop(0); } - - server.terminate(); } - public static void main(String[] args) throws Exception { - test(); - } - - public static void except (String s) { - server.terminate(); - throw new RuntimeException (s); - } -} + static class MyAppletClassLoader extends AppletClassLoader { + MyAppletClassLoader(URL base) { + super(base); + } -class MyAppletClassLoader extends AppletClassLoader { - MyAppletClassLoader(URL base) { - super(base); + @Override + public Class findClass(String name) throws ClassNotFoundException { + return super.findClass(name); + } } - public Class findClass(String name) throws ClassNotFoundException { - return super.findClass(name); - } + //--------------------- Infrastructure --------------------------- + static volatile int passed = 0, failed = 0; + static boolean pass() {passed++; return true;} + static boolean fail() {failed++; server.stop(0); Thread.dumpStack(); return false;} + static boolean fail(String msg) {System.out.println(msg); return fail();} + static void unexpected(Throwable t) {failed++; server.stop(0); t.printStackTrace();} + static boolean check(boolean cond) {if (cond) pass(); else fail(); return cond;} + static boolean equal(Object x, Object y) { + if (x == null ? y == null : x.equals(y)) return pass(); + else return fail(x + " not equal to " + y);} + public static void main(String[] args) throws Throwable { + try {realMain(args);} catch (Throwable t) {unexpected(t);} + System.out.println("\nPassed = " + passed + " failed = " + failed); + if (failed > 0) throw new AssertionError("Some tests failed");} } diff --git a/test/sun/misc/URLClassPath/ClassnameCharTest.sh b/test/sun/misc/URLClassPath/ClassnameCharTest.sh deleted file mode 100644 index 362d6dcb5451515772d98c12ed61d771f9e4f9f5..0000000000000000000000000000000000000000 --- a/test/sun/misc/URLClassPath/ClassnameCharTest.sh +++ /dev/null @@ -1,60 +0,0 @@ -#! /bin/sh - -# -# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @author Yingxian Wang -# @bug 4957669 5017871 -# @library ../../../sun/net/www/httptest/ -# @build HttpCallback HttpServer ClosedChannelList HttpTransaction -# @run shell/timeout=300 ClassnameCharTest.sh -# @summary ; cannot load class names containing some JSR 202 characters; -# plugin does not escape unicode character in http request -# -# set platform-dependent variables - -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin ) - PS=":" - FS="/" - ;; - Windows* | CYGWIN* ) - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -cp ${TESTSRC}${FS}testclasses.jar ${TESTCLASSES} -cd ${TESTCLASSES} -${TESTJAVA}${FS}bin${FS}jar xvf testclasses.jar "fo o.class" -${TESTJAVA}${FS}bin${FS}javac -d ${TESTCLASSES} ${TESTSRC}${FS}ClassnameCharTest.java - -${TESTJAVA}${FS}bin${FS}java -classpath "${TESTCLASSES}${PS}${TESTCLASSES}${FS}sun${FS}misc${FS}URLClassPath" ClassnameCharTest - -rm -rf "fo o.class" testclasses.jar diff --git a/test/sun/net/www/AuthHeaderTest.java b/test/sun/net/www/AuthHeaderTest.java index fb05f60be304a14a0b0bd450fcc45b55dfdec139..9e646e0a49b2dad9fb7286ddc5b23795277287e6 100644 --- a/test/sun/net/www/AuthHeaderTest.java +++ b/test/sun/net/www/AuthHeaderTest.java @@ -25,7 +25,7 @@ * @test * @bug 4804309 * @library ../../../sun/net/www/httptest/ - * @build HttpCallback HttpServer ClosedChannelList HttpTransaction + * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction * @run main AuthHeaderTest * @summary AuthHeaderTest bug */ @@ -90,13 +90,13 @@ public class AuthHeaderTest implements HttpCallback { is.close(); } - static HttpServer server; + static TestHttpServer server; public static void main (String[] args) throws Exception { MyAuthenticator auth = new MyAuthenticator (); Authenticator.setDefault (auth); try { - server = new HttpServer (new AuthHeaderTest(), 1, 10, 0); + server = new TestHttpServer (new AuthHeaderTest(), 1, 10, 0); System.out.println ("Server: listening on port: " + server.getLocalPort()); client ("http://localhost:"+server.getLocalPort()+"/d1/foo.html"); } catch (Exception e) { diff --git a/test/sun/net/www/http/ChunkedInputStream/ChunkedEncodingWithProgressMonitorTest.java b/test/sun/net/www/http/ChunkedInputStream/ChunkedEncodingWithProgressMonitorTest.java index e1827a96fe654bc042694a13df0c4a30df6b940d..c5e92d5b6f652dc2c04f135e5e05acd20b5762f5 100644 --- a/test/sun/net/www/http/ChunkedInputStream/ChunkedEncodingWithProgressMonitorTest.java +++ b/test/sun/net/www/http/ChunkedInputStream/ChunkedEncodingWithProgressMonitorTest.java @@ -24,8 +24,6 @@ /** * @test * @bug 4333920 4994372 - * @library ../../../../../sun/net/www/httptest/ - * @build HttpCallback HttpServer ClosedChannelList HttpTransaction * @run main ChunkedEncodingWithProgressMonitorTest * @summary ChunkedEncoding unit test; MeteredStream/ProgressData problem */ diff --git a/test/sun/net/www/http/KeepAliveCache/B5045306.java b/test/sun/net/www/http/KeepAliveCache/B5045306.java index 0a13017f43b8726491a5cefa30b64baecf291084..c36d2cfc3d9b25dd6c4c6ab3fcf1255fe89228cb 100644 --- a/test/sun/net/www/http/KeepAliveCache/B5045306.java +++ b/test/sun/net/www/http/KeepAliveCache/B5045306.java @@ -25,7 +25,7 @@ * @test * @bug 5045306 6356004 6993490 * @library ../../httptest/ - * @build HttpCallback HttpServer HttpTransaction + * @build HttpCallback TestHttpServer HttpTransaction * @run main/othervm B5045306 * @summary Http keep-alive implementation is not efficient */ @@ -50,7 +50,7 @@ import java.lang.management.*; public class B5045306 { static SimpleHttpTransaction httpTrans; - static HttpServer server; + static TestHttpServer server; public static void main(String[] args) throws Exception { startHttpServer(); @@ -60,7 +60,7 @@ public class B5045306 public static void startHttpServer() { try { httpTrans = new SimpleHttpTransaction(); - server = new HttpServer(httpTrans, 1, 10, 0); + server = new TestHttpServer(httpTrans, 1, 10, 0); } catch (IOException e) { e.printStackTrace(); } diff --git a/test/sun/net/www/httptest/HttpTransaction.java b/test/sun/net/www/httptest/HttpTransaction.java index fa269f235bbf21368b5bbf2b9bad8459eb641358..6007070b8e30e63a818e9d7bb381c0e4c93ceaa4 100644 --- a/test/sun/net/www/httptest/HttpTransaction.java +++ b/test/sun/net/www/httptest/HttpTransaction.java @@ -37,7 +37,7 @@ public class HttpTransaction { String command; URI requesturi; - HttpServer.Server server; + TestHttpServer.Server server; MessageHeader reqheaders, reqtrailers; String reqbody; byte[] rspbody; @@ -46,7 +46,7 @@ public class HttpTransaction { int rspbodylen; boolean rspchunked; - HttpTransaction (HttpServer.Server server, String command, + HttpTransaction (TestHttpServer.Server server, String command, URI requesturi, MessageHeader headers, String body, MessageHeader trailers, SelectionKey key) { this.command = command; @@ -290,7 +290,7 @@ public class HttpTransaction { * @param rTag the response string to send with the response code */ public void sendResponse (int rCode, String rTag) throws IOException { - OutputStream os = new HttpServer.NioOutputStream(channel()); + OutputStream os = new TestHttpServer.NioOutputStream(channel()); PrintStream ps = new PrintStream (os); ps.print ("HTTP/1.1 " + rCode + " " + rTag + "\r\n"); if (rspheaders != null) { @@ -314,7 +314,7 @@ public class HttpTransaction { /* sends one byte less than intended */ public void sendPartialResponse (int rCode, String rTag)throws IOException { - OutputStream os = new HttpServer.NioOutputStream(channel()); + OutputStream os = new TestHttpServer.NioOutputStream(channel()); PrintStream ps = new PrintStream (os); ps.print ("HTTP/1.1 " + rCode + " " + rTag + "\r\n"); ps.flush(); diff --git a/test/sun/net/www/httptest/HttpServer.java b/test/sun/net/www/httptest/TestHttpServer.java similarity index 98% rename from test/sun/net/www/httptest/HttpServer.java rename to test/sun/net/www/httptest/TestHttpServer.java index 33541f6a52475a2ae50e0da1aa91356c402d521a..7f91461b7342b0cb4c404079c477e5161a1a620d 100644 --- a/test/sun/net/www/httptest/HttpServer.java +++ b/test/sun/net/www/httptest/TestHttpServer.java @@ -48,7 +48,7 @@ import java.util.*; * NOTE NOTE NOTE NOTE NOTE NOTE NOTE */ -public class HttpServer { +public class TestHttpServer { ServerSocketChannel schan; int threads; @@ -57,19 +57,19 @@ public class HttpServer { Server[] servers; /** - * Create a HttpServer instance with the specified callback object + * Create a TestHttpServer instance with the specified callback object * for handling requests. One thread is created to handle requests, * and up to ten TCP connections will be handled simultaneously. * @param cb the callback object which is invoked to handle each * incoming request */ - public HttpServer (HttpCallback cb) throws IOException { + public TestHttpServer (HttpCallback cb) throws IOException { this (cb, 1, 10, 0); } /** - * Create a HttpServer instance with the specified number of + * Create a TestHttpServer instance with the specified number of * threads and maximum number of connections per thread. This functions * the same as the 4 arg constructor, where the port argument is set to zero. * @param cb the callback object which is invoked to handle each @@ -80,13 +80,13 @@ public class HttpServer { * handle per thread */ - public HttpServer (HttpCallback cb, int threads, int cperthread) + public TestHttpServer (HttpCallback cb, int threads, int cperthread) throws IOException { this (cb, threads, cperthread, 0); } /** - * Create a HttpServer instance with the specified number + * Create a TestHttpServer instance with the specified number * of threads and maximum number of connections per thread and running on * the specified port. The specified number of threads are created to * handle incoming requests, and each thread is allowed @@ -101,7 +101,7 @@ public class HttpServer { * means choose any free port. */ - public HttpServer (HttpCallback cb, int threads, int cperthread, int port) + public TestHttpServer (HttpCallback cb, int threads, int cperthread, int port) throws IOException { schan = ServerSocketChannel.open (); InetSocketAddress addr = new InetSocketAddress (port); diff --git a/test/sun/net/www/protocol/http/B6296310.java b/test/sun/net/www/protocol/http/B6296310.java index 7e545cd37afe1a100efbece29fe4e530599b735d..a932d9caece85a9ed9046d84e5d52a420810a418 100644 --- a/test/sun/net/www/protocol/http/B6296310.java +++ b/test/sun/net/www/protocol/http/B6296310.java @@ -25,7 +25,7 @@ * @test * @bug 6296310 * @library ../../httptest/ - * @build HttpCallback HttpServer HttpTransaction + * @build HttpCallback TestHttpServer HttpTransaction * @run main/othervm B6296310 * @summary REGRESSION: AppletClassLoader.getResourceAsStream() behaviour is wrong in some cases */ @@ -42,7 +42,7 @@ import java.util.*; public class B6296310 { static SimpleHttpTransaction httpTrans; - static HttpServer server; + static TestHttpServer server; public static void main(String[] args) { @@ -55,7 +55,7 @@ public class B6296310 public static void startHttpServer() { try { httpTrans = new SimpleHttpTransaction(); - server = new HttpServer(httpTrans, 1, 10, 0); + server = new TestHttpServer(httpTrans, 1, 10, 0); } catch (IOException e) { e.printStackTrace(); } diff --git a/test/sun/net/www/protocol/http/B6299712.java b/test/sun/net/www/protocol/http/B6299712.java index 2111a2e0bfa9e703a05a2980d57be1d09eae7401..727b62e5743d04eee870bf0802d44b3e5eee7d62 100644 --- a/test/sun/net/www/protocol/http/B6299712.java +++ b/test/sun/net/www/protocol/http/B6299712.java @@ -25,7 +25,7 @@ * @test * @bug 6299712 * @library ../../httptest/ - * @build HttpCallback HttpServer ClosedChannelList HttpTransaction + * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction * @run main/othervm B6299712 * @summary NullPointerException in sun.net.www.protocol.http.HttpURLConnection.followRedirect */ @@ -49,7 +49,7 @@ import java.util.*; */ public class B6299712 { static SimpleHttpTransaction httpTrans; - static HttpServer server; + static TestHttpServer server; public static void main(String[] args) throws Exception { ResponseCache.setDefault(new DeployCacheHandler()); @@ -61,7 +61,7 @@ public class B6299712 { public static void startHttpServer() { try { httpTrans = new SimpleHttpTransaction(); - server = new HttpServer(httpTrans, 1, 10, 0); + server = new TestHttpServer(httpTrans, 1, 10, 0); } catch (IOException e) { e.printStackTrace(); } diff --git a/test/sun/net/www/protocol/http/RelativeRedirect.java b/test/sun/net/www/protocol/http/RelativeRedirect.java index 651bcacc7889ba5e2df78ebf8e24d5a52350f858..861ee6a95d06861a116409068d7fd132f7648eea 100644 --- a/test/sun/net/www/protocol/http/RelativeRedirect.java +++ b/test/sun/net/www/protocol/http/RelativeRedirect.java @@ -25,7 +25,7 @@ * @test * @bug 4726087 * @library ../../httptest/ - * @build HttpCallback HttpServer ClosedChannelList HttpTransaction + * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction * @run main RelativeRedirect * @summary URLConnection cannot handle redirects */ @@ -35,7 +35,7 @@ import java.net.*; public class RelativeRedirect implements HttpCallback { static int count = 0; - static HttpServer server; + static TestHttpServer server; static class MyAuthenticator extends Authenticator { public MyAuthenticator () { @@ -89,7 +89,7 @@ public class RelativeRedirect implements HttpCallback { MyAuthenticator auth = new MyAuthenticator (); Authenticator.setDefault (auth); try { - server = new HttpServer (new RelativeRedirect(), 1, 10, 0); + server = new TestHttpServer (new RelativeRedirect(), 1, 10, 0); System.out.println ("Server: listening on port: " + server.getLocalPort()); URL url = new URL("http://localhost:"+server.getLocalPort()); System.out.println ("client opening connection to: " + url); diff --git a/test/sun/net/www/protocol/http/ResponseCacheStream.java b/test/sun/net/www/protocol/http/ResponseCacheStream.java index 4b8900e67f2ca8c3f038cee91095f0d94a185a0d..6b85d7f4c73ceab95b1c02a7bcb105547adbc580 100644 --- a/test/sun/net/www/protocol/http/ResponseCacheStream.java +++ b/test/sun/net/www/protocol/http/ResponseCacheStream.java @@ -25,7 +25,7 @@ * @test * @bug 6262486 * @library ../../httptest/ - * @build HttpCallback HttpServer ClosedChannelList HttpTransaction + * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction * @run main/othervm -Dhttp.keepAlive=false ResponseCacheStream * @summary COMPATIBILITY: jagex_com - Monkey Puzzle applet fails to load */ @@ -91,13 +91,13 @@ public class ResponseCacheStream implements HttpCallback { } } - static HttpServer server; + static TestHttpServer server; public static void main(String[] args) throws Exception { MyResponseCache cache = new MyResponseCache(); try { ResponseCache.setDefault(cache); - server = new HttpServer (new ResponseCacheStream()); + server = new TestHttpServer (new ResponseCacheStream()); System.out.println ("Server: listening on port: " + server.getLocalPort()); URL url = new URL ("http://127.0.0.1:"+server.getLocalPort()+"/"); System.out.println ("Client: connecting to " + url); diff --git a/test/sun/net/www/protocol/http/SetChunkedStreamingMode.java b/test/sun/net/www/protocol/http/SetChunkedStreamingMode.java index d14fb8693109c36c4baa799402c1bb7f0a3b6b64..e1d2fd9a8659962079cf71b0dad727e358cffe75 100644 --- a/test/sun/net/www/protocol/http/SetChunkedStreamingMode.java +++ b/test/sun/net/www/protocol/http/SetChunkedStreamingMode.java @@ -25,7 +25,7 @@ * @test * @bug 5049976 * @library ../../httptest/ - * @build HttpCallback HttpServer ClosedChannelList HttpTransaction + @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction * @run main SetChunkedStreamingMode * @summary Unspecified NPE is thrown when streaming output mode is enabled */ @@ -60,11 +60,11 @@ public class SetChunkedStreamingMode implements HttpCallback { System.out.println ("finished reading"); } - static HttpServer server; + static TestHttpServer server; public static void main (String[] args) throws Exception { try { - server = new HttpServer (new SetChunkedStreamingMode(), 1, 10, 0); + server = new TestHttpServer (new SetChunkedStreamingMode(), 1, 10, 0); System.out.println ("Server: listening on port: " + server.getLocalPort()); URL url = new URL ("http://127.0.0.1:"+server.getLocalPort()+"/"); System.out.println ("Client: connecting to " + url); diff --git a/test/sun/security/ssl/sun/net/www/http/ChunkedOutputStream/Test.java b/test/sun/security/ssl/sun/net/www/http/ChunkedOutputStream/Test.java index 9a6af1a7c3ddfd08f26153d9922e845557a24240..686411bf155afc4cca29a299bb5d44821a899b96 100644 --- a/test/sun/security/ssl/sun/net/www/http/ChunkedOutputStream/Test.java +++ b/test/sun/security/ssl/sun/net/www/http/ChunkedOutputStream/Test.java @@ -25,6 +25,7 @@ * @test * @bug 5026745 * @library ../../httpstest/ + * @build TestHttpsServer HttpCallback * @run main/othervm Test * * SunJSSE does not support dynamic system properties, no way to re-use @@ -275,7 +276,7 @@ public class Test implements HttpCallback { } } - static HttpServer server; + static TestHttpsServer server; public static void main (String[] args) throws Exception { // setup properties to do ssl @@ -296,7 +297,7 @@ public class Test implements HttpCallback { HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier()); try { - server = new HttpServer (new Test(), 1, 10, 0); + server = new TestHttpsServer (new Test(), 1, 10, 0); System.out.println ("Server started: listening on port: " + server.getLocalPort()); // the test server doesn't support keep-alive yet // test1("http://localhost:"+server.getLocalPort()+"/d0"); diff --git a/test/sun/security/ssl/sun/net/www/httpstest/HttpTransaction.java b/test/sun/security/ssl/sun/net/www/httpstest/HttpTransaction.java index 16d26aa60e8ce2aeaad980ced9a11d43cf9b3f14..5389d9f3fa30353f1ff246646b69cc5f203510f8 100644 --- a/test/sun/security/ssl/sun/net/www/httpstest/HttpTransaction.java +++ b/test/sun/security/ssl/sun/net/www/httpstest/HttpTransaction.java @@ -37,7 +37,7 @@ public class HttpTransaction { String command; URI requesturi; - HttpServer.ServerWorker server; + TestHttpsServer.ServerWorker server; MessageHeader reqheaders, reqtrailers; String reqbody; byte[] rspbody; @@ -46,7 +46,7 @@ public class HttpTransaction { int rspbodylen; boolean rspchunked; - HttpTransaction (HttpServer.ServerWorker server, String command, + HttpTransaction (TestHttpsServer.ServerWorker server, String command, URI requesturi, MessageHeader headers, String body, MessageHeader trailers, SocketChannel ch) { this.command = command; @@ -290,7 +290,7 @@ public class HttpTransaction { * @param rTag the response string to send with the response code */ public void sendResponse (int rCode, String rTag) throws IOException { - OutputStream os = new HttpServer.NioOutputStream(channel(), server.getSSLEngine(), server.outNetBB(), server.outAppBB()); + OutputStream os = new TestHttpsServer.NioOutputStream(channel(), server.getSSLEngine(), server.outNetBB(), server.outAppBB()); PrintStream ps = new PrintStream (os); ps.print ("HTTP/1.1 " + rCode + " " + rTag + "\r\n"); if (rspheaders != null) { @@ -314,7 +314,7 @@ public class HttpTransaction { /* sends one byte less than intended */ public void sendPartialResponse (int rCode, String rTag)throws IOException { - OutputStream os = new HttpServer.NioOutputStream(channel(), server.getSSLEngine(), server.outNetBB(), server.outAppBB()); + OutputStream os = new TestHttpsServer.NioOutputStream(channel(), server.getSSLEngine(), server.outNetBB(), server.outAppBB()); PrintStream ps = new PrintStream (os); ps.print ("HTTP/1.1 " + rCode + " " + rTag + "\r\n"); ps.flush(); diff --git a/test/sun/security/ssl/sun/net/www/httpstest/HttpServer.java b/test/sun/security/ssl/sun/net/www/httpstest/TestHttpsServer.java similarity index 98% rename from test/sun/security/ssl/sun/net/www/httpstest/HttpServer.java rename to test/sun/security/ssl/sun/net/www/httpstest/TestHttpsServer.java index 2d48847b2e6d6fb22f477fbb978923d6a353b7c5..21fc8ab29c219524fe36ef6819afc55b1b27f452 100644 --- a/test/sun/security/ssl/sun/net/www/httpstest/HttpServer.java +++ b/test/sun/security/ssl/sun/net/www/httpstest/TestHttpsServer.java @@ -51,7 +51,7 @@ import java.security.*; * NOTE NOTE NOTE NOTE NOTE NOTE NOTE */ -public class HttpServer { +public class TestHttpsServer { ServerSocketChannel schan; int threads; @@ -63,19 +63,19 @@ public class HttpServer { static SSLContext sslCtx; /** - * Create a HttpServer instance with the specified callback object + * Create a TestHttpsServer instance with the specified callback object * for handling requests. One thread is created to handle requests, * and up to ten TCP connections will be handled simultaneously. * @param cb the callback object which is invoked to handle each * incoming request */ - public HttpServer (HttpCallback cb) throws IOException { + public TestHttpsServer (HttpCallback cb) throws IOException { this (cb, 1, 10, 0); } /** - * Create a HttpServer instance with the specified number of + * Create a TestHttpsServer instance with the specified number of * threads and maximum number of connections per thread. This functions * the same as the 4 arg constructor, where the port argument is set to zero. * @param cb the callback object which is invoked to handle each @@ -86,13 +86,13 @@ public class HttpServer { * handle per thread */ - public HttpServer (HttpCallback cb, int threads, int cperthread) + public TestHttpsServer (HttpCallback cb, int threads, int cperthread) throws IOException { this (cb, threads, cperthread, 0); } /** - * Create a HttpServer instance with the specified number + * Create a TestHttpsServer instance with the specified number * of threads and maximum number of connections per thread and running on * the specified port. The specified number of threads are created to * handle incoming requests, and each thread is allowed @@ -107,7 +107,7 @@ public class HttpServer { * means choose any free port. */ - public HttpServer (HttpCallback cb, int threads, int cperthread, int port) + public TestHttpsServer (HttpCallback cb, int threads, int cperthread, int port) throws IOException { schan = ServerSocketChannel.open (); InetSocketAddress addr = new InetSocketAddress (port); diff --git a/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java b/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java index 85ac5cb5a73465555674002515abc745700b27fe..4df22a85c45e46e069ae24b5d7d134446f6e5139 100644 --- a/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java +++ b/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java @@ -25,7 +25,7 @@ * @test * @bug 6216082 * @library ../../../httpstest/ - * @build HttpCallback HttpServer ClosedChannelList HttpTransaction TunnelProxy + * @build HttpCallback TestHttpsServer ClosedChannelList HttpTransaction TunnelProxy * @summary Redirect problem with HttpsURLConnection using a proxy * SunJSSE does not support dynamic system properties, no way to re-use * system properties in samevm/agentvm mode. @@ -39,7 +39,7 @@ import java.util.*; public class B6216082 { static SimpleHttpTransaction httpTrans; - static HttpServer server; + static TestHttpsServer server; static TunnelProxy proxy; // it seems there's no proxy ever if a url points to 'localhost', @@ -133,7 +133,7 @@ public class B6216082 { // Both the https server and the proxy let the // system pick up an ephemeral port. httpTrans = new SimpleHttpTransaction(); - server = new HttpServer(httpTrans, 1, 10, 0); + server = new TestHttpsServer(httpTrans, 1, 10, 0); proxy = new TunnelProxy(1, 10, 0); } diff --git a/test/sun/security/tools/keytool/autotest.sh b/test/sun/security/tools/keytool/autotest.sh index ee6a0d5e55b5b8613ddc556cfdad6bcee0d9ff60..f414380a9523a09d6399790020f628f41aecd241 100644 --- a/test/sun/security/tools/keytool/autotest.sh +++ b/test/sun/security/tools/keytool/autotest.sh @@ -41,30 +41,35 @@ if [ "${TESTJAVA}" = "" ] ; then exit 1 fi +find_one() { + for TARGET_FILE in $@; do + if [ -e "$TARGET_FILE" ]; then + echo $TARGET_FILE + return + fi + done +} + # set platform-dependent variables OS=`uname -s` case "$OS" in SunOS ) FS="/" - LIBNAME=libsoftokn3.so - ARCH=`isainfo` - case "$ARCH" in - sparc* ) - NSSDIR="/usr/lib/mps" - ;; - * ) - echo "Will not run test on: Solaris ${ARCH}" - exit 0; - ;; - esac + LIBNAME="/usr/lib/mps/libsoftokn3.so" ;; Linux ) - LIBNAME=libsoftokn3.so ARCH=`uname -m` FS="/" case "$ARCH" in i[3-6]86 ) - NSSDIR="/usr/lib" + LIBNAME=`find_one \ + "/usr/lib/libsoftokn3.so" \ + "/usr/lib/i386-linux-gnu/nss/libsoftokn3.so"` + ;; + x86_64 ) + LIBNAME=`find_one \ + "/usr/lib64/libsoftokn3.so" \ + "/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so"` ;; * ) echo "Will not run test on: Linux ${ARCH}" @@ -78,7 +83,13 @@ case "$OS" in ;; esac -${TESTJAVA}${FS}bin${FS}javac -d . ${TESTSRC}${FS}KeyToolTest.java || exit 10 +if [ "$LIBNAME" = "" ]; then + echo "Cannot find LIBNAME" + exit 1 +fi + +${TESTJAVA}${FS}bin${FS}javac -d . -XDignore.symbol.file \ + ${TESTSRC}${FS}KeyToolTest.java || exit 10 NSS=${TESTSRC}${FS}..${FS}..${FS}pkcs11${FS}nss @@ -91,7 +102,7 @@ chmod u+w key3.db chmod u+w cert8.db echo | ${TESTJAVA}${FS}bin${FS}java -Dnss \ - -Dnss.lib=${NSSDIR}${FS}${LIBNAME} \ + -Dnss.lib=${LIBNAME} \ KeyToolTest status=$? @@ -105,4 +116,3 @@ rm KeyToolTest*.class rm TestException.class exit $status -