diff --git a/.hgtags b/.hgtags index 6e2a50acf2f3b84f81797d10ddfe563e8f2a58ee..782b2fe371668a21439030152ae364f881bc3ee9 100644 --- a/.hgtags +++ b/.hgtags @@ -216,3 +216,5 @@ c63eda8f63008a4398d2c22ac8d72f7fef6f9238 jdk8-b90 a2a2a91075ad85becbe10a39d7fd04ef9bea8df5 jdk8-b92 691d6c6cd332d98b0f0221445a73906776f31f72 jdk8-b93 51479fa56b7c4363c6d87c2e8b898d8185cf4b22 jdk8-b94 +42aa9f1828852bb8b77e98ec695211493ae0759d jdk8-b95 +4a5d3cf2b3af1660db0237e8da324c140e534fa4 jdk8-b96 diff --git a/makefiles/CompileNativeLibraries.gmk b/makefiles/CompileNativeLibraries.gmk index 2fc34d8eea754e5f7bf032af069d78a20fa127c9..4fcb6e846950cce1b12a7b9b1eb2450063d08a4e 100644 --- a/makefiles/CompileNativeLibraries.gmk +++ b/makefiles/CompileNativeLibraries.gmk @@ -2916,7 +2916,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUNDALSA,\ PLATFORM_API_LinuxOS_ALSA_Ports.c,\ LANG:=C,\ OPTIMIZATION:=LOW, \ - CFLAGS:=$(CFLAGS_JDKLIB) \ + CFLAGS:=$(CFLAGS_JDKLIB) $(ALSA_CFLAGS) \ $(LIBJSOUND_CFLAGS) \ -DUSE_DAUDIO=TRUE \ -DUSE_PORTS=TRUE \ @@ -2925,7 +2925,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUNDALSA,\ MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjsoundalsa/mapfile-vers, \ LDFLAGS:=$(LDFLAGS_JDKLIB)\ $(call SET_SHARED_LIBRARY_ORIGIN),\ - LDFLAGS_SUFFIX:=-lasound -ljava -ljvm,\ + LDFLAGS_SUFFIX:=$(ALSA_LIBS) -ljava -ljvm,\ OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundalsa,\ DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES))) diff --git a/makefiles/CopyFiles.gmk b/makefiles/CopyFiles.gmk index 82d3d4bb40e2417f5020943668e4c27ac98084f4..cb479bba1c52ec19a8e617e244918d1fa1ba721c 100644 --- a/makefiles/CopyFiles.gmk +++ b/makefiles/CopyFiles.gmk @@ -538,21 +538,4 @@ COPY_FILES += $(JDK_OUTPUTDIR)/lib/sound.properties ########################################################################################## -ifndef OPENJDK -ifeq ($(ENABLE_JFR), true) - -JFR_CONFIGURATION_DIR_SRC := $(JDK_TOPDIR)/src/closed/share/classes/oracle/jrockit/jfr/settings/ -JFR_CONFIGURATION_DIR_DST := $(LIBDIR)/jfr/ - -JFR_SRC_FILES = $(wildcard $(JFR_CONFIGURATION_DIR_SRC)/*.jfc) -JFR_TARGET_FILES = $(subst $(JFR_CONFIGURATION_DIR_SRC),$(JFR_CONFIGURATION_DIR_DST),$(JFR_SRC_FILES)) - -$(JFR_CONFIGURATION_DIR_DST)/%.jfc : $(JFR_CONFIGURATION_DIR_SRC)/%.jfc - $(call install-file) - -COPY_FILES += $(JFR_TARGET_FILES) - -endif -endif - -########################################################################################## +-include $(CUSTOM_MAKE_DIR)/CopyFiles.gmk diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index eab279193dd13d9f5c44dcaba0430fadd114b513..7230b2eeeb5d5457f3fbe81451682c7d644ea2dd 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -812,8 +812,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo throw new RuntimeException("Unknown window state: " + windowState); } - nativeSynthesizeMouseEnteredExitedEvents(); - // NOTE: the SWP.windowState field gets updated to the newWindowState // value when the native notification comes to us } diff --git a/src/macosx/native/com/apple/laf/AquaFileView.m b/src/macosx/native/com/apple/laf/AquaFileView.m index 8f33cc5da8c7bd49d546e9bf449dade0a470f2a2..65fcc72abd3be44a39153b44a067a58de362b4c4 100644 --- a/src/macosx/native/com/apple/laf/AquaFileView.m +++ b/src/macosx/native/com/apple/laf/AquaFileView.m @@ -187,13 +187,13 @@ JNIEXPORT jstring JNICALL Java_com_apple_laf_AquaFileView_getNativePathForResolv JNF_COCOA_ENTER(env); UInt8 pathCString[MAXPATHLEN + 1]; - size_t pathSize = sizeof(pathCString); + size_t maxPathLen = sizeof(pathCString) - 1; jbyte *byteArray = (*env)->GetByteArrayElements(env, pathToAlias, NULL); jsize length = (*env)->GetArrayLength(env, pathToAlias); - if (length > pathSize) { - length = pathSize; + if (length > maxPathLen) { + length = maxPathLen; } strncpy((char *)pathCString, (char *)byteArray, length); // make sure it's null terminated diff --git a/src/macosx/native/sun/awt/AWTWindow.m b/src/macosx/native/sun/awt/AWTWindow.m index 2997ff4de7560c2306fe25a3664fdbcdbc30788b..2a596bcfa75bb6abe62d046a15f01efb65c0d3c4 100644 --- a/src/macosx/native/sun/awt/AWTWindow.m +++ b/src/macosx/native/sun/awt/AWTWindow.m @@ -447,6 +447,8 @@ AWT_ASSERT_APPKIT_THREAD; // TODO: create generic AWT assert } + [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; + NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]); static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V"); @@ -630,6 +632,7 @@ AWT_ASSERT_APPKIT_THREAD; [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_ENTER withEnv:env]; (*env)->DeleteLocalRef(env, platformWindow); } + [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; } - (void)windowWillExitFullScreen:(NSNotification *)notification { @@ -652,6 +655,7 @@ AWT_ASSERT_APPKIT_THREAD; [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_EXIT withEnv:env]; (*env)->DeleteLocalRef(env, platformWindow); } + [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; } - (void)sendEvent:(NSEvent *)event { @@ -891,8 +895,6 @@ JNF_COCOA_ENTER(env); // ensure we repaint the whole window after the resize operation // (this will also re-enable screen updates, which were disabled above) // TODO: send PaintEvent - - [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; }]; JNF_COCOA_EXIT(env); diff --git a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java index 1358908528b11ba7c7e8b2f4c2e7a2ae737a193e..7c0c39d8ffa81e70323a3d823de427db8dd98ade 100644 --- a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java +++ b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java @@ -285,10 +285,17 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { TimedWindowEvent we = (TimedWindowEvent)e; long time = we.getWhen(); synchronized (this) { - for (KeyEvent ke: enqueuedKeyEvents) { - if (time >= ke.getWhen()) { - SunToolkit.postEvent(AppContext.getAppContext(), new SequencedEvent(e)); - return true; + KeyEvent ke = enqueuedKeyEvents.isEmpty() ? null : enqueuedKeyEvents.getFirst(); + if (ke != null && time >= ke.getWhen()) { + TypeAheadMarker marker = typeAheadMarkers.getFirst(); + if (marker != null) { + Window toplevel = marker.untilFocused.getContainingWindow(); + // Check that the component awaiting focus belongs to + // the current focused window. See 8015454. + if (toplevel != null && toplevel.isFocused()) { + SunToolkit.postEvent(AppContext.getAppContext(), new SequencedEvent(e)); + return true; + } } } } diff --git a/src/share/classes/java/awt/color/ICC_Profile.java b/src/share/classes/java/awt/color/ICC_Profile.java index b459f63b16d40ae5c98bcceb344f35b226781026..c1534249f391a14a30d261e81b3810920a27ffda 100644 --- a/src/share/classes/java/awt/color/ICC_Profile.java +++ b/src/share/classes/java/awt/color/ICC_Profile.java @@ -37,6 +37,7 @@ package java.awt.color; import sun.java2d.cmm.PCMM; import sun.java2d.cmm.CMSManager; +import sun.java2d.cmm.ProfileDataVerifier; import sun.java2d.cmm.ProfileDeferralMgr; import sun.java2d.cmm.ProfileDeferralInfo; import sun.java2d.cmm.ProfileActivator; @@ -775,6 +776,8 @@ public class ICC_Profile implements Serializable { ProfileDeferralMgr.activateProfiles(); } + ProfileDataVerifier.verify(data); + try { theID = CMSManager.getModule().loadProfile(data); } catch (CMMException c) { diff --git a/src/share/classes/java/nio/CharBufferSpliterator.java b/src/share/classes/java/nio/CharBufferSpliterator.java index 19fd8a8f0ba8b858239f107d56769fc12b535b07..5b3977ae7646f2740e3dc2c9ae4b7e10651a4df5 100644 --- a/src/share/classes/java/nio/CharBufferSpliterator.java +++ b/src/share/classes/java/nio/CharBufferSpliterator.java @@ -5,7 +5,7 @@ * 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 + * 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 diff --git a/src/share/classes/javax/swing/JFileChooser.java b/src/share/classes/javax/swing/JFileChooser.java index 2e1655d6d706b1b958be8b6fa8056644b9ff0268..d30c69675ae4dbab34baebafc01ffb4bad3fa5d7 100644 --- a/src/share/classes/javax/swing/JFileChooser.java +++ b/src/share/classes/javax/swing/JFileChooser.java @@ -1146,9 +1146,25 @@ public class JFileChooser extends JComponent implements Accessible { * @see #resetChoosableFileFilters */ public boolean removeChoosableFileFilter(FileFilter f) { - if(filters.contains(f)) { + int index = filters.indexOf(f); + if (index >= 0) { if(getFileFilter() == f) { - setFileFilter(null); + if (isAcceptAllFileFilterUsed()) { + // choose default filter if it is used + setFileFilter(getAcceptAllFileFilter()); + } + else if (index > 0) { + // choose the first filter, because it is not removed + setFileFilter(filters.get(0)); + } + else if (filters.size() > 1) { + // choose the second filter, because the first one is removed + setFileFilter(filters.get(1)); + } + else { + // no more filters + setFileFilter(null); + } } FileFilter[] oldValue = getChoosableFileFilters(); filters.removeElement(f); diff --git a/src/share/classes/javax/swing/JTree.java b/src/share/classes/javax/swing/JTree.java index f4d89e0042438260bfd0693afbc01a1956935627..09b31da9f28a9ea861ccd9fd87dd2fb08bbe859e 100644 --- a/src/share/classes/javax/swing/JTree.java +++ b/src/share/classes/javax/swing/JTree.java @@ -3751,7 +3751,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * the nodes identified by in e. */ void removeDescendantSelectedPaths(TreeModelEvent e) { - TreePath pPath = e.getTreePath(); + TreePath pPath = SwingUtilities2.getTreePath(e, getModel()); Object[] oldChildren = e.getChildren(); TreeSelectionModel sm = getSelectionModel(); @@ -3785,7 +3785,7 @@ public class JTree extends JComponent implements Scrollable, Accessible // and update BasicTreeUIs treeStructureChanged method // to update descendants in response to a treeStructureChanged // event, all the children of the event won't collapse! - TreePath parent = e.getTreePath(); + TreePath parent = SwingUtilities2.getTreePath(e, getModel()); if(parent == null) return; @@ -3822,7 +3822,7 @@ public class JTree extends JComponent implements Scrollable, Accessible if(e == null) return; - TreePath parent = e.getTreePath(); + TreePath parent = SwingUtilities2.getTreePath(e, getModel()); Object[] children = e.getChildren(); if(children == null) diff --git a/src/share/classes/javax/swing/event/TreeModelEvent.java b/src/share/classes/javax/swing/event/TreeModelEvent.java index 62389469839d591d0eeeddf1da0a2090878c0c36..3c92dc16377a43835e4ccf8ca2d66936573993d9 100644 --- a/src/share/classes/javax/swing/event/TreeModelEvent.java +++ b/src/share/classes/javax/swing/event/TreeModelEvent.java @@ -128,7 +128,7 @@ public class TreeModelEvent extends EventObject { public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children) { - this(source, new TreePath(path), childIndices, children); + this(source, (path == null) ? null : new TreePath(path), childIndices, children); } /** @@ -183,7 +183,7 @@ public class TreeModelEvent extends EventObject { */ public TreeModelEvent(Object source, Object[] path) { - this(source, new TreePath(path)); + this(source, (path == null) ? null : new TreePath(path)); } /** diff --git a/src/share/classes/javax/swing/plaf/basic/BasicComboBoxEditor.java b/src/share/classes/javax/swing/plaf/basic/BasicComboBoxEditor.java index 1b741db47f653e8a7fa0e68503c44152b8688d47..c902252f4dc84bc8e39c08b4275cfc479bd9fb22 100644 --- a/src/share/classes/javax/swing/plaf/basic/BasicComboBoxEditor.java +++ b/src/share/classes/javax/swing/plaf/basic/BasicComboBoxEditor.java @@ -73,6 +73,9 @@ public class BasicComboBoxEditor implements ComboBoxEditor,FocusListener { if ( anObject != null ) { text = anObject.toString(); + if (text == null) { + text = ""; + } oldValue = anObject; } else { text = ""; diff --git a/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java b/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java index 3d39cf6a876c6f834d1149c4492d3e886615a255..0e7cd1768e753fafb5024d69bd0d46ef6f1f4fcb 100644 --- a/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java +++ b/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java @@ -3827,7 +3827,7 @@ public class BasicTreeUI extends TreeUI // public void treeNodesChanged(TreeModelEvent e) { if(treeState != null && e != null) { - TreePath parentPath = e.getTreePath(); + TreePath parentPath = SwingUtilities2.getTreePath(e, getModel()); int[] indices = e.getChildIndices(); if (indices == null || indices.length == 0) { // The root has changed @@ -3882,7 +3882,7 @@ public class BasicTreeUI extends TreeUI updateLeadSelectionRow(); - TreePath path = e.getTreePath(); + TreePath path = SwingUtilities2.getTreePath(e, getModel()); if(treeState.isExpanded(path)) { updateSize(); @@ -3907,7 +3907,7 @@ public class BasicTreeUI extends TreeUI updateLeadSelectionRow(); - TreePath path = e.getTreePath(); + TreePath path = SwingUtilities2.getTreePath(e, getModel()); if(treeState.isExpanded(path) || treeModel.getChildCount(path.getLastPathComponent()) == 0) @@ -3921,7 +3921,7 @@ public class BasicTreeUI extends TreeUI updateLeadSelectionRow(); - TreePath pPath = e.getTreePath(); + TreePath pPath = SwingUtilities2.getTreePath(e, getModel()); if (pPath != null) { pPath = pPath.getParentPath(); diff --git a/src/share/classes/javax/swing/text/View.java b/src/share/classes/javax/swing/text/View.java index 097e6c33313a775814f5dfd760c2c00c3b4a70ba..c2e1e023d5a6e9ee7a94fe88ee96a608ad62282c 100644 --- a/src/share/classes/javax/swing/text/View.java +++ b/src/share/classes/javax/swing/text/View.java @@ -1174,7 +1174,7 @@ public abstract class View implements SwingConstants { // formed by added elements (i.e. they will be updated // by initialization. index0 = Math.max(index0, 0); - index1 = getViewIndex(elem.getDocument().getLength(), Position.Bias.Forward); + index1 = Math.max((getViewCount() - 1), 0); for (int i = index0; i <= index1; i++) { if (! ((i >= hole0) && (i <= hole1))) { v = getView(i); diff --git a/src/share/classes/javax/swing/tree/FixedHeightLayoutCache.java b/src/share/classes/javax/swing/tree/FixedHeightLayoutCache.java index fffea8b0b5b1dd6322df15ee4cce64fc99223b7f..4f61aff73041e2e15808163025cfc51ff1791683 100644 --- a/src/share/classes/javax/swing/tree/FixedHeightLayoutCache.java +++ b/src/share/classes/javax/swing/tree/FixedHeightLayoutCache.java @@ -26,13 +26,14 @@ package javax.swing.tree; import javax.swing.event.TreeModelEvent; -import java.awt.Dimension; import java.awt.Rectangle; import java.util.Enumeration; import java.util.Hashtable; import java.util.NoSuchElementException; import java.util.Stack; +import sun.swing.SwingUtilities2; + /** * NOTE: This will become more open in a future release. *

@@ -346,7 +347,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache { if(e != null) { int changedIndexs[]; FHTreeStateNode changedParent = getNodeForPath - (e.getTreePath(), false, false); + (SwingUtilities2.getTreePath(e, getModel()), false, false); int maxCounter; changedIndexs = e.getChildIndices(); @@ -390,7 +391,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache { if(e != null) { int changedIndexs[]; FHTreeStateNode changedParent = getNodeForPath - (e.getTreePath(), false, false); + (SwingUtilities2.getTreePath(e, getModel()), false, false); int maxCounter; changedIndexs = e.getChildIndices(); @@ -429,7 +430,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache { if(e != null) { int changedIndexs[]; int maxCounter; - TreePath parentPath = e.getTreePath(); + TreePath parentPath = SwingUtilities2.getTreePath(e, getModel()); FHTreeStateNode changedParentNode = getNodeForPath (parentPath, false, false); @@ -475,7 +476,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache { */ public void treeStructureChanged(TreeModelEvent e) { if(e != null) { - TreePath changedPath = e.getTreePath(); + TreePath changedPath = SwingUtilities2.getTreePath(e, getModel()); FHTreeStateNode changedNode = getNodeForPath (changedPath, false, false); diff --git a/src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java b/src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java index ad91d1c84c2afbaaa28a6c2bbec6f099e446e485..5185194ed3be5b35bf37073cea49da7ac89c1fc5 100644 --- a/src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java +++ b/src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java @@ -26,7 +26,6 @@ package javax.swing.tree; import javax.swing.event.TreeModelEvent; -import java.awt.Dimension; import java.awt.Rectangle; import java.util.Enumeration; import java.util.Hashtable; @@ -34,6 +33,8 @@ import java.util.NoSuchElementException; import java.util.Stack; import java.util.Vector; +import sun.swing.SwingUtilities2; + /** * NOTE: This will become more open in a future release. *

@@ -413,7 +414,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { TreeStateNode changedNode; changedIndexs = e.getChildIndices(); - changedNode = getNodeForPath(e.getTreePath(), false, false); + changedNode = getNodeForPath(SwingUtilities2.getTreePath(e, getModel()), false, false); if(changedNode != null) { Object changedValue = changedNode.getValue(); @@ -466,7 +467,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { TreeStateNode changedParentNode; changedIndexs = e.getChildIndices(); - changedParentNode = getNodeForPath(e.getTreePath(), false, false); + changedParentNode = getNodeForPath(SwingUtilities2.getTreePath(e, getModel()), false, false); /* Only need to update the children if the node has been expanded once. */ // PENDING(scott): make sure childIndexs is sorted! @@ -540,7 +541,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { TreeStateNode changedParentNode; changedIndexs = e.getChildIndices(); - changedParentNode = getNodeForPath(e.getTreePath(), false, false); + changedParentNode = getNodeForPath(SwingUtilities2.getTreePath(e, getModel()), false, false); // PENDING(scott): make sure that changedIndexs are sorted in // ascending order. if(changedParentNode != null && changedIndexs != null && @@ -628,7 +629,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { public void treeStructureChanged(TreeModelEvent e) { if(e != null) { - TreePath changedPath = e.getTreePath(); + TreePath changedPath = SwingUtilities2.getTreePath(e, getModel()); TreeStateNode changedNode; changedNode = getNodeForPath(changedPath, false, false); diff --git a/src/share/classes/sun/java2d/cmm/ProfileDataVerifier.java b/src/share/classes/sun/java2d/cmm/ProfileDataVerifier.java new file mode 100644 index 0000000000000000000000000000000000000000..e6100bbefd41153bf62223d91925d14610112be4 --- /dev/null +++ b/src/share/classes/sun/java2d/cmm/ProfileDataVerifier.java @@ -0,0 +1,114 @@ +/* + * 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. 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.java2d.cmm; + +public class ProfileDataVerifier { + /** + * Throws an IllegalArgumentException if the data does not correspond + * to a valid ICC Profile. + * + * @param data the specified profile data. + */ + public static void verify(byte[] data) { + if (data == null) { + throw new IllegalArgumentException("Invalid ICC Profile Data"); + } + + if (data.length < TOC_OFFSET) { + // not enough data for profile header + throw new IllegalArgumentException("Invalid ICC Profile Data"); + } + + // check profile size + final int size = readInt32(data, 0); + final int tagCount = readInt32(data, HEADER_SIZE); + + if (tagCount < 0 || tagCount > MAX_TAG_COUNT) { + throw new IllegalArgumentException("Invalid ICC Profile Data"); + } + + if (size < (TOC_OFFSET + (tagCount * TOC_RECORD_SIZE)) || + size > data.length) + { + throw new IllegalArgumentException("Invalid ICC Profile Data"); + } + + final int sig = readInt32(data, 36); + + if (PROFILE_FILE_SIGNATURE != sig) { + throw new IllegalArgumentException("Invalid ICC Profile Data"); + } + + // verify table of content + for (int i = 0; i < tagCount; i++) { + final int tag_offset = getTagOffset(i, data); + final int tag_size = getTagSize(i, data); + + if (tag_offset < TOC_OFFSET || tag_offset > size) { + throw new IllegalArgumentException("Invalid ICC Profile Data"); + } + + if (tag_size < 0 || + tag_size > (Integer.MAX_VALUE - tag_offset) || + tag_size + tag_offset > size) + { + throw new IllegalArgumentException("Invalid ICC Profile Data"); + } + } + } + + private static int getTagOffset(int idx, byte[] data) { + final int pos = TOC_OFFSET + idx * TOC_RECORD_SIZE + 4; + return readInt32(data, pos); + } + + private static int getTagSize(int idx, byte[] data) { + final int pos = TOC_OFFSET + idx * TOC_RECORD_SIZE + 8; + return readInt32(data, pos); + } + + private static int readInt32(byte[] data, int off) { + int res = 0; + for (int i = 0; i < 4; i++) { + res = res << 8; + + res |= (0xff & data[off++]); + } + return res; + } + + /** + * Lcms limit for the number of tags: 100 + * Kcms limit for the number of tags: N/A + */ + private static final int MAX_TAG_COUNT = 100; + + private static final int HEADER_SIZE = 128; + private static final int TOC_OFFSET = HEADER_SIZE + 4; + private static final int TOC_RECORD_SIZE = 12; + + private static final int PROFILE_FILE_SIGNATURE = 0x61637370; +} diff --git a/src/share/classes/sun/swing/SwingUtilities2.java b/src/share/classes/sun/swing/SwingUtilities2.java index c6134885adf4423e67d8596676c757d13a94819f..a1903f2bdd2eed678f8acd6fe85cd8041fff315c 100644 --- a/src/share/classes/sun/swing/SwingUtilities2.java +++ b/src/share/classes/sun/swing/SwingUtilities2.java @@ -33,18 +33,19 @@ import java.awt.event.*; import java.awt.font.*; import java.awt.geom.*; import java.awt.print.PrinterGraphics; -import java.text.Bidi; import java.text.AttributedCharacterIterator; import java.text.AttributedString; import javax.swing.*; -import javax.swing.plaf.*; +import javax.swing.event.TreeModelEvent; import javax.swing.text.Highlighter; import javax.swing.text.JTextComponent; import javax.swing.text.DefaultHighlighter; import javax.swing.text.DefaultCaret; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; import sun.swing.PrintColorUIResource; import sun.swing.ImageIconUIResource; @@ -1887,4 +1888,22 @@ public class SwingUtilities2 { } return InputEvent.ALT_MASK; } + + /** + * Returns the {@link TreePath} that identifies the changed nodes. + * + * @param event changes in a tree model + * @param model corresponing tree model + * @return the path to the changed nodes + */ + public static TreePath getTreePath(TreeModelEvent event, TreeModel model) { + TreePath path = event.getTreePath(); + if ((path == null) && (model != null)) { + Object root = model.getRoot(); + if (root != null) { + path = new TreePath(root); + } + } + return path; + } } diff --git a/src/share/native/sun/font/layout/KernTable.cpp b/src/share/native/sun/font/layout/KernTable.cpp index 13ddd0f3b32ab8416588d6e0d4ae56feabbb7b60..2d946513fb824d7c3c9e9be6baaf7ed69a4d5fe3 100644 --- a/src/share/native/sun/font/layout/KernTable.cpp +++ b/src/share/native/sun/font/layout/KernTable.cpp @@ -96,7 +96,7 @@ LE_CORRECT_SIZE(KernTableHeader, KERN_TABLE_HEADER_SIZE) * TODO: respect header flags */ KernTable::KernTable(const LETableReference& base, LEErrorCode &success) - : pairs(), pairsSwapped(NULL), fTable(base) + : pairsSwapped(NULL), fTable(base) { if(LE_FAILURE(success) || (fTable.isEmpty())) { #if DEBUG @@ -143,32 +143,36 @@ KernTable::KernTable(const LETableReference& base, LEErrorCode &success) #endif if(LE_SUCCESS(success) && nPairs>0) { - // pairs is an instance member, and table is on the stack. - // set 'pairs' based on table.getAlias(). This will range check it. - - pairs = LEReferenceToArrayOf(fTable, // based on overall table - success, - (const PairInfo*)table.getAlias(), // subtable 0 + .. - KERN_SUBTABLE_0_HEADER_SIZE, // .. offset of header size - nPairs); // count - } - if (LE_SUCCESS(success) && pairs.isValid()) { - pairsSwapped = (PairInfo*)(malloc(nPairs*sizeof(PairInfo))); - PairInfo *p = (PairInfo*)pairsSwapped; - for (int i = 0; LE_SUCCESS(success) && i < nPairs; i++, p++) { - memcpy(p, pairs.getAlias(i,success), KERN_PAIRINFO_SIZE); - p->key = SWAPL(p->key); + // pairsSwapped is an instance member, and table is on the stack. + // set 'pairsSwapped' based on table.getAlias(). This will range check it. + + pairsSwapped = (PairInfo*)(fTable.getFont()->getKernPairs()); + if (pairsSwapped == NULL) { + LEReferenceToArrayOfpairs = + LEReferenceToArrayOf(fTable, // based on overall table + success, + (const PairInfo*)table.getAlias(), // subtable 0 + .. + KERN_SUBTABLE_0_HEADER_SIZE, // .. offset of header size + nPairs); // count + if (LE_SUCCESS(success) && pairs.isValid()) { + pairsSwapped = (PairInfo*)(malloc(nPairs*sizeof(PairInfo))); + PairInfo *p = (PairInfo*)pairsSwapped; + for (int i = 0; LE_SUCCESS(success) && i < nPairs; i++, p++) { + memcpy(p, pairs.getAlias(i,success), KERN_PAIRINFO_SIZE); + p->key = SWAPL(p->key); + } + fTable.getFont()->setKernPairs((void*)pairsSwapped); // store it } - fTable.getFont()->setKernPairs((void*)pairsSwapped); // store it + } } #if 0 - fprintf(stderr, "coverage: %0.4x nPairs: %d pairs %p\n", coverage, nPairs, pairs.getAlias()); + fprintf(stderr, "coverage: %0.4x nPairs: %d pairs %p\n", coverage, nPairs, pairsSwapped); fprintf(stderr, " searchRange: %d entrySelector: %d rangeShift: %d\n", searchRange, entrySelector, rangeShift); fprintf(stderr, "[[ ignored font table entries: range %d selector %d shift %d ]]\n", SWAPW(table->searchRange), SWAPW(table->entrySelector), SWAPW(table->rangeShift)); #endif #if DEBUG - fprintf(stderr, "coverage: %0.4x nPairs: %d pairs 0x%x\n", coverage, nPairs, pairs); + fprintf(stderr, "coverage: %0.4x nPairs: %d pairs 0x%x\n", coverage, nPairs, pairsSwapped); fprintf(stderr, " searchRange(pairs): %d entrySelector: %d rangeShift(pairs): %d\n", searchRange, entrySelector, rangeShift); @@ -182,7 +186,7 @@ KernTable::KernTable(const LETableReference& base, LEErrorCode &success) ids[id] = (char)i; } } - PairInfo *p = pairs; + PairInfo *p = pairsSwapped; for (int i = 0; i < nPairs; ++i, p++) { le_uint32 k = p->key; le_uint16 left = (k >> 16) & 0xffff; diff --git a/src/share/native/sun/font/layout/KernTable.h b/src/share/native/sun/font/layout/KernTable.h index 1cc4f872d3be54b72e4a50daed116376bdbfee44..c667a18c05649293b43b183019f32722e621f22b 100644 --- a/src/share/native/sun/font/layout/KernTable.h +++ b/src/share/native/sun/font/layout/KernTable.h @@ -57,7 +57,6 @@ class U_LAYOUT_API KernTable private: le_uint16 coverage; le_uint16 nPairs; - LEReferenceToArrayOf pairs; PairInfo *pairsSwapped; const LETableReference &fTable; le_uint16 searchRange; diff --git a/src/share/native/sun/font/layout/LayoutEngine.cpp b/src/share/native/sun/font/layout/LayoutEngine.cpp index 6690316f32d2495946efe2c438187e2860b3c8f7..30fb0bbede59bf1297d061f8cc9fe7d1a1145de7 100644 --- a/src/share/native/sun/font/layout/LayoutEngine.cpp +++ b/src/share/native/sun/font/layout/LayoutEngine.cpp @@ -569,7 +569,6 @@ void LayoutEngine::reset() { if(fGlyphStorage!=NULL) { fGlyphStorage->reset(); - fGlyphStorage = NULL; } } diff --git a/src/share/native/sun/management/DiagnosticCommandImpl.c b/src/share/native/sun/management/DiagnosticCommandImpl.c index 4f601ed55a772ffabec4ea0e3d7a4c34472cc376..4ca0315abc3eef5a61054e5d7fdc9365bb0eaaec 100644 --- a/src/share/native/sun/management/DiagnosticCommandImpl.c +++ b/src/share/native/sun/management/DiagnosticCommandImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java b/src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java index 463a58da8f85a332beafa06bd47bc3a690a9389f..31548f90a811accb8b507b08c27b2028607cf6a5 100644 --- a/src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java +++ b/src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -26,9 +26,11 @@ package sun.awt.X11; import java.awt.Component; import java.awt.Window; -import sun.util.logging.PlatformLogger; + +import sun.awt.AWTAccessor; import sun.awt.CausedFocusEvent; import sun.awt.KeyboardFocusManagerPeerImpl; +import sun.util.logging.PlatformLogger; public class XKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl { private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XKeyboardFocusManagerPeer"); @@ -68,13 +70,13 @@ public class XKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl { synchronized(this) { if (currentFocusedWindow != null) { - from = (XWindowPeer)currentFocusedWindow.getPeer(); + from = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(currentFocusedWindow); } currentFocusedWindow = win; if (currentFocusedWindow != null) { - to = (XWindowPeer)currentFocusedWindow.getPeer(); + to = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(currentFocusedWindow); } } diff --git a/src/solaris/classes/sun/print/UnixPrintServiceLookup.java b/src/solaris/classes/sun/print/UnixPrintServiceLookup.java index 9fcbb86c75677daa46d7450bc03426734121ba3e..c682634b7b66579219808601d9425d8ce3570fc1 100644 --- a/src/solaris/classes/sun/print/UnixPrintServiceLookup.java +++ b/src/solaris/classes/sun/print/UnixPrintServiceLookup.java @@ -362,10 +362,33 @@ public class UnixPrintServiceLookup extends PrintServiceLookup */ private PrintService getServiceByName(PrinterName nameAttr) { String name = nameAttr.getValue(); - PrintService printer = null; if (name == null || name.equals("") || !checkPrinterName(name)) { return null; } + /* check is all printers are already available */ + if (printServices != null) { + for (PrintService printService : printServices) { + if (printService.getName().equals(name)) { + return printService; + } + } + } + /* take CUPS into account first */ + if (CUPSPrinter.isCupsRunning()) { + try { + return new IPPPrintService(name, + new URL("http://"+ + CUPSPrinter.getServer()+":"+ + CUPSPrinter.getPort()+"/"+ + name)); + } catch (Exception e) { + IPPPrintService.debug_println(debugPrefix+ + " getServiceByName Exception "+ + e); + } + } + /* fallback if nothing not having a printer at this point */ + PrintService printer = null; if (isMac() || isSysV()) { printer = getNamedPrinterNameSysV(name); } else { diff --git a/src/solaris/native/sun/awt/awt_GraphicsEnv.c b/src/solaris/native/sun/awt/awt_GraphicsEnv.c index 7282d22a94acba5ea23c405d08ab1e1f6cee2eeb..cb0b7274bd9abbbaabf1d6b9c9ccff1af1e91dc8 100644 --- a/src/solaris/native/sun/awt/awt_GraphicsEnv.c +++ b/src/solaris/native/sun/awt/awt_GraphicsEnv.c @@ -1369,12 +1369,18 @@ Java_sun_awt_X11GraphicsConfig_pGetBounds(JNIEnv *env, jobject this, jint screen mid = (*env)->GetMethodID(env, clazz, "", "(IIII)V"); if (mid != NULL) { if (usingXinerama) { - bounds = (*env)->NewObject(env, clazz, mid, fbrects[screen].x, - fbrects[screen].y, - fbrects[screen].width, - fbrects[screen].height); - } - else { + if (0 <= screen && screen < awt_numScreens) { + bounds = (*env)->NewObject(env, clazz, mid, fbrects[screen].x, + fbrects[screen].y, + fbrects[screen].width, + fbrects[screen].height); + } else { + jclass exceptionClass = (*env)->FindClass(env, "java/lang/IllegalArgumentException"); + if (exceptionClass != NULL) { + (*env)->ThrowNew(env, exceptionClass, "Illegal screen index"); + } + } + } else { XWindowAttributes xwa; memset(&xwa, 0, sizeof(xwa)); diff --git a/src/solaris/native/sun/awt/awt_InputMethod.c b/src/solaris/native/sun/awt/awt_InputMethod.c index faa76460213de7c069d0402217151fe0245837a4..dd9fb952da727b74ece948d606b2ffa275bcad9f 100644 --- a/src/solaris/native/sun/awt/awt_InputMethod.c +++ b/src/solaris/native/sun/awt/awt_InputMethod.c @@ -447,7 +447,7 @@ setXICWindowFocus(XIC ic, Window w) */ #define INITIAL_LOOKUP_BUF_SIZE 512 -Bool +Boolean awt_x11inputmethod_lookupString(XKeyPressedEvent *event, KeySym *keysymp) { JNIEnv *env = GetJNIEnv(); @@ -457,8 +457,8 @@ awt_x11inputmethod_lookupString(XKeyPressedEvent *event, KeySym *keysymp) int mblen; jstring javastr; XIC ic; - Bool result = True; - static Bool composing = False; + Boolean result = True; + static Boolean composing = False; /* printf("lookupString: entering...\n"); diff --git a/src/solaris/native/sun/xawt/XToolkit.c b/src/solaris/native/sun/xawt/XToolkit.c index 6dfb80d368a825e658532825f3cf9eff6fc5ef10..9abacadcb355f0236a1891d445675dbaee579c5b 100644 --- a/src/solaris/native/sun/xawt/XToolkit.c +++ b/src/solaris/native/sun/xawt/XToolkit.c @@ -685,8 +685,7 @@ performPoll(JNIEnv *env, jlong nextTaskTime) { if (result == 0) { /* poll() timed out -- update timeout value */ update_poll_timeout(TIMEOUT_TIMEDOUT); - PRINT2("%s(): TIMEOUT_TIMEDOUT curPollTimeout = %d \n", - performPoll, curPollTimeout); + PRINT2("performPoll(): TIMEOUT_TIMEDOUT curPollTimeout = %d \n", curPollTimeout); } if (pollFds[1].revents) { int count; @@ -695,14 +694,12 @@ performPoll(JNIEnv *env, jlong nextTaskTime) { do { count = read(AWT_READPIPE, read_buf, AWT_POLL_BUFSIZE ); } while (count == AWT_POLL_BUFSIZE ); - PRINT2("%s(): data on the AWT pipe: curPollTimeout = %d \n", - performPoll, curPollTimeout); + PRINT2("performPoll(): data on the AWT pipe: curPollTimeout = %d \n", curPollTimeout); } if (pollFds[0].revents) { // Events in X pipe update_poll_timeout(TIMEOUT_EVENTS); - PRINT2("%s(): TIMEOUT_EVENTS curPollTimeout = %ld \n", - performPoll, curPollTimeout); + PRINT2("performPoll(): TIMEOUT_EVENTS curPollTimeout = %ld \n", curPollTimeout); } return; diff --git a/src/windows/classes/sun/awt/windows/WPrinterJob.java b/src/windows/classes/sun/awt/windows/WPrinterJob.java index 250d8c722034ec872a36ce61d5a6a290497aedcd..897e8f1baf1eaf2278811e0d112cd1ca46349b71 100644 --- a/src/windows/classes/sun/awt/windows/WPrinterJob.java +++ b/src/windows/classes/sun/awt/windows/WPrinterJob.java @@ -1269,11 +1269,13 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { mLastFontFamily = null; } + private boolean defaultCopies = true; /** * Set the number of copies to be printed. */ public void setCopies(int copies) { super.setCopies(copies); + defaultCopies = false; mAttCopies = copies; setNativeCopies(copies); } @@ -1529,8 +1531,9 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { } /* SheetCollate */ - private final boolean getCollateAttrib() { - return (mAttCollate == 1); + private final int getCollateAttrib() { + // -1 means unset, 0 uncollated, 1 collated. + return mAttCollate; } private void setCollateAttrib(Attribute attr) { @@ -1553,6 +1556,10 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { int orient = PageFormat.PORTRAIT; OrientationRequested orientReq = (attributes == null) ? null : (OrientationRequested)attributes.get(OrientationRequested.class); + if (orientReq == null) { + orientReq = (OrientationRequested) + myService.getDefaultAttributeValue(OrientationRequested.class); + } if (orientReq != null) { if (orientReq == OrientationRequested.REVERSE_LANDSCAPE) { orient = PageFormat.REVERSE_LANDSCAPE; @@ -1573,7 +1580,11 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { /* Copies and Page Range. */ private final int getCopiesAttrib() { - return getCopiesInt(); + if (defaultCopies) { + return 0; + } else { + return getCopiesInt(); + } } private final void setRangeCopiesAttribute(int from, int to, @@ -1584,6 +1595,7 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { attributes.add(new PageRanges(from, to)); setPageRange(from, to); } + defaultCopies = false; attributes.add(new Copies(copies)); /* Since this is called from native to tell Java to sync * up with native, we don't call this class's own setCopies() diff --git a/src/windows/classes/sun/print/Win32PrintService.java b/src/windows/classes/sun/print/Win32PrintService.java index bef2213e66492870ee6991e0d483679fbb0a4e60..ace33268b471b9c33d27c1b4d8afb12be32ba493 100644 --- a/src/windows/classes/sun/print/Win32PrintService.java +++ b/src/windows/classes/sun/print/Win32PrintService.java @@ -180,6 +180,9 @@ public class Win32PrintService implements PrintService, AttributeUpdater, private static final int DMDUP_VERTICAL = 2; private static final int DMDUP_HORIZONTAL = 3; private static final int DMCOLLATE_TRUE = 1; + private static final int DMCOLOR_MONOCHROME = 1; + private static final int DMCOLOR_COLOR = 2; + // media sizes with indices above dmPaperToPrintService' length private static final int DMPAPER_A2 = 66; @@ -1041,6 +1044,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, int defOrient = defaults[5]; int defSides = defaults[6]; int defCollate = defaults[7]; + int defColor = defaults[8]; if (category == Copies.class) { if (defCopies > 0) { @@ -1049,11 +1053,10 @@ public class Win32PrintService implements PrintService, AttributeUpdater, return new Copies(1); } } else if (category == Chromaticity.class) { - int caps = getPrinterCapabilities(); - if ((caps & DEVCAP_COLOR) == 0) { - return Chromaticity.MONOCHROME; - } else { + if (defColor == DMCOLOR_COLOR) { return Chromaticity.COLOR; + } else { + return Chromaticity.MONOCHROME; } } else if (category == JobName.class) { return new JobName("Java Printing", null); diff --git a/src/windows/native/sun/windows/WPrinterJob.cpp b/src/windows/native/sun/windows/WPrinterJob.cpp index 1d7b692c4a3b66a81035369f70f610827ed45de9..4bb49983e8d327f2b21652a8cb661b00e9d154e6 100644 --- a/src/windows/native/sun/windows/WPrinterJob.cpp +++ b/src/windows/native/sun/windows/WPrinterJob.cpp @@ -750,7 +750,7 @@ Java_sun_print_Win32PrintService_getCapabilities(JNIEnv *env, #define GETDEFAULT_ERROR -50 -#define NDEFAULT 8 +#define NDEFAULT 9 JNIEXPORT jintArray JNICALL Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env, @@ -859,6 +859,11 @@ Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env, defIndices[7] = pDevMode->dmCollate; } + if (pDevMode->dmFields & DM_COLOR) { + defIndices[8] = pDevMode->dmColor; + } + + GlobalFree(pDevMode); ::ClosePrinter(hPrinter); diff --git a/src/windows/native/sun/windows/awt_Frame.cpp b/src/windows/native/sun/windows/awt_Frame.cpp index 5d344e71474fe01e8082fa4dc85841552f3ab72e..1195491069fa546f0d947c9afce2b120f34e1a68 100644 --- a/src/windows/native/sun/windows/awt_Frame.cpp +++ b/src/windows/native/sun/windows/awt_Frame.cpp @@ -380,9 +380,11 @@ LRESULT AwtFrame::ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, Ms if (!sm_suppressFocusAndActivation) { if (IsLightweightFrame() || IsEmbeddedFrame()) { - AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL); + HWND oppositeToplevelHWnd = AwtComponent::GetTopLevelParentForWindow((HWND)wParam); + if (oppositeToplevelHWnd != AwtComponent::GetFocusedWindow()) { + AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL); + } } - } else if (sm_restoreFocusAndActivation) { if (AwtComponent::GetFocusedWindow() != NULL) { AwtWindow *focusedWindow = (AwtWindow*)GetComponent(AwtComponent::GetFocusedWindow()); diff --git a/src/windows/native/sun/windows/awt_PrintControl.cpp b/src/windows/native/sun/windows/awt_PrintControl.cpp index 400583599900f4cbb5375d9aa5c15ded19c72641..71a08d3df330f05f14823e0fd3e6222514a07341 100644 --- a/src/windows/native/sun/windows/awt_PrintControl.cpp +++ b/src/windows/native/sun/windows/awt_PrintControl.cpp @@ -252,7 +252,7 @@ void AwtPrintControl::initIDs(JNIEnv *env, jclass cls) AwtPrintControl::getCopiesID = env->GetMethodID(cls, "getCopiesAttrib", "()I"); AwtPrintControl::getCollateID = - env->GetMethodID(cls, "getCollateAttrib","()Z"); + env->GetMethodID(cls, "getCollateAttrib","()I"); AwtPrintControl::getOrientID = env->GetMethodID(cls, "getOrientAttrib", "()I"); AwtPrintControl::getFromPageID = @@ -690,12 +690,6 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env, pd.Flags = PD_ENABLEPRINTHOOK | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDlgHook; - if (env->CallBooleanMethod(printCtrl, AwtPrintControl::getCollateID)) { - pd.Flags |= PD_COLLATE; - } - - pd.nCopies = (WORD)env->CallIntMethod(printCtrl, - AwtPrintControl::getCopiesID); pd.nFromPage = (WORD)env->CallIntMethod(printCtrl, AwtPrintControl::getFromPageID); pd.nToPage = (WORD)env->CallIntMethod(printCtrl, @@ -729,37 +723,52 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env, DEVMODE *devmode = (DEVMODE *)::GlobalLock(pd.hDevMode); DASSERT(!IsBadWritePtr(devmode, sizeof(DEVMODE))); - devmode->dmFields |= DM_COPIES | DM_COLLATE | DM_ORIENTATION | - DM_PAPERSIZE | DM_PRINTQUALITY | DM_COLOR | DM_DUPLEX; - - devmode->dmCopies = pd.nCopies; + WORD copies = (WORD)env->CallIntMethod(printCtrl, + AwtPrintControl::getCopiesID); + if (copies > 0) { + devmode->dmFields |= DM_COPIES; + devmode->dmCopies = copies; + } jint orient = env->CallIntMethod(printCtrl, AwtPrintControl::getOrientID); - if (orient == 0) { + if (orient == 0) { // PageFormat.LANDSCAPE == 0 + devmode->dmFields |= DM_ORIENTATION; devmode->dmOrientation = DMORIENT_LANDSCAPE; - } else if (orient == 1) { + } else if (orient == 1) { // PageFormat.PORTRAIT == 1 + devmode->dmFields |= DM_ORIENTATION; devmode->dmOrientation = DMORIENT_PORTRAIT; } - devmode->dmCollate = (pd.Flags & PD_COLLATE) ? DMCOLLATE_TRUE - : DMCOLLATE_FALSE; + // -1 means unset, so we'll accept the printer default. + int collate = env->CallIntMethod(printCtrl, + AwtPrintControl::getCollateID); + if (collate == 1) { + devmode->dmFields |= DM_COLLATE; + devmode->dmCollate = DMCOLLATE_TRUE; + } else if (collate == 0) { + devmode->dmFields |= DM_COLLATE; + devmode->dmCollate = DMCOLLATE_FALSE; + } int quality = env->CallIntMethod(printCtrl, AwtPrintControl::getQualityID); if (quality) { + devmode->dmFields |= DM_PRINTQUALITY; devmode->dmPrintQuality = quality; } int color = env->CallIntMethod(printCtrl, AwtPrintControl::getColorID); if (color) { + devmode->dmFields |= DM_COLOR; devmode->dmColor = color; } int sides = env->CallIntMethod(printCtrl, AwtPrintControl::getSidesID); if (sides) { + devmode->dmFields |= DM_DUPLEX; devmode->dmDuplex = (int)sides; } @@ -771,6 +780,7 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env, double newWid = 0.0, newHt = 0.0; if (wid_ht != NULL && wid_ht[0] != 0 && wid_ht[1] != 0) { + devmode->dmFields |= DM_PAPERSIZE; devmode->dmPaperSize = AwtPrintControl::getNearestMatchingPaper( printName, portName, diff --git a/test/com/sun/java/swing/plaf/gtk/4928019/bug4928019.java b/test/com/sun/java/swing/plaf/gtk/4928019/bug4928019.java new file mode 100644 index 0000000000000000000000000000000000000000..60761c00ea78f9ced3e60b4638d211a9bbd2d3d7 --- /dev/null +++ b/test/com/sun/java/swing/plaf/gtk/4928019/bug4928019.java @@ -0,0 +1,244 @@ +/* + * 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. + */ + +/* + * @test + * @bug 4928019 + * @summary Makes sure all the basic classes can be created with GTK. + * @author Scott Violet + */ + +import javax.swing.*; +import javax.swing.plaf.basic.*; + +public class bug4928019 { + public static void main(String[] args) throws Throwable { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + } catch (UnsupportedLookAndFeelException ex) { + System.err.println("GTKLookAndFeel is not supported on this platform." + + " Test is considered passed."); + return; + } catch (ClassNotFoundException ex) { + System.err.println("GTKLookAndFeel class is not found." + + " Test is considered passed."); + return; + } + new JButton() { + public void updateUI() { + setUI(new BasicButtonUI()); + } + }; + new JCheckBox() { + public void updateUI() { + setUI(new BasicCheckBoxUI()); + } + }; + new JCheckBoxMenuItem() { + public void updateUI() { + setUI(new BasicCheckBoxMenuItemUI()); + } + }; + new JColorChooser() { + public void updateUI() { + setUI(new BasicColorChooserUI()); + } + }; + new JComboBox() { + public void updateUI() { + setUI(new BasicComboBoxUI()); + } + }; + new JDesktopPane() { + public void updateUI() { + setUI(new BasicDesktopPaneUI()); + } + }; + new JEditorPane() { + public void updateUI() { + setUI(new BasicEditorPaneUI()); + } + }; + new JFileChooser() { + public void updateUI() { + setUI(new BasicFileChooserUI(null)); + } + }; + new JFormattedTextField() { + public void updateUI() { + setUI(new BasicFormattedTextFieldUI()); + } + }; + new JInternalFrame() { + public void updateUI() { + setUI(new BasicInternalFrameUI(null)); + } + }; + new JLabel() { + public void updateUI() { + setUI(new BasicLabelUI()); + } + }; + new JList() { + public void updateUI() { + setUI(new BasicListUI()); + } + }; + new JMenuBar() { + public void updateUI() { + setUI(new BasicMenuBarUI()); + } + }; + new JMenuItem() { + public void updateUI() { + setUI(new BasicMenuItemUI()); + } + }; + new JMenu() { + public void updateUI() { + setUI(new BasicMenuUI()); + } + }; + new JOptionPane() { + public void updateUI() { + setUI(new BasicOptionPaneUI()); + } + }; + new JPanel() { + public void updateUI() { + setUI(new BasicPanelUI()); + } + }; + new JPasswordField() { + public void updateUI() { + setUI(new BasicPasswordFieldUI()); + } + }; + new JPopupMenu() { + public void updateUI() { + setUI(new BasicPopupMenuUI()); + } + }; + new JProgressBar() { + public void updateUI() { + setUI(new BasicProgressBarUI()); + } + }; + new JRadioButton() { + public void updateUI() { + setUI(new BasicRadioButtonUI()); + } + }; + new JRadioButtonMenuItem() { + public void updateUI() { + setUI(new BasicRadioButtonMenuItemUI()); + } + }; + new JRootPane() { + public void updateUI() { + setUI(new BasicRootPaneUI()); + } + }; + new JScrollBar() { + public void updateUI() { + setUI(new BasicScrollBarUI()); + } + }; + new JScrollPane() { + public void updateUI() { + setUI(new BasicScrollPaneUI()); + } + }; + new JSeparator() { + public void updateUI() { + setUI(new BasicSeparatorUI()); + } + }; + new JSlider() { + public void updateUI() { + setUI(new BasicSliderUI(null)); + } + }; + new JSpinner() { + public void updateUI() { + setUI(new BasicSpinnerUI()); + } + }; + new JSplitPane() { + public void updateUI() { + setUI(new BasicSplitPaneUI()); + } + }; + new JTabbedPane() { + public void updateUI() { + setUI(new BasicTabbedPaneUI()); + } + }; + new JTable() { + public void updateUI() { + setUI(new BasicTableUI()); + } + }; + new JTextArea() { + public void updateUI() { + setUI(new BasicTextAreaUI()); + } + }; + new JTextField() { + public void updateUI() { + setUI(new BasicTextFieldUI()); + } + }; + new JTextPane() { + public void updateUI() { + setUI(new BasicTextPaneUI()); + } + }; + new JToggleButton() { + public void updateUI() { + setUI(new BasicToggleButtonUI()); + } + }; + new JToolBar() { + public void updateUI() { + setUI(new BasicToolBarUI()); + } + }; + new JToolTip() { + public void updateUI() { + setUI(new BasicToolTipUI()); + } + }; + new JTree() { + public void updateUI() { + setUI(new BasicTreeUI()); + } + }; + new JViewport() { + public void updateUI() { + setUI(new BasicViewportUI()); + } + }; + System.out.println("DONE"); + } +} diff --git a/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html index 03f470d2dec7120cd01544dac3ac428b6f1020b5..21396353d7c50f5aed05899163c76d4ada6959f2 100644 --- a/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html @@ -1,6 +1,5 @@ + Java 7 on mac os x only provides text clipboard formats diff --git a/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java index 765457e7ddd6a823cc40d1cd371a934109adc2f0..598426f61f0bfdc853230a643da47cee4a378baf 100644 --- a/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java @@ -22,7 +22,6 @@ */ /* - @test @bug 8005932 @summary Java 7 on mac os x only provides text clipboard formats @author mikhail.cherkasov@oracle.com @@ -30,10 +29,9 @@ @library ../../regtesthelpers/process @build Util @build ProcessResults ProcessCommunicator - - @run applet/othervm MissedHtmlAndRtfBug.html */ + import java.awt.*; import java.awt.datatransfer.DataFlavor; import java.awt.event.*; diff --git a/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java b/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java index a22551bec2c77ef3ca9fb991597f8e78fcf4953c..2edcf9db98aaa0422609704b8e722f148c66eb8b 100644 --- a/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java +++ b/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java @@ -132,6 +132,7 @@ class TestKFM extends DefaultKeyboardFocusManager { } protected synchronized void enqueueKeyEvents(long after, Component untilFocused) { super.enqueueKeyEvents(after, untilFocused); + robot.delay(1); robot.keyPress(KeyEvent.VK_SPACE); robot.delay(50); robot.keyRelease(KeyEvent.VK_SPACE); diff --git a/test/java/awt/GraphicsDevice/CheckDisplayModes.java b/test/java/awt/GraphicsDevice/CheckDisplayModes.java index bc8d8a50be6597d4219024a18776931b4df5dba2..719ee9b43a7d785aed465cdba7f7976b99942ea5 100644 --- a/test/java/awt/GraphicsDevice/CheckDisplayModes.java +++ b/test/java/awt/GraphicsDevice/CheckDisplayModes.java @@ -37,6 +37,10 @@ public class CheckDisplayModes { public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice graphicDevice = ge.getDefaultScreenDevice(); + if (!graphicDevice.isDisplayChangeSupported()) { + System.err.println("Display mode change is not supported on this host. Test is considered passed."); + return; + } DisplayMode defaultDisplayMode = graphicDevice.getDisplayMode(); checkDisplayMode(defaultDisplayMode); graphicDevice.setDisplayMode(defaultDisplayMode); diff --git a/test/java/awt/Mixing/MixingInHwPanel.java b/test/java/awt/Mixing/MixingInHwPanel.java index 7aceebd0b38de5f350c850a6c857d4f9665ad8ef..27b2d96715ea29417949397af7b1514351e1cd6d 100644 --- a/test/java/awt/Mixing/MixingInHwPanel.java +++ b/test/java/awt/Mixing/MixingInHwPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -22,7 +22,7 @@ */ /* - @test %W% %E% + @test @bug 6829858 @summary Mixing should work inside heavyweight containers @author anthony.petrov@sun.com: area=awt.mixing @@ -104,7 +104,7 @@ public class MixingInHwPanel // And click the part of the button that has been previously hidden Point bLoc = button.getLocationOnScreen(); - robot.mouseMove(bLoc.x + button.getWidth() - 6, bLoc.y + button.getHeight() / 2); + robot.mouseMove(bLoc.x + button.getWidth() - 15, bLoc.y + button.getHeight() / 2); Util.waitForIdle(robot); diff --git a/test/java/awt/Mouse/EnterExitEvents/FullscreenEnterEventTest.java b/test/java/awt/Mouse/EnterExitEvents/FullscreenEnterEventTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c27b295b3c39ef0320a1a87b3173f0ba082e4bf2 --- /dev/null +++ b/test/java/awt/Mouse/EnterExitEvents/FullscreenEnterEventTest.java @@ -0,0 +1,166 @@ +/* +* 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 sun.misc.OSEnvironment; +import test.java.awt.regtesthelpers.Util; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +/* + * @test + * @bug 8013468 + * @summary Cursor does not update properly when in fullscreen mode on Mac + * The core reason of the issue was the lack of a mouse entered event in fullscreen + * @library ../../regtesthelpers + * @build Util + * @author Petr Pchelko area=awt.event + * @run main FullscreenEnterEventTest + */ +public class FullscreenEnterEventTest { + + private static String OS = System.getProperty("os.name").toLowerCase(); + + private static JFrame frame; + + private static volatile int mouseEnterCount = 0; + + private static volatile boolean windowEnteringFullScreen = false; + private static volatile boolean windowEnteredFullScreen = false; + + public static void main(String[] args) throws Exception { + + if (!OS.contains("mac")) { + System.out.println("The test is applicable only to Mac OS X. Passed"); + return; + } + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + createAndShowGUI(); + } + }); + + //Move the mouse away from the frame and check the View-base full screen mode + Robot r = Util.createRobot(); + Util.waitForIdle(r); + r.mouseMove(500, 500); + Util.waitForIdle(r); + mouseEnterCount = 0; + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame); + } + }); + Util.waitForIdle(r); + if (mouseEnterCount != 1) { + throw new RuntimeException("No MouseEntered event for view-base full screen. Failed."); + } + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(null); + } + }); + + //Test native full screen support + Point fullScreenButtonPos = frame.getLocation(); + fullScreenButtonPos.translate(frame.getWidth() - 10, 10); + r.mouseMove(fullScreenButtonPos.x, fullScreenButtonPos.y); + mouseEnterCount = 0; + + //Cant use waitForIdle for full screen transition. + int waitCount = 0; + while (!windowEnteringFullScreen) { + r.mousePress(InputEvent.BUTTON1_MASK); + r.mouseRelease(InputEvent.BUTTON1_MASK); + Thread.sleep(100); + if (waitCount++ > 10) throw new RuntimeException("Can't enter full screen mode. Failed"); + } + + waitCount = 0; + while (!windowEnteredFullScreen) { + Thread.sleep(200); + if (waitCount++ > 10) throw new RuntimeException("Can't enter full screen mode. Failed"); + } + + if (mouseEnterCount != 1) { + throw new RuntimeException("No MouseEntered event for native full screen. Failed."); + } + } + + private static void createAndShowGUI() { + frame = new JFrame(" Fullscreen OSX Bug "); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + enableFullScreen(frame); + frame.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + mouseEnterCount++; + } + }); + frame.setBounds(100, 100, 100, 100); + frame.pack(); + frame.setVisible(true); + + } + + /* + * Use reflection to make a test compilable on not Mac OS X + */ + private static void enableFullScreen(Window window) { + try { + Class fullScreenUtilities = Class.forName("com.apple.eawt.FullScreenUtilities"); + Method setWindowCanFullScreen = fullScreenUtilities.getMethod("setWindowCanFullScreen", Window.class, boolean.class); + setWindowCanFullScreen.invoke(fullScreenUtilities, window, true); + Class fullScreenListener = Class.forName("com.apple.eawt.FullScreenListener"); + Object listenerObject = Proxy.newProxyInstance(fullScreenListener.getClassLoader(), new Class[]{fullScreenListener}, new InvocationHandler() { + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + switch (method.getName()) { + case "windowEnteringFullScreen": + windowEnteringFullScreen = true; + break; + case "windowEnteredFullScreen": + windowEnteredFullScreen = true; + break; + } + return null; + } + }); + Method addFullScreenListener = fullScreenUtilities.getMethod("addFullScreenListenerTo", Window.class, fullScreenListener); + addFullScreenListener.invoke(fullScreenUtilities, window, listenerObject); + } catch (Exception e) { + throw new RuntimeException("FullScreen utilities not available", e); + } + } + +} diff --git a/test/java/awt/event/KeyEvent/KeyReleasedInAppletTest/KeyReleasedInAppletTest.java b/test/java/awt/event/KeyEvent/KeyReleasedInAppletTest/KeyReleasedInAppletTest.java index 71e8994e347bc0c5833fb224cc13ac0b677a43b5..34bcbb531bf891bdf72722a343738a2193cd710a 100644 --- a/test/java/awt/event/KeyEvent/KeyReleasedInAppletTest/KeyReleasedInAppletTest.java +++ b/test/java/awt/event/KeyEvent/KeyReleasedInAppletTest/KeyReleasedInAppletTest.java @@ -39,7 +39,6 @@ import java.lang.Throwable; import java.util.Hashtable; /* -@test @bug 8010009 @summary [macosx] Unable type into online word games on MacOSX @author petr.pchelko : area=awt.keyboard diff --git a/test/java/awt/font/TextLayout/KerningLeak.java b/test/java/awt/font/TextLayout/KerningLeak.java new file mode 100644 index 0000000000000000000000000000000000000000..fb8448c3a4eb648669a196f9d70a1e330c5cde25 --- /dev/null +++ b/test/java/awt/font/TextLayout/KerningLeak.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +/** + * @bug 8015334 + * @summary Memory leak with kerning. + */ + +import java.awt.EventQueue; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.font.TextAttribute; +import java.util.HashMap; +import java.util.Map; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; + +public class KerningLeak { + + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + leak(); + } + }); + } + + private static void leak() { + Map textAttributes = new HashMap<>(); + textAttributes.put(TextAttribute.FAMILY, "Sans Serif"); + textAttributes.put(TextAttribute.SIZE, 12); + textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON); + Font font = Font.getFont(textAttributes); + JLabel label = new JLabel(); + int dummy = 0; + for (int i = 0; i < 500; i++) { + if (i % 10 == 0) System.out.println("Starting iter " + (i+1)); + for (int j = 0; j <1000; j++) { + FontMetrics fm = label.getFontMetrics(font); + dummy += SwingUtilities.computeStringWidth(fm, Integer.toString(j)); + } + } + System.out.println("done " + dummy); + } +} diff --git a/test/java/lang/management/MXBean/MXBeanBehavior.java b/test/java/lang/management/MXBean/MXBeanBehavior.java index ccffecabebd671642b2bbb71bf00950bdba4da53..12403164abab8b44dc0366c75fba947e8d409816 100644 --- a/test/java/lang/management/MXBean/MXBeanBehavior.java +++ b/test/java/lang/management/MXBean/MXBeanBehavior.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/java/lang/management/ManagementFactory/MBeanServerMXBeanUnsupportedTest.java b/test/java/lang/management/ManagementFactory/MBeanServerMXBeanUnsupportedTest.java index 00f3768efe622a8d638841ed63ce36bbf8decb71..195fb573ec8ed279611dae9e88fa41fb022cca23 100644 --- a/test/java/lang/management/ManagementFactory/MBeanServerMXBeanUnsupportedTest.java +++ b/test/java/lang/management/ManagementFactory/MBeanServerMXBeanUnsupportedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/javax/print/PrintServiceLookup/GetPrintServices.java b/test/javax/print/PrintServiceLookup/GetPrintServices.java new file mode 100644 index 0000000000000000000000000000000000000000..f8373a6383a5bd9f2b7362632cd96647c04b2f1f --- /dev/null +++ b/test/javax/print/PrintServiceLookup/GetPrintServices.java @@ -0,0 +1,58 @@ +/* + * 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 javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.attribute.AttributeSet; +import javax.print.attribute.HashAttributeSet; +import javax.print.attribute.standard.PrinterName; + +/* + * @test + * @bug 8013810 + * @summary Test that print service returned without filter are of the same class as with name filter + */ +public class GetPrintServices { + + public static void main(String[] args) throws Exception { + for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) { + String serviceName = service.getName(); + PrintService serviceByName = lookupByName(serviceName); + if (!service.equals(serviceByName)) { + throw new RuntimeException("NOK " + serviceName + + " expected: " + service.getClass().getName() + + " got: " + serviceByName.getClass().getName()); + } + } + System.out.println("Test PASSED"); + } + + private static PrintService lookupByName(String name) { + AttributeSet attributes = new HashAttributeSet(); + attributes.add(new PrinterName(name, null)); + for (PrintService service : PrintServiceLookup.lookupPrintServices(null, attributes)) { + return service; + } + return null; + } +} diff --git a/test/javax/swing/JFileChooser/8013442/Test8013442.java b/test/javax/swing/JFileChooser/8013442/Test8013442.java new file mode 100644 index 0000000000000000000000000000000000000000..e7b892ddaed4a6bee9f35d9b16516c20c21d88e2 --- /dev/null +++ b/test/javax/swing/JFileChooser/8013442/Test8013442.java @@ -0,0 +1,122 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8013442 + * @summary Tests that at least one file filter is selected + * @author Sergey Malenkov + */ + +import java.io.File; +import java.util.concurrent.CountDownLatch; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UIManager.LookAndFeelInfo; +import javax.swing.filechooser.FileFilter; + +public class Test8013442 extends FileFilter implements Runnable, Thread.UncaughtExceptionHandler { + private static final CountDownLatch LATCH = new CountDownLatch(1); + + public static void main(String[] args) throws InterruptedException { + SwingUtilities.invokeLater(new Test8013442()); + LATCH.await(); // workaround for jtreg + } + + private int index; + private LookAndFeelInfo[] infos; + private JFileChooser chooser; + + @Override + public boolean accept(File file) { + return !file.isFile() || file.getName().toLowerCase().endsWith(".txt"); + } + + @Override + public String getDescription() { + return "Text files"; + } + + @Override + public void run() { + if (this.infos == null) { + this.infos = UIManager.getInstalledLookAndFeels(); + Thread.currentThread().setUncaughtExceptionHandler(this); + } + if (this.infos.length == this.index) { + LATCH.countDown(); // release main thread + } else if (this.chooser == null) { + // change LaF before creation of Swing components + LookAndFeelInfo info = this.infos[this.index]; + System.out.println(info.getName()); + try { + UIManager.setLookAndFeel(info.getClassName()); + } + catch (Exception exception) { + throw new Error("could not change look and feel", exception); + } + // create and show new file chooser + JFrame frame = new JFrame(getClass().getSimpleName()); + frame.add(this.chooser = new JFileChooser()); + frame.setSize(800, 600); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + SwingUtilities.invokeLater(this); + } + else { + int count = this.chooser.getChoosableFileFilters().length; + System.out.println("count = " + count + "; " + this.chooser.isAcceptAllFileFilterUsed()); + if (count == 0) { + if (null != this.chooser.getFileFilter()) { + throw new Error("file filter is selected"); + } + // close window and stop testing file chooser for current LaF + SwingUtilities.getWindowAncestor(this.chooser).dispose(); + this.chooser = null; + this.index++; + } else { + if (null == this.chooser.getFileFilter()) { + throw new Error("file filter is not selected"); + } + if (count == 2) { + // remove default file filter + this.chooser.setAcceptAllFileFilterUsed(false); + } else if (this.chooser.isAcceptAllFileFilterUsed()) { + // remove add file filter + this.chooser.addChoosableFileFilter(this); + } else { + // remove custom file filter + this.chooser.removeChoosableFileFilter(this); + } + } + SwingUtilities.invokeLater(this); + } + } + + public void uncaughtException(Thread thread, Throwable throwable) { + throwable.printStackTrace(); + System.exit(1); + } +} diff --git a/test/javax/swing/JMenu/4692443/bug4692443.java b/test/javax/swing/JMenu/4692443/bug4692443.java new file mode 100644 index 0000000000000000000000000000000000000000..6032287e53405eda8610c15a4a4e331b8d8f09c6 --- /dev/null +++ b/test/javax/swing/JMenu/4692443/bug4692443.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2009, 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. + */ + +/* + * @test + * @library ../../regtesthelpers + * @build Util + * @bug 4692443 7105030 + * @summary JMenu: MenuListener.menuSelected() event fired too late when using mnemonics + * @author Alexander Zuev + * @run main bug4692443 + */ + +import javax.swing.*; +import javax.swing.event.*; +import java.awt.event.*; +import java.awt.*; +import sun.awt.SunToolkit; + +public class bug4692443 { + + public static PassedListener pass; + public static FailedListener fail; + public static volatile Boolean passed; + + public static void main(String args[]) throws Throwable { + + fail = new FailedListener(); + pass = new PassedListener(); + passed = false; + Robot robo = new Robot(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + createAndShowGUI(); + } + }); + + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + toolkit.realSync(); + + try { + robo = new Robot(); + } catch (AWTException e) { + throw new RuntimeException("Robot could not be created"); + } + int altKey = java.awt.event.KeyEvent.VK_ALT; + robo.setAutoDelay(100); + Util.hitMnemonics(robo, KeyEvent.VK_F); // Enter File menu + robo.keyPress(KeyEvent.VK_S); // Enter submenu + robo.keyRelease(KeyEvent.VK_S); + robo.keyPress(KeyEvent.VK_O); // Launch "One" action + robo.keyRelease(KeyEvent.VK_O); + robo.keyPress(KeyEvent.VK_M); // Launch "One" action + robo.keyRelease(KeyEvent.VK_M); + + toolkit.realSync(); + + if (!passed) { + throw new RuntimeException("Test failed."); + } + + } + + private static void createAndShowGUI() { + JFrame mainFrame = new JFrame("Bug 4692443"); + JMenuBar mbar = new JMenuBar(); + JMenu menu = new JMenu("File"); + menu.setMnemonic('F'); + menu.add(new JMenuItem("Menu Item 1")).setMnemonic('I'); + final JMenu submenu = new JMenu("Submenu"); + submenu.setMnemonic('S'); + submenu.addMenuListener(new MenuListener() { + public void menuSelected(MenuEvent e) { + JMenuItem item = submenu.add(new JMenuItem("One", 'O')); + item.addActionListener(pass); + submenu.add(new JMenuItem("Two", 'w')); + submenu.add(new JMenuItem("Three", 'r')); + } + public void menuDeselected(MenuEvent e) { + submenu.removeAll(); + } + public void menuCanceled(MenuEvent e) { + submenu.removeAll(); + } + }); + menu.add(submenu); + JMenuItem menuItem = menu.add(new JMenuItem("Menu Item 2")); + menuItem.setMnemonic('M'); + menuItem.addActionListener(fail); + mbar.add(menu); + mainFrame.setJMenuBar(mbar); + + mainFrame.setSize(200, 200); + mainFrame.setLocation(200, 200); + mainFrame.setVisible(true); + mainFrame.toFront(); + } + + public static class FailedListener implements ActionListener { + public void actionPerformed(ActionEvent ev) { + throw new RuntimeException("Test failed."); + } + } + + public static class PassedListener implements ActionListener { + public void actionPerformed(ActionEvent ev) { + passed = true; + } + } + +} diff --git a/test/javax/swing/JTree/8013571/Test8013571.java b/test/javax/swing/JTree/8013571/Test8013571.java new file mode 100644 index 0000000000000000000000000000000000000000..15ad391dcf235269ea865fa0599537c0dff49290 --- /dev/null +++ b/test/javax/swing/JTree/8013571/Test8013571.java @@ -0,0 +1,64 @@ +/* + * 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 javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; + +/* + * @test + * @bug 8016545 + * @summary Tests beans with public fields + * @author Sergey Malenkov + */ + +public class Test8013571 extends DefaultTreeModel { + public static void main(String[] args) { + DefaultMutableTreeNode root = create("root"); + root.add(create("colors", "blue", "violet", "red", "yellow")); + root.add(create("sports", "basketball", "soccer", "football", "hockey")); + root.add(create("food", "hot dogs", "pizza", "ravioli", "bananas")); + Test8013571 model = new Test8013571(root); + JTree tree = new JTree(model); + model.fireTreeChanged(tree); + } + + private static DefaultMutableTreeNode create(String name, String... values) { + DefaultMutableTreeNode node = new DefaultMutableTreeNode(name); + for (String value : values) { + node.add(create(value)); + } + return node; + } + + private Test8013571(DefaultMutableTreeNode root) { + super(root); + } + + private void fireTreeChanged(Object source) { + fireTreeNodesInserted(source, null, null, null); + fireTreeNodesChanged(source, null, null, null); + fireTreeNodesRemoved(source, null, null, null); + fireTreeStructureChanged(source, null, null, null); + } +} diff --git a/test/javax/swing/plaf/basic/BasicComboBoxEditor/Test8015336.java b/test/javax/swing/plaf/basic/BasicComboBoxEditor/Test8015336.java new file mode 100644 index 0000000000000000000000000000000000000000..742fc99091aeaee0e0f747fd9a7f13a82ea741ed --- /dev/null +++ b/test/javax/swing/plaf/basic/BasicComboBoxEditor/Test8015336.java @@ -0,0 +1,41 @@ +/* + * 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 javax.swing.JComboBox; + +/* + * @test + * @bug 8015336 + * @summary No NPE for BasicComboBoxEditor.setItem(null) + * @author Sergey Malenkov + */ +public class Test8015336 { + public static void main(String[] args) throws Exception { + new JComboBox().getEditor().setItem(new Test8015336()); + } + + @Override + public String toString() { + return null; + } +} diff --git a/test/javax/swing/text/View/8015853/bug8015853.java b/test/javax/swing/text/View/8015853/bug8015853.java new file mode 100644 index 0000000000000000000000000000000000000000..f63210683beae30c17d30b429ec136b0ff90ed46 --- /dev/null +++ b/test/javax/swing/text/View/8015853/bug8015853.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2007, 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. + */ + +/* + * @test + * @bug 8015853 + * @summary Tests the rendering of a large HTML document + * @author Dmitry Markov + * @run main bug8015853 + */ + +import java.io.*; +import java.net.URL; +import java.util.Scanner; +import javax.swing.*; +import javax.swing.text.html.HTMLEditorKit; + +public class bug8015853 { + + private static String text = ""; + + public static void main(String[] args) throws Exception { + + try { + URL path = ClassLoader.getSystemResource("bug8015853.txt"); + File file = new File(path.toURI()); + Scanner scanner = new Scanner(file); + while (scanner.hasNextLine()) { + text += scanner.nextLine() + "\n"; + } + scanner.close(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + + text += text; + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + createAndShowGUI(); + } + }); + } + + private static void createAndShowGUI() { + try { + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JEditorPane editorPane = new JEditorPane(); + HTMLEditorKit editorKit = new HTMLEditorKit(); + editorPane.setEditorKit(editorKit); + editorPane.setText(text); + + frame.add(editorPane); + frame.setVisible(true); + } +} diff --git a/test/javax/swing/text/View/8015853/bug8015853.txt b/test/javax/swing/text/View/8015853/bug8015853.txt new file mode 100644 index 0000000000000000000000000000000000000000..d9a6230684fe0939c1a39d88e8486a9ed4ddbd6c --- /dev/null +++ b/test/javax/swing/text/View/8015853/bug8015853.txt @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2007, 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.io.*; +import java.net.URL; +import java.util.Scanner; +import javax.swing.*; +import javax.swing.text.html.HTMLEditorKit; +public class bug8015853 { + private static String text = ""; + public static void main(String[] args) throws Exception { + + try { + URL path = ClassLoader.getSystemResource("bug8015853.txt"); + File file = new File(path.toURI()); + Scanner scanner = new Scanner(file); + while (scanner.hasNextLine()) { + text += scanner.nextLine() + "\n"; + } + scanner.close(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + + System.out.println(text); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + createAndShowGUI(); + } + }); + } + private static void createAndShowGUI() { + try { + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JEditorPane editorPane = new JEditorPane(); + HTMLEditorKit editorKit = new HTMLEditorKit(); + editorPane.setEditorKit(editorKit); + editorPane.setText(text); + frame.add(editorPane); + frame.setVisible(true); + } +} \ No newline at end of file diff --git a/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java b/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java index 89bd29af05675b535b59bc2589f665ec25233f13..12418c0ed2a3f01277e6abaf97acf814265748a6 100644 --- a/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java +++ b/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java @@ -23,7 +23,7 @@ /** * @test - * @bug 6476665 7033534 + * @bug 6476665 7033534 6830714 * @summary Verifies color conversion of Component Color Model based images * @run main ColConvCCMTest */ @@ -57,9 +57,9 @@ public class ColConvCCMTest extends ColConvTest { final static double [] ACCURACY = { // Accuracy for color conversions 2.5, // sRGB - 6.5, // LINEAR_RGB + (isOpenProfile() ? 45.0 : 10.1), // LINEAR_RGB 10.5, // GRAY - 45.5, // PYCC + (isOpenProfile() ? 207 : 45.5), // PYCC 47.5 // CIEXYZ }; diff --git a/test/sun/java2d/cmm/ColorConvertOp/ColConvDCMTest.java b/test/sun/java2d/cmm/ColorConvertOp/ColConvDCMTest.java index b9f85c72519d61722dd77c4cdea81742007a365f..9ad05689942f9ca242e0dfd0caa59752ba21542a 100644 --- a/test/sun/java2d/cmm/ColorConvertOp/ColConvDCMTest.java +++ b/test/sun/java2d/cmm/ColorConvertOp/ColConvDCMTest.java @@ -62,7 +62,11 @@ public class ColConvDCMTest extends ColConvTest { ColorSpace.CS_LINEAR_RGB, }; - final static double ACCURACY = 2.5; + final static double [] ACCURACY = { + // Accuracy for color conversions + 2.5, // sRGB + (isOpenProfile() ? 45.0 : 2.5), // LINEAR_RGB + }; final static String [] gldImgNames = { "SRGB.png", "SRGB555.png", "SRGB565.png", "LRGB.png", "LRGB555.png", @@ -142,7 +146,7 @@ public class ColConvDCMTest extends ColConvTest { if (!testImage(imgTypes[i][0], imgTypes[i][1], imgTypes[i][2], imgTypes[i][3], cSpaces[imgTypes[i][4]], gldImage, - ACCURACY)) + ACCURACY[imgTypes[i][4]])) { throw new RuntimeException( "Invalid result of the ColorConvertOp for " + @@ -154,7 +158,8 @@ public class ColConvDCMTest extends ColConvTest { if (!testSubImage(SI_X, SI_Y, SI_W, SI_H, imgTypes[i][0], imgTypes[i][1], imgTypes[i][2], imgTypes[i][3], - cSpaces[imgTypes[i][4]], gldImage, ACCURACY)) + cSpaces[imgTypes[i][4]], gldImage, + ACCURACY[imgTypes[i][4]])) { throw new RuntimeException( "Invalid result of the ColorConvertOp for " + diff --git a/test/sun/java2d/cmm/ColorConvertOp/ColConvTest.java b/test/sun/java2d/cmm/ColorConvertOp/ColConvTest.java index db3719134f18febb752fecb9298f0924eaf410a0..b3f1c2e4da2f0bef9f4eb49463585ce42141ac34 100644 --- a/test/sun/java2d/cmm/ColorConvertOp/ColConvTest.java +++ b/test/sun/java2d/cmm/ColorConvertOp/ColConvTest.java @@ -22,6 +22,7 @@ */ import java.awt.color.ColorSpace; +import java.awt.color.ICC_Profile; import java.awt.image.BufferedImage; import java.awt.image.DataBuffer; @@ -126,4 +127,33 @@ public abstract class ColConvTest implements Runnable { public boolean isPassed() { return passed; } + + private static Boolean isOpenProfile = null; + + public static boolean isOpenProfile() { + if (isOpenProfile == null) { + ICC_Profile p = ICC_Profile.getInstance(ColorSpace.CS_sRGB); + + byte[] h = p.getData(ICC_Profile.icSigHead); + + if (h == null || h.length < 128) { + throw new RuntimeException("Test failed: invalid sRGB header"); + } + + final byte[] lcmsID = new byte[] { + (byte)0x6c, // l + (byte)0x63, // c + (byte)0x6d, // m + (byte)0x73, // s + }; + + int off = ICC_Profile.icHdrCmmId; + + isOpenProfile = ((h[off + 0] == lcmsID[0]) + && (h[off + 1] == lcmsID[1]) + && (h[off + 2] == lcmsID[2]) + && (h[off + 3] == lcmsID[3])); + } + return isOpenProfile; + } }