Mercurial > hg > openjdk > jdk8u > jdk
changeset 9228:db30cb9eb18d jdk8u20-b07
Merge
author | lana |
---|---|
date | Mon, 24 Mar 2014 13:15:07 -0700 |
parents | 536384b58ae9 (current diff) 9b750cc73624 (diff) |
children | 0f2d82ba2b40 91cb60617489 8c4e83c2d060 ac97f128d302 |
files | .hgtags src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java src/macosx/native/sun/awt/CWrapper.h |
diffstat | 97 files changed, 3039 insertions(+), 1112 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Wed Mar 19 15:19:35 2014 -0700 +++ b/.hgtags Mon Mar 24 13:15:07 2014 -0700 @@ -257,4 +257,7 @@ 5a9f04957f826ce23639479c9791c7d8fd282b01 jdk8u20-b03 c347889445c1153f11aaa56092d44a911e497454 jdk8u20-b04 c9117a5defe912b1f7ae92bb0730d6e7a5a045df jdk8u20-b05 +43386cc9a017a9f9e704760050086bb18b778ae0 jdk8-b130 +e291ac47c9a90366c3c0787a6f7ce547a2bda308 jdk8-b131 +43cb25339b5500871f41388a5197f1b01c4b57b8 jdk8-b132 1ecfc0fac3e7b931f09728b7594384ea5b5f9f0f jdk8u20-b06
--- a/make/Import.gmk Wed Mar 19 15:19:35 2014 -0700 +++ b/make/Import.gmk Mon Mar 24 13:15:07 2014 -0700 @@ -252,7 +252,7 @@ $(ECHO) Unzipping $(<F) $(MKDIR) -p $(@D) $(RM) $@ - ($(CD) $(JDK_OUTPUTDIR) && $(UNZIP) $< > $@.tmp) + ($(CD) $(JDK_OUTPUTDIR) && $(UNZIP) -q -o $< > $@.tmp) $(MV) $@.tmp $@ endef
--- a/make/data/tzdata/VERSION Wed Mar 19 15:19:35 2014 -0700 +++ b/make/data/tzdata/VERSION Mon Mar 24 13:15:07 2014 -0700 @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2013i +tzdata2014a
--- a/make/data/tzdata/asia Wed Mar 19 15:19:35 2014 -0700 +++ b/make/data/tzdata/asia Mon Mar 24 13:15:07 2014 -0700 @@ -1113,8 +1113,13 @@ Rule Zion 1986 only - Sep 7 0:00 0 S Rule Zion 1987 only - Apr 15 0:00 1:00 D Rule Zion 1987 only - Sep 13 0:00 0 S -Rule Zion 1988 only - Apr 9 0:00 1:00 D -Rule Zion 1988 only - Sep 3 0:00 0 S + +# From Avigdor Finkelstein (2014-03-05): +# I check the Parliament (Knesset) records and there it's stated that the +# [1988] transition should take place on Saturday night, when the Sabbath +# ends and changes to Sunday. +Rule Zion 1988 only - Apr 10 0:00 1:00 D +Rule Zion 1988 only - Sep 4 0:00 0 S # From Ephraim Silverberg # (1997-03-04, 1998-03-16, 1998-12-28, 2000-01-17, 2000-07-25, 2004-12-22,
--- a/make/data/tzdata/australasia Wed Mar 19 15:19:35 2014 -0700 +++ b/make/data/tzdata/australasia Mon Mar 24 13:15:07 2014 -0700 @@ -377,16 +377,18 @@ # http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=6702&catid=71&Itemid=155 # From the Fijian Government Media Center (2013-08-30) via David Wheeler: -# Fiji will start daylight savings on Sunday 27th October, 2013 and end at 3am -# on Sunday 19th January, 2014.... move clocks forward by one hour from 2am +# Fiji will start daylight savings on Sunday 27th October, 2013 ... +# move clocks forward by one hour from 2am # http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-27th-OCTOBER-201.aspx -# -# From Paul Eggert (2013-09-09): + +# From Steffen Thorsen (2013-01-10): +# Fiji will end DST on 2014-01-19 02:00: +# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVINGS-TO-END-THIS-MONTH-%281%29.aspx + +# From Paul Eggert (2014-01-10): # For now, guess that Fiji springs forward the Sunday before the fourth -# Monday in October. This matches both recent practice and -# timeanddate.com's current spring-forward prediction. -# For the January 2014 transition we guessed right while timeanddate.com -# guessed wrong, so leave the fall-back prediction alone. +# Monday in October, and springs back the penultimate Sunday in January. +# This is ad hoc, but matches recent practice. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 S @@ -395,7 +397,8 @@ Rule Fiji 2010 only - Mar lastSun 3:00 0 - Rule Fiji 2010 max - Oct Sun>=21 2:00 1:00 S Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - -Rule Fiji 2012 max - Jan Sun>=18 3:00 0 - +Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - +Rule Fiji 2014 max - Jan Sun>=18 2:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva 12:00 Fiji FJ%sT # Fiji Time
--- a/make/data/tzdata/europe Wed Mar 19 15:19:35 2014 -0700 +++ b/make/data/tzdata/europe Mon Mar 24 13:15:07 2014 -0700 @@ -2768,14 +2768,18 @@ # According to the articles linked below, Turkey will change into summer # time zone (GMT+3) on March 28, 2011 at 3:00 a.m. instead of March 27. # This change is due to a nationwide exam on 27th. -# -# <a href="http://www.worldbulletin.net/?aType=haber&ArticleID=70872"> # http://www.worldbulletin.net/?aType=haber&ArticleID=70872 -# </a> # Turkish: -# <a href="http://www.hurriyet.com.tr/ekonomi/17230464.asp?gid=373"> # http://www.hurriyet.com.tr/ekonomi/17230464.asp?gid=373 -# </a> + +# From Faruk Pasin (2014-02-14): +# The DST for Turkey has been changed for this year because of the +# Turkish Local election.... +# http://www.sabah.com.tr/Ekonomi/2014/02/12/yaz-saatinde-onemli-degisiklik +# ... so Turkey will move clocks forward one hour on March 31 at 3:00 a.m. +# From Paul Eggert (2014-02-17): +# Here is an English-language source: +# http://www.worldbulletin.net/turkey/129016/turkey-switches-to-daylight-saving-time-march-31 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Turkey 1916 only - May 1 0:00 1:00 S @@ -2844,6 +2848,8 @@ 2:00 Turkey EE%sT 2007 2:00 EU EE%sT 2011 Mar 27 1:00u 2:00 - EET 2011 Mar 28 1:00u + 2:00 EU EE%sT 2014 Mar 30 1:00u + 2:00 - EET 2014 Mar 31 1:00u 2:00 EU EE%sT Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. @@ -2865,19 +2871,13 @@ # approval from 266 deputies. # # Ukraine abolishes transter back to the winter time (in Russian) -# <a href="http://news.mail.ru/politics/6861560/"> # http://news.mail.ru/politics/6861560/ -# </a> # # The Ukrainians will no longer change the clock (in Russian) -# <a href="http://www.segodnya.ua/news/14290482.html"> # http://www.segodnya.ua/news/14290482.html -# </a> # # Deputies cancelled the winter time (in Russian) -# <a href="http://www.pravda.com.ua/rus/news/2011/09/20/6600616/"> # http://www.pravda.com.ua/rus/news/2011/09/20/6600616/ -# </a> # # From Philip Pizzey (2011-10-18): # Today my Ukrainian colleagues have informed me that the @@ -2888,18 +2888,39 @@ # As far as I understand, the recent change to the Ukrainian time zone # (Europe/Kiev) to introduce permanent daylight saving time (similar # to Russia) was reverted today: -# -# <a href="http://portal.rada.gov.ua/rada/control/en/publish/article/info_left?art_id=287324&cat_id=105995"> # http://portal.rada.gov.ua/rada/control/en/publish/article/info_left?art_id=287324&cat_id=105995 -# </a> # # Also reported by Alexander Bokovoy (2011-10-18) who also noted: # The law documents themselves are at +# http://w1.c1.rada.gov.ua/pls/zweb_n/webproc4_1?id=&pf3511=41484 + +# From Vladimir in Moscow via Alois Treindl re Kiev time 1991/2 (2014-02-28): +# First in Ukraine they changed Time zone from UTC+3 to UTC+2 with DST: +# 03 25 1990 02:00 -03.00 1 Time Zone 3 with DST +# 07 01 1990 02:00 -02.00 1 Time Zone 2 with DST +# * Ukrainian Government's Resolution of 18.06.1990, No. 134. +# http://search.ligazakon.ua/l_doc2.nsf/link1/T001500.html # -# <a href="http://w1.c1.rada.gov.ua/pls/zweb_n/webproc4_1?id=&pf3511=41484"> -# http://w1.c1.rada.gov.ua/pls/zweb_n/webproc4_1?id=&pf3511=41484 -# </a> - +# They did not end DST in September, 1990 (according to the law, +# "summer time" was still in action): +# 09 30 1990 03:00 -02.00 1 Time Zone 2 with DST +# * Ukrainian Government's Resolution of 21.09.1990, No. 272. +# http://search.ligazakon.ua/l_doc2.nsf/link1/KP900272.html +# +# Again no change in March, 1991 ("summer time" in action): +# 03 31 1991 02:00 -02.00 1 Time Zone 2 with DST +# +# DST ended in September 1991 ("summer time" ended): +# 09 29 1991 03:00 -02.00 0 Time Zone 2, no DST +# * Ukrainian Government's Resolution of 25.09.1991, No. 225. +# http://www.uazakon.com/documents/date_21/pg_iwgdoc.htm +# This is an answer. +# +# Since 1992 they had normal DST procedure: +# 03 29 1992 02:00 -02.00 1 DST started +# 09 27 1992 03:00 -02.00 0 DST ended +# * Ukrainian Government's Resolution of 20.03.1992, No. 139. +# http://www.uazakon.com/documents/date_8u/pg_grcasa.htm # Zone NAME GMTOFF RULES FORMAT [UNTIL] # Most of Ukraine since 1970 has been like Kiev. @@ -2910,9 +2931,8 @@ 2:00 - EET 1930 Jun 21 3:00 - MSK 1941 Sep 20 1:00 C-Eur CE%sT 1943 Nov 6 - 3:00 Russia MSK/MSD 1990 - 3:00 - MSK 1990 Jul 1 2:00 - 2:00 - EET 1992 + 3:00 Russia MSK/MSD 1990 Jul 1 2:00 + 2:00 1:00 EEST 1991 Sep 29 3:00 2:00 E-Eur EE%sT 1995 2:00 EU EE%sT # Ruthenia used CET 1990/1991.
--- a/make/data/tzdata/northamerica Wed Mar 19 15:19:35 2014 -0700 +++ b/make/data/tzdata/northamerica Mon Mar 24 13:15:07 2014 -0700 @@ -414,9 +414,10 @@ # US Pacific time, represented by Los Angeles # # California, northern Idaho (Benewah, Bonner, Boundary, Clearwater, -# Idaho, Kootenai, Latah, Lewis, Nez Perce, and Shoshone counties, -# and the northern three-quarters of Idaho county), -# most of Nevada, most of Oregon, and Washington +# Kootenai, Latah, Lewis, Nez Perce, and Shoshone counties, Idaho county +# north of the Salmon River, and the towns of Burgdorf and Warren), +# Nevada (except West Wendover), Oregon (except the northern 3/4 of +# Malheur county), and Washington # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule CA 1948 only - Mar 14 2:00 1:00 D
--- a/make/data/tzdata/southamerica Wed Mar 19 15:19:35 2014 -0700 +++ b/make/data/tzdata/southamerica Mon Mar 24 13:15:07 2014 -0700 @@ -1298,6 +1298,13 @@ # start date is 2013-09-08 00:00.... # http://www.gob.cl/informa/2013/02/15/gobierno-anuncia-fechas-de-cambio-de-hora-para-el-ano-2013.htm +# From Jose Miguel Garrido (2014-02-19): +# Today appeared in the Diario Oficial a decree amending the time change +# dates to 2014. +# DST End: last Saturday of April 2014 (Sun 27 Apr 2014 03:00 UTC) +# DST Start: first Saturday of September 2014 (Sun 07 Sep 2014 04:00 UTC) +# http://www.diariooficial.interior.gob.cl//media/2014/02/19/do-20140219.pdf + # NOTE: ChileAQ rules for Antarctic bases are stored separately in the # 'antarctica' file. @@ -1631,6 +1638,9 @@ # From Carlos Raul Perasso (2013-03-15): # The change in Paraguay is now final. Decree number 10780 # http://www.presidencia.gov.py/uploads/pdf/presidencia-3b86ff4b691c79d4f5927ca964922ec74772ce857c02ca054a52a37b49afc7fb.pdf +# From Carlos Raul Perasso (2014-02-28): +# Decree 1264 can be found at: +# http://www.presidencia.gov.py/archivos/documentos/DECRETO1264_ey9r8zai.pdf Rule Para 2013 max - Mar Sun>=22 0:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -1689,18 +1699,19 @@ Zone America/Port_of_Spain -4:06:04 - LMT 1912 Mar 2 -4:00 - AST +# These all agree with Trinidad and Tobago since 1970. Link America/Port_of_Spain America/Anguilla Link America/Port_of_Spain America/Dominica Link America/Port_of_Spain America/Grenada Link America/Port_of_Spain America/Guadeloupe -Link America/Port_of_Spain America/Marigot +Link America/Port_of_Spain America/Marigot # St Martin (French part) Link America/Port_of_Spain America/Montserrat Link America/Port_of_Spain America/St_Barthelemy -Link America/Port_of_Spain America/St_Kitts +Link America/Port_of_Spain America/St_Kitts # St Kitts & Nevis Link America/Port_of_Spain America/St_Lucia -Link America/Port_of_Spain America/St_Thomas +Link America/Port_of_Spain America/St_Thomas # Virgin Islands (US) Link America/Port_of_Spain America/St_Vincent -Link America/Port_of_Spain America/Tortola +Link America/Port_of_Spain America/Tortola # Virgin Islands (UK) # Uruguay # From Paul Eggert (1993-11-18):
--- a/src/macosx/classes/sun/lwawt/LWChoicePeer.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/LWChoicePeer.java Mon Mar 24 13:15:07 2014 -0700 @@ -168,16 +168,16 @@ @Override public void firePopupMenuWillBecomeVisible() { super.firePopupMenuWillBecomeVisible(); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - JPopupMenu popupMenu = getPopupMenu(); - if (popupMenu != null) { - if (popupMenu.getInvoker() != LWChoicePeer.this.getTarget()) { - popupMenu.setVisible(false); - popupMenu.show(LWChoicePeer.this.getTarget(), 0, 0); - } - } + SwingUtilities.invokeLater(() -> { + JPopupMenu popupMenu = getPopupMenu(); + // Need to override the invoker for proper grab handling + if (popupMenu != null && popupMenu.getInvoker() != getTarget()) { + // The popup is now visible with correct location + // Save it and restore after toggling visibility and changing invoker + Point loc = popupMenu.getLocationOnScreen(); + SwingUtilities.convertPointFromScreen(loc, this); + popupMenu.setVisible(false); + popupMenu.show(getTarget(), loc.x, loc.y); } }); }
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -684,7 +684,7 @@ public void notifyNCMouseDown() { // Ungrab except for a click on a Dialog with the grabbing owner if (grabbingWindow != null && - grabbingWindow != getOwnerFrameDialog(this)) + !grabbingWindow.isOneOfOwnersOf(this)) { grabbingWindow.ungrab(); } @@ -779,7 +779,7 @@ // Ungrab only if this window is not an owned window of the grabbing one. if (!isGrabbing() && grabbingWindow != null && - grabbingWindow != getOwnerFrameDialog(this)) + !grabbingWindow.isOneOfOwnersOf(this)) { grabbingWindow.ungrab(); } @@ -1232,6 +1232,17 @@ changeFocusedWindow(activate, null); } + private boolean isOneOfOwnersOf(LWWindowPeer peer) { + Window owner = (peer != null ? peer.getTarget().getOwner() : null); + while (owner != null) { + if ((LWWindowPeer)owner.getPeer() == this) { + return true; + } + owner = owner.getOwner(); + } + return false; + } + /* * Changes focused window on java level. */ @@ -1263,7 +1274,7 @@ // - when the opposite (gaining focus) window is an owned/owner window. // - for a simple window in any case. if (!becomesFocused && - (isGrabbing() || getOwnerFrameDialog(grabbingWindow) == this)) + (isGrabbing() || this.isOneOfOwnersOf(grabbingWindow))) { if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { focusLog.fine("ungrabbing on " + grabbingWindow); @@ -1282,6 +1293,11 @@ postEvent(windowEvent); } + /* + * Retrieves the owner of the peer. + * Note: this method returns the owner which can be activated, (i.e. the instance + * of Frame or Dialog may be returned). + */ static LWWindowPeer getOwnerFrameDialog(LWWindowPeer peer) { Window owner = (peer != null ? peer.getTarget().getOwner() : null); while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) {
--- a/src/macosx/classes/sun/lwawt/macosx/CClipboard.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CClipboard.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,20 +40,23 @@ * sun.awt.datatransfer.DataTransferer. */ -public class CClipboard extends SunClipboard { +final class CClipboard extends SunClipboard { public CClipboard(String name) { super(name); } + @Override public long getID() { return 0; } + @Override protected void clearNativeContext() { // Leaving Empty, as WClipboard.clearNativeContext is empty as well. } + @Override protected void setContentsNative(Transferable contents) { // Don't use delayed Clipboard rendering for the Transferable's data. @@ -89,6 +92,39 @@ notifyChanged(); } + @Override + protected native long[] getClipboardFormats(); + @Override + protected native byte[] getClipboardData(long format) throws IOException; + + // 1.5 peer method + @Override + protected void unregisterClipboardViewerChecked() { + // no-op because we lack OS support. This requires 4048791, which requires 4048792 + } + + // 1.5 peer method + @Override + protected void registerClipboardViewerChecked() { + // no-op because we lack OS support. This requires 4048791, which requires 4048792 + } + + // 1.5 peer method + // no-op. This appears to be win32 specific. Filed 4048790 for investigation + //protected Transferable createLocaleTransferable(long[] formats) throws IOException; + + private native void declareTypes(long[] formats, SunClipboard newOwner); + private native void setData(byte[] data, long format); + + /** + * Invokes native check whether a change count on the general pasteboard is different + * than when we set it. The different count value means the current owner lost + * pasteboard ownership and someone else put data on the clipboard. + * @since 1.7 + */ + native void checkPasteboard(); + + /*** Native Callbacks ***/ private void notifyLostOwnership() { lostOwnershipImpl(); } @@ -100,32 +136,4 @@ } clipboard.checkChange(clipboard.getClipboardFormats()); } - - protected native long[] getClipboardFormats(); - protected native byte[] getClipboardData(long format) throws IOException; - - // 1.5 peer method - protected void unregisterClipboardViewerChecked() { - // no-op because we lack OS support. This requires 4048791, which requires 4048792 - } - - // 1.5 peer method - protected void registerClipboardViewerChecked() { - // no-op because we lack OS support. This requires 4048791, which requires 4048792 - } - - // 1.5 peer method - // no-op. This appears to be win32 specific. Filed 4048790 for investigation - //protected Transferable createLocaleTransferable(long[] formats) throws IOException; - - public native void declareTypes(long[] formats, SunClipboard newOwner); - public native void setData(byte[] data, long format); - - /** - * Invokes native check whether a change count on the general pasteboard is different - * than when we set it. The different count value means the current owner lost - * pasteboard ownership and someone else put data on the clipboard. - * @since 1.7 - */ - public native void checkPasteboard(); }
--- a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,11 +56,11 @@ }; static { - Map<String, Long> nameMap = new HashMap<String, Long>(predefinedClipboardNames.length, 1.0f); - Map<Long, String> formatMap = new HashMap<Long, String>(predefinedClipboardNames.length, 1.0f); + Map<String, Long> nameMap = new HashMap<>(predefinedClipboardNames.length, 1.0f); + Map<Long, String> formatMap = new HashMap<>(predefinedClipboardNames.length, 1.0f); for (int i = 1; i < predefinedClipboardNames.length; i++) { - nameMap.put(predefinedClipboardNames[i], new Long(i)); - formatMap.put(new Long(i), predefinedClipboardNames[i]); + nameMap.put(predefinedClipboardNames[i], (long) i); + formatMap.put((long) i, predefinedClipboardNames[i]); } predefinedClipboardNameMap = Collections.synchronizedMap(nameMap); predefinedClipboardFormatMap = Collections.synchronizedMap(formatMap); @@ -77,19 +77,11 @@ public static final int CF_PNG = 10; public static final int CF_JPEG = 11; - public static final Long L_CF_TIFF = predefinedClipboardNameMap.get(predefinedClipboardNames[CF_TIFF]); - - // Image file formats with java.awt.Image representation: - private static final Long[] imageFormats = new Long[] { - L_CF_TIFF - }; - - private CDataTransferer() {} private static CDataTransferer fTransferer; - public static synchronized CDataTransferer getInstanceImpl() { + static synchronized CDataTransferer getInstanceImpl() { if (fTransferer == null) { fTransferer = new CDataTransferer(); } @@ -97,18 +89,22 @@ return fTransferer; } + @Override public String getDefaultUnicodeEncoding() { return "utf-16le"; } + @Override public boolean isLocaleDependentTextFormat(long format) { return format == CF_STRING; } + @Override public boolean isFileFormat(long format) { return format == CF_FILE; } + @Override public boolean isImageFormat(long format) { int ifmt = (int)format; switch(ifmt) { @@ -122,43 +118,12 @@ } } - protected Long[] getImageFormatsAsLongArray() { - return imageFormats; - } - - public byte[] translateTransferable(Transferable contents, DataFlavor flavor, long format) throws IOException - { - byte[] bytes = super.translateTransferable(contents, flavor, format); - - // 9-12-02 VL: we may need to do something like Windows here. - //if (format == CF_HTML) { - // bytes = HTMLSupport.convertToHTMLFormat(bytes); - //} - - return bytes; - } - - protected Object translateBytesOrStream(InputStream stream, byte[] bytes, DataFlavor flavor, long format, - Transferable transferable) throws IOException - { - // 5-28-03 VL: [Radar 3266030] - // We need to do like Windows does here. - if (format == CF_HTML && flavor.isFlavorTextType()) { - if (stream == null) { - stream = new ByteArrayInputStream(bytes); - bytes = null; - } - - stream = new HTMLDecodingInputStream(stream); - } + @Override + public Object translateBytes(byte[] bytes, DataFlavor flavor, + long format, Transferable transferable) throws IOException { if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass())) { - if (bytes == null) { - bytes = inputStreamToByteArray(stream); - stream = null; - } - String charset = getDefaultTextCharset(); if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) { try { @@ -175,9 +140,9 @@ } return super.translateBytes(bytes, flavor, format, transferable); - } + } - + @Override synchronized protected Long getFormatForNativeAsLong(String str) { Long format = predefinedClipboardNameMap.get(str); @@ -202,6 +167,7 @@ // Get registered native format string for an index, return null if unknown: private native String formatForIndex(long index); + @Override protected String getNativeForFormat(long format) { String returnValue = null; @@ -209,7 +175,7 @@ if (format >= 0 && format < predefinedClipboardNames.length) { returnValue = predefinedClipboardNames[(int) format]; } else { - Long formatObj = new Long(format); + Long formatObj = format; returnValue = predefinedClipboardFormatMap.get(formatObj); // predefinedClipboardFormatMap may not know this format: @@ -233,10 +199,13 @@ private final ToolkitThreadBlockedHandler handler = new CToolkitThreadBlockedHandler(); + @Override public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() { return handler; } + private native byte[] imageDataToPlatformImageBytes(int[] rData, int nW, int nH); + @Override protected byte[] imageToPlatformBytes(Image image, long format) { int w = image.getWidth(null); int h = image.getHeight(null); @@ -252,32 +221,28 @@ } private static native String[] nativeDragQueryFile(final byte[] bytes); + @Override protected String[] dragQueryFile(final byte[] bytes) { if (bytes == null) return null; if (new String(bytes).startsWith("Unsupported type")) return null; return nativeDragQueryFile(bytes); } - private native byte[] imageDataToPlatformImageBytes(int[] rData, int nW, int nH); - + private native Image getImageForByteStream(byte[] bytes); /** * Translates a byte array which contains * platform-specific image data in the given format into an Image. */ - protected Image platformImageBytesToImage(byte[] bytes, long format) - throws IOException - { + @Override + protected Image platformImageBytesToImage(byte[] bytes, long format) throws IOException { return getImageForByteStream(bytes); } - private native Image getImageForByteStream(byte[] bytes); - @Override protected ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); - for (int i = 0; i < fileList.size(); i++) - { - byte[] bytes = fileList.get(i).getBytes(); + for (String file : fileList) { + byte[] bytes = file.getBytes(); bos.write(bytes, 0, bytes.length); bos.write(0); } @@ -303,246 +268,3 @@ } -// ---- Code borrowed from WDataTransferer: ---- -// This will come handy for supporting HTML data. - -final class HTMLSupport { - public static final String ENCODING = "UTF-8"; - - public static final String VERSION = "Version:"; - public static final String START_HTML = "StartHTML:"; - public static final String END_HTML = "EndHTML:"; - public static final String START_FRAGMENT = "StartFragment:"; - public static final String END_FRAGMENT = "EndFragment:"; - public static final String START_FRAGMENT_CMT = "<!--StartFragment-->"; - public static final String END_FRAGMENT_CMT = "<!--EndFragment-->"; - public static final String EOLN = "\r\n"; - - private static final String VERSION_NUM = "0.9"; - private static final String HTML_START_END = "-1"; - - private static final int PADDED_WIDTH = 10; - - private static final int HEADER_LEN = - VERSION.length() + VERSION_NUM.length() + EOLN.length() + - START_HTML.length() + HTML_START_END.length() + EOLN.length() + - END_HTML.length() + HTML_START_END.length() + EOLN.length() + - START_FRAGMENT.length() + PADDED_WIDTH + EOLN.length() + - END_FRAGMENT.length() + PADDED_WIDTH + EOLN.length() + - START_FRAGMENT_CMT.length() + EOLN.length(); - private static final String HEADER_LEN_STR = - toPaddedString(HEADER_LEN, PADDED_WIDTH); - - private static final String TRAILER = END_FRAGMENT_CMT + EOLN + '\0'; - - private static String toPaddedString(int n, int width) { - String string = "" + n; - int len = string.length(); - if (n >= 0 && len < width) { - char[] array = new char[width - len]; - Arrays.fill(array, '0'); - StringBuffer buffer = new StringBuffer(); - buffer.append(array); - buffer.append(string); - string = buffer.toString(); - } - return string; - } - - public static byte[] convertToHTMLFormat(byte[] bytes) { - StringBuffer header = new StringBuffer(HEADER_LEN); - header.append(VERSION); - header.append(VERSION_NUM); - header.append(EOLN); - header.append(START_HTML); - header.append(HTML_START_END); - header.append(EOLN); - header.append(END_HTML); - header.append(HTML_START_END); - header.append(EOLN); - header.append(START_FRAGMENT); - header.append(HEADER_LEN_STR); - header.append(EOLN); - header.append(END_FRAGMENT); - // Strip terminating NUL byte from array - header.append(toPaddedString(HEADER_LEN + bytes.length - 1, - PADDED_WIDTH)); - header.append(EOLN); - header.append(START_FRAGMENT_CMT); - header.append(EOLN); - - byte[] headerBytes = null, trailerBytes = null; - - try { - headerBytes = new String(header).getBytes(ENCODING); - trailerBytes = TRAILER.getBytes(ENCODING); - } catch (UnsupportedEncodingException cannotHappen) { - } - - byte[] retval = new byte[headerBytes.length + bytes.length - 1 + - trailerBytes.length]; - - System.arraycopy(headerBytes, 0, retval, 0, headerBytes.length); - System.arraycopy(bytes, 0, retval, headerBytes.length, - bytes.length - 1); - System.arraycopy(trailerBytes, 0, retval, - headerBytes.length + bytes.length - 1, - trailerBytes.length); - - return retval; - } -} - -/** -* This stream takes an InputStream which provides data in CF_HTML format, - * strips off the description and context to extract the original HTML data. - */ -class HTMLDecodingInputStream extends InputStream { - - private final BufferedInputStream bufferedStream; - private boolean descriptionParsed = false; - private boolean closed = false; - private int index; - private int end; - - // InputStreamReader uses an 8K buffer. The size is not customizable. - public static final int BYTE_BUFFER_LEN = 8192; - - // CharToByteUTF8.getMaxBytesPerChar returns 3, so we should not buffer - // more chars than 3 times the number of bytes we can buffer. - public static final int CHAR_BUFFER_LEN = BYTE_BUFFER_LEN / 3; - - private static final String FAILURE_MSG = - "Unable to parse HTML description: "; - private static final String INVALID_MSG = " invalid"; - - public HTMLDecodingInputStream(InputStream bytestream) throws IOException { - bufferedStream = new BufferedInputStream(bytestream, BYTE_BUFFER_LEN); - } - - private void parseDescription() throws IOException { - bufferedStream.mark(BYTE_BUFFER_LEN); - - BufferedReader bufferedReader = new BufferedReader - (new InputStreamReader(bufferedStream, HTMLSupport.ENCODING), - CHAR_BUFFER_LEN); - String version = bufferedReader.readLine().trim(); - if (version == null || !version.startsWith(HTMLSupport.VERSION)) { - // Not MS-compliant HTML text. Return raw text from read(). - index = 0; - end = -1; - bufferedStream.reset(); - return; - } - - String input; - boolean startHTML, endHTML, startFragment, endFragment; - startHTML = endHTML = startFragment = endFragment = false; - - try { - do { - input = bufferedReader.readLine().trim(); - if (input == null) { - close(); - throw new IOException(FAILURE_MSG); - } else if (input.startsWith(HTMLSupport.START_HTML)) { - int val = Integer.parseInt - (input.substring(HTMLSupport.START_HTML.length(), - input.length()).trim()); - if (val >= 0) { - index = val; - startHTML = true; - } else if (val != -1) { - close(); - throw new IOException(FAILURE_MSG + - HTMLSupport.START_HTML + - INVALID_MSG); - } - } else if (input.startsWith(HTMLSupport.END_HTML)) { - int val = Integer.parseInt - (input.substring(HTMLSupport.END_HTML.length(), - input.length()).trim()); - if (val >= 0) { - end = val; - endHTML = true; - } else if (val != -1) { - close(); - throw new IOException(FAILURE_MSG + - HTMLSupport.END_HTML + - INVALID_MSG); - } - } else if (!startHTML && !endHTML && - input.startsWith(HTMLSupport.START_FRAGMENT)) { - index = Integer.parseInt - (input.substring(HTMLSupport.START_FRAGMENT.length(), - input.length()).trim()); - if (index < 0) { - close(); - throw new IOException(FAILURE_MSG + - HTMLSupport.START_FRAGMENT + - INVALID_MSG); - } - startFragment = true; - } else if (!startHTML && !endHTML && - input.startsWith(HTMLSupport.END_FRAGMENT)) { - end = Integer.parseInt - (input.substring(HTMLSupport.END_FRAGMENT.length(), - input.length()).trim()); - if (end < 0) { - close(); - throw new IOException(FAILURE_MSG + - HTMLSupport.END_FRAGMENT + - INVALID_MSG); - } - endFragment = true; - } - } while (!((startHTML && endHTML) || - (startFragment && endFragment))); - } catch (NumberFormatException e) { - close(); - throw new IOException(FAILURE_MSG + e); - } - - bufferedStream.reset(); - - for (int i = 0; i < index; i++) { - if (bufferedStream.read() == -1) { - close(); - throw new IOException(FAILURE_MSG + - "Byte stream ends in description."); - } - } - } - - public int read() throws IOException { - if (closed) { - throw new IOException("Stream closed"); - } - - if (!descriptionParsed) { - parseDescription(); // initializes 'index' and 'end' - descriptionParsed = true; - } - - if (end != -1 && index >= end) { - return -1; - } - - int retval = bufferedStream.read(); - if (retval == -1) { - index = end = 0; // so future read() calls will fail quickly - return -1; - } - - index++; - // System.out.print((char)retval); - return retval; - } - - public void close() throws IOException { - if (!closed) { - closed = true; - bufferedStream.close(); - } - } -}
--- a/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Mon Mar 24 13:15:07 2014 -0700 @@ -28,7 +28,6 @@ import sun.lwawt.LWToolkit; import sun.lwawt.LWWindowPeer; import sun.lwawt.macosx.CocoaConstants; -import sun.lwawt.macosx.event.NSEvent; import sun.awt.EmbeddedFrame;
--- a/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java Mon Mar 24 13:15:07 2014 -0700 @@ -46,17 +46,16 @@ @Override public void run() { try { - boolean navigateApps = false; - int dialogMode = target.getMode(); + boolean navigateApps = !AccessController.doPrivileged( + new GetBooleanAction("apple.awt.use-file-dialog-packages")); + boolean chooseDirectories = AccessController.doPrivileged( + new GetBooleanAction("apple.awt.fileDialogForDirectories")); - navigateApps = true; - + int dialogMode = target.getMode(); String title = target.getTitle(); if (title == null) { title = " "; } - Boolean chooseDirectories = AccessController.doPrivileged( - new GetBooleanAction("apple.awt.fileDialogForDirectories")); String[] userFileNames = nativeRunFileDialog(title, dialogMode,
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ import sun.awt.SunToolkit; import sun.lwawt.LWWindowPeer; import sun.lwawt.PlatformEventNotifier; -import sun.lwawt.macosx.event.NSEvent; + import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.awt.event.InputEvent;
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ import sun.awt.CGraphicsConfig; import sun.awt.CGraphicsEnvironment; import sun.lwawt.LWWindowPeer; -import sun.lwawt.macosx.event.NSEvent; import sun.java2d.SurfaceData; import sun.java2d.opengl.CGLLayer;
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Mon Mar 24 13:15:07 2014 -0700 @@ -613,9 +613,7 @@ // Add myself as a child if (owner != null && owner.isVisible()) { CWrapper.NSWindow.addChildWindow(owner.getNSWindowPtr(), nsWindowPtr, CWrapper.NSWindow.NSWindowAbove); - if (target.isAlwaysOnTop()) { - CWrapper.NSWindow.setLevel(nsWindowPtr, CWrapper.NSWindow.NSFloatingWindowLevel); - } + applyWindowLevel(target); } // Add my own children to myself @@ -625,9 +623,7 @@ CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow(); if (pw != null && pw.isVisible()) { CWrapper.NSWindow.addChildWindow(nsWindowPtr, pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove); - if (w.isAlwaysOnTop()) { - CWrapper.NSWindow.setLevel(pw.getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel); - } + pw.applyWindowLevel(w); } } } @@ -1050,8 +1046,14 @@ CWrapper.NSWindow.addChildWindow(nsWindowOwnerPtr, nsWindowSelfPtr, CWrapper.NSWindow.NSWindowAbove); } - if (target.isAlwaysOnTop()) { + applyWindowLevel(target); + } + + protected void applyWindowLevel(Window target) { + if (target.isAlwaysOnTop() && target.getType() != Window.Type.POPUP) { CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel); + } else if (target.getType() == Window.Type.POPUP) { + CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel); } }
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ import sun.java2d.*; import sun.print.*; -public class CPrinterJob extends RasterPrinterJob { +final class CPrinterJob extends RasterPrinterJob { // NOTE: This uses RasterPrinterJob as a base, but it doesn't use // all of the RasterPrinterJob functions. RasterPrinterJob will // break down printing to pieces that aren't necessary under MacOSX @@ -89,6 +89,7 @@ * returns true. * @see java.awt.GraphicsEnvironment#isHeadless */ + @Override public boolean printDialog() throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); @@ -131,6 +132,7 @@ * @see java.awt.GraphicsEnvironment#isHeadless * @since 1.2 */ + @Override public PageFormat pageDialog(PageFormat page) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); @@ -156,12 +158,14 @@ * @return clone of <code>page</code>, altered to describe a default * <code>PageFormat</code>. */ + @Override public PageFormat defaultPage(PageFormat page) { PageFormat newPage = (PageFormat)page.clone(); getDefaultPage(newPage); return newPage; } + @Override protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException { super.setAttributes(attributes); @@ -216,7 +220,7 @@ } } - + @Override public void print(PrintRequestAttributeSet attributes) throws PrinterException { // NOTE: Some of this code is copied from RasterPrinterJob. @@ -343,6 +347,7 @@ * Returns the resolution in dots per inch across the width * of the page. */ + @Override protected double getXRes() { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -352,6 +357,7 @@ * Returns the resolution in dots per inch down the height * of the page. */ + @Override protected double getYRes() { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -362,6 +368,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPrintableX(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -372,6 +379,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPrintableY(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -382,6 +390,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPrintableWidth(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -392,6 +401,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPrintableHeight(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -402,6 +412,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPageWidth(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -412,6 +423,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPageHeight(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -429,6 +441,7 @@ /** * End a page. */ + @Override protected void endPage(PageFormat format, Printable painter, int index) throws PrinterException { // NOTE: This is not used in the CPrinterJob code path. throw new PrinterException(sShouldNotReachHere); @@ -441,6 +454,7 @@ * page. The width and height of the band is * specified by the caller. */ + @Override protected void printBand(byte[] data, int x, int y, int width, int height) throws PrinterException { // NOTE: This is not used in the CPrinterJob code path. throw new PrinterException(sShouldNotReachHere); @@ -450,6 +464,7 @@ * Called by the print() method at the start of * a print job. */ + @Override protected void startDoc() throws PrinterException { // NOTE: This is not used in the CPrinterJob code path. throw new PrinterException(sShouldNotReachHere); @@ -459,12 +474,14 @@ * Called by the print() method at the end of * a print job. */ + @Override protected void endDoc() throws PrinterException { // NOTE: This is not used in the CPrinterJob code path. throw new PrinterException(sShouldNotReachHere); } /* Called by cancelDoc */ + @Override protected native void abortDoc(); /** @@ -502,10 +519,12 @@ /** * validate the paper size against the current printer. */ + @Override protected native void validatePaper(Paper origPaper, Paper newPaper ); // The following methods are CPrinterJob specific. + @Override protected void finalize() { if (fNSPrintInfo != -1) { dispose(fNSPrintInfo);
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJobDialog.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJobDialog.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import java.awt.*; import java.awt.print.*; -public class CPrinterJobDialog extends CPrinterDialog { +final class CPrinterJobDialog extends CPrinterDialog { private Pageable fPageable; private boolean fAllowPrintToFile; @@ -39,5 +39,6 @@ fAllowPrintToFile = allowPrintToFile; } + @Override protected native boolean showDialog(); }
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterPageDialog.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterPageDialog.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import java.awt.*; import java.awt.print.*; -public class CPrinterPageDialog extends CPrinterDialog { +final class CPrinterPageDialog extends CPrinterDialog { private PageFormat fPage; private Printable fPainter; @@ -39,5 +39,6 @@ fPainter = painter; } + @Override protected native boolean showDialog(); }
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterSurfaceData.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterSurfaceData.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,11 +40,11 @@ // public static final SurfaceType IntArgbPQ = SurfaceType.IntArgb.deriveSubType(DESC_INT_ARGB_PQ); public static final SurfaceType IntRgbPQ = SurfaceType.IntRgb.deriveSubType(DESC_INT_RGB_PQ); - public static SurfaceData createData(PageFormat pf, long context) { + static SurfaceData createData(PageFormat pf, long context) { return new CPrinterSurfaceData(CPrinterGraphicsConfig.getConfig(pf), context); } - public CPrinterSurfaceData(GraphicsConfiguration gc, long context) { + private CPrinterSurfaceData(GraphicsConfiguration gc, long context) { super(IntRgbPQ, gc.getColorModel(), gc, gc.getBounds()); initOps(context, this.fGraphicsStates, this.fGraphicsStatesObject, gc.getBounds().width, gc.getBounds().height); }
--- a/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ import sun.awt.AWTAccessor; import sun.awt.SunToolkit; -import sun.lwawt.macosx.event.NSEvent; import javax.swing.*; import java.awt.*; @@ -76,8 +75,9 @@ menuPeer = (CPopupMenu)popup.getPeer(); if (menuPeer == null) { popup.addNotify(); + menuPeer = (CPopupMenu)popup.getPeer(); } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } @@ -97,7 +97,12 @@ //invocation from the AWTTrayIcon.m public long getPopupMenuModel(){ if(popup == null) { - return 0L; + PopupMenu popupMenu = target.getPopupMenu(); + if (popupMenu != null) { + popup = popupMenu; + } else { + return 0L; + } } return checkAndCreatePopupPeer().getModel(); } @@ -134,6 +139,10 @@ dummyFrame.dispose(); + if (popup != null) { + popup.removeNotify(); + } + LWCToolkit.targetDisposedPeer(target, this); target = null;
--- a/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java Mon Mar 24 13:15:07 2014 -0700 @@ -247,10 +247,7 @@ nsWindowPtr, CWrapper.NSWindow.NSWindowAbove); // do not allow security warning to be obscured by other windows - if (ownerWindow.isAlwaysOnTop()) { - CWrapper.NSWindow.setLevel(nsWindowPtr, - CWrapper.NSWindow.NSFloatingWindowLevel); - } + applyWindowLevel(ownerWindow); } } }
--- a/src/macosx/classes/sun/lwawt/macosx/CWrapper.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CWrapper.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,73 +25,65 @@ package sun.lwawt.macosx; -import java.awt.geom.Rectangle2D; - -public final class CWrapper { +final class CWrapper { private CWrapper() { } - public static final class NSWindow { + static final class NSWindow { // NSWindowOrderingMode - public static final int NSWindowAbove = 1; - public static final int NSWindowBelow = -1; - public static final int NSWindowOut = 0; + static final int NSWindowAbove = 1; + static final int NSWindowBelow = -1; + static final int NSWindowOut = 0; // Window level constants // The number of supported levels: (we'll use more in the future) - public static final int MAX_WINDOW_LEVELS = 2; + static final int MAX_WINDOW_LEVELS = 3; // The levels: (these are NOT real constants, these are keys. See native code.) - public static final int NSNormalWindowLevel = 0; - public static final int NSFloatingWindowLevel = 1; + static final int NSNormalWindowLevel = 0; + static final int NSFloatingWindowLevel = 1; + static final int NSPopUpMenuWindowLevel = 2; // 'level' is one of the keys defined above - public static native void setLevel(long window, int level); + static native void setLevel(long window, int level); - public static native void makeKeyAndOrderFront(long window); - public static native void makeKeyWindow(long window); - public static native void makeMainWindow(long window); - public static native boolean canBecomeMainWindow(long window); - public static native boolean isKeyWindow(long window); + static native void makeKeyAndOrderFront(long window); + static native void makeKeyWindow(long window); + static native void makeMainWindow(long window); + static native boolean canBecomeMainWindow(long window); + static native boolean isKeyWindow(long window); - public static native void orderFront(long window); - public static native void orderFrontRegardless(long window); - public static native void orderWindow(long window, int ordered, long relativeTo); - public static native void orderOut(long window); + static native void orderFront(long window); + static native void orderFrontRegardless(long window); + static native void orderWindow(long window, int ordered, long relativeTo); + static native void orderOut(long window); - public static native void addChildWindow(long parent, long child, int ordered); - public static native void removeChildWindow(long parent, long child); + static native void addChildWindow(long parent, long child, int ordered); + static native void removeChildWindow(long parent, long child); - public static native void setFrame(long window, int x, int y, int w, int h, boolean display); + static native void setAlphaValue(long window, float alpha); + static native void setOpaque(long window, boolean opaque); + static native void setBackgroundColor(long window, long color); - public static native void setAlphaValue(long window, float alpha); - public static native void setOpaque(long window, boolean opaque); - public static native void setBackgroundColor(long window, long color); + static native void miniaturize(long window); + static native void deminiaturize(long window); + static native boolean isZoomed(long window); + static native void zoom(long window); - public static native void miniaturize(long window); - public static native void deminiaturize(long window); - public static native boolean isZoomed(long window); - public static native void zoom(long window); - - public static native void makeFirstResponder(long window, long responder); + static native void makeFirstResponder(long window, long responder); } - public static final class NSView { - public static native void addSubview(long view, long subview); - public static native void removeFromSuperview(long view); + static final class NSView { + static native void addSubview(long view, long subview); + static native void removeFromSuperview(long view); - public static native void setFrame(long view, int x, int y, int w, int h); - public static native Rectangle2D frame(long view); - public static native long window(long view); + static native void setFrame(long view, int x, int y, int w, int h); + static native long window(long view); - public static native void setHidden(long view, boolean hidden); + static native void setHidden(long view, boolean hidden); - public static native void setToolTip(long view, String msg); + static native void setToolTip(long view, String msg); } - public static final class NSObject { - public static native void release(long object); - } - - public static final class NSColor { - public static native long clearColor(); + static final class NSColor { + static native long clearColor(); } }
--- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,7 @@ import java.net.MalformedURLException; import sun.awt.*; +import sun.awt.datatransfer.DataTransferer; import sun.lwawt.*; import sun.lwawt.LWWindowPeer.PeerType; import sun.security.action.GetBooleanAction; @@ -112,8 +113,6 @@ private static final boolean inAWT; public LWCToolkit() { - SunToolkit.setDataTransfererClassName("sun.lwawt.macosx.CDataTransferer"); - areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true")); //set system property if not yet assigned System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled); @@ -159,25 +158,14 @@ return new AppleSpecificColor(color); } + // This is only called from native code. static void systemColorsChanged() { - // This is only called from native code. - EventQueue.invokeLater(new Runnable() { - public void run() { - AccessController.doPrivileged (new PrivilegedAction<Object>() { - public Object run() { - try { - final Method updateColorsMethod = SystemColor.class.getDeclaredMethod("updateSystemColors", new Class[0]); - updateColorsMethod.setAccessible(true); - updateColorsMethod.invoke(null, new Object[0]); - } catch (final Throwable e) { - e.printStackTrace(); - // swallow this if something goes horribly wrong - } - return null; - } - }); - } - }); + EventQueue.invokeLater(() -> { + AccessController.doPrivileged ((PrivilegedAction<Object>) () -> { + AWTAccessor.getSystemColorAccessor().updateSystemColors(); + return null; + }); + }); } public static LWCToolkit getLWCToolkit() { @@ -442,6 +430,11 @@ } @Override + public DataTransferer getDataTransferer() { + return CDataTransferer.getInstanceImpl(); + } + + @Override public boolean isAlwaysOnTopSupported() { return true; } @@ -732,7 +725,7 @@ /* * Returns true if the application (one of its windows) owns keyboard focus. */ - public native boolean isApplicationActive(); + native boolean isApplicationActive(); /************************ * Native methods section
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/macosx/classes/sun/lwawt/macosx/NSEvent.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. 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; + +import java.awt.event.*; + +/** + * A class representing Cocoa NSEvent class with the fields only necessary for + * JDK functionality. + */ +final class NSEvent { + private int type; + private int modifierFlags; + + // Mouse event information + private int clickCount; + private int buttonNumber; + private int x; + private int y; + private double scrollDeltaY; + private double scrollDeltaX; + private int absX; + private int absY; + + // Key event information + private short keyCode; + private String charactersIgnoringModifiers; + + // Called from native + NSEvent(int type, int modifierFlags, short keyCode, String charactersIgnoringModifiers) { + this.type = type; + this.modifierFlags = modifierFlags; + this.keyCode = keyCode; + this.charactersIgnoringModifiers = charactersIgnoringModifiers; + } + + // Called from native + NSEvent(int type, int modifierFlags, int clickCount, int buttonNumber, + int x, int y, int absX, int absY, + double scrollDeltaY, double scrollDeltaX) { + this.type = type; + this.modifierFlags = modifierFlags; + this.clickCount = clickCount; + this.buttonNumber = buttonNumber; + this.x = x; + this.y = y; + this.absX = absX; + this.absY = absY; + this.scrollDeltaY = scrollDeltaY; + this.scrollDeltaX = scrollDeltaX; + } + + int getType() { + return type; + } + + int getModifierFlags() { + return modifierFlags; + } + + int getClickCount() { + return clickCount; + } + + int getButtonNumber() { + return buttonNumber; + } + + int getX() { + return x; + } + + int getY() { + return y; + } + + double getScrollDeltaY() { + return scrollDeltaY; + } + + double getScrollDeltaX() { + return scrollDeltaX; + } + + int getAbsX() { + return absX; + } + + int getAbsY() { + return absY; + } + + short getKeyCode() { + return keyCode; + } + + String getCharactersIgnoringModifiers() { + return charactersIgnoringModifiers; + } + + @Override + public String toString() { + return "NSEvent[" + getType() + " ," + getModifierFlags() + " ," + + getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ," + + getY() + " ," + getAbsX() + " ," + getAbsY()+ " ," + getKeyCode() + " ," + + getCharactersIgnoringModifiers() + "]"; + } + + /* + * Converts an NSEvent button number to a MouseEvent constant. + */ + static int nsToJavaButton(int buttonNumber) { + int jbuttonNumber = buttonNumber + 1; + switch (buttonNumber) { + case CocoaConstants.kCGMouseButtonLeft: + jbuttonNumber = MouseEvent.BUTTON1; + break; + case CocoaConstants.kCGMouseButtonRight: + jbuttonNumber = MouseEvent.BUTTON3; + break; + case CocoaConstants.kCGMouseButtonCenter: + jbuttonNumber = MouseEvent.BUTTON2; + break; + } + return jbuttonNumber; + } + + /* + * Converts NPCocoaEvent types to AWT event types. + */ + static int npToJavaEventType(int npEventType) { + int jeventType = 0; + switch (npEventType) { + case CocoaConstants.NPCocoaEventMouseDown: + jeventType = MouseEvent.MOUSE_PRESSED; + break; + case CocoaConstants.NPCocoaEventMouseUp: + jeventType = MouseEvent.MOUSE_RELEASED; + break; + case CocoaConstants.NPCocoaEventMouseMoved: + jeventType = MouseEvent.MOUSE_MOVED; + break; + case CocoaConstants.NPCocoaEventMouseEntered: + jeventType = MouseEvent.MOUSE_ENTERED; + break; + case CocoaConstants.NPCocoaEventMouseExited: + jeventType = MouseEvent.MOUSE_EXITED; + break; + case CocoaConstants.NPCocoaEventMouseDragged: + jeventType = MouseEvent.MOUSE_DRAGGED; + break; + case CocoaConstants.NPCocoaEventKeyDown: + jeventType = KeyEvent.KEY_PRESSED; + break; + case CocoaConstants.NPCocoaEventKeyUp: + jeventType = KeyEvent.KEY_RELEASED; + break; + } + return jeventType; + } + + /* + * Converts NSEvent types to AWT event types. + */ + static int nsToJavaEventType(int nsEventType) { + int jeventType = 0; + switch (nsEventType) { + case CocoaConstants.NSLeftMouseDown: + case CocoaConstants.NSRightMouseDown: + case CocoaConstants.NSOtherMouseDown: + jeventType = MouseEvent.MOUSE_PRESSED; + break; + case CocoaConstants.NSLeftMouseUp: + case CocoaConstants.NSRightMouseUp: + case CocoaConstants.NSOtherMouseUp: + jeventType = MouseEvent.MOUSE_RELEASED; + break; + case CocoaConstants.NSMouseMoved: + jeventType = MouseEvent.MOUSE_MOVED; + break; + case CocoaConstants.NSLeftMouseDragged: + case CocoaConstants.NSRightMouseDragged: + case CocoaConstants.NSOtherMouseDragged: + jeventType = MouseEvent.MOUSE_DRAGGED; + break; + case CocoaConstants.NSMouseEntered: + jeventType = MouseEvent.MOUSE_ENTERED; + break; + case CocoaConstants.NSMouseExited: + jeventType = MouseEvent.MOUSE_EXITED; + break; + case CocoaConstants.NSScrollWheel: + jeventType = MouseEvent.MOUSE_WHEEL; + break; + case CocoaConstants.NSKeyDown: + jeventType = KeyEvent.KEY_PRESSED; + break; + case CocoaConstants.NSKeyUp: + jeventType = KeyEvent.KEY_RELEASED; + break; + } + return jeventType; + } + + /* + * Converts NSEvent mouse modifiers to AWT mouse modifiers. + */ + static native int nsToJavaMouseModifiers(int buttonNumber, + int modifierFlags); + + /* + * Converts NSEvent key modifiers to AWT key modifiers. + */ + static native int nsToJavaKeyModifiers(int modifierFlags); + + /* + * Converts NSEvent key info to AWT key info. + */ + static native boolean nsToJavaKeyInfo(int[] in, int[] out); + + /* + * Converts NSEvent key modifiers to AWT key info. + */ + static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out); + + /* + * There is a small number of NS characters that need to be converted + * into other characters before we pass them to AWT. + */ + static native char nsToJavaChar(char nsChar, int modifierFlags); + + static boolean isPopupTrigger(int jmodifiers) { + final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0); + final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0); + final boolean isControlDown = ((jmodifiers & InputEvent.CTRL_DOWN_MASK) != 0); + return isRightButtonDown || (isControlDown && isLeftButtonDown); + } +}
--- a/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java Wed Mar 19 15:19:35 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,260 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. 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.event; - -import sun.lwawt.macosx.CocoaConstants; -import java.awt.event.*; - -/** - * A class representing Cocoa NSEvent class with the fields only necessary for - * JDK functionality. - */ -public final class NSEvent { - private int type; - private int modifierFlags; - - // Mouse event information - private int clickCount; - private int buttonNumber; - private int x; - private int y; - private double scrollDeltaY; - private double scrollDeltaX; - private int absX; - private int absY; - - // Key event information - private short keyCode; - private String charactersIgnoringModifiers; - - public NSEvent(int type, int modifierFlags, short keyCode, String charactersIgnoringModifiers) { - this.type = type; - this.modifierFlags = modifierFlags; - this.keyCode = keyCode; - this.charactersIgnoringModifiers = charactersIgnoringModifiers; - } - - public NSEvent(int type, int modifierFlags, int clickCount, int buttonNumber, - int x, int y, int absX, int absY, - double scrollDeltaY, double scrollDeltaX) { - this.type = type; - this.modifierFlags = modifierFlags; - this.clickCount = clickCount; - this.buttonNumber = buttonNumber; - this.x = x; - this.y = y; - this.absX = absX; - this.absY = absY; - this.scrollDeltaY = scrollDeltaY; - this.scrollDeltaX = scrollDeltaX; - } - - public int getType() { - return type; - } - - public int getModifierFlags() { - return modifierFlags; - } - - public int getClickCount() { - return clickCount; - } - - public int getButtonNumber() { - return buttonNumber; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - - public double getScrollDeltaY() { - return scrollDeltaY; - } - - public double getScrollDeltaX() { - return scrollDeltaX; - } - - public int getAbsX() { - return absX; - } - - public int getAbsY() { - return absY; - } - - public short getKeyCode() { - return keyCode; - } - - public String getCharactersIgnoringModifiers() { - return charactersIgnoringModifiers; - } - - @Override - public String toString() { - return "NSEvent[" + getType() + " ," + getModifierFlags() + " ," - + getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ," - + getY() + " ," + getAbsX() + " ," + getAbsY()+ " ," + getKeyCode() + " ," - + getCharactersIgnoringModifiers() + "]"; - } - - /* - * Converts an NSEvent button number to a MouseEvent constant. - */ - public static int nsToJavaButton(int buttonNumber) { - int jbuttonNumber = buttonNumber + 1; - switch (buttonNumber) { - case CocoaConstants.kCGMouseButtonLeft: - jbuttonNumber = MouseEvent.BUTTON1; - break; - case CocoaConstants.kCGMouseButtonRight: - jbuttonNumber = MouseEvent.BUTTON3; - break; - case CocoaConstants.kCGMouseButtonCenter: - jbuttonNumber = MouseEvent.BUTTON2; - break; - } - return jbuttonNumber; - } - - /* - * Converts NPCocoaEvent types to AWT event types. - */ - public static int npToJavaEventType(int npEventType) { - int jeventType = 0; - switch (npEventType) { - case CocoaConstants.NPCocoaEventMouseDown: - jeventType = MouseEvent.MOUSE_PRESSED; - break; - case CocoaConstants.NPCocoaEventMouseUp: - jeventType = MouseEvent.MOUSE_RELEASED; - break; - case CocoaConstants.NPCocoaEventMouseMoved: - jeventType = MouseEvent.MOUSE_MOVED; - break; - case CocoaConstants.NPCocoaEventMouseEntered: - jeventType = MouseEvent.MOUSE_ENTERED; - break; - case CocoaConstants.NPCocoaEventMouseExited: - jeventType = MouseEvent.MOUSE_EXITED; - break; - case CocoaConstants.NPCocoaEventMouseDragged: - jeventType = MouseEvent.MOUSE_DRAGGED; - break; - case CocoaConstants.NPCocoaEventKeyDown: - jeventType = KeyEvent.KEY_PRESSED; - break; - case CocoaConstants.NPCocoaEventKeyUp: - jeventType = KeyEvent.KEY_RELEASED; - break; - } - return jeventType; - } - - /* - * Converts NSEvent types to AWT event types. - */ - public static int nsToJavaEventType(int nsEventType) { - int jeventType = 0; - switch (nsEventType) { - case CocoaConstants.NSLeftMouseDown: - case CocoaConstants.NSRightMouseDown: - case CocoaConstants.NSOtherMouseDown: - jeventType = MouseEvent.MOUSE_PRESSED; - break; - case CocoaConstants.NSLeftMouseUp: - case CocoaConstants.NSRightMouseUp: - case CocoaConstants.NSOtherMouseUp: - jeventType = MouseEvent.MOUSE_RELEASED; - break; - case CocoaConstants.NSMouseMoved: - jeventType = MouseEvent.MOUSE_MOVED; - break; - case CocoaConstants.NSLeftMouseDragged: - case CocoaConstants.NSRightMouseDragged: - case CocoaConstants.NSOtherMouseDragged: - jeventType = MouseEvent.MOUSE_DRAGGED; - break; - case CocoaConstants.NSMouseEntered: - jeventType = MouseEvent.MOUSE_ENTERED; - break; - case CocoaConstants.NSMouseExited: - jeventType = MouseEvent.MOUSE_EXITED; - break; - case CocoaConstants.NSScrollWheel: - jeventType = MouseEvent.MOUSE_WHEEL; - break; - case CocoaConstants.NSKeyDown: - jeventType = KeyEvent.KEY_PRESSED; - break; - case CocoaConstants.NSKeyUp: - jeventType = KeyEvent.KEY_RELEASED; - break; - } - return jeventType; - } - - /* - * Converts NSEvent mouse modifiers to AWT mouse modifiers. - */ - public static native int nsToJavaMouseModifiers(int buttonNumber, - int modifierFlags); - - /* - * Converts NSEvent key modifiers to AWT key modifiers. - */ - public static native int nsToJavaKeyModifiers(int modifierFlags); - - /* - * Converts NSEvent key info to AWT key info. - */ - public static native boolean nsToJavaKeyInfo(int[] in, int[] out); - - /* - * Converts NSEvent key modifiers to AWT key info. - */ - public static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out); - - /* - * There is a small number of NS characters that need to be converted - * into other characters before we pass them to AWT. - */ - public static native char nsToJavaChar(char nsChar, int modifierFlags); - - public static boolean isPopupTrigger(int jmodifiers) { - final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0); - final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0); - final boolean isControlDown = ((jmodifiers & InputEvent.CTRL_DOWN_MASK) != 0); - return isRightButtonDown || (isControlDown && isLeftButtonDown); - } -}
--- a/src/macosx/lib/flavormap.properties Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/lib/flavormap.properties Mon Mar 24 13:15:07 2014 -0700 @@ -79,3 +79,5 @@ TIFF=image/x-java-image;class=java.awt.Image RICH_TEXT=text/rtf HTML=text/html;charset=utf-8;eoln="\r\n";terminators=1 +URL=application/x-java-url;class=java.net.URL +URL=text/uri-list;eoln="\r\n";terminators=1
--- a/src/macosx/native/sun/awt/AWTEvent.m Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/native/sun/awt/AWTEvent.m Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -633,12 +633,12 @@ } /* - * Class: sun_lwawt_macosx_event_NSEvent + * Class: sun_lwawt_macosx_NSEvent * Method: nsToJavaMouseModifiers * Signature: (II)I */ JNIEXPORT jint JNICALL -Java_sun_lwawt_macosx_event_NSEvent_nsToJavaMouseModifiers +Java_sun_lwawt_macosx_NSEvent_nsToJavaMouseModifiers (JNIEnv *env, jclass cls, jint buttonNumber, jint modifierFlags) { jint jmodifiers = 0; @@ -653,12 +653,12 @@ } /* - * Class: sun_lwawt_macosx_event_NSEvent + * Class: sun_lwawt_macosx_NSEvent * Method: nsToJavaKeyModifiers * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_sun_lwawt_macosx_event_NSEvent_nsToJavaKeyModifiers +Java_sun_lwawt_macosx_NSEvent_nsToJavaKeyModifiers (JNIEnv *env, jclass cls, jint modifierFlags) { jint jmodifiers = 0; @@ -673,12 +673,12 @@ } /* - * Class: sun_lwawt_macosx_event_NSEvent + * Class: sun_lwawt_macosx_NSEvent * Method: nsToJavaKeyInfo * Signature: ([I[I)Z */ JNIEXPORT jboolean JNICALL -Java_sun_lwawt_macosx_event_NSEvent_nsToJavaKeyInfo +Java_sun_lwawt_macosx_NSEvent_nsToJavaKeyInfo (JNIEnv *env, jclass cls, jintArray inData, jintArray outData) { BOOL postsTyped = NO; @@ -715,12 +715,12 @@ } /* - * Class: sun_lwawt_macosx_event_NSEvent + * Class: sun_lwawt_macosx_NSEvent * Method: nsKeyModifiersToJavaKeyInfo * Signature: ([I[I)V */ JNIEXPORT void JNICALL -Java_sun_lwawt_macosx_event_NSEvent_nsKeyModifiersToJavaKeyInfo +Java_sun_lwawt_macosx_NSEvent_nsKeyModifiersToJavaKeyInfo (JNIEnv *env, jclass cls, jintArray inData, jintArray outData) { JNF_COCOA_ENTER(env); @@ -753,12 +753,12 @@ } /* - * Class: sun_lwawt_macosx_event_NSEvent + * Class: sun_lwawt_macosx_NSEvent * Method: nsToJavaChar * Signature: (CI)C */ JNIEXPORT jint JNICALL -Java_sun_lwawt_macosx_event_NSEvent_nsToJavaChar +Java_sun_lwawt_macosx_NSEvent_nsToJavaChar (JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags) { jchar javaChar = 0;
--- a/src/macosx/native/sun/awt/AWTView.h Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/native/sun/awt/AWTView.h Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ #import "CDragSource.h" #import "CDropTarget.h" -@interface AWTView : NSView<NSTextInputClient> { +@interface AWTView : NSView<NSTextInputClient, CDragSourceHolder, CDropTargetHolder> { @private jobject m_cPlatformView; @@ -61,14 +61,8 @@ - (id) initWithRect:(NSRect) rect platformView:(jobject)cPlatformView windowLayer:(CALayer*)windowLayer; - (void) deliverJavaMouseEvent: (NSEvent *) event; -- (void) resetTrackingArea; -- (void) deliverJavaKeyEventHelper: (NSEvent *) event; - (jobject) awtComponent:(JNIEnv *)env; -- (void) setDragSource:(CDragSource *)source; -- (void) setDropTarget:(CDropTarget *)target; - - // Input method-related events - (void)setInputMethod:(jobject)inputMethod; - (void)abandonInput;
--- a/src/macosx/native/sun/awt/AWTView.m Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/native/sun/awt/AWTView.m Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,10 @@ @interface AWTView() @property (retain) CDropTarget *_dropTarget; @property (retain) CDragSource *_dragSource; + +-(void) deliverResize: (NSRect) rect; +-(void) resetTrackingArea; +-(void) deliverJavaKeyEventHelper: (NSEvent*) event; @end // Uncomment this line to see fprintfs of each InputMethod API being called on this View @@ -376,7 +380,7 @@ clickCount = [event clickCount]; } - static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent"); + static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V"); jobject jEvent = JNFNewObject(env, jctor_NSEvent, [event type], @@ -393,7 +397,7 @@ } static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView"); - static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V"); + static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); JNFCallVoidMethod(env, m_cPlatformView, jm_deliverMouseEvent, jEvent); } @@ -441,7 +445,7 @@ characters = JNFNSToJavaString(env, [event characters]); } - static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent"); + static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;)V"); jobject jevent = JNFNewObject(env, jctor_NSEvent, [event type], @@ -451,7 +455,7 @@ static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView"); static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView, - "deliverKeyEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V"); + "deliverKeyEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); JNFCallVoidMethod(env, m_cPlatformView, jm_deliverKeyEvent, jevent); if (characters != NULL) {
--- a/src/macosx/native/sun/awt/CDragSource.h Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/native/sun/awt/CDragSource.h Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,9 +29,15 @@ #import <Cocoa/Cocoa.h> #include <jni.h> +@class CDragSource; + +@protocol CDragSourceHolder +- (void) setDragSource:(CDragSource *)source; +@end + @interface CDragSource : NSObject { @private - NSView* fView; + NSView<CDragSourceHolder>* fView; jobject fComponent; jobject fDragSourceContextPeer; @@ -53,8 +59,6 @@ jint fDragMouseModifiers; } -+ (CDragSource *) currentDragSource; - // Common methods: - (id) init:(jobject)jDragSourceContextPeer component:(jobject)jComponent @@ -84,13 +88,6 @@ - (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint; - (BOOL)ignoreModifierKeysWhileDragging; -// Updates from the destination to the source -- (void) postDragEnter; -- (void) postDragExit; - -// Utility -- (NSPoint) mapNSScreenPointToJavaWithOffset:(NSPoint) point; - @end #endif // CDragSource_h
--- a/src/macosx/native/sun/awt/CDragSource.m Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/native/sun/awt/CDragSource.m Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,15 +75,18 @@ static NSDragOperation sDragOperation; static NSPoint sDraggingLocation; -static CDragSource* sCurrentDragSource; static BOOL sNeedsEnter; +@interface CDragSource () +// Updates from the destination to the source +- (void) postDragEnter; +- (void) postDragExit; +// Utility +- (NSPoint) mapNSScreenPointToJavaWithOffset:(NSPoint) point; +@end + @implementation CDragSource -+ (CDragSource *) currentDragSource { - return sCurrentDragSource; -} - - (id) init:(jobject)jDragSourceContextPeer component:(jobject)jComponent control:(id)control @@ -515,8 +518,6 @@ fDragKeyModifiers = [DnDUtilities extractJavaExtKeyModifiersFromJavaExtModifiers:fModifiers]; fDragMouseModifiers = [DnDUtilities extractJavaExtMouseModifiersFromJavaExtModifiers:fModifiers]; - // Set the current DragSource - sCurrentDragSource = self; sNeedsEnter = YES; @try { @@ -566,8 +567,6 @@ JNF_MEMBER_CACHE(resetHoveringMethod, CDragSourceContextPeerClass, "resetHovering", "()V"); JNFCallVoidMethod(env, fDragSourceContextPeer, resetHoveringMethod); // Hust reset static variable } @finally { - // Clear the current DragSource - sCurrentDragSource = nil; sNeedsEnter = NO; }
--- a/src/macosx/native/sun/awt/CDropTarget.h Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/native/sun/awt/CDropTarget.h Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,9 +31,15 @@ @class ControlModel; +@class CDropTarget; + +@protocol CDropTargetHolder +- (void) setDropTarget:(CDropTarget *)target; +@end + @interface CDropTarget : NSObject { @private - NSView* fView; + NSView<CDropTargetHolder>* fView; jobject fComponent; jobject fDropTarget; jobject fDropTargetContextPeer;
--- a/src/macosx/native/sun/awt/CTrayIcon.m Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/native/sun/awt/CTrayIcon.m Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -135,7 +135,7 @@ clickCount = [event clickCount]; - static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent"); + static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V"); jobject jEvent = JNFNewObject(env, jctor_NSEvent, [event type], @@ -152,7 +152,7 @@ } static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon"); - static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V"); + static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); JNFCallVoidMethod(env, peer, jm_handleMouseEvent, jEvent); }
--- a/src/macosx/native/sun/awt/CWrapper.h Wed Mar 19 15:19:35 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. 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. - */
--- a/src/macosx/native/sun/awt/CWrapper.m Wed Mar 19 15:19:35 2014 -0700 +++ b/src/macosx/native/sun/awt/CWrapper.m Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,38 +23,11 @@ * questions. */ -#import "CWrapper.h" - #import <JavaNativeFoundation/JavaNativeFoundation.h> - -#import "AWTWindow.h" -#import "LWCToolkit.h" -#import "GeomUtilities.h" #import "ThreadUtilities.h" - #import "sun_lwawt_macosx_CWrapper_NSWindow.h" /* - * Class: sun_lwawt_macosx_CWrapper$NSObject - * Method: release - * Signature: (J)V - */ -JNIEXPORT void JNICALL -Java_sun_lwawt_macosx_CWrapper_00024NSObject_release -(JNIEnv *env, jclass cls, jlong objectPtr) -{ -JNF_COCOA_ENTER(env); - - id obj = (id)jlong_to_ptr(objectPtr); - [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ - CFRelease(obj); - }]; - -JNF_COCOA_EXIT(env); -} - - -/* * Class: sun_lwawt_macosx_CWrapper$NSWindow * Method: makeKeyAndOrderFront * Signature: (J)V @@ -249,6 +222,7 @@ dispatch_once(&pred, ^{ LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSNormalWindowLevel] = NSNormalWindowLevel; LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSFloatingWindowLevel] = NSFloatingWindowLevel; + LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSPopUpMenuWindowLevel] = NSPopUpMenuWindowLevel; }); } @@ -308,8 +282,8 @@ { JNF_COCOA_ENTER(env); - AWTWindow *parent = (AWTWindow *)jlong_to_ptr(parentPtr); - AWTWindow *child = (AWTWindow *)jlong_to_ptr(childPtr); + NSWindow *parent = (NSWindow *)jlong_to_ptr(parentPtr); + NSWindow *child = (NSWindow *)jlong_to_ptr(childPtr); [ThreadUtilities performOnMainThread:@selector(removeChildWindow:) on:parent withObject:child @@ -320,26 +294,6 @@ /* * Class: sun_lwawt_macosx_CWrapper$NSWindow - * Method: setFrame - * Signature: (JIIIIZ)V - */ -JNIEXPORT void JNICALL -Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setFrame -(JNIEnv *env, jclass cls, jlong windowPtr, jint x, jint y, jint w, jint h, jboolean display) -{ -JNF_COCOA_ENTER(env); - - AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); - NSRect frame = NSMakeRect(x, y, w, h); - [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ - [window setFrame:frame display:display]; - }]; - -JNF_COCOA_EXIT(env); -} - -/* - * Class: sun_lwawt_macosx_CWrapper$NSWindow * Method: setAlphaValue * Signature: (JF)V */ @@ -349,7 +303,7 @@ { JNF_COCOA_ENTER(env); - AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); + NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [window setAlphaValue:(CGFloat)alpha]; }]; @@ -368,7 +322,7 @@ { JNF_COCOA_ENTER(env); - AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); + NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [window setOpaque:(BOOL)opaque]; }]; @@ -387,7 +341,7 @@ { JNF_COCOA_ENTER(env); - AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); + NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); NSColor *color = (NSColor *)jlong_to_ptr(colorPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [window setBackgroundColor:color]; @@ -397,6 +351,7 @@ } /* + * Class: sun_lwawt_macosx_CWrapper$NSWindow * Method: miniaturize * Signature: (J)V */ @@ -560,33 +515,6 @@ /* * Class: sun_lwawt_macosx_CWrapper$NSView - * Method: frame - * Signature: (J)Ljava/awt/Rectangle; - */ -JNIEXPORT jobject JNICALL -Java_sun_lwawt_macosx_CWrapper_00024NSView_frame -(JNIEnv *env, jclass cls, jlong viewPtr) -{ - jobject jRect = NULL; - -JNF_COCOA_ENTER(env); - - __block NSRect rect = NSZeroRect; - - NSView *view = (NSView *)jlong_to_ptr(viewPtr); - [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - rect = [view frame]; - }]; - - jRect = NSToJavaRect(env, rect); - -JNF_COCOA_EXIT(env); - - return jRect; -} - -/* - * Class: sun_lwawt_macosx_CWrapper$NSView * Method: window * Signature: (J)J */
--- a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java Mon Mar 24 13:15:07 2014 -0700 @@ -287,7 +287,7 @@ synchronized (this) { KeyEvent ke = enqueuedKeyEvents.isEmpty() ? null : enqueuedKeyEvents.getFirst(); if (ke != null && time >= ke.getWhen()) { - TypeAheadMarker marker = typeAheadMarkers.getFirst(); + TypeAheadMarker marker = typeAheadMarkers.isEmpty() ? null : typeAheadMarkers.getFirst(); if (marker != null) { Window toplevel = marker.untilFocused.getContainingWindow(); // Check that the component awaiting focus belongs to
--- a/src/share/classes/java/awt/SystemColor.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/java/awt/SystemColor.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,8 @@ */ package java.awt; +import sun.awt.AWTAccessor; + import java.io.ObjectStreamException; import java.lang.annotation.Native; @@ -459,7 +461,8 @@ }; static { - updateSystemColors(); + AWTAccessor.setSystemColorAccessor(SystemColor::updateSystemColors); + updateSystemColors(); } /**
--- a/src/share/classes/java/awt/datatransfer/DataFlavor.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/java/awt/datatransfer/DataFlavor.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -570,7 +570,7 @@ if (DataTransferer.isFlavorCharsetTextType(this) && (isRepresentationClassInputStream() || isRepresentationClassByteBuffer() || - DataTransferer.byteArrayClass.equals(representationClass))) + byte[].class.equals(representationClass))) { params += ";charset=" + DataTransferer.getTextCharset(this); } @@ -1015,7 +1015,7 @@ !(isRepresentationClassReader() || String.class.equals(representationClass) || isRepresentationClassCharBuffer() || - DataTransferer.charArrayClass.equals(representationClass))) + char[].class.equals(representationClass))) { String thisCharset = DataTransferer.canonicalName(getParameter("charset")); @@ -1100,8 +1100,7 @@ !(isRepresentationClassReader() || String.class.equals(representationClass) || isRepresentationClassCharBuffer() || - DataTransferer.charArrayClass.equals - (representationClass))) + char[].class.equals(representationClass))) { String charset = DataTransferer.canonicalName(getParameter("charset"));
--- a/src/share/classes/java/awt/dnd/DragGestureEvent.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/java/awt/dnd/DragGestureEvent.java Mon Mar 24 13:15:07 2014 -0700 @@ -36,6 +36,7 @@ import java.awt.datatransfer.Transferable; +import java.io.InvalidObjectException; import java.util.EventObject; import java.util.Collections; @@ -329,22 +330,50 @@ { ObjectInputStream.GetField f = s.readFields(); - dragSource = (DragSource)f.get("dragSource", null); - component = (Component)f.get("component", null); - origin = (Point)f.get("origin", null); - action = f.get("action", 0); + DragSource newDragSource = (DragSource)f.get("dragSource", null); + if (newDragSource == null) { + throw new InvalidObjectException("null DragSource"); + } + dragSource = newDragSource; + + Component newComponent = (Component)f.get("component", null); + if (newComponent == null) { + throw new InvalidObjectException("null component"); + } + component = newComponent; + + Point newOrigin = (Point)f.get("origin", null); + if (newOrigin == null) { + throw new InvalidObjectException("null origin"); + } + origin = newOrigin; + + int newAction = f.get("action", 0); + if (newAction != DnDConstants.ACTION_COPY && + newAction != DnDConstants.ACTION_MOVE && + newAction != DnDConstants.ACTION_LINK) { + throw new InvalidObjectException("bad action"); + } + action = newAction; + // Pre-1.4 support. 'events' was previously non-transient + List newEvents; try { - events = (List)f.get("events", null); + newEvents = (List)f.get("events", null); } catch (IllegalArgumentException e) { // 1.4-compatible byte stream. 'events' was written explicitly - events = (List)s.readObject(); + newEvents = (List)s.readObject(); } // Implementation assumes 'events' is never null. - if (events == null) { - events = Collections.EMPTY_LIST; + if (newEvents != null && newEvents.isEmpty()) { + // Constructor treats empty events list as invalid value + // Throw exception if serialized list is empty + throw new InvalidObjectException("empty list of events"); + } else if (newEvents == null) { + newEvents = Collections.emptyList(); } + events = newEvents; } /*
--- a/src/share/classes/java/awt/dnd/DragGestureRecognizer.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/java/awt/dnd/DragGestureRecognizer.java Mon Mar 24 13:15:07 2014 -0700 @@ -29,6 +29,8 @@ import java.awt.Component; import java.awt.Point; +import java.io.InvalidObjectException; +import java.util.Collections; import java.util.TooManyListenersException; import java.util.ArrayList; @@ -411,10 +413,21 @@ * * @since 1.4 */ + @SuppressWarnings("unchecked") private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + DragSource newDragSource = (DragSource)f.get("dragSource", null); + if (newDragSource == null) { + throw new InvalidObjectException("null DragSource"); + } + dragSource = newDragSource; + + component = (Component)f.get("component", null); + sourceActions = f.get("sourceActions", 0) & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); + events = (ArrayList<InputEvent>)f.get("events", new ArrayList<>(1)); dragGestureListener = (DragGestureListener)s.readObject(); }
--- a/src/share/classes/java/awt/dnd/DragSourceContext.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/java/awt/dnd/DragSourceContext.java Mon Mar 24 13:15:07 2014 -0700 @@ -37,6 +37,7 @@ import java.awt.dnd.peer.DragSourceContextPeer; import java.io.IOException; +import java.io.InvalidObjectException; import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.io.Serializable; @@ -562,7 +563,36 @@ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + DragGestureEvent newTrigger = (DragGestureEvent)f.get("trigger", null); + if (newTrigger == null) { + throw new InvalidObjectException("Null trigger"); + } + if (newTrigger.getDragSource() == null) { + throw new InvalidObjectException("Null DragSource"); + } + if (newTrigger.getComponent() == null) { + throw new InvalidObjectException("Null trigger component"); + } + + int DGRActions = newTrigger.getSourceAsDragGestureRecognizer().getSourceActions() + & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); + if (DGRActions == DnDConstants.ACTION_NONE) { + throw new InvalidObjectException("Invalid source actions"); + } + int triggerActions = newTrigger.getDragAction(); + if (triggerActions != DnDConstants.ACTION_COPY && + triggerActions != DnDConstants.ACTION_MOVE && + triggerActions != DnDConstants.ACTION_LINK) { + throw new InvalidObjectException("No drag action"); + } + trigger = newTrigger; + + cursor = (Cursor)f.get("cursor", null); + useCustomCursor = f.get("useCustomCursor", false); + sourceActions = f.get("sourceActions", 0) + & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); transferable = (Transferable)s.readObject(); listener = (DragSourceListener)s.readObject(); @@ -630,5 +660,5 @@ * * @serial */ - private final int sourceActions; + private int sourceActions; }
--- a/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java Mon Mar 24 13:15:07 2014 -0700 @@ -200,6 +200,13 @@ implIsInstanceMethod ? "instance" : "static", implInfo, instantiatedArity, samArity)); } + for (MethodType bridgeMT : additionalBridges) { + if (bridgeMT.parameterCount() != samArity) { + throw new LambdaConversionException( + String.format("Incorrect number of parameters for bridge signature %s; incompatible with %s", + bridgeMT, samMethodType)); + } + } // If instance: first captured arg (receiver) must be subtype of class where impl method is defined final int capturedStart; @@ -232,7 +239,7 @@ throw new LambdaConversionException( String.format("Invalid receiver type %s; not a subtype of implementation receiver type %s", receiverClass, implReceiverClass)); - } + } } else { // no receiver capturedStart = 0; @@ -274,11 +281,18 @@ String.format("Type mismatch for lambda return: %s is not convertible to %s", actualReturnType, expectedType)); } - if (!isAdaptableToAsReturn(expectedType, samReturnType)) { + if (!isAdaptableToAsReturnStrict(expectedType, samReturnType)) { throw new LambdaConversionException( String.format("Type mismatch for lambda expected return: %s is not convertible to %s", expectedType, samReturnType)); } + for (MethodType bridgeMT : additionalBridges) { + if (!isAdaptableToAsReturnStrict(expectedType, bridgeMT.returnType())) { + throw new LambdaConversionException( + String.format("Type mismatch for lambda expected return: %s is not convertible to %s", + expectedType, bridgeMT.returnType())); + } + } } /** @@ -330,6 +344,10 @@ return toType.equals(void.class) || !fromType.equals(void.class) && isAdaptableTo(fromType, toType, false); } + private boolean isAdaptableToAsReturnStrict(Class<?> fromType, Class<?> toType) { + if (fromType.equals(void.class)) return toType.equals(void.class); + return isAdaptableTo(fromType, toType, true); + } /*********** Logging support -- for debugging only, uncomment as needed
--- a/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java Mon Mar 24 13:15:07 2014 -0700 @@ -212,7 +212,7 @@ * @param functional */ void convertType(Class<?> arg, Class<?> target, Class<?> functional) { - if (arg.equals(target)) { + if (arg.equals(target) && arg.equals(functional)) { return; } if (arg == Void.TYPE || target == Void.TYPE) {
--- a/src/share/classes/sun/awt/AWTAccessor.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/sun/awt/AWTAccessor.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -729,6 +729,13 @@ } /* + * An accessor object for the SystemColor class + */ + public interface SystemColorAccessor { + void updateSystemColors(); + } + + /* * Accessor instances are initialized in the static initializers of * corresponding AWT classes by using setters defined below. */ @@ -757,6 +764,7 @@ private static SequencedEventAccessor sequencedEventAccessor; private static ToolkitAccessor toolkitAccessor; private static InvocationEventAccessor invocationEventAccessor; + private static SystemColorAccessor systemColorAccessor; /* * Set an accessor object for the java.awt.Component class. @@ -1182,4 +1190,22 @@ public static InvocationEventAccessor getInvocationEventAccessor() { return invocationEventAccessor; } + + /* + * Get the accessor object for the java.awt.SystemColor class. + */ + public static SystemColorAccessor getSystemColorAccessor() { + if (systemColorAccessor == null) { + unsafe.ensureClassInitialized(SystemColor.class); + } + + return systemColorAccessor; + } + + /* + * Set the accessor object for the java.awt.SystemColor class. + */ + public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) { + AWTAccessor.systemColorAccessor = systemColorAccessor; + } }
--- a/src/share/classes/sun/awt/HToolkit.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/sun/awt/HToolkit.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package sun.awt; +import sun.awt.datatransfer.DataTransferer; + import java.awt.*; import java.awt.dnd.*; import java.awt.dnd.peer.DragSourceContextPeer; @@ -184,6 +186,11 @@ return false; } + @Override + public DataTransferer getDataTransferer() { + return null; + } + public GlobalCursorManager getGlobalCursorManager() throws HeadlessException { throw new HeadlessException();
--- a/src/share/classes/sun/awt/SunToolkit.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/sun/awt/SunToolkit.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,6 +46,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import sun.awt.datatransfer.DataTransferer; import sun.security.util.SecurityConstants; import sun.util.logging.PlatformLogger; import sun.misc.SoftCache; @@ -203,6 +204,8 @@ public abstract boolean isTraySupported(); + public abstract DataTransferer getDataTransferer(); + @SuppressWarnings("deprecation") public abstract FontPeer getFontPeer(String name, int style); @@ -1191,19 +1194,6 @@ return getStartupLocale(); } - private static String dataTransfererClassName = null; - - protected static void setDataTransfererClassName(String className) { - dataTransfererClassName = className; - } - - public static String getDataTransfererClassName() { - if (dataTransfererClassName == null) { - Toolkit.getDefaultToolkit(); // transferer set during toolkit init - } - return dataTransfererClassName; - } - // Support for window closing event notifications private transient WindowClosingListener windowClosingListener = null; /**
--- a/src/share/classes/sun/awt/datatransfer/DataTransferer.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/share/classes/sun/awt/datatransfer/DataTransferer.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,10 @@ package sun.awt.datatransfer; -import java.awt.AWTError; import java.awt.EventQueue; +import java.awt.Graphics; import java.awt.Image; -import java.awt.Graphics; +import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.FlavorMap; @@ -138,16 +138,6 @@ public abstract class DataTransferer { /** - * Cached value of Class.forName("[C"); - */ - public static final Class charArrayClass; - - /** - * Cached value of Class.forName("[B"); - */ - public static final Class byteArrayClass; - - /** * The <code>DataFlavor</code> representing plain text with Unicode * encoding, where: * <pre> @@ -241,15 +231,6 @@ private static final PlatformLogger dtLog = PlatformLogger.getLogger("sun.awt.datatransfer.DataTransfer"); static { - Class tCharArrayClass = null, tByteArrayClass = null; - try { - tCharArrayClass = Class.forName("[C"); - tByteArrayClass = Class.forName("[B"); - } catch (ClassNotFoundException cannotHappen) { - } - charArrayClass = tCharArrayClass; - byteArrayClass = tByteArrayClass; - DataFlavor tPlainTextStringFlavor = null; try { tPlainTextStringFlavor = new DataFlavor @@ -290,63 +271,8 @@ * that in a headless environment, there may be no DataTransferer instance; * instead, null will be returned. */ - public static DataTransferer getInstance() { - synchronized (DataTransferer.class) { - if (transferer == null) { - final String name = SunToolkit.getDataTransfererClassName(); - if (name != null) { - PrivilegedAction<DataTransferer> action = new PrivilegedAction<DataTransferer>() - { - public DataTransferer run() { - Class cls = null; - Method method = null; - DataTransferer ret = null; - - try { - cls = Class.forName(name); - } catch (ClassNotFoundException e) { - ClassLoader cl = ClassLoader. - getSystemClassLoader(); - if (cl != null) { - try { - cls = cl.loadClass(name); - } catch (ClassNotFoundException ee) { - ee.printStackTrace(); - throw new AWTError("DataTransferer not found: " + name); - } - } - } - if (cls != null) { - try { - method = cls.getDeclaredMethod("getInstanceImpl"); - method.setAccessible(true); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new AWTError("Cannot instantiate DataTransferer: " + name); - } catch (SecurityException e) { - e.printStackTrace(); - throw new AWTError("Access is denied for DataTransferer: " + name); - } - } - if (method != null) { - try { - ret = (DataTransferer) method.invoke(null); - } catch (InvocationTargetException e) { - e.printStackTrace(); - throw new AWTError("Cannot instantiate DataTransferer: " + name); - } catch (IllegalAccessException e) { - e.printStackTrace(); - throw new AWTError("Cannot access DataTransferer: " + name); - } - } - return ret; - } - }; - transferer = AccessController.doPrivileged(action); - } - } - } - return transferer; + public static synchronized DataTransferer getInstance() { + return ((SunToolkit) Toolkit.getDefaultToolkit()).getDataTransferer(); } /** @@ -459,14 +385,14 @@ if (flavor.isRepresentationClassReader() || String.class.equals(rep_class) || flavor.isRepresentationClassCharBuffer() || - DataTransferer.charArrayClass.equals(rep_class)) + char[].class.equals(rep_class)) { return true; } if (!(flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || - DataTransferer.byteArrayClass.equals(rep_class))) { + byte[].class.equals(rep_class))) { return false; } @@ -490,8 +416,7 @@ return (flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || - DataTransferer.byteArrayClass. - equals(flavor.getRepresentationClass())); + byte[].class.equals(flavor.getRepresentationClass())); } /** @@ -1243,7 +1168,7 @@ format); // Source data is a char array. Convert to a String and recur. - } else if (charArrayClass.equals(flavor.getRepresentationClass())) { + } else if (char[].class.equals(flavor.getRepresentationClass())) { if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) { throw new IOException ("cannot transfer non-text data as char array"); @@ -1274,7 +1199,7 @@ // Source data is a byte array. For arbitrary flavors, simply return // the array. For text flavors, decode back to a String and recur to // reencode according to the requested format. - } else if (byteArrayClass.equals(flavor.getRepresentationClass())) { + } else if (byte[].class.equals(flavor.getRepresentationClass())) { byte[] bytes = (byte[])obj; if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) { @@ -1651,7 +1576,7 @@ // Target data is a char array. Recur to obtain String and convert to // char array. - } else if (charArrayClass.equals(flavor.getRepresentationClass())) { + } else if (char[].class.equals(flavor.getRepresentationClass())) { if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) { throw new IOException ("cannot transfer non-text data as char array"); @@ -1679,7 +1604,7 @@ // the raw bytes. For text flavors, convert to a String to strip // terminators and search-and-replace EOLN, then reencode according to // the requested flavor. - } else if (byteArrayClass.equals(flavor.getRepresentationClass())) { + } else if (byte[].class.equals(flavor.getRepresentationClass())) { if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) { theObject = translateBytesToString( bytes, format, localeTransferable @@ -1807,7 +1732,7 @@ theObject = constructFlavoredObject(reader, flavor, Reader.class); // Target data is a byte array - } else if (byteArrayClass.equals(flavor.getRepresentationClass())) { + } else if (byte[].class.equals(flavor.getRepresentationClass())) { if(isFlavorCharsetTextType(flavor) && isTextFormat(format)) { theObject = translateBytesToString(inputStreamToByteArray(str), format, localeTransferable) .getBytes(DataTransferer.getTextCharset(flavor)); @@ -2857,7 +2782,7 @@ HashMap decodedTextRepresentationsMap = new HashMap(4, 1.0f); decodedTextRepresentationsMap.put - (DataTransferer.charArrayClass, Integer.valueOf(0)); + (char[].class, Integer.valueOf(0)); decodedTextRepresentationsMap.put (java.nio.CharBuffer.class, Integer.valueOf(1)); decodedTextRepresentationsMap.put @@ -2873,7 +2798,7 @@ HashMap encodedTextRepresentationsMap = new HashMap(3, 1.0f); encodedTextRepresentationsMap.put - (DataTransferer.byteArrayClass, Integer.valueOf(0)); + (byte[].class, Integer.valueOf(0)); encodedTextRepresentationsMap.put (java.nio.ByteBuffer.class, Integer.valueOf(1)); encodedTextRepresentationsMap.put
--- a/src/solaris/classes/sun/awt/X11/XDataTransferer.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/solaris/classes/sun/awt/X11/XDataTransferer.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,11 +77,9 @@ private static XDataTransferer transferer; - static XDataTransferer getInstanceImpl() { - synchronized (XDataTransferer.class) { - if (transferer == null) { - transferer = new XDataTransferer(); - } + static synchronized XDataTransferer getInstanceImpl() { + if (transferer == null) { + transferer = new XDataTransferer(); } return transferer; } @@ -411,7 +409,7 @@ if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || - byteArrayClass.equals(df.getRepresentationClass()))) { + byte[].class.equals(df.getRepresentationClass()))) { natives.add(mimeType); }
--- a/src/solaris/classes/sun/awt/X11/XToolkit.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/solaris/classes/sun/awt/X11/XToolkit.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,7 @@ import javax.swing.LookAndFeel; import javax.swing.UIDefaults; import sun.awt.*; +import sun.awt.datatransfer.DataTransferer; import sun.font.FontConfigManager; import sun.java2d.SunGraphicsEnvironment; import sun.misc.PerformanceLogger; @@ -300,8 +301,6 @@ return awtAppClassName; } - static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.X11.XDataTransferer"; - public XToolkit() { super(); if (PerformanceLogger.loggingEnabled()) { @@ -323,7 +322,6 @@ init(); XWM.init(); - SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME); PrivilegedAction<Thread> action = new PrivilegedAction() { public Thread run() { @@ -1125,6 +1123,11 @@ return false; } + @Override + public DataTransferer getDataTransferer() { + return XDataTransferer.getInstanceImpl(); + } + /** * Returns the supported cursor size */
--- a/src/windows/classes/sun/awt/windows/WDataTransferer.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/windows/classes/sun/awt/windows/WDataTransferer.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -159,13 +159,9 @@ private static WDataTransferer transferer; - public static WDataTransferer getInstanceImpl() { + static synchronized WDataTransferer getInstanceImpl() { if (transferer == null) { - synchronized (WDataTransferer.class) { - if (transferer == null) { - transferer = new WDataTransferer(); - } - } + transferer = new WDataTransferer(); } return transferer; }
--- a/src/windows/classes/sun/awt/windows/WToolkit.java Wed Mar 19 15:19:35 2014 -0700 +++ b/src/windows/classes/sun/awt/windows/WToolkit.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,7 @@ import sun.awt.SunToolkit; import sun.awt.Win32GraphicsDevice; import sun.awt.Win32GraphicsEnvironment; +import sun.awt.datatransfer.DataTransferer; import sun.java2d.d3d.D3DRenderQueue; import sun.java2d.opengl.OGLRenderQueue; @@ -210,8 +211,6 @@ */ public native void embeddedEventLoopIdleProcessing(); - public static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.windows.WDataTransferer"; - static class ToolkitDisposer implements sun.java2d.DisposerRecord { public void dispose() { WToolkit.postDispose(); @@ -255,8 +254,6 @@ // swallow the exception } - SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME); - // Enabled "live resizing" by default. It remains controlled // by the native system though. setDynamicLayout(true); @@ -514,6 +511,11 @@ return true; } + @Override + public DataTransferer getDataTransferer() { + return WDataTransferer.getInstanceImpl(); + } + public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() throws HeadlessException {
--- a/src/windows/native/sun/windows/ShellFolder2.cpp Wed Mar 19 15:19:35 2014 -0700 +++ b/src/windows/native/sun/windows/ShellFolder2.cpp Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -219,10 +219,15 @@ return; } MID_pIShellFolder = env->GetMethodID(cls, "setIShellFolder", "(J)V"); + CHECK_NULL(MID_pIShellFolder); FID_pIShellIcon = env->GetFieldID(cls, "pIShellIcon", "J"); + CHECK_NULL(FID_pIShellIcon); MID_relativePIDL = env->GetMethodID(cls, "setRelativePIDL", "(J)V"); + CHECK_NULL(MID_relativePIDL); FID_displayName = env->GetFieldID(cls, "displayName", "Ljava/lang/String;"); + CHECK_NULL(FID_displayName); FID_folderType = env->GetFieldID(cls, "folderType", "Ljava/lang/String;"); + CHECK_NULL(FID_folderType); } @@ -719,8 +724,9 @@ // Get relative PIDL for name LPITEMIDLIST pIDL; int nLength = env->GetStringLength(jname); + const jchar* strPath = env->GetStringChars(jname, NULL); + JNU_CHECK_EXCEPTION_RETURN(env, 0); jchar* wszPath = new jchar[nLength + 1]; - const jchar* strPath = env->GetStringChars(jname, NULL); wcsncpy(reinterpret_cast<LPWSTR>(wszPath), reinterpret_cast<LPCWSTR>(strPath), nLength); wszPath[nLength] = 0; HRESULT res = pIShellFolder->ParseDisplayName(NULL, NULL, @@ -811,6 +817,7 @@ HICON hIcon = NULL; SHFILEINFO fileInfo; LPCTSTR pathStr = JNU_GetStringPlatformChars(env, absolutePath, NULL); + JNU_CHECK_EXCEPTION_RETURN(env, 0); if (fn_SHGetFileInfo(pathStr, 0L, &fileInfo, sizeof(fileInfo), SHGFI_ICON | (getLargeIcon ? 0 : SHGFI_SMALLICON)) != 0) { hIcon = fileInfo.hIcon; @@ -954,9 +961,11 @@ ReleaseDC(NULL, dc); // Create java array iconBits = env->NewIntArray(nBits); + if (!(env->ExceptionCheck())) { // Copy values to java array env->SetIntArrayRegion(iconBits, 0, nBits, colorBits); } + } // Fix 4745575 GDI Resource Leak // MSDN // GetIconInfo creates bitmaps for the hbmMask and hbmColor members of ICONINFO. @@ -1028,6 +1037,7 @@ jint cxDesired, jint cyDesired, jboolean useVGAColors) { const char *pLibName = env->GetStringUTFChars(libName, NULL); + JNU_CHECK_EXCEPTION_RETURN(env, 0); HINSTANCE libHandle = (HINSTANCE)JDK_LoadSystemLibrary(pLibName); if (libHandle != NULL) { UINT fuLoad = (useVGAColors && !IS_WINXP) ? LR_VGACOLOR : 0; @@ -1046,8 +1056,11 @@ jclass *pClass, jmethodID *pConstructor, SHELLDETAILS *psd, ULONG visible) { + jstring str = jstringFromSTRRET(pEnv, NULL, &(psd->str)); + JNU_CHECK_EXCEPTION_RETURN(pEnv, NULL); + return pEnv->NewObject(*pClass, *pConstructor, - jstringFromSTRRET(pEnv, NULL, &(psd->str)), + str, (jint)(psd->cxChar * 6), // TODO: is 6 OK for converting chars to pixels? (jint)psd->fmt, (jboolean) visible); } @@ -1115,6 +1128,10 @@ jobject column = CreateColumnInfo(env, &columnClass, &columnConstructor, &sd, csFlags & SHCOLSTATE_ONBYDEFAULT); + if(!column){ + pIShellFolder2->Release(); + return NULL; + } env->SetObjectArrayElement(columns, (jsize) colNum, column); } } @@ -1155,6 +1172,10 @@ jobject column = CreateColumnInfo(env, &columnClass, &columnConstructor, &sd, 1); + if(!column){ + pIShellDetails->Release(); + return NULL; + } env->SetObjectArrayElement(columns, (jsize) colNum++, column); } }
--- a/src/windows/native/sun/windows/awt_Object.cpp Wed Mar 19 15:19:35 2014 -0700 +++ b/src/windows/native/sun/windows/awt_Object.cpp Mon Mar 24 13:15:07 2014 -0700 @@ -232,22 +232,31 @@ TRY; AwtObject::wObjectPeerClass = (jclass)env->NewGlobalRef(cls); + DASSERT(AwtObject::wObjectPeerClass != NULL); + CHECK_NULL(AwtObject::wObjectPeerClass); + AwtObject::pDataID = env->GetFieldID(cls, "pData", "J"); + DASSERT(AwtObject::pDataID != NULL); + CHECK_NULL(AwtObject::pDataID); + AwtObject::destroyedID = env->GetFieldID(cls, "destroyed", "Z"); + DASSERT(AwtObject::destroyedID != NULL); + CHECK_NULL(AwtObject::destroyedID); + AwtObject::targetID = env->GetFieldID(cls, "target", "Ljava/lang/Object;"); + DASSERT(AwtObject::targetID != NULL); + CHECK_NULL(AwtObject::targetID); AwtObject::getPeerForTargetMID = env->GetStaticMethodID(cls, "getPeerForTarget", "(Ljava/lang/Object;)Lsun/awt/windows/WObjectPeer;"); + DASSERT(AwtObject::getPeerForTargetMID != NULL); + CHECK_NULL(AwtObject::getPeerForTargetMID); AwtObject::createErrorID = env->GetFieldID(cls, "createError", "Ljava/lang/Error;"); - - DASSERT(AwtObject::pDataID != NULL); - DASSERT(AwtObject::destroyedID != NULL); - DASSERT(AwtObject::targetID != NULL); - DASSERT(AwtObject::getPeerForTargetMID != NULL); DASSERT(AwtObject::createErrorID != NULL); + CHECK_NULL(AwtObject::createErrorID); CATCH_BAD_ALLOC; }
--- a/src/windows/native/sun/windows/awt_PrintDialog.cpp Wed Mar 19 15:19:35 2014 -0700 +++ b/src/windows/native/sun/windows/awt_PrintDialog.cpp Mon Mar 24 13:15:07 2014 -0700 @@ -183,11 +183,13 @@ AwtPrintDialog::parentID = env->GetFieldID(cls, "parent", "Lsun/awt/windows/WComponentPeer;"); + DASSERT(AwtPrintDialog::parentID != NULL); + CHECK_NULL(AwtPrintDialog::parentID); + AwtPrintDialog::setHWndMID = env->GetMethodID(cls, "setHWnd", "(J)V"); - - DASSERT(AwtPrintDialog::parentID != NULL); DASSERT(AwtPrintDialog::setHWndMID != NULL); + CHECK_NULL(AwtPrintDialog::setHWndMID); CATCH_BAD_ALLOC; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + @test + @bug 7159566 + @summary The choice positioned in the top of applet when clicking the choice. + @author Petr Pchelko + @library ../../regtesthelpers + @build Util + @run main ChoiceLocationTest + */ + +import java.awt.*; +import javax.swing.*; +import java.awt.event.InputEvent; +import java.util.stream.Stream; + +import test.java.awt.regtesthelpers.Util; + +public class ChoiceLocationTest { + + private static final int FRAME_LOCATION = 100; + private static final int FRAME_SIZE = 400; + private static final int CLICK_STEP = 5; + + private static String[] choiceItems = new String[] { + "test item 1", + "test item 2", + "test item 3" + }; + + private static volatile Frame frame; + private static volatile Choice choice; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(ChoiceLocationTest::initAndShowUI); + Robot r = new Robot(); + r.waitForIdle(); + r.delay(100); + + Util.clickOnComp(choice, r); + + choice.addItemListener(event -> {throw new RuntimeException("Failed: the choice popup is in the wrong place");}); + + // Test: click in several places on the top of the frame an ensure there' no choice there + Point locOnScreen = frame.getLocationOnScreen(); + int x = locOnScreen.x + FRAME_SIZE / 2; + for (int y = locOnScreen.y + frame.getInsets().top + 10; y < locOnScreen.y + FRAME_SIZE / 3 ; y += CLICK_STEP) { + r.mouseMove(x, y); + r.waitForIdle(); + r.mousePress(InputEvent.BUTTON1_MASK); + r.mouseRelease(InputEvent.BUTTON1_MASK); + r.waitForIdle(); + r.delay(100); + } + } finally { + if (frame != null) { + frame.dispose(); + } + } + + } + + private static void initAndShowUI() { + frame = new Frame("Test frame"); + choice = new Choice(); + Stream.of(choiceItems).forEach(choice::add); + frame.add(choice); + frame.setBounds(FRAME_LOCATION, FRAME_LOCATION, FRAME_SIZE, FRAME_SIZE); + frame.setVisible(true); + } + + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.html Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,45 @@ +<!-- + Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + This code is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License version 2 only, as + published by the Free Software Foundation. + + This code is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + version 2 for more details (a copy is included in the LICENSE file that + accompanied this code). + + You should have received a copy of the GNU General Public License version + 2 along with this work; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + + Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + or visit www.oracle.com if you need additional information or have any + questions. +--> + +<html> +<!-- + @test + @bug 8026869 + @summary Support apple.awt.use-file-dialog-packages property. + @author Petr Pchelko area=awt.filedialog + @library ../../regtesthelpers + @build Sysout + @run applet/manual=yesno FileDialogForPackages.html + --> +<head> + <title> FileDialogForPackages </title> +</head> +<body> + +<h1>FileDialogForPackages<br>Bug ID: 8026869</h1> + +<p> See the dialog box (usually in upper left corner) for instructions</p> + +<APPLET CODE="FileDialogForPackages.class" WIDTH=200 HEIGHT=200></APPLET> +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import sun.awt.OSInfo; +import test.java.awt.regtesthelpers.Sysout; + +import java.applet.Applet; +import java.awt.Button; +import java.awt.FileDialog; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class FileDialogForPackages extends Applet implements ActionListener { + private static final String APPLICATIONS_FOLDER = "/Applications"; + + private volatile Button showBtn; + private volatile FileDialog fd; + + @Override + public void init() { + if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { + Sysout.createDialogWithInstructions(new String[]{ + "Press PASS, this test is for MacOS X only."}); + return; + } + + System.setProperty("apple.awt.use-file-dialog-packages", "true"); + + setLayout(new GridLayout(1, 1)); + + fd = new FileDialog(new Frame(), "Open"); + fd.setDirectory(APPLICATIONS_FOLDER); + + showBtn = new Button("Show File Dialog"); + showBtn.addActionListener(this); + add(showBtn); + String[] instructions = { + "1) Click on 'Show File Dialog' button. A file dialog will come up.", + "2) Navigate to the Applications folder if not already there", + "3) Check that the application bundles can be selected and can not be navigated", + "4) If it's true then the test passed, otherwise it failed."}; + Sysout.createDialogWithInstructions(instructions); + } + + @Override + public void start() { + setSize(200, 200); + show(); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == showBtn) { + fd.setVisible(true); + String output = fd.getFile(); + if (output != null) { + Sysout.println(output + " is selected"); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8032872 + * @summary Tests JComboBox selection via the mouse + * @author Dmitry Markov + */ +import sun.awt.SunToolkit; + +import javax.swing.*; +import javax.swing.plaf.basic.BasicComboPopup; +import javax.swing.plaf.basic.ComboPopup; +import javax.swing.plaf.metal.MetalComboBoxUI; +import javax.swing.plaf.metal.MetalLookAndFeel; +import java.awt.*; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +public class MouseComboBoxTest { + private static final String[] items = {"One", "Two", "Three", "Four", "Five"}; + + private static SunToolkit toolkit = null; + private static Robot robot = null; + private static JFrame frame = null; + private static JComboBox comboBox = null; + private static MyComboBoxUI comboBoxUI = null; + + public static void main(String[] args) throws Exception { + toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + robot = new Robot(); + robot.setAutoDelay(50); + + UIManager.setLookAndFeel(new MetalLookAndFeel()); + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + createAndShowGUI(); + } + }); + toolkit.realSync(); + + for (int i = 0; i < items.length; i++) { + // Open popup + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + toolkit.realSync(); + + Point point = getItemPointToClick(i); + robot.mouseMove(point.x, point.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + toolkit.realSync(); + + if (i != getSelectedIndex()) { + throw new RuntimeException("Test Failed! Incorrect value of selected index = " + getSelectedIndex() + + ", expected value = " + i); + } + } + } + + private static Point getItemPointToClick(final int item) throws Exception { + final Point[] result = new Point[1]; + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup(); + Point point = popup.getLocationOnScreen(); + Dimension size = popup.getSize(); + + int step = size.height / items.length; + point.x += size.width / 2; + point.y += step / 2 + step * item; + result[0] = point; + } + }); + return result[0]; + } + + private static int getSelectedIndex() throws Exception { + final int[] result = new int[1]; + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + result[0] = comboBox.getSelectedIndex(); + } + }); + return result[0]; + } + + private static void createAndShowGUI() { + frame = new JFrame("MouseComboBoxTest"); + + comboBox = new JComboBox(items); + comboBox.setEditable(true); + comboBoxUI = new MyComboBoxUI(); + comboBox.setUI(comboBoxUI); + + frame.pack(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + + JWindow window = new JWindow(frame); + window.add(comboBox); + window.pack(); + window.setVisible(true); + } + + private static class MyComboBoxUI extends MetalComboBoxUI { + public ComboPopup getComboPopup() { + return popup; + } + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/TrayIcon/AddPopupAfterShowTest/AddPopupAfterShowTest.html Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,45 @@ +<!-- + 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. +--> + +<html> +<!-- + @test + @bug 8007220 + @summary The popup menu is not added to the tray icon after it was added to tray + @author Petr Pchelko + @library ../../regtesthelpers + @build Sysout + @run applet/manual=yesno AddPopupAfterShowTest.html + --> +<head> + <title> AddPopupAfterShowTest </title> +</head> +<body> + +<h1>AddPopupAfterShowTest<br>Bug ID: 8007220</h1> + +<p> See the dialog box (usually in upper left corner) for instructions</p> + +<APPLET CODE="AddPopupAfterShowTest.class" WIDTH=200 HEIGHT=200></APPLET> +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/TrayIcon/AddPopupAfterShowTest/AddPopupAfterShowTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,106 @@ +/* + * 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 test.java.awt.regtesthelpers.Sysout; + +import java.applet.Applet; +import java.awt.*; +import java.awt.image.BufferedImage; + +public class AddPopupAfterShowTest extends Applet { + @Override + public void init() { + if (!SystemTray.isSupported()) { + Sysout.createDialogWithInstructions(new String[]{ + "Press PASS, the System Tray is not supported"}); + return; + } + + + String[] instructions = { + "1) The red circle icon was added to the system tray.", + "2) Check that a popup menu is opened when the icon is clicked.", + "3) If true the test is passed, otherwise failed."}; + Sysout.createDialogWithInstructions(instructions); + } + + @Override + public void start() { + setSize(200, 200); + show(); + + createSystemTrayIcon(); + } + + private static void createSystemTrayIcon() { + final TrayIcon trayIcon = new TrayIcon(createTrayIconImage()); + trayIcon.setImageAutoSize(true); + + try { + // Add tray icon to system tray *before* adding popup menu to demonstrate buggy behaviour + SystemTray.getSystemTray().add(trayIcon); + trayIcon.setPopupMenu(createTrayIconPopupMenu()); + } catch (final AWTException awte) { + awte.printStackTrace(); + } + } + + private static Image createTrayIconImage() { + /** + * Create a small image of a red circle to use as the icon for the tray icon + */ + int trayIconImageSize = 32; + final BufferedImage trayImage = new BufferedImage(trayIconImageSize, trayIconImageSize, BufferedImage.TYPE_INT_ARGB); + final Graphics2D trayImageGraphics = (Graphics2D) trayImage.getGraphics(); + + trayImageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + trayImageGraphics.setColor(new Color(255, 255, 255, 0)); + trayImageGraphics.fillRect(0, 0, trayImage.getWidth(), trayImage.getHeight()); + + trayImageGraphics.setColor(Color.red); + + int trayIconImageInset = 4; + trayImageGraphics.fillOval(trayIconImageInset, + trayIconImageInset, + trayImage.getWidth() - 2 * trayIconImageInset, + trayImage.getHeight() - 2 * trayIconImageInset); + + trayImageGraphics.setColor(Color.darkGray); + + trayImageGraphics.drawOval(trayIconImageInset, + trayIconImageInset, + trayImage.getWidth() - 2 * trayIconImageInset, + trayImage.getHeight() - 2 * trayIconImageInset); + + return trayImage; + } + + private static PopupMenu createTrayIconPopupMenu() { + final PopupMenu trayIconPopupMenu = new PopupMenu(); + final MenuItem popupMenuItem = new MenuItem("TEST PASSED!"); + trayIconPopupMenu.add(popupMenuItem); + return trayIconPopupMenu; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,149 @@ +/* + * 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 8007220 + @summary Reference to the popup leaks after the TrayIcon is removed + @author Petr Pchelko + @run main/othervm -Xmx50m PopupMenuLeakTest + */ + +import java.awt.*; +import javax.swing.SwingUtilities; +import sun.awt.SunToolkit; + +import java.awt.image.BufferedImage; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicReference; + +public class PopupMenuLeakTest { + + static final AtomicReference<WeakReference<TrayIcon>> iconWeakReference = new AtomicReference<>(); + static final AtomicReference<WeakReference<PopupMenu>> popupWeakReference = new AtomicReference<>(); + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(PopupMenuLeakTest::createSystemTrayIcon); + sleep(); + // To make the test automatic we explicitly call addNotify on a popup to create the peer + SwingUtilities.invokeAndWait(PopupMenuLeakTest::addNotifyPopup); + sleep(); + SwingUtilities.invokeAndWait(PopupMenuLeakTest::removeIcon); + sleep(); + assertCollected(popupWeakReference.get(), "Failed, reference to popup not collected"); + assertCollected(iconWeakReference.get(), "Failed, reference to tray icon not collected"); + } + + private static void addNotifyPopup() { + PopupMenu menu = popupWeakReference.get().get(); + if (menu == null) { + throw new RuntimeException("Failed: popup collected too early"); + } + menu.addNotify(); + } + + private static void removeIcon() { + TrayIcon icon = iconWeakReference.get().get(); + if (icon == null) { + throw new RuntimeException("Failed: TrayIcon collected too early"); + } + SystemTray.getSystemTray().remove(icon); + } + + private static void assertCollected(WeakReference<?> reference, String message) { + java.util.List<byte[]> bytes = new ArrayList<>(); + for (int i = 0; i < 5; i ++) { + try { + while (true) { + bytes.add(new byte[1024]); + } + } catch (OutOfMemoryError err) { + bytes = new ArrayList<>(); + } + } + if (reference.get() != null) { + throw new RuntimeException(message); + } + } + + private static void createSystemTrayIcon() { + final TrayIcon trayIcon = new TrayIcon(createTrayIconImage()); + trayIcon.setImageAutoSize(true); + + try { + // Add tray icon to system tray *before* adding popup menu to demonstrate buggy behaviour + trayIcon.setPopupMenu(createTrayIconPopupMenu()); + SystemTray.getSystemTray().add(trayIcon); + iconWeakReference.set(new WeakReference<>(trayIcon)); + popupWeakReference.set(new WeakReference<>(trayIcon.getPopupMenu())); + } catch (final AWTException awte) { + awte.printStackTrace(); + } + } + + private static Image createTrayIconImage() { + /** + * Create a small image of a red circle to use as the icon for the tray icon + */ + int trayIconImageSize = 32; + final BufferedImage trayImage = new BufferedImage(trayIconImageSize, trayIconImageSize, BufferedImage.TYPE_INT_ARGB); + final Graphics2D trayImageGraphics = (Graphics2D) trayImage.getGraphics(); + + trayImageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + trayImageGraphics.setColor(new Color(255, 255, 255, 0)); + trayImageGraphics.fillRect(0, 0, trayImage.getWidth(), trayImage.getHeight()); + + trayImageGraphics.setColor(Color.red); + + int trayIconImageInset = 4; + trayImageGraphics.fillOval(trayIconImageInset, + trayIconImageInset, + trayImage.getWidth() - 2 * trayIconImageInset, + trayImage.getHeight() - 2 * trayIconImageInset); + + trayImageGraphics.setColor(Color.darkGray); + + trayImageGraphics.drawOval(trayIconImageInset, + trayIconImageInset, + trayImage.getWidth() - 2 * trayIconImageInset, + trayImage.getHeight() - 2 * trayIconImageInset); + + return trayImage; + } + + private static PopupMenu createTrayIconPopupMenu() { + final PopupMenu trayIconPopupMenu = new PopupMenu(); + final MenuItem popupMenuItem = new MenuItem("TEST!"); + trayIconPopupMenu.add(popupMenuItem); + return trayIconPopupMenu; + } + + private static void sleep() { + ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + try { + Thread.sleep(100); + } catch (InterruptedException ignored) { } + } +}
--- a/test/java/awt/Window/Grab/GrabTest.java Wed Mar 19 15:19:35 2014 -0700 +++ b/test/java/awt/Window/Grab/GrabTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,10 @@ public class GrabTest { private static Frame f; private static Frame f1; + private static Frame frame; private static Window w; + private static Window window1; + private static Window window2; private static Button b; private static Robot robot; @@ -96,6 +99,15 @@ f.setVisible(true); w.setVisible(true); + frame = new Frame(); + window1 = new Window(frame); + window1.setBounds(0, 0, 100, 100); + window1.setBackground(Color.blue); + + window2 = new Window(window1); + window2.setBounds(0, 0, 50, 50); + window2.setBackground(Color.green); + tk = (sun.awt.SunToolkit)Toolkit.getDefaultToolkit(); try { @@ -194,6 +206,24 @@ passed = false; System.err.println("Failure: [7] Window disposal didn't cause ungrab"); } + ungrabbed = false; + + + // 8. Check that mouse click on subwindow does not cause ungrab + frame.setVisible(true); + window1.setVisible(true); + window2.setVisible(true); + Util.waitForIdle(robot); + + tk.grab(window1); + + Util.clickOnComp(window2, robot); + Util.waitForIdle(robot); + + if (ungrabbed) { + passed = false; + System.err.println("Failure: [8] Press on the subwindow caused ungrab"); + } if (passed) { System.out.println("Test passed.");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/dnd/BadSerializaionTest/BadSerializationTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8030050 + * @summary Validate fields on DnD class deserialization + * @author petr.pchelko@oracle.com + */ + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; +import java.util.stream.Stream; + +public class BadSerializationTest { + + private static final String[] badSerialized = new String[] { + "badAction", + "noEvents", + "nullComponent", + "nullDragSource", + "nullOrigin" + }; + + private static final String goodSerialized = "good"; + + public static void main(String[] args) throws Exception { + String testSrc = System.getProperty("test.src") + File.separator; + testReadObject(testSrc + goodSerialized, false); + Stream.of(badSerialized).forEach(file -> testReadObject(testSrc + file, true)); + } + + private static void testReadObject(String filename, boolean expectException) { + Exception exceptionCaught = null; + try (FileInputStream fileInputStream = new FileInputStream(filename); + ObjectInputStream ois = new ObjectInputStream(fileInputStream)) { + ois.readObject(); + } catch (InvalidObjectException e) { + exceptionCaught = e; + } catch (IOException e) { + throw new RuntimeException("FAILED: IOException", e); + } catch (ClassNotFoundException e) { + throw new RuntimeException("FAILED: ClassNotFoundException", e); + } + if (exceptionCaught != null && !expectException) { + throw new RuntimeException("FAILED: UnexpectedException", exceptionCaught); + } + if (exceptionCaught == null && expectException) { + throw new RuntimeException("FAILED: Invalid object was created with no exception"); + } + } +}
--- a/test/java/awt/dnd/Button2DragTest/Button2DragTest.java Wed Mar 19 15:19:35 2014 -0700 +++ b/test/java/awt/dnd/Button2DragTest/Button2DragTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -112,6 +112,7 @@ Util.drag(robot, startPoint, endPoint, InputEvent.BUTTON2_MASK); Util.waitForIdle(robot); + robot.delay(500); if (dropSuccess) { System.err.println("test passed");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/dnd/URLDragTest/URLDragTest.html Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,45 @@ +<!-- + Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + This code is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License version 2 only, as + published by the Free Software Foundation. + + This code is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + version 2 for more details (a copy is included in the LICENSE file that + accompanied this code). + + You should have received a copy of the GNU General Public License version + 2 along with this work; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + + Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + or visit www.oracle.com if you need additional information or have any + questions. +--> + +<html> +<!-- + @test + @bug 8031964 + @summary Dragging images from the browser does not work + @author Petr Pchelko : area=dnd + @library ../../regtesthelpers + @build Sysout + @run applet/manual=yesno URLDragTest.html +--> +<head> +<title> DnD of URL across JVM </title> +</head> +<body> + +<h1>URLDragTest<br>Bug ID: 8031964</h1> + +<p> This is an AUTOMATIC test, simply wait for completion </p> + +<APPLET CODE="URLDragTest.class" WIDTH=200 HEIGHT=200></APPLET> +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/dnd/URLDragTest/URLDragTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + test + @bug 8031964 + @summary Dragging images from the browser does not work + @author Petr Pchelko : area=dnd + @library ../../regtesthelpers + @build Sysout + @run applet/manual=yesno URLDragTest.html +*/ + +import test.java.awt.regtesthelpers.Sysout; + +import java.applet.Applet; +import java.awt.*; +import java.awt.datatransfer.DataFlavor; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; + +public class URLDragTest extends Applet { + + + @Override + public void init() { + setBackground(Color.red); + setDropTarget(new DropTarget(this, + DnDConstants.ACTION_COPY, + new DropTargetAdapter() { + @Override + public void dragEnter(DropTargetDragEvent dtde) { + dtde.acceptDrag(DnDConstants.ACTION_COPY); + } + + @Override + public void dragOver(DropTargetDragEvent dtde) { + dtde.acceptDrag(DnDConstants.ACTION_COPY); + } + + @Override + public void drop(DropTargetDropEvent dtde) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + dtde.getCurrentDataFlavorsAsList() + .stream() + .map(DataFlavor::toString) + .forEach(Sysout::println); + } + })); + + String[] instructions = { + "1) Open the browser.", + "2) Drag any image from the browser page to the red square", + "3) When the image is dropped you should se the list of available DataFlavors", + "4) If you see application/x-java-url and text/uri-list flavors - test PASSED", + "5) Otherwise the test is FAILED"}; + Sysout.createDialogWithInstructions(instructions); + } + + @Override + public void start() { + setSize(200, 200); + setVisible(true); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/invoke/lambda/LambdaReceiver.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8035776 + * @summary Consistent Lambda construction + */ + +import java.lang.invoke.CallSite; +import java.lang.invoke.LambdaMetafactory; +import java.lang.invoke.LambdaConversionException; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.util.ArrayList; +import java.util.List; + +import LambdaReceiver_anotherpkg.LambdaReceiver_A; + +public class LambdaReceiver extends LambdaReceiver_A { + + interface IA { + int m(LambdaReceiver_A x); + } + + static MethodHandles.Lookup l; + static MethodHandle h; + private static MethodType mt(Class<?> k) { return MethodType.methodType(k); } + private static MethodType mt(Class<?> k, Class<?> k2) { return MethodType.methodType(k, k2); } + private static void mf(List<String> errs, MethodType mts, MethodType mtf, boolean shouldWork) { + } + + public static void main(String[] args) throws Throwable { + l = MethodHandles.lookup(); + h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class)); + MethodType X = mt(int.class, LambdaReceiver.class); + MethodType A = mt(int.class, LambdaReceiver_A.class); + MethodType mti = mt(IA.class); + CallSite cs = LambdaMetafactory.metafactory(l, "m", mti,A,h,X); + IA p = (IA)cs.dynamicInvoker().invoke(); + LambdaReceiver_A lra = new LambdaReceiver_A(); + try { + p.m(lra); + } catch (ClassCastException cce) { + return; + } + throw new AssertionError("CCE expected"); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/invoke/lambda/LambdaReceiverBridge.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8035776 + * @summary Consistent Lambda construction + */ + +import java.lang.invoke.CallSite; +import java.lang.invoke.LambdaMetafactory; +import java.lang.invoke.LambdaConversionException; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.util.ArrayList; +import java.util.List; + +import LambdaReceiver_anotherpkg.LambdaReceiver_A; + +public class LambdaReceiverBridge extends LambdaReceiver_A { + + interface IA { + int m(LambdaReceiver_A x); + } + + static MethodHandles.Lookup l; + static MethodHandle h; + private static MethodType mt(Class<?> k) { return MethodType.methodType(k); } + private static MethodType mt(Class<?> k, Class<?> k2) { return MethodType.methodType(k, k2); } + private static void mf(List<String> errs, MethodType mts, MethodType mtf, boolean shouldWork) { + } + + public static void main(String[] args) throws Throwable { + l = MethodHandles.lookup(); + h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class)); + MethodType X = mt(int.class, LambdaReceiverBridge.class); + MethodType A = mt(int.class, LambdaReceiver_A.class); + MethodType mti = mt(IA.class); + CallSite cs = LambdaMetafactory.altMetafactory(l, "m", mti,X,h,X, + LambdaMetafactory.FLAG_BRIDGES, 1, A); + IA p = (IA)cs.dynamicInvoker().invoke(); + LambdaReceiver_A lra = new LambdaReceiver_A(); + try { + p.m(lra); + } catch (ClassCastException cce) { + return; + } + throw new AssertionError("CCE expected"); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/invoke/lambda/LambdaReceiver_anotherpkg/LambdaReceiver_A.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package LambdaReceiver_anotherpkg; + +public class LambdaReceiver_A { + protected final int f() { return 2; } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/invoke/lambda/LambdaReturn.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8035776 + * @summary Consistent Lambda construction + */ + +import java.lang.invoke.LambdaMetafactory; +import java.lang.invoke.LambdaConversionException; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.util.ArrayList; +import java.util.List; + +public class LambdaReturn { + + interface I { + void m(); + } + + static void hereV() {} + static String hereS() { return "hi"; } + static MethodHandles.Lookup l; + private static MethodType mt(Class<?> k) { return MethodType.methodType(k); } + private static MethodType mt(Class<?> k, Class<?> k2) { return MethodType.methodType(k, k2); } + private static void amf(List<String> errs, MethodHandle h, MethodType mts, MethodType mtf, MethodType mtb, boolean shouldWork) { + MethodType mti = mt(I.class); + try { + LambdaMetafactory.altMetafactory(l, "m", mti, mts,h,mtf, + LambdaMetafactory.FLAG_BRIDGES, 1, mtb); + } catch(LambdaConversionException e) { + if (shouldWork) errs.add("Error: Should work h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb + " got: " + e); + return; + } + if (!shouldWork) errs.add("Error: Should fail h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb); + } + + public static void main(String[] args) throws Throwable { + l = MethodHandles.lookup(); + MethodHandle hV = l.findStatic(LambdaReturn.class, "hereV", mt(void.class)); + MethodHandle hS = l.findStatic(LambdaReturn.class, "hereS", mt(String.class)); + List<String> errs = new ArrayList<>(); + MethodType V = mt(void.class); + MethodType S = mt(String.class); + MethodType O = mt(Object.class); + MethodType I = mt(int.class); + amf(errs, hS, S, S, O, true); + amf(errs, hS, S, S, V, false); + amf(errs, hS, S, S, I, false); + amf(errs, hS, O, S, S, true); + amf(errs, hS, V, S, S, false); + amf(errs, hS, I, S, S, false); + amf(errs, hS, O, O, S, false); + amf(errs, hS, S, O, O, false); + amf(errs, hV, V, V, O, false); + amf(errs, hV, V, V, I, false); + amf(errs, hV, V, V, S, false); + amf(errs, hV, O, V, V, false); + amf(errs, hV, I, V, V, false); + amf(errs, hV, S, V, V, false); + + if (errs.size() > 0) { + for (String err : errs) { + System.err.println(err); + } + throw new AssertionError("Errors: " + errs.size()); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/invoke/lambda/MetafactoryArityTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8035776 + * @summary metafactory should fail if arities are mismatched + */ +import java.lang.invoke.*; +import java.util.Arrays; +import static java.lang.invoke.MethodType.methodType; + +public class MetafactoryArityTest { + + public interface I {} + public static class C { public static String m(int arg) { return ""; } } + + static final MethodHandles.Lookup lookup = MethodHandles.lookup(); + static final Class<?>[] capInt = { int.class }; + static final MethodHandle C_m; + static { + try { C_m = lookup.findStatic(C.class, "m", methodType(String.class, int.class)); } + catch (NoSuchMethodException | IllegalAccessException e) { throw new RuntimeException(e); } + } + + public static void main(String... args) { + MethodType unary = methodType(String.class, int.class); + MethodType nullary = methodType(String.class); + MethodType binary = methodType(String.class, int.class, int.class); + MethodType unaryCS = methodType(CharSequence.class, int.class); + MethodType nullaryCS = methodType(CharSequence.class); + MethodType binaryCS = methodType(CharSequence.class, int.class, int.class); + MethodType unaryObj = methodType(Object.class, int.class); + MethodType nullaryObj = methodType(Object.class); + MethodType binaryObj = methodType(Object.class, int.class, int.class); + + test(true, C_m, unary, unary); + test(false, C_m, unary, nullary); + test(false, C_m, nullary, unary); + test(false, C_m, unary, binary); + test(false, C_m, binary, unary); + + testBridge(true, C_m, unary, unary, unaryCS); + testBridge(false, C_m, unary, unary, nullaryCS); + testBridge(false, C_m, unary, unary, binaryCS); + + testBridge(true, C_m, unary, unary, unaryCS, unaryObj); + testBridge(false, C_m, unary, unary, unaryCS, nullaryObj); + testBridge(false, C_m, unary, unary, unaryCS, binaryObj); + + testCapture(true, C_m, capInt, nullary, nullary); + testCapture(false, C_m, capInt, binary, binary); + testCapture(false, C_m, capInt, nullary, unary); + testCapture(false, C_m, capInt, nullary, binary); + testCapture(false, C_m, capInt, unary, nullary); + testCapture(false, C_m, capInt, unary, binary); + + testCaptureBridge(true, C_m, capInt, nullary, nullary, nullaryCS); + testCaptureBridge(false, C_m, capInt, unary, unary, unaryCS); + testCaptureBridge(false, C_m, capInt, nullary, nullary, unaryCS); + testCaptureBridge(false, C_m, capInt, nullary, nullary, binaryCS); + + testCaptureBridge(true, C_m, capInt, nullary, nullary, nullaryCS, nullaryObj); + testCaptureBridge(false, C_m, capInt, unary, unary, unaryCS, unaryObj); + testCaptureBridge(false, C_m, capInt, nullary, nullary, nullaryCS, unaryObj); + testCaptureBridge(false, C_m, capInt, nullary, nullary, nullaryCS, binaryObj); + } + + static void test(boolean correct, MethodHandle mh, MethodType instMT, MethodType samMT) { + tryMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT); + tryAltMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT); + } + + static void testBridge(boolean correct, MethodHandle mh, MethodType instMT, MethodType samMT, MethodType... bridgeMTs) { + tryAltMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT, bridgeMTs); + } + + static void testCapture(boolean correct, MethodHandle mh, Class<?>[] captured, MethodType instMT, MethodType samMT) { + tryMetafactory(correct, mh, captured, instMT, samMT); + tryAltMetafactory(correct, mh, captured, instMT, samMT); + } + + static void testCaptureBridge(boolean correct, MethodHandle mh, Class<?>[] captured, + MethodType instMT, MethodType samMT, MethodType... bridgeMTs) { + tryAltMetafactory(correct, mh, captured, instMT, samMT, bridgeMTs); + } + + static void tryMetafactory(boolean correct, MethodHandle mh, Class<?>[] captured, + MethodType instMT, MethodType samMT) { + try { + LambdaMetafactory.metafactory(lookup, "run", methodType(I.class, captured), + samMT, mh, instMT); + if (!correct) { + throw new AssertionError("Uncaught linkage error:" + + " impl=" + mh + + ", captured=" + Arrays.toString(captured) + + ", inst=" + instMT + + ", sam=" + samMT); + } + } + catch (LambdaConversionException e) { + if (correct) { + throw new AssertionError("Unexpected linkage error:" + + " e=" + e + + ", impl=" + mh + + ", captured=" + Arrays.toString(captured) + + ", inst=" + instMT + + ", sam=" + samMT); + } + } + } + + static void tryAltMetafactory(boolean correct, MethodHandle mh, Class<?>[] captured, + MethodType instMT, MethodType samMT, MethodType... bridgeMTs) { + boolean bridge = bridgeMTs.length > 0; + Object[] args = new Object[bridge ? 5+bridgeMTs.length : 4]; + args[0] = samMT; + args[1] = mh; + args[2] = instMT; + args[3] = bridge ? LambdaMetafactory.FLAG_BRIDGES : 0; + if (bridge) { + args[4] = bridgeMTs.length; + for (int i = 0; i < bridgeMTs.length; i++) args[5+i] = bridgeMTs[i]; + } + try { + LambdaMetafactory.altMetafactory(lookup, "run", methodType(I.class, captured), args); + if (!correct) { + throw new AssertionError("Uncaught linkage error:" + + " impl=" + mh + + ", captured=" + Arrays.toString(captured) + + ", inst=" + instMT + + ", sam=" + samMT + + ", bridges=" + Arrays.toString(bridgeMTs)); + } + } + catch (LambdaConversionException e) { + if (correct) { + throw new AssertionError("Unexpected linkage error:" + + " e=" + e + + ", impl=" + mh + + ", captured=" + Arrays.toString(captured) + + ", inst=" + instMT + + ", sam=" + samMT + + ", bridges=" + Arrays.toString(bridgeMTs)); + } + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/invoke/lambda/MetafactoryParameterCastTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8035776 + * @summary Ensure that invocation parameters are always cast to the instantiatedMethodType + */ +import java.lang.invoke.*; +import java.util.Arrays; +import static java.lang.invoke.MethodType.methodType; + +public class MetafactoryParameterCastTest { + + static final MethodHandles.Lookup lookup = MethodHandles.lookup(); + + public static class A { + } + + public static class B extends A { + void instance0() {} + void instance1(B arg) {} + static void static1(B arg) {} + static void static2(B arg1, B arg2) {} + } + + public static class C extends B {} + public static class NotC extends B {} + + public interface ASink { void take(A arg); } + public interface BSink { void take(B arg); } + + public static void main(String... args) throws Throwable { + new MetafactoryParameterCastTest().test(); + } + + void test() throws Throwable { + MethodType takeA = methodType(void.class, A.class); + MethodType takeB = methodType(void.class, B.class); + MethodType takeC = methodType(void.class, C.class); + + Class<?>[] noCapture = {}; + Class<?>[] captureB = { B.class }; + + MethodHandle[] oneBParam = { lookup.findVirtual(B.class, "instance0", methodType(void.class)), + lookup.findStatic(B.class, "static1", methodType(void.class, B.class)) }; + MethodHandle[] twoBParams = { lookup.findVirtual(B.class, "instance1", methodType(void.class, B.class)), + lookup.findStatic(B.class, "static2", methodType(void.class, B.class, B.class)) }; + + for (MethodHandle mh : oneBParam) { + // sam + tryASink(invokeMetafactory(mh, ASink.class, "take", noCapture, takeC, takeA)); + tryBSink(invokeMetafactory(mh, BSink.class, "take", noCapture, takeC, takeB)); + tryASink(invokeAltMetafactory(mh, ASink.class, "take", noCapture, takeC, takeA)); + tryBSink(invokeAltMetafactory(mh, BSink.class, "take", noCapture, takeC, takeB)); + + // bridge + tryASink(invokeAltMetafactory(mh, ASink.class, "take", noCapture, takeC, takeC, takeA)); + tryBSink(invokeAltMetafactory(mh, BSink.class, "take", noCapture, takeC, takeC, takeB)); + } + + for (MethodHandle mh : twoBParams) { + // sam + tryCapASink(invokeMetafactory(mh, ASink.class, "take", captureB, takeC, takeA)); + tryCapBSink(invokeMetafactory(mh, BSink.class, "take", captureB, takeC, takeB)); + tryCapASink(invokeAltMetafactory(mh, ASink.class, "take", captureB, takeC, takeA)); + tryCapBSink(invokeAltMetafactory(mh, BSink.class, "take", captureB, takeC, takeB)); + + // bridge + tryCapASink(invokeAltMetafactory(mh, ASink.class, "take", captureB, takeC, takeC, takeA)); + tryCapBSink(invokeAltMetafactory(mh, BSink.class, "take", captureB, takeC, takeC, takeB)); + } + } + + void tryASink(CallSite cs) throws Throwable { + ASink sink = (ASink) cs.dynamicInvoker().invoke(); + tryASink(sink); + } + + void tryCapASink(CallSite cs) throws Throwable { + ASink sink = (ASink) cs.dynamicInvoker().invoke(new B()); + tryASink(sink); + } + + void tryBSink(CallSite cs) throws Throwable { + BSink sink = (BSink) cs.dynamicInvoker().invoke(); + tryBSink(sink); + } + + void tryCapBSink(CallSite cs) throws Throwable { + BSink sink = (BSink) cs.dynamicInvoker().invoke(new B()); + tryBSink(sink); + } + + void tryASink(ASink sink) { + try { sink.take(new C()); } + catch (ClassCastException e) { + throw new AssertionError("Unexpected cast failure: " + e + " " + lastMFParams()); + } + + try { + sink.take(new B()); + throw new AssertionError("Missing cast from A to C: " + lastMFParams()); + } + catch (ClassCastException e) { /* expected */ } + + try { + sink.take(new NotC()); + throw new AssertionError("Missing cast from A to C: " + lastMFParams()); + } + catch (ClassCastException e) { /* expected */ } + } + + void tryBSink(BSink sink) { + try { sink.take(new C()); } + catch (ClassCastException e) { + throw new AssertionError("Unexpected cast failure: " + e + " " + lastMFParams()); + } + + try { + sink.take(new B()); + throw new AssertionError("Missing cast from B to C: " + lastMFParams()); + } + catch (ClassCastException e) { /* expected */ } + + try { + sink.take(new NotC()); + throw new AssertionError("Missing cast from B to C: " + lastMFParams()); + } + catch (ClassCastException e) { /* expected */ } + } + + MethodHandle lastMH; + Class<?>[] lastCaptured; + MethodType lastInstMT; + MethodType lastSamMT; + MethodType[] lastBridgeMTs; + + String lastMFParams() { + return "mh=" + lastMH + + ", captured=" + Arrays.toString(lastCaptured) + + ", instMT=" + lastInstMT + + ", samMT=" + lastSamMT + + ", bridgeMTs=" + Arrays.toString(lastBridgeMTs); + } + + CallSite invokeMetafactory(MethodHandle mh, Class<?> sam, String methodName, + Class<?>[] captured, MethodType instMT, MethodType samMT) { + lastMH = mh; + lastCaptured = captured; + lastInstMT = instMT; + lastSamMT = samMT; + lastBridgeMTs = new MethodType[]{}; + try { + return LambdaMetafactory.metafactory(lookup, methodName, methodType(sam, captured), + samMT, mh, instMT); + } + catch (LambdaConversionException e) { + // unexpected linkage error + throw new RuntimeException(e); + } + } + + CallSite invokeAltMetafactory(MethodHandle mh, Class<?> sam, String methodName, + Class<?>[] captured, MethodType instMT, + MethodType samMT, MethodType... bridgeMTs) { + lastMH = mh; + lastCaptured = captured; + lastInstMT = instMT; + lastSamMT = samMT; + lastBridgeMTs = bridgeMTs; + try { + boolean bridge = bridgeMTs.length > 0; + Object[] args = new Object[bridge ? 5+bridgeMTs.length : 4]; + args[0] = samMT; + args[1] = mh; + args[2] = instMT; + args[3] = bridge ? LambdaMetafactory.FLAG_BRIDGES : 0; + if (bridge) { + args[4] = bridgeMTs.length; + for (int i = 0; i < bridgeMTs.length; i++) args[5+i] = bridgeMTs[i]; + } + return LambdaMetafactory.altMetafactory(lookup, methodName, methodType(sam, captured), args); + } + catch (LambdaConversionException e) { + // unexpected linkage error + throw new RuntimeException(e); + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/invoke/lambda/MetafactorySamReturnTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8035776 + * @summary metafactory should fail if impl return does not match sam/bridge returns + */ +import java.lang.invoke.*; +import java.util.Arrays; +import static java.lang.invoke.MethodType.methodType; + +public class MetafactorySamReturnTest { + + static final MethodHandles.Lookup lookup = MethodHandles.lookup(); + + public interface I {} + + public static class C { + public static void m_void(String arg) {} + public static boolean m_boolean(String arg) { return true; } + public static char m_char(String arg) { return 'x'; } + public static byte m_byte(String arg) { return 12; } + public static short m_short(String arg) { return 12; } + public static int m_int(String arg) { return 12; } + public static long m_long(String arg) { return 12; } + public static float m_float(String arg) { return 12; } + public static double m_double(String arg) { return 12; } + public static String m_String(String arg) { return ""; } + public static Integer m_Integer(String arg) { return 23; } + public static Object m_Object(String arg) { return new Object(); } + + public static MethodHandle getMH(Class<?> c) { + try { + return lookup.findStatic(C.class, "m_" + c.getSimpleName(), methodType(c, String.class)); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String... args) { + Class<?>[] t = { void.class, boolean.class, char.class, + byte.class, short.class, int.class, long.class, float.class, double.class, + String.class, Integer.class, Object.class }; + + for (int i = 0; i < t.length; i++) { + MethodHandle mh = C.getMH(t[i]); + for (int j = 0; j < t.length; j++) { + // TEMPORARY EXCEPTIONS + if (t[j] == void.class) continue; + if (t[i].isPrimitive() && t[j] == Object.class) continue; + if (t[i] == char.class && (t[j] == int.class || t[j] == long.class || t[j] == float.class || t[j] == double.class)) continue; + if (t[i] == byte.class && (t[j] == short.class || t[j] == int.class || t[j] == long.class || t[j] == float.class || t[j] == double.class)) continue; + if (t[i] == short.class && (t[j] == int.class || t[j] == long.class || t[j] == float.class || t[j] == double.class)) continue; + if (t[i] == int.class && (t[j] == long.class || t[j] == float.class || t[j] == double.class)) continue; + if (t[i] == long.class && (t[j] == float.class || t[j] == double.class)) continue; + if (t[i] == float.class && t[j] == double.class) continue; + if (t[i] == int.class && t[j] == Integer.class) continue; + if (t[i] == Integer.class && (t[j] == int.class || t[j] == long.class || t[j] == float.class || t[j] == double.class)) continue; + // END TEMPORARY EXCEPTIONS + boolean correct = (t[i].isPrimitive() || t[j].isPrimitive()) + ? t[i] == t[j] + : t[j].isAssignableFrom(t[i]); + MethodType mti = methodType(t[i], String.class); + MethodType mtiCS = methodType(t[i], CharSequence.class); + MethodType mtj = methodType(t[j], String.class); + MethodType mtjObj = methodType(t[j], Object.class); + test(correct, mh, mti, mtj); + testBridge(correct, mh, mti, mti, mtjObj); + testBridge(correct, mh, mti, mti, mtiCS, mtjObj); + } + } + } + + static void test(boolean correct, MethodHandle mh, MethodType instMT, MethodType samMT) { + tryMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT); + tryAltMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT); + } + + static void testBridge(boolean correct, MethodHandle mh, MethodType instMT, MethodType samMT, MethodType... bridgeMTs) { + tryAltMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT, bridgeMTs); + } + + static void tryMetafactory(boolean correct, MethodHandle mh, Class<?>[] captured, + MethodType instMT, MethodType samMT) { + try { + LambdaMetafactory.metafactory(lookup, "run", methodType(I.class, captured), + samMT, mh, instMT); + if (!correct) { + throw new AssertionError("Uncaught linkage error:" + + " impl=" + mh + + ", captured=" + Arrays.toString(captured) + + ", inst=" + instMT + + ", sam=" + samMT); + } + } + catch (LambdaConversionException e) { + if (correct) { + throw new AssertionError("Unexpected linkage error:" + + " e=" + e + + ", impl=" + mh + + ", captured=" + Arrays.toString(captured) + + ", inst=" + instMT + + ", sam=" + samMT); + } + } + } + + static void tryAltMetafactory(boolean correct, MethodHandle mh, Class<?>[] captured, + MethodType instMT, MethodType samMT, MethodType... bridgeMTs) { + boolean bridge = bridgeMTs.length > 0; + Object[] args = new Object[bridge ? 5+bridgeMTs.length : 4]; + args[0] = samMT; + args[1] = mh; + args[2] = instMT; + args[3] = bridge ? LambdaMetafactory.FLAG_BRIDGES : 0; + if (bridge) { + args[4] = bridgeMTs.length; + for (int i = 0; i < bridgeMTs.length; i++) args[5+i] = bridgeMTs[i]; + } + try { + LambdaMetafactory.altMetafactory(lookup, "run", methodType(I.class, captured), args); + if (!correct) { + throw new AssertionError("Uncaught linkage error:" + + " impl=" + mh + + ", captured=" + Arrays.toString(captured) + + ", inst=" + instMT + + ", sam=" + samMT + + ", bridges=" + Arrays.toString(bridgeMTs)); + } + } + catch (LambdaConversionException e) { + if (correct) { + throw new AssertionError("Unexpected linkage error:" + + " e=" + e + + ", impl=" + mh + + ", captured=" + Arrays.toString(captured) + + ", inst=" + instMT + + ", sam=" + samMT + + ", bridges=" + Arrays.toString(bridgeMTs)); + } + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JPopupMenu/7154841/bug7154841.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,121 @@ +/* + * 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 7154841 + @summary JPopupMenu is overlapped by a Dock on Mac OS X + @author Petr Pchelko + */ + +import sun.awt.OSInfo; +import sun.awt.SunToolkit; + +import java.awt.*; +import javax.swing.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.util.concurrent.atomic.AtomicReference; + +public class bug7154841 { + + private static final int STEP = 10; + + private static volatile boolean passed = false; + private static JFrame frame; + private static JPopupMenu popupMenu; + private static AtomicReference<Rectangle> screenBounds = new AtomicReference<>(); + + private static void initAndShowUI() { + popupMenu = new JPopupMenu(); + for (int i = 0; i < 100; i++) { + JRadioButtonMenuItem item = new JRadioButtonMenuItem(" Test " + i); + item.addMouseMotionListener(new MouseMotionAdapter() { + @Override + public void mouseMoved(MouseEvent e) { + passed = true; + } + }); + popupMenu.add(item); + } + + frame = new JFrame(); + screenBounds.set(getScreenBounds()); + frame.setBounds(screenBounds.get()); + frame.setVisible(true); + } + + public static void main(String[] args) throws Exception { + if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { + return; // Test only for Mac OS X + } + + try { + Robot r = new Robot(); + r.setAutoDelay(100); + r.setAutoWaitForIdle(true); + r.mouseMove(0, 0); + + SwingUtilities.invokeAndWait(bug7154841::initAndShowUI); + + sleep(); + + SwingUtilities.invokeAndWait(() -> { + popupMenu.show(frame, frame.getX() + frame.getWidth() / 2, frame.getY() + frame.getHeight() / 2); + }); + + sleep(); + + int y = (int)screenBounds.get().getY() + (int)screenBounds.get().getHeight() - 10; + int center = (int)(screenBounds.get().getX() + screenBounds.get().getWidth() / 2); + for (int x = center - 10 * STEP; x < center + 10 * STEP; x += STEP) { + r.mouseMove(x, y); + } + + if (!passed) { + throw new RuntimeException("Failed: no mouse events on the popup menu"); + } + } finally { + SwingUtilities.invokeLater(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static Rectangle getScreenBounds() { + return GraphicsEnvironment + .getLocalGraphicsEnvironment() + .getDefaultScreenDevice() + .getDefaultConfiguration() + .getBounds(); + } + + private static void sleep() { + ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + try { + Thread.sleep(200); + } catch (InterruptedException ignored) { } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/jaxp/parsers/8027359/XML11EntityScannerTest.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,184 @@ +/* + * 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 8027359 + * @summary test that the XML11EntityScanner refreshes cache when it loads new data + * @run main XML11EntityScannerTest + */ + +import java.io.*; +import java.util.regex.Pattern; +import javax.xml.parsers.DocumentBuilderFactory; +import org.w3c.dom.*; + + +/** + * XML11EntityScanner functions similarly as XMLEntityScanner in handling data + * cache + */ +public class XML11EntityScannerTest { + static final String rawXML = + "<?xml version=\"1.1\" encoding=\"UTF-8\" standalone=\"no\"?>" + + "<WebOfTrustRC2 Version=\"4004\">" + + "<Identity Name=\"maggot\" PublishesTrustList=\"true\" Version=\"1\">" + + "<Context Name=\"Introduction\"/>" + + "<Context Name=\"FreetalkRC2\"/>" + + "<Property Name=\"IntroductionPuzzleCount\" Value=\"10\"/>" + + "<TrustList>" + + "<Trust Comment=\"\" Identity=\"USK@fdZ2In5mnLVG6RTc5hq9P~M1EG0WuH-itZ7mnQx2iuM,aUG-57VqxQLhQ4N1uNmH9kSI2syEfVFrVOIPAKTY2Yg,AQACAAE/WebOfTrustRC2/5\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@YwwRkHSo-xU8CvSFcLqlU2FFsQ3ztjr0X~xPXkX-klY,poB3tdcXrBU9naI0pyNVYp~zQmHaFkRRTj8xB8tuiPc,AQACAAE/WebOfTrustRC2/7\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@lsd~~79wrGvfb99FnAEY4VhJg2b5KFUloCOUff-Q2fk,71eV-F580euOtaCgim69Yw~2Rjh43DT49sl6zNamjk0,AQACAAE/WebOfTrustRC2/47\" Value=\"100\"/>" + + "<Trust Comment=\"Automatically assigned trust to a seed identity.\" Identity=\"USK@xyzElfFQnwBb4ZuSEh1aSNsbRjEGCTa-2rcjeW58A4E,TiYrXSCcoGETPf0TWLNthaimJEP1PW7nJ2tYXKxdC4s,AQACAAE/WebOfTrustRC2/456\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@pTtYoCsMO-~~2Grqya6Y7cf7nIU3VlL4168-c6EIwA8,QabBgrH1LYKKyBROnWz1r6iI8N7WFTt-mKD-0Qxsw1w,AQACAAE/WebOfTrustRC2/133\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@m~lDSvnetPNy77wsoxDZDUf7OkgX6ZAd7ob9orm3J4Y,SEX20g148KGJg3bsxvXNPNbUsVs1yQ5LfVUOGMh~1Q0,AQACAAE/WebOfTrustRC2/7\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@ss5yQit~bQL5easM68d4sImnPAxHNUbi99XtDMhpzgQ,CnpuD8dO29KvpkQyxtz1llAxHCB7yXfqrQLNRIELZow,AQACAAE/WebOfTrustRC2/2\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@krPcyGts~~wZTbABTAJ59nSplmum2~EkSD5IzinrFko,7YEbm-YEx1LFoZVHtGmIa5q0KbEjw48Rgwx2NqwrH~o,AQACAAE/WebOfTrustRC2/15\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@Usl-yNWc3VtuQWQ9srowZaWyfB6MiD9fzM5WexrlKE8,qMS83aGFsN~aFGajUmGrnbXvRIYZMd8N8IjnGmEvi-s,AQACAAE/WebOfTrustRC2/68\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@St0yKRdQJ3Lq17yoVt9h08bMfhqRhH1vtrcVVInoZVU,BaYM72qM3CYO1yzfVyO1UDUobL56CMbt9EQt3sEXabA,AQACAAE/WebOfTrustRC2/7\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@P8v4ZHUBPYGylYC-KHeWmeu5ZvB6RPYGgKcI5639Wz8,OM9PvjwMlt4L6jKRhqpvyblwpVMYumUgYFrAu3NxY~o,AQACAAE/WebOfTrustRC2/54\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@u2vn3Lh6Kte2-TgBSNKorbsKkuAt34ckoLmgx0ndXO0,4~q8q~3wIHjX9DT0yCNfQmr9oxmYrDZoQVLOdNg~yk0,AQACAAE/WebOfTrustRC2/2\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@MotrIucaZk37pJNS~HHpW5Vea3q0EZpfENPNGSjWh9s,RkFyDjl6-l7V-xYMWtGypmDYk-VehAU1LXmNYdIlHJs,AQACAAE/WebOfTrustRC2/108\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@KXAWN8DJxJ48XzZu7IBBpZ7SFc4n-OXqu4HhQC0V9Ww,DyklyACbgDCZyFpq-LeNqmuve7KWv-WDvJicd37ycn4,AQACAAE/WebOfTrustRC2/11\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@D6BZ1sSEmDMKNMPUN9I~7AalkkXockAdtbxONEN315w,0LiGUSSv4Ln4O7Xe4GQjpMEflNN7okKAH42Vlpv8d8s,AQACAAE/WebOfTrustRC2/56\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@sDehmSJoiaKYT455GIGHIVNKMs7KmiiwXXcCIcDhZ3o,upypWy-ze9Cz7WiCnbbJmoZOh7Xtveitftc5bE~p0Ug,AQACAAE/WebOfTrustRC2/6\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@GsTGXzIm9BTM5~KSZJknfTcPpJtlRs62aJtkNp05T5A,wuQcDjsdPQD9Fa21zWGB5GiiDlmf56vI9Niu5jl8eiM,AQACAAE/WebOfTrustRC2/31\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@eLFdT9VWP60iPNf8a3AkZrzgkcgje2n3Ca1yS8Tc5HU,5D0PISp19VkgzD4VSrRFTmo2CCvRoIuxlQzgMZBmj74,AQACAAE/WebOfTrustRC2/62\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@rz12UCXn-lG53i-6JswD98Kk9Zp0kt05gqIMNYc~9d0,42hoYZ5f~1fPuyvTOVYGJ~28MgYBSfoyzceR8-u1Z2I,AQACAAE/WebOfTrustRC2/126\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@5CYp3t28N5ZbPss9XhOkwUjD~T65q6-nc4aGwbV~-O0,CBfwMjYBiqKunzj3k6Ofpo9pyQsVFPz0OUWVzfd5a0c,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@dSSrRL9BY7JmTQD0dCpcIgVaLFF7pqU8EJzVUp1BYPA,EkTPkLrhEBQLPq-dRVPB1f2CAVdFGbXbUBlIww6re60,AQACAAE/WebOfTrustRC2/5\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@cw2rrCAcYTBjlO-I8DfEj-txttebZMG2LwuPGJV3Qlg,5ZcXLJW8G-R2SFqg4TEQX7IMs~e3Q4DjxUXGuHr9fxA,AQACAAE/WebOfTrustRC2/7\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@7zpRmhkkd5XcAUY6yUwp-53t7to3UN96w98~KQEwha0,30VpXev32s2mhmM5aBRJ---I0OlYbbN6~18j8rJ6qMU,AQACAAE/WebOfTrustRC2/8\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@YmCWYwlaSeE8o~8GawGYWeuPwsgVQtlBwlBkhGQFX04,H3DthY0MZXTe4rL0vsUOOMQDaj6UB9wK59yEwG8Q6No,AQACAAE/WebOfTrustRC2/13\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@aO9svsQEWmib~UyF1ihRUHA8i6uZprGy-tIS-Od9MMk,kwaMemPMVp-jcIRgGLAdF6PZimNE2cZFbvM6ShXAuZw,AQACAAE/WebOfTrustRC2/7\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@6J7FWPHwiCElTRXAO77tMGYAiLxerNF~5olAG0alQxQ,cz72iTz9FT~H57TgroVFv1eZlN5Ia5dhCtRa8bLh1KQ,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@kukYpNG56TNUnQzQe1RZvSYoqQ5B9lcoMZyDlh7xfO4,DNybejZVcWBAaByMRYYLZlgzUjQg28V8j6Zu1CtBc~g,AQACAAE/WebOfTrustRC2/27\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@a-tin0kMl1I~8xn5lkQDqYZRExKLzJITrxcNsr4T~fY,0VmnI67gAzIpdXlZFq~hYD8ikR5IEAg5QTwQv5Ifv5M,AQACAAE/WebOfTrustRC2/24\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@g~4XXw0hjp9TLocYZzunYWX6Don2AQhG-zplmzoCmY0,lyNjClSjRCrBZXVcmPKEAfvH01ySPgv1NWqL8wd11L8,AQACAAE/WebOfTrustRC2/115\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@UXgNMPe1YbVpXHOBXgMlcm9XcGY0G3gUtu43IO-YLLA,7EHSp20GHupg0rWrGPRY1g0TFJcRs-kubVtAcQRMxAc,AQACAAE/WebOfTrustRC2/69\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@lHrF2trsC9gyVeT2zpoL6IlZMz0aKlhN4xa2Ig70rmA,niASdKFC3nDfW6KMvzcv6VmRoHakE7GQAFpfz~2-v3Y,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@hp7IFNYSA97cHNAnHcreTJjQE5fF5sbsFlvbcZXaoxQ,O5h6cAcl5MvxuE2-xOkuvUP4JkT59NQNtaSmtuAS2Y8,AQACAAE/WebOfTrustRC2/16\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@QKPxALYrv6UyAGJs7tor8YlcikFzmy2msZ~42JMT~80,vx01piijkj0o3K8gzNaAOIIZ7NAtQVvPBxlRKtc4iP0,AQACAAE/WebOfTrustRC2/35\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@NmNfUNIr2WwIb9Ej1038Pk0M5gS1M0eHKvxdWqRUfTg,JUJYTsWuNQPOHK039Rczp6oPZDbfPdbO62gSaCuBXFQ,AQACAAE/WebOfTrustRC2/69\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@ONB7kRFo7mI0O3~QLRWlTbo1oB91XmGGS7KtSzz4XVI,yGiqMWRwR~i6ffAXOTBvrngHGC6nYOETUXj4L6Izj64,AQACAAE/WebOfTrustRC2/122\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@k-i0PmxoxO6Mahx8s850Rd7TEe0r4cnEohqC66aMDKw,IlTVYmQ9OSHjiu5pOLq4t-8r50SsVPNMlXn56zfpfDI,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@GtzvV-VHMGQILkpZ3O4CWBTWlhB423UUwpIlzRDgBLs,HUxBDT-Hhy6GqjBV24NRMjlK-o76YGMEgO~ZS6yighU,AQACAAE/WebOfTrustRC2/6\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@Ws0yzkcOYw6ax~kCtnzyX4MgLBHiQd5a6u9FMUmqLG4,zqNjNNGLz7HE4pdSPTovX2AwzGQWJ3-LI7YZt7aq3gg,AQACAAE/WebOfTrustRC2/30\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@6brkdrKlglWHnqMjWG6wrdLMWGPooc~7wQ7ID-PIsJk,X3RRBIdOQ5zthpkk8FjLL33LyoVVI4csJ1~g~sZ1msc,AQACAAE/WebOfTrustRC2/63\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@4DO0Yp1a3RZeAUAjeoPVu~GqpKhaX8RYqe~mwcWgjsM,klsqky963KI6uG3JqE1crihSeBbKBgkJHkIZ2xkWJ4A,AQACAAE/WebOfTrustRC2/36\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@axtoU6zHIkx3bicWK-hLNOj0br4xi0HW1qZ8H6CEv0U,SuPIncAHyYXmR9jQkTFUJd-QgGm0g9lW5ESUjzFOl~Q,AQACAAE/WebOfTrustRC2/8\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@BYsosP8TA22rSz1uA0KGbp6OVFZXhdgAlpH4R4hX9zE,o~qV5IzMR3m7ZOnnG5FPnDqpdffEpu7yOM7VEU9j6lQ,AQACAAE/WebOfTrustRC2/7\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@EilKmVin5cVL7b4FoEQ7ZoHS932O8OI880Qkd~tmzWs,8WK34lo95u~b60GLVczYU6EiRpY0LH7130~ASP9F6dU,AQACAAE/WebOfTrustRC2/75\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@xDYiCplSPLvFGC2dQjAC6eeaYVyQMtV-HmkpuKIJPgQ,CYKZcPacSNfB67IK10xlq7~bAqR-aOnZIA~yhHs2Hj0,AQACAAE/WebOfTrustRC2/71\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@DfCUA1sEJgiGzijEO0BWgeGjjHi28GGgv76H4rLujp8,1lnaOtPiXmvhpRZkBamZNF47uETNKIBgjSzElxcLhZc,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@F45FWNz9rs6TmafG~6n5Bg3Sr69YCHY9v01KTyK17lw,ikIvUS079Qw3aQknvdM8yKgr0XwjcqHgW0pWLu-1osA,AQACAAE/WebOfTrustRC2/13\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@VTDWbj9C5FUEXZBQRXmSsV1aEdOfsB9QHKzZ7-CnCh4,aDjtAVMuGPpCmw1rnCAj5myEnq9HYZeIzrfrhJO2JNw,AQACAAE/WebOfTrustRC2/52\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@dhYMUELq~HtJOweiV2JkGcoFS6hulHd9O~7a9LpGIxM,M-H3ySL8BdCctDUvwvbFNwHUyO1zghSNyotLqkKowi8,AQACAAE/WebOfTrustRC2/20\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@oRpTFVvCqp8qFWiZyCh2QhQ85eh3eP8C8G4YTFhm~rw,kyyeUPuksdt7omGFYFxoWPz3lu6e0q~G1HBx8wFztFc,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@RINL4YHPkTUGBWSoohAoO7Knzk89XSnqnQ6pUZkRY~w,OvIyTUUf4T2Tm46-em~A7zn1zBksIwe-hJP3KKdCe6s,AQACAAE/WebOfTrustRC2/4\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@sEZ-eWgUcQSj-To7lClNN6QNoKuvt0Cz3iTGKv63wQo,krEwvob7MhJ-pGvIk-RM8pVDPFSuXYTZw58oc2Lc49o,AQACAAE/WebOfTrustRC2/1\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@gNTVpdblFLSKMzUBEQM8YTfrO2fQQNIZeV7yJRTqYTQ,EKJhCmbQ5hpMU3cd-J91uneBF7CxTLPqffPs6DxoSMs,AQACAAE/WebOfTrustRC2/21\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@AV8Ubs8pbsMQ1F028a~pSJqtatznLjvhnwfSAtm1QKg,lUHPp~mgzV-pVoG9lYpceL6oOUtFRpvyQjGQdfx1GjY,AQACAAE/WebOfTrustRC2/41\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@xb3QGWdoUpeX9Fn1ZKeDwGN884c2XAMTpYLM9z4OIKo,aWNEDvjhhacFKAjiYJLaUnK1e7dQ9sCk-cnqkGZd7F8,AQACAAE/WebOfTrustRC2/9\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@MrxyFFM~n-kZ4kYvOOZodsvAA2vwp2XtAQJCrkEEU6s,tSHvx3u7uJN8ciaTqBIzt3lLmonM9mj6I7pz88MtBXc,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@-tpkd0enlFMTnjANRjzMKyfE3uyXU-WDX8VUqk3MXEg,J6h7edIdQCsiuc53qahzMzxsyNayXL~9IR0x5QoJVxk,AQACAAE/WebOfTrustRC2/15\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@gBQsXbnA9HX6wQB8x7DIEJT6e7lOxq5jGF353Po~p90,HjdyCLfG9r-zSBN6-AXwA1he9blIO2WEN9u7dMQ7H1w,AQACAAE/WebOfTrustRC2/13\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@ye~rQ4m~pu2Iu3O2TH-GOLBbSeKoQ~QR~vC6tJbKmDg,YSuI-J1nKZjGB2zmIa9Bh2Wtud~jzYBuR7OVhXYh7qM,AQACAAE/WebOfTrustRC2/99\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@HwgX8mU9A7bd2sCsM9And7fotpMGqfba9LzxZtOHHOU,10nYjjfKDH5RB3YvCCi5bpq4GPR-myd8ea7n8DRvx~c,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@qQArPJZuODDeM6C2ndbSczsFLWmLDm2SoaE-9F1hwQU,E3x6TbIvBj~6D9GrMUWSYgnNkLRg85BXXy5~mncoNEI,AQACAAE/WebOfTrustRC2/7\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@4hm9fo4IN0akORyJECttbEGZ~rPCPQ9KKAAH2AWMy8E,klvTyVp-GJznJq8Sln4W2GUfV6tVX2TI2sPCGBFU4tM,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@x7SDH5rL2-tGOaOKFFNMRrylCq94OfiZTWt4t3nwRHk,~E-kX9VqlANo4MeccvNlXDIjJ5xTWTEDNW-Qk04Ke6U,AQACAAE/WebOfTrustRC2/17\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@A9RAAKmky5yroigSupz6Bvrmc4q5FN1SXSrSXa6oRUg,s3RfurouqPnKmlGRkERao6jOJv9kcrVBBKAHqZVuQH4,AQACAAE/WebOfTrustRC2/1\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@yEstdNIW54-3~YA7QnYodpyWgPZStskrN9WXLHujUrE,j4PciAtpUHOjR2wmaaCKwiryJAi~exjETJ13UPGJLTg,AQACAAE/WebOfTrustRC2/58\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@NZSwPe8RJQOTSQ-~cAuxy97ieuX9reSft0cyD0vfbJg,99y8KOdRJmVLCWqryDzB8NdBrQGY7V9JDFtgCQBuGsU,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@Nq6iEvHP0B2VCszLCenQrfyJmkD0vas~00-9MoWgcTA,6dI2kB1z9mtjwITkhc9~V86QE5gM9CJBMjdpvRzKAoY,AQACAAE/WebOfTrustRC2/29\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@ZaNXnLCT7OQrwhp4I9V-rI1ZAV9WzegFj0HSaEJQ-Z4,i23K-dQupDenVE8O3xGv92vVanfDeyjLYWescevMbGg,AQACAAE/WebOfTrustRC2/14\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@53e9r9zEkJ0TRW~Tq8XIWjZ3WkL7Jv5Ez8LDhdwwzwM,7a0vL0OmWkHy3gC5Zs~MxB4k0QppwK4igrH6iuwls68,AQACAAE/WebOfTrustRC2/7\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@W1c~RYRC09xIHiHIucfV~Rj4J8uKAGrUeHmrH-q-U1c,niOrI75WMQ-Dtl9luIbKBmnvf6chkQEKvUvoKvSjhxI,AQACAAE/WebOfTrustRC2/4\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@G6zv74PaPcVZcf78lWp-e1TfrCSNZa1ZaPvmjm7DVzk,f4Ft3sLQ6cUEwpumpTMt5N17UORfZoXjGfmke5PJbdc,AQACAAE/WebOfTrustRC2/5\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@m5ILsPVAlcOY5D91J2iQu~PIntZb3L-B1VkONjEZs2k,592dl39JXIF1kpC4OMkw7ELOhdPrn~WXBsZln20pM7Q,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@iK69tf7gzQ53oZV60rF6ZSwwCfADMRsJeG2YmODdmJc,5czI5ZmWbWLDr2L9JdDmkt7qrr8fs55VDt3tXnrFw0E,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@bloE1LJ~qzSYUkU2nt7sB9kq060D4HTQC66pk5Q8NpA,DOOASUnp0kj6tOdhZJ-h5Tk7Ka50FSrUgsH7tCG1usU,AQACAAE/WebOfTrustRC2/58\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@0j-H~zKeP9mh6LEJUl4HSJYC-lQWstYRJeC~5E2F5~c,VbjnSixETRzKp80jYYXD-bqsTUWzxwcYmI9ZSWsBrik,AQACAAE/WebOfTrustRC2/13\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@~4ZW0eji3~hYAakiCI056soETGPf9O94GtoIpE2NGEg,GdtKsS~WeDlBS~OL1egxqZ4pr-iPXHjT2zcy8pjvEK4,AQACAAE/WebOfTrustRC2/88\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@YommlOi4fTYx9axhnl9iAi9BNHRvnM5XWjl21i0563k,5FswxS7hPf2erR8KkrBobG8R9bekaakeY1tM8DDNsjI,AQACAAE/WebOfTrustRC2/2\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@-ucM1bn8sICGRAemM8wZ~BVHgX3ZPUoutjZY64mBIcQ,Ko~kC54wZ-joCpfdc67Vds8LkAIxvTJGpMtfQSl4mAA,AQACAAE/WebOfTrustRC2/2\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@VwcZEhjtMuFcYIa8r0yksTs~FvMWB7swEz6tK67Vmsw,0blSLTQDms-WWbw1IBuKIoR2ZvSHpI21lMFeByQPuII,AQACAAE/WebOfTrustRC2/56\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@HAoXk-dW6~j5eLdAZCEjyKTVC974wkdl-4QqrPcbyzE,NlS05DkGK8QzL~EVUOfb~Jl1EZoVJTQBQBzA6N2qMn4,AQACAAE/WebOfTrustRC2/7\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@2PK-12eJFcVziT6eMpiUpOpTlmDNAoVOKZvA~8s7VSg,EaHdnKfKoWQDclX1mwcQeGr5jo1ijxyExYqL7Vsf-o8,AQACAAE/WebOfTrustRC2/33\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@8D3L5TDTyp5jnbT4imUWK12QC-B0iaSxFPOstMX2URg,ZtSShNkEVV8whaGQtIxiJ3FBroihw8YDyZrWvqncs0s,AQACAAE/WebOfTrustRC2/12\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@HKv7Hp94hFz8CKlINXCImq~XIBL9VfsPSgqfR0QIZFQ,vFM45qVvCajf3iqZm~ykZYwqM0KhaUSkU3RGaxJzHLI,AQACAAE/WebOfTrustRC2/4\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@NJu4xYtC3cgZo8s2xqmap3eh1dy60tFQFoxU8aeSnq8,fp~WLcrSSUKnr9wDDz-geb8FDwADCMCA9fjKt04Cyg8,AQACAAE/WebOfTrustRC2/4\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@IazjsmIK8VnIjDkq3-ecMEKHmi0dBT1QsNBq2mp2Fuo,uu24sWwNW~tjszdw19Mz18NBGx1MSADi03BHZnttwFo,AQACAAE/WebOfTrustRC2/8\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@IfxF-y7PNV97WUiHLqlIwXQyfVsHjI-Am4unZ0AK-Qk,Xm78gNC236A3wZ1RWBnft4oBGHU1R88Yt9AlphmtJPo,AQACAAE/WebOfTrustRC2/36\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@i1YvNnlMkd0i~0SiXiDHlGaxbtYd8ZqEUij~VzxyXmM,rxi19mph9KtHA6~gVGJ1rZ6kytff~kJDm6~NrA4YQaI,AQACAAE/WebOfTrustRC2/9\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@nXf5sbMSDqE~OkCQ~8JaMgPbj2LQJcuouvO56ADo28s,uEMqVaBzpA06TaC8A0cqKuv~lSfqZBiijasA3nlQ0Fc,AQACAAE/WebOfTrustRC2/8\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@Y8fLVylNs~pB6sdA5Dl1l6T~hXQrLNZLMgfDl5-E5Z0,n0zdN5XUa-D5Puf0L9wu~xQQmU~A5TpfqJ4RFHJLjLs,AQACAAE/WebOfTrustRC2/1\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@F0ixRao2hQlvTQDkN6rPcwLTG2nA6x0r8RrTQ0443IQ,LxN-gYvq4eWRuhjAgejmgNqYJdIw0q8IJ2XNwwVHhmQ,AQACAAE/WebOfTrustRC2/12\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@Pgk~nJzSVNAjFHh-qTovvm6muY08igdOCEWuyUrbFvk,NlwUDwfQlbXRjIaFAVljD5E1loXi31Xq6dG8YC7JOR0,AQACAAE/WebOfTrustRC2/5\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@m9gYemmVNXe32Ao6jeUgW8ttgGlMSIAW1608YZ19olE,LnEWPRzsPlPfq2~gIYQ5SVV-V2lthAx254dht9EZgyU,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@Pwiulr-xlPJelS5CO4~do78zZHTL5TNIChF5hpz8nkY,z77V~KhcKZRWLSWtVzaWO-dt~TzCCJFCHUDhHXI715M,AQACAAE/WebOfTrustRC2/8\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@OH3ZkrLAkMJbQTjVW3e9ioH04F7jpUVNMekiQAAvRjs,J6qOC05GoqRgST93M1V90HWxq9VK4PCKIpltkL8GAhg,AQACAAE/WebOfTrustRC2/5\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@nirNdzBgVyqMpnuT5UrmX~TU354qDIY7XAp04Kutysg,vpf1npG3nUARPSkFRx9xbVT~w1ELw0jQhdiXbxWcafg,AQACAAE/WebOfTrustRC2/1\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@ozK579KUDjjxkve1gKeV8IDd5qe0NPtxlFVV2-8iXrM,hlU82qnHi5ZnIfSD5~hr4wmUjNFJjQYted7FJWBj8z8,AQACAAE/WebOfTrustRC2/12\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@D6JSlrnlDDXfnGhijswHC5a4-EBuYNFhg2IyoFhzRRM,tCJy6EvZRhk-Og9CIkR3jfLD4VYxwOY5Wf991XMLdmE,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@Bn1Ozb4~Q639N~GvSXrbzZoVx9ziFfbkiKf1akXr9dQ,DrwwRjH~WrErR595BqxyDeisgcTLRZjCsQUBQSdnPLk,AQACAAE/WebOfTrustRC2/10\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@~aHztTNobVhKiaJ2eE-k6LLMy3qrRzL0zvk1UZp1xAU,xs3tuQsYRrTgxoU5qrayiwoOYEOLE6bTHvIKBQLIwco,AQACAAE/WebOfTrustRC2/3\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@jr3FrHPhtxP-IYQ-A12A3jjNNK4-KcHsUH8qNpBGHJ0,WK9IlZuG17JZ3YvaRUR-3uHf1YqkxxyGxkpkLW56ZTY,AQACAAE/WebOfTrustRC2/1\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@iBBjdbuuabx3v7iy-Pt3WZjWuixqo2-rzH~2kV4FkwE,Hll6SNQ~FXY5mrOY2W0GTfyNhJSlOrYutJmoXeSKseE,AQACAAE/WebOfTrustRC2/4\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@TKOVixP3xx6nA3-cgl2fksatQzxg4LlReoK0GFl7uAo,r~MCdO2rhGxBgRYv2EPuIE-tP7-0z6vuwbS04oyoAyI,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@bK9LQT2mqilUY4DxwmlKvKi5Jfwf4Brr~EQGa8RLIRU,Ni90~c4q-VNFrxFS7cDimQwCcRsqdScHoElWQgBpoT8,AQACAAE/WebOfTrustRC2/6\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@DYXv~V1jDo0XBhaiaGeRvy-~snqMbBiFR~R8TK8VBNg,4YYHZfVVYZmudSCOetDlNxnvbLy6IULV1SOgeC1zXmI,AQACAAE/WebOfTrustRC2/4\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@CSWvDlm9RM31O9NPpZomFvpTVM8cV0brixDXxpwnJ7A,4wfD~qxb5hFgCBN0JWgK6p11wUCpOHGOWhJ4i2FgFhY,AQACAAE/WebOfTrustRC2/0\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@sFsqYnIVQ9FwULsp3e-q0M46fRw2jVsLJYF9PUyHVME,aDhfrzYPt4O0BTuuRF3aCPTR0A~zr2rqHtPpJXeSqFU,AQACAAE/WebOfTrustRC2/4\" Value=\"100\"/>" + + "<Trust Comment=\"\" Identity=\"USK@1QwMtp0oc4jIh6DFUjec~U0O3ldWHrRmhh5OZd41MMo,GZ-QOMc4mAkHhG4LwJWU~-rl0zJIp90YcB5hn3M9tlg,AQACAAE/WebOfTrustRC2/4\" Value=\"100\"/>" + + "</TrustList>" + + "</Identity>" + + "</WebOfTrustRC2>"; + + /** + * main method. + * + * @param args Standard args. + */ + public static void main(String[] args) { + try { + final Document xmlDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(rawXML.getBytes("UTF-8"))); + final Element identityElement = (Element) xmlDoc.getElementsByTagName("Identity").item(0); + final Element trustListElement = (Element) identityElement.getElementsByTagName("TrustList").item(0); + final NodeList trustList = trustListElement.getElementsByTagName("Trust"); + final Pattern keyPattern = Pattern.compile("USK@[%,~" + "*-_./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" + "]+"); + for (int i = 0; i < trustList.getLength(); ++i) { + Element trustElement = (Element) trustList.item(i); + final String identity = trustElement.getAttribute("Identity"); + if (!keyPattern.matcher(identity).matches()) { + throw new RuntimeException("Parsing failure: Instead of USK URI I got: " + identity); + } + } + } catch (Exception ex) { + throw new RuntimeException(ex.getMessage()); + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/jaxp/parsers/8032909/XSLT.java Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8032909 + * @summary Test for XSLT string-length function with complementary chars + * @compile XSLT.java + * @run main/othervm XSLT a_utf16.xml a_utf16.xsl 1270 + * @run main/othervm XSLT a_utf8.xml a_utf8.xsl 130 + * @run main/othervm XSLT a_windows1252.xml a_windows1252.xsl 200 + */ + +import java.io.ByteArrayOutputStream; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; + +public class XSLT { + public static void main(String[] args) throws Exception { + + ByteArrayOutputStream resStream = new ByteArrayOutputStream(); + TransformerFactory trf = TransformerFactory.newInstance(); + Transformer tr = trf.newTransformer(new StreamSource(System.getProperty("test.src", ".")+"/"+args[1])); + String res, expectedRes; + tr.transform( new StreamSource(System.getProperty("test.src", ".")+"/"+args[0]), new StreamResult(resStream)); + res = resStream.toString(); + System.out.println("Transformation completed. Result:"+res); + + if (!res.replaceAll("\\s","").equals(args[2])) + throw new RuntimeException("Incorrect transformation result. Expected:"+args[2]+" Observed:"+res); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/jaxp/parsers/8032909/a_utf8.xml Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<testxml> +<Element>UTF-8_Element</Element> +<Element2></Element2> +</testxml>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/jaxp/parsers/8032909/a_utf8.xsl Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + +<xsl:output method="text" /> + +<xsl:template match="Element"> +<xsl:value-of select="string-length(.)"/> +</xsl:template> +<xsl:template match="Element2"> +<xsl:value-of select="string-length(.)"/> +</xsl:template> + +</xsl:stylesheet>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/jaxp/parsers/8032909/a_windows1252.xml Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="windows-1252"?> +<testxml> +<Element>Windows-1252_Element</Element> +<Element2></Element2> +</testxml>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/jaxp/parsers/8032909/a_windows1252.xsl Mon Mar 24 13:15:07 2014 -0700 @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="windows-1252"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + +<xsl:output method="text" /> + +<xsl:template match="Element"> +<xsl:value-of select="string-length(.)"/> +</xsl:template> +<xsl:template match="Element2"> +<xsl:value-of select="string-length(.)"/> +</xsl:template> + +</xsl:stylesheet>
--- a/test/sun/util/calendar/zi/Zoneinfo.java Wed Mar 19 15:19:35 2014 -0700 +++ b/test/sun/util/calendar/zi/Zoneinfo.java Mon Mar 24 13:15:07 2014 -0700 @@ -372,6 +372,7 @@ ZoneRec zrec = zone.get(zone.size()-1); tz.getOffsetIndex(zrec.getGmtOffset()); + int lastGmtOffsetValue = -1; int currentSave = 0; boolean usedZone; for (int zindex = 0; zindex < zone.size(); zindex++) { @@ -380,9 +381,12 @@ gmtOffset = zrec.getGmtOffset(); int stdOffset = zrec.getDirectSave(); + if (gmtOffset != lastGmtOffsetValue) { + tz.setRawOffset(gmtOffset, fromTime); + lastGmtOffsetValue = gmtOffset; + } // If this is the last zone record, take the last rule info. if (!zrec.hasUntil()) { - tz.setRawOffset(gmtOffset, fromTime); if (zrec.hasRuleReference()) { tz.setLastRules(zrec.getRuleRef().getLastRules()); } else if (stdOffset != 0) {
--- a/test/sun/util/calendar/zi/tzdata/VERSION Wed Mar 19 15:19:35 2014 -0700 +++ b/test/sun/util/calendar/zi/tzdata/VERSION Mon Mar 24 13:15:07 2014 -0700 @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2013i +tzdata2014a
--- a/test/sun/util/calendar/zi/tzdata/asia Wed Mar 19 15:19:35 2014 -0700 +++ b/test/sun/util/calendar/zi/tzdata/asia Mon Mar 24 13:15:07 2014 -0700 @@ -1113,8 +1113,13 @@ Rule Zion 1986 only - Sep 7 0:00 0 S Rule Zion 1987 only - Apr 15 0:00 1:00 D Rule Zion 1987 only - Sep 13 0:00 0 S -Rule Zion 1988 only - Apr 9 0:00 1:00 D -Rule Zion 1988 only - Sep 3 0:00 0 S + +# From Avigdor Finkelstein (2014-03-05): +# I check the Parliament (Knesset) records and there it's stated that the +# [1988] transition should take place on Saturday night, when the Sabbath +# ends and changes to Sunday. +Rule Zion 1988 only - Apr 10 0:00 1:00 D +Rule Zion 1988 only - Sep 4 0:00 0 S # From Ephraim Silverberg # (1997-03-04, 1998-03-16, 1998-12-28, 2000-01-17, 2000-07-25, 2004-12-22,
--- a/test/sun/util/calendar/zi/tzdata/australasia Wed Mar 19 15:19:35 2014 -0700 +++ b/test/sun/util/calendar/zi/tzdata/australasia Mon Mar 24 13:15:07 2014 -0700 @@ -377,16 +377,18 @@ # http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=6702&catid=71&Itemid=155 # From the Fijian Government Media Center (2013-08-30) via David Wheeler: -# Fiji will start daylight savings on Sunday 27th October, 2013 and end at 3am -# on Sunday 19th January, 2014.... move clocks forward by one hour from 2am +# Fiji will start daylight savings on Sunday 27th October, 2013 ... +# move clocks forward by one hour from 2am # http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-27th-OCTOBER-201.aspx -# -# From Paul Eggert (2013-09-09): + +# From Steffen Thorsen (2013-01-10): +# Fiji will end DST on 2014-01-19 02:00: +# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVINGS-TO-END-THIS-MONTH-%281%29.aspx + +# From Paul Eggert (2014-01-10): # For now, guess that Fiji springs forward the Sunday before the fourth -# Monday in October. This matches both recent practice and -# timeanddate.com's current spring-forward prediction. -# For the January 2014 transition we guessed right while timeanddate.com -# guessed wrong, so leave the fall-back prediction alone. +# Monday in October, and springs back the penultimate Sunday in January. +# This is ad hoc, but matches recent practice. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 S @@ -395,7 +397,8 @@ Rule Fiji 2010 only - Mar lastSun 3:00 0 - Rule Fiji 2010 max - Oct Sun>=21 2:00 1:00 S Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - -Rule Fiji 2012 max - Jan Sun>=18 3:00 0 - +Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - +Rule Fiji 2014 max - Jan Sun>=18 2:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva 12:00 Fiji FJ%sT # Fiji Time
--- a/test/sun/util/calendar/zi/tzdata/europe Wed Mar 19 15:19:35 2014 -0700 +++ b/test/sun/util/calendar/zi/tzdata/europe Mon Mar 24 13:15:07 2014 -0700 @@ -2768,14 +2768,18 @@ # According to the articles linked below, Turkey will change into summer # time zone (GMT+3) on March 28, 2011 at 3:00 a.m. instead of March 27. # This change is due to a nationwide exam on 27th. -# -# <a href="http://www.worldbulletin.net/?aType=haber&ArticleID=70872"> # http://www.worldbulletin.net/?aType=haber&ArticleID=70872 -# </a> # Turkish: -# <a href="http://www.hurriyet.com.tr/ekonomi/17230464.asp?gid=373"> # http://www.hurriyet.com.tr/ekonomi/17230464.asp?gid=373 -# </a> + +# From Faruk Pasin (2014-02-14): +# The DST for Turkey has been changed for this year because of the +# Turkish Local election.... +# http://www.sabah.com.tr/Ekonomi/2014/02/12/yaz-saatinde-onemli-degisiklik +# ... so Turkey will move clocks forward one hour on March 31 at 3:00 a.m. +# From Paul Eggert (2014-02-17): +# Here is an English-language source: +# http://www.worldbulletin.net/turkey/129016/turkey-switches-to-daylight-saving-time-march-31 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Turkey 1916 only - May 1 0:00 1:00 S @@ -2844,6 +2848,8 @@ 2:00 Turkey EE%sT 2007 2:00 EU EE%sT 2011 Mar 27 1:00u 2:00 - EET 2011 Mar 28 1:00u + 2:00 EU EE%sT 2014 Mar 30 1:00u + 2:00 - EET 2014 Mar 31 1:00u 2:00 EU EE%sT Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. @@ -2865,19 +2871,13 @@ # approval from 266 deputies. # # Ukraine abolishes transter back to the winter time (in Russian) -# <a href="http://news.mail.ru/politics/6861560/"> # http://news.mail.ru/politics/6861560/ -# </a> # # The Ukrainians will no longer change the clock (in Russian) -# <a href="http://www.segodnya.ua/news/14290482.html"> # http://www.segodnya.ua/news/14290482.html -# </a> # # Deputies cancelled the winter time (in Russian) -# <a href="http://www.pravda.com.ua/rus/news/2011/09/20/6600616/"> # http://www.pravda.com.ua/rus/news/2011/09/20/6600616/ -# </a> # # From Philip Pizzey (2011-10-18): # Today my Ukrainian colleagues have informed me that the @@ -2888,18 +2888,39 @@ # As far as I understand, the recent change to the Ukrainian time zone # (Europe/Kiev) to introduce permanent daylight saving time (similar # to Russia) was reverted today: -# -# <a href="http://portal.rada.gov.ua/rada/control/en/publish/article/info_left?art_id=287324&cat_id=105995"> # http://portal.rada.gov.ua/rada/control/en/publish/article/info_left?art_id=287324&cat_id=105995 -# </a> # # Also reported by Alexander Bokovoy (2011-10-18) who also noted: # The law documents themselves are at +# http://w1.c1.rada.gov.ua/pls/zweb_n/webproc4_1?id=&pf3511=41484 + +# From Vladimir in Moscow via Alois Treindl re Kiev time 1991/2 (2014-02-28): +# First in Ukraine they changed Time zone from UTC+3 to UTC+2 with DST: +# 03 25 1990 02:00 -03.00 1 Time Zone 3 with DST +# 07 01 1990 02:00 -02.00 1 Time Zone 2 with DST +# * Ukrainian Government's Resolution of 18.06.1990, No. 134. +# http://search.ligazakon.ua/l_doc2.nsf/link1/T001500.html # -# <a href="http://w1.c1.rada.gov.ua/pls/zweb_n/webproc4_1?id=&pf3511=41484"> -# http://w1.c1.rada.gov.ua/pls/zweb_n/webproc4_1?id=&pf3511=41484 -# </a> - +# They did not end DST in September, 1990 (according to the law, +# "summer time" was still in action): +# 09 30 1990 03:00 -02.00 1 Time Zone 2 with DST +# * Ukrainian Government's Resolution of 21.09.1990, No. 272. +# http://search.ligazakon.ua/l_doc2.nsf/link1/KP900272.html +# +# Again no change in March, 1991 ("summer time" in action): +# 03 31 1991 02:00 -02.00 1 Time Zone 2 with DST +# +# DST ended in September 1991 ("summer time" ended): +# 09 29 1991 03:00 -02.00 0 Time Zone 2, no DST +# * Ukrainian Government's Resolution of 25.09.1991, No. 225. +# http://www.uazakon.com/documents/date_21/pg_iwgdoc.htm +# This is an answer. +# +# Since 1992 they had normal DST procedure: +# 03 29 1992 02:00 -02.00 1 DST started +# 09 27 1992 03:00 -02.00 0 DST ended +# * Ukrainian Government's Resolution of 20.03.1992, No. 139. +# http://www.uazakon.com/documents/date_8u/pg_grcasa.htm # Zone NAME GMTOFF RULES FORMAT [UNTIL] # Most of Ukraine since 1970 has been like Kiev. @@ -2910,9 +2931,8 @@ 2:00 - EET 1930 Jun 21 3:00 - MSK 1941 Sep 20 1:00 C-Eur CE%sT 1943 Nov 6 - 3:00 Russia MSK/MSD 1990 - 3:00 - MSK 1990 Jul 1 2:00 - 2:00 - EET 1992 + 3:00 Russia MSK/MSD 1990 Jul 1 2:00 + 2:00 1:00 EEST 1991 Sep 29 3:00 2:00 E-Eur EE%sT 1995 2:00 EU EE%sT # Ruthenia used CET 1990/1991.
--- a/test/sun/util/calendar/zi/tzdata/northamerica Wed Mar 19 15:19:35 2014 -0700 +++ b/test/sun/util/calendar/zi/tzdata/northamerica Mon Mar 24 13:15:07 2014 -0700 @@ -414,9 +414,10 @@ # US Pacific time, represented by Los Angeles # # California, northern Idaho (Benewah, Bonner, Boundary, Clearwater, -# Idaho, Kootenai, Latah, Lewis, Nez Perce, and Shoshone counties, -# and the northern three-quarters of Idaho county), -# most of Nevada, most of Oregon, and Washington +# Kootenai, Latah, Lewis, Nez Perce, and Shoshone counties, Idaho county +# north of the Salmon River, and the towns of Burgdorf and Warren), +# Nevada (except West Wendover), Oregon (except the northern 3/4 of +# Malheur county), and Washington # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule CA 1948 only - Mar 14 2:00 1:00 D
--- a/test/sun/util/calendar/zi/tzdata/southamerica Wed Mar 19 15:19:35 2014 -0700 +++ b/test/sun/util/calendar/zi/tzdata/southamerica Mon Mar 24 13:15:07 2014 -0700 @@ -1298,6 +1298,13 @@ # start date is 2013-09-08 00:00.... # http://www.gob.cl/informa/2013/02/15/gobierno-anuncia-fechas-de-cambio-de-hora-para-el-ano-2013.htm +# From Jose Miguel Garrido (2014-02-19): +# Today appeared in the Diario Oficial a decree amending the time change +# dates to 2014. +# DST End: last Saturday of April 2014 (Sun 27 Apr 2014 03:00 UTC) +# DST Start: first Saturday of September 2014 (Sun 07 Sep 2014 04:00 UTC) +# http://www.diariooficial.interior.gob.cl//media/2014/02/19/do-20140219.pdf + # NOTE: ChileAQ rules for Antarctic bases are stored separately in the # 'antarctica' file. @@ -1631,6 +1638,9 @@ # From Carlos Raul Perasso (2013-03-15): # The change in Paraguay is now final. Decree number 10780 # http://www.presidencia.gov.py/uploads/pdf/presidencia-3b86ff4b691c79d4f5927ca964922ec74772ce857c02ca054a52a37b49afc7fb.pdf +# From Carlos Raul Perasso (2014-02-28): +# Decree 1264 can be found at: +# http://www.presidencia.gov.py/archivos/documentos/DECRETO1264_ey9r8zai.pdf Rule Para 2013 max - Mar Sun>=22 0:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -1689,18 +1699,19 @@ Zone America/Port_of_Spain -4:06:04 - LMT 1912 Mar 2 -4:00 - AST +# These all agree with Trinidad and Tobago since 1970. Link America/Port_of_Spain America/Anguilla Link America/Port_of_Spain America/Dominica Link America/Port_of_Spain America/Grenada Link America/Port_of_Spain America/Guadeloupe -Link America/Port_of_Spain America/Marigot +Link America/Port_of_Spain America/Marigot # St Martin (French part) Link America/Port_of_Spain America/Montserrat Link America/Port_of_Spain America/St_Barthelemy -Link America/Port_of_Spain America/St_Kitts +Link America/Port_of_Spain America/St_Kitts # St Kitts & Nevis Link America/Port_of_Spain America/St_Lucia -Link America/Port_of_Spain America/St_Thomas +Link America/Port_of_Spain America/St_Thomas # Virgin Islands (US) Link America/Port_of_Spain America/St_Vincent -Link America/Port_of_Spain America/Tortola +Link America/Port_of_Spain America/Tortola # Virgin Islands (UK) # Uruguay # From Paul Eggert (1993-11-18):