# HG changeset patch # User lana # Date 1361335959 28800 # Node ID 3b0464b381cc7e90703b877efcc5050b73f3ff6c # Parent 3569e84e74294afbb8490eab2f65c0ce2a9607aa# Parent c6c397d4cbaca3e726a1975d00b20e5b0c744155 Merge diff -r 3569e84e7429 -r 3b0464b381cc jdk/.hgtags --- a/jdk/.hgtags Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/.hgtags Tue Feb 19 20:52:39 2013 -0800 @@ -198,3 +198,4 @@ 57d5d954462831ac353a1f40d3bb05ddb4620952 jdk8-b74 4a67fdb752b7d6329d9be9c28d3f9d6cf7eb9a3c jdk8-b75 3a263052866137b645ab86498a43693ff5c19e69 jdk8-b76 +b2fc8e31cecc35b76188e821d4c5dc0e0b74ac24 jdk8-b77 diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Tue Feb 19 20:52:39 2013 -0800 @@ -30,6 +30,8 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.print.*; +import java.security.AccessController; +import java.security.PrivilegedAction; import javax.print.*; import javax.print.attribute.PrintRequestAttributeSet; @@ -47,6 +49,8 @@ private static String sShouldNotReachHere = "Should not reach here."; + private volatile SecondaryLoop printingLoop; + private boolean noDefaultPrinter = false; private static Font defaultFont; @@ -160,11 +164,22 @@ volatile boolean onEventThread; + @Override + protected void cancelDoc() throws PrinterAbortException { + super.cancelDoc(); + if (printingLoop != null) { + printingLoop.exit(); + } + } + private void completePrintLoop() { Runnable r = new Runnable() { public void run() { synchronized(this) { performingPrinting = false; } + if (printingLoop != null) { + printingLoop.exit(); + } }}; if (onEventThread) { @@ -219,17 +234,21 @@ onEventThread = true; + printingLoop = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public SecondaryLoop run() { + return Toolkit.getDefaultToolkit() + .getSystemEventQueue() + .createSecondaryLoop(); + } + }); + try { // Fire off the print rendering loop on the AppKit thread, and don't have // it wait and block this thread. if (printLoop(false, firstPage, lastPage)) { - // Fire off the EventConditional that will what until the condition is met, - // but will still process AWTEvent's as they occur. - new EventDispatchAccess() { - public boolean evaluate() { - return performingPrinting; - } - }.pumpEventsAndWait(); + // Start a secondary loop on EDT until printing operation is finished or cancelled + printingLoop.enter(); } } catch (Exception e) { e.printStackTrace(); @@ -253,6 +272,9 @@ performingPrinting = false; notify(); } + if (printingLoop != null) { + printingLoop.exit(); + } } // Normalize the collated, # copies, numPages, first/last pages. Need to diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/macosx/classes/sun/lwawt/macosx/EventDispatchAccess.java --- a/jdk/src/macosx/classes/sun/lwawt/macosx/EventDispatchAccess.java Tue Feb 19 16:49:28 2013 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.lwawt.macosx; - -// This exists strictly to work around the fact that java.awt.Conditional isn't a public class. -// It uses java reflection to get the EventDispatchThread class and call a MacOSX only -// method on it. -// -// NOTE: This uses reflection in its implementation, so it is not for performance critical code. -// -// See java.awt.EventDispatchThread and apple.awt.CPrintJob for more. -// -public abstract class EventDispatchAccess { - public native void pumpEventsAndWait(); - public abstract boolean evaluate(); -} diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/macosx/lib/flavormap.properties --- a/jdk/src/macosx/lib/flavormap.properties Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/macosx/lib/flavormap.properties Tue Feb 19 20:52:39 2013 -0800 @@ -1,7 +1,7 @@ # # This properties file is used to initialize the default -# java.awt.datatransfer.SystemFlavorMap. It contains the X11 platform-specific, -# default mappings between common X11 selection atoms and platform-independent +# java.awt.datatransfer.SystemFlavorMap. It contains the Mac OS X platform-specific, +# default mappings between common Mac OS X selection atoms and platform-independent # MIME type strings, which will be converted into # java.awt.datatransfer.DataFlavors. # @@ -76,3 +76,5 @@ text/uri-list=application/x-java-file-list;class=java.util.List PNG=image/x-java-image;class=java.awt.Image JFIF=image/x-java-image;class=java.awt.Image +RICH_TEXT=text/rtf +HTML=text/html;charset=utf-8;eoln="\r\n";terminators=1 diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/macosx/native/jobjc/src/core/native/SEL.m --- a/jdk/src/macosx/native/jobjc/src/core/native/SEL.m Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/macosx/native/jobjc/src/core/native/SEL.m Tue Feb 19 20:52:39 2013 -0800 @@ -34,7 +34,7 @@ const char *selNameAsChars = (*env)->GetStringUTFChars(env, selName, JNI_FALSE); const SEL sel = sel_registerName(selNameAsChars); (*env)->ReleaseStringUTFChars(env, selName, selNameAsChars); - return ptr_to_jlong(sel); + return ptr_to_jlong((void*)sel); } JNIEXPORT jstring JNICALL Java_com_apple_jobjc_SEL_getSelectorName diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/macosx/native/sun/awt/CPrinterJob.m --- a/jdk/src/macosx/native/sun/awt/CPrinterJob.m Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/macosx/native/sun/awt/CPrinterJob.m Tue Feb 19 20:52:39 2013 -0800 @@ -384,31 +384,6 @@ } /* - * Class: sun_lwawt_macosx_EventDispatchAccess - * Method: pumpEventsAndWait - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_sun_lwawt_macosx_EventDispatchAccess_pumpEventsAndWait -(JNIEnv *env, jobject eda) -{ - static JNF_CLASS_CACHE(jc_Thread, "java/lang/Thread"); - static JNF_STATIC_MEMBER_CACHE(jm_currentThread, jc_Thread, "currentThread", "()Ljava/lang/Thread;"); - static JNF_CLASS_CACHE(jc_EventDispatchThread, "java/awt/EventDispatchThread"); - static JNF_MEMBER_CACHE(jm_macosxGetConditional, jc_EventDispatchThread, "_macosxGetConditional", "(Ljava/lang/Object;)Ljava/awt/Conditional;"); - static JNF_MEMBER_CACHE(jm_pumpEvents, jc_EventDispatchThread, "pumpEvents", "(Ljava/awt/Conditional;)V"); - -JNF_COCOA_DURING(env); - - jobject thread = JNFCallStaticObjectMethod(env, jm_currentThread); - jobject conditional = JNFCallObjectMethod(env, thread, jm_macosxGetConditional, eda); - if (conditional != NULL) { - JNFCallVoidMethod(env, thread, jm_pumpEvents, conditional); - } - -JNF_COCOA_HANDLE(env); -} - -/* * Class: sun_lwawt_macosx_CPrinterJob * Method: abortDoc * Signature: ()V diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/classes/java/awt/EventDispatchThread.java --- a/jdk/src/share/classes/java/awt/EventDispatchThread.java Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/classes/java/awt/EventDispatchThread.java Tue Feb 19 20:52:39 2013 -0800 @@ -107,34 +107,6 @@ } } - // MacOSX change: - // This was added because this class (and java.awt.Conditional) are package private. - // There are certain instances where classes in other packages need to block the - // AWTEventQueue while still allowing it to process events. This uses reflection - // to call back into the caller in order to remove dependencies. - // - // NOTE: This uses reflection in its implementation, so it is not for performance critical code. - // - // cond is an instance of sun.lwawt.macosx.EventDispatchAccess - // - private Conditional _macosxGetConditional(final Object cond) { - try { - return new Conditional() { - final Method evaluateMethod = Class.forName("sun.lwawt.macosx.EventDispatchAccess").getMethod("evaluate", null); - public boolean evaluate() { - try { - return ((Boolean)evaluateMethod.invoke(cond, null)).booleanValue(); - } catch (Exception e) { - return false; - } - } - }; - } catch (Exception e) { - return new Conditional() { public boolean evaluate() { return false; } }; - } - } - - void pumpEvents(Conditional cond) { pumpEvents(ANY_EVENT, cond); } diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/classes/javax/swing/JMenuBar.java --- a/jdk/src/share/classes/javax/swing/JMenuBar.java Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/classes/javax/swing/JMenuBar.java Tue Feb 19 20:52:39 2013 -0800 @@ -70,7 +70,14 @@ * of all JavaBeansTM * has been added to the java.beans package. * Please see {@link java.beans.XMLEncoder}. - * + *

+ * Warning: + * By default, pressing the Tab key does not transfer focus from a + * JMenuBar which is added to a container together with other Swing + * components, because the focusTraversalKeysEnabled property + * of JMenuBar is set to false. To resolve this, + * you should call the JMenuBar.setFocusTraversalKeysEnabled(true) + * method. * @beaninfo * attribute: isContainer true * description: A container for holding and displaying menus. diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java Tue Feb 19 20:52:39 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -1120,7 +1120,9 @@ listBox.setSelectedIndex( si + 1 ); listBox.ensureIndexIsVisible( si + 1 ); if ( !isTableCellEditor ) { - comboBox.setSelectedIndex(si+1); + if (!(UIManager.getBoolean("ComboBox.noActionOnKeyNavigation") && comboBox.isPopupVisible())) { + comboBox.setSelectedIndex(si+1); + } } comboBox.repaint(); } @@ -1144,7 +1146,9 @@ listBox.setSelectedIndex( si - 1 ); listBox.ensureIndexIsVisible( si - 1 ); if ( !isTableCellEditor ) { - comboBox.setSelectedIndex(si-1); + if (!(UIManager.getBoolean("ComboBox.noActionOnKeyNavigation") && comboBox.isPopupVisible())) { + comboBox.setSelectedIndex(si-1); + } } comboBox.repaint(); } @@ -1490,7 +1494,13 @@ key == HOME || key == END) { int index = getNextIndex(comboBox, key); if (index >= 0 && index < comboBox.getItemCount()) { - comboBox.setSelectedIndex(index); + if (UIManager.getBoolean("ComboBox.noActionOnKeyNavigation") && comboBox.isPopupVisible()) { + ui.listBox.setSelectedIndex(index); + ui.listBox.ensureIndexIsVisible(index); + comboBox.repaint(); + } else { + comboBox.setSelectedIndex(index); + } } } else if (key == DOWN) { @@ -1558,22 +1568,33 @@ else if (key == ENTER) { if (comboBox.isPopupVisible()) { - // Forces the selection of the list item - boolean isEnterSelectablePopup = - UIManager.getBoolean("ComboBox.isEnterSelectablePopup"); - if (!comboBox.isEditable() || isEnterSelectablePopup - || ui.isTableCellEditor) { + // If ComboBox.noActionOnKeyNavigation is set, + // forse selection of list item + if (UIManager.getBoolean("ComboBox.noActionOnKeyNavigation")) { Object listItem = ui.popup.getList().getSelectedValue(); if (listItem != null) { - // Use the selected value from popup - // to set the selected item in combo box, - // but ensure before that JComboBox.actionPerformed() - // won't use editor's value to set the selected item comboBox.getEditor().setItem(listItem); comboBox.setSelectedItem(listItem); } + comboBox.setPopupVisible(false); + } else { + // Forces the selection of the list item + boolean isEnterSelectablePopup = + UIManager.getBoolean("ComboBox.isEnterSelectablePopup"); + if (!comboBox.isEditable() || isEnterSelectablePopup + || ui.isTableCellEditor) { + Object listItem = ui.popup.getList().getSelectedValue(); + if (listItem != null) { + // Use the selected value from popup + // to set the selected item in combo box, + // but ensure before that JComboBox.actionPerformed() + // won't use editor's value to set the selected item + comboBox.getEditor().setItem(listItem); + comboBox.setSelectedItem(listItem); + } + } + comboBox.setPopupVisible(false); } - comboBox.setPopupVisible(false); } else { // Hide combo box if it is a table cell editor @@ -1604,14 +1625,20 @@ } private int getNextIndex(JComboBox comboBox, String key) { + int listHeight = comboBox.getMaximumRowCount(); + + int selectedIndex = comboBox.getSelectedIndex(); + if (UIManager.getBoolean("ComboBox.noActionOnKeyNavigation") + && (comboBox.getUI() instanceof BasicComboBoxUI)) { + selectedIndex = ((BasicComboBoxUI) comboBox.getUI()).listBox.getSelectedIndex(); + } + if (key == PAGE_UP) { - int listHeight = comboBox.getMaximumRowCount(); - int index = comboBox.getSelectedIndex() - listHeight; + int index = selectedIndex - listHeight; return (index < 0 ? 0: index); } else if (key == PAGE_DOWN) { - int listHeight = comboBox.getMaximumRowCount(); - int index = comboBox.getSelectedIndex() + listHeight; + int index = selectedIndex + listHeight; int max = comboBox.getItemCount(); return (index < max ? index: max-1); } diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java Tue Feb 19 20:52:39 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -861,6 +861,7 @@ "END", "endPassThrough", "ENTER", "enterPressed" }), + "ComboBox.noActionOnKeyNavigation", Boolean.FALSE, // *** FileChooser diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java --- a/jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java Tue Feb 19 20:52:39 2013 -0800 @@ -33,6 +33,7 @@ import java.awt.font.TextAttribute; import java.awt.font.TextHitInfo; import java.awt.im.InputMethodRequests; +import java.lang.ref.WeakReference; import java.text.AttributedCharacterIterator; import java.text.AttributedCharacterIterator.Attribute; import java.text.AttributedString; @@ -55,7 +56,7 @@ private AttributedCharacterIterator composedText; private TextHitInfo caret = null; - private Component clientComponent = null; + private WeakReference clientComponent = new WeakReference<>(null); private InputMethodContext inputMethodContext; /** @@ -76,8 +77,9 @@ } // If the client component is an active client using below-the-spot style, then // make the composition window undecorated without a title bar. - if(clientComponent!=null){ - InputMethodRequests req = clientComponent.getInputMethodRequests(); + Component client = clientComponent.get(); + if(client != null){ + InputMethodRequests req = client.getInputMethodRequests(); if (req != null && inputMethodContext.useBelowTheSpotInput()) { setCompositionAreaUndecorated(true); } @@ -86,7 +88,7 @@ } void setClientComponent(Component clientComponent) { - this.clientComponent = clientComponent; + this.clientComponent = new WeakReference<>(clientComponent); } /** @@ -256,8 +258,9 @@ * the composed text are forwarded to the client component. */ InputMethodRequests getClientInputMethodRequests() { - if (clientComponent != null) { - return clientComponent.getInputMethodRequests(); + Component client = clientComponent.get(); + if (client != null) { + return client.getInputMethodRequests(); } return null; diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c --- a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Tue Feb 19 20:52:39 2013 -0800 @@ -2694,6 +2694,11 @@ scale[i] = (UINT8*) malloc((maxBandValue + 1) * sizeof(UINT8)); if (scale[i] == NULL) { + // Cleanup before throwing an out of memory exception + for (j = 0; j < i; j++) { + free(scale[j]); + } + free(scale); JNU_ThrowByName( env, "java/lang/OutOfMemoryError", "Writing JPEG Stream"); return JNI_FALSE; diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_ImageConv.h --- a/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv.h Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv.h Tue Feb 19 20:52:39 2013 -0800 @@ -31,6 +31,16 @@ extern "C" { #endif /* __cplusplus */ +// Shared macro defined for cleanup of allocated memory. +#ifndef FREE_AND_RETURN_STATUS +#define FREE_AND_RETURN_STATUS \ +{ \ +if (pbuff != buff) mlib_free(pbuff); \ +if (k != akernel) mlib_free(k); \ +return status; \ +} +#endif /* FREE_AND_RETURN_STATUS */ + void mlib_ImageXor80_aa(mlib_u8 *dl, mlib_s32 wid, mlib_s32 hgt, diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_ImageConvMxN_ext.c --- a/jdk/src/share/native/sun/awt/medialib/mlib_ImageConvMxN_ext.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_ImageConvMxN_ext.c Tue Feb 19 20:52:39 2013 -0800 @@ -253,8 +253,10 @@ if (mn > 256) { dkernel = mlib_malloc(mn * sizeof(mlib_d64)); - if (dkernel == NULL) + if (dkernel == NULL) { + if (dsa != dspace) mlib_free(dsa); return MLIB_FAILURE; + } } while (scale > 30) { diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16ext.c --- a/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16ext.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16ext.c Tue Feb 19 20:52:39 2013 -0800 @@ -1884,6 +1884,8 @@ mlib_s32 nchannel, chan1, chan2; mlib_s32 i, j, c, swid; d64_2x32 dd; + mlib_status status = MLIB_SUCCESS; + GET_SRC_DST_PARAMETERS(DTYPE); if (scale > 30) { @@ -1905,7 +1907,10 @@ k[i] = kernel[i]*fscale; } - if (m == 1) return mlib_ImageConv1xN_ext(dst, src, k, n, dy_t, dy_b, cmask); + if (m == 1) { + status = mlib_ImageConv1xN_ext(dst, src, k, n, dy_t, dy_b, cmask); + FREE_AND_RETURN_STATUS; + } swid = wid + (m - 1); @@ -1914,7 +1919,10 @@ if ((bsize > BUFF_SIZE) || (n > MAX_N)) { pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1)); - if (pbuff == NULL) return MLIB_FAILURE; + if (pbuff == NULL) { + status = MLIB_FAILURE; + FREE_AND_RETURN_STATUS; + } buffs = (FTYPE **)(pbuff + bsize); } @@ -2318,9 +2326,7 @@ } } - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; + FREE_AND_RETURN_STATUS; } /***************************************************************/ diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16nw.c --- a/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16nw.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16nw.c Tue Feb 19 20:52:39 2013 -0800 @@ -1651,6 +1651,8 @@ DEF_VARS(DTYPE); mlib_s32 chan2; mlib_s32 *buffo, *buffi; + mlib_status status = MLIB_SUCCESS; + GET_SRC_DST_PARAMETERS(DTYPE); if (scale > 30) { @@ -1672,14 +1674,20 @@ k[i] = kernel[i]*fscale; } - if (m == 1) return mlib_ImageConv1xN(dst, src, k, n, dn, cmask); + if (m == 1) { + status = mlib_ImageConv1xN(dst, src, k, n, dn, cmask); + FREE_AND_RETURN_STATUS; + } bsize = (n + 3)*wid; if ((bsize > BUFF_SIZE) || (n > MAX_N)) { pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1)); - if (pbuff == NULL) return MLIB_FAILURE; + if (pbuff == NULL) { + status = MLIB_FAILURE; + FREE_AND_RETURN_STATUS; + } buffs = (FTYPE **)(pbuff + bsize); } @@ -2033,9 +2041,7 @@ } } - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; + FREE_AND_RETURN_STATUS; } /***************************************************************/ diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_32nw.c --- a/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_32nw.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_32nw.c Tue Feb 19 20:52:39 2013 -0800 @@ -1160,6 +1160,8 @@ DEF_VARS_MxN(mlib_s32); mlib_s32 chan2 = chan1 + chan1; + mlib_status status = MLIB_SUCCESS; + if (scale > 30) { fscale *= 1.0/(1 << 30); scale -= 30; @@ -1179,14 +1181,20 @@ k[i] = kernel[i]*fscale; } - if (m == 1) return mlib_ImageConv1xN(dst, src, k, n, dn, cmask); + if (m == 1) { + status = mlib_ImageConv1xN(dst, src, k, n, dn, cmask); + FREE_AND_RETURN_STATUS; + } bsize = (n + 2)*wid; if ((bsize > BUFF_SIZE) || (n > MAX_N)) { pbuff = mlib_malloc(sizeof(mlib_d64)*bsize + sizeof(mlib_d64*)*2*(n + 1)); - if (pbuff == NULL) return MLIB_FAILURE; + if (pbuff == NULL) { + status = MLIB_FAILURE; + FREE_AND_RETURN_STATUS; + } buffs = (mlib_d64**)(pbuff + bsize); } @@ -1531,9 +1539,7 @@ } } - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; + FREE_AND_RETURN_STATUS; } /***************************************************************/ diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_8ext.c --- a/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_8ext.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_8ext.c Tue Feb 19 20:52:39 2013 -0800 @@ -1884,6 +1884,8 @@ mlib_s32 nchannel, chan1, chan2; mlib_s32 i, j, c, swid; d64_2x32 dd; + mlib_status status = MLIB_SUCCESS; + GET_SRC_DST_PARAMETERS(DTYPE); if (scale > 30) { @@ -1905,7 +1907,10 @@ k[i] = kernel[i]*fscale; } - if (m == 1) return mlib_ImageConv1xN_ext(dst, src, k, n, dy_t, dy_b, cmask); + if (m == 1) { + status = mlib_ImageConv1xN_ext(dst, src, k, n, dy_t, dy_b, cmask); + FREE_AND_RETURN_STATUS; + } swid = wid + (m - 1); @@ -1914,7 +1919,10 @@ if ((bsize > BUFF_SIZE) || (n > MAX_N)) { pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1)); - if (pbuff == NULL) return MLIB_FAILURE; + if (pbuff == NULL) { + status = MLIB_FAILURE; + FREE_AND_RETURN_STATUS; + } buffs = (FTYPE **)(pbuff + bsize); } @@ -2318,9 +2326,7 @@ } } - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; + FREE_AND_RETURN_STATUS; } /***************************************************************/ diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_8nw.c --- a/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_8nw.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_8nw.c Tue Feb 19 20:52:39 2013 -0800 @@ -1652,6 +1652,8 @@ DEF_VARS(DTYPE); mlib_s32 chan2; mlib_s32 *buffo, *buffi; + mlib_status status = MLIB_SUCCESS; + GET_SRC_DST_PARAMETERS(DTYPE); if (scale > 30) { @@ -1673,14 +1675,20 @@ k[i] = kernel[i]*fscale; } - if (m == 1) return mlib_ImageConv1xN(dst, src, k, n, dn, cmask); + if (m == 1) { + status = mlib_ImageConv1xN(dst, src, k, n, dn, cmask); + FREE_AND_RETURN_STATUS; + } bsize = (n + 3)*wid; if ((bsize > BUFF_SIZE) || (n > MAX_N)) { pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1)); - if (pbuff == NULL) return MLIB_FAILURE; + if (pbuff == NULL) { + status = MLIB_FAILURE; + FREE_AND_RETURN_STATUS; + } buffs = (FTYPE **)(pbuff + bsize); } @@ -2034,9 +2042,7 @@ } } - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; + FREE_AND_RETURN_STATUS; } /***************************************************************/ diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_u16ext.c --- a/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_u16ext.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_u16ext.c Tue Feb 19 20:52:39 2013 -0800 @@ -1884,6 +1884,8 @@ mlib_s32 nchannel, chan1, chan2; mlib_s32 i, j, c, swid; d64_2x32 dd; + mlib_status status = MLIB_SUCCESS; + GET_SRC_DST_PARAMETERS(DTYPE); if (scale > 30) { @@ -1905,7 +1907,10 @@ k[i] = kernel[i]*fscale; } - if (m == 1) return mlib_ImageConv1xN_ext(dst, src, k, n, dy_t, dy_b, cmask); + if (m == 1) { + status = mlib_ImageConv1xN_ext(dst, src, k, n, dy_t, dy_b, cmask); + FREE_AND_RETURN_STATUS; + } swid = wid + (m - 1); @@ -1914,7 +1919,10 @@ if ((bsize > BUFF_SIZE) || (n > MAX_N)) { pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1)); - if (pbuff == NULL) return MLIB_FAILURE; + if (pbuff == NULL) { + status = MLIB_FAILURE; + FREE_AND_RETURN_STATUS; + } buffs = (FTYPE **)(pbuff + bsize); } @@ -2318,9 +2326,7 @@ } } - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; + FREE_AND_RETURN_STATUS; } /***************************************************************/ diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_u16nw.c --- a/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_u16nw.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_u16nw.c Tue Feb 19 20:52:39 2013 -0800 @@ -1651,6 +1651,8 @@ DEF_VARS(DTYPE); mlib_s32 chan2; mlib_s32 *buffo, *buffi; + mlib_status status = MLIB_SUCCESS; + GET_SRC_DST_PARAMETERS(DTYPE); if (scale > 30) { @@ -1672,14 +1674,20 @@ k[i] = kernel[i]*fscale; } - if (m == 1) return mlib_ImageConv1xN(dst, src, k, n, dn, cmask); + if (m == 1) { + status = mlib_ImageConv1xN(dst, src, k, n, dn, cmask); + FREE_AND_RETURN_STATUS; + } bsize = (n + 3)*wid; if ((bsize > BUFF_SIZE) || (n > MAX_N)) { pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1)); - if (pbuff == NULL) return MLIB_FAILURE; + if (pbuff == NULL) { + status = MLIB_FAILURE; + FREE_AND_RETURN_STATUS; + } buffs = (FTYPE **)(pbuff + bsize); } @@ -2033,9 +2041,7 @@ } } - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; + FREE_AND_RETURN_STATUS; } /***************************************************************/ diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_ImageCreate.c --- a/jdk/src/share/native/sun/awt/medialib/mlib_ImageCreate.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_ImageCreate.c Tue Feb 19 20:52:39 2013 -0800 @@ -477,9 +477,9 @@ im_height = mlib_ImageGetHeight(img); im_stride = mlib_ImageGetStride(img); tline = mlib_ImageGetData(img); + if (tline == NULL) return NULL; rtable = mlib_malloc((3 + im_height)*sizeof(mlib_u8 *)); - - if (rtable == NULL || tline == NULL) return NULL; + if (rtable == NULL) return NULL; rtable[0] = 0; rtable[1] = (mlib_u8*)((void **)rtable + 1); diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/share/native/sun/awt/medialib/mlib_c_ImageConv.h --- a/jdk/src/share/native/sun/awt/medialib/mlib_c_ImageConv.h Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_c_ImageConv.h Tue Feb 19 20:52:39 2013 -0800 @@ -31,6 +31,16 @@ extern "C" { #endif /* __cplusplus */ +// Shared macro defined for cleanup of allocated memory. +#ifndef FREE_AND_RETURN_STATUS +#define FREE_AND_RETURN_STATUS \ +{ \ +if (pbuff != buff) mlib_free(pbuff); \ +if (k != akernel) mlib_free(k); \ +return status; \ +} +#endif /* FREE_AND_RETURN_STATUS */ + mlib_status mlib_c_conv2x2ext_s16(mlib_image *dst, const mlib_image *src, mlib_s32 dx_l, diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java --- a/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java Tue Feb 19 20:52:39 2013 -0800 @@ -92,7 +92,7 @@ } XIconSize[] sizeList = getIconSizes(); - log.finest("Icon sizes: {0}", sizeList); + log.finest("Icon sizes: {0}", (Object[]) sizeList); if (sizeList == null) { // No icon sizes so we simply fall back to 16x16 return new Dimension(16, 16); diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/solaris/classes/sun/awt/X11InputMethod.java --- a/jdk/src/solaris/classes/sun/awt/X11InputMethod.java Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/solaris/classes/sun/awt/X11InputMethod.java Tue Feb 19 20:52:39 2013 -0800 @@ -57,6 +57,7 @@ import java.io.FileReader; import java.io.BufferedReader; import java.io.IOException; +import java.lang.ref.WeakReference; import sun.util.logging.PlatformLogger; import java.util.StringTokenizer; import java.util.regex.Pattern; @@ -104,7 +105,7 @@ //reset the XIC if necessary private boolean needResetXIC = false; - private Component needResetXICClient = null; + private WeakReference needResetXICClient = new WeakReference<>(null); // The use of compositionEnableSupported is to reduce unnecessary // native calls if set/isCompositionEnabled @@ -272,14 +273,14 @@ called on the passive client when endComposition is called. */ if (needResetXIC && haveActiveClient() && - getClientComponent() != needResetXICClient){ + getClientComponent() != needResetXICClient.get()){ resetXIC(); // needs to reset the last xic focussed component. lastXICFocussedComponent = null; isLastXICActive = false; - needResetXICClient = null; + needResetXICClient.clear(); needResetXIC = false; } } @@ -417,7 +418,7 @@ isLastXICActive = false; resetXIC(); - needResetXICClient = null; + needResetXICClient.clear(); needResetXIC = false; } } @@ -478,7 +479,7 @@ disableInputMethod(); if (needResetXIC) { resetXIC(); - needResetXICClient = null; + needResetXICClient.clear(); needResetXIC = false; } } @@ -877,7 +878,7 @@ boolean active = haveActiveClient(); if (active && composedText == null && committedText == null){ needResetXIC = true; - needResetXICClient = getClientComponent(); + needResetXICClient = new WeakReference<>(getClientComponent()); return; } diff -r 3569e84e7429 -r 3b0464b381cc jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c --- a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c Tue Feb 19 16:49:28 2013 -0800 +++ b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c Tue Feb 19 20:52:39 2013 -0800 @@ -57,22 +57,23 @@ jobject peer, jlong aData) { #ifndef HEADLESS - OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd, - sizeof(OGLSDOps)); GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps)); - J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps"); - - if (oglsdo == NULL) { - JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); - return; - } - if (glxsdo == NULL) { JNU_ThrowOutOfMemoryError(env, "creating native GLX ops"); return; } + OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd, + sizeof(OGLSDOps)); + if (oglsdo == NULL) { + free(glxsdo); + JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); + return; + } + + J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps"); + oglsdo->privOps = glxsdo; oglsdo->sdOps.Lock = OGLSD_Lock; diff -r 3569e84e7429 -r 3b0464b381cc jdk/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/AbsoluteComponentCenterCalculator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/AbsoluteComponentCenterCalculator.java Tue Feb 19 20:52:39 2013 -0800 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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.*; + +class AbsoluteComponentCenterCalculator { + private AbsoluteComponentCenterCalculator() { + } + + public static int calculateXCenterCoordinate(Component component) { + return (int) component.getLocationOnScreen().getX() + (component.getWidth() / 2); + } + + public static int calculateYCenterCoordinate(Component component) { + return (int) component.getLocationOnScreen().getY() + (component.getHeight() / 2); + } +} diff -r 3569e84e7429 -r 3b0464b381cc jdk/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/DataFlavorSearcher.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/DataFlavorSearcher.java Tue Feb 19 20:52:39 2013 -0800 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2013, 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.datatransfer.DataFlavor; +import java.awt.datatransfer.FlavorTable; +import java.awt.datatransfer.SystemFlavorMap; +import java.util.Arrays; + +public class DataFlavorSearcher { + static public String[] HTML_NAMES = new String[]{"HTML", "HTML Format"}; + static public String[] RICH_TEXT_NAMES = new String[]{"RICH_TEXT", "Rich Text Format"}; + + static public DataFlavor getByteDataFlavorForNative(String[] nats) { + FlavorTable flavorTable = (FlavorTable) SystemFlavorMap.getDefaultFlavorMap(); + + for (String nat : nats) { + java.util.List flavors = flavorTable.getFlavorsForNative(nat); + for (DataFlavor flavor : flavors) { + if (flavor != null + && flavor.getRepresentationClass().equals(byte[].class)) { + return flavor; + } + } + } + throw new RuntimeException("No data flavor was found for natives: " + Arrays.toString(nats)); + } +} diff -r 3569e84e7429 -r 3b0464b381cc jdk/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/InterprocessMessages.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/InterprocessMessages.java Tue Feb 19 20:52:39 2013 -0800 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2013, 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. + */ + +interface InterprocessMessages { + final static int EXECUTION_IS_SUCCESSFULL = 0; + final static int DATA_IS_CORRUPTED = 212; +} + diff -r 3569e84e7429 -r 3b0464b381cc jdk/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html Tue Feb 19 20:52:39 2013 -0800 @@ -0,0 +1,27 @@ + +