--- a/jdk/make/launcher/Launcher-jdk.accessibility.gmk Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/make/launcher/Launcher-jdk.accessibility.gmk Mon Dec 14 10:36:12 2015 -0800
@@ -73,8 +73,9 @@
$$(eval $$(call SetupNativeCompilation, BUILD_JACCESSINSPECTOR$1, \
SRC := $(TOPDIR)/jaccessinspector $(TOPDIR)/common \
$(TOPDIR)/toolscommon $(TOPDIR)/include/bridge, \
- CFLAGS := $$(CFLAGS_JDKEXE) $(TOOLS_CFLAGS) -DACCESSBRIDGE_ARCH_$2 /EHsc, \
- LDFLAGS := $$(LDFLAGS_JDKEXE) /STACK:655360 Advapi32.lib User32.lib, \
+ CFLAGS := $$(CFLAGS_JDKEXE) $(TOOLS_CFLAGS) -DACCESSBRIDGE_ARCH_$2 -EHsc, \
+ LDFLAGS := $$(LDFLAGS_JDKEXE) -stack:655360, \
+ LIBS := advapi32.lib user32.lib, \
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/jdk.accessibility/jaccessinspector$1, \
OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/jdk.accessibility, \
PROGRAM := jaccessinspector$1, \
@@ -100,8 +101,9 @@
$$(eval $$(call SetupNativeCompilation,BUILD_JACCESSWALKER$1, \
SRC := $(TOPDIR)/jaccesswalker $(TOPDIR)/common \
$(TOPDIR)/toolscommon $(TOPDIR)/include/bridge, \
- CFLAGS :== $$(CFLAGS_JDKEXE) $(TOOLS_CFLAGS) -DACCESSBRIDGE_ARCH_$2 /EHsc, \
- LDFLAGS := $$(LDFLAGS_JDKEXE) /STACK:655360 Advapi32.lib Comctl32.lib Gdi32.lib User32.lib, \
+ CFLAGS := $$(CFLAGS_JDKEXE) $(TOOLS_CFLAGS) -DACCESSBRIDGE_ARCH_$2 -EHsc, \
+ LDFLAGS := $$(LDFLAGS_JDKEXE) -stack:655360, \
+ LIBS := advapi32.lib comctl32.lib gdi32.lib user32.lib, \
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/jdk.accessibility/jaccesswalker$1, \
OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/jdk.accessibility, \
PROGRAM := jaccesswalker$1, \
--- a/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/DataFlavor.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/DataFlavor.java Mon Dec 14 10:36:12 2015 -0800
@@ -289,6 +289,8 @@
* representationClass = String
* mimeType = "text/html"
* </pre>
+ *
+ * @since 1.8
*/
public static DataFlavor selectionHtmlFlavor = initHtmlDataFlavor("selection");
@@ -301,6 +303,8 @@
* representationClass = String
* mimeType = "text/html"
* </pre>
+ *
+ * @since 1.8
*/
public static DataFlavor fragmentHtmlFlavor = initHtmlDataFlavor("fragment");
@@ -314,6 +318,8 @@
* representationClass = String
* mimeType = "text/html"
* </pre>
+ *
+ * @since 1.8
*/
public static DataFlavor allHtmlFlavor = initHtmlDataFlavor("all");
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m Mon Dec 14 10:36:12 2015 -0800
@@ -24,6 +24,7 @@
*/
#import <JavaNativeFoundation/JavaNativeFoundation.h>
+#include <Carbon/Carbon.h>
#import "CMenuItem.h"
#import "CMenu.h"
@@ -40,7 +41,7 @@
@implementation CMenuItem
- (id) initWithPeer:(jobject)peer asSeparator: (NSNumber *) asSeparator{
-AWT_ASSERT_APPKIT_THREAD;
+ AWT_ASSERT_APPKIT_THREAD;
self = [super initWithPeer:peer];
if (self) {
if ([asSeparator boolValue]) {
@@ -63,13 +64,48 @@
- (BOOL) worksWhenModal {
return YES;
}
+// This is a method written using Carbon framework methods to remove
+// All modifiers including "Shift" modifier.
+// Example 1: Shortcut set is "Command Shift m" returns "m"
+// Example 2: Shortcut set is "Command m" returns "m"
+// Example 3: Shortcut set is "Alt Shift ," returns ","
+
+CFStringRef createStringForKey(CGKeyCode keyCode)
+{
+ TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
+// currentKeyboard now contains the current input source
+ CFDataRef layoutData =
+ TISGetInputSourceProperty(currentKeyboard,
+ kTISPropertyUnicodeKeyLayoutData);
+// the UNICODE keyLayout is fetched from currentKeyboard in layoutData
+ const UCKeyboardLayout *keyboardLayout =
+ (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
+// A read-only data pointer is fetched from layoutData
+ UInt32 keysDown = 0;
+ UniChar chars[4];
+ UniCharCount realLength;
+
+ UCKeyTranslate(keyboardLayout,
+ keyCode,
+ kUCKeyActionDisplay,
+ 0,
+ LMGetKbdType(),
+ kUCKeyTranslateNoDeadKeysBit,
+ &keysDown,
+ sizeof(chars) / sizeof(chars[0]),
+ &realLength,
+ chars);
+ CFRelease(currentKeyboard);
+// Converts keyCode, modifier and dead-key state into UNICODE characters
+ return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1);
+}
// Events
- (void)handleAction:(NSMenuItem *)sender {
-AWT_ASSERT_APPKIT_THREAD;
+ AWT_ASSERT_APPKIT_THREAD;
JNIEnv *env = [ThreadUtilities getJNIEnv];
-JNF_COCOA_ENTER(env);
-
+ JNF_COCOA_ENTER(env);
+
// If we are called as a result of user pressing a shortcut, do nothing,
// because AVTView has already sent corresponding key event to the Java
// layer from performKeyEquivalent.
@@ -82,31 +118,37 @@
NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
if ([currEvent type] == NSKeyDown) {
NSString *menuKey = [sender keyEquivalent];
- NSString *eventKey = [currEvent charactersIgnoringModifiers];
-
- // Apple uses characters from private Unicode range for some of the
- // keys, so we need to do the same translation here that we do
- // for the regular key down events
- if ([eventKey length] == 1) {
- unichar origChar = [eventKey characterAtIndex:0];
- unichar newChar = NsCharToJavaChar(origChar, 0);
- if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
- newChar = origChar;
- }
-
- eventKey = [NSString stringWithCharacters: &newChar length: 1];
- }
-
+// If shortcut is "Command Shift ," the menuKey gets the value ","
+// But [currEvent charactersIgnoringModifiers]; returns "<" and not ","
+// because the charactersIgnoreingModifiers does not ignore "Shift"
+// So a shortcut like "Command Shift m" will return "M" where as the
+// MenuKey will have the value "m". To remove this issue the below
+// createStringForKey is used.
+ NSString *eventKey = createStringForKey([currEvent keyCode]);
+
+// Apple uses characters from private Unicode range for some of the
+// keys, so we need to do the same translation here that we do
+// for the regular key down events
+ if ([eventKey length] == 1) {
+ unichar origChar = [eventKey characterAtIndex:0];
+ unichar newChar = NsCharToJavaChar(origChar, 0);
+ if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
+ newChar = origChar;
+ }
+
+ eventKey = [NSString stringWithCharacters: &newChar length: 1];
+ }
+
NSWindow *keyWindow = [NSApp keyWindow];
if ([menuKey isEqualToString:eventKey] && keyWindow != nil) {
return;
}
}
-
+
if (fIsCheckbox) {
static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem");
static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V");
-
+
// Send the opposite of what's currently checked -- the action
// indicates what state we're going to.
NSInteger state = [sender state];
@@ -115,26 +157,26 @@
} else {
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)
-
+
NSUInteger modifiers = [currEvent modifierFlags];
jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
-
+
JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
}
-JNF_COCOA_EXIT(env);
+ JNF_COCOA_EXIT(env);
}
- (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
-
+
NSUInteger modifierMask = 0;
-
+
if (![theKeyEquivalent isEqualToString:@""]) {
// Force the key equivalent to lower case if not using the shift key.
// Otherwise AppKit will draw a Shift glyph in the menu.
if ((modifiers & java_awt_event_KeyEvent_SHIFT_MASK) == 0) {
theKeyEquivalent = [theKeyEquivalent lowercaseString];
}
-
+
// Hack for the question mark -- SHIFT and / means use the question mark.
if ((modifiers & java_awt_event_KeyEvent_SHIFT_MASK) != 0 &&
[theKeyEquivalent isEqualToString:@"/"])
@@ -142,10 +184,10 @@
theKeyEquivalent = @"?";
modifiers &= ~java_awt_event_KeyEvent_SHIFT_MASK;
}
-
+
modifierMask = JavaModifiersToNsKeyModifiers(modifiers, NO);
}
-
+
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
[fMenuItem setKeyEquivalent:theKeyEquivalent];
[fMenuItem setKeyEquivalentModifierMask:modifierMask];
@@ -154,14 +196,14 @@
}
- (void) setJavaImage:(NSImage *)theImage {
-
+
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[fMenuItem setImage:theImage];
}];
}
- (void) setJavaToolTipText:(NSString *)theText {
-
+
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[fMenuItem setToolTip:theText];
}];
@@ -169,11 +211,11 @@
- (void)setJavaEnabled:(BOOL) enabled {
-
+
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
@synchronized(self) {
fIsEnabled = enabled;
-
+
// Warning: This won't work if the parent menu is disabled.
// See [CMenu syncFromJava]. We still need to call it here so
// the NSMenuItem itself gets properly updated.
@@ -183,7 +225,7 @@
}
- (BOOL)isEnabled {
-
+
BOOL enabled = NO;
@synchronized(self) {
enabled = fIsEnabled;
@@ -193,7 +235,7 @@
- (void)setJavaState:(BOOL)newState {
-
+
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[fMenuItem setState:(newState ? NSOnState : NSOffState)];
}];
@@ -207,7 +249,7 @@
- (void)dealloc {
[fMenuItem release];
fMenuItem = nil;
-
+
[super dealloc];
}
@@ -240,7 +282,7 @@
/** Convert a Java keycode for SetMenuItemCmd */
static unichar AWTKeyToMacShortcut(jint awtKey, BOOL doShift) {
unichar macKey = 0;
-
+
if ((awtKey >= java_awt_event_KeyEvent_VK_0 && awtKey <= java_awt_event_KeyEvent_VK_9) ||
(awtKey >= java_awt_event_KeyEvent_VK_A && awtKey <= java_awt_event_KeyEvent_VK_Z))
{
@@ -255,68 +297,68 @@
} else {
// Special characters
switch (awtKey) {
- case java_awt_event_KeyEvent_VK_BACK_QUOTE : macKey = '`'; break;
- case java_awt_event_KeyEvent_VK_QUOTE : macKey = '\''; break;
-
- case java_awt_event_KeyEvent_VK_ESCAPE : macKey = 0x1B; break;
- case java_awt_event_KeyEvent_VK_SPACE : macKey = ' '; break;
- case java_awt_event_KeyEvent_VK_PAGE_UP : macKey = NSPageUpFunctionKey; break;
- case java_awt_event_KeyEvent_VK_PAGE_DOWN : macKey = NSPageDownFunctionKey; break;
- case java_awt_event_KeyEvent_VK_END : macKey = NSEndFunctionKey; break;
- case java_awt_event_KeyEvent_VK_HOME : macKey = NSHomeFunctionKey; break;
-
- case java_awt_event_KeyEvent_VK_LEFT : macKey = NSLeftArrowFunctionKey; break;
- case java_awt_event_KeyEvent_VK_UP : macKey = NSUpArrowFunctionKey; break;
- case java_awt_event_KeyEvent_VK_RIGHT : macKey = NSRightArrowFunctionKey; break;
- case java_awt_event_KeyEvent_VK_DOWN : macKey = NSDownArrowFunctionKey; break;
-
- case java_awt_event_KeyEvent_VK_COMMA : macKey = ','; break;
-
- // Mac OS doesn't distinguish between the two '-' keys...
- case java_awt_event_KeyEvent_VK_MINUS :
- case java_awt_event_KeyEvent_VK_SUBTRACT : macKey = '-'; break;
-
- // or the two '.' keys...
- case java_awt_event_KeyEvent_VK_DECIMAL :
- case java_awt_event_KeyEvent_VK_PERIOD : macKey = '.'; break;
-
- // or the two '/' keys.
- case java_awt_event_KeyEvent_VK_DIVIDE :
- case java_awt_event_KeyEvent_VK_SLASH : macKey = '/'; break;
-
- case java_awt_event_KeyEvent_VK_SEMICOLON : macKey = ';'; break;
- case java_awt_event_KeyEvent_VK_EQUALS : macKey = '='; break;
-
- case java_awt_event_KeyEvent_VK_OPEN_BRACKET : macKey = '['; break;
- case java_awt_event_KeyEvent_VK_BACK_SLASH : macKey = '\\'; break;
- case java_awt_event_KeyEvent_VK_CLOSE_BRACKET : macKey = ']'; break;
-
- case java_awt_event_KeyEvent_VK_MULTIPLY : macKey = '*'; break;
- case java_awt_event_KeyEvent_VK_ADD : macKey = '+'; break;
-
- case java_awt_event_KeyEvent_VK_HELP : macKey = NSHelpFunctionKey; break;
- case java_awt_event_KeyEvent_VK_TAB : macKey = NSTabCharacter; break;
- case java_awt_event_KeyEvent_VK_ENTER : macKey = NSNewlineCharacter; break;
- case java_awt_event_KeyEvent_VK_BACK_SPACE : macKey = NSBackspaceCharacter; break;
- case java_awt_event_KeyEvent_VK_DELETE : macKey = NSDeleteCharacter; break;
- case java_awt_event_KeyEvent_VK_CLEAR : macKey = NSClearDisplayFunctionKey; break;
- case java_awt_event_KeyEvent_VK_AMPERSAND : macKey = '&'; break;
- case java_awt_event_KeyEvent_VK_ASTERISK : macKey = '*'; break;
- case java_awt_event_KeyEvent_VK_QUOTEDBL : macKey = '\"'; break;
- case java_awt_event_KeyEvent_VK_LESS : macKey = '<'; break;
- case java_awt_event_KeyEvent_VK_GREATER : macKey = '>'; break;
- case java_awt_event_KeyEvent_VK_BRACELEFT : macKey = '{'; break;
- case java_awt_event_KeyEvent_VK_BRACERIGHT : macKey = '}'; break;
- case java_awt_event_KeyEvent_VK_AT : macKey = '@'; break;
- case java_awt_event_KeyEvent_VK_COLON : macKey = ':'; break;
- case java_awt_event_KeyEvent_VK_CIRCUMFLEX : macKey = '^'; break;
- case java_awt_event_KeyEvent_VK_DOLLAR : macKey = '$'; break;
- case java_awt_event_KeyEvent_VK_EXCLAMATION_MARK : macKey = '!'; break;
- case java_awt_event_KeyEvent_VK_LEFT_PARENTHESIS : macKey = '('; break;
- case java_awt_event_KeyEvent_VK_NUMBER_SIGN : macKey = '#'; break;
- case java_awt_event_KeyEvent_VK_PLUS : macKey = '+'; break;
- case java_awt_event_KeyEvent_VK_RIGHT_PARENTHESIS: macKey = ')'; break;
- case java_awt_event_KeyEvent_VK_UNDERSCORE : macKey = '_'; break;
+ case java_awt_event_KeyEvent_VK_BACK_QUOTE : macKey = '`'; break;
+ case java_awt_event_KeyEvent_VK_QUOTE : macKey = '\''; break;
+
+ case java_awt_event_KeyEvent_VK_ESCAPE : macKey = 0x1B; break;
+ case java_awt_event_KeyEvent_VK_SPACE : macKey = ' '; break;
+ case java_awt_event_KeyEvent_VK_PAGE_UP : macKey = NSPageUpFunctionKey; break;
+ case java_awt_event_KeyEvent_VK_PAGE_DOWN : macKey = NSPageDownFunctionKey; break;
+ case java_awt_event_KeyEvent_VK_END : macKey = NSEndFunctionKey; break;
+ case java_awt_event_KeyEvent_VK_HOME : macKey = NSHomeFunctionKey; break;
+
+ case java_awt_event_KeyEvent_VK_LEFT : macKey = NSLeftArrowFunctionKey; break;
+ case java_awt_event_KeyEvent_VK_UP : macKey = NSUpArrowFunctionKey; break;
+ case java_awt_event_KeyEvent_VK_RIGHT : macKey = NSRightArrowFunctionKey; break;
+ case java_awt_event_KeyEvent_VK_DOWN : macKey = NSDownArrowFunctionKey; break;
+
+ case java_awt_event_KeyEvent_VK_COMMA : macKey = ','; break;
+
+ // Mac OS doesn't distinguish between the two '-' keys...
+ case java_awt_event_KeyEvent_VK_MINUS :
+ case java_awt_event_KeyEvent_VK_SUBTRACT : macKey = '-'; break;
+
+ // or the two '.' keys...
+ case java_awt_event_KeyEvent_VK_DECIMAL :
+ case java_awt_event_KeyEvent_VK_PERIOD : macKey = '.'; break;
+
+ // or the two '/' keys.
+ case java_awt_event_KeyEvent_VK_DIVIDE :
+ case java_awt_event_KeyEvent_VK_SLASH : macKey = '/'; break;
+
+ case java_awt_event_KeyEvent_VK_SEMICOLON : macKey = ';'; break;
+ case java_awt_event_KeyEvent_VK_EQUALS : macKey = '='; break;
+
+ case java_awt_event_KeyEvent_VK_OPEN_BRACKET : macKey = '['; break;
+ case java_awt_event_KeyEvent_VK_BACK_SLASH : macKey = '\\'; break;
+ case java_awt_event_KeyEvent_VK_CLOSE_BRACKET : macKey = ']'; break;
+
+ case java_awt_event_KeyEvent_VK_MULTIPLY : macKey = '*'; break;
+ case java_awt_event_KeyEvent_VK_ADD : macKey = '+'; break;
+
+ case java_awt_event_KeyEvent_VK_HELP : macKey = NSHelpFunctionKey; break;
+ case java_awt_event_KeyEvent_VK_TAB : macKey = NSTabCharacter; break;
+ case java_awt_event_KeyEvent_VK_ENTER : macKey = NSNewlineCharacter; break;
+ case java_awt_event_KeyEvent_VK_BACK_SPACE : macKey = NSBackspaceCharacter; break;
+ case java_awt_event_KeyEvent_VK_DELETE : macKey = NSDeleteCharacter; break;
+ case java_awt_event_KeyEvent_VK_CLEAR : macKey = NSClearDisplayFunctionKey; break;
+ case java_awt_event_KeyEvent_VK_AMPERSAND : macKey = '&'; break;
+ case java_awt_event_KeyEvent_VK_ASTERISK : macKey = '*'; break;
+ case java_awt_event_KeyEvent_VK_QUOTEDBL : macKey = '\"'; break;
+ case java_awt_event_KeyEvent_VK_LESS : macKey = '<'; break;
+ case java_awt_event_KeyEvent_VK_GREATER : macKey = '>'; break;
+ case java_awt_event_KeyEvent_VK_BRACELEFT : macKey = '{'; break;
+ case java_awt_event_KeyEvent_VK_BRACERIGHT : macKey = '}'; break;
+ case java_awt_event_KeyEvent_VK_AT : macKey = '@'; break;
+ case java_awt_event_KeyEvent_VK_COLON : macKey = ':'; break;
+ case java_awt_event_KeyEvent_VK_CIRCUMFLEX : macKey = '^'; break;
+ case java_awt_event_KeyEvent_VK_DOLLAR : macKey = '$'; break;
+ case java_awt_event_KeyEvent_VK_EXCLAMATION_MARK : macKey = '!'; break;
+ case java_awt_event_KeyEvent_VK_LEFT_PARENTHESIS : macKey = '('; break;
+ case java_awt_event_KeyEvent_VK_NUMBER_SIGN : macKey = '#'; break;
+ case java_awt_event_KeyEvent_VK_PLUS : macKey = '+'; break;
+ case java_awt_event_KeyEvent_VK_RIGHT_PARENTHESIS: macKey = ')'; break;
+ case java_awt_event_KeyEvent_VK_UNDERSCORE : macKey = '_'; break;
}
}
return macKey;
@@ -330,27 +372,27 @@
JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CMenuItem_nativeSetLabel
(JNIEnv *env, jobject peer,
- jlong menuItemObj, jstring label,
- jchar shortcutKey, jint shortcutKeyCode, jint mods)
+ jlong menuItemObj, jstring label,
+ jchar shortcutKey, jint shortcutKeyCode, jint mods)
{
-JNF_COCOA_ENTER(env);
+ JNF_COCOA_ENTER(env);
NSString *theLabel = JNFJavaToNSString(env, label);
NSString *theKeyEquivalent = nil;
unichar macKey = shortcutKey;
-
+
if (macKey == 0) {
macKey = AWTKeyToMacShortcut(shortcutKeyCode, (mods & java_awt_event_KeyEvent_SHIFT_MASK) != 0);
}
-
+
if (macKey != 0) {
unichar equivalent[1] = {macKey};
theKeyEquivalent = [NSString stringWithCharacters:equivalent length:1];
} else {
theKeyEquivalent = @"";
}
-
+
[((CMenuItem *)jlong_to_ptr(menuItemObj)) setJavaLabel:theLabel shortcut:theKeyEquivalent modifierMask:mods];
-JNF_COCOA_EXIT(env);
+ JNF_COCOA_EXIT(env);
}
/*
@@ -362,10 +404,10 @@
Java_sun_lwawt_macosx_CMenuItem_nativeSetTooltip
(JNIEnv *env, jobject peer, jlong menuItemObj, jstring tooltip)
{
-JNF_COCOA_ENTER(env);
+ JNF_COCOA_ENTER(env);
NSString *theTooltip = JNFJavaToNSString(env, tooltip);
[((CMenuItem *)jlong_to_ptr(menuItemObj)) setJavaToolTipText:theTooltip];
-JNF_COCOA_EXIT(env);
+ JNF_COCOA_EXIT(env);
}
/*
@@ -377,9 +419,9 @@
Java_sun_lwawt_macosx_CMenuItem_nativeSetImage
(JNIEnv *env, jobject peer, jlong menuItemObj, jlong image)
{
-JNF_COCOA_ENTER(env);
+ JNF_COCOA_ENTER(env);
[((CMenuItem *)jlong_to_ptr(menuItemObj)) setJavaImage:(NSImage*)jlong_to_ptr(image)];
-JNF_COCOA_EXIT(env);
+ JNF_COCOA_EXIT(env);
}
/*
@@ -389,38 +431,38 @@
*/
JNIEXPORT jlong JNICALL
Java_sun_lwawt_macosx_CMenuItem_nativeCreate
- (JNIEnv *env, jobject peer, jlong parentCMenuObj, jboolean isSeparator)
+(JNIEnv *env, jobject peer, jlong parentCMenuObj, jboolean isSeparator)
{
-
+
CMenuItem *aCMenuItem = nil;
CMenu *parentCMenu = (CMenu *)jlong_to_ptr(parentCMenuObj);
-JNF_COCOA_ENTER(env);
-
+ JNF_COCOA_ENTER(env);
+
jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer);
-
+
NSMutableArray *args = nil;
-
+
// Create a new item....
if (isSeparator == JNI_TRUE) {
args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:YES], nil];
} else {
args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:NO], nil];
}
-
+
[ThreadUtilities performOnMainThread:@selector(_createMenuItem_OnAppKitThread:) on:[CMenuItem alloc] withObject:args waitUntilDone:YES];
-
+
aCMenuItem = (CMenuItem *)[args objectAtIndex: 0];
-
+
if (aCMenuItem == nil) {
return 0L;
}
-
+
// and add it to the parent item.
[parentCMenu addJavaMenuItem: aCMenuItem];
-
+
// setLabel will be called after creation completes.
-
-JNF_COCOA_EXIT(env);
+
+ JNF_COCOA_EXIT(env);
return ptr_to_jlong(aCMenuItem);
}
@@ -433,10 +475,10 @@
Java_sun_lwawt_macosx_CMenuItem_nativeSetEnabled
(JNIEnv *env, jobject peer, jlong menuItemObj, jboolean enable)
{
-JNF_COCOA_ENTER(env);
+ JNF_COCOA_ENTER(env);
CMenuItem *item = (CMenuItem *)jlong_to_ptr(menuItemObj);
[item setJavaEnabled: (enable == JNI_TRUE)];
-JNF_COCOA_EXIT(env);
+ JNF_COCOA_EXIT(env);
}
/*
@@ -448,10 +490,10 @@
Java_sun_lwawt_macosx_CCheckboxMenuItem_nativeSetState
(JNIEnv *env, jobject peer, jlong menuItemObj, jboolean state)
{
-JNF_COCOA_ENTER(env);
+ JNF_COCOA_ENTER(env);
CMenuItem *item = (CMenuItem *)jlong_to_ptr(menuItemObj);
[item setJavaState: (state == JNI_TRUE)];
-JNF_COCOA_EXIT(env);
+ JNF_COCOA_EXIT(env);
}
/*
@@ -463,8 +505,8 @@
Java_sun_lwawt_macosx_CCheckboxMenuItem_nativeSetIsCheckbox
(JNIEnv *env, jobject peer, jlong menuItemObj)
{
-JNF_COCOA_ENTER(env);
+ JNF_COCOA_ENTER(env);
CMenuItem *item = (CMenuItem *)jlong_to_ptr(menuItemObj);
[item setIsCheckbox];
-JNF_COCOA_EXIT(env);
+ JNF_COCOA_EXIT(env);
}
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java Mon Dec 14 10:36:12 2015 -0800
@@ -874,13 +874,13 @@
return chroma;
}
- boolean idsAreJFIF = true;
+ boolean idsAreJFIF = false;
- for (int i = 0; i < sof.componentSpecs.length; i++) {
- int id = sof.componentSpecs[i].componentId;
- if ((id < 1) || (id >= sof.componentSpecs.length)) {
- idsAreJFIF = false;
- }
+ int cid0 = sof.componentSpecs[0].componentId;
+ int cid1 = sof.componentSpecs[1].componentId;
+ int cid2 = sof.componentSpecs[2].componentId;
+ if ((cid0 == 1) && (cid1 == 2) && (cid2 == 3)) {
+ idsAreJFIF = true;
}
if (idsAreJFIF) {
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java Mon Dec 14 10:36:12 2015 -0800
@@ -193,7 +193,17 @@
// Return to end of chunk and flush to minimize buffering
stream.seek(pos);
- stream.flushBefore(pos);
+ try {
+ stream.flushBefore(pos);
+ } catch (IOException e) {
+ /*
+ * If flushBefore() fails we try to access startPos in finally
+ * block of write_IDAT(). We should update startPos to avoid
+ * IndexOutOfBoundException while seek() is happening.
+ */
+ this.startPos = stream.getStreamPosition();
+ throw e;
+ }
}
public int read() throws IOException {
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java Mon Dec 14 10:36:12 2015 -0800
@@ -472,6 +472,14 @@
// Read tag number, value type, and value count.
int tagNumber = stream.readUnsignedShort();
int type = stream.readUnsignedShort();
+ int sizeOfType;
+ try {
+ sizeOfType = TIFFTag.getSizeOfType(type);
+ } catch (IllegalArgumentException ignored) {
+ // Continue with the next IFD entry.
+ stream.skipBytes(4);
+ continue;
+ }
int count = (int)stream.readUnsignedInt();
// Get the associated TIFFTag.
@@ -510,14 +518,14 @@
}
}
- int size = count*TIFFTag.getSizeOfType(type);
+ int size = count*sizeOfType;
if (size > 4 || tag.isIFDPointer()) {
// The IFD entry value is a pointer to the actual field value.
long offset = stream.readUnsignedInt();
// Check whether the the field value is within the stream.
if (haveStreamLength && offset + size > streamLength) {
- throw new IIOException("Field data is past end-of-stream");
+ continue;
}
// Add a TIFFIFDEntry as a placeholder. This avoids a mark,
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java Mon Dec 14 10:36:12 2015 -0800
@@ -205,6 +205,10 @@
// Next available space.
private long nextSpace = 0L;
+ private long prevStreamPosition;
+ private long prevHeaderPosition;
+ private long prevNextSpace;
+
// Whether a sequence is being written.
private boolean isWritingSequence = false;
private boolean isInsertingEmpty = false;
@@ -2300,7 +2304,14 @@
public void write(IIOMetadata sm,
IIOImage iioimage,
ImageWriteParam p) throws IOException {
+ if (stream == null) {
+ throw new IllegalStateException("output == null!");
+ }
+ markPositions();
write(sm, iioimage, p, true, true);
+ if (abortRequested()) {
+ resetPositions();
+ }
}
private void writeHeader() throws IOException {
@@ -2333,7 +2344,7 @@
throw new IllegalStateException("output == null!");
}
if (iioimage == null) {
- throw new NullPointerException("image == null!");
+ throw new IllegalArgumentException("image == null!");
}
if(iioimage.hasRaster() && !canWriteRasters()) {
throw new UnsupportedOperationException
@@ -2767,7 +2778,7 @@
throw new IllegalStateException("Output not set!");
}
if (image == null) {
- throw new NullPointerException("image == null!");
+ throw new IllegalArgumentException("image == null!");
}
// Locate the position of the old IFD (ifd) and the location
@@ -2779,9 +2790,16 @@
// imageIndex is < -1 or is too big thereby satisfying the spec.
locateIFD(imageIndex, ifdpos, ifd);
+ markPositions();
+
// Seek to the position containing the pointer to the old IFD.
stream.seek(ifdpos[0]);
+ // Save the previous pointer value in case of abort.
+ stream.mark();
+ long prevPointerValue = stream.readUnsignedInt();
+ stream.reset();
+
// Update next space pointer in anticipation of next write.
if(ifdpos[0] + 4 > nextSpace) {
nextSpace = ifdpos[0] + 4;
@@ -2805,6 +2823,12 @@
// Update the new IFD to point to the old IFD.
stream.writeInt((int)ifd[0]);
// Don't need to update nextSpace here as already done in write().
+
+ if (abortRequested()) {
+ stream.seek(ifdpos[0]);
+ stream.writeInt((int)prevPointerValue);
+ resetPositions();
+ }
}
// ----- BEGIN insert/writeEmpty methods -----
@@ -2834,7 +2858,7 @@
}
if(imageType == null) {
- throw new NullPointerException("imageType == null!");
+ throw new IllegalArgumentException("imageType == null!");
}
if(width < 1 || height < 1) {
@@ -2891,6 +2915,10 @@
IIOMetadata imageMetadata,
List<? extends BufferedImage> thumbnails,
ImageWriteParam param) throws IOException {
+ if (stream == null) {
+ throw new IllegalStateException("output == null!");
+ }
+
checkParamsEmpty(imageType, width, height, thumbnails);
this.isWritingEmpty = true;
@@ -2901,8 +2929,12 @@
0, 0, emptySM.getWidth(), emptySM.getHeight(),
emptySM, imageType.getColorModel());
+ markPositions();
write(streamMetadata, new IIOImage(emptyImage, null, imageMetadata),
param, true, false);
+ if (abortRequested()) {
+ resetPositions();
+ }
}
public void endInsertEmpty() throws IOException {
@@ -3015,7 +3047,7 @@
throw new IllegalStateException("Output not set!");
}
if (region == null) {
- throw new NullPointerException("region == null!");
+ throw new IllegalArgumentException("region == null!");
}
if (region.getWidth() < 1) {
throw new IllegalArgumentException("region.getWidth() < 1!");
@@ -3200,7 +3232,7 @@
}
if (image == null) {
- throw new NullPointerException("image == null!");
+ throw new IllegalArgumentException("image == null!");
}
if (!inReplacePixelsNest) {
@@ -3559,6 +3591,20 @@
// ----- END replacePixels methods -----
+ // Save stream positions for use when aborted.
+ private void markPositions() throws IOException {
+ prevStreamPosition = stream.getStreamPosition();
+ prevHeaderPosition = headerPosition;
+ prevNextSpace = nextSpace;
+ }
+
+ // Reset to positions saved by markPositions().
+ private void resetPositions() throws IOException {
+ stream.seek(prevStreamPosition);
+ headerPosition = prevHeaderPosition;
+ nextSpace = prevNextSpace;
+ }
+
public void reset() {
super.reset();
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, 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
@@ -25,10 +25,11 @@
package com.sun.media.sound;
+import java.util.Objects;
+
import javax.sound.midi.MidiDevice;
import javax.sound.midi.spi.MidiDeviceProvider;
-
/**
* Super class for MIDI input or output device provider.
*
@@ -127,7 +128,8 @@
}
@Override
- public final MidiDevice getDevice(MidiDevice.Info info) {
+ public final MidiDevice getDevice(final MidiDevice.Info info) {
+ Objects.requireNonNull(info);
if (info instanceof Info) {
readDeviceInfos();
MidiDevice[] devices = getDeviceCache();
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/JARSoundbankReader.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/JARSoundbankReader.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package com.sun.media.sound;
import java.io.BufferedReader;
@@ -32,6 +33,8 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
+import java.util.Objects;
+
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.Soundbank;
import javax.sound.midi.spi.SoundbankReader;
@@ -112,6 +115,7 @@
public Soundbank getSoundbank(InputStream stream)
throws InvalidMidiDataException, IOException {
+ Objects.requireNonNull(stream);
return null;
}
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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
@@ -25,6 +25,8 @@
package com.sun.media.sound;
+import java.util.Objects;
+
import javax.sound.midi.MidiDevice;
import javax.sound.midi.spi.MidiDeviceProvider;
@@ -42,6 +44,7 @@
@Override
public MidiDevice getDevice(final MidiDevice.Info info) {
+ Objects.requireNonNull(info);
if (RealTimeSequencer.info.equals(info)) {
return new RealTimeSequencer();
}
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftProvider.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftProvider.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -25,6 +25,8 @@
package com.sun.media.sound;
+import java.util.Objects;
+
import javax.sound.midi.MidiDevice;
import javax.sound.midi.spi.MidiDeviceProvider;
@@ -42,6 +44,7 @@
@Override
public MidiDevice getDevice(final MidiDevice.Info info) {
+ Objects.requireNonNull(info);
if (SoftSynthesizer.info.equals(info)) {
return new SoftSynthesizer();
}
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardMidiFileWriter.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardMidiFileWriter.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -25,21 +25,22 @@
package com.sun.media.sound;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.SequenceInputStream;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
-import java.io.IOException;
import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.io.SequenceInputStream;
+import java.util.Objects;
import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MetaMessage;
import javax.sound.midi.MidiEvent;
-import javax.sound.midi.MetaMessage;
import javax.sound.midi.Sequence;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.SysexMessage;
@@ -115,24 +116,16 @@
return typesArray;
}
- public boolean isFileTypeSupported(int type) {
- for(int i=0; i<types.length; i++) {
- if( type == types[i] ) {
- return true;
- }
+ public int write(Sequence in, int type, OutputStream out) throws IOException {
+ Objects.requireNonNull(out);
+ if (!isFileTypeSupported(type, in)) {
+ throw new IllegalArgumentException("Could not write MIDI file");
}
- return false;
- }
-
- public int write(Sequence in, int type, OutputStream out) throws IOException {
byte [] buffer = null;
int bytesRead = 0;
long bytesWritten = 0;
- if( !isFileTypeSupported(type,in) ) {
- throw new IllegalArgumentException("Could not write MIDI file");
- }
// First get the fileStream from this sequence
InputStream fileStream = getFileStream(type,in);
if (fileStream == null) {
@@ -149,6 +142,7 @@
}
public int write(Sequence in, int type, File out) throws IOException {
+ Objects.requireNonNull(in);
FileOutputStream fos = new FileOutputStream(out); // throws IOException
int bytesWritten = write( in, type, fos );
fos.close();
--- a/jdk/src/java.desktop/share/classes/java/awt/TextComponent.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/TextComponent.java Mon Dec 14 10:36:12 2015 -0800
@@ -229,15 +229,21 @@
* @see java.awt.TextComponent#getText
*/
public synchronized void setText(String t) {
- boolean skipTextEvent = (text == null || text.isEmpty())
- && (t == null || t.isEmpty());
- text = (t != null) ? t : "";
+ if (t == null) {
+ t = "";
+ }
TextComponentPeer peer = (TextComponentPeer)this.peer;
- // Please note that we do not want to post an event
- // if TextArea.setText() or TextField.setText() replaces an empty text
- // by an empty text, that is, if component's text remains unchanged.
- if (peer != null && !skipTextEvent) {
- peer.setText(text);
+ if (peer != null) {
+ text = peer.getText();
+ // Please note that we do not want to post an event
+ // if TextArea.setText() or TextField.setText() replaces text
+ // by same text, that is, if component's text remains unchanged.
+ if (!t.equals(text)) {
+ text = t;
+ peer.setText(text);
+ }
+ } else {
+ text = t;
}
}
--- a/jdk/src/java.desktop/share/classes/java/awt/TextField.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/TextField.java Mon Dec 14 10:36:12 2015 -0800
@@ -198,7 +198,7 @@
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public TextField(String text, int columns) throws HeadlessException {
- super(text);
+ super(replaceEOL(text));
this.columns = (columns >= 0) ? columns : 0;
}
@@ -297,13 +297,32 @@
* @see java.awt.TextComponent#getText
*/
public void setText(String t) {
- super.setText(t);
+ super.setText(replaceEOL(t));
// This could change the preferred size of the Component.
invalidateIfValid();
}
/**
+ * Replaces EOL characters from the text variable with a space character.
+ * @param text the new text.
+ * @return Returns text after replacing EOL characters.
+ */
+ private static String replaceEOL(String text) {
+ if (text == null) {
+ return text;
+ }
+ String[] strEOLs = {System.lineSeparator(), "\n"};
+ for (String eol : strEOLs) {
+ if (text.contains(eol)) {
+ text = text.replace(eol, " ");
+ }
+ }
+ return text;
+ }
+
+
+ /**
* Indicates whether or not this text field has a
* character set for echoing.
* <p>
@@ -704,6 +723,7 @@
{
// HeadlessException will be thrown by TextComponent's readObject
s.defaultReadObject();
+ text = replaceEOL(text);
// Make sure the state we just read in for columns has legal values
if (columns < 0) {
--- a/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java Mon Dec 14 10:36:12 2015 -0800
@@ -564,9 +564,12 @@
if (stream != null) {
stream.mark();
}
- canDecode = spi.canDecodeInput(input);
- if (stream != null) {
- stream.reset();
+ try {
+ canDecode = spi.canDecodeInput(input);
+ } finally {
+ if (stream != null) {
+ stream.reset();
+ }
}
return canDecode;
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiSystem.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiSystem.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -35,6 +35,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
import java.util.Properties;
import java.util.Set;
@@ -179,10 +180,12 @@
* due to resource restrictions
* @throws IllegalArgumentException if the info object does not represent a
* MIDI device installed on the system
+ * @throws NullPointerException if {@code info} is {@code null}
* @see #getMidiDeviceInfo
*/
public static MidiDevice getMidiDevice(final MidiDevice.Info info)
throws MidiUnavailableException {
+ Objects.requireNonNull(info);
for (final MidiDeviceProvider provider : getMidiDeviceProviders()) {
if (provider.isDeviceSupported(info)) {
return provider.getDevice(info);
@@ -447,11 +450,13 @@
* @throws InvalidMidiDataException if the stream does not point to valid
* MIDI soundbank data recognized by the system
* @throws IOException if an I/O error occurred when loading the soundbank
+ * @throws NullPointerException if {@code stream} is {@code null}
* @see InputStream#markSupported
* @see InputStream#mark
*/
- public static Soundbank getSoundbank(InputStream stream)
- throws InvalidMidiDataException, IOException {
+ public static Soundbank getSoundbank(final InputStream stream)
+ throws InvalidMidiDataException, IOException {
+ Objects.requireNonNull(stream);
SoundbankReader sp = null;
Soundbank s = null;
@@ -479,9 +484,11 @@
* @throws InvalidMidiDataException if the URL does not point to valid MIDI
* soundbank data recognized by the system
* @throws IOException if an I/O error occurred when loading the soundbank
+ * @throws NullPointerException if {@code url} is {@code null}
*/
- public static Soundbank getSoundbank(URL url)
- throws InvalidMidiDataException, IOException {
+ public static Soundbank getSoundbank(final URL url)
+ throws InvalidMidiDataException, IOException {
+ Objects.requireNonNull(url);
SoundbankReader sp = null;
Soundbank s = null;
@@ -509,9 +516,11 @@
* @throws InvalidMidiDataException if the {@code File} does not point to
* valid MIDI soundbank data recognized by the system
* @throws IOException if an I/O error occurred when loading the soundbank
+ * @throws NullPointerException if {@code file} is {@code null}
*/
- public static Soundbank getSoundbank(File file)
- throws InvalidMidiDataException, IOException {
+ public static Soundbank getSoundbank(final File file)
+ throws InvalidMidiDataException, IOException {
+ Objects.requireNonNull(file);
SoundbankReader sp = null;
Soundbank s = null;
@@ -556,13 +565,15 @@
* MIDI file data recognized by the system
* @throws IOException if an I/O exception occurs while accessing the
* stream
+ * @throws NullPointerException if {@code stream} is {@code null}
* @see #getMidiFileFormat(URL)
* @see #getMidiFileFormat(File)
* @see InputStream#markSupported
* @see InputStream#mark
*/
- public static MidiFileFormat getMidiFileFormat(InputStream stream)
- throws InvalidMidiDataException, IOException {
+ public static MidiFileFormat getMidiFileFormat(final InputStream stream)
+ throws InvalidMidiDataException, IOException {
+ Objects.requireNonNull(stream);
List<MidiFileReader> providers = getMidiFileReaders();
MidiFileFormat format = null;
@@ -602,11 +613,13 @@
* @throws InvalidMidiDataException if the URL does not point to valid MIDI
* file data recognized by the system
* @throws IOException if an I/O exception occurs while accessing the URL
+ * @throws NullPointerException if {@code url} is {@code null}
* @see #getMidiFileFormat(InputStream)
* @see #getMidiFileFormat(File)
*/
- public static MidiFileFormat getMidiFileFormat(URL url)
- throws InvalidMidiDataException, IOException {
+ public static MidiFileFormat getMidiFileFormat(final URL url)
+ throws InvalidMidiDataException, IOException {
+ Objects.requireNonNull(url);
List<MidiFileReader> providers = getMidiFileReaders();
MidiFileFormat format = null;
@@ -646,11 +659,13 @@
* @throws InvalidMidiDataException if the {@code File} does not point to
* valid MIDI file data recognized by the system
* @throws IOException if an I/O exception occurs while accessing the file
+ * @throws NullPointerException if {@code file} is {@code null}
* @see #getMidiFileFormat(InputStream)
* @see #getMidiFileFormat(URL)
*/
- public static MidiFileFormat getMidiFileFormat(File file)
- throws InvalidMidiDataException, IOException {
+ public static MidiFileFormat getMidiFileFormat(final File file)
+ throws InvalidMidiDataException, IOException {
+ Objects.requireNonNull(file);
List<MidiFileReader> providers = getMidiFileReaders();
MidiFileFormat format = null;
@@ -699,11 +714,13 @@
* @throws InvalidMidiDataException if the stream does not point to valid
* MIDI file data recognized by the system
* @throws IOException if an I/O exception occurs while accessing the stream
+ * @throws NullPointerException if {@code stream} is {@code null}
* @see InputStream#markSupported
* @see InputStream#mark
*/
- public static Sequence getSequence(InputStream stream)
- throws InvalidMidiDataException, IOException {
+ public static Sequence getSequence(final InputStream stream)
+ throws InvalidMidiDataException, IOException {
+ Objects.requireNonNull(stream);
List<MidiFileReader> providers = getMidiFileReaders();
Sequence sequence = null;
@@ -743,9 +760,11 @@
* @throws InvalidMidiDataException if the URL does not point to valid MIDI
* file data recognized by the system
* @throws IOException if an I/O exception occurs while accessing the URL
+ * @throws NullPointerException if {@code url} is {@code null}
*/
- public static Sequence getSequence(URL url)
- throws InvalidMidiDataException, IOException {
+ public static Sequence getSequence(final URL url)
+ throws InvalidMidiDataException, IOException {
+ Objects.requireNonNull(url);
List<MidiFileReader> providers = getMidiFileReaders();
Sequence sequence = null;
@@ -787,9 +806,11 @@
* @throws InvalidMidiDataException if the File does not point to valid MIDI
* file data recognized by the system
* @throws IOException if an I/O exception occurs
+ * @throws NullPointerException if {@code file} is {@code null}
*/
- public static Sequence getSequence(File file)
- throws InvalidMidiDataException, IOException {
+ public static Sequence getSequence(final File file)
+ throws InvalidMidiDataException, IOException {
+ Objects.requireNonNull(file);
List<MidiFileReader> providers = getMidiFileReaders();
Sequence sequence = null;
@@ -870,8 +891,10 @@
* @param sequence the sequence for which MIDI file type support is queried
* @return the set of unique supported file types. If no file types are
* supported, returns an array of length 0.
+ * @throws NullPointerException if {@code sequence} is {@code null}
*/
- public static int[] getMidiFileTypes(Sequence sequence) {
+ public static int[] getMidiFileTypes(final Sequence sequence) {
+ Objects.requireNonNull(sequence);
List<MidiFileWriter> providers = getMidiFileWriters();
Set<Integer> allTypes = new HashSet<>();
@@ -903,8 +926,11 @@
* @param sequence the sequence for which file writing support is queried
* @return {@code true} if the file type is supported for this sequence,
* otherwise {@code false}
+ * @throws NullPointerException if {@code sequence} is {@code null}
*/
- public static boolean isFileTypeSupported(int fileType, Sequence sequence) {
+ public static boolean isFileTypeSupported(final int fileType,
+ final Sequence sequence) {
+ Objects.requireNonNull(sequence);
List<MidiFileWriter> providers = getMidiFileWriters();
@@ -929,10 +955,15 @@
* @throws IOException if an I/O exception occurs
* @throws IllegalArgumentException if the file format is not supported by
* the system
+ * @throws NullPointerException if {@code in} or {@code out} are
+ * {@code null}
* @see #isFileTypeSupported(int, Sequence)
* @see #getMidiFileTypes(Sequence)
*/
- public static int write(Sequence in, int fileType, OutputStream out) throws IOException {
+ public static int write(final Sequence in, final int fileType,
+ final OutputStream out) throws IOException {
+ Objects.requireNonNull(in);
+ Objects.requireNonNull(out);
List<MidiFileWriter> providers = getMidiFileWriters();
//$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
@@ -963,10 +994,15 @@
* @throws IOException if an I/O exception occurs
* @throws IllegalArgumentException if the file type is not supported by the
* system
+ * @throws NullPointerException if {@code in} or {@code out} are
+ * {@code null}
* @see #isFileTypeSupported(int, Sequence)
* @see #getMidiFileTypes(Sequence)
*/
- public static int write(Sequence in, int type, File out) throws IOException {
+ public static int write(final Sequence in, final int type, final File out)
+ throws IOException {
+ Objects.requireNonNull(in);
+ Objects.requireNonNull(out);
List<MidiFileWriter> providers = getMidiFileWriters();
//$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiDeviceProvider.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiDeviceProvider.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -26,6 +26,7 @@
package javax.sound.midi.spi;
import java.util.Arrays;
+import java.util.Objects;
import javax.sound.midi.MidiDevice;
@@ -46,8 +47,10 @@
* is queried
* @return {@code true} if the specified device is supported, otherwise
* {@code false}
+ * @throws NullPointerException if {@code info} is {@code null}
*/
public boolean isDeviceSupported(final MidiDevice.Info info) {
+ Objects.requireNonNull(info);
return Arrays.asList(getDeviceInfo()).contains(info);
}
@@ -67,6 +70,7 @@
* @throws IllegalArgumentException if the info object specified does not
* match the info object for a device supported by this
* {@code MidiDeviceProvider}
+ * @throws NullPointerException if {@code info} is {@code null}
*/
public abstract MidiDevice getDevice(MidiDevice.Info info);
}
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -60,6 +60,7 @@
* @throws InvalidMidiDataException if the stream does not point to valid
* MIDI file data recognized by the system
* @throws IOException if an I/O exception occurs
+ * @throws NullPointerException if {@code stream} is {@code null}
* @see InputStream#markSupported
* @see InputStream#mark
*/
@@ -76,6 +77,7 @@
* @throws InvalidMidiDataException if the URL does not point to valid MIDI
* file data recognized by the system
* @throws IOException if an I/O exception occurs
+ * @throws NullPointerException if {@code url} is {@code null}
*/
public abstract MidiFileFormat getMidiFileFormat(URL url)
throws InvalidMidiDataException, IOException;
@@ -90,6 +92,7 @@
* @throws InvalidMidiDataException if the {@code File} does not point to
* valid MIDI file data recognized by the system
* @throws IOException if an I/O exception occurs
+ * @throws NullPointerException if {@code file} is {@code null}
*/
public abstract MidiFileFormat getMidiFileFormat(File file)
throws InvalidMidiDataException, IOException;
@@ -110,6 +113,7 @@
* @throws InvalidMidiDataException if the stream does not point to valid
* MIDI file data recognized by the system
* @throws IOException if an I/O exception occurs
+ * @throws NullPointerException if {@code stream} is {@code null}
* @see InputStream#markSupported
* @see InputStream#mark
*/
@@ -126,6 +130,7 @@
* @throws InvalidMidiDataException if the URL does not point to valid MIDI
* file data recognized by the system
* @throws IOException if an I/O exception occurs
+ * @throws NullPointerException if {@code url} is {@code null}
*/
public abstract Sequence getSequence(URL url)
throws InvalidMidiDataException, IOException;
@@ -141,6 +146,7 @@
* @throws InvalidMidiDataException if the {@code File} does not point to
* valid MIDI file data recognized by the system
* @throws IOException if an I/O exception occurs
+ * @throws NullPointerException if {@code file} is {@code null}
*/
public abstract Sequence getSequence(File file)
throws InvalidMidiDataException, IOException;
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileWriter.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileWriter.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -58,6 +58,7 @@
* queried
* @return array of file types. If no file types are supported, returns an
* array of length 0.
+ * @throws NullPointerException if {@code sequence} is {@code null}
*/
public abstract int[] getMidiFileTypes(Sequence sequence);
@@ -88,6 +89,7 @@
* @param sequence the sequence for which file writing support is queried
* @return {@code true} if the file type is supported for this sequence,
* otherwise {@code false}
+ * @throws NullPointerException if {@code sequence} is {@code null}
*/
public boolean isFileTypeSupported(int fileType, Sequence sequence) {
@@ -111,6 +113,8 @@
* @throws IOException if an I/O exception occurs
* @throws IllegalArgumentException if the file type is not supported by
* this file writer
+ * @throws NullPointerException if {@code in} or {@code out} are
+ * {@code null}
* @see #isFileTypeSupported(int, Sequence)
* @see #getMidiFileTypes(Sequence)
*/
@@ -129,6 +133,8 @@
* @throws IOException if an I/O exception occurs
* @throws IllegalArgumentException if the file type is not supported by
* this file writer
+ * @throws NullPointerException if {@code in} or {@code out} are
+ * {@code null}
* @see #isFileTypeSupported(int, Sequence)
* @see #getMidiFileTypes(Sequence)
*/
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -52,6 +52,7 @@
* @throws InvalidMidiDataException if the URL does not point to valid MIDI
* soundbank data recognized by this soundbank reader
* @throws IOException if an I/O error occurs
+ * @throws NullPointerException if {@code url} is {@code null}
*/
public abstract Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException;
@@ -64,6 +65,7 @@
* @throws InvalidMidiDataException if the stream does not point to valid
* MIDI soundbank data recognized by this soundbank reader
* @throws IOException if an I/O error occurs
+ * @throws NullPointerException if {@code stream} is {@code null}
*/
public abstract Soundbank getSoundbank(InputStream stream)
throws InvalidMidiDataException, IOException;
@@ -76,6 +78,7 @@
* @throws InvalidMidiDataException if the file does not point to valid MIDI
* soundbank data recognized by this soundbank reader
* @throws IOException if an I/O error occurs
+ * @throws NullPointerException if {@code file} is {@code null}
*/
public abstract Soundbank getSoundbank(File file)
throws InvalidMidiDataException, IOException;
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java Mon Dec 14 10:36:12 2015 -0800
@@ -618,6 +618,7 @@
* @return the {@code ComponentUI} object that renders this component
* @since 1.9
*/
+ @Transient
public ComponentUI getUI() {
return ui;
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java Mon Dec 14 10:36:12 2015 -0800
@@ -663,7 +663,9 @@
if(newFolder.exists()) {
throw new IOException("Directory already exists:" + newFolder.getAbsolutePath());
} else {
- newFolder.mkdirs();
+ if(!newFolder.mkdirs()) {
+ throw new IOException(newFolder.getAbsolutePath());
+ }
}
return newFolder;
@@ -773,7 +775,9 @@
if(newFolder.exists()) {
throw new IOException("Directory already exists:" + newFolder.getAbsolutePath());
} else {
- newFolder.mkdirs();
+ if(!newFolder.mkdirs()) {
+ throw new IOException(newFolder.getAbsolutePath());
+ }
}
return newFolder;
@@ -842,9 +846,10 @@
if(newFolder.exists()) {
throw new IOException("Directory already exists:" + newFolder.getAbsolutePath());
} else {
- newFolder.mkdirs();
+ if(!newFolder.mkdirs()) {
+ throw new IOException(newFolder.getAbsolutePath());
+ }
}
-
return newFolder;
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java Mon Dec 14 10:36:12 2015 -0800
@@ -36,6 +36,7 @@
import sun.font.BidiUtils;
import sun.swing.SwingUtilities2;
+import sun.swing.text.UndoableEditLockSupport;
/**
* An implementation of the document interface to serve as a
@@ -275,6 +276,11 @@
* @see EventListenerList
*/
protected void fireUndoableEditUpdate(UndoableEditEvent e) {
+ if (e.getEdit() instanceof DefaultDocumentEvent) {
+ e = new UndoableEditEvent(e.getSource(),
+ new DefaultDocumentEventUndoableWrapper(
+ (DefaultDocumentEvent)e.getEdit()));
+ }
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
@@ -2952,6 +2958,88 @@
}
+ static class DefaultDocumentEventUndoableWrapper implements
+ UndoableEdit, UndoableEditLockSupport
+ {
+ final DefaultDocumentEvent dde;
+ public DefaultDocumentEventUndoableWrapper(DefaultDocumentEvent dde) {
+ this.dde = dde;
+ }
+
+ @Override
+ public void undo() throws CannotUndoException {
+ dde.undo();
+ }
+
+ @Override
+ public boolean canUndo() {
+ return dde.canUndo();
+ }
+
+ @Override
+ public void redo() throws CannotRedoException {
+ dde.redo();
+ }
+
+ @Override
+ public boolean canRedo() {
+ return dde.canRedo();
+ }
+
+ @Override
+ public void die() {
+ dde.die();
+ }
+
+ @Override
+ public boolean addEdit(UndoableEdit anEdit) {
+ return dde.addEdit(anEdit);
+ }
+
+ @Override
+ public boolean replaceEdit(UndoableEdit anEdit) {
+ return dde.replaceEdit(anEdit);
+ }
+
+ @Override
+ public boolean isSignificant() {
+ return dde.isSignificant();
+ }
+
+ @Override
+ public String getPresentationName() {
+ return dde.getPresentationName();
+ }
+
+ @Override
+ public String getUndoPresentationName() {
+ return dde.getUndoPresentationName();
+ }
+
+ @Override
+ public String getRedoPresentationName() {
+ return dde.getRedoPresentationName();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public void lockEdit() {
+ ((AbstractDocument)dde.getDocument()).writeLock();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public void unlockEdit() {
+ ((AbstractDocument)dde.getDocument()).writeUnlock();
+ }
+ }
+
/**
* This event used when firing document changes while Undo/Redo
* operations. It just wraps DefaultDocumentEvent and delegates
--- a/jdk/src/java.desktop/share/classes/javax/swing/undo/UndoManager.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/undo/UndoManager.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -28,6 +28,7 @@
import javax.swing.event.*;
import javax.swing.UIManager;
import java.util.*;
+import sun.swing.text.UndoableEditLockSupport;
/**
* {@code UndoManager} manages a list of {@code UndoableEdits},
@@ -134,6 +135,11 @@
*/
@SuppressWarnings("serial") // Same-version serialization only
public class UndoManager extends CompoundEdit implements UndoableEditListener {
+ private enum Action {
+ UNDO,
+ REDO,
+ ANY
+ }
int indexOfNextAdd;
int limit;
@@ -369,13 +375,8 @@
* @throws CannotRedoException if one of the edits throws
* <code>CannotRedoException</code>
*/
- public synchronized void undoOrRedo() throws CannotRedoException,
- CannotUndoException {
- if (indexOfNextAdd == edits.size()) {
- undo();
- } else {
- redo();
- }
+ public void undoOrRedo() throws CannotRedoException, CannotUndoException {
+ tryUndoOrRedo(Action.ANY);
}
/**
@@ -407,16 +408,8 @@
* @see #canUndo
* @see #editToBeUndone
*/
- public synchronized void undo() throws CannotUndoException {
- if (inProgress) {
- UndoableEdit edit = editToBeUndone();
- if (edit == null) {
- throw new CannotUndoException();
- }
- undoTo(edit);
- } else {
- super.undo();
- }
+ public void undo() throws CannotUndoException {
+ tryUndoOrRedo(Action.UNDO);
}
/**
@@ -452,16 +445,90 @@
* @see #canRedo
* @see #editToBeRedone
*/
- public synchronized void redo() throws CannotRedoException {
- if (inProgress) {
- UndoableEdit edit = editToBeRedone();
- if (edit == null) {
- throw new CannotRedoException();
+ public void redo() throws CannotRedoException {
+ tryUndoOrRedo(Action.REDO);
+ }
+
+ private void tryUndoOrRedo(Action action) {
+ UndoableEditLockSupport lockSupport = null;
+ boolean undo;
+ synchronized (this) {
+ if (action == Action.ANY) {
+ undo = indexOfNextAdd == edits.size();
+ } else {
+ undo = action == Action.UNDO;
+ }
+ if (inProgress) {
+ UndoableEdit edit = undo ? editToBeUndone() : editToBeRedone();
+ if (edit == null) {
+ throw undo ? new CannotUndoException() :
+ new CannotRedoException();
+ }
+ lockSupport = getEditLockSupport(edit);
+ if (lockSupport == null) {
+ if (undo) {
+ undoTo(edit);
+ } else {
+ redoTo(edit);
+ }
+ return;
+ }
+ } else {
+ if (undo) {
+ super.undo();
+ } else {
+ super.redo();
+ }
+ return;
}
- redoTo(edit);
- } else {
- super.redo();
}
+ // the edit synchronization is required
+ while (true) {
+ lockSupport.lockEdit();
+ UndoableEditLockSupport editLockSupport = null;
+ try {
+ synchronized (this) {
+ if (action == Action.ANY) {
+ undo = indexOfNextAdd == edits.size();
+ }
+ if (inProgress) {
+ UndoableEdit edit = undo ? editToBeUndone() :
+ editToBeRedone();
+ if (edit == null) {
+ throw undo ? new CannotUndoException() :
+ new CannotRedoException();
+ }
+ editLockSupport = getEditLockSupport(edit);
+ if (editLockSupport == null ||
+ editLockSupport == lockSupport) {
+ if (undo) {
+ undoTo(edit);
+ } else {
+ redoTo(edit);
+ }
+ return;
+ }
+ } else {
+ if (undo) {
+ super.undo();
+ } else {
+ super.redo();
+ }
+ return;
+ }
+ }
+ } finally {
+ if (lockSupport != null) {
+ lockSupport.unlockEdit();
+ }
+ lockSupport = editLockSupport;
+ }
+ }
+ }
+
+ private UndoableEditLockSupport getEditLockSupport(UndoableEdit anEdit) {
+ return anEdit instanceof UndoableEditLockSupport ?
+ (UndoableEditLockSupport)anEdit : null;
}
/**
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java Mon Dec 14 10:36:12 2015 -0800
@@ -70,6 +70,10 @@
{
this.comp = comp;
this.graphicsConfig = graphicsConfig;
+ if (width <= 0 || height <= 0) {
+ throw new IllegalArgumentException("Width (" + width + ")" +
+ " and height (" + height + ") cannot be <= 0");
+ }
this.width = width;
this.height = height;
this.forcedAccelSurfaceType = accType;
--- a/jdk/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java Mon Dec 14 10:36:12 2015 -0800
@@ -445,13 +445,19 @@
}
public void setGlyphPosition(int ix, Point2D pos) {
+ if (ix < 0 || ix > glyphs.length) {
+ throw new IndexOutOfBoundsException("ix = " + ix);
+ }
+
initPositions();
int ix2 = ix << 1;
positions[ix2] = (float)pos.getX();
positions[ix2 + 1] = (float)pos.getY();
- clearCaches(ix);
+ if (ix < glyphs.length) {
+ clearCaches(ix);
+ }
addFlags(FLAG_HAS_POSITION_ADJUSTMENTS);
}
--- a/jdk/src/java.desktop/share/classes/sun/font/TrueTypeFont.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/TrueTypeFont.java Mon Dec 14 10:36:12 2015 -0800
@@ -176,6 +176,13 @@
private String localeFamilyName;
private String localeFullName;
+ public TrueTypeFont(String platname, Object nativeNames, int fIndex,
+ boolean javaRasterizer)
+ throws FontFormatException
+ {
+ this(platname, nativeNames, fIndex, javaRasterizer, true);
+ }
+
/**
* - does basic verification of the file
* - reads the header table for this font (within a collection)
@@ -186,14 +193,17 @@
* or fails verification, or there's no usable cmap
*/
public TrueTypeFont(String platname, Object nativeNames, int fIndex,
- boolean javaRasterizer)
+ boolean javaRasterizer, boolean useFilePool)
throws FontFormatException {
super(platname, nativeNames);
useJavaRasterizer = javaRasterizer;
fontRank = Font2D.TTF_RANK;
try {
- verify();
+ verify(useFilePool);
init(fIndex);
+ if (!useFilePool) {
+ close();
+ }
} catch (Throwable t) {
close();
if (t instanceof FontFormatException) {
@@ -280,6 +290,10 @@
}
+ private synchronized FileChannel open() throws FontFormatException {
+ return open(true);
+ }
+
/* This is intended to be called, and the returned value used,
* from within a block synchronized on this font object.
* ie the channel returned may be nulled out at any time by "close()"
@@ -287,7 +301,8 @@
* Deadlock warning: FontManager.addToPool(..) acquires a global lock,
* which means nested locks may be in effect.
*/
- private synchronized FileChannel open() throws FontFormatException {
+ private synchronized FileChannel open(boolean usePool)
+ throws FontFormatException {
if (disposerRecord.channel == null) {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().info("open TTF: " + platName);
@@ -306,9 +321,11 @@
});
disposerRecord.channel = raf.getChannel();
fileSize = (int)disposerRecord.channel.size();
- FontManager fm = FontManagerFactory.getInstance();
- if (fm instanceof SunFontManager) {
- ((SunFontManager) fm).addToPool(this);
+ if (usePool) {
+ FontManager fm = FontManagerFactory.getInstance();
+ if (fm instanceof SunFontManager) {
+ ((SunFontManager) fm).addToPool(this);
+ }
}
} catch (NullPointerException e) {
close();
@@ -492,8 +509,8 @@
}
}
- private void verify() throws FontFormatException {
- open();
+ private void verify(boolean usePool) throws FontFormatException {
+ open(usePool);
}
/* sizes, in bytes, of TT/TTC header records */
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ArrayCache.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ArrayCache.java Mon Dec 14 10:36:12 2015 -0800
@@ -166,18 +166,31 @@
* @return new array size
*/
public static int getNewSize(final int curSize, final int needSize) {
+ // check if needSize is negative or integer overflow:
+ if (needSize < 0) {
+ // hard overflow failure - we can't even accommodate
+ // new items without overflowing
+ throw new ArrayIndexOutOfBoundsException(
+ "array exceeds maximum capacity !");
+ }
+ assert curSize >= 0;
final int initial = (curSize & MASK_CLR_1);
int size;
if (initial > THRESHOLD_ARRAY_SIZE) {
size = initial + (initial >> 1); // x(3/2)
} else {
- size = (initial) << 1; // x2
+ size = (initial << 1); // x2
}
// ensure the new size is >= needed size:
if (size < needSize) {
- // align to 4096:
+ // align to 4096 (may overflow):
size = ((needSize >> 12) + 1) << 12;
}
+ // check integer overflow:
+ if (size < 0) {
+ // resize to maximum capacity:
+ size = Integer.MAX_VALUE;
+ }
return size;
}
@@ -188,26 +201,29 @@
* @return new array size
*/
public static long getNewLargeSize(final long curSize, final long needSize) {
+ // check if needSize is negative or integer overflow:
+ if ((needSize >> 31L) != 0L) {
+ // hard overflow failure - we can't even accommodate
+ // new items without overflowing
+ throw new ArrayIndexOutOfBoundsException(
+ "array exceeds maximum capacity !");
+ }
+ assert curSize >= 0L;
long size;
if (curSize > THRESHOLD_HUGE_ARRAY_SIZE) {
size = curSize + (curSize >> 2L); // x(5/4)
} else if (curSize > THRESHOLD_LARGE_ARRAY_SIZE) {
size = curSize + (curSize >> 1L); // x(3/2)
} else {
- size = curSize << 1L; // x2
+ size = (curSize << 1L); // x2
}
// ensure the new size is >= needed size:
if (size < needSize) {
// align to 4096:
- size = ((needSize >> 12) + 1) << 12;
+ size = ((needSize >> 12L) + 1L) << 12L;
}
- if (size >= Integer.MAX_VALUE) {
- if (curSize >= Integer.MAX_VALUE) {
- // hard overflow failure - we can't even accommodate
- // new items without overflowing
- throw new ArrayIndexOutOfBoundsException(
- "array exceeds maximum capacity !");
- }
+ // check integer overflow:
+ if (size > Integer.MAX_VALUE) {
// resize to maximum capacity:
size = Integer.MAX_VALUE;
}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ByteArrayCache.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ByteArrayCache.java Mon Dec 14 10:36:12 2015 -0800
@@ -74,7 +74,7 @@
void putDirtyArray(final byte[] array, final int length) {
if (length != arraySize) {
if (doChecks) {
- System.out.println("ArrayCache: bad length = " + length);
+ MarlinUtils.logInfo("ArrayCache: bad length = " + length);
}
return;
}
@@ -98,7 +98,7 @@
{
if (length != arraySize) {
if (doChecks) {
- System.out.println("ArrayCache: bad length = " + length);
+ MarlinUtils.logInfo("ArrayCache: bad length = " + length);
}
return;
}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/FloatArrayCache.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/FloatArrayCache.java Mon Dec 14 10:36:12 2015 -0800
@@ -75,7 +75,7 @@
void putDirtyArray(final float[] array, final int length) {
if (length != arraySize) {
if (doChecks) {
- System.out.println("ArrayCache: bad length = " + length);
+ MarlinUtils.logInfo("ArrayCache: bad length = " + length);
}
return;
}
@@ -99,7 +99,7 @@
{
if (length != arraySize) {
if (doChecks) {
- System.out.println("ArrayCache: bad length = " + length);
+ MarlinUtils.logInfo("ArrayCache: bad length = " + length);
}
return;
}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/IntArrayCache.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/IntArrayCache.java Mon Dec 14 10:36:12 2015 -0800
@@ -74,7 +74,7 @@
void putDirtyArray(final int[] array, final int length) {
if (length != arraySize) {
if (doChecks) {
- System.out.println("ArrayCache: bad length = " + length);
+ MarlinUtils.logInfo("ArrayCache: bad length = " + length);
}
return;
}
@@ -98,7 +98,7 @@
{
if (length != arraySize) {
if (doChecks) {
- System.out.println("ArrayCache: bad length = " + length);
+ MarlinUtils.logInfo("ArrayCache: bad length = " + length);
}
return;
}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinCache.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinCache.java Mon Dec 14 10:36:12 2015 -0800
@@ -156,8 +156,6 @@
// rewritten to avoid division:
|| (width * heightSubPixel) >
((edgeSumDeltaY - heightSubPixel) << BLOCK_SIZE_LG);
-// ((edgeSumDeltaY - heightSubPixel) * RLE_THRESHOLD);
-// ((edgeSumDeltaY - heightSubPixel) << BLOCK_TH_LG);
if (doTrace && !useRLE) {
final float meanCrossings
@@ -293,8 +291,10 @@
// update row index to current position:
rowAAChunkIndex[row] = pos;
- // determine need array size (may overflow):
- final long needSize = pos + (px_bbox1 - px0);
+ // determine need array size:
+ // for RLE encoding, position must be aligned to 4 bytes (int):
+ // align - 1 = 3 so add +3 and round-off by mask ~3 = -4
+ final long needSize = pos + ((px_bbox1 - px0 + 3) & -4);
// update next position (bytes):
rowAAChunkPos = needSize;
@@ -401,8 +401,7 @@
// determine need array size:
// pessimistic: max needed size = deltaX x 4 (1 int)
- final int maxLen = (to - from);
- final long needSize = initialPos + (maxLen << 2);
+ final long needSize = initialPos + ((to - from) << 2);
// update row data:
OffHeapArray _rowAAChunk = rowAAChunk;
@@ -465,6 +464,13 @@
// note: last pixel exclusive (>= 0)
// note: it should check X is smaller than 23bits (overflow)!
+ // check address alignment to 4 bytes:
+ if (doCheckUnsafe) {
+ if ((addr_off & 3) != 0) {
+ MarlinUtils.logInfo("Misaligned Unsafe address: " + addr_off);
+ }
+ }
+
// special case to encode entries into a single int:
if (val == 0) {
_unsafe.putInt(addr_off,
@@ -521,6 +527,13 @@
// note: last pixel exclusive (>= 0)
// note: it should check X is smaller than 23bits (overflow)!
+ // check address alignment to 4 bytes:
+ if (doCheckUnsafe) {
+ if ((addr_off & 3) != 0) {
+ MarlinUtils.logInfo("Misaligned Unsafe address: " + addr_off);
+ }
+ }
+
// special case to encode entries into a single int:
if (val == 0) {
_unsafe.putInt(addr_off,
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinConst.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinConst.java Mon Dec 14 10:36:12 2015 -0800
@@ -30,8 +30,8 @@
*/
interface MarlinConst {
// enable Logs (logger or stdout)
- static final boolean enableLogs = false;
- // enable Logger
+ static final boolean enableLogs = MarlinProperties.isLoggingEnabled();
+ // use Logger instead of stdout
static final boolean useLogger = enableLogs && MarlinProperties.isUseLogger();
// log new RendererContext
@@ -40,14 +40,17 @@
// log misc.Unsafe alloc/realloc/free
static final boolean logUnsafeMalloc = enableLogs
&& MarlinProperties.isLogUnsafeMalloc();
+ // do check unsafe alignment:
+ static final boolean doCheckUnsafe = false;
// do statistics
static final boolean doStats = enableLogs && MarlinProperties.isDoStats();
// do monitors
// disabled to reduce byte-code size a bit...
- static final boolean doMonitors = enableLogs && false; // MarlinProperties.isDoMonitors();
+ static final boolean doMonitors = false;
+// static final boolean doMonitors = enableLogs && MarlinProperties.isDoMonitors();
// do checks
- static final boolean doChecks = false; // MarlinProperties.isDoChecks();
+ static final boolean doChecks = enableLogs && MarlinProperties.isDoChecks();
// do AA range checks: disable when algorithm / code is stable
static final boolean DO_AA_RANGE_CHECK = false;
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinProperties.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinProperties.java Mon Dec 14 10:36:12 2015 -0800
@@ -136,6 +136,10 @@
// logging parameters
+ public static boolean isLoggingEnabled() {
+ return getBoolean("sun.java2d.renderer.log", "false");
+ }
+
public static boolean isUseLogger() {
return getBoolean("sun.java2d.renderer.useLogger", "false");
}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinUtils.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinUtils.java Mon Dec 14 10:36:12 2015 -0800
@@ -27,12 +27,12 @@
public final class MarlinUtils {
- // TODO: use sun.util.logging.PlatformLogger once in JDK9
- private static final java.util.logging.Logger log;
+ // Marlin logger
+ private static final sun.util.logging.PlatformLogger log;
static {
if (MarlinConst.useLogger) {
- log = java.util.logging.Logger.getLogger("sun.java2d.marlin");
+ log = sun.util.logging.PlatformLogger.getLogger("sun.java2d.marlin");
} else {
log = null;
}
@@ -53,25 +53,11 @@
public static void logException(final String msg, final Throwable th) {
if (MarlinConst.useLogger) {
-// log.warning(msg, th);
- log.log(java.util.logging.Level.WARNING, msg, th);
+ log.warning(msg, th);
} else if (MarlinConst.enableLogs) {
System.out.print("WARNING: ");
System.out.println(msg);
th.printStackTrace(System.err);
}
}
-
- // Returns the caller's class and method's name; best effort
- // if cannot infer, return the logger's name.
- static String getCallerInfo(String className) {
- String sourceClassName = null;
- String sourceMethodName = null;
-
- if (sourceClassName != null) {
- return sourceClassName + " " + sourceMethodName;
- } else {
- return "unknown";
- }
- }
}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Renderer.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Renderer.java Mon Dec 14 10:36:12 2015 -0800
@@ -629,6 +629,13 @@
}
if (edgeMinY != Float.POSITIVE_INFINITY) {
+ // if context is maked as DIRTY:
+ if (rdrCtx.dirty) {
+ // may happen if an exception if thrown in the pipeline processing:
+ // clear completely buckets arrays:
+ buckets_minY = 0;
+ buckets_maxY = boundsMaxY - boundsMinY;
+ }
// clear used part
if (edgeBuckets == edgeBuckets_initial) {
// fill only used part
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java Mon Dec 14 10:36:12 2015 -0800
@@ -31,7 +31,6 @@
import java.util.concurrent.atomic.AtomicInteger;
import static sun.java2d.marlin.ArrayCache.*;
import sun.java2d.marlin.MarlinRenderingEngine.NormalizingPathIterator;
-import static sun.java2d.marlin.MarlinUtils.getCallerInfo;
import static sun.java2d.marlin.MarlinUtils.logInfo;
/**
@@ -39,7 +38,6 @@
*/
final class RendererContext implements MarlinConst {
- private static final String className = RendererContext.class.getName();
// RendererContext creation counter
private static final AtomicInteger contextCount = new AtomicInteger(1);
// RendererContext statistics
@@ -214,8 +212,7 @@
}
if (doLogOverSize) {
- logInfo("getDirtyByteArray[oversize]: length=\t" + length
- + "\tfrom=\t" + getCallerInfo(className));
+ logInfo("getDirtyByteArray[oversize]: length=\t" + length);
}
return new byte[length];
@@ -254,7 +251,7 @@
if (doLogWidenArray) {
logInfo("widenDirtyByteArray[" + res.length + "]: usedSize=\t"
+ usedSize + "\tlength=\t" + length + "\tneeded length=\t"
- + needSize + "\tfrom=\t" + getCallerInfo(className));
+ + needSize);
}
return res;
}
@@ -275,8 +272,7 @@
}
if (doLogOverSize) {
- logInfo("getIntArray[oversize]: length=\t" + length + "\tfrom=\t"
- + getCallerInfo(className));
+ logInfo("getIntArray[oversize]: length=\t" + length);
}
return new int[length];
@@ -306,7 +302,7 @@
if (doLogWidenArray) {
logInfo("widenIntArray[" + res.length + "]: usedSize=\t"
+ usedSize + "\tlength=\t" + length + "\tneeded length=\t"
- + needSize + "\tfrom=\t" + getCallerInfo(className));
+ + needSize);
}
return res;
}
@@ -338,8 +334,7 @@
}
if (doLogOverSize) {
- logInfo("getDirtyIntArray[oversize]: length=\t" + length
- + "\tfrom=\t" + getCallerInfo(className));
+ logInfo("getDirtyIntArray[oversize]: length=\t" + length);
}
return new int[length];
@@ -369,7 +364,7 @@
if (doLogWidenArray) {
logInfo("widenDirtyIntArray[" + res.length + "]: usedSize=\t"
+ usedSize + "\tlength=\t" + length + "\tneeded length=\t"
- + needSize + "\tfrom=\t" + getCallerInfo(className));
+ + needSize);
}
return res;
}
@@ -399,8 +394,7 @@
}
if (doLogOverSize) {
- logInfo("getDirtyFloatArray[oversize]: length=\t" + length
- + "\tfrom=\t" + getCallerInfo(className));
+ logInfo("getDirtyFloatArray[oversize]: length=\t" + length);
}
return new float[length];
@@ -430,7 +424,7 @@
if (doLogWidenArray) {
logInfo("widenDirtyFloatArray[" + res.length + "]: usedSize=\t"
+ usedSize + "\tlength=\t" + length + "\tneeded length=\t"
- + needSize + "\tfrom=\t" + getCallerInfo(className));
+ + needSize);
}
return res;
}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/RendererStats.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/RendererStats.java Mon Dec 14 10:36:12 2015 -0800
@@ -25,6 +25,8 @@
package sun.java2d.marlin;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -32,6 +34,7 @@
import sun.java2d.marlin.stats.Histogram;
import sun.java2d.marlin.stats.Monitor;
import sun.java2d.marlin.stats.StatLong;
+import sun.awt.util.ThreadGroupUtils;
/**
* This class gathers global rendering statistics for debugging purposes only
@@ -237,22 +240,33 @@
private RendererStats() {
super();
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- dump();
- }
- });
+ AccessController.doPrivileged(
+ (PrivilegedAction<Void>) () -> {
+ final Thread hook = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(),
+ new Runnable() {
+ @Override
+ public void run() {
+ dump();
+ }
+ },
+ "MarlinStatsHook"
+ );
+ hook.setContextClassLoader(null);
+ Runtime.getRuntime().addShutdownHook(hook);
- if (useDumpThread) {
- final Timer statTimer = new Timer("RendererStats");
- statTimer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- dump();
+ if (useDumpThread) {
+ final Timer statTimer = new Timer("RendererStats");
+ statTimer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ dump();
+ }
+ }, statDump, statDump);
}
- }, statDump, statDump);
- }
+ return null;
+ }
+ );
}
void dump() {
--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java Mon Dec 14 10:36:12 2015 -0800
@@ -1265,14 +1265,15 @@
}
private void ensureSpace(final int n) {
- if (end + n > curves.length) {
+ // use substraction to avoid integer overflow:
+ if (curves.length - end < n) {
if (doStats) {
RendererContext.stats.stat_array_stroker_polystack_curves
.add(end + n);
}
curves = rdrCtx.widenDirtyFloatArray(curves, end, end + n);
}
- if (numCurves + 1 > curveTypes.length) {
+ if (curveTypes.length <= numCurves) {
if (doStats) {
RendererContext.stats.stat_array_stroker_polystack_curveTypes
.add(numCurves + 1);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/swing/text/UndoableEditLockSupport.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015, 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.swing.text;
+
+import javax.swing.undo.UndoableEdit;
+
+/**
+ * UndoableEdit support for undo/redo actions synchronization
+ * @since 1.9
+ */
+public interface UndoableEditLockSupport extends UndoableEdit {
+ /**
+ * lock the UndoableEdit for threadsafe undo/redo
+ */
+ void lockEdit();
+
+ /**
+ * unlock the UndoableEdit
+ */
+ void unlockEdit();
+}
--- a/jdk/src/java.desktop/share/native/libfontmanager/FontInstanceAdapter.cpp Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/native/libfontmanager/FontInstanceAdapter.cpp Mon Dec 14 10:36:12 2015 -0800
@@ -67,12 +67,6 @@
};
-const void *FontInstanceAdapter::getFontTable(LETag tableTag) const
-{
- size_t ignored = 0;
- return getFontTable(tableTag, ignored);
-}
-
static const LETag cacheMap[LAYOUTCACHE_ENTRIES] = {
GPOS_TAG, GDEF_TAG, GSUB_TAG, MORT_TAG, MORX_TAG, KERN_TAG
};
--- a/jdk/src/java.desktop/share/native/libfontmanager/FontInstanceAdapter.h Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/native/libfontmanager/FontInstanceAdapter.h Mon Dec 14 10:36:12 2015 -0800
@@ -85,7 +85,6 @@
// tables are cached with the native font scaler data
// only supports gsub, gpos, gdef, mort tables at present
- virtual const void *getFontTable(LETag tableTag) const;
virtual const void *getFontTable(LETag tableTag, size_t &len) const;
virtual void *getKernPairs() const {
--- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c Mon Dec 14 10:36:12 2015 -0800
@@ -80,15 +80,18 @@
float scale = 1.0f/64.0f;
unsigned int* glyphs;
float* positions;
+ int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv;
+ unsigned int* indices;
+ jarray glyphArray, posArray, inxArray;
if (!init_JNI_IDs(env)) {
return 0;
}
- int initialCount = (*env)->GetIntField(env, gvdata, gvdCountFID);
- jarray glyphArray =
+ initialCount = (*env)->GetIntField(env, gvdata, gvdCountFID);
+ glyphArray =
(jarray)(*env)->GetObjectField(env, gvdata, gvdGlyphsFID);
- jarray posArray =
+ posArray =
(jarray)(*env)->GetObjectField(env, gvdata, gvdPositionsFID);
if (glyphArray == NULL || posArray == NULL)
@@ -101,9 +104,9 @@
// and re-invokes layout. I suppose this is expected to be rare
// because at least in a single threaded case there should be
// re-use of the same container, but it is a little wasteful/distateful.
- int glyphArrayLen = (*env)->GetArrayLength(env, glyphArray);
- int posArrayLen = (*env)->GetArrayLength(env, posArray);
- int maxGlyphs = glyphCount + initialCount;
+ glyphArrayLen = (*env)->GetArrayLength(env, glyphArray);
+ posArrayLen = (*env)->GetArrayLength(env, posArray);
+ maxGlyphs = glyphCount + initialCount;
if ((maxGlyphs > glyphArrayLen) ||
(maxGlyphs * 2 + 2 > posArrayLen))
{
@@ -125,7 +128,7 @@
x += glyphPos[i].x_advance * scale;
y += glyphPos[i].y_advance * scale;
}
- int storeadv = initialCount+glyphCount;
+ storeadv = initialCount+glyphCount;
// The final slot in the positions array is important
// because when the GlyphVector is created from this
// data it determines the overall advance of the glyphvector
@@ -138,11 +141,10 @@
(*env)->ReleasePrimitiveArrayCritical(env, glyphArray, glyphs, 0);
(*env)->ReleasePrimitiveArrayCritical(env, posArray, positions, 0);
putFloat(env, startPt,positions[(storeadv*2)],positions[(storeadv*2)+1] );
- jarray inxArray =
+ inxArray =
(jarray)(*env)->GetObjectField(env, gvdata, gvdIndicesFID);
- unsigned int* indices =
+ indices =
(unsigned int*)(*env)->GetPrimitiveArrayCritical(env, inxArray, NULL);
- int prevCluster = -1;
for (i = 0; i < glyphCount; i++) {
int cluster = glyphInfo[i].cluster;
if (direction == HB_DIRECTION_LTR) {
--- a/jdk/src/java.desktop/share/native/libfontmanager/freetypeScaler.c Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/native/libfontmanager/freetypeScaler.c Mon Dec 14 10:36:12 2015 -0800
@@ -258,7 +258,7 @@
scalerInfo->fontData,
scalerInfo->fontDataLength);
if (bBuffer != NULL) {
- (*env)->CallObjectMethod(env, font2D,
+ (*env)->CallVoidMethod(env, font2D,
sunFontIDs.readFileMID, bBuffer);
error = FT_New_Memory_Face(scalerInfo->library,
--- a/jdk/src/java.desktop/share/native/libfontmanager/layout/LEFontInstance.h Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/LEFontInstance.h Mon Dec 14 10:36:12 2015 -0800
@@ -181,28 +181,6 @@
*
* Subclasses which represent composite fonts should always return <code>NULL</code>.
*
- * Note that implementing this function does not allow for range checking.
- * Subclasses that desire the safety of range checking must implement the
- * variation which has a length parameter.
- *
- * @param tableTag - the four byte table tag. (e.g. 'cmap')
- *
- * @return the address of the table in memory, or <code>NULL</code>
- * if the table doesn't exist.
- *
- * @stable ICU 2.8
- */
- virtual const void *getFontTable(LETag tableTag) const = 0;
-
- /**
- * This method reads a table from the font. Note that in general,
- * it only makes sense to call this method on an <code>LEFontInstance</code>
- * which represents a physical font - i.e. one which has been returned by
- * <code>getSubFont()</code>. This is because each subfont in a composite font
- * will have different tables, and there's no way to know which subfont to access.
- *
- * Subclasses which represent composite fonts should always return <code>NULL</code>.
- *
* This version sets a length, for range checking.
* Note that range checking can only be accomplished if this function is
* implemented in subclasses.
@@ -213,7 +191,7 @@
* if the table doesn't exist.
* @internal
*/
- virtual const void* getFontTable(LETag tableTag, size_t &length) const { length=-1; return getFontTable(tableTag); } /* -1 = unknown length */
+ virtual const void* getFontTable(LETag tableTag, size_t &length) const = 0;
virtual void *getKernPairs() const = 0;
virtual void setKernPairs(void *pairs) const = 0;
--- a/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c Mon Dec 14 10:36:12 2015 -0800
@@ -1610,6 +1610,7 @@
int ret;
int h_samp0, h_samp1, h_samp2;
int v_samp0, v_samp1, v_samp2;
+ int cid0, cid1, cid2;
jboolean retval = JNI_FALSE;
imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
j_decompress_ptr cinfo;
@@ -1711,17 +1712,15 @@
}
} else if (!cinfo->saw_JFIF_marker && !IS_EXIF(cinfo)) {
/*
- * IJG assumes all unidentified 3-channels are YCbCr.
- * We assume that only if the second two channels are
- * subsampled (either horizontally or vertically). If not,
- * we assume RGB.
- *
- * 4776576: Some digital cameras output YCbCr JPEG images
- * that do not contain a JFIF APP0 marker but are only
- * vertically subsampled (no horizontal subsampling).
- * We should only assume this is RGB data if the subsampling
- * factors for the second two channels are the same as the
- * first (check both horizontal and vertical factors).
+ * In the absence of certain markers, IJG has interpreted
+ * component id's of [1,2,3] as meaning YCbCr.We follow that
+ * interpretation, which is additionally described in the Image
+ * I/O JPEG metadata spec.If that condition is not met here the
+ * next step will be to examine the subsampling factors, if
+ * there is any difference in subsampling factors we also assume
+ * YCbCr, only if both horizontal and vertical subsampling
+ * is same we assume JPEG color space as RGB.
+ * This is also described in the Image I/O JPEG metadata spec.
*/
h_samp0 = cinfo->comp_info[0].h_samp_factor;
h_samp1 = cinfo->comp_info[1].h_samp_factor;
@@ -1731,8 +1730,13 @@
v_samp1 = cinfo->comp_info[1].v_samp_factor;
v_samp2 = cinfo->comp_info[2].v_samp_factor;
- if ((h_samp1 == h_samp0) && (h_samp2 == h_samp0) &&
- (v_samp1 == v_samp0) && (v_samp2 == v_samp0))
+ cid0 = cinfo->comp_info[0].component_id;
+ cid1 = cinfo->comp_info[1].component_id;
+ cid2 = cinfo->comp_info[2].component_id;
+
+ if ((!(cid0 == 1 && cid1 == 2 && cid2 == 3)) &&
+ ((h_samp1 == h_samp0) && (h_samp2 == h_samp0) &&
+ (v_samp1 == v_samp0) && (v_samp2 == v_samp0)))
{
cinfo->jpeg_color_space = JCS_RGB;
/* output is already RGB, so it stays the same */
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java Mon Dec 14 10:36:12 2015 -0800
@@ -413,6 +413,7 @@
void addListeners() {
canvas.addMouseListener(eventProxy);
canvas.addMouseMotionListener(eventProxy);
+ eframe.addMouseListener(eventProxy);
}
long getWindow() {
--- a/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java Mon Dec 14 10:36:12 2015 -0800
@@ -926,7 +926,10 @@
return copyflavors;
}
}
- return null;
+ DocFlavor[] flavor = new DocFlavor[2];
+ flavor[0] = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
+ flavor[1] = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
+ return flavor;
}
--- a/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c Mon Dec 14 10:36:12 2015 -0800
@@ -438,6 +438,15 @@
xsdo->drawable = drawable;
xsdo->isPixmap = JNI_FALSE;
} else {
+ /*
+ * width , height must be nonzero otherwise XCreatePixmap
+ * generates BadValue in error_handler
+ */
+ if (width <= 0 || height <= 0) {
+ JNU_ThrowOutOfMemoryError(env,
+ "Can't create offscreen surface");
+ return JNI_FALSE;
+ }
xsdo->isPixmap = JNI_TRUE;
/* REMIND: workaround for bug 4420220 on pgx32 boards:
don't use DGA with pixmaps unless USE_DGA_PIXMAPS is set.
--- a/jdk/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java Mon Dec 14 10:36:12 2015 -0800
@@ -61,7 +61,7 @@
* enumerate (allow direct use) of EUDC fonts.
*/
eudcFont = new TrueTypeFont(eudcFile, null, 0,
- true);
+ true, false);
} catch (FontFormatException e) {
}
}
--- a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java Mon Dec 14 10:36:12 2015 -0800
@@ -48,8 +48,6 @@
@jdk.Exported
public class AWTEventMonitor {
- static private boolean runningOnJDK1_4 = false;
-
/**
* The current component with keyboard focus.
*
@@ -638,15 +636,9 @@
* @see AWTEventMonitor
*/
public AWTEventsListener() {
- String version = System.getProperty("java.version");
- if (version != null) {
- runningOnJDK1_4 = (version.compareTo("1.4") >= 0);
- }
initializeIntrospection();
installListeners();
- if (runningOnJDK1_4) {
- MenuSelectionManager.defaultManager().addChangeListener(this);
- }
+ MenuSelectionManager.defaultManager().addChangeListener(this);
EventQueueMonitor.addTopLevelWindowListener(this);
}
@@ -848,15 +840,7 @@
case EventID.FOCUS:
c.removeFocusListener(this);
c.addFocusListener(this);
-
- if (runningOnJDK1_4) {
- processFocusGained();
-
- } else { // not runningOnJDK1_4
- if ((c != componentWithFocus_private) && c.hasFocus()) {
- componentWithFocus_private = c;
- }
- }
+ processFocusGained();
break;
case EventID.ITEM:
--- a/jdk/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java Mon Dec 14 10:36:12 2015 -0800
@@ -140,10 +140,6 @@
// initialize AccessibleRole map
initAccessibleRoleMap();
- // determine which version of the JDK is running
- String version = getJavaVersionProperty();
- debugString("JDK version = "+version);
-
// initialize the methods that map HWNDs and Java top-level
// windows
initHWNDcalls();
@@ -215,9 +211,7 @@
} catch (Exception e) {}
/*
- Build the extendedVirtualNameSearchRoles array list. I chose this method
- because some of the Accessible Roles that need to be added to it are not
- available in all versions of the J2SE that we want to support.
+ Build the extendedVirtualNameSearchRoles array list.
*/
extendedVirtualNameSearchRoles.add (AccessibleRole.COMBO_BOX);
try {
@@ -5919,7 +5913,7 @@
*/
AccessibleRole.UNKNOWN,
- // These roles are only available in JDK 1.4
+ // These roles are available since JDK 1.4
/**
* A STATUS_BAR is an simple component that can contain
--- a/jdk/test/ProblemList.txt Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/ProblemList.txt Mon Dec 14 10:36:12 2015 -0800
@@ -310,8 +310,6 @@
# jdk_imageio
-javax/imageio/plugins/shared/WriteAfterAbort.java generic-all
-
############################################################################
# jdk_swing
--- a/jdk/test/java/awt/List/SetFontTest/SetFontTest.html Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/List/SetFontTest/SetFontTest.html Mon Dec 14 10:36:12 2015 -0800
@@ -38,6 +38,6 @@
<p> See the dialog box (usually in upper left corner) for instructions</p>
-<APPLET CODE="SetFontTest.class" WIDTH=200 HEIGHT=200></APPLET>
+<APPLET CODE="SetFontTest.class" WIDTH=200 HEIGHT=220></APPLET>
</body>
</html>
--- a/jdk/test/java/awt/Mouse/MaximizedFrameTest/MaximizedFrameTest.html Mon Dec 14 09:27:15 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6176814
- @summary Metalworks frame maximizes after the move
- @author Andrei.Dmitriev.Com area=Event
- @run applet MaximizedFrameTest.html
- -->
-<head>
-<title> </title>
-</head>
-<body>
-
-<h1>bug 6176814<br>Bug ID: 6176814 </h1>
-
-<p> This is an AUTOMATIC test, simply wait for completion </p>
-
-<APPLET CODE="MaximizedFrameTest.class" WIDTH=200 HEIGHT=200></APPLET>
-</body>
-</html>
--- a/jdk/test/java/awt/Mouse/MaximizedFrameTest/MaximizedFrameTest.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/Mouse/MaximizedFrameTest/MaximizedFrameTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015 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
@@ -22,91 +22,149 @@
*/
/*
- test
- @bug 6176814
- @summary Metalworks frame maximizes after the move
- @author Andrei.Dmitriev area=Event
- @run applet MaximizedFrameTest.html
-*/
+ @test
+ @bug 6176814 8132766
+ @summary Metalworks frame maximizes after the move
+ @run main MaximizedFrameTest
+ */
-import java.applet.Applet;
-import javax.swing.*;
-import java.awt.event.*;
-import java.awt.*;
+import java.awt.AWTException;
+import java.awt.Component;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JFrame;
+import javax.swing.JLayeredPane;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
-public class MaximizedFrameTest extends Applet
-{
- final int ITERATIONS_COUNT = 20;
- Robot robot;
- Point framePosition;
- Point newFrameLocation;
- JFrame frame;
- Rectangle gcBounds;
- public static Object LOCK = new Object();
+public class MaximizedFrameTest {
+
+ final static int ITERATIONS_COUNT = 5;
+ private static JFrame frame;
+ private static Point tempMousePosition;
+ private static Component titleComponent;
- public void init()
- {
- String[] instructions =
- {
- "This is an AUTOMATIC test",
- "simply wait until it is done"
- };
+ public void init() {
JFrame.setDefaultLookAndFeelDecorated(true);
+
+ try {
+ UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+ } catch (ClassNotFoundException | InstantiationException |
+ IllegalAccessException | UnsupportedLookAndFeelException ex) {
+ throw new RuntimeException("Test Failed. MetalLookAndFeel not set "
+ + "for frame");
+ }
+
frame = new JFrame("JFrame Maximization Test");
frame.pack();
frame.setSize(450, 260);
- }//End init()
+ frame.setVisible(true);
+ }
+
+ public void getTitleComponent() throws Exception {
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ JLayeredPane lPane = frame.getLayeredPane();
+ boolean titleFound = false;
+
+ for (int j = 0; j < lPane.getComponentsInLayer(
+ JLayeredPane.FRAME_CONTENT_LAYER.intValue()).length; j++) {
+
+ titleComponent = lPane.getComponentsInLayer(
+ JLayeredPane.FRAME_CONTENT_LAYER.intValue())[j];
- public void start ()
- {
- frame.setVisible(true);
- validate();
- JLayeredPane lPane = frame.getLayeredPane();
- // System.out.println("JFrame's LayeredPane " + lPane );
- Component titleComponent = null;
- boolean titleFound = false;
- for (int j=0; j < lPane.getComponentsInLayer(JLayeredPane.FRAME_CONTENT_LAYER.intValue()).length; j++){
- titleComponent = lPane.getComponentsInLayer(JLayeredPane.FRAME_CONTENT_LAYER.intValue())[j];
- if (titleComponent.getClass().getName().equals("javax.swing.plaf.metal.MetalTitlePane")){
- titleFound = true;
- break;
+ if (titleComponent.getClass().getName().equals(
+ "javax.swing.plaf.metal.MetalTitlePane")) {
+
+ titleFound = true;
+ break;
+ }
+ }
+
+ if (!titleFound) {
+ try {
+ dispose();
+ } catch (Exception ex) {
+ Logger.getLogger(MaximizedFrameTest.class.getName())
+ .log(Level.SEVERE, null, ex);
+ }
+ throw new RuntimeException("Test Failed. Unable to "
+ + "determine title component");
+ }
}
- }
- if ( !titleFound ){
- throw new RuntimeException("Test Failed. Unable to determine title's size.");
- }
- //--------------------------------
- // it is sufficient to get maximized Frame only once.
- Point tempMousePosition;
- framePosition = frame.getLocationOnScreen();
+ });
+ }
+
+ public void doMaximizeFrameTest() throws Exception {
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ Point framePosition = frame.getLocationOnScreen();
+
+ tempMousePosition = new Point(framePosition.x
+ + frame.getWidth() / 2, framePosition.y
+ + titleComponent.getHeight() / 2);
+ }
+ });
+
try {
- robot = new Robot();
- tempMousePosition = new Point(framePosition.x +
- frame.getWidth()/2,
- framePosition.y +
- titleComponent.getHeight()/2);
+ Robot robot = new Robot();
robot.mouseMove(tempMousePosition.x, tempMousePosition.y);
- for (int iteration=0; iteration < ITERATIONS_COUNT; iteration++){
+ robot.waitForIdle();
+
+ for (int iteration = 0; iteration < ITERATIONS_COUNT; iteration++) {
robot.mousePress(InputEvent.BUTTON1_MASK);
- gcBounds =
- GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getConfigurations()[0].getBounds();
- //Moving a mouse pointer less than a few pixels
- //leads to rising a double click event.
- //We have to use exceeded the AWT_MULTICLICK_SMUDGE
- //const value (which is 4 by default on GNOME) to test that.
+ robot.waitForIdle();
+
+ // Moving a mouse pointer less than a few pixels
+ // leads to rising a double click event.
+ // We have to use exceeded the AWT_MULTICLICK_SMUDGE
+ // const value (which is 4 by default on GNOME) to test that.
tempMousePosition.x += 5;
robot.mouseMove(tempMousePosition.x, tempMousePosition.y);
- robot.delay(70);
+ robot.waitForIdle();
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- if ( frame.getExtendedState() != 0 ){
- throw new RuntimeException ("Test failed. JFrame was maximized. ExtendedState is : "+frame.getExtendedState());
+ robot.waitForIdle();
+
+ if (frame.getExtendedState() != 0) {
+ dispose();
+ throw new RuntimeException("Test failed. JFrame was "
+ + "maximized. ExtendedState is : "
+ + frame.getExtendedState());
}
- robot.delay(500);
- } //for iteration
+ }
+ } catch (AWTException e) {
+ dispose();
+ throw new RuntimeException("Test Failed. AWTException thrown.");
+ }
+ System.out.println("Test passed.");
+ }
- }catch(AWTException e) {
- throw new RuntimeException("Test Failed. AWTException thrown.");
+ private void dispose() throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ if (null != frame) {
+ frame.dispose();
+ }
}
- System.out.println("Test passed.");
- }// start()
-}// class
+ });
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ MaximizedFrameTest maximizedFrameTest = new MaximizedFrameTest();
+ maximizedFrameTest.init();
+ maximizedFrameTest.getTitleComponent();
+ maximizedFrameTest.doMaximizeFrameTest();
+ maximizedFrameTest.dispose();
+ }
+}
--- a/jdk/test/java/awt/TextArea/TextAreaEditing/TextAreaEditing.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TextArea/TextAreaEditing/TextAreaEditing.java Mon Dec 14 10:36:12 2015 -0800
@@ -23,16 +23,23 @@
/*
@test
- @bug 8040322
+ @bug 8040322 8060137
+ @library ../../regtesthelpers
+ @build Util
@summary Test TextArea APIs replaceRange, insert, append & setText
@run main TextAreaEditing
*/
import java.awt.Frame;
+import java.awt.Robot;
import java.awt.TextArea;
+import java.awt.AWTException;
+import java.awt.event.KeyEvent;
+import test.java.awt.regtesthelpers.Util;
public class TextAreaEditing {
+ final static Robot robot = Util.createRobot();
private int testFailCount;
private boolean isTestFail;
private StringBuilder testFailMessage;
@@ -61,6 +68,7 @@
textArea.testReplaceRange();
textArea.testInsert();
textArea.testAppend();
+ textArea.testSetText();
textArea.checkFailures();
textArea.dispose();
}
@@ -119,6 +127,24 @@
checkTest("");
}
+ private void testSetText() {
+ textArea.setText(null);
+ textArea.requestFocus();
+ Util.clickOnComp(textArea, robot);
+ Util.waitForIdle(robot);
+ robot.keyPress(KeyEvent.VK_A);
+ robot.delay(5);
+ robot.keyRelease(KeyEvent.VK_A);
+ Util.waitForIdle(robot);
+ textArea.setText(null);
+ checkTest("");
+ textArea.setText("CaseSensitive");
+ checkTest("CaseSensitive");
+ textArea.setText("caseSensitive");
+ checkTest("caseSensitive");
+
+ }
+
private void checkTest(String str) {
if (str != null && !str.equals(textArea.getText())) {
testFailMessage.append("TestFail line : ");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/TextField/EOLTest/EOLTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2015, 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 8055197 7186036
+ @summary TextField should replace EOL character with space character
+ @run main EOLTest
+ */
+
+import java.awt.Frame;
+import java.awt.TextField;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+
+public class EOLTest {
+
+ private Frame mainFrame;
+ private TextField textField;
+ private String testStrEOL;
+ private boolean isTestFail;
+ private int testFailCount;
+ StringBuilder testFailMessage;
+ private String expectedString = "Row1 Row2 Row3";
+
+ public EOLTest() {
+ mainFrame = new Frame();
+ mainFrame.setSize(200, 200);
+ mainFrame.setVisible(true);
+ testFailMessage = new StringBuilder();
+ testStrEOL = "Row1" + System.lineSeparator() + "Row2\nRow3";
+ }
+
+ private void testConstructor1() {
+ textField = new TextField(testStrEOL);
+ textField.setSize(200, 100);
+ mainFrame.add(textField);
+ checkTest();
+ mainFrame.remove(textField);
+ }
+
+ private void testConstructor2() {
+ textField = new TextField(30);
+ textField.setSize(200, 100);
+ mainFrame.add(textField);
+ textField.setText(testStrEOL);
+ checkTest();
+ mainFrame.remove(textField);
+ }
+
+ private void testConstructor3() {
+ textField = new TextField(testStrEOL, 30);
+ textField.setSize(200, 100);
+ mainFrame.add(textField);
+ checkTest();
+ mainFrame.remove(textField);
+ }
+
+ private void testSetText() {
+ textField = new TextField();
+ textField.setSize(200, 100);
+ textField.setText(testStrEOL);
+ mainFrame.add(textField);
+ checkTest();
+ mainFrame.remove(textField);
+ }
+
+ private void testDeserialization() {
+ TextField textFieldToSerialize = new TextField(testStrEOL);
+ textFieldToSerialize.setSize(200, 100);
+ mainFrame.add(textFieldToSerialize);
+ try {
+ // Serialize TextField object "textFieldToSerialize".
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutput outStream = new ObjectOutputStream(baos);
+ outStream.writeObject(textFieldToSerialize);
+
+ // Search the text variable data through serialized object stream.
+ byte[] streamedBytes = baos.toByteArray();
+ int foundLoc = 0;
+ for (int i = 0; i < streamedBytes.length; ++i) {
+ if (streamedBytes[i] == expectedString.charAt(0)) {
+ foundLoc = i;
+ int j = 1;
+ for (; j < expectedString.length(); ++j) {
+ if (streamedBytes[i+j] != expectedString.charAt(j)) {
+ break;
+ }
+ }
+ if (j == expectedString.length()) {
+ break;
+ }
+ }
+ foundLoc = -1;
+ }
+
+ if (foundLoc == -1) {
+ // Could not find text data in serialized object stream.
+ throw new Exception("Could not find text data in serialized "
+ + "object stream.");
+ }
+ // Replace space character from serialized stream with
+ // EOL character for testing de-serialization.
+ String EOLChar = System.lineSeparator();
+ String newExpectedString = "";
+ for (int i = foundLoc, j = 0; j < expectedString.length(); ++i, ++j) {
+ newExpectedString += (char)(streamedBytes[i]);
+ if (streamedBytes[i] == ' ') {
+ int k = 0;
+ for (; k < EOLChar.length(); ++k) {
+ streamedBytes[i + k] = (byte) EOLChar.charAt(k);
+ }
+ i += k-1;
+ j += k-1;
+ }
+ }
+ // New line character varies with platform,
+ // ex. For windows '\r\n', for linux '\n'.
+ // While replacing space from serialized object stream, the length
+ // of EOL character will affect the expected string as well.
+ expectedString = newExpectedString;
+
+ // De-serialize TextField object stream.
+ ByteArrayInputStream bais = new ByteArrayInputStream(streamedBytes);
+ ObjectInput inStream = new ObjectInputStream(bais);
+ textField = (TextField) inStream.readObject();
+ } catch (Exception ex) {
+ // Serialization or De-serialization failed.
+ // Create textField with empty string to show failure.
+ ex.printStackTrace();
+ textField = new TextField();
+ }
+
+ checkTest();
+ mainFrame.remove(textFieldToSerialize);
+ }
+
+ private void checkTest() {
+ if (!textField.getText().equals(expectedString)) {
+ testFailMessage.append("TestFail line : ");
+ testFailMessage.append(Thread.currentThread().getStackTrace()[2].
+ getLineNumber());
+ testFailMessage.append(" TextField.getText() : \"");
+ testFailMessage.append(textField.getText());
+ testFailMessage.append("\" does not match expected string : \"");
+ testFailMessage.append(expectedString).append("\"");
+ testFailMessage.append(System.getProperty("line.separator"));
+ testFailCount++;
+ isTestFail = true;
+ }
+ }
+
+ private void checkFailures() {
+ if (isTestFail) {
+ testFailMessage.insert(0, "Test Fail count : " + testFailCount
+ + System.getProperty("line.separator"));
+ dispose();
+ throw new RuntimeException(testFailMessage.toString());
+ }
+ }
+
+ private void dispose() {
+ if (mainFrame != null) {
+ mainFrame.dispose();
+ }
+ }
+
+ public static void main(String[] args) {
+ EOLTest testEOL = new EOLTest();
+ testEOL.testConstructor1();
+ testEOL.testConstructor2();
+ testEOL.testConstructor3();
+ testEOL.testSetText();
+ testEOL.testDeserialization();
+ testEOL.checkFailures();
+ testEOL.dispose();
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/TextField/TextFieldEditing/TextFieldEditing.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2015, 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 8060137
+ @library ../../regtesthelpers
+ @build Util
+ @summary Test TextField setText API
+ @run main TextFieldEditing
+ */
+
+import java.awt.Frame;
+import java.awt.Robot;
+import java.awt.TextField;
+import java.awt.AWTException;
+import java.awt.event.KeyEvent;
+import test.java.awt.regtesthelpers.Util;
+
+public class TextFieldEditing {
+
+ final static Robot robot = Util.createRobot();
+ private int testFailCount;
+ private boolean isTestFail;
+ private StringBuilder testFailMessage;
+
+ private Frame mainFrame;
+ private TextField textField;
+
+ private TextFieldEditing() {
+ testFailMessage = new StringBuilder();
+ mainFrame = new Frame();
+ mainFrame.setSize(200, 200);
+
+ textField = new TextField();
+ mainFrame.add(textField);
+ mainFrame.setVisible(true);
+ }
+
+ private void dispose() {
+ if (mainFrame != null) {
+ mainFrame.dispose();
+ }
+ }
+
+ public static void main(String[] s) {
+ TextFieldEditing textField = new TextFieldEditing();
+ textField.testSetText();
+ textField.checkFailures();
+ textField.dispose();
+ }
+
+ private void testSetText() {
+ textField.setText(null);
+ textField.requestFocus();
+ Util.clickOnComp(textField, robot);
+ Util.waitForIdle(robot);
+ robot.keyPress(KeyEvent.VK_A);
+ robot.delay(5);
+ robot.keyRelease(KeyEvent.VK_A);
+ Util.waitForIdle(robot);
+ textField.setText(null);
+ checkTest("");
+ textField.setText("CaseSensitive");
+ checkTest("CaseSensitive");
+ textField.setText("caseSensitive");
+ checkTest("caseSensitive");
+ }
+
+ private void checkTest(String str) {
+ if (str != null && !str.equals(textField.getText())) {
+ testFailMessage.append("TestFail line : ");
+ testFailMessage.append(Thread.currentThread().getStackTrace()[2].
+ getLineNumber());
+ testFailMessage.append(" TextField string : \"");
+ testFailMessage.append(textField.getText());
+ testFailMessage.append("\" does not match expected string : \"");
+ testFailMessage.append(str).append("\"");
+ testFailMessage.append(System.getProperty("line.separator"));
+ testFailCount++;
+ isTestFail = true;
+ }
+ }
+
+ private void checkFailures() {
+ if (isTestFail) {
+ testFailMessage.insert(0, "Test Fail count : " + testFailCount
+ + System.getProperty("line.separator"));
+ dispose();
+ throw new RuntimeException(testFailMessage.toString());
+ }
+ }
+}
--- a/jdk/test/java/awt/TrayIcon/ActionCommand/ActionCommand.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/ActionCommand/ActionCommand.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -59,8 +59,11 @@
"and rerun test.");
} else if (System.getProperty("os.name").toLowerCase().startsWith("mac")){
isMacOS = true;
+ } else if (SystemTrayIconHelper.isOel7()) {
+ System.out.println("OEL 7 doesn't support double click in " +
+ "systray. Skipped");
+ return;
}
-
new ActionCommand().doTest();
}
}
--- a/jdk/test/java/awt/TrayIcon/ActionEventMask/ActionEventMask.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/ActionEventMask/ActionEventMask.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -66,6 +66,10 @@
} else {
if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
isMacOS = true;
+ } else if (SystemTrayIconHelper.isOel7()) {
+ System.out.println("OEL 7 doesn't support double click in " +
+ "systray. Skipped");
+ return;
}
new ActionEventMask().doTest();
}
--- a/jdk/test/java/awt/TrayIcon/ModalityTest/ModalityTest.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/ModalityTest/ModalityTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -35,6 +35,7 @@
*/
public class ModalityTest {
+ private static boolean isOEL7;
TrayIcon icon;
ExtendedRobot robot;
Dialog d;
@@ -80,7 +81,7 @@
"\"Always show all icons and notifications on the taskbar\" true " +
"to avoid this problem. Or change behavior only for Java SE tray " +
"icon and rerun test.");
-
+ isOEL7 = SystemTrayIconHelper.isOel7();
new ModalityTest().doTest();
}
}
@@ -225,6 +226,12 @@
Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon);
if (iconPosition == null)
throw new RuntimeException("Unable to find the icon location!");
+ if (isOEL7) {
+ // close tray
+ robot.mouseMove(100,100);
+ robot.click(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle(2000);
+ }
if (! d.isVisible())
throw new RuntimeException("FAIL: The modal dialog is not yet visible");
@@ -232,27 +239,35 @@
robot.mouseMove(iconPosition.x, iconPosition.y);
robot.waitForIdle(2000);
- SystemTrayIconHelper.doubleClick(robot);
+ if(!isOEL7) {
+ SystemTrayIconHelper.doubleClick(robot);
- if (! actionPerformed) {
- synchronized (actionLock) {
- try {
- actionLock.wait(3000);
- } catch (Exception e) {
+ if (!actionPerformed) {
+ synchronized (actionLock) {
+ try {
+ actionLock.wait(3000);
+ } catch (Exception e) {
+ }
}
}
+ if (!actionPerformed)
+ throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked");
}
- if (! actionPerformed)
- throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked");
for (int i = 0; i < buttonTypes.length; i++) {
mousePressed = false;
- robot.mousePress(buttonTypes[i]);
+ if(isOEL7) {
+ SystemTrayIconHelper.openTrayIfNeeded(robot);
+ robot.mouseMove(iconPosition.x, iconPosition.y);
+ robot.click(buttonTypes[i]);
+ } else {
+ robot.mousePress(buttonTypes[i]);
+ }
if (! mousePressed) {
synchronized (pressLock) {
try {
- pressLock.wait(3000);
+ pressLock.wait(6000);
} catch (Exception e) {
}
}
@@ -264,12 +279,18 @@
mouseReleased = false;
mouseClicked = false;
- robot.mouseRelease(buttonTypes[i]);
+ if(isOEL7) {
+ SystemTrayIconHelper.openTrayIfNeeded(robot);
+ robot.mouseMove(iconPosition.x, iconPosition.y);
+ robot.click(buttonTypes[i]);
+ } else {
+ robot.mouseRelease(buttonTypes[i]);
+ }
if (! mouseReleased) {
synchronized (releaseLock) {
try {
- releaseLock.wait(3000);
+ releaseLock.wait(6000);
} catch (Exception e) {
}
}
@@ -281,7 +302,7 @@
if (! mouseClicked) {
synchronized (clickLock) {
try {
- clickLock.wait(3000);
+ clickLock.wait(6000);
} catch (Exception e) {
}
}
@@ -290,13 +311,14 @@
throw new RuntimeException("FAIL: mouseClicked not triggered when " +
buttonNames[i] + " pressed & released");
}
+ if (!isOEL7) {
+ mouseMoved = false;
+ robot.mouseMove(iconPosition.x, iconPosition.y);
+ robot.glide(iconPosition.x + 100, iconPosition.y);
- mouseMoved = false;
- robot.mouseMove(iconPosition.x, iconPosition.y);
- robot.glide(iconPosition.x + 100, iconPosition.y);
-
- if (! mouseMoved)
- if (! SystemTrayIconHelper.skip(0) )
- throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon");
+ if (!mouseMoved)
+ if (!SystemTrayIconHelper.skip(0))
+ throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon");
+ }
}
}
--- a/jdk/test/java/awt/TrayIcon/MouseEventMask/MouseEventMaskTest.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/MouseEventMask/MouseEventMaskTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -71,6 +71,8 @@
"\"Always show all icons and notifications on the taskbar\" true " +
"to avoid this problem. Or change behavior only for Java SE tray " +
"icon and rerun test.");
+ } else if (SystemTrayIconHelper.isOel7()) {
+ return;
}
new MouseEventMaskTest().doTest();
}
--- a/jdk/test/java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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,7 @@
* @summary Check for mouseMoved event for java.awt.TrayIcon
* @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
* @library ../../../../lib/testlibrary
- * @build ExtendedRobot
+ * @build ExtendedRobot SystemTrayIconHelper
* @run main MouseMovedTest
*/
@@ -39,6 +39,14 @@
static volatile boolean moved;
public static void main(String[] args) throws Exception {
+ if (!SystemTray.isSupported()) {
+ return;
+ }
+
+ if (SystemTrayIconHelper.isOel7()) {
+ return;
+ }
+
moved = false;
TrayIcon icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Test icon");
--- a/jdk/test/java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/FunctionalityCheck.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/FunctionalityCheck.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -51,6 +51,7 @@
boolean mouseReleased = false;
boolean mouseClicked = false;
boolean mouseMoved = false;
+ static boolean isOEL7;
static final int[] buttonTypes = {
InputEvent.BUTTON1_MASK,
@@ -69,6 +70,7 @@
System.out.println("SystemTray not supported on the platform under test. " +
"Marking the test passed");
} else {
+ isOEL7 = SystemTrayIconHelper.isOel7();
new FunctionalityCheck().doTest();
}
}
@@ -188,31 +190,44 @@
Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon);
if (iconPosition == null)
throw new RuntimeException("Unable to find the icon location!");
+ if (isOEL7) {
+ // close tray
+ robot.mouseMove(100,100);
+ robot.click(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle(2000);
+ }
robot.mouseMove(iconPosition.x, iconPosition.y);
- robot.waitForIdle(2000);
-
- SystemTrayIconHelper.doubleClick(robot);
+ robot.waitForIdle();
+ if(!isOEL7) {
+ SystemTrayIconHelper.doubleClick(robot);
- if (! actionPerformed) {
- synchronized (actionLock) {
- try {
- actionLock.wait(3000);
- } catch (Exception e) {
+ if (!actionPerformed) {
+ synchronized (actionLock) {
+ try {
+ actionLock.wait(3000);
+ } catch (Exception e) {
+ }
}
}
+ if (!actionPerformed)
+ throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked");
}
- if (! actionPerformed)
- throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked");
for (int i = 0; i < buttonTypes.length; i++) {
mousePressed = false;
- robot.mousePress(buttonTypes[i]);
+ if(isOEL7) {
+ SystemTrayIconHelper.openTrayIfNeeded(robot);
+ robot.mouseMove(iconPosition.x, iconPosition.y);
+ robot.click(buttonTypes[i]);
+ } else {
+ robot.mousePress(buttonTypes[i]);
+ }
if (! mousePressed) {
synchronized (pressLock) {
try {
- pressLock.wait(3000);
+ pressLock.wait(6000);
} catch (Exception e) {
}
}
@@ -224,12 +239,17 @@
mouseReleased = false;
mouseClicked = false;
- robot.mouseRelease(buttonTypes[i]);
-
+ if(isOEL7) {
+ SystemTrayIconHelper.openTrayIfNeeded(robot);
+ robot.mouseMove(iconPosition.x, iconPosition.y);
+ robot.click(buttonTypes[i]);
+ } else {
+ robot.mouseRelease(buttonTypes[i]);
+ }
if (! mouseReleased) {
synchronized (releaseLock) {
try {
- releaseLock.wait(3000);
+ releaseLock.wait(6000);
} catch (Exception e) {
}
}
@@ -242,7 +262,7 @@
if (! mouseClicked) {
synchronized (clickLock) {
try {
- clickLock.wait(3000);
+ clickLock.wait(6000);
} catch (Exception e) {
}
}
@@ -251,13 +271,14 @@
throw new RuntimeException("FAIL: mouseClicked not triggered when " +
buttonNames[i] + " pressed & released");
}
+ if(!isOEL7) {
+ mouseMoved = false;
+ robot.mouseMove(iconPosition.x + 100, iconPosition.y);
+ robot.glide(iconPosition.x, iconPosition.y);
- mouseMoved = false;
- robot.mouseMove(iconPosition.x + 100, iconPosition.y);
- robot.glide(iconPosition.x, iconPosition.y);
-
- if (! mouseMoved)
- if (! SystemTrayIconHelper.skip(0) )
- throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon");
+ if (!mouseMoved)
+ if (!SystemTrayIconHelper.skip(0))
+ throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon");
+ }
}
}
--- a/jdk/test/java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/tray.policy Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/tray.policy Mon Dec 14 10:36:12 2015 -0800
@@ -5,6 +5,7 @@
permission java.util.PropertyPermission "resultsDir", "read";
permission java.util.PropertyPermission "user.home", "read";
permission java.util.PropertyPermission "os.name", "read";
+ permission java.util.PropertyPermission "os.version", "read";
permission java.awt.AWTPermission "accessEventQueue";
permission java.lang.RuntimePermission "setIO";
permission java.lang.RuntimePermission "accessDeclaredMembers";
@@ -17,5 +18,6 @@
permission java.util.PropertyPermission "java.class.path", "read";
permission java.awt.AWTPermission "readDisplayPixels";
permission java.awt.AWTPermission "watchMousePointer";
+
};
--- a/jdk/test/java/awt/TrayIcon/SystemTrayIconHelper.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/SystemTrayIconHelper.java Mon Dec 14 10:36:12 2015 -0800
@@ -66,7 +66,9 @@
for (int x = (int) (screenSize.getWidth()-width); x > 0; x--) {
for (int y = (int) (screenSize.getHeight()-height); y > (screenSize.getHeight()-50); y--) {
if (imagesEquals(((BufferedImage)icon.getImage()).getSubimage(0, 0, width, height), screen.getSubimage(x, y, width, height))) {
- return new Point(x+5, y+5);
+ Point point = new Point(x + 5, y + 5);
+ System.out.println("Icon location " + point);
+ return point;
}
}
}
@@ -91,6 +93,7 @@
point2d = (Point2D)m_getLocation.invoke(peer, new Object[]{model});
Point po = new Point((int)(point2d.getX()), (int)(point2d.getY()));
po.translate(10, -5);
+ System.out.println("Icon location " + po);
return po;
}catch(Exception e) {
e.printStackTrace();
@@ -101,12 +104,15 @@
// sun.awt.X11.XTrayIconPeer
Field f_peer = getField(java.awt.TrayIcon.class, "peer");
+ SystemTrayIconHelper.openTrayIfNeeded(robot);
+
Object peer = f_peer.get(icon);
Method m_getLOS = peer.getClass().getDeclaredMethod(
"getLocationOnScreen", new Class[]{});
m_getLOS.setAccessible(true);
Point point = (Point)m_getLOS.invoke(peer, new Object[]{});
point.translate(5, 5);
+ System.out.println("Icon location " + point);
return point;
} catch (Exception e) {
e.printStackTrace();
@@ -169,4 +175,38 @@
}
return false;
}
+
+ public static boolean openTrayIfNeeded(Robot robot) {
+ String sysv = System.getProperty("os.version");
+ System.out.println("System version is " + sysv);
+ //Additional step to raise the system try in Gnome 3 in OEL 7
+ if(isOel7()) {
+ System.out.println("OEL 7 detected");
+ GraphicsConfiguration gc = GraphicsEnvironment.
+ getLocalGraphicsEnvironment().getDefaultScreenDevice().
+ getDefaultConfiguration();
+ Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
+ if(insets.bottom > 0) {
+ Dimension screenSize = Toolkit.getDefaultToolkit()
+ .getScreenSize();
+ robot.mouseMove(screenSize.width - insets.bottom / 2,
+ screenSize.height - insets.bottom / 2);
+ robot.delay(50);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(50);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ robot.delay(1000);
+ System.out.println("Tray is opened");
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean isOel7() {
+ return System.getProperty("os.name").toLowerCase()
+ .contains("linux") && System.getProperty("os.version")
+ .toLowerCase().contains("el7");
+ }
}
--- a/jdk/test/java/awt/TrayIcon/TrayIconEventModifiers/TrayIconEventModifiersTest.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/TrayIconEventModifiers/TrayIconEventModifiersTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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,12 @@
};
}
+ if (SystemTrayIconHelper.isOel7()) {
+ System.out.println("OEL 7 doesn't support click modifiers in " +
+ "systray. Skipped");
+ return;
+ }
+
new TrayIconEventModifiersTest().doTest();
}
}
--- a/jdk/test/java/awt/TrayIcon/TrayIconEvents/TrayIconEventsTest.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/TrayIconEvents/TrayIconEventsTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -37,6 +37,7 @@
public class TrayIconEventsTest {
+ private static boolean isOEL7;
TrayIcon icon;
ExtendedRobot robot;
@@ -77,6 +78,7 @@
"\"Always show all icons and notifications on the taskbar\" true " +
"to avoid this problem. Or change behavior only for Java SE " +
"tray icon.");
+ isOEL7 = SystemTrayIconHelper.isOel7();
new TrayIconEventsTest().doTest();
}
}
@@ -195,31 +197,44 @@
Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon);
if (iconPosition == null)
throw new RuntimeException("Unable to find the icon location!");
+ if (isOEL7) {
+ // close tray
+ robot.mouseMove(100,100);
+ robot.click(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle(2000);
+ }
robot.mouseMove(iconPosition.x, iconPosition.y);
- robot.waitForIdle(2000);
-
- SystemTrayIconHelper.doubleClick(robot);
+ robot.waitForIdle();
+ if(!isOEL7) {
+ SystemTrayIconHelper.doubleClick(robot);
- if (! actionPerformed) {
- synchronized (actionLock) {
- try {
- actionLock.wait(10000);
- } catch (Exception e) {
+ if (!actionPerformed) {
+ synchronized (actionLock) {
+ try {
+ actionLock.wait(10000);
+ } catch (Exception e) {
+ }
}
}
+ if (!actionPerformed)
+ throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked");
}
- if (! actionPerformed)
- throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked");
for (int i = 0; i < buttonTypes.length; i++) {
mousePressed = false;
- robot.mousePress(buttonTypes[i]);
+ if(isOEL7) {
+ SystemTrayIconHelper.openTrayIfNeeded(robot);
+ robot.mouseMove(iconPosition.x, iconPosition.y);
+ robot.click(buttonTypes[i]);
+ } else {
+ robot.mousePress(buttonTypes[i]);
+ }
if (! mousePressed) {
synchronized (pressLock) {
try {
- pressLock.wait(3000);
+ pressLock.wait(6000);
} catch (Exception e) {
}
}
@@ -231,12 +246,18 @@
mouseReleased = false;
mouseClicked = false;
- robot.mouseRelease(buttonTypes[i]);
+ if(isOEL7) {
+ SystemTrayIconHelper.openTrayIfNeeded(robot);
+ robot.mouseMove(iconPosition.x, iconPosition.y);
+ robot.click(buttonTypes[i]);
+ } else {
+ robot.mouseRelease(buttonTypes[i]);
+ }
if (! mouseReleased) {
synchronized (releaseLock) {
try {
- releaseLock.wait(3000);
+ releaseLock.wait(6000);
} catch (Exception e) {
}
}
@@ -248,7 +269,7 @@
if (! mouseClicked) {
synchronized (clickLock) {
try {
- clickLock.wait(3000);
+ clickLock.wait(6000);
} catch (Exception e) {
}
}
@@ -258,12 +279,14 @@
buttonNames[i] + " pressed & released");
}
- mouseMoved = false;
- robot.mouseMove(iconPosition.x + 100, iconPosition.y);
- robot.glide(iconPosition.x, iconPosition.y);
+ if (!isOEL7) {
+ mouseMoved = false;
+ robot.mouseMove(iconPosition.x + 100, iconPosition.y);
+ robot.glide(iconPosition.x, iconPosition.y);
- if (! mouseMoved)
- if (! SystemTrayIconHelper.skip(0) )
- throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon");
+ if (!mouseMoved)
+ if (!SystemTrayIconHelper.skip(0))
+ throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon");
+ }
}
}
--- a/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -66,6 +66,10 @@
} else {
if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
isMacOS = true;
+ } else if (SystemTrayIconHelper.isOel7()) {
+ System.out.println("OEL 7 doesn't support double click in " +
+ "systray. Skipped");
+ return;
}
new TrayIconMouseTest().doTest();
}
@@ -108,7 +112,7 @@
for (int i = 0; i < buttonTypes.length; i++) {
actionPerformed = false;
robot.click(buttonTypes[i]);
- robot.waitForIdle(2000);
+ robot.waitForIdle(6000);
if (isMacOS && actionPerformed && i == 2) {
@@ -155,7 +159,7 @@
if (! actionPerformed) {
synchronized (actionLock) {
try {
- actionLock.wait(3000);
+ actionLock.wait(6000);
} catch (Exception e) {
}
}
--- a/jdk/test/java/awt/TrayIcon/TrayIconPopup/TrayIconPopupTest.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/java/awt/TrayIcon/TrayIconPopup/TrayIconPopupTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -127,7 +127,7 @@
robot.mousePress(InputEvent.BUTTON3_MASK);
robot.delay(50);
robot.mouseRelease(InputEvent.BUTTON3_MASK);
- robot.delay(1000);
+ robot.delay(6000);
robot.mouseMove(window.getLocation().x + 10, window.getLocation().y + 10);
robot.mousePress(InputEvent.BUTTON3_MASK);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/font/GlyphVector/TestStandardGlyphVectorBug.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+import java.awt.Font;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+
+/**
+ * @test
+ * @bug 7160052
+ * @run main TestStandardGlyphVectorBug
+ * @summary GlyphVector.setGlyphPosition should not throw an exception on valid input
+ */
+public class TestStandardGlyphVectorBug
+{
+ public static void main(String[] args)
+ {
+ Font defaultFont = new Font(null);
+ FontRenderContext defaultFrc = new FontRenderContext(new AffineTransform(),
+ true, true);
+ GlyphVector gv = defaultFont.createGlyphVector(defaultFrc, "test");
+
+ //this causes the bounds to be cached
+ //which is necessary to trigger the bug
+ gv.getGlyphLogicalBounds(0);
+
+ //this correctly gets the position of the overall advance
+ Point2D glyphPosition = gv.getGlyphPosition(gv.getNumGlyphs());
+
+ // this sets the position of the overall advance,
+ // but also incorrectly tries to clear the bounds cache
+ // of a specific glyph indexed by the glyphIndex parameter
+ // even if the glyphIndex represents the overall advance
+ // (i.e. if glyphIndex == getNumGlyphs())
+ gv.setGlyphPosition(gv.getNumGlyphs(), glyphPosition);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/VolatileImage/VolatileImageBug.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.image.VolatileImage;
+
+/**
+ * @test
+ * @bug 8140530
+ * @run main VolatileImageBug
+ * @summary Creating volatileimage(0,0) should throw IAE
+ */
+public class VolatileImageBug {
+ public static void main(String[] args) {
+
+ boolean iaeThrown = false;
+ GraphicsEnvironment ge = GraphicsEnvironment.
+ getLocalGraphicsEnvironment();
+ GraphicsConfiguration gc = ge.getDefaultScreenDevice().
+ getDefaultConfiguration();
+ try {
+ VolatileImage volatileImage = gc.createCompatibleVolatileImage(0, 0);
+ } catch (IllegalArgumentException iae) {
+ iaeThrown = true;
+ }
+ if (!iaeThrown) {
+ throw new RuntimeException ("IllegalArgumentException not thrown " +
+ "for createCompatibleVolatileImage(0,0)");
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/javax_swing_JComponent.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+import javax.swing.JComponent;
+import javax.swing.plaf.ComponentUI;
+
+/*
+ * @test
+ * @bug 8131754
+ * @summary Tests JComponent encoding
+ */
+public final class javax_swing_JComponent extends AbstractTest<JComponent> {
+
+ public static void main(final String[] args) {
+ new javax_swing_JComponent().test(true);
+ }
+
+ protected JComponent getObject() {
+ return new SimpleJComponent();
+ }
+
+ protected JComponent getAnotherObject() {
+ return new CustomJComponent();
+ }
+
+ public static final class SimpleJComponent extends JComponent {
+
+ }
+
+ public static final class CustomJComponent extends JComponent {
+
+ public CustomJComponent() {
+ ui = new CustomUI();
+ }
+
+ @Override
+ public ComponentUI getUI() {
+ return ui;
+ }
+
+ @Override
+ public void setUI(final ComponentUI newUI) {
+ ui = newUI;
+ }
+ }
+
+ public static final class CustomUI extends ComponentUI {
+
+ public boolean getFlag() {
+ throw new Error();
+ }
+
+ public void setFlag(final boolean flag) {
+ throw new Error();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/jpeg/JpegImageColorSpaceTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015, 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 8041501
+ * @summary Test verifies if there is no JFIF & EXIF header
+ * and sampling factor is same of JPEG image, then
+ * imageIO should not override colorspace determined
+ * in IJG library.
+ * @run main JpegImageColorSpaceTest
+ */
+
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import javax.imageio.ImageIO;
+
+public class JpegImageColorSpaceTest {
+
+ public static void main(String args[]) throws Exception {
+
+ String fileName = "nomarkers.jpg";
+ String sep = System.getProperty("file.separator");
+ String dir = System.getProperty("test.src", ".");
+ String filePath = dir+sep+fileName;
+ System.out.println("Test file: " + filePath);
+ File imageFile = new File(filePath);
+
+ BufferedImage bufferedImage = ImageIO.read(imageFile);
+ int imageWidth = bufferedImage.getWidth();
+ int imageHeight = bufferedImage.getHeight();
+
+ for (int i = 0; i < imageWidth; i++) {
+ for(int j = 0; j < imageHeight; j++) {
+ /*
+ * Since image is white we check individual pixel values from
+ * BufferedImage to verify if ImageIO.read() is done with proper
+ * color space or not.
+ */
+ if (bufferedImage.getRGB(i, j) != Color.white.getRGB()) {
+ // color space is not proper
+ throw new RuntimeException("ColorSpace is not determined "
+ + "properly by ImageIO");
+ }
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/jpeg/JpegMetadataColorSpaceTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015, 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 8074967
+ * @summary Test verifies if there is no JFIF & EXIF header
+ * and sampling factor is same of JPEG image, then
+ * JPEG colorspace should not be RGB.
+ * @run main JpegMetadataColorSpaceTest
+ */
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.metadata.IIOMetadataFormatImpl;
+import javax.imageio.metadata.IIOMetadataNode;
+import javax.imageio.stream.ImageInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+
+public class JpegMetadataColorSpaceTest {
+ public static void main(String[] args) throws IOException {
+ String fileName = "nomarkers.jpg";
+ String sep = System.getProperty("file.separator");
+ String dir = System.getProperty("test.src", ".");
+ String filePath = dir+sep+fileName;
+ System.out.println("Test file: " + filePath);
+ File file = new File(filePath);
+ ImageInputStream stream = ImageIO.createImageInputStream(file);
+ Iterator<ImageReader> readers = ImageIO.getImageReaders(stream);
+
+ if(readers.hasNext()) {
+ ImageReader reader = readers.next();
+ reader.setInput(stream);
+ IIOMetadata metadata = reader.getImageMetadata(0);
+
+ IIOMetadataNode standardTree = (IIOMetadataNode)
+ metadata.getAsTree
+ (IIOMetadataFormatImpl.standardMetadataFormatName);
+ IIOMetadataNode colorSpaceType = (IIOMetadataNode)
+ standardTree.getElementsByTagName("ColorSpaceType").item(0);
+ String colorSpaceName = colorSpaceType.getAttribute("name");
+ if(colorSpaceName.equals("RGB"))
+ throw new RuntimeException("Identified incorrect ColorSpace");
+ }
+ }
+}
Binary file jdk/test/javax/imageio/plugins/jpeg/nomarkers.jpg has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/png/PngForceStopWritingTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2015, 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 6967419
+ * @summary Test verifies that when we force stop PNG writing to
+ * ImageOutputStream, it should not cause IndexOutOfBoundException.
+ * @run main PngForceStopWritingTest
+ */
+
+import java.awt.Color;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import javax.imageio.ImageIO;
+import javax.imageio.stream.ImageOutputStream;
+
+public class PngForceStopWritingTest {
+
+ public static void main(String[] args) throws IOException {
+
+ OutputStream outputStream = new NullOutputStream();
+ ImageOutputStream imageOutputStream =
+ ImageIO.createImageOutputStream(outputStream);
+ try {
+ ImageIO.write(createImage(2048),"PNG", imageOutputStream);
+ } catch (IOException e) {
+ imageOutputStream.close();
+ }
+ }
+
+ private static BufferedImage createImage(int size) {
+
+ BufferedImage image = new
+ BufferedImage(size, size, BufferedImage.TYPE_3BYTE_BGR);
+ Graphics2D g = image.createGraphics();
+ g.setPaint(new GradientPaint(0, 0, Color.blue, size, size, Color.red));
+ g.fillRect(0, 0, size, size);
+ g.dispose();
+ return image;
+ }
+
+ static class NullOutputStream extends OutputStream {
+ long count = 0;
+ @Override
+ public void write(int b) throws IOException {
+ count++;
+ if (count > 30000L) {
+ throw new IOException("Force stop image writing");
+ }
+ }
+ }
+}
--- a/jdk/test/javax/imageio/plugins/shared/WriteAfterAbort.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/javax/imageio/plugins/shared/WriteAfterAbort.java Mon Dec 14 10:36:12 2015 -0800
@@ -130,13 +130,25 @@
ImageWriterSpi.class, provider -> true, true);
// Validates all supported ImageWriters
+ int numFailures = 0;
while (iter.hasNext()) {
final WriteAfterAbort writeAfterAbort = new WriteAfterAbort();
final ImageWriter writer = iter.next().createWriterInstance();
System.out.println("ImageWriter = " + writer);
- writeAfterAbort.test(writer);
+ try {
+ writeAfterAbort.test(writer);
+ } catch (Exception e) {
+ System.err.println("Test failed for \""
+ + writer.getOriginatingProvider().getFormatNames()[0]
+ + "\" format.");
+ numFailures++;
+ }
}
- System.out.println("Test passed");
+ if (numFailures == 0) {
+ System.out.println("Test passed.");
+ } else {
+ throw new RuntimeException("Test failed.");
+ }
}
// Callbacks
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/WriteToSequenceAfterAbort.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,376 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageWriter;
+import javax.imageio.event.IIOWriteProgressListener;
+import javax.imageio.stream.ImageOutputStream;
+
+import static java.awt.image.BufferedImage.TYPE_BYTE_BINARY;
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.awt.image.SampleModel;
+import java.awt.image.WritableRaster;
+import java.util.Vector;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+
+/**
+ * @test
+ * @bug 8144245
+ * @summary Ensure aborting write works properly for a TIFF sequence.
+ */
+public final class WriteToSequenceAfterAbort implements IIOWriteProgressListener {
+
+ private volatile boolean abortFlag = true;
+ private volatile boolean isAbortCalled;
+ private volatile boolean isCompleteCalled;
+ private volatile boolean isProgressCalled;
+ private volatile boolean isStartedCalled;
+ private static final int WIDTH = 100;
+ private static final int HEIGHT = 100;
+ private static final int NUM_TILES_XY = 3;
+
+ private class TiledImage implements RenderedImage {
+ private final BufferedImage tile;
+ private final BufferedImage image;
+ private final int numXTiles, numYTiles;
+ private boolean isImageInitialized = false;
+
+ TiledImage(BufferedImage tile, int numXTiles, int numYTiles) {
+ this.tile = tile;
+ this.numXTiles = numXTiles;
+ this.numYTiles = numYTiles;
+ image = new BufferedImage(getWidth(), getHeight(), tile.getType());
+ }
+
+ @Override
+ public Vector<RenderedImage> getSources() {
+ return null;
+ }
+
+ @Override
+ public Object getProperty(String string) {
+ return java.awt.Image.UndefinedProperty;
+ }
+
+ @Override
+ public String[] getPropertyNames() {
+ return new String[0];
+ }
+
+ @Override
+ public ColorModel getColorModel() {
+ return tile.getColorModel();
+ }
+
+ @Override
+ public SampleModel getSampleModel() {
+ return tile.getSampleModel();
+ }
+
+ @Override
+ public int getWidth() {
+ return numXTiles*tile.getWidth();
+ }
+
+ @Override
+ public int getHeight() {
+ return numYTiles*tile.getHeight();
+ }
+
+ @Override
+ public int getMinX() {
+ return 0;
+ }
+
+ @Override
+ public int getMinY() {
+ return 0;
+ }
+
+ @Override
+ public int getNumXTiles() {
+ return numXTiles;
+ }
+
+ @Override
+ public int getNumYTiles() {
+ return numYTiles;
+ }
+
+ @Override
+ public int getMinTileX() {
+ return 0;
+ }
+
+ @Override
+ public int getMinTileY() {
+ return 0;
+ }
+
+ @Override
+ public int getTileWidth() {
+ return tile.getWidth();
+ }
+
+ @Override
+ public int getTileHeight() {
+ return tile.getHeight();
+ }
+
+ @Override
+ public int getTileGridXOffset() {
+ return 0;
+ }
+
+ @Override
+ public int getTileGridYOffset() {
+ return 0;
+ }
+
+ @Override
+ public Raster getTile(int x, int y) {
+ WritableRaster r = tile.getRaster();
+ return r.createWritableTranslatedChild(x*tile.getWidth(),
+ y*tile.getHeight());
+ }
+
+ @Override
+ public Raster getData() {
+ return getAsBufferedImage().getData();
+ }
+
+ @Override
+ public Raster getData(Rectangle r) {
+ return getAsBufferedImage().getData(r);
+ }
+
+ @Override
+ public WritableRaster copyData(WritableRaster wr) {
+ return getAsBufferedImage().copyData(wr);
+ }
+
+ public BufferedImage getAsBufferedImage() {
+ synchronized (image) {
+ if (!isImageInitialized) {
+ int tx0 = getMinTileX(), ty0 = getMinTileY();
+ int txN = tx0 + getNumXTiles(), tyN = ty0 + getNumYTiles();
+ for (int j = ty0; j < tyN; j++) {
+ for (int i = tx0; i < txN; i++) {
+ image.setData(getTile(i, j));
+ }
+ }
+ }
+ isImageInitialized = true;
+ }
+ return image;
+ }
+ }
+
+ private void test(final ImageWriter writer) throws IOException {
+ String suffix = writer.getOriginatingProvider().getFileSuffixes()[0];
+
+ // Image initialization
+ BufferedImage imageUpperLeft =
+ new BufferedImage(WIDTH, HEIGHT, TYPE_BYTE_BINARY);
+ Graphics2D g = imageUpperLeft.createGraphics();
+ g.setColor(Color.WHITE);
+ g.fillRect(0, 0, WIDTH/2, HEIGHT/2);
+ g.dispose();
+ BufferedImage imageLowerRight =
+ new BufferedImage(WIDTH, HEIGHT, TYPE_BYTE_BINARY);
+ g = imageLowerRight.createGraphics();
+ g.setColor(Color.WHITE);
+ g.fillRect(WIDTH/2, HEIGHT/2, WIDTH/2, HEIGHT/2);
+ g.dispose();
+ TiledImage[] images = new TiledImage[] {
+ new TiledImage(imageUpperLeft, NUM_TILES_XY, NUM_TILES_XY),
+ new TiledImage(imageUpperLeft, NUM_TILES_XY, NUM_TILES_XY),
+ new TiledImage(imageLowerRight, NUM_TILES_XY, NUM_TILES_XY),
+ new TiledImage(imageLowerRight, NUM_TILES_XY, NUM_TILES_XY)
+ };
+
+ // File initialization
+ File file = File.createTempFile("temp", "." + suffix);
+ file.deleteOnExit();
+ FileOutputStream fos = new SkipWriteOnAbortOutputStream(file);
+ ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
+ writer.setOutput(ios);
+ writer.addIIOWriteProgressListener(this);
+
+ writer.prepareWriteSequence(null);
+ boolean[] abortions = new boolean[] {true, false, true, false};
+ for (int i = 0; i < 4; i++) {
+ abortFlag = abortions[i];
+ isAbortCalled = false;
+ isCompleteCalled = false;
+ isProgressCalled = false;
+ isStartedCalled = false;
+
+ TiledImage image = images[i];
+ if (abortFlag) {
+ // This write will be aborted, and file will not be touched
+ writer.writeToSequence(new IIOImage(image, null, null), null);
+ if (!isStartedCalled) {
+ throw new RuntimeException("Started should be called");
+ }
+ if (!isProgressCalled) {
+ throw new RuntimeException("Progress should be called");
+ }
+ if (!isAbortCalled) {
+ throw new RuntimeException("Abort should be called");
+ }
+ if (isCompleteCalled) {
+ throw new RuntimeException("Complete should not be called");
+ }
+ } else {
+ // This write should be completed successfully and the file should
+ // contain correct image data.
+ writer.writeToSequence(new IIOImage(image, null, null), null);
+ if (!isStartedCalled) {
+ throw new RuntimeException("Started should be called");
+ }
+ if (!isProgressCalled) {
+ throw new RuntimeException("Progress should be called");
+ }
+ if (isAbortCalled) {
+ throw new RuntimeException("Abort should not be called");
+ }
+ if (!isCompleteCalled) {
+ throw new RuntimeException("Complete should be called");
+ }
+ }
+ }
+
+ writer.endWriteSequence();
+ writer.dispose();
+ ios.close();
+
+ // Validates content of the file.
+ ImageReader reader = ImageIO.getImageReader(writer);
+ ImageInputStream iis = ImageIO.createImageInputStream(file);
+ reader.setInput(iis);
+ for (int i = 0; i < 2; i++) {
+ System.out.println("Testing image " + i);
+ BufferedImage imageRead = reader.read(i);
+ BufferedImage imageWrite = images[2 * i].getAsBufferedImage();
+ for (int x = 0; x < WIDTH; ++x) {
+ for (int y = 0; y < HEIGHT; ++y) {
+ if (imageRead.getRGB(x, y) != imageWrite.getRGB(x, y)) {
+ throw new RuntimeException("Test failed for image " + i);
+ }
+ }
+ }
+ }
+ }
+
+ public static void main(final String[] args) throws IOException {
+ WriteToSequenceAfterAbort writeAfterAbort = new WriteToSequenceAfterAbort();
+ ImageWriter writer = ImageIO.getImageWritersByFormatName("TIFF").next();
+ writeAfterAbort.test(writer);
+ System.out.println("Test passed.");
+ }
+
+ // Callbacks
+
+ @Override
+ public void imageComplete(ImageWriter source) {
+ isCompleteCalled = true;
+ }
+
+ @Override
+ public void imageProgress(ImageWriter source, float percentageDone) {
+ isProgressCalled = true;
+ if (percentageDone > 50 && abortFlag) {
+ source.abort();
+ }
+ }
+
+ @Override
+ public void imageStarted(ImageWriter source, int imageIndex) {
+ isStartedCalled = true;
+ }
+
+ @Override
+ public void writeAborted(final ImageWriter source) {
+ isAbortCalled = true;
+ }
+
+ @Override
+ public void thumbnailComplete(ImageWriter source) {
+ }
+
+ @Override
+ public void thumbnailProgress(ImageWriter source, float percentageDone) {
+ }
+
+ @Override
+ public void thumbnailStarted(ImageWriter source, int imageIndex,
+ int thumbnailIndex) {
+ }
+
+ /**
+ * We need to skip writes on abort, because content of the file after abort
+ * is undefined.
+ */
+ private class SkipWriteOnAbortOutputStream extends FileOutputStream {
+
+ SkipWriteOnAbortOutputStream(File file) throws FileNotFoundException {
+ super(file);
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ if (!abortFlag) {
+ super.write(b);
+ }
+ }
+
+ @Override
+ public void write(byte[] b) throws IOException {
+ if (!abortFlag) {
+ super.write(b);
+ }
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ if (!abortFlag) {
+ super.write(b, off, len);
+ }
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/spi/MarkTryFinallyReproducer.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,367 @@
+/*
+ * Copyright 2015 Red Hat, Inc.
+ * 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 8144071
+ * @run main/othervm MarkTryFinallyReproducer
+ * @summary Test that call to canDecodeInput in ImageIO don't corrupt
+ * mark/reset stack in ImageInputStream
+ * @author Jiri Vanek
+ */
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.ByteOrder;
+import java.util.Locale;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.spi.IIORegistry;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.stream.IIOByteBuffer;
+import javax.imageio.stream.ImageInputStream;
+
+
+public class MarkTryFinallyReproducer {
+
+ private static final byte[] bmp = new byte[]{
+ 127,127, 66, 77, -86, 0, 0, 0, 0, 0, 0, 0,
+ 122, 0, 0, 0, 108, 0, 0, 0, 4, 0, 0, 0, 4,
+ 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, 48, 0, 0,
+ 0, 19, 11, 0, 0, 19, 11, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 66, 71, 82, 115, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, -1, -1,
+ -1, -1, -1, 0, -1, 0, -1, -1, -1, -1, 0, 0, 0, -17,
+ 0, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, -1, -1, -1,
+ -1, 0, 0, 0, -1, -1, -1, -1, -1, -1, 0, 0, -1
+ };
+ //first two are evil, we are skipping them later. Others are normal BMP
+
+ private static class NotClosingImageInputStream implements ImageInputStream {
+
+ private final ImageInputStream src;
+
+ private NotClosingImageInputStream(ImageInputStream createImageInputStream) {
+ this.src = createImageInputStream;
+ }
+
+ @Override
+ public void setByteOrder(ByteOrder byteOrder) {
+ src.setByteOrder(byteOrder);
+ }
+
+ @Override
+ public ByteOrder getByteOrder() {
+ return src.getByteOrder();
+ }
+
+ @Override
+ public int read() throws IOException {
+ return src.read();
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ return src.read(b);
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ return src.read(b, off, len);
+ }
+
+ @Override
+ public void readBytes(IIOByteBuffer buf, int len) throws IOException {
+ src.readBytes(buf, len);
+ }
+
+ @Override
+ public boolean readBoolean() throws IOException {
+ return src.readBoolean();
+ }
+
+ @Override
+ public byte readByte() throws IOException {
+ return src.readByte();
+ }
+
+ @Override
+ public int readUnsignedByte() throws IOException {
+ return src.readUnsignedByte();
+ }
+
+ @Override
+ public short readShort() throws IOException {
+ return src.readShort();
+ }
+
+ @Override
+ public int readUnsignedShort() throws IOException {
+ return src.readUnsignedShort();
+ }
+
+ @Override
+ public char readChar() throws IOException {
+ return src.readChar();
+ }
+
+ @Override
+ public int readInt() throws IOException {
+ return src.readInt();
+ }
+
+ @Override
+ public long readUnsignedInt() throws IOException {
+ return src.readUnsignedInt();
+ }
+
+ @Override
+ public long readLong() throws IOException {
+ return src.readLong();
+ }
+
+ @Override
+ public float readFloat() throws IOException {
+ return src.readFloat();
+ }
+
+ @Override
+ public double readDouble() throws IOException {
+ return src.readDouble();
+ }
+
+ @Override
+ public String readLine() throws IOException {
+ return src.readLine();
+ }
+
+ @Override
+ public String readUTF() throws IOException {
+ return src.readUTF();
+ }
+
+ @Override
+ public void readFully(byte[] b, int off, int len) throws IOException {
+ src.readFully(b, off, len);
+ }
+
+ @Override
+ public void readFully(byte[] b) throws IOException {
+ src.readFully(b);
+ }
+
+ @Override
+ public void readFully(short[] s, int off, int len) throws IOException {
+ src.readFully(s, off, len);
+ }
+
+ @Override
+ public void readFully(char[] c, int off, int len) throws IOException {
+ src.readFully(c, off, len);
+ }
+
+ @Override
+ public void readFully(int[] i, int off, int len) throws IOException {
+ src.readFully(i, off, len);
+ }
+
+ @Override
+ public void readFully(long[] l, int off, int len) throws IOException {
+ src.readFully(l, off, len);
+ }
+
+ @Override
+ public void readFully(float[] f, int off, int len) throws IOException {
+ src.readFully(f, off, len);
+ }
+
+ @Override
+ public void readFully(double[] d, int off, int len) throws IOException {
+ src.readFully(d, off, len);
+ }
+
+ @Override
+ public long getStreamPosition() throws IOException {
+ return src.getStreamPosition();
+ }
+
+ @Override
+ public int getBitOffset() throws IOException {
+ return src.getBitOffset();
+ }
+
+ @Override
+ public void setBitOffset(int bitOffset) throws IOException {
+ src.setBitOffset(bitOffset);
+ }
+
+ @Override
+ public int readBit() throws IOException {
+ return src.readBit();
+ }
+
+ @Override
+ public long readBits(int numBits) throws IOException {
+ return src.readBits(numBits);
+ }
+
+ @Override
+ public long length() throws IOException {
+ return src.length();
+ }
+
+ @Override
+ public int skipBytes(int n) throws IOException {
+ return src.skipBytes(n);
+ }
+
+ @Override
+ public long skipBytes(long n) throws IOException {
+ return src.skipBytes(n);
+ }
+
+ @Override
+ public void seek(long pos) throws IOException {
+ src.seek(pos);
+ }
+
+ @Override
+ public void mark() {
+ src.mark();
+ }
+
+ @Override
+ public void reset() throws IOException {
+ src.reset();
+ }
+
+ @Override
+ public void flushBefore(long pos) throws IOException {
+ src.flushBefore(pos);
+ }
+
+ @Override
+ public void flush() throws IOException {
+ src.flush();
+ }
+
+ @Override
+ public long getFlushedPosition() {
+ return src.getFlushedPosition();
+ }
+
+ @Override
+ public boolean isCached() {
+ return src.isCached();
+ }
+
+ @Override
+ public boolean isCachedMemory() {
+ return src.isCachedMemory();
+ }
+
+ @Override
+ public boolean isCachedFile() {
+ return src.isCachedFile();
+ }
+
+ @Override
+ public void close() throws IOException {
+ //the only important one. nothing
+ }
+ }
+
+ static final String readerClassName
+ = MarkTryFinallyReproducerSpi.class.getName();
+ static final String[] localNames = {"myNames"};
+ static final String[] localSuffixes = {"mySuffixes"};
+ static final String[] localMIMETypes = {"myMimes"};
+
+ public static class MarkTryFinallyReproducerSpi extends ImageReaderSpi {
+
+ public MarkTryFinallyReproducerSpi() {
+ super("MarkTryFinallyReproducerSpi",
+ "1.0",
+ localNames,
+ localSuffixes,
+ localMIMETypes,
+ readerClassName,
+ new Class[]{ImageInputStream.class},
+ new String[0],
+ false,
+ null,
+ null,
+ new String[0],
+ new String[0],
+ false,
+ null,
+ null,
+ new String[0],
+ new String[0]);
+ }
+
+ @Override
+ public String getDescription(Locale locale) {
+ return "";
+ }
+
+ @Override
+ public boolean canDecodeInput(Object input) throws IOException {
+ throw new IOException("Bad luck");
+ }
+
+ @Override
+ public ImageReader createReaderInstance(Object extension) {
+ return null;
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ MarkTryFinallyReproducerSpi spi = new MarkTryFinallyReproducerSpi();
+ IIORegistry.getDefaultInstance().registerServiceProvider(spi);
+
+ ImageInputStream iis1 =
+ new NotClosingImageInputStream(ImageIO.createImageInputStream(new ByteArrayInputStream(bmp)));
+ iis1.readByte();
+ iis1.mark();
+ long p1 = iis1.getStreamPosition();
+ iis1.readByte();
+ iis1.mark();
+ long p2 = iis1.getStreamPosition();
+ BufferedImage bi1 = ImageIO.read(iis1);
+ iis1.reset();
+ long pn2 = iis1.getStreamPosition();
+ iis1.reset();
+ long pn1 = iis1.getStreamPosition();
+ if (p1 != pn1 || p2!= pn2) {
+ throw new RuntimeException("Exception from call to canDecodeInput in ImageIO. " +
+ "Corrupted stack in ImageInputStream");
+ }
+
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/print/attribute/Services_getDocFl.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+import javax.print.DocFlavor;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+
+/*
+ * @test
+ * @bug 4901243 8040139
+ * @summary JPG, GIF, and PNG DocFlavors (URL) should be supported if Postscript is supported.
+ * @run main Services_getDocFl
+*/
+
+
+public class Services_getDocFl {
+ public static void main (String [] args) {
+
+ HashPrintRequestAttributeSet prSet = null;
+ boolean psSupported = false,
+ pngImagesSupported = false,
+ gifImagesSupported = false,
+ jpgImagesSupported = false;
+ String mimeType;
+
+ PrintService[] serv = PrintServiceLookup.lookupPrintServices(null, null);
+ if (serv.length==0) {
+ System.out.println("no PrintService found");
+ } else {
+ System.out.println("number of Services "+serv.length);
+ }
+
+
+ for (int i = 0; i<serv.length ;i++) {
+ System.out.println(" PRINT SERVICE: "+ i+" "+serv[i]);
+ DocFlavor[] flavors = serv[i].getSupportedDocFlavors();
+ pngImagesSupported = false;
+ gifImagesSupported = false;
+ jpgImagesSupported = false;
+ for (int j=0; j<flavors.length; j++) {
+ System.out.println(flavors[j]);
+
+ if (flavors[j].equals(DocFlavor.URL.PNG)) {
+ pngImagesSupported = true;
+ } else if (flavors[j].equals(DocFlavor.URL.GIF)) {
+ gifImagesSupported = true;
+ } else if (flavors[j].equals(DocFlavor.URL.JPEG)) {
+ jpgImagesSupported = true;
+ } else if (flavors[j].getMimeType().indexOf("postscript") != -1) {
+ psSupported = true;
+ }
+ }
+
+ if (psSupported && !(pngImagesSupported && gifImagesSupported &&
+ jpgImagesSupported)) {
+
+ throw new RuntimeException("Error: URL image DocFlavors are not reported as supported");
+ }
+ }
+
+ }
+}
+
--- a/jdk/test/javax/sound/midi/MidiDeviceProvider/FakeInfo.java Mon Dec 14 09:27:15 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2015, 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.
- */
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import javax.sound.midi.MidiDevice;
-import javax.sound.midi.MidiDevice.Info;
-import javax.sound.midi.MidiSystem;
-import javax.sound.midi.MidiUnavailableException;
-import javax.sound.midi.spi.MidiDeviceProvider;
-
-import static java.util.ServiceLoader.load;
-
-/**
- * @test
- * @bug 8059743
- * @summary MidiDeviceProvider shouldn't returns incorrect results in case of
- * some unknown MidiDevice.Info
- * @author Sergey Bylokhov
- */
-public final class FakeInfo {
-
- private static final class Fake extends Info {
-
- Fake() {
- super("a", "b", "c", "d");
- }
- }
-
- public static void main(final String[] args) {
- final Info fake = new Fake();
- // MidiSystem API
- try {
- MidiSystem.getMidiDevice(fake);
- throw new RuntimeException("IllegalArgumentException expected");
- } catch (final MidiUnavailableException e) {
- throw new RuntimeException("IllegalArgumentException expected", e);
- } catch (final IllegalArgumentException ignored) {
- // expected
- }
- // MidiDeviceProvider API
- final Collection<String> errors = new HashSet<>();
- for (final MidiDeviceProvider mdp : load(MidiDeviceProvider.class)) {
- try {
- if (mdp.isDeviceSupported(fake)) {
- throw new RuntimeException("fake is supported");
- }
- final MidiDevice device = mdp.getDevice(fake);
- System.err.println("MidiDevice: " + device);
- throw new RuntimeException("IllegalArgumentException expected");
- } catch (final IllegalArgumentException e) {
- errors.add(e.getMessage());
- }
- }
- if (errors.size() != 1) {
- throw new RuntimeException("Wrong number of messages:" + errors);
- }
- }
-}
--- a/jdk/test/javax/sound/midi/MidiDeviceProvider/NullInfo.java Mon Dec 14 09:27:15 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2014, 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.
- */
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import javax.sound.midi.MidiDevice;
-import javax.sound.midi.MidiSystem;
-import javax.sound.midi.MidiUnavailableException;
-import javax.sound.midi.spi.MidiDeviceProvider;
-
-import static java.util.ServiceLoader.load;
-
-/**
- * @test
- * @bug 8058115
- * @summary MidiDeviceProvider shouldn't returns incorrect results or throw NPE
- * in case of null MidiDevice.Info
- * @author Sergey Bylokhov
- */
-public final class NullInfo {
-
- public static void main(final String[] args) {
- // MidiSystem API
- try {
- MidiSystem.getMidiDevice(null);
- throw new RuntimeException("IllegalArgumentException expected");
- } catch (final MidiUnavailableException e) {
- throw new RuntimeException("IllegalArgumentException expected", e);
- } catch (final IllegalArgumentException ignored) {
- // expected
- }
- // MidiDeviceProvider API
- final Collection<String> errors = new HashSet<>();
- for (final MidiDeviceProvider mdp : load(MidiDeviceProvider.class)) {
- try {
- if (mdp.isDeviceSupported(null)) {
- throw new RuntimeException("null is supported");
- }
- final MidiDevice device = mdp.getDevice(null);
- System.err.println("MidiDevice: " + device);
- throw new RuntimeException("IllegalArgumentException expected");
- } catch (final IllegalArgumentException e) {
- errors.add(e.getMessage());
- }
- }
- if (errors.size() != 1) {
- throw new RuntimeException("Wrong number of messages:" + errors);
- }
- }
-}
--- a/jdk/test/javax/sound/midi/MidiDeviceProvider/UnsupportedInfo.java Mon Dec 14 09:27:15 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2014, 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.
- */
-
-import javax.sound.midi.MidiDevice;
-import javax.sound.midi.MidiSystem;
-import javax.sound.midi.spi.MidiDeviceProvider;
-
-import static java.util.ServiceLoader.load;
-
-/**
- * @test
- * @bug 8058115
- * @summary MidiDeviceProvider shouldn't returns incorrect results in case of
- * unsupported MidiDevice.Info
- * @author Sergey Bylokhov
- */
-public final class UnsupportedInfo {
-
- public static void main(final String[] args) {
- final MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
- for (final MidiDeviceProvider mdp : load(MidiDeviceProvider.class)) {
- for (final MidiDevice.Info info : infos) {
- if (mdp.isDeviceSupported(info)) {
- if (mdp.getDevice(info) == null) {
- throw new RuntimeException("MidiDevice is null");
- }
- } else {
- try {
- mdp.getDevice(info);
- throw new RuntimeException(
- "IllegalArgumentException expected");
- } catch (final IllegalArgumentException ignored) {
- // expected
- }
- }
- }
- }
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/spi/MidiDeviceProvider/ExpectedNPEOnNull.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+import java.util.Objects;
+
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.MidiSystem;
+import javax.sound.midi.spi.MidiDeviceProvider;
+
+import static java.util.ServiceLoader.load;
+
+/**
+ * @test
+ * @bug 8143909
+ * @author Sergey Bylokhov
+ */
+public final class ExpectedNPEOnNull {
+
+ public static void main(final String[] args) throws Exception {
+ testMS();
+ for (final MidiDeviceProvider mdp : load(MidiDeviceProvider.class)) {
+ testMDP(mdp);
+ }
+ testMDP(customMDP);
+ }
+
+ /**
+ * Tests the part of MidiSystem API, which implemented via
+ * MidiDeviceProvider.
+ */
+ private static void testMS() throws Exception {
+ // MidiSystem#getMidiDevice(MidiDevice.Info)
+ try {
+ MidiSystem.getMidiDevice(null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+
+ /**
+ * Tests the MidiDeviceProvider API directly.
+ */
+ private static void testMDP(final MidiDeviceProvider mdp) throws Exception {
+ // MidiDeviceProvider#isDeviceSupported(Info)
+ try {
+ mdp.isDeviceSupported(null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiDeviceProvider#getDevice(Info)
+ try {
+ mdp.getDevice(null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+
+ /**
+ * Tests some default implementation of MidiDeviceProvider API, using the
+ * custom {@code MidiDeviceProvider}, which support nothing.
+ */
+ static MidiDeviceProvider customMDP = new MidiDeviceProvider() {
+ @Override
+ public MidiDevice.Info[] getDeviceInfo() {
+ return new MidiDevice.Info[0];
+ }
+
+ @Override
+ public MidiDevice getDevice(MidiDevice.Info info) {
+ Objects.requireNonNull(info);
+ return null;
+ }
+ };
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/spi/MidiDeviceProvider/FakeInfo.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.MidiDevice.Info;
+import javax.sound.midi.MidiSystem;
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.spi.MidiDeviceProvider;
+
+import static java.util.ServiceLoader.load;
+
+/**
+ * @test
+ * @bug 8059743
+ * @summary MidiDeviceProvider shouldn't returns incorrect results in case of
+ * some unknown MidiDevice.Info
+ * @author Sergey Bylokhov
+ */
+public final class FakeInfo {
+
+ private static final class Fake extends Info {
+
+ Fake() {
+ super("a", "b", "c", "d");
+ }
+ }
+
+ public static void main(final String[] args) {
+ final Info fake = new Fake();
+ // MidiSystem API
+ try {
+ MidiSystem.getMidiDevice(fake);
+ throw new RuntimeException("IllegalArgumentException expected");
+ } catch (final MidiUnavailableException e) {
+ throw new RuntimeException("IllegalArgumentException expected", e);
+ } catch (final IllegalArgumentException ignored) {
+ // expected
+ }
+ // MidiDeviceProvider API
+ final Collection<String> errors = new HashSet<>();
+ for (final MidiDeviceProvider mdp : load(MidiDeviceProvider.class)) {
+ try {
+ if (mdp.isDeviceSupported(fake)) {
+ throw new RuntimeException("fake is supported");
+ }
+ final MidiDevice device = mdp.getDevice(fake);
+ System.err.println("MidiDevice: " + device);
+ throw new RuntimeException("IllegalArgumentException expected");
+ } catch (final IllegalArgumentException e) {
+ errors.add(e.getMessage());
+ }
+ }
+ if (errors.size() != 1) {
+ throw new RuntimeException("Wrong number of messages:" + errors);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/spi/MidiDeviceProvider/UnsupportedInfo.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.MidiSystem;
+import javax.sound.midi.spi.MidiDeviceProvider;
+
+import static java.util.ServiceLoader.load;
+
+/**
+ * @test
+ * @bug 8058115
+ * @summary MidiDeviceProvider shouldn't returns incorrect results in case of
+ * unsupported MidiDevice.Info
+ * @author Sergey Bylokhov
+ */
+public final class UnsupportedInfo {
+
+ public static void main(final String[] args) {
+ final MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
+ for (final MidiDeviceProvider mdp : load(MidiDeviceProvider.class)) {
+ for (final MidiDevice.Info info : infos) {
+ if (mdp.isDeviceSupported(info)) {
+ if (mdp.getDevice(info) == null) {
+ throw new RuntimeException("MidiDevice is null");
+ }
+ } else {
+ try {
+ mdp.getDevice(info);
+ throw new RuntimeException(
+ "IllegalArgumentException expected");
+ } catch (final IllegalArgumentException ignored) {
+ // expected
+ }
+ }
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/spi/MidiFileReader/ExpectedNPEOnNull.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.sound.midi.MidiSystem;
+import javax.sound.midi.spi.MidiFileReader;
+
+import static java.util.ServiceLoader.load;
+
+/**
+ * @test
+ * @bug 8143909
+ * @author Sergey Bylokhov
+ */
+public final class ExpectedNPEOnNull {
+
+ public static void main(final String[] args) throws Exception {
+ testMS();
+ for (final MidiFileReader mfr : load(MidiFileReader.class)) {
+ testMFR(mfr);
+ }
+ }
+
+ /**
+ * Tests the part of MidiSystem API, which implemented via MidiFileReader.
+ */
+ private static void testMS() throws Exception {
+ // MidiSystem#getMidiFileFormat(InputStream)
+ try {
+ MidiSystem.getMidiFileFormat((InputStream) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiSystem#getMidiFileFormat(URL)
+ try {
+ MidiSystem.getMidiFileFormat((URL) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiSystem#getMidiFileFormat(File)
+ try {
+ MidiSystem.getMidiFileFormat((File) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiSystem#getSequence(InputStream)
+ try {
+ MidiSystem.getSequence((InputStream) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiSystem#getSequence(URL)
+ try {
+ MidiSystem.getSequence((URL) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiSystem#getSequence(File)
+ try {
+ MidiSystem.getSequence((File) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+
+ /**
+ * Tests the MidiFileReader API directly.
+ */
+ private static void testMFR(final MidiFileReader mfr) throws Exception {
+ // MidiFileReader#getMidiFileFormat(InputStream)
+ try {
+ mfr.getMidiFileFormat((InputStream) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiFileReader#getMidiFileFormat(URL)
+ try {
+ mfr.getMidiFileFormat((URL) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiFileReader#getMidiFileFormat(File)
+ try {
+ mfr.getMidiFileFormat((File) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiFileReader#getSequence(InputStream)
+ try {
+ mfr.getSequence((InputStream) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiFileReader#getSequence(URL)
+ try {
+ mfr.getSequence((URL) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiFileReader#getSequence(File)
+ try {
+ mfr.getSequence((File) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/spi/MidiFileWriter/ExpectedNPEOnNull.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+import java.io.File;
+import java.io.OutputStream;
+import java.util.Objects;
+
+import javax.sound.midi.MidiSystem;
+import javax.sound.midi.Sequence;
+import javax.sound.midi.spi.MidiFileWriter;
+
+import static java.util.ServiceLoader.load;
+
+/**
+ * @test
+ * @bug 8143909
+ * @author Sergey Bylokhov
+ */
+public final class ExpectedNPEOnNull {
+
+ public static void main(final String[] args) throws Exception {
+ testMS();
+ for (final MidiFileWriter mfw : load(MidiFileWriter.class)) {
+ testMFW(mfw);
+ }
+ testMFW(customMFW);
+ }
+
+ /**
+ * Tests the part of MidiSystem API, which implemented via MidiFileWriter.
+ */
+ private static void testMS() throws Exception {
+ // MidiSystem#getMidiFileTypes(Sequence)
+ try {
+ MidiSystem.getMidiFileTypes(null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+
+ // MidiSystem#isFileTypeSupported(int, Sequence)
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ MidiSystem.isFileTypeSupported(type, null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ // MidiSystem#write(Sequence, int, OutputStream)
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ MidiSystem.write(null, type, new NullOutputStream());
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ MidiSystem.write(new Sequence(0, 0), type, (OutputStream) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ MidiSystem.write(null, type, (OutputStream) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ // MidiSystem#write(Sequence, int, File)
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ MidiSystem.write(null, type, new File(""));
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ MidiSystem.write(new Sequence(0, 0), type, (File) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ MidiSystem.write(null, type, (File) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ }
+
+ /**
+ * Tests the MidiFileWriter API directly.
+ */
+ private static void testMFW(final MidiFileWriter mfw) throws Exception {
+ // MidiFileWriter#getMidiFileTypes(Sequence)
+ try {
+ mfw.getMidiFileTypes(null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiFileWriter#isFileTypeSupported(int, Sequence)
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ mfw.isFileTypeSupported(type, null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ // MidiFileWriter#write(Sequence, int, OutputStream)
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ mfw.write(null, type, new NullOutputStream());
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ mfw.write(new Sequence(0, 0), type, (OutputStream) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ mfw.write(null, type, (OutputStream) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ // MidiFileWriter#write(Sequence, int, File)
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ mfw.write(null, type, new File(""));
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ mfw.write(new Sequence(0, 0), type, (File) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ for (final int type : MidiSystem.getMidiFileTypes()) {
+ try {
+ mfw.write(null, type, (File) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+ }
+ /**
+ * Tests some default implementation of MidiFileWriter API, using the custom
+ * {@code MidiFileWriter}, which support nothing.
+ */
+ static MidiFileWriter customMFW = new MidiFileWriter() {
+ @Override
+ public int[] getMidiFileTypes() {
+ return new int[0];
+ }
+
+ @Override
+ public int[] getMidiFileTypes(Sequence sequence) {
+ Objects.requireNonNull(sequence);
+ return new int[0];
+ }
+
+ @Override
+ public int write(Sequence in, int fileType, OutputStream out) {
+ Objects.requireNonNull(in);
+ Objects.requireNonNull(out);
+ return 0;
+ }
+
+ @Override
+ public int write(Sequence in, int fileType, File out) {
+ Objects.requireNonNull(in);
+ Objects.requireNonNull(out);
+ return 0;
+ }
+ };
+
+ private static final class NullOutputStream extends OutputStream {
+
+ @Override
+ public void write(final int b) {
+ //do nothing
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/spi/SoundbankReader/ExpectedNPEOnNull.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.sound.midi.MidiSystem;
+import javax.sound.midi.spi.SoundbankReader;
+
+import static java.util.ServiceLoader.load;
+
+/**
+ * @test
+ * @bug 8143909
+ * @author Sergey Bylokhov
+ */
+public final class ExpectedNPEOnNull {
+
+ public static void main(final String[] args) throws Exception {
+ testMS();
+ for (final SoundbankReader sbr : load(SoundbankReader.class)) {
+ testSBR(sbr);
+ }
+ }
+
+ /**
+ * Tests the part of MidiSystem API, which implemented via SoundbankReader.
+ */
+ private static void testMS() throws Exception {
+ // MidiSystem#getSoundbank(InputStream)
+ try {
+ MidiSystem.getSoundbank((InputStream) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiSystem#getSoundbank(URL)
+ try {
+ MidiSystem.getSoundbank((URL) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // MidiSystem#getSoundbank(File)
+ try {
+ MidiSystem.getSoundbank((File) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+
+ /**
+ * Tests the SoundbankReader API directly.
+ */
+ private static void testSBR(final SoundbankReader sbr) throws Exception {
+ // SoundbankReader#getSoundbank(InputStream)
+ try {
+ sbr.getSoundbank((InputStream) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // SoundbankReader#getSoundbank(URL)
+ try {
+ sbr.getSoundbank((URL) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ // SoundbankReader#getSoundbank(File)
+ try {
+ sbr.getSoundbank((File) null);
+ throw new RuntimeException("NPE is expected");
+ } catch (final NullPointerException ignored) {
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JFileChooser/8067660/FileChooserTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2015, 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 8067660
+ * @summary JFileChooser create new folder fails silently
+ * @requires (os.family == "windows")
+ * @run main/manual FileChooserTest
+ */
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+public class FileChooserTest {
+
+ private static boolean theTestPassed;
+ private static boolean testGeneratedInterrupt;
+ private static Thread mainThread;
+ private static int sleepTime = 30000;
+ public static JFileChooser fileChooser;
+
+ private static void init() throws Exception {
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ String[] instructions
+ = {
+ "1) Create a folder with read only permissions",
+ "2) Click on run test button.It will open a open dialog"
+ + " Navigate to the newly created read only folder",
+ "3) Click on the create new folder button in open dialog",
+ "4) If an error message does not pops up"
+ + "test failed otherwise passed.",
+ "5) Pressing Pass/Fail button will mark test as "
+ + "pass/fail and will shutdown JVM"};
+
+ Sysout.createDialogWithInstructions(instructions);
+ Sysout.printInstructions(instructions);
+ }
+ });
+ }
+
+ /**
+ * ***************************************************
+ * Standard Test Machinery Section DO NOT modify anything in this section --
+ * it's a standard chunk of code which has all of the synchronisation
+ * necessary for the test harness. By keeping it the same in all tests, it
+ * is easier to read and understand someone else's test, as well as insuring
+ * that all tests behave correctly with the test harness. There is a section
+ * following this for test-defined classes
+ */
+ public static void main(String args[]) throws Exception {
+
+ mainThread = Thread.currentThread();
+ try {
+ init();
+ } catch (Exception ex) {
+ return;
+ }
+ try {
+ mainThread.sleep(sleepTime);
+ } catch (InterruptedException ex) {
+ Sysout.dispose();
+ if (!theTestPassed && testGeneratedInterrupt) {
+ throw new RuntimeException("Test Failed");
+ }
+ }
+ if (!testGeneratedInterrupt) {
+ Sysout.dispose();
+ throw new RuntimeException("Test Failed");
+ }
+ }
+
+ public static synchronized void pass() {
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }
+
+ public static synchronized void fail() {
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }
+}
+
+/**
+ * This is part of the standard test machinery. It creates a dialog (with the
+ * instructions), and is the interface for sending text messages to the user. To
+ * print the instructions, send an array of strings to Sysout.createDialog
+ * WithInstructions method. Put one line of instructions per array entry. To
+ * display a message for the tester to see, simply call Sysout.println with the
+ * string to be displayed. This mimics System.out.println but works within the
+ * test harness as well as standalone.
+ */
+class Sysout {
+
+ private static TestDialog dialog;
+ private static JFrame frame;
+
+ public static void createDialogWithInstructions(String[] instructions) {
+ frame = new JFrame();
+ dialog = new TestDialog(frame, "Instructions");
+ dialog.printInstructions(instructions);
+ dialog.setVisible(true);
+ println("Any messages for the tester will display here.");
+ }
+
+ public static void printInstructions(String[] instructions) {
+ dialog.printInstructions(instructions);
+ }
+
+ public static void println(String messageIn) {
+ dialog.displayMessage(messageIn);
+ }
+
+ public static void dispose() {
+ Sysout.println("Shutting down the Java process..");
+ if(FileChooserTest.fileChooser != null) {
+ FileChooserTest.fileChooser.cancelSelection();
+ }
+ frame.dispose();
+ dialog.dispose();
+ }
+}
+
+/**
+ * This is part of the standard test machinery. It provides a place for the test
+ * instructions to be displayed, and a place for interactive messages to the
+ * user to be displayed. To have the test instructions displayed, see Sysout. To
+ * have a message to the user be displayed, see Sysout. Do not call anything in
+ * this dialog directly.
+ */
+class TestDialog extends JDialog {
+
+ private TextArea instructionsText;
+ private TextArea messageText;
+ private int maxStringLength = 80;
+ private Panel buttonP = new Panel();
+ private JButton run = new JButton("Run");
+ private JButton passB = new JButton("Pass");
+ private JButton failB = new JButton("Fail");
+
+ public TestDialog(JFrame frame, String name) {
+ super(frame, name);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
+ add("North", instructionsText);
+
+ messageText = new TextArea("", 5, maxStringLength, scrollBoth);
+ add("Center", messageText);
+
+ buttonP.add("East", run);
+ buttonP.add("East", passB);
+ buttonP.add("West", failB);
+ passB.setEnabled(false);
+ failB.setEnabled(false);
+ add("South", buttonP);
+
+ run.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ FileChooserTest.fileChooser = new JFileChooser();
+ FileChooserTest.fileChooser.showOpenDialog(null);
+ passB.setEnabled(true);
+ failB.setEnabled(true);
+ }
+ });
+
+ passB.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ FileChooserTest.pass();
+ }
+ });
+
+ failB.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ FileChooserTest.fail();
+ }
+ });
+ pack();
+
+ setVisible(true);
+ }
+
+ public void printInstructions(String[] instructions) {
+ instructionsText.setText("");
+
+ String printStr, remainingStr;
+ for (String instruction : instructions) {
+ remainingStr = instruction;
+ while (remainingStr.length() > 0) {
+ if (remainingStr.length() >= maxStringLength) {
+ int posOfSpace = remainingStr.
+ lastIndexOf(' ', maxStringLength - 1);
+
+ if (posOfSpace <= 0) {
+ posOfSpace = maxStringLength - 1;
+ }
+
+ printStr = remainingStr.substring(0, posOfSpace + 1);
+ remainingStr = remainingStr.substring(posOfSpace + 1);
+ } else {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+ instructionsText.append(printStr + "\n");
+ }
+ }
+
+ }
+
+ public void displayMessage(String messageIn) {
+ messageText.append(messageIn + "\n");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JMenuItem/8139169/ScreenMenuBarInputTwice.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2015, 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 8139169
+ * @summary verifies if TextArea gets input twice due to Apple's Screen Menubar
+ * @requires (os.family=="mac")
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main ScreenMenuBarInputTwice
+ */
+import java.awt.BorderLayout;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import static java.awt.event.KeyEvent.VK_COMMA;
+import static java.awt.event.KeyEvent.VK_META;
+import static java.awt.event.KeyEvent.VK_SHIFT;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
+import javax.swing.text.BadLocationException;
+
+public class ScreenMenuBarInputTwice {
+
+ public static final String TEST_STRING = "Check string";
+
+ private static Robot robot;
+ private static JFrame frame;
+ private static JPanel content;
+ private static JTextArea textArea;
+ private static JMenuBar menuBar;
+ private static JMenu menu;
+ private static JMenuItem menuItem;
+
+ public static void main(String[] args) throws Exception {
+ robot = new Robot();
+ createUIWithSeperateMenuBar();
+ robot.delay(2000);
+ shortcutTestCase();
+ robot.delay(2000);
+ cleanUp();
+ createUIWithIntegratedMenuBar();
+ robot.delay(2000);
+ menuTestCase();
+ robot.delay(2000);
+ cleanUp();
+ }
+
+ private static void createUIWithSeperateMenuBar() throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ System.setProperty(
+ "com.apple.mrj.application.apple.menu.about.name",
+ "A test frame");
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ frame = new JFrame("Text input twice check");
+ content = new JPanel(new BorderLayout());
+ textArea = new JTextArea();
+ content.add(new JScrollPane(textArea,
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),
+ BorderLayout.CENTER);
+ menuBar = new JMenuBar();
+ frame.setJMenuBar(menuBar);
+ Action a = new AbstractAction("Insert some text") {
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ try {
+
+ textArea.getDocument()
+ .insertString(0, TEST_STRING, null);
+ } catch (BadLocationException e) {
+ frame.dispose();
+ throw new RuntimeException("Bad location: ", e);
+ }
+ }
+ };
+ KeyStroke keyStroke = KeyStroke.getKeyStroke(
+ "meta shift COMMA");
+ a.putValue(Action.ACCELERATOR_KEY, keyStroke);
+ textArea.getInputMap().put(keyStroke, "myAction");
+ textArea.getActionMap().put("myAction", a);
+ menu = new JMenu("The Menu");
+ menuItem = new JMenuItem(a);
+ menuItem.setAccelerator((KeyStroke) a.getValue(
+ Action.ACCELERATOR_KEY));
+ menu.add(menuItem);
+ menuBar.add(menu);
+ frame.getContentPane().add(content);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setLocationRelativeTo(null);
+ frame.setSize(500, 500);
+ frame.setVisible(true);
+ frame.toFront();
+ }
+ });
+ }
+
+ private static void createUIWithIntegratedMenuBar() throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ System.setProperty(
+ "com.apple.mrj.application.apple.menu.about.name",
+ "A test frame");
+ System.setProperty("apple.laf.useScreenMenuBar", "false");
+ frame = new JFrame("Text input twice check");
+ content = new JPanel(new BorderLayout());
+ textArea = new JTextArea();
+ content.add(new JScrollPane(textArea,
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),
+ BorderLayout.CENTER);
+ menuBar = new JMenuBar();
+ frame.setJMenuBar(menuBar);
+ Action a = new AbstractAction("Insert some text") {
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ try {
+
+ textArea.getDocument()
+ .insertString(0, TEST_STRING, null);
+ } catch (BadLocationException e) {
+ frame.dispose();
+ throw new RuntimeException("Bad location: ", e);
+ }
+ }
+ };
+ KeyStroke keyStroke = KeyStroke.getKeyStroke(
+ "meta shift COMMA");
+ a.putValue(Action.ACCELERATOR_KEY, keyStroke);
+ textArea.getInputMap().put(keyStroke, "myAction");
+ textArea.getActionMap().put("myAction", a);
+ menu = new JMenu("The Menu");
+ menuItem = new JMenuItem(a);
+ menuItem.setAccelerator((KeyStroke) a.getValue(
+ Action.ACCELERATOR_KEY));
+ menu.add(menuItem);
+ menuBar.add(menu);
+ frame.getContentPane().add(content);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(500, 500);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ frame.toFront();
+ }
+ });
+ }
+
+ private static void shortcutTestCase() throws Exception {
+ robot.keyPress(KeyEvent.VK_META);
+ robot.keyPress(KeyEvent.VK_SHIFT);
+ robot.keyPress(KeyEvent.VK_COMMA);
+ robot.keyRelease(VK_COMMA);
+ robot.keyRelease(VK_SHIFT);
+ robot.keyRelease(VK_META);
+ robot.delay(2000);
+ checkText(textArea.getText());
+ }
+
+ private static void menuTestCase() throws Exception {
+ Point mousePoint;
+ mousePoint = Util.getCenterPoint(menu);
+ robot.mouseMove(mousePoint.x, mousePoint.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.delay(2000);
+ mousePoint = Util.getCenterPoint(menuItem);
+ robot.mouseMove(mousePoint.x, mousePoint.y);
+ robot.delay(2000);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.delay(2000);
+ checkText(textArea.getText());
+ }
+
+ private static void checkText(String text) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ if (TEST_STRING.equals(text)) {
+ textArea.setText("");
+ } else {
+ frame.dispose();
+ throw new RuntimeException("Failed. "
+ + " Menu item shortcut invoked twice");
+ }
+ }
+ });
+ }
+
+ private static void cleanUp() throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame.dispose();
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/undo/UndoManager/AbstractDocumentUndoConcurrentTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2015, 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 8030702
+ @summary Deadlock between subclass of AbstractDocument and UndoManager
+ @author Semyon Sadetsky
+ */
+
+import javax.swing.text.PlainDocument;
+import javax.swing.text.StringContent;
+import javax.swing.undo.UndoManager;
+import java.text.DecimalFormat;
+import java.text.Format;
+import java.util.concurrent.CyclicBarrier;
+
+public class AbstractDocumentUndoConcurrentTest {
+ static CyclicBarrier barrier = new CyclicBarrier(3);
+
+ private static PlainDocument doc1;
+ private static PlainDocument doc2;
+ private static Format format1 = new DecimalFormat("<Test1 0000>");
+ private static Format format2 = new DecimalFormat("<Test22 0000>");
+
+ public static void main(String[] args) throws Exception {
+ test();
+ System.out.println(doc1.getText(0, doc1.getLength()));
+ System.out.println(doc2.getText(0, doc2.getLength()));
+ System.out.println("ok");
+ }
+
+ private static void test() throws Exception {
+ doc1 = new PlainDocument(new StringContent());
+ final UndoManager undoManager = new UndoManager();
+
+ doc1.addUndoableEditListener(undoManager);
+ doc1.insertString(0, "<Test1 XXXX>", null);
+
+ doc2 = new PlainDocument(new StringContent());
+
+ doc2.addUndoableEditListener(undoManager);
+ doc2.insertString(0, "<Test22 XXXX>", null);
+
+ Thread t1 = new Thread("Thread doc1") {
+ @Override
+ public void run() {
+ try {
+ barrier.await();
+ for (int i = 0; i < 1000; i++) {
+ doc1.insertString(0, format1.format(i), null);
+ if(doc1.getLength() > 100) doc1.remove(0, 12);
+ }
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ System.out.println("t1 done");
+ }
+ };
+
+ Thread t2 = new Thread("Thread doc2") {
+ @Override
+ public void run() {
+ try {
+ barrier.await();
+ for (int i = 0; i < 1000; i++) {
+ doc2.insertString(0, format2.format(i), null);
+ if(doc2.getLength() > 100) doc2.remove(0, 13);
+ }
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ System.out.println("t2 done");
+ }
+ };
+
+ Thread t3 = new Thread("Undo/Redo Thread") {
+ @Override
+ public void run() {
+ try {
+ barrier.await();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ for (int i = 0; i < 1000; i++) {
+ undoManager.undoOrRedo();
+ undoManager.undo();
+ }
+ System.out.println("t3 done");
+ }
+ };
+
+ t1.start();
+ t2.start();
+ t3.start();
+
+ t1.join();
+ t2.join();
+ t3.join();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/java2d/marlin/ArrayCacheSizeTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+import sun.java2d.marlin.ArrayCache;
+
+/**
+ * @test
+ * @bug 8144445
+ * @summary Check the ArrayCache getNewLargeSize() method
+ * @run main ArrayCacheSizeTest
+ */
+public class ArrayCacheSizeTest {
+
+ public static void main(String[] args) {
+ testNewSize();
+ testNewLargeSize();
+ }
+
+ private static void testNewSize() {
+ testNewSize(0, 1);
+ testNewSize(0, 100000);
+
+ testNewSize(4096, 4097);
+ testNewSize(4096 * 16, 4096 * 16 + 1);
+
+ testNewSize(4096 * 4096 * 4, 4096 * 4096 * 4 + 1);
+
+ testNewSize(4096 * 4096 * 4, Integer.MAX_VALUE);
+
+ testNewSize(Integer.MAX_VALUE - 1000, Integer.MAX_VALUE);
+
+ testNewSizeExpectAIOB(Integer.MAX_VALUE - 1000, Integer.MAX_VALUE + 1);
+ testNewSizeExpectAIOB(1, -1);
+ testNewSizeExpectAIOB(Integer.MAX_VALUE, -1);
+ }
+
+ private static void testNewSizeExpectAIOB(final int curSize,
+ final int needSize) {
+ try {
+ testNewSize(curSize, needSize);
+ throw new RuntimeException("ArrayIndexOutOfBoundsException not thrown");
+ } catch (ArrayIndexOutOfBoundsException aiobe) {
+ System.out.println("ArrayIndexOutOfBoundsException expected.");
+ } catch (RuntimeException re) {
+ throw re;
+ } catch (Throwable th) {
+ throw new RuntimeException("Unexpected exception", th);
+ }
+ }
+
+ private static void testNewSize(final int curSize,
+ final int needSize) {
+
+ int size = ArrayCache.getNewSize(curSize, needSize);
+
+ System.out.println("getNewSize(" + curSize + ", " + needSize
+ + ") = " + size);
+
+ if (size < 0 || size < needSize) {
+ throw new IllegalStateException("Invalid getNewSize("
+ + curSize + ", " + needSize + ") = " + size + " !");
+ }
+ }
+
+ private static void testNewLargeSize() {
+ testNewLargeSize(0, 1);
+ testNewLargeSize(0, 100000);
+
+ testNewLargeSize(4096, 4097);
+ testNewLargeSize(4096 * 16, 4096 * 16 + 1);
+
+ testNewLargeSize(4096 * 4096 * 4, 4096 * 4096 * 4 + 1);
+
+ testNewLargeSize(4096 * 4096 * 4, Integer.MAX_VALUE);
+
+ testNewLargeSize(Integer.MAX_VALUE - 1000, Integer.MAX_VALUE);
+
+ testNewLargeSizeExpectAIOB(Integer.MAX_VALUE - 1000, Integer.MAX_VALUE + 1L);
+ testNewLargeSizeExpectAIOB(1, -1L);
+ testNewLargeSizeExpectAIOB(Integer.MAX_VALUE, -1L);
+ }
+
+ private static void testNewLargeSizeExpectAIOB(final long curSize,
+ final long needSize) {
+ try {
+ testNewLargeSize(curSize, needSize);
+ throw new RuntimeException("ArrayIndexOutOfBoundsException not thrown");
+ } catch (ArrayIndexOutOfBoundsException aiobe) {
+ System.out.println("ArrayIndexOutOfBoundsException expected.");
+ } catch (RuntimeException re) {
+ throw re;
+ } catch (Throwable th) {
+ throw new RuntimeException("Unexpected exception", th);
+ }
+ }
+
+ private static void testNewLargeSize(final long curSize,
+ final long needSize) {
+
+ long size = ArrayCache.getNewLargeSize(curSize, needSize);
+
+ System.out.println("getNewLargeSize(" + curSize + ", " + needSize
+ + ") = " + size);
+
+ if (size < 0 || size < needSize || size > Integer.MAX_VALUE) {
+ throw new IllegalStateException("Invalid getNewLargeSize("
+ + curSize + ", " + needSize + ") = " + size + " !");
+ }
+ }
+
+}
--- a/jdk/test/sun/java2d/marlin/CrashTest.java Mon Dec 14 09:27:15 2015 -0800
+++ b/jdk/test/sun/java2d/marlin/CrashTest.java Mon Dec 14 10:36:12 2015 -0800
@@ -31,31 +31,44 @@
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
-import sun.java2d.pipe.RenderingEngine;
/**
- * Simple crash rendering test using huge GeneralPaths with marlin renderer
- *
- * run it with large heap (2g):
- * java -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine marlin.CrashTest
- *
- * @author bourgesl
- */
+ * @test
+ * @summary Simple crash rendering test using huge GeneralPaths with the Marlin renderer
+ * @run main/othervm -mx512m CrashTest
+ * @ignore tests that take a long time and consumes 5Gb memory
+ * @run main/othervm -ms4g -mx4g CrashTest -slow
+*/
public class CrashTest {
static final boolean SAVE_IMAGE = false;
static boolean USE_ROUND_CAPS_AND_JOINS = true;
public static void main(String[] args) {
+ boolean runSlowTests = (args.length != 0 && "-slow".equals(args[0]));
+
+ // First display which renderer is tested:
+ System.setProperty("sun.java2d.renderer.verbose", "true");
+
// try insane image sizes:
// subpixel coords may overflow:
-// testHugeImage((Integer.MAX_VALUE >> 3) + 1, 6);
+ // check MAX_VALUE / (8 * 2); overflow may happen due to orientation flag
+ // But as it is impossible to allocate an image larger than 2Gb (byte) then
+ // it is also impossible to have rowAAChunk larger than 2Gb !
+
+ // Disabled test as it consumes 4GB heap + offheap (2Gb) ie > 6Gb !
+ if (runSlowTests) {
+ testHugeImage((Integer.MAX_VALUE >> 4) - 100, 16);
+ }
+
// larger than 23 bits: (RLE)
testHugeImage(8388608 + 1, 10);
- test(0.1f, false, 0);
- test(0.1f, true, 7f);
+ if (runSlowTests) {
+ test(0.1f, false, 0);
+ test(0.1f, true, 7f);
+ }
// Exceed 2Gb OffHeap buffer for edges:
try {
@@ -67,17 +80,15 @@
if (th instanceof ArrayIndexOutOfBoundsException) {
System.out.println("ArrayIndexOutOfBoundsException expected.");
} else {
- System.out.println("Exception occured:");
- th.printStackTrace();
+ throw new RuntimeException("Unexpected exception", th);
}
}
-
}
private static void test(final float lineStroke,
final boolean useDashes,
final float dashMinLen)
- throws ArrayIndexOutOfBoundsException
+ throws ArrayIndexOutOfBoundsException
{
System.out.println("---\n" + "test: "
+ "lineStroke=" + lineStroke
@@ -85,9 +96,6 @@
+", dashMinLen=" + dashMinLen
);
- final String renderer = RenderingEngine.getInstance().getClass().getSimpleName();
- System.out.println("Testing renderer = " + renderer);
-
final BasicStroke stroke = createStroke(lineStroke, useDashes, dashMinLen);
// TODO: test Dasher.firstSegmentsBuffer resizing ?
@@ -135,7 +143,7 @@
if (SAVE_IMAGE) {
try {
- final File file = new File("CrashTest-" + renderer + "-dash-" + useDashes + ".bmp");
+ final File file = new File("CrashTest-dash-" + useDashes + ".bmp");
System.out.println("Writing file: " + file.getAbsolutePath());
ImageIO.write(image, "BMP", file);
@@ -150,15 +158,10 @@
}
private static void testHugeImage(final int width, final int height)
- throws ArrayIndexOutOfBoundsException
+ throws ArrayIndexOutOfBoundsException
{
System.out.println("---\n" + "testHugeImage: "
- + "width=" + width
- + ", height=" + height
- );
-
- final String renderer = RenderingEngine.getInstance().getClass().getSimpleName();
- System.out.println("Testing renderer = " + renderer);
+ + "width=" + width + ", height=" + height);
final BasicStroke stroke = createStroke(2.5f, false, 0);
@@ -195,8 +198,8 @@
if (SAVE_IMAGE) {
try {
- final File file = new File("CrashTest-" + renderer +
- "-huge-" + width + "x" +height + ".bmp");
+ final File file = new File("CrashTest-huge-"
+ + width + "x" +height + ".bmp");
System.out.println("Writing file: " + file.getAbsolutePath());
ImageIO.write(image, "BMP", file);