diff --git a/.hgtags b/.hgtags index 005af9445666b3fc8b04a99d224b24ee3643f0f0..58af38bd8637d6e9d816ba6be8acf1bb2f2f0e56 100644 --- a/.hgtags +++ b/.hgtags @@ -257,4 +257,7 @@ f644211c59fd7c1d0c81239c55b31e1d377d7650 jdk8-b128 5a9f04957f826ce23639479c9791c7d8fd282b01 jdk8u20-b03 c347889445c1153f11aaa56092d44a911e497454 jdk8u20-b04 c9117a5defe912b1f7ae92bb0730d6e7a5a045df jdk8u20-b05 +43386cc9a017a9f9e704760050086bb18b778ae0 jdk8-b130 +e291ac47c9a90366c3c0787a6f7ce547a2bda308 jdk8-b131 +43cb25339b5500871f41388a5197f1b01c4b57b8 jdk8-b132 1ecfc0fac3e7b931f09728b7594384ea5b5f9f0f jdk8u20-b06 diff --git a/make/Import.gmk b/make/Import.gmk index 46c64d4d468b3b424b1cf98890485f3cc49242f4..92d4d1d26d10c540d50a22a586f04b0a17130f02 100644 --- a/make/Import.gmk +++ b/make/Import.gmk @@ -252,7 +252,7 @@ define unzip-sec-file $(ECHO) Unzipping $( $@.tmp) + ($(CD) $(JDK_OUTPUTDIR) && $(UNZIP) -q -o $< > $@.tmp) $(MV) $@.tmp $@ endef diff --git a/make/data/tzdata/VERSION b/make/data/tzdata/VERSION index 2f162e0638af1a8de4d3e8c5052e695aa4468111..8ab96a77e71215f15dee92049dbed3fa6ae8047f 100644 --- a/make/data/tzdata/VERSION +++ b/make/data/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2013i +tzdata2014a diff --git a/make/data/tzdata/asia b/make/data/tzdata/asia index 1a8f83d3a644ea690abda78ad4cc8170af9a6aed..dc3c94ba9ccc8dc4e2244f32b459eaed7297e289 100644 --- a/make/data/tzdata/asia +++ b/make/data/tzdata/asia @@ -1113,8 +1113,13 @@ Rule Zion 1986 only - May 18 0:00 1:00 D 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, diff --git a/make/data/tzdata/australasia b/make/data/tzdata/australasia index cd6b724859de11d7f5dd448b2cb4df2f4f7a7ba6..a0e8b5a2ce97edbf13e8d684723ab649f0b53047 100644 --- a/make/data/tzdata/australasia +++ b/make/data/tzdata/australasia @@ -377,16 +377,18 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 # 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 2009 only - Nov 29 2:00 1:00 S 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 diff --git a/make/data/tzdata/europe b/make/data/tzdata/europe index 9f574a3b2b6cba812969bece8280aa051678d585..585e64d14fa713a22cae5be7bf2bb7025cc02d0f 100644 --- a/make/data/tzdata/europe +++ b/make/data/tzdata/europe @@ -2768,14 +2768,18 @@ Zone Europe/Zurich 0:34:08 - LMT 1853 Jul 16 # See above comment. # 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. -# -# # http://www.worldbulletin.net/?aType=haber&ArticleID=70872 -# # Turkish: -# # http://www.hurriyet.com.tr/ekonomi/17230464.asp?gid=373 -# + +# 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 @@ Zone Europe/Istanbul 1:55:52 - LMT 1880 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 @@ Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. # approval from 266 deputies. # # Ukraine abolishes transter back to the winter time (in Russian) -# # http://news.mail.ru/politics/6861560/ -# # # The Ukrainians will no longer change the clock (in Russian) -# # http://www.segodnya.ua/news/14290482.html -# # # Deputies cancelled the winter time (in Russian) -# # http://www.pravda.com.ua/rus/news/2011/09/20/6600616/ -# # # From Philip Pizzey (2011-10-18): # Today my Ukrainian colleagues have informed me that the @@ -2888,18 +2888,39 @@ Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. # 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: -# -# # http://portal.rada.gov.ua/rada/control/en/publish/article/info_left?art_id=287324&cat_id=105995 -# # # 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 +# +# 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 @@ Zone Europe/Kiev 2:02:04 - LMT 1880 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. diff --git a/make/data/tzdata/northamerica b/make/data/tzdata/northamerica index 9e551bb1c465d4acf5e30e15895e5d6d83bcfeb1..dc0c2e92cff499a8a1c53d2ce2be86ec84465c2c 100644 --- a/make/data/tzdata/northamerica +++ b/make/data/tzdata/northamerica @@ -414,9 +414,10 @@ Zone America/Denver -6:59:56 - LMT 1883 Nov 18 12:00:04 # 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 diff --git a/make/data/tzdata/southamerica b/make/data/tzdata/southamerica index 071f890bd05951666c46001d2f780200a14e75a3..02bf3bb633268d7eb403183746a3b44e21888aca 100644 --- a/make/data/tzdata/southamerica +++ b/make/data/tzdata/southamerica @@ -1298,6 +1298,13 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # 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 @@ Rule Para 2010 2012 - Apr Sun>=8 0:00 0 - # 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/Paramaribo -3:40:40 - LMT 1911 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): diff --git a/src/macosx/classes/sun/lwawt/LWChoicePeer.java b/src/macosx/classes/sun/lwawt/LWChoicePeer.java index 5b78e74b6a2175da7db6fcf8f417b8b975b48b1b..bb360d6d67785d0108c685ed670158996c0878a2 100644 --- a/src/macosx/classes/sun/lwawt/LWChoicePeer.java +++ b/src/macosx/classes/sun/lwawt/LWChoicePeer.java @@ -168,16 +168,16 @@ final class LWChoicePeer extends LWComponentPeer> @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); } }); } diff --git a/src/macosx/classes/sun/lwawt/LWWindowPeer.java b/src/macosx/classes/sun/lwawt/LWWindowPeer.java index d61dc7a9d0ef97c62af1821f0e4496a7cd257ed7..5b8e7fcc1c1790c08507dc2941dfee36d00967de 100644 --- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -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 class LWWindowPeer 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 @@ public class LWWindowPeer // 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 @@ public class LWWindowPeer 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 @@ public class LWWindowPeer // - 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 @@ public class LWWindowPeer 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)) { diff --git a/src/macosx/classes/sun/lwawt/macosx/CClipboard.java b/src/macosx/classes/sun/lwawt/macosx/CClipboard.java index df5f2178cbf22140aa1d97f2965a1a4335e62718..ad45ce9a565c13c358323f88e1104565dbb110a7 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CClipboard.java +++ b/src/macosx/classes/sun/lwawt/macosx/CClipboard.java @@ -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 @@ import sun.awt.datatransfer.*; * 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,27 +92,19 @@ public class CClipboard extends SunClipboard { notifyChanged(); } - private void notifyLostOwnership() { - lostOwnershipImpl(); - } - - private static void notifyChanged() { - CClipboard clipboard = (CClipboard) Toolkit.getDefaultToolkit().getSystemClipboard(); - if (!clipboard.areFlavorListenersRegistered()) { - return; - } - clipboard.checkChange(clipboard.getClipboardFormats()); - } - + @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 } @@ -118,8 +113,8 @@ public class CClipboard extends SunClipboard { // 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); + 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 @@ -127,5 +122,18 @@ public class CClipboard extends SunClipboard { * pasteboard ownership and someone else put data on the clipboard. * @since 1.7 */ - public native void checkPasteboard(); + native void checkPasteboard(); + + /*** Native Callbacks ***/ + private void notifyLostOwnership() { + lostOwnershipImpl(); + } + + private static void notifyChanged() { + CClipboard clipboard = (CClipboard) Toolkit.getDefaultToolkit().getSystemClipboard(); + if (!clipboard.areFlavorListenersRegistered()) { + return; + } + clipboard.checkChange(clipboard.getClipboardFormats()); + } } diff --git a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java index dcee9ce10b865bd8a66594c3e2b157e3819365df..8b2eb3dfd783a55d09e502b90bbac46422c0c8fe 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java +++ b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java @@ -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 @@ public class CDataTransferer extends DataTransferer { }; static { - Map nameMap = new HashMap(predefinedClipboardNames.length, 1.0f); - Map formatMap = new HashMap(predefinedClipboardNames.length, 1.0f); + Map nameMap = new HashMap<>(predefinedClipboardNames.length, 1.0f); + Map 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 class CDataTransferer extends DataTransferer { 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 @@ public class CDataTransferer extends DataTransferer { 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 @@ public class CDataTransferer extends DataTransferer { } } - 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 @@ public class CDataTransferer extends DataTransferer { } return super.translateBytes(bytes, flavor, format, transferable); - } - + } + @Override synchronized protected Long getFormatForNativeAsLong(String str) { Long format = predefinedClipboardNameMap.get(str); @@ -202,6 +167,7 @@ public class CDataTransferer extends DataTransferer { // 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 @@ public class CDataTransferer extends DataTransferer { 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 @@ public class CDataTransferer extends DataTransferer { 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 @@ public class CDataTransferer extends DataTransferer { } 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 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 @@ public class CDataTransferer extends DataTransferer { } -// ---- 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 = ""; - public static final String END_FRAGMENT_CMT = ""; - 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(); - } - } -} diff --git a/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java b/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java index 570a2ac7730c878ad025b15e9dd75104b0bfab4b..c87c230c5275fb77fd9cb201a113b6a45ba78f9e 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java +++ b/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java @@ -28,7 +28,6 @@ package sun.lwawt.macosx; import sun.lwawt.LWToolkit; import sun.lwawt.LWWindowPeer; import sun.lwawt.macosx.CocoaConstants; -import sun.lwawt.macosx.event.NSEvent; import sun.awt.EmbeddedFrame; diff --git a/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java b/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java index 4702cecc5accba25b706e820dea076121d97d8d9..cc31b532f7682fdcb57efbc7b761dd143f0126e3 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java +++ b/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java @@ -46,17 +46,16 @@ class CFileDialog implements FileDialogPeer { @Override public void run() { try { - boolean navigateApps = false; - int dialogMode = target.getMode(); - - navigateApps = true; + boolean navigateApps = !AccessController.doPrivileged( + new GetBooleanAction("apple.awt.use-file-dialog-packages")); + boolean chooseDirectories = AccessController.doPrivileged( + new GetBooleanAction("apple.awt.fileDialogForDirectories")); + 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, diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java index 3c7620f2be6321cbb622dc915f7929734d9c4b1b..d8d1555450c725cc0558a976c7d12fabb278299b 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java @@ -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 @@ package sun.lwawt.macosx; 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; diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java index ba05ab0b6c33beed90e9473741ba1760de26eff7..e81371b4751a65e477a57c939c7e8b47b04a7299 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java @@ -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 java.awt.geom.Rectangle2D; 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; diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index 50703d40aa029571add01bac629262aaceb6707c..a9de01d0d981f8015df15728c42169bcc050b1d2 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -613,9 +613,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // 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 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo 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 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo 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); } } diff --git a/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java b/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java index 4e398ae12dc574665c565e0e9564c2265c571472..dbc8d73c396d23d7f6cda5802013542cc6869839 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java @@ -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 javax.print.attribute.standard.PageRanges; 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 @@ public class CPrinterJob extends RasterPrinterJob { * returns true. * @see java.awt.GraphicsEnvironment#isHeadless */ + @Override public boolean printDialog() throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); @@ -131,6 +132,7 @@ public class CPrinterJob extends RasterPrinterJob { * @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 @@ public class CPrinterJob extends RasterPrinterJob { * @return clone of page, altered to describe a default * PageFormat. */ + @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 @@ public class CPrinterJob extends RasterPrinterJob { } } - + @Override public void print(PrintRequestAttributeSet attributes) throws PrinterException { // NOTE: Some of this code is copied from RasterPrinterJob. @@ -343,6 +347,7 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { /** * 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 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { * 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 @@ public class CPrinterJob extends RasterPrinterJob { /** * 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); diff --git a/src/macosx/classes/sun/lwawt/macosx/CPrinterJobDialog.java b/src/macosx/classes/sun/lwawt/macosx/CPrinterJobDialog.java index fb5d959d210d60c839e0f8f0cf08cdc9a075c493..55da56845212e669abb285a62c56cc558752366a 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJobDialog.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJobDialog.java @@ -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 @@ package sun.lwawt.macosx; 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 @@ public class CPrinterJobDialog extends CPrinterDialog { fAllowPrintToFile = allowPrintToFile; } + @Override protected native boolean showDialog(); } diff --git a/src/macosx/classes/sun/lwawt/macosx/CPrinterPageDialog.java b/src/macosx/classes/sun/lwawt/macosx/CPrinterPageDialog.java index b4bd34e90954257eae5925ea652ef192c19798a9..95b8e58985ada256bbf71b4141aaeb496d2cabdb 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPrinterPageDialog.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterPageDialog.java @@ -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 @@ package sun.lwawt.macosx; 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 @@ public class CPrinterPageDialog extends CPrinterDialog { fPainter = painter; } + @Override protected native boolean showDialog(); } diff --git a/src/macosx/classes/sun/lwawt/macosx/CPrinterSurfaceData.java b/src/macosx/classes/sun/lwawt/macosx/CPrinterSurfaceData.java index 082568cb780e541c3b5b1ea6cd4bb0a219a0f176..82f6ca98922a140ec6199e55a383d07ca507f23e 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPrinterSurfaceData.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterSurfaceData.java @@ -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 class CPrinterSurfaceData extends OSXSurfaceData{ // 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); } diff --git a/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java b/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java index dd1661564f545d733f7f612e1043477cacc3fd24..8e2a18fc121f589f0834e787ae530769d0842b74 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java +++ b/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java @@ -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 @@ package sun.lwawt.macosx; import sun.awt.AWTAccessor; import sun.awt.SunToolkit; -import sun.lwawt.macosx.event.NSEvent; import javax.swing.*; import java.awt.*; @@ -76,8 +75,9 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { 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 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { //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 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { dummyFrame.dispose(); + if (popup != null) { + popup.removeNotify(); + } + LWCToolkit.targetDisposedPeer(target, this); target = null; diff --git a/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java b/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java index 695bf4a96aafa235b93026402b3a0d1b90f30e97..800d76f478a5b87bac8b6015ee1632267274148f 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java +++ b/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java @@ -247,10 +247,7 @@ public final class CWarningWindow extends CPlatformWindow 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); } } } diff --git a/src/macosx/classes/sun/lwawt/macosx/CWrapper.java b/src/macosx/classes/sun/lwawt/macosx/CWrapper.java index a9c55237eeea72e68e36b438ee1da7579decc678..8c2e9c01f2d07ff1d29093bd61456f92cea2940e 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CWrapper.java +++ b/src/macosx/classes/sun/lwawt/macosx/CWrapper.java @@ -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); - - 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 setLevel(long window, int level); - 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 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 addChildWindow(long parent, long child, int ordered); - public static native void removeChildWindow(long parent, long child); + 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 setFrame(long window, int x, int y, int w, int h, boolean display); + static native void addChildWindow(long parent, long child, int ordered); + static native void removeChildWindow(long parent, long child); - 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 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 miniaturize(long window); - public static native void deminiaturize(long window); - public static native boolean isZoomed(long window); - public static native void zoom(long window); + 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 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); - - public static native void setToolTip(long view, String msg); - } + static native void setHidden(long view, boolean hidden); - public static final class NSObject { - public static native void release(long object); + static native void setToolTip(long view, String msg); } - public static final class NSColor { - public static native long clearColor(); + static final class NSColor { + static native long clearColor(); } } diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index a200f0cda78f02d94e9bc70aebdc09414894b3fb..bb4621715068aaa4054d9ec77018887b4cea06d4 100644 --- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -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.util.concurrent.Callable; 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 @@ public final class LWCToolkit extends LWToolkit { 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 @@ public final class LWCToolkit extends LWToolkit { 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() { - 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) () -> { + AWTAccessor.getSystemColorAccessor().updateSystemColors(); + return null; + }); + }); } public static LWCToolkit getLWCToolkit() { @@ -441,6 +429,11 @@ public final class LWCToolkit extends LWToolkit { return true; } + @Override + public DataTransferer getDataTransferer() { + return CDataTransferer.getInstanceImpl(); + } + @Override public boolean isAlwaysOnTopSupported() { return true; @@ -732,7 +725,7 @@ public final class LWCToolkit extends LWToolkit { /* * Returns true if the application (one of its windows) owns keyboard focus. */ - public native boolean isApplicationActive(); + native boolean isApplicationActive(); /************************ * Native methods section diff --git a/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java b/src/macosx/classes/sun/lwawt/macosx/NSEvent.java similarity index 84% rename from src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java rename to src/macosx/classes/sun/lwawt/macosx/NSEvent.java index 31e2498e6b93ea33e7ee8a412f5b4f97367447d7..ddb74d42b02493ff70f89e9accc9d2d45cbc7a60 100644 --- a/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java +++ b/src/macosx/classes/sun/lwawt/macosx/NSEvent.java @@ -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 @@ -23,16 +23,15 @@ * questions. */ -package sun.lwawt.macosx.event; +package sun.lwawt.macosx; -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 { +final class NSEvent { private int type; private int modifierFlags; @@ -50,14 +49,16 @@ public final class NSEvent { private short keyCode; private String charactersIgnoringModifiers; - public NSEvent(int type, int modifierFlags, short keyCode, 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; } - public NSEvent(int type, int modifierFlags, int clickCount, int buttonNumber, + // 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; @@ -72,51 +73,51 @@ public final class NSEvent { this.scrollDeltaX = scrollDeltaX; } - public int getType() { + int getType() { return type; } - public int getModifierFlags() { + int getModifierFlags() { return modifierFlags; } - public int getClickCount() { + int getClickCount() { return clickCount; } - public int getButtonNumber() { + int getButtonNumber() { return buttonNumber; } - public int getX() { + int getX() { return x; } - public int getY() { + int getY() { return y; } - public double getScrollDeltaY() { + double getScrollDeltaY() { return scrollDeltaY; } - public double getScrollDeltaX() { + double getScrollDeltaX() { return scrollDeltaX; } - public int getAbsX() { + int getAbsX() { return absX; } - public int getAbsY() { + int getAbsY() { return absY; } - public short getKeyCode() { + short getKeyCode() { return keyCode; } - public String getCharactersIgnoringModifiers() { + String getCharactersIgnoringModifiers() { return charactersIgnoringModifiers; } @@ -131,7 +132,7 @@ public final class NSEvent { /* * Converts an NSEvent button number to a MouseEvent constant. */ - public static int nsToJavaButton(int buttonNumber) { + static int nsToJavaButton(int buttonNumber) { int jbuttonNumber = buttonNumber + 1; switch (buttonNumber) { case CocoaConstants.kCGMouseButtonLeft: @@ -150,7 +151,7 @@ public final class NSEvent { /* * Converts NPCocoaEvent types to AWT event types. */ - public static int npToJavaEventType(int npEventType) { + static int npToJavaEventType(int npEventType) { int jeventType = 0; switch (npEventType) { case CocoaConstants.NPCocoaEventMouseDown: @@ -184,7 +185,7 @@ public final class NSEvent { /* * Converts NSEvent types to AWT event types. */ - public static int nsToJavaEventType(int nsEventType) { + static int nsToJavaEventType(int nsEventType) { int jeventType = 0; switch (nsEventType) { case CocoaConstants.NSLeftMouseDown: @@ -227,31 +228,31 @@ public final class NSEvent { /* * Converts NSEvent mouse modifiers to AWT mouse modifiers. */ - public static native int nsToJavaMouseModifiers(int buttonNumber, + static native int nsToJavaMouseModifiers(int buttonNumber, int modifierFlags); /* * Converts NSEvent key modifiers to AWT key modifiers. */ - public static native int nsToJavaKeyModifiers(int modifierFlags); + static native int nsToJavaKeyModifiers(int modifierFlags); /* * Converts NSEvent key info to AWT key info. */ - public static native boolean nsToJavaKeyInfo(int[] in, int[] out); + 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); + 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); + static native char nsToJavaChar(char nsChar, int modifierFlags); - public static boolean isPopupTrigger(int jmodifiers) { + 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); diff --git a/src/macosx/lib/flavormap.properties b/src/macosx/lib/flavormap.properties index b00f2c2c3a644ef069e042dc3a4ac5ecb4d3578d..8f17d95fa2071c5f56ee3caa596a41b72e4f0f11 100644 --- a/src/macosx/lib/flavormap.properties +++ b/src/macosx/lib/flavormap.properties @@ -79,3 +79,5 @@ JFIF=image/x-java-image;class=java.awt.Image 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 diff --git a/src/macosx/native/sun/awt/AWTEvent.m b/src/macosx/native/sun/awt/AWTEvent.m index c6bda77d1725740b32a88eafd35ae705ae8796c5..3a7aab4d94fad2ca049ca68673a6c481f448a6dc 100644 --- a/src/macosx/native/sun/awt/AWTEvent.m +++ b/src/macosx/native/sun/awt/AWTEvent.m @@ -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 @@ Java_java_awt_AWTEvent_nativeSetSource } /* - * 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 @@ JNF_COCOA_EXIT(env); } /* - * 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 @@ JNF_COCOA_EXIT(env); } /* - * 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 @@ JNF_COCOA_EXIT(env); } /* - * 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 @@ JNF_COCOA_EXIT(env); } /* - * 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; diff --git a/src/macosx/native/sun/awt/AWTView.h b/src/macosx/native/sun/awt/AWTView.h index 58e4f6e0705ce66b4d5cdbeb4dde9f488246fab4..592235bf7be845535cb5ba5da165b17ba68b9015 100644 --- a/src/macosx/native/sun/awt/AWTView.h +++ b/src/macosx/native/sun/awt/AWTView.h @@ -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 { +@interface AWTView : NSView { @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; diff --git a/src/macosx/native/sun/awt/AWTView.m b/src/macosx/native/sun/awt/AWTView.m index 0356ebc790c81a7d555abf339ed373d2b3509e7c..7e64695471ea8c6007e531194ecaf97af0f2c727 100644 --- a/src/macosx/native/sun/awt/AWTView.m +++ b/src/macosx/native/sun/awt/AWTView.m @@ -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 @@ AWT_ASSERT_APPKIT_THREAD; 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 @@ AWT_ASSERT_APPKIT_THREAD; } 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 @@ AWT_ASSERT_APPKIT_THREAD; 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 @@ AWT_ASSERT_APPKIT_THREAD; 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) { diff --git a/src/macosx/native/sun/awt/CDragSource.h b/src/macosx/native/sun/awt/CDragSource.h index 96e0e6831b10fb5fa4b2c9bf971d8c81ed8f1889..d18816abd410cc297596d277ddc951f424a5a9f7 100644 --- a/src/macosx/native/sun/awt/CDragSource.h +++ b/src/macosx/native/sun/awt/CDragSource.h @@ -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 #include +@class CDragSource; + +@protocol CDragSourceHolder +- (void) setDragSource:(CDragSource *)source; +@end + @interface CDragSource : NSObject { @private - NSView* fView; + NSView* 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 diff --git a/src/macosx/native/sun/awt/CDragSource.m b/src/macosx/native/sun/awt/CDragSource.m index 7459a805164a1651e1c55679dcd1d0a1b55dc1f0..dc1507746bea1f5b72eea1871537e52ef67e2923 100644 --- a/src/macosx/native/sun/awt/CDragSource.m +++ b/src/macosx/native/sun/awt/CDragSource.m @@ -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,14 +75,17 @@ JNF_CLASS_CACHE(CImageClass, "sun/lwawt/macosx/CImage"); static NSDragOperation sDragOperation; static NSPoint sDraggingLocation; -static CDragSource* sCurrentDragSource; static BOOL sNeedsEnter; -@implementation CDragSource +@interface CDragSource () +// Updates from the destination to the source +- (void) postDragEnter; +- (void) postDragExit; +// Utility +- (NSPoint) mapNSScreenPointToJavaWithOffset:(NSPoint) point; +@end -+ (CDragSource *) currentDragSource { - return sCurrentDragSource; -} +@implementation CDragSource - (id) init:(jobject)jDragSourceContextPeer component:(jobject)jComponent @@ -515,8 +518,6 @@ static BOOL sNeedsEnter; fDragKeyModifiers = [DnDUtilities extractJavaExtKeyModifiersFromJavaExtModifiers:fModifiers]; fDragMouseModifiers = [DnDUtilities extractJavaExtMouseModifiersFromJavaExtModifiers:fModifiers]; - // Set the current DragSource - sCurrentDragSource = self; sNeedsEnter = YES; @try { @@ -566,8 +567,6 @@ static BOOL sNeedsEnter; JNF_MEMBER_CACHE(resetHoveringMethod, CDragSourceContextPeerClass, "resetHovering", "()V"); JNFCallVoidMethod(env, fDragSourceContextPeer, resetHoveringMethod); // Hust reset static variable } @finally { - // Clear the current DragSource - sCurrentDragSource = nil; sNeedsEnter = NO; } diff --git a/src/macosx/native/sun/awt/CDropTarget.h b/src/macosx/native/sun/awt/CDropTarget.h index e8f801d7009a00465d9c3afeb3af61ec657f1260..b6cd156562b2806ec0e897ccd0b7509ad5fb593c 100644 --- a/src/macosx/native/sun/awt/CDropTarget.h +++ b/src/macosx/native/sun/awt/CDropTarget.h @@ -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* fView; jobject fComponent; jobject fDropTarget; jobject fDropTargetContextPeer; diff --git a/src/macosx/native/sun/awt/CTrayIcon.m b/src/macosx/native/sun/awt/CTrayIcon.m index 5a494fe73322b470e8f347c50dd789adb4fbdb98..79ae024f76fe3ad74970816c15ac617404ebfb23 100644 --- a/src/macosx/native/sun/awt/CTrayIcon.m +++ b/src/macosx/native/sun/awt/CTrayIcon.m @@ -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 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) { 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 NSSize ScaledImageSizeForStatusBar(NSSize imageSize) { } 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); } diff --git a/src/macosx/native/sun/awt/CWrapper.m b/src/macosx/native/sun/awt/CWrapper.m index e5847bea9609f64358fd8d3b0e98821092b855c8..247358f0df98d4dba0796721811df49b0ca2983c 100644 --- a/src/macosx/native/sun/awt/CWrapper.m +++ b/src/macosx/native/sun/awt/CWrapper.m @@ -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,37 +23,10 @@ * questions. */ -#import "CWrapper.h" - #import - -#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 @@ -249,6 +222,7 @@ static void initLevels() 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 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_removeChildWindow { 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 @@ -318,26 +292,6 @@ JNF_COCOA_ENTER(env); JNF_COCOA_EXIT(env); } -/* - * 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 @@ -349,7 +303,7 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setAlphaValue { 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 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setOpaque { 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 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setBackgroundColor { 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 @@ JNF_COCOA_EXIT(env); } /* + * Class: sun_lwawt_macosx_CWrapper$NSWindow * Method: miniaturize * Signature: (J)V */ @@ -558,33 +513,6 @@ JNF_COCOA_ENTER(env); JNF_COCOA_EXIT(env); } -/* - * 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 diff --git a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java index 613091a1d73e253fad1f1924c40106c97ff470db..0e4a829415e1f38b77d936769e00ee2d1e27fc0c 100644 --- a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java +++ b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java @@ -287,7 +287,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { 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 diff --git a/src/share/classes/java/awt/SystemColor.java b/src/share/classes/java/awt/SystemColor.java index ed5a26b4947260b3a267b5ff087ffd934645ce47..65b01b2c05b6ea49e13059c4f9a02d535798eba8 100644 --- a/src/share/classes/java/awt/SystemColor.java +++ b/src/share/classes/java/awt/SystemColor.java @@ -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 @@ public final class SystemColor extends Color implements java.io.Serializable { }; static { - updateSystemColors(); + AWTAccessor.setSystemColorAccessor(SystemColor::updateSystemColors); + updateSystemColors(); } /** diff --git a/src/share/classes/java/awt/datatransfer/DataFlavor.java b/src/share/classes/java/awt/datatransfer/DataFlavor.java index fe16248898d96c568215503abe98d3f9d159f511..9ca61a34af1841274514b26c14f4712c20b444f9 100644 --- a/src/share/classes/java/awt/datatransfer/DataFlavor.java +++ b/src/share/classes/java/awt/datatransfer/DataFlavor.java @@ -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 @@ public class DataFlavor implements Externalizable, Cloneable { if (DataTransferer.isFlavorCharsetTextType(this) && (isRepresentationClassInputStream() || isRepresentationClassByteBuffer() || - DataTransferer.byteArrayClass.equals(representationClass))) + byte[].class.equals(representationClass))) { params += ";charset=" + DataTransferer.getTextCharset(this); } @@ -1015,7 +1015,7 @@ public class DataFlavor implements Externalizable, Cloneable { !(isRepresentationClassReader() || String.class.equals(representationClass) || isRepresentationClassCharBuffer() || - DataTransferer.charArrayClass.equals(representationClass))) + char[].class.equals(representationClass))) { String thisCharset = DataTransferer.canonicalName(getParameter("charset")); @@ -1100,8 +1100,7 @@ public class DataFlavor implements Externalizable, Cloneable { !(isRepresentationClassReader() || String.class.equals(representationClass) || isRepresentationClassCharBuffer() || - DataTransferer.charArrayClass.equals - (representationClass))) + char[].class.equals(representationClass))) { String charset = DataTransferer.canonicalName(getParameter("charset")); diff --git a/src/share/classes/java/awt/dnd/DragGestureEvent.java b/src/share/classes/java/awt/dnd/DragGestureEvent.java index f4960922e66e922789acc4814f4b40f36de5d3b9..3c9eadd6e56e023e693593c14b9d1b0479d28e3c 100644 --- a/src/share/classes/java/awt/dnd/DragGestureEvent.java +++ b/src/share/classes/java/awt/dnd/DragGestureEvent.java @@ -36,6 +36,7 @@ import java.awt.event.InputEvent; import java.awt.datatransfer.Transferable; +import java.io.InvalidObjectException; import java.util.EventObject; import java.util.Collections; @@ -329,22 +330,50 @@ public class DragGestureEvent extends EventObject { { 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; } /* diff --git a/src/share/classes/java/awt/dnd/DragGestureRecognizer.java b/src/share/classes/java/awt/dnd/DragGestureRecognizer.java index 2d0108a33b9c4b1b840ded85a411e370f451ef4a..18f2e2a813d8cd59ff5122a88ff02ecfa2b7da17 100644 --- a/src/share/classes/java/awt/dnd/DragGestureRecognizer.java +++ b/src/share/classes/java/awt/dnd/DragGestureRecognizer.java @@ -29,6 +29,8 @@ import java.awt.event.InputEvent; 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 @@ public abstract class DragGestureRecognizer implements Serializable { * * @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)f.get("events", new ArrayList<>(1)); dragGestureListener = (DragGestureListener)s.readObject(); } diff --git a/src/share/classes/java/awt/dnd/DragSourceContext.java b/src/share/classes/java/awt/dnd/DragSourceContext.java index 5d7715d469911815b95250730a6d3ca0f19b636f..cbc4c83b148f6a15d379b120584543d766348e64 100644 --- a/src/share/classes/java/awt/dnd/DragSourceContext.java +++ b/src/share/classes/java/awt/dnd/DragSourceContext.java @@ -37,6 +37,7 @@ import java.awt.datatransfer.UnsupportedFlavorException; 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 @@ public class DragSourceContext 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 @@ public class DragSourceContext * * @serial */ - private final int sourceActions; + private int sourceActions; } diff --git a/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java b/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java index 10c3ed14663ef22dbd2209b9291ba59aaccdb786..3f91060ccc89a11c7e09f47128ad17d6c728693b 100644 --- a/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java +++ b/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java @@ -200,6 +200,13 @@ import static sun.invoke.util.Wrapper.isWrapperType; 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 @@ import static sun.invoke.util.Wrapper.isWrapperType; 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 @@ import static sun.invoke.util.Wrapper.isWrapperType; 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 @@ import static sun.invoke.util.Wrapper.isWrapperType; 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 diff --git a/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java b/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java index 5d8e1bf82f5b6ef38c7642698976d2bbc7a0d290..aecbeb6d084566a196631e9551ec317f87a71f4c 100644 --- a/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java +++ b/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java @@ -212,7 +212,7 @@ class TypeConvertingMethodAdapter extends MethodVisitor { * @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) { diff --git a/src/share/classes/sun/awt/AWTAccessor.java b/src/share/classes/sun/awt/AWTAccessor.java index a00a23453feacc702c1abdaa19dddcb3eb57fca7..300134e4780482e4cd25f314e3dac554e667e25d 100644 --- a/src/share/classes/sun/awt/AWTAccessor.java +++ b/src/share/classes/sun/awt/AWTAccessor.java @@ -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 @@ -728,6 +728,13 @@ public final class AWTAccessor { void dispose(InvocationEvent event); } + /* + * 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 @@ public final class AWTAccessor { 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 final class AWTAccessor { 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; + } } diff --git a/src/share/classes/sun/awt/HToolkit.java b/src/share/classes/sun/awt/HToolkit.java index ea182753c78f4424814a894969315a45ee9b8ff2..fdce8ccdcfc0606544d62f8dc9d62ae6d3bab61b 100644 --- a/src/share/classes/sun/awt/HToolkit.java +++ b/src/share/classes/sun/awt/HToolkit.java @@ -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 @@ public class HToolkit extends SunToolkit return false; } + @Override + public DataTransferer getDataTransferer() { + return null; + } + public GlobalCursorManager getGlobalCursorManager() throws HeadlessException { throw new HeadlessException(); diff --git a/src/share/classes/sun/awt/SunToolkit.java b/src/share/classes/sun/awt/SunToolkit.java index e290e1a2d2c71dc40ce937a710b59e1d41ec51ce..e416f687a627b07506fa37d6b66e4a584a04918b 100644 --- a/src/share/classes/sun/awt/SunToolkit.java +++ b/src/share/classes/sun/awt/SunToolkit.java @@ -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.Condition; 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 class SunToolkit extends Toolkit public abstract boolean isTraySupported(); + public abstract DataTransferer getDataTransferer(); + @SuppressWarnings("deprecation") public abstract FontPeer getFontPeer(String name, int style); @@ -1191,19 +1194,6 @@ public abstract class SunToolkit extends Toolkit 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; /** diff --git a/src/share/classes/sun/awt/datatransfer/DataTransferer.java b/src/share/classes/sun/awt/datatransfer/DataTransferer.java index 1ebcc1a56a842a9e68d868c72f3f16c263c7e337..2c4b75fcaac08d216794d67da234fecb35e9a938 100644 --- a/src/share/classes/sun/awt/datatransfer/DataTransferer.java +++ b/src/share/classes/sun/awt/datatransfer/DataTransferer.java @@ -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.Image; import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.FlavorMap; @@ -137,16 +137,6 @@ import java.io.FilePermission; */ 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 DataFlavor representing plain text with Unicode * encoding, where: @@ -241,15 +231,6 @@ public abstract class DataTransferer { 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 @@ public abstract class DataTransferer { * 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 action = new PrivilegedAction() - { - 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 @@ public abstract class DataTransferer { 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 @@ public abstract class DataTransferer { return (flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || - DataTransferer.byteArrayClass. - equals(flavor.getRepresentationClass())); + byte[].class.equals(flavor.getRepresentationClass())); } /** @@ -1243,7 +1168,7 @@ search: 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 @@ search: // 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 @@ search: // 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 @@ search: // 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 @@ search: 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 @@ search: 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 @@ search: 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 diff --git a/src/solaris/classes/sun/awt/X11/XDataTransferer.java b/src/solaris/classes/sun/awt/X11/XDataTransferer.java index 401931f4af981b759f5307ca337e4af0a49a1a69..fe8920d8c381ceef4c6a572395a3f7f3b0d3cade 100644 --- a/src/solaris/classes/sun/awt/X11/XDataTransferer.java +++ b/src/solaris/classes/sun/awt/X11/XDataTransferer.java @@ -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 @@ public class XDataTransferer extends DataTransferer { 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 @@ public class XDataTransferer extends DataTransferer { if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || - byteArrayClass.equals(df.getRepresentationClass()))) { + byte[].class.equals(df.getRepresentationClass()))) { natives.add(mimeType); } diff --git a/src/solaris/classes/sun/awt/X11/XToolkit.java b/src/solaris/classes/sun/awt/X11/XToolkit.java index 303842300342cfbe80c41971960d0ee28e595e9d..1ae0a0967b67b2db86a5f53b93121d3f7a2df946 100644 --- a/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -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 java.util.*; 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 @@ public final class XToolkit extends UNIXToolkit implements Runnable { return awtAppClassName; } - static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.X11.XDataTransferer"; - public XToolkit() { super(); if (PerformanceLogger.loggingEnabled()) { @@ -323,7 +322,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable { init(); XWM.init(); - SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME); PrivilegedAction action = new PrivilegedAction() { public Thread run() { @@ -1125,6 +1123,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable { return false; } + @Override + public DataTransferer getDataTransferer() { + return XDataTransferer.getInstanceImpl(); + } + /** * Returns the supported cursor size */ diff --git a/src/windows/classes/sun/awt/windows/WDataTransferer.java b/src/windows/classes/sun/awt/windows/WDataTransferer.java index a5685ade6e456d44a3de6ffea94d2fdc861defcf..9c84ba728c4567dcf4544b46bc718077322b0510 100644 --- a/src/windows/classes/sun/awt/windows/WDataTransferer.java +++ b/src/windows/classes/sun/awt/windows/WDataTransferer.java @@ -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 @@ public class WDataTransferer extends DataTransferer { 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; } diff --git a/src/windows/classes/sun/awt/windows/WToolkit.java b/src/windows/classes/sun/awt/windows/WToolkit.java index fabc2f825bcdaf5364d91642c29a8b5176d48506..04a550d8982d3c29cb0c2a40604416e977c2428c 100644 --- a/src/windows/classes/sun/awt/windows/WToolkit.java +++ b/src/windows/classes/sun/awt/windows/WToolkit.java @@ -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.LightweightFrame; 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 class WToolkit extends SunToolkit implements Runnable { */ 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 @@ public class WToolkit extends SunToolkit implements Runnable { // 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 @@ public class WToolkit extends SunToolkit implements Runnable { return true; } + @Override + public DataTransferer getDataTransferer() { + return WDataTransferer.getInstanceImpl(); + } + public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() throws HeadlessException { diff --git a/src/windows/native/sun/windows/ShellFolder2.cpp b/src/windows/native/sun/windows/ShellFolder2.cpp index 63bebf0a63feef23501727de30aa6798b488a25c..cdc60d9ee9ca70797a557f0b9f73385d7b33822e 100644 --- a/src/windows/native/sun/windows/ShellFolder2.cpp +++ b/src/windows/native/sun/windows/ShellFolder2.cpp @@ -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 @@ JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolder2_initIDs 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 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_parseDisplayName0 // Get relative PIDL for name LPITEMIDLIST pIDL; int nLength = env->GetStringLength(jname); - jchar* wszPath = new jchar[nLength + 1]; const jchar* strPath = env->GetStringChars(jname, NULL); + JNU_CHECK_EXCEPTION_RETURN(env, 0); + jchar* wszPath = new jchar[nLength + 1]; wcsncpy(reinterpret_cast(wszPath), reinterpret_cast(strPath), nLength); wszPath[nLength] = 0; HRESULT res = pIShellFolder->ParseDisplayName(NULL, NULL, @@ -811,6 +817,7 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIcon 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 @@ JNIEXPORT jintArray JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconBits 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 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconResource 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 @@ static jobject CreateColumnInfo(JNIEnv *pEnv, 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 @@ JNIEXPORT jobjectArray JNICALL 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 @@ JNIEXPORT jobjectArray JNICALL jobject column = CreateColumnInfo(env, &columnClass, &columnConstructor, &sd, 1); + if(!column){ + pIShellDetails->Release(); + return NULL; + } env->SetObjectArrayElement(columns, (jsize) colNum++, column); } } diff --git a/src/windows/native/sun/windows/awt_Object.cpp b/src/windows/native/sun/windows/awt_Object.cpp index b3552807ba6fe89d3421a616635ca08966b89846..13507b9846ce4016e8f02a2be6fce0d301eea670 100644 --- a/src/windows/native/sun/windows/awt_Object.cpp +++ b/src/windows/native/sun/windows/awt_Object.cpp @@ -232,22 +232,31 @@ Java_sun_awt_windows_WObjectPeer_initIDs(JNIEnv *env, jclass cls) { 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; } diff --git a/src/windows/native/sun/windows/awt_PrintDialog.cpp b/src/windows/native/sun/windows/awt_PrintDialog.cpp index 614f10902dd306b8945fd69e2e61b3bcacc4d6f9..d2deb0e82f196cb1eb0e56753a2607de09daf3f4 100644 --- a/src/windows/native/sun/windows/awt_PrintDialog.cpp +++ b/src/windows/native/sun/windows/awt_PrintDialog.cpp @@ -183,11 +183,13 @@ Java_sun_awt_windows_WPrintDialogPeer_initIDs(JNIEnv *env, jclass cls) 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; } diff --git a/test/java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java b/test/java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c5f78e21970ec2e319d805a78a641426dfc8446e --- /dev/null +++ b/test/java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java @@ -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); + } + + +} diff --git a/test/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.html b/test/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.html new file mode 100644 index 0000000000000000000000000000000000000000..3572db0e4d8e875018b9a0a61ad362b68806865a --- /dev/null +++ b/test/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.html @@ -0,0 +1,45 @@ + + + + + + FileDialogForPackages + + + +

FileDialogForPackages
Bug ID: 8026869

+ +

See the dialog box (usually in upper left corner) for instructions

+ + + + diff --git a/test/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.java b/test/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.java new file mode 100644 index 0000000000000000000000000000000000000000..cc851f85b6e2f5afa252cd5431cb331525de409b --- /dev/null +++ b/test/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.java @@ -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"); + } + } + } +} diff --git a/test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java b/test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c032d7ac072ed5a22a8746c37092bed690f3e39a --- /dev/null +++ b/test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java @@ -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; + } + } +} + diff --git a/test/java/awt/TrayIcon/AddPopupAfterShowTest/AddPopupAfterShowTest.html b/test/java/awt/TrayIcon/AddPopupAfterShowTest/AddPopupAfterShowTest.html new file mode 100644 index 0000000000000000000000000000000000000000..a7851c71a8c1cd5360e86e36669a71f4b9b8cc52 --- /dev/null +++ b/test/java/awt/TrayIcon/AddPopupAfterShowTest/AddPopupAfterShowTest.html @@ -0,0 +1,45 @@ + + + + + + AddPopupAfterShowTest + + + +

AddPopupAfterShowTest
Bug ID: 8007220

+ +

See the dialog box (usually in upper left corner) for instructions

+ + + + diff --git a/test/java/awt/TrayIcon/AddPopupAfterShowTest/AddPopupAfterShowTest.java b/test/java/awt/TrayIcon/AddPopupAfterShowTest/AddPopupAfterShowTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4335b6c5927f21c00249479a31f347eddda741ad --- /dev/null +++ b/test/java/awt/TrayIcon/AddPopupAfterShowTest/AddPopupAfterShowTest.java @@ -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; + } +} diff --git a/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java b/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4d5dd7295f6c1f5353b6ff3252482bb2c1650014 --- /dev/null +++ b/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java @@ -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> iconWeakReference = new AtomicReference<>(); + static final AtomicReference> 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 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) { } + } +} diff --git a/test/java/awt/Window/Grab/GrabTest.java b/test/java/awt/Window/Grab/GrabTest.java index 8cc0538b333ab191ce2804e619a4ea07a1e43781..e632af18dbf8757b078ca7e618ab876c70368c17 100644 --- a/test/java/awt/Window/Grab/GrabTest.java +++ b/test/java/awt/Window/Grab/GrabTest.java @@ -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 @@ import test.java.awt.regtesthelpers.Util; 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 @@ public class GrabTest { 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 @@ public class GrabTest { 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."); diff --git a/test/java/awt/dnd/BadSerializaionTest/BadSerializationTest.java b/test/java/awt/dnd/BadSerializaionTest/BadSerializationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5198b529f7a0d1f98c1e4e89518a4490535d3726 --- /dev/null +++ b/test/java/awt/dnd/BadSerializaionTest/BadSerializationTest.java @@ -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"); + } + } +} diff --git a/test/java/awt/dnd/BadSerializaionTest/badAction b/test/java/awt/dnd/BadSerializaionTest/badAction new file mode 100644 index 0000000000000000000000000000000000000000..d8b58ee48eb957adcfc1eeba826815e9a890be27 Binary files /dev/null and b/test/java/awt/dnd/BadSerializaionTest/badAction differ diff --git a/test/java/awt/dnd/BadSerializaionTest/good b/test/java/awt/dnd/BadSerializaionTest/good new file mode 100644 index 0000000000000000000000000000000000000000..3580da63bb87405729e64dd2e4967eca31f68126 Binary files /dev/null and b/test/java/awt/dnd/BadSerializaionTest/good differ diff --git a/test/java/awt/dnd/BadSerializaionTest/noEvents b/test/java/awt/dnd/BadSerializaionTest/noEvents new file mode 100644 index 0000000000000000000000000000000000000000..eee6a49949c2f004ba7562890ec9601e8005a725 Binary files /dev/null and b/test/java/awt/dnd/BadSerializaionTest/noEvents differ diff --git a/test/java/awt/dnd/BadSerializaionTest/nullComponent b/test/java/awt/dnd/BadSerializaionTest/nullComponent new file mode 100644 index 0000000000000000000000000000000000000000..3166bcbcaf13ab9951b779a7b3d14a602b1a030f Binary files /dev/null and b/test/java/awt/dnd/BadSerializaionTest/nullComponent differ diff --git a/test/java/awt/dnd/BadSerializaionTest/nullDragSource b/test/java/awt/dnd/BadSerializaionTest/nullDragSource new file mode 100644 index 0000000000000000000000000000000000000000..62a9bb69bc5775d6d65521a78e6c6629e5179a58 Binary files /dev/null and b/test/java/awt/dnd/BadSerializaionTest/nullDragSource differ diff --git a/test/java/awt/dnd/BadSerializaionTest/nullOrigin b/test/java/awt/dnd/BadSerializaionTest/nullOrigin new file mode 100644 index 0000000000000000000000000000000000000000..e5daa2a136381cf83c31fd08d9ae24064e688ee0 Binary files /dev/null and b/test/java/awt/dnd/BadSerializaionTest/nullOrigin differ diff --git a/test/java/awt/dnd/Button2DragTest/Button2DragTest.java b/test/java/awt/dnd/Button2DragTest/Button2DragTest.java index 11a7bf9eff928db571eefb4a0cc76bb47e664bed..33bb505870627977d339ff62daa751a76b0a742c 100644 --- a/test/java/awt/dnd/Button2DragTest/Button2DragTest.java +++ b/test/java/awt/dnd/Button2DragTest/Button2DragTest.java @@ -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 @@ public class Button2DragTest extends Applet { Util.drag(robot, startPoint, endPoint, InputEvent.BUTTON2_MASK); Util.waitForIdle(robot); + robot.delay(500); if (dropSuccess) { System.err.println("test passed"); diff --git a/test/java/awt/dnd/URLDragTest/URLDragTest.html b/test/java/awt/dnd/URLDragTest/URLDragTest.html new file mode 100644 index 0000000000000000000000000000000000000000..0ff497ae233c3a9993d8e1241560648aaf82febf --- /dev/null +++ b/test/java/awt/dnd/URLDragTest/URLDragTest.html @@ -0,0 +1,45 @@ + + + + + + DnD of URL across JVM + + + +

URLDragTest
Bug ID: 8031964

+ +

This is an AUTOMATIC test, simply wait for completion

+ + + + diff --git a/test/java/awt/dnd/URLDragTest/URLDragTest.java b/test/java/awt/dnd/URLDragTest/URLDragTest.java new file mode 100644 index 0000000000000000000000000000000000000000..98933327c1a60b810a18fd7f454edf7234cdfce0 --- /dev/null +++ b/test/java/awt/dnd/URLDragTest/URLDragTest.java @@ -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); + } +} diff --git a/test/java/lang/invoke/lambda/LambdaReceiver.java b/test/java/lang/invoke/lambda/LambdaReceiver.java new file mode 100644 index 0000000000000000000000000000000000000000..8e24379456ea56e242dbc298973f58e282f949c3 --- /dev/null +++ b/test/java/lang/invoke/lambda/LambdaReceiver.java @@ -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 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"); + } +} diff --git a/test/java/lang/invoke/lambda/LambdaReceiverBridge.java b/test/java/lang/invoke/lambda/LambdaReceiverBridge.java new file mode 100644 index 0000000000000000000000000000000000000000..b1f3b859c98a68a55db7d2c6842da686f30f36d0 --- /dev/null +++ b/test/java/lang/invoke/lambda/LambdaReceiverBridge.java @@ -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 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"); + } +} diff --git a/src/macosx/native/sun/awt/CWrapper.h b/test/java/lang/invoke/lambda/LambdaReceiver_anotherpkg/LambdaReceiver_A.java similarity index 76% rename from src/macosx/native/sun/awt/CWrapper.h rename to test/java/lang/invoke/lambda/LambdaReceiver_anotherpkg/LambdaReceiver_A.java index 416bac7ce6ba6a2ca58f5b23cc27d9b40b94d6ad..e4d1c98336b987d2ae6abe6100f8cb3883143a2d 100644 --- a/src/macosx/native/sun/awt/CWrapper.h +++ b/test/java/lang/invoke/lambda/LambdaReceiver_anotherpkg/LambdaReceiver_A.java @@ -1,12 +1,10 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -22,3 +20,9 @@ * 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; } +} diff --git a/test/java/lang/invoke/lambda/LambdaReturn.java b/test/java/lang/invoke/lambda/LambdaReturn.java new file mode 100644 index 0000000000000000000000000000000000000000..27a02f058383ddf74c5da5fb0a208c0e40f24b7a --- /dev/null +++ b/test/java/lang/invoke/lambda/LambdaReturn.java @@ -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 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 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()); + } + } +} diff --git a/test/java/lang/invoke/lambda/MetafactoryArityTest.java b/test/java/lang/invoke/lambda/MetafactoryArityTest.java new file mode 100644 index 0000000000000000000000000000000000000000..568abbacca11a628e4ba500f75583f7b62616773 --- /dev/null +++ b/test/java/lang/invoke/lambda/MetafactoryArityTest.java @@ -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)); + } + } + } + +} diff --git a/test/java/lang/invoke/lambda/MetafactoryParameterCastTest.java b/test/java/lang/invoke/lambda/MetafactoryParameterCastTest.java new file mode 100644 index 0000000000000000000000000000000000000000..70a65e57917af4361bd6b937c0b34011f973540a --- /dev/null +++ b/test/java/lang/invoke/lambda/MetafactoryParameterCastTest.java @@ -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); + } + } + +} diff --git a/test/java/lang/invoke/lambda/MetafactorySamReturnTest.java b/test/java/lang/invoke/lambda/MetafactorySamReturnTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4caf2624df90c97fd4cc138303408b44fe089ad0 --- /dev/null +++ b/test/java/lang/invoke/lambda/MetafactorySamReturnTest.java @@ -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)); + } + } + } + +} diff --git a/test/javax/swing/JPopupMenu/7154841/bug7154841.java b/test/javax/swing/JPopupMenu/7154841/bug7154841.java new file mode 100644 index 0000000000000000000000000000000000000000..c1e6ac86e3a10f00f31b646a35671f288cee6f6c --- /dev/null +++ b/test/javax/swing/JPopupMenu/7154841/bug7154841.java @@ -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 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) { } + } +} diff --git a/test/javax/xml/jaxp/parsers/8027359/XML11EntityScannerTest.java b/test/javax/xml/jaxp/parsers/8027359/XML11EntityScannerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a430b5f51a995b1106293383b3eabd2ea1823bf2 --- /dev/null +++ b/test/javax/xml/jaxp/parsers/8027359/XML11EntityScannerTest.java @@ -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 = + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + + /** + * 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()); + } + } + +} diff --git a/test/javax/xml/jaxp/parsers/8032909/XSLT.java b/test/javax/xml/jaxp/parsers/8032909/XSLT.java new file mode 100644 index 0000000000000000000000000000000000000000..d133920f40a40afd6480ce9ef418eaad2477d023 --- /dev/null +++ b/test/javax/xml/jaxp/parsers/8032909/XSLT.java @@ -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); + } +} diff --git a/test/javax/xml/jaxp/parsers/8032909/a_utf16.xml b/test/javax/xml/jaxp/parsers/8032909/a_utf16.xml new file mode 100644 index 0000000000000000000000000000000000000000..fae65cc655c6b96f810da8b6316c0227738f5da5 Binary files /dev/null and b/test/javax/xml/jaxp/parsers/8032909/a_utf16.xml differ diff --git a/test/javax/xml/jaxp/parsers/8032909/a_utf16.xsl b/test/javax/xml/jaxp/parsers/8032909/a_utf16.xsl new file mode 100644 index 0000000000000000000000000000000000000000..4d886036cd138295d2a5cbe4519daf2cd608b884 Binary files /dev/null and b/test/javax/xml/jaxp/parsers/8032909/a_utf16.xsl differ diff --git a/test/javax/xml/jaxp/parsers/8032909/a_utf8.xml b/test/javax/xml/jaxp/parsers/8032909/a_utf8.xml new file mode 100644 index 0000000000000000000000000000000000000000..a3b327f1232bb20a75931e17273a58513b5c4342 --- /dev/null +++ b/test/javax/xml/jaxp/parsers/8032909/a_utf8.xml @@ -0,0 +1,5 @@ + + +UTF-8_Element + + diff --git a/test/javax/xml/jaxp/parsers/8032909/a_utf8.xsl b/test/javax/xml/jaxp/parsers/8032909/a_utf8.xsl new file mode 100644 index 0000000000000000000000000000000000000000..b7e222be1926852dd2b98302433ce09a95997053 --- /dev/null +++ b/test/javax/xml/jaxp/parsers/8032909/a_utf8.xsl @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/test/javax/xml/jaxp/parsers/8032909/a_windows1252.xml b/test/javax/xml/jaxp/parsers/8032909/a_windows1252.xml new file mode 100644 index 0000000000000000000000000000000000000000..6d5726eb442a8f69461aae5cc240eb7cf76ef2fb --- /dev/null +++ b/test/javax/xml/jaxp/parsers/8032909/a_windows1252.xml @@ -0,0 +1,5 @@ + + +Windows-1252_Element + + diff --git a/test/javax/xml/jaxp/parsers/8032909/a_windows1252.xsl b/test/javax/xml/jaxp/parsers/8032909/a_windows1252.xsl new file mode 100644 index 0000000000000000000000000000000000000000..ff50bf8f8a0f4975189c2304120a9aad110da589 --- /dev/null +++ b/test/javax/xml/jaxp/parsers/8032909/a_windows1252.xsl @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/test/sun/util/calendar/zi/Zoneinfo.java b/test/sun/util/calendar/zi/Zoneinfo.java index 277c045a2b0c05209d57588b7d2971f7720a0b73..9e48655181fa9d410f0da37d23e4ab2d20e67fec 100644 --- a/test/sun/util/calendar/zi/Zoneinfo.java +++ b/test/sun/util/calendar/zi/Zoneinfo.java @@ -372,6 +372,7 @@ class Zoneinfo { 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 @@ class Zoneinfo { 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) { diff --git a/test/sun/util/calendar/zi/tzdata/VERSION b/test/sun/util/calendar/zi/tzdata/VERSION index 2f162e0638af1a8de4d3e8c5052e695aa4468111..8ab96a77e71215f15dee92049dbed3fa6ae8047f 100644 --- a/test/sun/util/calendar/zi/tzdata/VERSION +++ b/test/sun/util/calendar/zi/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2013i +tzdata2014a diff --git a/test/sun/util/calendar/zi/tzdata/asia b/test/sun/util/calendar/zi/tzdata/asia index 1a8f83d3a644ea690abda78ad4cc8170af9a6aed..dc3c94ba9ccc8dc4e2244f32b459eaed7297e289 100644 --- a/test/sun/util/calendar/zi/tzdata/asia +++ b/test/sun/util/calendar/zi/tzdata/asia @@ -1113,8 +1113,13 @@ Rule Zion 1986 only - May 18 0:00 1:00 D 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, diff --git a/test/sun/util/calendar/zi/tzdata/australasia b/test/sun/util/calendar/zi/tzdata/australasia index cd6b724859de11d7f5dd448b2cb4df2f4f7a7ba6..a0e8b5a2ce97edbf13e8d684723ab649f0b53047 100644 --- a/test/sun/util/calendar/zi/tzdata/australasia +++ b/test/sun/util/calendar/zi/tzdata/australasia @@ -377,16 +377,18 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 # 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 2009 only - Nov 29 2:00 1:00 S 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 diff --git a/test/sun/util/calendar/zi/tzdata/europe b/test/sun/util/calendar/zi/tzdata/europe index 9f574a3b2b6cba812969bece8280aa051678d585..585e64d14fa713a22cae5be7bf2bb7025cc02d0f 100644 --- a/test/sun/util/calendar/zi/tzdata/europe +++ b/test/sun/util/calendar/zi/tzdata/europe @@ -2768,14 +2768,18 @@ Zone Europe/Zurich 0:34:08 - LMT 1853 Jul 16 # See above comment. # 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. -# -# # http://www.worldbulletin.net/?aType=haber&ArticleID=70872 -# # Turkish: -# # http://www.hurriyet.com.tr/ekonomi/17230464.asp?gid=373 -# + +# 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 @@ Zone Europe/Istanbul 1:55:52 - LMT 1880 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 @@ Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. # approval from 266 deputies. # # Ukraine abolishes transter back to the winter time (in Russian) -# # http://news.mail.ru/politics/6861560/ -# # # The Ukrainians will no longer change the clock (in Russian) -# # http://www.segodnya.ua/news/14290482.html -# # # Deputies cancelled the winter time (in Russian) -# # http://www.pravda.com.ua/rus/news/2011/09/20/6600616/ -# # # From Philip Pizzey (2011-10-18): # Today my Ukrainian colleagues have informed me that the @@ -2888,18 +2888,39 @@ Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. # 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: -# -# # http://portal.rada.gov.ua/rada/control/en/publish/article/info_left?art_id=287324&cat_id=105995 -# # # 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 +# +# 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 @@ Zone Europe/Kiev 2:02:04 - LMT 1880 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. diff --git a/test/sun/util/calendar/zi/tzdata/northamerica b/test/sun/util/calendar/zi/tzdata/northamerica index 9e551bb1c465d4acf5e30e15895e5d6d83bcfeb1..dc0c2e92cff499a8a1c53d2ce2be86ec84465c2c 100644 --- a/test/sun/util/calendar/zi/tzdata/northamerica +++ b/test/sun/util/calendar/zi/tzdata/northamerica @@ -414,9 +414,10 @@ Zone America/Denver -6:59:56 - LMT 1883 Nov 18 12:00:04 # 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 diff --git a/test/sun/util/calendar/zi/tzdata/southamerica b/test/sun/util/calendar/zi/tzdata/southamerica index 071f890bd05951666c46001d2f780200a14e75a3..02bf3bb633268d7eb403183746a3b44e21888aca 100644 --- a/test/sun/util/calendar/zi/tzdata/southamerica +++ b/test/sun/util/calendar/zi/tzdata/southamerica @@ -1298,6 +1298,13 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # 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 @@ Rule Para 2010 2012 - Apr Sun>=8 0:00 0 - # 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/Paramaribo -3:40:40 - LMT 1911 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):