Mercurial > hg > release > icedtea8-forest-3.0 > jdk
changeset 11709:8f97bfe5bcc8
Merge
author | asaha |
---|---|
date | Thu, 03 Dec 2015 13:27:36 -0800 |
parents | 7f58ba643922 (diff) ceb82a973af9 (current diff) |
children | e373d5fbe557 75c994c14748 |
files | .hgtags |
diffstat | 239 files changed, 5611 insertions(+), 3225 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Thu Dec 03 10:32:59 2015 -0800 +++ b/.hgtags Thu Dec 03 13:27:36 2015 -0800 @@ -495,8 +495,33 @@ ea602badedd0cd0c352c072220a884e8f1335e33 jdk8u66-b15 5ceafca6a734e13d51319df6afd40678d68f9851 jdk8u66-b16 e6d562c0f079dfd1e21c3734b2dca16f4b2e2494 jdk8u66-b17 +fd2fe69089aca0f187901a5f6f8bfe261ff17f5b jdk8u66-b18 f712dceafb546ea5833aeea507b5736e7e45f1ae jdk8u66-b31 74cfe16ae44c1c6d511dbeabf13a516da3799d55 jdk8u66-b32 ea7a705eab9e6495d08a92ff21e0370b68374c54 jdk8u66-b33 72ab45285f0e8293aa63e889bc75f0287b6e0436 jdk8u66-b34 e169a214f1f096af6b57169eeb0ba66ee5e9caa3 jdk8u66-b35 +9a2747ef337bdee71bc8225dea77eb403cca1179 jdk8u71-b00 +e8b5e10a19d66a77d04f12d4677e6fec66f79651 jdk8u71-b01 +25d689a73bc037e1710f95f6d4acf0671d22047d jdk8u71-b02 +ab54163c8610f6238a1d5f1f67cbd19ba13d08a0 jdk8u71-b03 +5ea62bb625b6b8f828098884d13eb2e3114a7c97 jdk8u71-b04 +1a9ced1852957b65e0c156602c3101aff17274fb jdk8u71-b05 +be9d91d310a02c2974d2bdabc31d8a6df8ad596e jdk8u71-b06 +f556d4c82ef13430e2708053caa9e11a74b2aebf jdk8u71-b07 +a81edad7e1e16c2b3cf2e60a8a98e232ebcaf3b1 jdk8u71-b08 +eac13ca04cc5c9adb4f14a76856376db0187f7dc jdk8u71-b09 +e494e93d48f943229223d881a2928064a69cdf23 jdk8u71-b10 +32226f73879f21f7a7bb024f4197c089b53a93c4 jdk8u71-b11 +be5faa9c77042f202106c18f4e8ea211137b4a3b jdk8u72-b00 +5ad1e9e8e8417f80c91d7e0f1f44cdf89b34ead3 jdk8u72-b01 +ab0c1040414d038ccbcfcc8ceb1ccf2f44ead8e4 jdk8u72-b02 +bdbb8a650d90d3481802a4f5297b522a16bd3f63 jdk8u72-b03 +b6645d81ccd773820aca99548640ace9c2f39225 jdk8u72-b04 +2bae9d627eb83f2ea23f4fa86e8eb46920cd1be6 jdk8u72-b05 +93148bc60f510af5160b6727533733c66284a84f jdk8u72-b06 +2a18f2af436ea62e7565ca0324f99112ef9cd4bc jdk8u72-b07 +c7d5bd8d04eb5d2adbb1112de95a2e2986e85925 jdk8u72-b08 +ff73e114d682ec14c11099c6c5d48b75bf685394 jdk8u72-b09 +dcf7fd07b08b59e1802851d016d913c254221a44 jdk8u72-b10 +d7cc3225f1050de03b236b92e12c547f21697013 jdk8u72-b11
--- a/make/data/tzdata/VERSION Thu Dec 03 10:32:59 2015 -0800 +++ b/make/data/tzdata/VERSION Thu Dec 03 13:27:36 2015 -0800 @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2015f +tzdata2015g
--- a/make/data/tzdata/asia Thu Dec 03 10:32:59 2015 -0800 +++ b/make/data/tzdata/asia Thu Dec 03 13:27:36 2015 -0800 @@ -154,7 +154,8 @@ # Azerbaijan # From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23): # According to the resolution of Cabinet of Ministers, 1997 -# Resolution available at: http://aif.az/docs/daylight_res.pdf +# From Paul Eggert (2015-09-17): It was Resolution No. 21 (1997-03-17). +# http://code.az/files/daylight_res.pdf # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Azer 1997 max - Mar lastSun 4:00 1:00 S Rule Azer 1997 max - Oct lastSun 5:00 0 - @@ -1740,11 +1741,12 @@ # the 8:30 time zone on August 15, one example: # http://www.bbc.com/news/world-asia-33815049 # -# From Paul Eggert (2015-08-07): -# No transition time is specified; assume 00:00. +# From Paul Eggert (2015-08-15): +# Bells rang out midnight (00:00) Friday as part of the celebrations. See: +# Talmadge E. North Korea celebrates new time zone, 'Pyongyang Time' +# http://news.yahoo.com/north-korea-celebrates-time-zone-pyongyang-time-164038128.html # There is no common English-language abbreviation for this time zone. -# Use %z rather than invent one. We can't assume %z works everywhere yet, -# so for now substitute its output manually. +# Use KST, as that's what we already use for 1954-1961 in ROK. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Seoul 8:27:52 - LMT 1908 Apr 1 @@ -1758,7 +1760,7 @@ 8:30 - KST 1912 Jan 1 9:00 - JCST 1937 Oct 1 9:00 - JST 1945 Aug 24 - 9:00 - KST 2015 Aug 15 + 9:00 - KST 2015 Aug 15 00:00 8:30 - KST ###############################################################################
--- a/make/data/tzdata/australasia Thu Dec 03 10:32:59 2015 -0800 +++ b/make/data/tzdata/australasia Thu Dec 03 13:27:36 2015 -0800 @@ -358,10 +358,17 @@ # DST will start Nov. 2 this year. # http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-NOVEMBER-2ND.aspx -# From Paul Eggert (2014-10-20): +# From a government order dated 2015-08-26 and published as Legal Notice No. 77 +# in the Government of Fiji Gazette Supplement No. 24 (2015-08-28), +# via Ken Rylander (2015-09-02): +# the daylight saving period is 1 hour in advance of the standard time +# commencing at 2.00 am on Sunday 1st November, 2015 and ending at +# 3.00 am on Sunday 17th January, 2016. + +# From Paul Eggert (2015-09-01): # For now, guess DST from 02:00 the first Sunday in November to -# 03:00 the first Sunday on or after January 18. Although ad hoc, it -# matches this year's plan and seems more likely to match future +# 03:00 the third Sunday in January. Although ad hoc, it matches +# transitions since late 2014 and seems more likely to match future # practice than guessing no DST. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -374,7 +381,7 @@ Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - Rule Fiji 2014 only - Jan Sun>=18 2:00 0 - Rule Fiji 2014 max - Nov Sun>=1 2:00 1:00 S -Rule Fiji 2015 max - Jan Sun>=18 3:00 0 - +Rule Fiji 2015 max - Jan Sun>=15 3: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 @@ -533,7 +540,10 @@ # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Pacific/Norfolk 11:11:52 - LMT 1901 # Kingston 11:12 - NMT 1951 # Norfolk Mean Time - 11:30 - NFT # Norfolk Time + 11:30 - NFT 1974 Oct 27 02:00 # Norfolk T. + 11:30 1:00 NFST 1975 Mar 2 02:00 + 11:30 - NFT 2015 Oct 4 02:00 + 11:00 - NFT # Palau (Belau) # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -1573,6 +1583,20 @@ # started DST on June 3. Possibly DST was observed other years # in Midway, but we have no record of it. +# Norfolk + +# From Alexander Krivenyshev (2015-09-23): +# Norfolk Island will change ... from +1130 to +1100: +# https://www.comlaw.gov.au/Details/F2015L01483/Explanatory%20Statement/Text +# ... at 12.30 am (by legal time in New South Wales) on 4 October 2015. +# http://www.norfolkisland.gov.nf/nia/MediaRelease/Media%20Release%20Norfolk%20Island%20Standard%20Time%20Change.pdf + +# From Paul Eggert (2015-09-23): +# Transitions before 2015 are from timeanddate.com, which consulted +# the Norfolk Island Museum and the Australian Bureau of Meteorology's +# Norfolk Island station, and found no record of Norfolk observing DST +# other than in 1974/5. See: +# http://www.timeanddate.com/time/australia/norfolk-island.html # Pitcairn
--- a/make/data/tzdata/europe Thu Dec 03 10:32:59 2015 -0800 +++ b/make/data/tzdata/europe Thu Dec 03 13:27:36 2015 -0800 @@ -3173,6 +3173,11 @@ # http://www.balkaneu.com/eventful-elections-turkey/ 2014-03-30. # I guess the best we can do is document the official time. +# From Fatih (2015-09-29): +# It's officially announced now by the Ministry of Energy. +# Turkey delays winter time to 8th of November 04:00 +# http://www.aa.com.tr/tr/turkiye/yaz-saati-uygulamasi-8-kasimda-sona-erecek/362217 + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Turkey 1916 only - May 1 0:00 1:00 S Rule Turkey 1916 only - Oct 1 0:00 0 - @@ -3242,6 +3247,8 @@ 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 2015 Oct 25 1:00u + 2:00 1:00 EEST 2015 Nov 8 1:00u 2:00 EU EE%sT Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents.
--- a/make/data/tzdata/northamerica Thu Dec 03 10:32:59 2015 -0800 +++ b/make/data/tzdata/northamerica Thu Dec 03 13:27:36 2015 -0800 @@ -1849,6 +1849,22 @@ # The transition dates (and times) are guesses. +# From Matt Johnson (2015-09-21): +# Fort Nelson, BC, Canada will cancel DST this year. So while previously they +# were aligned with America/Vancouver, they're now aligned with +# America/Dawson_Creek. +# http://www.northernrockies.ca/EN/meta/news/archives/2015/northern-rockies-time-change.html +# +# From Tim Parenti (2015-09-23): +# This requires a new zone for the Northern Rockies Regional Municipality, +# America/Fort_Nelson. The resolution of 2014-12-08 was reached following a +# 2014-11-15 poll with nearly 75% support. Effectively, the municipality has +# been on MST (-0700) like Dawson Creek since it advanced its clocks on +# 2015-03-08. +# +# From Paul Eggert (2015-09-23): +# Shanks says Fort Nelson did not observe DST in 1946, unlike Vancouver. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Vanc 1918 only - Apr 14 2:00 1:00 D Rule Vanc 1918 only - Oct 27 2:00 0 S @@ -1867,6 +1883,12 @@ -8:00 Canada P%sT 1947 -8:00 Vanc P%sT 1972 Aug 30 2:00 -7:00 - MST +Zone America/Fort_Nelson -8:10:47 - LMT 1884 + -8:00 Vanc P%sT 1946 + -8:00 - PST 1947 + -8:00 Vanc P%sT 1987 + -8:00 Canada P%sT 2015 Mar 8 2:00 + -7:00 - MST Zone America/Creston -7:46:04 - LMT 1884 -7:00 - MST 1916 Oct 1 -8:00 - PST 1918 Jun 2
--- a/make/data/tzdata/zone.tab Thu Dec 03 10:32:59 2015 -0800 +++ b/make/data/tzdata/zone.tab Thu Dec 03 13:27:36 2015 -0800 @@ -152,6 +152,7 @@ CA +682059-1334300 America/Inuvik Mountain Time - west Northwest Territories CA +4906-11631 America/Creston Mountain Standard Time - Creston, British Columbia CA +5946-12014 America/Dawson_Creek Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia +CA +5848-12242 America/Fort_Nelson Mountain Standard Time - Fort Nelson, British Columbia CA +4916-12307 America/Vancouver Pacific Time - west British Columbia CA +6043-13503 America/Whitehorse Pacific Time - south Yukon CA +6404-13925 America/Dawson Pacific Time - north Yukon
--- a/make/lib/CoreLibraries.gmk Thu Dec 03 10:32:59 2015 -0800 +++ b/make/lib/CoreLibraries.gmk Thu Dec 03 13:27:36 2015 -0800 @@ -205,6 +205,7 @@ -framework Foundation \ -framework Security -framework SystemConfiguration, \ LDFLAGS_SUFFIX_windows := -export:winFileHandleOpen -export:handleLseek \ + -export:getErrorString \ jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \ shell32.lib delayimp.lib -DELAYLOAD:shell32.dll \ advapi32.lib version.lib, \
--- a/make/mapfiles/libawt/mapfile-mawt-vers Thu Dec 03 10:32:59 2015 -0800 +++ b/make/mapfiles/libawt/mapfile-mawt-vers Thu Dec 03 13:27:36 2015 -0800 @@ -242,7 +242,7 @@ getDefaultConfig; Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_X11FontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_font_SunFontManager_populateFontFileNameMap; # CDE private entry point
--- a/make/mapfiles/libawt/mapfile-vers-linux Thu Dec 03 10:32:59 2015 -0800 +++ b/make/mapfiles/libawt/mapfile-vers-linux Thu Dec 03 13:27:36 2015 -0800 @@ -270,7 +270,7 @@ getDefaultConfig; Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_X11FontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_font_SunFontManager_populateFontFileNameMap; # CDE private entry point
--- a/make/mapfiles/libawt_headless/mapfile-vers Thu Dec 03 10:32:59 2015 -0800 +++ b/make/mapfiles/libawt_headless/mapfile-vers Thu Dec 03 13:27:36 2015 -0800 @@ -65,7 +65,7 @@ Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_X11FontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_awt_FontDescriptor_initIDs; Java_sun_awt_PlatformFont_initIDs;
--- a/make/mapfiles/libawt_xawt/mapfile-vers Thu Dec 03 10:32:59 2015 -0800 +++ b/make/mapfiles/libawt_xawt/mapfile-vers Thu Dec 03 13:27:36 2015 -0800 @@ -188,7 +188,7 @@ Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_X11FontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_awt_X11GraphicsEnvironment_initDisplay; Java_sun_awt_X11GraphicsEnvironment_initGLX; Java_sun_awt_X11GraphicsEnvironment_initXRender;
--- a/make/mapfiles/libjava/mapfile-vers Thu Dec 03 10:32:59 2015 -0800 +++ b/make/mapfiles/libjava/mapfile-vers Thu Dec 03 13:27:36 2015 -0800 @@ -284,6 +284,8 @@ # ZipFile.c needs this one throwFileNotFoundException; + # zip_util.c needs this + getErrorString; # Java_sun_misc_VM_getState; threads.c # Java_sun_misc_VM_threadsSuspended; threads.c
--- a/make/mapfiles/libnet/mapfile-vers Thu Dec 03 10:32:59 2015 -0800 +++ b/make/mapfiles/libnet/mapfile-vers Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -28,8 +28,7 @@ SUNWprivate_1.1 { global: JNI_OnLoad; - Java_java_net_AbstractPlainDatagramSocketImpl_init; - Java_java_net_AbstractPlainDatagramSocketImpl_dataAvailable; + Java_java_net_PlainDatagramSocketImpl_dataAvailable; Java_java_net_PlainSocketImpl_socketListen; Java_java_net_PlainDatagramSocketImpl_getTTL; Java_java_net_PlainDatagramSocketImpl_init;
--- a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,3 +1,4 @@ + /* * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,9 +28,10 @@ import java.awt.*; import java.awt.image.*; -import sun.awt.image.ImageRepresentation; import java.io.*; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.text.Normalizer; import java.text.Normalizer.Form; @@ -54,7 +56,8 @@ "PDF", "URL", "PNG", - "JFIF" + "JFIF", + "XPICT" }; static { @@ -78,6 +81,7 @@ public static final int CF_URL = 7; public static final int CF_PNG = 8; public static final int CF_JPEG = 9; + public static final int CF_XPICT = 10; private CDataTransferer() {} @@ -122,26 +126,43 @@ @Override public Object translateBytes(byte[] bytes, DataFlavor flavor, - long format, Transferable transferable) throws IOException { + long format, Transferable transferable) throws IOException { + - if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass())) - { - String charset = getDefaultTextCharset(); - if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) { - try { - charset = new String((byte[])transferable.getTransferData(javaTextEncodingFlavor), "UTF-8"); - } catch (UnsupportedFlavorException cannotHappen) { - } + if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass())) { + String[] strings = dragQueryFile(bytes); + if(strings == null || strings.length == 0) { + return null; + } + return new URL(strings[0]); + } else if(isUriListFlavor(flavor)) { + // dragQueryFile works fine with files and url, + // it parses and extracts values from property list. + // maxosx always returns property list for + // CF_URL and CF_FILE + String[] strings = dragQueryFile(bytes); + if(strings == null) { + return null; + } + String separator = System.getProperty("line.separator"); + StringBuilder sb = new StringBuilder(); + if(strings.length > 0) { + sb.append(strings[0]); + for(int i = 1; i < strings.length; i++) { + sb.append(strings[i]); + sb.append(separator); } - - return new URL(new String(bytes, charset)); } + bytes = sb.toString().getBytes(); + // now we extracted uri from xml, now we should treat it as + // regular string that allows to translate data to target represantation + // class by base method + format = CF_STRING; + } else if (format == CF_STRING) { + bytes = Normalizer.normalize(new String(bytes, "UTF8"), Form.NFC).getBytes("UTF8"); + } - if (format == CF_STRING) { - bytes = Normalizer.normalize(new String(bytes, "UTF8"), Form.NFC).getBytes("UTF8"); - } - - return super.translateBytes(bytes, flavor, format, transferable); + return super.translateBytes(bytes, flavor, format, transferable); } @Override @@ -219,6 +240,7 @@ return nativeDragQueryFile(bytes); } + @Override protected Image platformImageBytesToImage(byte[] bytes, long format) throws IOException { return CImage.getCreator().createImageFromPlatformImageBytes(bytes); @@ -243,7 +265,7 @@ } try { DataFlavor df = new DataFlavor(nat); - if (df.getPrimaryType().equals("text") && df.getSubType().equals("uri-list")) { + if (isUriListFlavor(df)) { return true; } } catch (Exception e) { @@ -251,6 +273,13 @@ } return false; } + + private boolean isUriListFlavor(DataFlavor df) { + if (df.getPrimaryType().equals("text") && df.getSubType().equals("uri-list")) { + return true; + } + return false; + } }
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -234,6 +234,11 @@ // this will not work if the user clicks on the "Preview" button // However if the printer is a StreamPrintService, its the right path. PrintService psvc = getPrintService(); + + if (psvc == null) { + throw new PrinterException("No print service found."); + } + if (psvc instanceof StreamPrintService) { spoolToService(psvc, attributes); return; @@ -775,4 +780,4 @@ (float) (paper.getImageableHeight() / dpi), MediaPrintableArea.INCH); } -} \ No newline at end of file +}
--- a/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,10 +84,24 @@ long fds = IOUtil.makePipe(false); fd0 = (int)(fds >>> 32); fd1 = (int)fds; - kqueueWrapper = new KQueueArrayWrapper(); - kqueueWrapper.initInterrupt(fd0, fd1); - fdMap = new HashMap<>(); - totalChannels = 1; + try { + kqueueWrapper = new KQueueArrayWrapper(); + kqueueWrapper.initInterrupt(fd0, fd1); + fdMap = new HashMap<>(); + totalChannels = 1; + } catch (Throwable t) { + try { + FileDispatcherImpl.closeIntFD(fd0); + } catch (IOException ioe0) { + t.addSuppressed(ioe0); + } + try { + FileDispatcherImpl.closeIntFD(fd1); + } catch (IOException ioe1) { + t.addSuppressed(ioe1); + } + throw t; + } }
--- a/src/macosx/lib/flavormap.properties Thu Dec 03 10:32:59 2015 -0800 +++ b/src/macosx/lib/flavormap.properties Thu Dec 03 13:27:36 2015 -0800 @@ -80,4 +80,6 @@ RICH_TEXT=text/rtf HTML=text/html;charset=utf-8;eoln="\r\n";terminators=1 URL=application/x-java-url;class=java.net.URL +FILE_NAME=text/uri-list;eoln="\r\n";terminators=1 URL=text/uri-list;eoln="\r\n";terminators=1 +XPICT=image/x-pict;class=java.io.InputStream
--- a/src/macosx/native/sun/awt/CDataTransferer.m Thu Dec 03 10:32:59 2015 -0800 +++ b/src/macosx/native/sun/awt/CDataTransferer.m Thu Dec 03 13:27:36 2015 -0800 @@ -58,6 +58,8 @@ forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_PNG]]; [sStandardMappings setObject:(NSString*)kUTTypeJPEG forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_JPEG]]; + [sStandardMappings setObject:NSPICTPboardType + forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_XPICT]]; } return sStandardMappings; }
--- a/src/macosx/native/sun/awt/LWCToolkit.m Thu Dec 03 10:32:59 2015 -0800 +++ b/src/macosx/native/sun/awt/LWCToolkit.m Thu Dec 03 13:27:36 2015 -0800 @@ -287,7 +287,7 @@ // Processing all events excluding NSApplicationDefined which need to be processed // on the main loop only (those events are intended for disposing resources) NSEvent *event; - if ((event = [NSApp nextEventMatchingMask:(NSAnyEventMask & ~NSApplicationDefined) + if ((event = [NSApp nextEventMatchingMask:(NSAnyEventMask & ~NSApplicationDefinedMask) untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]) != nil) {
--- a/src/share/classes/com/sun/crypto/provider/PBES2Core.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/com/sun/crypto/provider/PBES2Core.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -263,7 +263,7 @@ passwdChars[i] = (char) (passwdBytes[i] & 0x7f); PBEKeySpec pbeSpec = - new PBEKeySpec(passwdChars, salt, iCount, blkSize * 8); + new PBEKeySpec(passwdChars, salt, iCount, keyLength); // password char[] was cloned in PBEKeySpec constructor, // so we can zero it out here java.util.Arrays.fill(passwdChars, ' ');
--- a/src/share/classes/com/sun/jndi/ldap/LdapClient.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/com/sun/jndi/ldap/LdapClient.java Thu Dec 03 13:27:36 2015 -0800 @@ -494,16 +494,14 @@ */ void processConnectionClosure() { // Notify listeners - synchronized (unsolicited) { - if (unsolicited.size() > 0) { - String msg; - if (conn != null) { - msg = conn.host + ":" + conn.port + " connection closed"; - } else { - msg = "Connection closed"; - } - notifyUnsolicited(new CommunicationException(msg)); + if (unsolicited.size() > 0) { + String msg; + if (conn != null) { + msg = conn.host + ":" + conn.port + " connection closed"; + } else { + msg = "Connection closed"; } + notifyUnsolicited(new CommunicationException(msg)); } // Remove from pool @@ -1499,13 +1497,8 @@ if (debug > 0) { System.err.println("LdapClient.removeUnsolicited" + ctx); } - synchronized (unsolicited) { - if (unsolicited.size() == 0) { - return; - } unsolicited.removeElement(ctx); } - } // NOTE: Cannot be synchronized because this is called asynchronously // by the reader thread in Connection. Instead, sync on 'unsolicited' Vector. @@ -1513,30 +1506,35 @@ if (debug > 0) { System.err.println("LdapClient.processUnsolicited"); } - synchronized (unsolicited) { - try { - // Parse the response - LdapResult res = new LdapResult(); + try { + // Parse the response + LdapResult res = new LdapResult(); + + ber.parseSeq(null); // init seq + ber.parseInt(); // msg id; should be 0; ignored + if (ber.parseByte() != LDAP_REP_EXTENSION) { + throw new IOException( + "Unsolicited Notification must be an Extended Response"); + } + ber.parseLength(); + parseExtResponse(ber, res); - ber.parseSeq(null); // init seq - ber.parseInt(); // msg id; should be 0; ignored - if (ber.parseByte() != LDAP_REP_EXTENSION) { - throw new IOException( - "Unsolicited Notification must be an Extended Response"); - } - ber.parseLength(); - parseExtResponse(ber, res); + if (DISCONNECT_OID.equals(res.extensionId)) { + // force closing of connection + forceClose(pooled); + } - if (DISCONNECT_OID.equals(res.extensionId)) { - // force closing of connection - forceClose(pooled); - } + LdapCtx first = null; + UnsolicitedNotification notice = null; + synchronized (unsolicited) { if (unsolicited.size() > 0) { + first = unsolicited.elementAt(0); + // Create an UnsolicitedNotification using the parsed data // Need a 'ctx' object because we want to use the context's // list of provider control factories. - UnsolicitedNotification notice = new UnsolicitedResponseImpl( + notice = new UnsolicitedResponseImpl( res.extensionId, res.extensionValue, res.referrals, @@ -1544,42 +1542,45 @@ res.errorMessage, res.matchedDN, (res.resControls != null) ? - unsolicited.elementAt(0).convertControls(res.resControls) : + first.convertControls(res.resControls) : null); - - // Fire UnsolicitedNotification events to listeners - notifyUnsolicited(notice); - - // If "disconnect" notification, - // notify unsolicited listeners via NamingException - if (DISCONNECT_OID.equals(res.extensionId)) { - notifyUnsolicited( - new CommunicationException("Connection closed")); - } } - } catch (IOException e) { - if (unsolicited.size() == 0) - return; // no one registered; ignore + } + + if (notice != null) { + // Fire UnsolicitedNotification events to listeners + notifyUnsolicited(notice); - NamingException ne = new CommunicationException( - "Problem parsing unsolicited notification"); - ne.setRootCause(e); + // If "disconnect" notification, + // notify unsolicited listeners via NamingException + if (DISCONNECT_OID.equals(res.extensionId)) { + notifyUnsolicited( + new CommunicationException("Connection closed")); + } + } + } catch (IOException e) { + NamingException ne = new CommunicationException( + "Problem parsing unsolicited notification"); + ne.setRootCause(e); - notifyUnsolicited(ne); + notifyUnsolicited(ne); - } catch (NamingException e) { - notifyUnsolicited(e); - } + } catch (NamingException e) { + notifyUnsolicited(e); } } private void notifyUnsolicited(Object e) { - for (int i = 0; i < unsolicited.size(); i++) { - unsolicited.elementAt(i).fireUnsolicited(e); + Vector<LdapCtx> unsolicitedCopy; + synchronized (unsolicited) { + unsolicitedCopy = new Vector<>(unsolicited); + if (e instanceof NamingException) { + unsolicited.setSize(0); // no more listeners after exception + } } - if (e instanceof NamingException) { - unsolicited.setSize(0); // no more listeners after exception + for (int i = 0; i < unsolicitedCopy.size(); i++) { + unsolicitedCopy.elementAt(i).fireUnsolicited(e); } }
--- a/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1041,12 +1041,11 @@ } Type findBootType(String signature) throws ClassNotLoadedException { - List<ReferenceType> types = allClasses(); + List<ReferenceType> types = retrieveClassesBySignature(signature); Iterator<ReferenceType> iter = types.iterator(); while (iter.hasNext()) { ReferenceType type = iter.next(); - if ((type.classLoader() == null) && - (type.signature().equals(signature))) { + if (type.classLoader() == null) { return type; } }
--- a/src/share/classes/java/awt/EventQueue.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/awt/EventQueue.java Thu Dec 03 13:27:36 2015 -0800 @@ -896,11 +896,13 @@ } } - // Wake up EDT waiting in getNextEvent(), so it can - // pick up a new EventQueue. Post the waking event before - // topQueue.nextQueue is assigned, otherwise the event would - // go newEventQueue - topQueue.postEventPrivate(new InvocationEvent(topQueue, dummyRunnable)); + if (topQueue.dispatchThread != null) { + // Wake up EDT waiting in getNextEvent(), so it can + // pick up a new EventQueue. Post the waking event before + // topQueue.nextQueue is assigned, otherwise the event would + // go newEventQueue + topQueue.postEventPrivate(new InvocationEvent(topQueue, dummyRunnable)); + } newEventQueue.previousQueue = topQueue; topQueue.nextQueue = newEventQueue;
--- a/src/share/classes/java/lang/Character.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/lang/Character.java Thu Dec 03 13:27:36 2015 -0800 @@ -6647,7 +6647,7 @@ * <td>{@code FORM FEED}</td></tr> * <tr><td>{@code '\r'}</td> <td>{@code U+000D}</td> * <td>{@code CARRIAGE RETURN}</td></tr> - * <tr><td>{@code ' '}</td> <td>{@code U+0020}</td> + * <tr><td>{@code ' '}</td> <td>{@code U+0020}</td> * <td>{@code SPACE}</td></tr> * </table> *
--- a/src/share/classes/java/lang/invoke/LambdaFormEditor.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/lang/invoke/LambdaFormEditor.java Thu Dec 03 13:27:36 2015 -0800 @@ -436,7 +436,7 @@ } private MethodType bindArgumentType(BoundMethodHandle mh, int pos, BasicType bt) { - assert(mh.form == lambdaForm); + assert(mh.form.uncustomize() == lambdaForm); assert(mh.form.names[1+pos].type == bt); assert(BasicType.basicType(mh.type().parameterType(pos)) == bt); return mh.type().dropParameterTypes(pos, pos+1);
--- a/src/share/classes/java/lang/invoke/MemberName.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/lang/invoke/MemberName.java Thu Dec 03 13:27:36 2015 -0800 @@ -93,7 +93,7 @@ /** Return the simple name of this member. * For a type, it is the same as {@link Class#getSimpleName}. * For a method or field, it is the simple name of the member. - * For a constructor, it is always {@code "<init>"}. + * For a constructor, it is always {@code "<init>"}. */ public String getName() { if (name == null) { @@ -727,7 +727,7 @@ } /** Create a method or constructor name from the given components: * Declaring class, name, type, reference kind. - * It will be a constructor if and only if the name is {@code "<init>"}. + * It will be a constructor if and only if the name is {@code "<init>"}. * The declaring class may be supplied as null if this is to be a bare name and type. * The last argument is optional, a boolean which requests REF_invokeSpecial. * The resulting name will in an unresolved state.
--- a/src/share/classes/java/lang/invoke/MethodHandleInfo.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/lang/invoke/MethodHandleInfo.java Thu Dec 03 13:27:36 2015 -0800 @@ -155,7 +155,7 @@ /** * Returns the name of the cracked method handle's underlying member. - * This is {@code "<init>"} if the underlying member was a constructor, + * This is {@code "<init>"} if the underlying member was a constructor, * else it is a simple method name or field name. * @return the simple name of the underlying member */
--- a/src/share/classes/java/lang/invoke/Stable.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/lang/invoke/Stable.java Thu Dec 03 13:27:36 2015 -0800 @@ -51,7 +51,7 @@ * If the field is an array type, then both the field value and * all the components of the field value (if the field value is non-null) * are indicated to be stable. - * If the field type is an array type with rank {@code N > 1}, + * If the field type is an array type with rank {@code N > 1}, * then each component of the field value (if the field value is non-null), * is regarded as a stable array of rank {@code N-1}. * <p>
--- a/src/share/classes/java/lang/invoke/SwitchPoint.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/lang/invoke/SwitchPoint.java Thu Dec 03 13:27:36 2015 -0800 @@ -55,20 +55,20 @@ * At that point {@code guardWithTest} may ignore {@code T} and return {@code F}. * <p> * Here is an example of a switch point in action: - * <blockquote><pre>{@code -MethodHandle MH_strcat = MethodHandles.lookup() - .findVirtual(String.class, "concat", MethodType.methodType(String.class, String.class)); -SwitchPoint spt = new SwitchPoint(); -assert(!spt.hasBeenInvalidated()); -// the following steps may be repeated to re-use the same switch point: -MethodHandle worker1 = MH_strcat; -MethodHandle worker2 = MethodHandles.permuteArguments(MH_strcat, MH_strcat.type(), 1, 0); -MethodHandle worker = spt.guardWithTest(worker1, worker2); -assertEquals("method", (String) worker.invokeExact("met", "hod")); -SwitchPoint.invalidateAll(new SwitchPoint[]{ spt }); -assert(spt.hasBeenInvalidated()); -assertEquals("hodmet", (String) worker.invokeExact("met", "hod")); - * }</pre></blockquote> + * <pre>{@code + * MethodHandle MH_strcat = MethodHandles.lookup() + * .findVirtual(String.class, "concat", MethodType.methodType(String.class, String.class)); + * SwitchPoint spt = new SwitchPoint(); + * assert(!spt.hasBeenInvalidated()); + * // the following steps may be repeated to re-use the same switch point: + * MethodHandle worker1 = MH_strcat; + * MethodHandle worker2 = MethodHandles.permuteArguments(MH_strcat, MH_strcat.type(), 1, 0); + * MethodHandle worker = spt.guardWithTest(worker1, worker2); + * assertEquals("method", (String) worker.invokeExact("met", "hod")); + * SwitchPoint.invalidateAll(new SwitchPoint[]{ spt }); + * assert(spt.hasBeenInvalidated()); + * assertEquals("hodmet", (String) worker.invokeExact("met", "hod")); + * }</pre> * <p style="font-size:smaller;"> * <em>Discussion:</em> * Switch points are useful without subclassing. They may also be subclassed. @@ -82,31 +82,31 @@ * <em>Implementation Note:</em> * A switch point behaves as if implemented on top of {@link MutableCallSite}, * approximately as follows: - * <blockquote><pre>{@code -public class SwitchPoint { - private static final MethodHandle - K_true = MethodHandles.constant(boolean.class, true), - K_false = MethodHandles.constant(boolean.class, false); - private final MutableCallSite mcs; - private final MethodHandle mcsInvoker; - public SwitchPoint() { - this.mcs = new MutableCallSite(K_true); - this.mcsInvoker = mcs.dynamicInvoker(); - } - public MethodHandle guardWithTest( - MethodHandle target, MethodHandle fallback) { - // Note: mcsInvoker is of type ()boolean. - // Target and fallback may take any arguments, but must have the same type. - return MethodHandles.guardWithTest(this.mcsInvoker, target, fallback); - } - public static void invalidateAll(SwitchPoint[] spts) { - List<MutableCallSite> mcss = new ArrayList<>(); - for (SwitchPoint spt : spts) mcss.add(spt.mcs); - for (MutableCallSite mcs : mcss) mcs.setTarget(K_false); - MutableCallSite.syncAll(mcss.toArray(new MutableCallSite[0])); - } -} - * }</pre></blockquote> + * <pre>{@code + * public class SwitchPoint { + * private static final MethodHandle + * K_true = MethodHandles.constant(boolean.class, true), + * K_false = MethodHandles.constant(boolean.class, false); + * private final MutableCallSite mcs; + * private final MethodHandle mcsInvoker; + * public SwitchPoint() { + * this.mcs = new MutableCallSite(K_true); + * this.mcsInvoker = mcs.dynamicInvoker(); + * } + * public MethodHandle guardWithTest( + * MethodHandle target, MethodHandle fallback) { + * // Note: mcsInvoker is of type ()boolean. + * // Target and fallback may take any arguments, but must have the same type. + * return MethodHandles.guardWithTest(this.mcsInvoker, target, fallback); + * } + * public static void invalidateAll(SwitchPoint[] spts) { + * List<MutableCallSite> mcss = new ArrayList<>(); + * for (SwitchPoint spt : spts) mcss.add(spt.mcs); + * for (MutableCallSite mcs : mcss) mcs.setTarget(K_false); + * MutableCallSite.syncAll(mcss.toArray(new MutableCallSite[0])); + * } + * } + * }</pre> * @author Remi Forax, JSR 292 EG */ public class SwitchPoint {
--- a/src/share/classes/java/lang/ref/Reference.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/lang/ref/Reference.java Thu Dec 03 13:27:36 2015 -0800 @@ -26,6 +26,8 @@ package java.lang.ref; import sun.misc.Cleaner; +import sun.misc.JavaLangRefAccess; +import sun.misc.SharedSecrets; /** * Abstract base class for reference objects. This class defines the @@ -111,7 +113,7 @@ * therefore critical that any code holding this lock complete as quickly * as possible, allocate no new objects, and avoid calling user code. */ - static private class Lock { }; + static private class Lock { } private static Lock lock = new Lock(); @@ -126,53 +128,96 @@ */ private static class ReferenceHandler extends Thread { + private static void ensureClassInitialized(Class<?> clazz) { + try { + Class.forName(clazz.getName(), true, clazz.getClassLoader()); + } catch (ClassNotFoundException e) { + throw (Error) new NoClassDefFoundError(e.getMessage()).initCause(e); + } + } + + static { + // pre-load and initialize InterruptedException and Cleaner classes + // so that we don't get into trouble later in the run loop if there's + // memory shortage while loading/initializing them lazily. + ensureClassInitialized(InterruptedException.class); + ensureClassInitialized(Cleaner.class); + } + ReferenceHandler(ThreadGroup g, String name) { super(g, name); } public void run() { - for (;;) { - Reference<Object> r; - synchronized (lock) { - if (pending != null) { - r = pending; - pending = r.discovered; - r.discovered = null; - } else { - // The waiting on the lock may cause an OOME because it may try to allocate - // exception objects, so also catch OOME here to avoid silent exit of the - // reference handler thread. - // - // Explicitly define the order of the two exceptions we catch here - // when waiting for the lock. - // - // We do not want to try to potentially load the InterruptedException class - // (which would be done if this was its first use, and InterruptedException - // were checked first) in this situation. - // - // This may lead to the VM not ever trying to load the InterruptedException - // class again. - try { - try { - lock.wait(); - } catch (OutOfMemoryError x) { } - } catch (InterruptedException x) { } - continue; - } - } - - // Fast path for cleaners - if (r instanceof Cleaner) { - ((Cleaner)r).clean(); - continue; - } - - ReferenceQueue<Object> q = r.queue; - if (q != ReferenceQueue.NULL) q.enqueue(r); + while (true) { + tryHandlePending(true); } } } + /** + * Try handle pending {@link Reference} if there is one.<p> + * Return {@code true} as a hint that there might be another + * {@link Reference} pending or {@code false} when there are no more pending + * {@link Reference}s at the moment and the program can do some other + * useful work instead of looping. + * + * @param waitForNotify if {@code true} and there was no pending + * {@link Reference}, wait until notified from VM + * or interrupted; if {@code false}, return immediately + * when there is no pending {@link Reference}. + * @return {@code true} if there was a {@link Reference} pending and it + * was processed, or we waited for notification and either got it + * or thread was interrupted before being notified; + * {@code false} otherwise. + */ + static boolean tryHandlePending(boolean waitForNotify) { + Reference<Object> r; + Cleaner c; + try { + synchronized (lock) { + if (pending != null) { + r = pending; + // 'instanceof' might throw OutOfMemoryError sometimes + // so do this before un-linking 'r' from the 'pending' chain... + c = r instanceof Cleaner ? (Cleaner) r : null; + // unlink 'r' from 'pending' chain + pending = r.discovered; + r.discovered = null; + } else { + // The waiting on the lock may cause an OutOfMemoryError + // because it may try to allocate exception objects. + if (waitForNotify) { + lock.wait(); + } + // retry if waited + return waitForNotify; + } + } + } catch (OutOfMemoryError x) { + // Give other threads CPU time so they hopefully drop some live references + // and GC reclaims some space. + // Also prevent CPU intensive spinning in case 'r instanceof Cleaner' above + // persistently throws OOME for some time... + Thread.yield(); + // retry + return true; + } catch (InterruptedException x) { + // retry + return true; + } + + // Fast path for cleaners + if (c != null) { + c.clean(); + return true; + } + + ReferenceQueue<? super Object> q = r.queue; + if (q != ReferenceQueue.NULL) q.enqueue(r); + return true; + } + static { ThreadGroup tg = Thread.currentThread().getThreadGroup(); for (ThreadGroup tgn = tg; @@ -185,9 +230,16 @@ handler.setPriority(Thread.MAX_PRIORITY); handler.setDaemon(true); handler.start(); + + // provide access in SharedSecrets + SharedSecrets.setJavaLangRefAccess(new JavaLangRefAccess() { + @Override + public boolean tryHandlePendingReference() { + return tryHandlePending(false); + } + }); } - /* -- Referent accessor and setters -- */ /**
--- a/src/share/classes/java/lang/reflect/Constructor.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/lang/reflect/Constructor.java Thu Dec 03 13:27:36 2015 -0800 @@ -218,6 +218,7 @@ /** * {@inheritDoc} + * @since 1.8 */ public int getParameterCount() { return parameterTypes.length; }
--- a/src/share/classes/java/lang/reflect/Executable.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/lang/reflect/Executable.java Thu Dec 03 13:27:36 2015 -0800 @@ -245,7 +245,6 @@ * declared or implicitly declared or neither) for the executable * represented by this object. * - * @since 1.8 * @return The number of formal parameters for the executable this * object represents */ @@ -343,7 +342,6 @@ * have unique names, or names that are legal identifiers in the * Java programming language (JLS 3.8). * - * @since 1.8 * @throws MalformedParametersException if the class file contains * a MethodParameters attribute that is improperly formatted. * @return an array of {@code Parameter} objects representing all @@ -575,7 +573,6 @@ /** * {@inheritDoc} * @throws NullPointerException {@inheritDoc} - * @since 1.8 */ @Override public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) { @@ -623,8 +620,6 @@ * * @return an object representing the return type of the method * or constructor represented by this {@code Executable} - * - * @since 1.8 */ public abstract AnnotatedType getAnnotatedReturnType(); @@ -633,8 +628,6 @@ * Returns an AnnotatedType object that represents the use of a type to * specify the return type of the method/constructor represented by this * Executable. - * - * @since 1.8 */ AnnotatedType getAnnotatedReturnType0(Type returnType) { return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(), @@ -664,8 +657,6 @@ * * @return an object representing the receiver type of the method or * constructor represented by this {@code Executable} - * - * @since 1.8 */ public AnnotatedType getAnnotatedReceiverType() { if (Modifier.isStatic(this.getModifiers())) @@ -692,8 +683,6 @@ * @return an array of objects representing the types of the * formal parameters of the method or constructor represented by this * {@code Executable} - * - * @since 1.8 */ public AnnotatedType[] getAnnotatedParameterTypes() { return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes0(), @@ -718,8 +707,6 @@ * @return an array of objects representing the declared * exceptions of the method or constructor represented by this {@code * Executable} - * - * @since 1.8 */ public AnnotatedType[] getAnnotatedExceptionTypes() { return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes0(),
--- a/src/share/classes/java/lang/reflect/Method.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/lang/reflect/Method.java Thu Dec 03 13:27:36 2015 -0800 @@ -266,6 +266,7 @@ /** * {@inheritDoc} + * @since 1.8 */ public int getParameterCount() { return parameterTypes.length; }
--- a/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,6 @@ return null; } }); - init(); } /** @@ -364,6 +363,5 @@ return connectDisabled; } - native int dataAvailable(); - private static native void init(); + abstract int dataAvailable(); }
--- a/src/share/classes/java/net/URL.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/net/URL.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,10 @@ import java.io.IOException; import java.io.InputStream; +import java.io.InvalidObjectException; +import java.io.ObjectStreamException; +import java.io.ObjectStreamField; +import java.io.ObjectInputStream.GetField; import java.util.Hashtable; import java.util.StringTokenizer; import sun.security.util.SecurityConstants; @@ -135,6 +139,7 @@ */ public final class URL implements java.io.Serializable { + static final String BUILTIN_HANDLERS_PREFIX = "sun.net.www.protocol"; static final long serialVersionUID = -7627629688361524110L; /** @@ -219,6 +224,8 @@ */ private int hashCode = -1; + private transient UrlDeserializedState tempState; + /** * Creates a {@code URL} object from the specified * {@code protocol}, {@code host}, {@code port} @@ -1220,6 +1227,31 @@ } /** + * @serialField protocol String + * + * @serialField host String + * + * @serialField port int + * + * @serialField authority String + * + * @serialField file String + * + * @serialField ref String + * + * @serialField hashCode int + * + */ + private static final ObjectStreamField[] serialPersistentFields = { + new ObjectStreamField("protocol", String.class), + new ObjectStreamField("host", String.class), + new ObjectStreamField("port", int.class), + new ObjectStreamField("authority", String.class), + new ObjectStreamField("file", String.class), + new ObjectStreamField("ref", String.class), + new ObjectStreamField("hashCode", int.class), }; + + /** * WriteObject is called to save the state of the URL to an * ObjectOutputStream. The handler is not saved since it is * specific to this system. @@ -1241,16 +1273,67 @@ * stream handler. */ private synchronized void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException - { - s.defaultReadObject(); // read the fields - if ((handler = getURLStreamHandler(protocol)) == null) { + throws IOException, ClassNotFoundException { + GetField gf = s.readFields(); + String protocol = (String)gf.get("protocol", null); + if (getURLStreamHandler(protocol) == null) { throw new IOException("unknown protocol: " + protocol); } + String host = (String)gf.get("host", null); + int port = gf.get("port", -1); + String authority = (String)gf.get("authority", null); + String file = (String)gf.get("file", null); + String ref = (String)gf.get("ref", null); + int hashCode = gf.get("hashCode", -1); + if (authority == null + && ((host != null && host.length() > 0) || port != -1)) { + if (host == null) + host = ""; + authority = (port == -1) ? host : host + ":" + port; + } + tempState = new UrlDeserializedState(protocol, host, port, authority, + file, ref, hashCode); + } + + /** + * Replaces the de-serialized object with an URL object. + * + * @return a newly created object from the deserialzed state. + * + * @throws ObjectStreamException if a new object replacing this + * object could not be created + */ + + private Object readResolve() throws ObjectStreamException { + + URLStreamHandler handler = null; + // already been checked in readObject + handler = getURLStreamHandler(tempState.getProtocol()); + + URL replacementURL = null; + if (isBuiltinStreamHandler(handler.getClass().getName())) { + replacementURL = fabricateNewURL(); + } else { + replacementURL = setDeserializedFields(handler); + } + return replacementURL; + } + + private URL setDeserializedFields(URLStreamHandler handler) { + URL replacementURL; + String userInfo = null; + String protocol = tempState.getProtocol(); + String host = tempState.getHost(); + int port = tempState.getPort(); + String authority = tempState.getAuthority(); + String file = tempState.getFile(); + String ref = tempState.getRef(); + int hashCode = tempState.getHashCode(); + // Construct authority part - if (authority == null && - ((host != null && host.length() > 0) || port != -1)) { + if (authority == null + && ((host != null && host.length() > 0) || port != -1)) { if (host == null) host = ""; authority = (port == -1) ? host : host + ":" + port; @@ -1269,8 +1352,8 @@ } // Construct path and query part - path = null; - query = null; + String path = null; + String query = null; if (file != null) { // Fix: only do this if hierarchical? int q = file.lastIndexOf('?'); @@ -1280,6 +1363,67 @@ } else path = file; } + + if (port == -1) { + port = 0; + } + // Set the object fields. + this.protocol = protocol; + this.host = host; + this.port = port; + this.file = file; + this.authority = authority; + this.ref = ref; + this.hashCode = hashCode; + this.handler = handler; + this.query = query; + this.path = path; + this.userInfo = userInfo; + replacementURL = this; + return replacementURL; + } + + private URL fabricateNewURL() + throws InvalidObjectException { + // create URL string from deserialized object + URL replacementURL = null; + String urlString = tempState.reconstituteUrlString(); + + try { + replacementURL = new URL(urlString); + } catch (MalformedURLException mEx) { + resetState(); + InvalidObjectException invoEx = new InvalidObjectException( + "Malformed URL: " + urlString); + invoEx.initCause(mEx); + throw invoEx; + } + replacementURL.setSerializedHashCode(tempState.getHashCode()); + resetState(); + return replacementURL; + } + + private boolean isBuiltinStreamHandler(String handlerClassName) { + return (handlerClassName.startsWith(BUILTIN_HANDLERS_PREFIX)); + } + + private void resetState() { + this.protocol = null; + this.host = null; + this.port = -1; + this.file = null; + this.authority = null; + this.ref = null; + this.hashCode = -1; + this.handler = null; + this.query = null; + this.path = null; + this.userInfo = null; + this.tempState = null; + } + + private void setSerializedHashCode(int hc) { + this.hashCode = hc; } } @@ -1311,3 +1455,82 @@ return ref; } } + +final class UrlDeserializedState { + private final String protocol; + private final String host; + private final int port; + private final String authority; + private final String file; + private final String ref; + private final int hashCode; + + public UrlDeserializedState(String protocol, + String host, int port, + String authority, String file, + String ref, int hashCode) { + this.protocol = protocol; + this.host = host; + this.port = port; + this.authority = authority; + this.file = file; + this.ref = ref; + this.hashCode = hashCode; + } + + String getProtocol() { + return protocol; + } + + String getHost() { + return host; + } + + String getAuthority () { + return authority; + } + + int getPort() { + return port; + } + + String getFile () { + return file; + } + + String getRef () { + return ref; + } + + int getHashCode () { + return hashCode; + } + + String reconstituteUrlString() { + + // pre-compute length of StringBuilder + int len = protocol.length() + 1; + if (authority != null && authority.length() > 0) + len += 2 + authority.length(); + if (file != null) { + len += file.length(); + } + if (ref != null) + len += 1 + ref.length(); + StringBuilder result = new StringBuilder(len); + result.append(protocol); + result.append(":"); + if (authority != null && authority.length() > 0) { + result.append("//"); + result.append(authority); + } + if (file != null) { + result.append(file); + } + if (ref != null) { + result.append("#"); + result.append(ref); + } + return result.toString(); + } +}
--- a/src/share/classes/java/nio/Bits.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/nio/Bits.java Thu Dec 03 13:27:36 2015 -0800 @@ -26,6 +26,11 @@ package java.nio; import java.security.AccessController; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.LongAdder; + +import sun.misc.JavaLangRefAccess; +import sun.misc.SharedSecrets; import sun.misc.Unsafe; import sun.misc.VM; @@ -621,55 +626,103 @@ // direct buffer memory. This value may be changed during VM // initialization if it is launched with "-XX:MaxDirectMemorySize=<size>". private static volatile long maxMemory = VM.maxDirectMemory(); - private static volatile long reservedMemory; - private static volatile long totalCapacity; - private static volatile long count; - private static boolean memoryLimitSet = false; + private static final AtomicLong reservedMemory = new AtomicLong(); + private static final AtomicLong totalCapacity = new AtomicLong(); + private static final AtomicLong count = new AtomicLong(); + private static volatile boolean memoryLimitSet = false; + // max. number of sleeps during try-reserving with exponentially + // increasing delay before throwing OutOfMemoryError: + // 1, 2, 4, 8, 16, 32, 64, 128, 256 (total 511 ms ~ 0.5 s) + // which means that OOME will be thrown after 0.5 s of trying + private static final int MAX_SLEEPS = 9; // These methods should be called whenever direct memory is allocated or // freed. They allow the user to control the amount of direct memory // which a process may access. All sizes are specified in bytes. static void reserveMemory(long size, int cap) { - synchronized (Bits.class) { - if (!memoryLimitSet && VM.isBooted()) { - maxMemory = VM.maxDirectMemory(); - memoryLimitSet = true; - } - // -XX:MaxDirectMemorySize limits the total capacity rather than the - // actual memory usage, which will differ when buffers are page - // aligned. - if (cap <= maxMemory - totalCapacity) { - reservedMemory += size; - totalCapacity += cap; - count++; + + if (!memoryLimitSet && VM.isBooted()) { + maxMemory = VM.maxDirectMemory(); + memoryLimitSet = true; + } + + // optimist! + if (tryReserveMemory(size, cap)) { + return; + } + + final JavaLangRefAccess jlra = SharedSecrets.getJavaLangRefAccess(); + + // retry while helping enqueue pending Reference objects + // which includes executing pending Cleaner(s) which includes + // Cleaner(s) that free direct buffer memory + while (jlra.tryHandlePendingReference()) { + if (tryReserveMemory(size, cap)) { return; } } + // trigger VM's Reference processing System.gc(); + + // a retry loop with exponential back-off delays + // (this gives VM some time to do it's job) + boolean interrupted = false; try { - Thread.sleep(100); - } catch (InterruptedException x) { - // Restore interrupt status - Thread.currentThread().interrupt(); + long sleepTime = 1; + int sleeps = 0; + while (true) { + if (tryReserveMemory(size, cap)) { + return; + } + if (sleeps >= MAX_SLEEPS) { + break; + } + if (!jlra.tryHandlePendingReference()) { + try { + Thread.sleep(sleepTime); + sleepTime <<= 1; + sleeps++; + } catch (InterruptedException e) { + interrupted = true; + } + } + } + + // no luck + throw new OutOfMemoryError("Direct buffer memory"); + + } finally { + if (interrupted) { + // don't swallow interrupts + Thread.currentThread().interrupt(); + } } - synchronized (Bits.class) { - if (totalCapacity + cap > maxMemory) - throw new OutOfMemoryError("Direct buffer memory"); - reservedMemory += size; - totalCapacity += cap; - count++; + } + + private static boolean tryReserveMemory(long size, int cap) { + + // -XX:MaxDirectMemorySize limits the total capacity rather than the + // actual memory usage, which will differ when buffers are page + // aligned. + long totalCap; + while (cap <= maxMemory - (totalCap = totalCapacity.get())) { + if (totalCapacity.compareAndSet(totalCap, totalCap + cap)) { + reservedMemory.addAndGet(size); + count.incrementAndGet(); + return true; + } } + return false; } - static synchronized void unreserveMemory(long size, int cap) { - if (reservedMemory > 0) { - reservedMemory -= size; - totalCapacity -= cap; - count--; - assert (reservedMemory > -1); - } + + static void unreserveMemory(long size, int cap) { + long cnt = count.decrementAndGet(); + long reservedMem = reservedMemory.addAndGet(-size); + long totalCap = totalCapacity.addAndGet(-cap); + assert cnt >= 0 && reservedMem >= 0 && totalCap >= 0; } // -- Monitoring of direct buffer usage -- @@ -687,15 +740,15 @@ } @Override public long getCount() { - return Bits.count; + return Bits.count.get(); } @Override public long getTotalCapacity() { - return Bits.totalCapacity; + return Bits.totalCapacity.get(); } @Override public long getMemoryUsed() { - return Bits.reservedMemory; + return Bits.reservedMemory.get(); } }; }
--- a/src/share/classes/java/text/SimpleDateFormat.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/text/SimpleDateFormat.java Thu Dec 03 13:27:36 2015 -0800 @@ -1722,7 +1722,7 @@ } return (start + zoneNames[nameIndex].length()); } - return 0; + return -start; } /**
--- a/src/share/classes/java/time/Instant.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/time/Instant.java Thu Dec 03 13:27:36 2015 -0800 @@ -1229,8 +1229,14 @@ * @throws ArithmeticException if numeric overflow occurs */ public long toEpochMilli() { - long millis = Math.multiplyExact(seconds, 1000); - return millis + nanos / 1000_000; + if (seconds < 0 && nanos > 0) { + long millis = Math.multiplyExact(seconds+1, 1000); + long adjustment = nanos / 1000_000 - 1000; + return Math.addExact(millis, adjustment); + } else { + long millis = Math.multiplyExact(seconds, 1000); + return Math.addExact(millis, nanos / 1000_000); + } } //-----------------------------------------------------------------------
--- a/src/share/classes/java/time/chrono/ChronoLocalDate.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/time/chrono/ChronoLocalDate.java Thu Dec 03 13:27:36 2015 -0800 @@ -715,7 +715,7 @@ * only compares the underlying date and not the chronology. * This allows dates in different calendar systems to be compared based * on the time-line position. - * This is equivalent to using {@code date1.toEpochDay() > date2.toEpochDay()}. + * This is equivalent to using {@code date1.toEpochDay() > date2.toEpochDay()}. * <p> * This default implementation performs the comparison based on the epoch-day. * @@ -733,7 +733,7 @@ * only compares the underlying date and not the chronology. * This allows dates in different calendar systems to be compared based * on the time-line position. - * This is equivalent to using {@code date1.toEpochDay() < date2.toEpochDay()}. + * This is equivalent to using {@code date1.toEpochDay() < date2.toEpochDay()}. * <p> * This default implementation performs the comparison based on the epoch-day. *
--- a/src/share/classes/java/util/zip/Deflater.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/util/zip/Deflater.java Thu Dec 03 13:27:36 2015 -0800 @@ -318,7 +318,9 @@ * should be called in order to provide more input */ public boolean needsInput() { - return len <= 0; + synchronized (zsRef) { + return len <= 0; + } } /**
--- a/src/share/classes/java/util/zip/ZStreamRef.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/util/zip/ZStreamRef.java Thu Dec 03 13:27:36 2015 -0800 @@ -31,7 +31,7 @@ class ZStreamRef { - private long address; + private volatile long address; ZStreamRef (long address) { this.address = address; }
--- a/src/share/classes/java/util/zip/ZipFile.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/java/util/zip/ZipFile.java Thu Dec 03 13:27:36 2015 -0800 @@ -58,7 +58,7 @@ */ public class ZipFile implements ZipConstants, Closeable { - private long jzfile; // address of jzfile data + private long jzfile; // address of jzfile data private final String name; // zip file name private final int total; // total number of entries private final boolean locsig; // if zip file starts with LOCSIG (usually true) @@ -685,7 +685,7 @@ * (possibly compressed) zip file entry. */ private class ZipFileInputStream extends InputStream { - private volatile boolean closeRequested = false; + private volatile boolean zfisCloseRequested = false; protected long jzentry; // address of jzentry data private long pos; // current position within entry data protected long rem; // number of remaining bytes within entry @@ -712,6 +712,7 @@ len = (int) rem; } + // Check if ZipFile open ensureOpenOrZipException(); len = ZipFile.read(ZipFile.this.jzfile, jzentry, pos, b, off, len); @@ -755,9 +756,9 @@ } public void close() { - if (closeRequested) + if (zfisCloseRequested) return; - closeRequested = true; + zfisCloseRequested = true; rem = 0; synchronized (ZipFile.this) {
--- a/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -361,7 +361,6 @@ "connectionId=" + connectionId +", className=" + className +", name=" + name - +", params=" + objects(values) +", signature=" + strings(signature)); return (ObjectInstance) @@ -427,7 +426,6 @@ +", className=" + className +", name=" + name +", loaderName=" + loaderName - +", params=" + objects(values) +", signature=" + strings(signature)); return (ObjectInstance) @@ -719,7 +717,7 @@ if (debug) logger.debug("setAttribute", "connectionId=" + connectionId +", name="+name - +", attribute="+attr); + +", attribute name="+attr.getName()); doPrivilegedOperation( SET_ATTRIBUTE, @@ -770,7 +768,7 @@ if (debug) logger.debug("setAttributes", "connectionId=" + connectionId +", name="+name - +", attributes="+attrlist); + +", attribute names="+RMIConnector.getAttributesNames(attrlist)); return (AttributeList) doPrivilegedOperation( @@ -825,7 +823,6 @@ "connectionId=" + connectionId +", name="+name +", operationName="+operationName - +", params="+objects(values) +", signature="+strings(signature)); return
--- a/src/share/classes/javax/management/remote/rmi/RMIConnector.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/javax/management/remote/rmi/RMIConnector.java Thu Dec 03 13:27:36 2015 -0800 @@ -41,7 +41,6 @@ import java.io.ObjectInputStream; import java.io.ObjectStreamClass; import java.io.Serializable; -import java.io.WriteAbortedException; import java.lang.ref.WeakReference; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; @@ -70,6 +69,7 @@ import java.util.Properties; import java.util.Set; import java.util.WeakHashMap; +import java.util.stream.Collectors; import javax.management.Attribute; import javax.management.AttributeList; import javax.management.AttributeNotFoundException; @@ -712,9 +712,7 @@ if (logger.debugOn()) logger.debug("createMBean(String,ObjectName,Object[],String[])", "className=" + className + ", name=" - + name + ", params=" - + objects(params) + ", signature=" - + strings(signature)); + + name + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = new MarshalledObject<Object[]>(params); @@ -753,8 +751,7 @@ if (logger.debugOn()) logger.debug( "createMBean(String,ObjectName,ObjectName,Object[],String[])", "className=" + className + ", name=" + name + ", loaderName=" - + loaderName + ", params=" + objects(params) - + ", signature=" + strings(signature)); + + loaderName + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = new MarshalledObject<Object[]>(params); @@ -954,8 +951,8 @@ IOException { if (logger.debugOn()) logger.debug("setAttribute", - "name=" + name + ", attribute=" - + attribute); + "name=" + name + ", attribute name=" + + attribute.getName()); final MarshalledObject<Attribute> sAttribute = new MarshalledObject<Attribute>(attribute); @@ -977,9 +974,11 @@ ReflectionException, IOException { - if (logger.debugOn()) logger.debug("setAttributes", - "name=" + name + ", attributes=" - + attributes); + if (logger.debugOn()) { + logger.debug("setAttributes", + "name=" + name + ", attribute names=" + + getAttributesNames(attributes)); + } final MarshalledObject<AttributeList> sAttributes = new MarshalledObject<AttributeList>(attributes); @@ -1012,7 +1011,6 @@ if (logger.debugOn()) logger.debug("invoke", "name=" + name + ", operationName=" + operationName - + ", params=" + objects(params) + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = @@ -2636,4 +2634,12 @@ private static String strings(final String[] strs) { return objects(strs); } + + static String getAttributesNames(AttributeList attributes) { + return attributes != null ? + attributes.asList().stream() + .map(Attribute::getName) + .collect(Collectors.joining("[", ", ", "]")) + : "[]"; + } }
--- a/src/share/classes/javax/swing/event/ListSelectionEvent.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/javax/swing/event/ListSelectionEvent.java Thu Dec 03 13:27:36 2015 -0800 @@ -78,7 +78,7 @@ /** * Returns the index of the first row whose selection may have changed. - * {@code getFirstIndex() <= getLastIndex()} + * {@code getFirstIndex() <= getLastIndex()} * * @return the first row whose selection value may have changed, * where zero is the first row @@ -87,7 +87,7 @@ /** * Returns the index of the last row whose selection may have changed. - * {@code getLastIndex() >= getFirstIndex()} + * {@code getLastIndex() >= getFirstIndex()} * * @return the last row whose selection value may have changed, * where zero is the first row
--- a/src/share/classes/sun/applet/AppletPanel.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/applet/AppletPanel.java Thu Dec 03 13:27:36 2015 -0800 @@ -682,12 +682,7 @@ if (toFocus != null) { if (parent instanceof EmbeddedFrame) { - // JDK-8056915: Try to request focus to the embedder first and - // activate the embedded frame through it - if (!((EmbeddedFrame) parent).requestFocusToEmbedder()) { - // Otherwise activate the embedded frame directly - ((EmbeddedFrame) parent).synthesizeWindowActivation(true); - } + ((EmbeddedFrame) parent).synthesizeWindowActivation(true); } // EmbeddedFrame might have focus before the applet was added. // Thus after its activation the most recent focus owner will be
--- a/src/share/classes/sun/awt/EmbeddedFrame.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/awt/EmbeddedFrame.java Thu Dec 03 13:27:36 2015 -0800 @@ -361,15 +361,6 @@ public void synthesizeWindowActivation(boolean doActivate) {} /** - * Requests the focus to the embedder. - * - * @return {@code true} if focus request was successful, and {@code false} otherwise. - */ - public boolean requestFocusToEmbedder() { - return false; - } - - /** * Moves this embedded frame to a new location. The top-left corner of * the new location is specified by the <code>x</code> and <code>y</code> * parameters relative to the native parent component.
--- a/src/share/classes/sun/font/CompositeFont.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/font/CompositeFont.java Thu Dec 03 13:27:36 2015 -0800 @@ -71,6 +71,13 @@ } else { numSlots = componentNames.length; } + /* We will limit the number of slots to 254. + * We store the slot for a glyph id in a byte and we may use one slot + * for an EUDC font, and we may also create a composite + * using this composite as a backup for a physical font. + * So we want to leave space for the two additional slots. + */ + numSlots = (numSlots <= 254) ? numSlots : 254; /* Only the first "numMetricsSlots" slots are used for font metrics. * the rest are considered "fallback" slots".
--- a/src/share/classes/sun/font/FileFontStrike.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/font/FileFontStrike.java Thu Dec 03 13:27:36 2015 -0800 @@ -420,14 +420,13 @@ /* The following method is called from CompositeStrike as a special case. */ - private static final int SLOTZEROMAX = 0xffffff; int getSlot0GlyphImagePtrs(int[] glyphCodes, long[] images, int len) { int convertedCnt = 0; for (int i=0; i<len; i++) { int glyphCode = glyphCodes[i]; - if (glyphCode >= SLOTZEROMAX) { + if (glyphCode >>> 24 != 0) { return convertedCnt; } else { convertedCnt++;
--- a/src/share/classes/sun/invoke/util/BytecodeName.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/invoke/util/BytecodeName.java Thu Dec 03 13:27:36 2015 -0800 @@ -295,7 +295,7 @@ * (The safe name might possibly be mangled to hide further dangerous characters.) * For example, the qualified class name {@code java/lang/String} * will be parsed into the array {@code {"java", '/', "lang", '/', "String"}}. - * The name {@code <init>} will be parsed into { '<', "init", '>'}} + * The name {@code <init>} will be parsed into {@code {'<', "init", '>'}}. * The name {@code foo/bar$:baz} will be parsed into * {@code {"foo", '/', "bar", '$', ':', "baz"}}. * The name {@code ::\=:foo:\=bar\!baz} will be parsed into
--- a/src/share/classes/sun/management/GarbageCollectorImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/management/GarbageCollectorImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -102,17 +102,13 @@ GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION }; - private MBeanNotificationInfo[] notifInfo = null; + @Override public MBeanNotificationInfo[] getNotificationInfo() { - synchronized (this) { - if (notifInfo == null) { - notifInfo = new MBeanNotificationInfo[1]; - notifInfo[0] = new MBeanNotificationInfo(gcNotifTypes, - notifName, - "GC Notification"); - } - } - return notifInfo; + return new MBeanNotificationInfo[]{ + new MBeanNotificationInfo(gcNotifTypes, + notifName, + "GC Notification") + }; } private static long seqNumber = 0;
--- a/src/share/classes/sun/management/MemoryImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/management/MemoryImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -115,17 +115,10 @@ "Memory usage exceeds collection usage threshold" }; - private MBeanNotificationInfo[] notifInfo = null; public MBeanNotificationInfo[] getNotificationInfo() { - synchronized (this) { - if (notifInfo == null) { - notifInfo = new MBeanNotificationInfo[1]; - notifInfo[0] = new MBeanNotificationInfo(notifTypes, - notifName, - "Memory Notification"); - } - } - return notifInfo; + return new MBeanNotificationInfo[] { + new MBeanNotificationInfo(notifTypes, notifName, "Memory Notification") + }; } private static String getNotifMsg(String notifType) {
--- a/src/share/classes/sun/management/ThreadImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/management/ThreadImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -165,6 +165,10 @@ "Invalid maxDepth parameter: " + maxDepth); } + // ids has been verified to be non-null + // an empty array of ids should return an empty array of ThreadInfos + if (ids.length == 0) return new ThreadInfo[0]; + Util.checkMonitorAccess(); ThreadInfo[] infos = new ThreadInfo[ids.length]; // nulls @@ -436,6 +440,10 @@ boolean lockedMonitors, boolean lockedSynchronizers) { verifyThreadIds(ids); + // ids has been verified to be non-null + // an empty array of ids should return an empty array of ThreadInfos + if (ids.length == 0) return new ThreadInfo[0]; + verifyDumpThreads(lockedMonitors, lockedSynchronizers); return dumpThreads0(ids, lockedMonitors, lockedSynchronizers); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/misc/JavaLangRefAccess.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,39 @@ +/* + * 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.misc; + +public interface JavaLangRefAccess { + + /** + * Help ReferenceHandler thread process next pending + * {@link java.lang.ref.Reference} + * + * @return {@code true} if there was a pending reference and it + * was enqueue-ed or {@code false} if there was no + * pending reference + */ + boolean tryHandlePendingReference(); +}
--- a/src/share/classes/sun/misc/SharedSecrets.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/misc/SharedSecrets.java Thu Dec 03 13:27:36 2015 -0800 @@ -45,6 +45,7 @@ private static final Unsafe unsafe = Unsafe.getUnsafe(); private static JavaUtilJarAccess javaUtilJarAccess; private static JavaLangAccess javaLangAccess; + private static JavaLangRefAccess javaLangRefAccess; private static JavaIOAccess javaIOAccess; private static JavaNetAccess javaNetAccess; private static JavaNetHttpCookieAccess javaNetHttpCookieAccess; @@ -76,6 +77,14 @@ return javaLangAccess; } + public static void setJavaLangRefAccess(JavaLangRefAccess jlra) { + javaLangRefAccess = jlra; + } + + public static JavaLangRefAccess getJavaLangRefAccess() { + return javaLangRefAccess; + } + public static void setJavaNetAccess(JavaNetAccess jna) { javaNetAccess = jna; }
--- a/src/share/classes/sun/net/util/IPAddressUtil.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/net/util/IPAddressUtil.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,7 @@ long tmpValue = 0; int currByte = 0; + boolean newOctet = true; int len = src.length(); if (len == 0 || len > 15) { @@ -77,11 +78,12 @@ for (int i = 0; i < len; i++) { char c = src.charAt(i); if (c == '.') { - if (tmpValue < 0 || tmpValue > 0xff || currByte == 3) { + if (newOctet || tmpValue < 0 || tmpValue > 0xff || currByte == 3) { return null; } res[currByte++] = (byte) (tmpValue & 0xff); tmpValue = 0; + newOctet = true; } else { int digit = Character.digit(c, 10); if (digit < 0) { @@ -89,9 +91,10 @@ } tmpValue *= 10; tmpValue += digit; + newOctet = false; } } - if (tmpValue < 0 || tmpValue >= (1L << ((4 - currByte) * 8))) { + if (newOctet || tmpValue < 0 || tmpValue >= (1L << ((4 - currByte) * 8))) { return null; } switch (currByte) {
--- a/src/share/classes/sun/nio/ch/FileChannelImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/nio/ch/FileChannelImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -328,6 +328,7 @@ int rv = -1; long p = -1; int ti = -1; + long rp = -1; try { begin(); ti = threads.add(); @@ -363,8 +364,8 @@ if (p > newSize) p = newSize; do { - rv = (int)position0(fd, p); - } while ((rv == IOStatus.INTERRUPTED) && isOpen()); + rp = position0(fd, p); + } while ((rp == IOStatus.INTERRUPTED) && isOpen()); return this; } finally { threads.remove(ti);
--- a/src/share/classes/sun/security/jca/JCAUtil.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/jca/JCAUtil.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,12 +41,6 @@ // no instantiation } - // lock to use for synchronization - private static final Object LOCK = JCAUtil.class; - - // cached SecureRandom instance - private static volatile SecureRandom secureRandom; - // size of the temporary arrays we use. Should fit into the CPU's 1st // level cache and could be adjusted based on the platform private final static int ARRAY_SIZE = 4096; @@ -60,26 +54,19 @@ return Math.min(ARRAY_SIZE, totalSize); } + // cached SecureRandom instance + private static class CachedSecureRandomHolder { + public static SecureRandom instance = new SecureRandom(); + } + /** - * Get a SecureRandom instance. This method should me used by JDK + * Get a SecureRandom instance. This method should be used by JDK * internal code in favor of calling "new SecureRandom()". That needs to * iterate through the provider table to find the default SecureRandom * implementation, which is fairly inefficient. */ public static SecureRandom getSecureRandom() { - // we use double checked locking to minimize synchronization - // works because we use a volatile reference - SecureRandom r = secureRandom; - if (r == null) { - synchronized (LOCK) { - r = secureRandom; - if (r == null) { - r = new SecureRandom(); - secureRandom = r; - } - } - } - return r; + return CachedSecureRandomHolder.instance; } }
--- a/src/share/classes/sun/security/pkcs11/P11Cipher.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/pkcs11/P11Cipher.java Thu Dec 03 13:27:36 2015 -0800 @@ -35,6 +35,7 @@ import javax.crypto.spec.*; import sun.nio.ch.DirectBuffer; +import sun.security.jca.JCAUtil; import sun.security.pkcs11.wrapper.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*; @@ -379,7 +380,7 @@ } // generate random IV if (random == null) { - random = new SecureRandom(); + random = JCAUtil.getSecureRandom(); } iv = new byte[blockSize]; random.nextBytes(iv);
--- a/src/share/classes/sun/security/pkcs11/P11RSACipher.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/pkcs11/P11RSACipher.java Thu Dec 03 13:27:36 2015 -0800 @@ -468,49 +468,49 @@ algorithm.equals("TlsRsaPremasterSecret"); Exception failover = null; - SecureRandom secureRandom = random; - if (secureRandom == null && isTlsRsaPremasterSecret) { - secureRandom = new SecureRandom(); - } - // Should C_Unwrap be preferred for non-TLS RSA premaster secret? if (token.supportsRawSecretKeyImport()) { // XXX implement unwrap using C_Unwrap() for all keys implInit(Cipher.DECRYPT_MODE, p11Key); - if (wrappedKey.length > maxInputSize) { - throw new InvalidKeyException("Key is too long for unwrapping"); - } + try { + if (wrappedKey.length > maxInputSize) { + throw new InvalidKeyException("Key is too long for unwrapping"); + } - byte[] encoded = null; - implUpdate(wrappedKey, 0, wrappedKey.length); - try { - encoded = doFinal(); - } catch (BadPaddingException e) { - if (isTlsRsaPremasterSecret) { - failover = e; - } else { + byte[] encoded = null; + implUpdate(wrappedKey, 0, wrappedKey.length); + try { + encoded = doFinal(); + } catch (BadPaddingException e) { + if (isTlsRsaPremasterSecret) { + failover = e; + } else { + throw new InvalidKeyException("Unwrapping failed", e); + } + } catch (IllegalBlockSizeException e) { + // should not occur, handled with length check above throw new InvalidKeyException("Unwrapping failed", e); } - } catch (IllegalBlockSizeException e) { - // should not occur, handled with length check above - throw new InvalidKeyException("Unwrapping failed", e); - } + + if (isTlsRsaPremasterSecret) { + if (!(spec instanceof TlsRsaPremasterSecretParameterSpec)) { + throw new IllegalStateException( + "No TlsRsaPremasterSecretParameterSpec specified"); + } - if (isTlsRsaPremasterSecret) { - if (!(spec instanceof TlsRsaPremasterSecretParameterSpec)) { - throw new IllegalStateException( - "No TlsRsaPremasterSecretParameterSpec specified"); + // polish the TLS premaster secret + TlsRsaPremasterSecretParameterSpec psps = + (TlsRsaPremasterSecretParameterSpec)spec; + encoded = KeyUtil.checkTlsPreMasterSecretKey( + psps.getClientVersion(), psps.getServerVersion(), + random, encoded, (failover != null)); } - // polish the TLS premaster secret - TlsRsaPremasterSecretParameterSpec psps = - (TlsRsaPremasterSecretParameterSpec)spec; - encoded = KeyUtil.checkTlsPreMasterSecretKey( - psps.getClientVersion(), psps.getServerVersion(), - secureRandom, encoded, (failover != null)); + return ConstructKeys.constructKey(encoded, algorithm, type); + } finally { + // Restore original mode + implInit(Cipher.UNWRAP_MODE, p11Key); } - - return ConstructKeys.constructKey(encoded, algorithm, type); } else { Session s = null; SecretKey secretKey = null; @@ -538,20 +538,13 @@ } if (isTlsRsaPremasterSecret) { - byte[] replacer = new byte[48]; - if (failover == null) { - // Does smart compiler dispose this operation? - secureRandom.nextBytes(replacer); - } - TlsRsaPremasterSecretParameterSpec psps = (TlsRsaPremasterSecretParameterSpec)spec; - // Please use the tricky failover and replacer byte array - // as the parameters so that smart compiler won't dispose - // the unused variable . + // Please use the tricky failover as the parameter so that + // smart compiler won't dispose the unused variable. secretKey = polishPreMasterSecretKey(token, s, - failover, replacer, secretKey, + failover, secretKey, psps.getClientVersion(), psps.getServerVersion()); } @@ -570,29 +563,27 @@ private static SecretKey polishPreMasterSecretKey( Token token, Session session, - Exception failover, byte[] replacer, SecretKey secretKey, + Exception failover, SecretKey unwrappedKey, int clientVersion, int serverVersion) { - if (failover != null) { - CK_VERSION version = new CK_VERSION( - (clientVersion >>> 8) & 0xFF, clientVersion & 0xFF); - try { - CK_ATTRIBUTE[] attributes = token.getAttributes( - O_GENERATE, CKO_SECRET_KEY, - CKK_GENERIC_SECRET, new CK_ATTRIBUTE[0]); - long keyID = token.p11.C_GenerateKey(session.id(), - // new CK_MECHANISM(CKM_TLS_PRE_MASTER_KEY_GEN, version), - new CK_MECHANISM(CKM_SSL3_PRE_MASTER_KEY_GEN, version), - attributes); - return P11Key.secretKey(session, - keyID, "TlsRsaPremasterSecret", 48 << 3, attributes); - } catch (PKCS11Exception e) { - throw new ProviderException( - "Could not generate premaster secret", e); - } + SecretKey newKey; + CK_VERSION version = new CK_VERSION( + (clientVersion >>> 8) & 0xFF, clientVersion & 0xFF); + try { + CK_ATTRIBUTE[] attributes = token.getAttributes( + O_GENERATE, CKO_SECRET_KEY, + CKK_GENERIC_SECRET, new CK_ATTRIBUTE[0]); + long keyID = token.p11.C_GenerateKey(session.id(), + new CK_MECHANISM(CKM_SSL3_PRE_MASTER_KEY_GEN, version), + attributes); + newKey = P11Key.secretKey(session, + keyID, "TlsRsaPremasterSecret", 48 << 3, attributes); + } catch (PKCS11Exception e) { + throw new ProviderException( + "Could not generate premaster secret", e); } - return secretKey; + return (failover == null) ? unwrappedKey : newKey; } }
--- a/src/share/classes/sun/security/provider/KeyStoreDelegator.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/provider/KeyStoreDelegator.java Thu Dec 03 13:27:36 2015 -0800 @@ -216,57 +216,55 @@ } else { // First try the primary keystore then try the secondary keystore - try (InputStream bufferedStream = new BufferedInputStream(stream)) { - bufferedStream.mark(Integer.MAX_VALUE); + InputStream bufferedStream = new BufferedInputStream(stream); + bufferedStream.mark(Integer.MAX_VALUE); + try { + keystore = primaryKeyStore.newInstance(); + type = primaryType; + keystore.engineLoad(bufferedStream, password); + + } catch (Exception e) { + + // incorrect password + if (e instanceof IOException && + e.getCause() instanceof UnrecoverableKeyException) { + throw (IOException)e; + } try { - keystore = primaryKeyStore.newInstance(); - type = primaryType; + keystore = secondaryKeyStore.newInstance(); + type = secondaryType; + bufferedStream.reset(); keystore.engineLoad(bufferedStream, password); - } catch (Exception e) { - - // incorrect password - if (e instanceof IOException && - e.getCause() instanceof UnrecoverableKeyException) { - throw (IOException)e; + if (debug != null) { + debug.println("WARNING: switching from " + + primaryType + " to " + secondaryType + + " keystore file format has altered the " + + "keystore security level"); } - try { - keystore = secondaryKeyStore.newInstance(); - type = secondaryType; - bufferedStream.reset(); - keystore.engineLoad(bufferedStream, password); + } catch (InstantiationException | + IllegalAccessException e2) { + // can safely ignore - if (debug != null) { - debug.println("WARNING: switching from " + - primaryType + " to " + secondaryType + - " keystore file format has altered the " + - "keystore security level"); - } - - } catch (InstantiationException | - IllegalAccessException e2) { - // can safely ignore + } catch (IOException | + NoSuchAlgorithmException | + CertificateException e3) { - } catch (IOException | - NoSuchAlgorithmException | - CertificateException e3) { - - // incorrect password - if (e3 instanceof IOException && - e3.getCause() instanceof - UnrecoverableKeyException) { - throw (IOException)e3; - } - // rethrow the outer exception - if (e instanceof IOException) { - throw (IOException)e; - } else if (e instanceof CertificateException) { - throw (CertificateException)e; - } else if (e instanceof NoSuchAlgorithmException) { - throw (NoSuchAlgorithmException)e; - } + // incorrect password + if (e3 instanceof IOException && + e3.getCause() instanceof + UnrecoverableKeyException) { + throw (IOException)e3; + } + // rethrow the outer exception + if (e instanceof IOException) { + throw (IOException)e; + } else if (e instanceof CertificateException) { + throw (CertificateException)e; + } else if (e instanceof NoSuchAlgorithmException) { + throw (NoSuchAlgorithmException)e; } } }
--- a/src/share/classes/sun/security/provider/certpath/Builder.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/provider/certpath/Builder.java Thu Dec 03 13:27:36 2015 -0800 @@ -102,8 +102,8 @@ /** * Verifies whether the input certificate completes the path. - * When building forward, a trust anchor will complete the path. - * When building reverse, the target certificate will complete the path. + * When building in the forward direction, a trust anchor will + * complete the path. * * @param cert the certificate to test * @return a boolean value indicating whether the cert completes the path.
--- a/src/share/classes/sun/security/provider/certpath/PKIX.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/provider/certpath/PKIX.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ package sun.security.provider.certpath; import java.security.InvalidAlgorithmParameterException; -import java.security.KeyStore; import java.security.PublicKey; import java.security.cert.*; import java.security.interfaces.DSAPublicKey; @@ -194,7 +193,6 @@ static class BuilderParams extends ValidatorParams { private PKIXBuilderParameters params; - private boolean buildForward = true; private List<CertStore> stores; private X500Principal targetSubject; @@ -213,10 +211,6 @@ + "targetCertConstraints parameter must be an " + "X509CertSelector"); } - if (params instanceof SunCertPathBuilderParameters) { - buildForward = - ((SunCertPathBuilderParameters)params).getBuildForward(); - } this.params = params; this.targetSubject = getTargetSubject( certStores(), (X509CertSelector)targetCertConstraints()); @@ -230,7 +224,6 @@ return stores; } int maxPathLength() { return params.getMaxPathLength(); } - boolean buildForward() { return buildForward; } PKIXBuilderParameters params() { return params; } X500Principal targetSubject() { return targetSubject; }
--- a/src/share/classes/sun/security/provider/certpath/ReverseBuilder.java Thu Dec 03 10:32:59 2015 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,551 +0,0 @@ -/* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.provider.certpath; - -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.security.Principal; -import java.security.cert.CertificateException; -import java.security.cert.CertPathValidatorException; -import java.security.cert.CertStore; -import java.security.cert.CertStoreException; -import java.security.cert.PKIXBuilderParameters; -import java.security.cert.PKIXCertPathChecker; -import java.security.cert.PKIXParameters; -import java.security.cert.PKIXReason; -import java.security.cert.TrustAnchor; -import java.security.cert.X509Certificate; -import java.security.cert.X509CertSelector; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.LinkedList; -import java.util.Set; - -import javax.security.auth.x500.X500Principal; - -import sun.security.provider.certpath.PKIX.BuilderParams; -import sun.security.util.Debug; -import sun.security.x509.Extension; -import static sun.security.x509.PKIXExtensions.*; -import sun.security.x509.X500Name; -import sun.security.x509.X509CertImpl; -import sun.security.x509.PolicyMappingsExtension; - -/** - * This class represents a reverse builder, which is able to retrieve - * matching certificates from CertStores and verify a particular certificate - * against a ReverseState. - * - * @since 1.4 - * @author Sean Mullan - * @author Yassir Elley - */ - -class ReverseBuilder extends Builder { - - private Debug debug = Debug.getInstance("certpath"); - - private final Set<String> initPolicies; - - /** - * Initialize the builder with the input parameters. - * - * @param params the parameter set used to build a certification path - */ - ReverseBuilder(BuilderParams buildParams) { - super(buildParams); - - Set<String> initialPolicies = buildParams.initialPolicies(); - initPolicies = new HashSet<String>(); - if (initialPolicies.isEmpty()) { - // if no initialPolicies are specified by user, set - // initPolicies to be anyPolicy by default - initPolicies.add(PolicyChecker.ANY_POLICY); - } else { - initPolicies.addAll(initialPolicies); - } - } - - /** - * Retrieves all certs from the specified CertStores that satisfy the - * requirements specified in the parameters and the current - * PKIX state (name constraints, policy constraints, etc). - * - * @param currentState the current state. - * Must be an instance of <code>ReverseState</code> - * @param certStores list of CertStores - */ - @Override - Collection<X509Certificate> getMatchingCerts - (State currState, List<CertStore> certStores) - throws CertStoreException, CertificateException, IOException - { - ReverseState currentState = (ReverseState) currState; - - if (debug != null) - debug.println("In ReverseBuilder.getMatchingCerts."); - - /* - * The last certificate could be an EE or a CA certificate - * (we may be building a partial certification path or - * establishing trust in a CA). - * - * Try the EE certs before the CA certs. It will be more - * common to build a path to an end entity. - */ - Collection<X509Certificate> certs = - getMatchingEECerts(currentState, certStores); - certs.addAll(getMatchingCACerts(currentState, certStores)); - - return certs; - } - - /* - * Retrieves all end-entity certificates which satisfy constraints - * and requirements specified in the parameters and PKIX state. - */ - private Collection<X509Certificate> getMatchingEECerts - (ReverseState currentState, List<CertStore> certStores) - throws CertStoreException, CertificateException, IOException { - - /* - * Compose a CertSelector to filter out - * certs which do not satisfy requirements. - * - * First, retrieve clone of current target cert constraints, and - * then add more selection criteria based on current validation state. - */ - X509CertSelector sel = (X509CertSelector) targetCertConstraints.clone(); - - /* - * Match on issuer (subject of previous cert) - */ - sel.setIssuer(currentState.subjectDN); - - /* - * Match on certificate validity date. - */ - sel.setCertificateValid(buildParams.date()); - - /* - * Policy processing optimizations - */ - if (currentState.explicitPolicy == 0) - sel.setPolicy(getMatchingPolicies()); - - /* - * If previous cert has a subject key identifier extension, - * use it to match on authority key identifier extension. - */ - /*if (currentState.subjKeyId != null) { - AuthorityKeyIdentifierExtension authKeyId = new AuthorityKeyIdentifierExtension( - (KeyIdentifier) currentState.subjKeyId.get(SubjectKeyIdentifierExtension.KEY_ID), - null, null); - sel.setAuthorityKeyIdentifier(authKeyId.getExtensionValue()); - }*/ - - /* - * Require EE certs - */ - sel.setBasicConstraints(-2); - - /* Retrieve matching certs from CertStores */ - HashSet<X509Certificate> eeCerts = new HashSet<>(); - addMatchingCerts(sel, certStores, eeCerts, true); - - if (debug != null) { - debug.println("ReverseBuilder.getMatchingEECerts got " - + eeCerts.size() + " certs."); - } - return eeCerts; - } - - /* - * Retrieves all CA certificates which satisfy constraints - * and requirements specified in the parameters and PKIX state. - */ - private Collection<X509Certificate> getMatchingCACerts - (ReverseState currentState, List<CertStore> certStores) - throws CertificateException, CertStoreException, IOException { - - /* - * Compose a CertSelector to filter out - * certs which do not satisfy requirements. - */ - X509CertSelector sel = new X509CertSelector(); - - /* - * Match on issuer (subject of previous cert) - */ - sel.setIssuer(currentState.subjectDN); - - /* - * Match on certificate validity date. - */ - sel.setCertificateValid(buildParams.date()); - - /* - * Match on target subject name (checks that current cert's - * name constraints permit it to certify target). - * (4 is the integer type for DIRECTORY name). - */ - byte[] subject = targetCertConstraints.getSubjectAsBytes(); - if (subject != null) { - sel.addPathToName(4, subject); - } else { - X509Certificate cert = targetCertConstraints.getCertificate(); - if (cert != null) { - sel.addPathToName(4, - cert.getSubjectX500Principal().getEncoded()); - } - } - - /* - * Policy processing optimizations - */ - if (currentState.explicitPolicy == 0) - sel.setPolicy(getMatchingPolicies()); - - /* - * If previous cert has a subject key identifier extension, - * use it to match on authority key identifier extension. - */ - /*if (currentState.subjKeyId != null) { - AuthorityKeyIdentifierExtension authKeyId = new AuthorityKeyIdentifierExtension( - (KeyIdentifier) currentState.subjKeyId.get(SubjectKeyIdentifierExtension.KEY_ID), - null, null); - sel.setAuthorityKeyIdentifier(authKeyId.getExtensionValue()); - }*/ - - /* - * Require CA certs - */ - sel.setBasicConstraints(0); - - /* Retrieve matching certs from CertStores */ - ArrayList<X509Certificate> reverseCerts = new ArrayList<>(); - addMatchingCerts(sel, certStores, reverseCerts, true); - - /* Sort remaining certs using name constraints */ - Collections.sort(reverseCerts, new PKIXCertComparator()); - - if (debug != null) - debug.println("ReverseBuilder.getMatchingCACerts got " + - reverseCerts.size() + " certs."); - return reverseCerts; - } - - /* - * This inner class compares 2 PKIX certificates according to which - * should be tried first when building a path to the target. For - * now, the algorithm is to look at name constraints in each cert and those - * which constrain the path closer to the target should be - * ranked higher. Later, we may want to consider other components, - * such as key identifiers. - */ - class PKIXCertComparator implements Comparator<X509Certificate> { - - private Debug debug = Debug.getInstance("certpath"); - - @Override - public int compare(X509Certificate cert1, X509Certificate cert2) { - - /* - * if either cert certifies the target, always - * put at head of list. - */ - X500Principal targetSubject = buildParams.targetSubject(); - if (cert1.getSubjectX500Principal().equals(targetSubject)) { - return -1; - } - if (cert2.getSubjectX500Principal().equals(targetSubject)) { - return 1; - } - - int targetDist1; - int targetDist2; - try { - X500Name targetSubjectName = X500Name.asX500Name(targetSubject); - targetDist1 = Builder.targetDistance( - null, cert1, targetSubjectName); - targetDist2 = Builder.targetDistance( - null, cert2, targetSubjectName); - } catch (IOException e) { - if (debug != null) { - debug.println("IOException in call to Builder.targetDistance"); - e.printStackTrace(); - } - throw new ClassCastException - ("Invalid target subject distinguished name"); - } - - if (targetDist1 == targetDist2) - return 0; - - if (targetDist1 == -1) - return 1; - - if (targetDist1 < targetDist2) - return -1; - - return 1; - } - } - - /** - * Verifies a matching certificate. - * - * This method executes any of the validation steps in the PKIX path validation - * algorithm which were not satisfied via filtering out non-compliant - * certificates with certificate matching rules. - * - * If the last certificate is being verified (the one whose subject - * matches the target subject, then the steps in Section 6.1.4 of the - * Certification Path Validation algorithm are NOT executed, - * regardless of whether or not the last cert is an end-entity - * cert or not. This allows callers to certify CA certs as - * well as EE certs. - * - * @param cert the certificate to be verified - * @param currentState the current state against which the cert is verified - * @param certPathList the certPathList generated thus far - */ - @Override - void verifyCert(X509Certificate cert, State currState, - List<X509Certificate> certPathList) - throws GeneralSecurityException - { - if (debug != null) { - debug.println("ReverseBuilder.verifyCert(SN: " - + Debug.toHexString(cert.getSerialNumber()) - + "\n Subject: " + cert.getSubjectX500Principal() + ")"); - } - - ReverseState currentState = (ReverseState) currState; - - /* we don't perform any validation of the trusted cert */ - if (currentState.isInitial()) { - return; - } - - // Don't bother to verify untrusted certificate more. - currentState.untrustedChecker.check(cert, - Collections.<String>emptySet()); - - /* - * check for looping - abort a loop if - * ((we encounter the same certificate twice) AND - * ((policyMappingInhibited = true) OR (no policy mapping - * extensions can be found between the occurrences of the same - * certificate))) - * in order to facilitate the check to see if there are - * any policy mapping extensions found between the occurrences - * of the same certificate, we reverse the certpathlist first - */ - if ((certPathList != null) && (!certPathList.isEmpty())) { - List<X509Certificate> reverseCertList = new ArrayList<>(); - for (X509Certificate c : certPathList) { - reverseCertList.add(0, c); - } - - boolean policyMappingFound = false; - for (X509Certificate cpListCert : reverseCertList) { - X509CertImpl cpListCertImpl = X509CertImpl.toImpl(cpListCert); - PolicyMappingsExtension policyMappingsExt = - cpListCertImpl.getPolicyMappingsExtension(); - if (policyMappingsExt != null) { - policyMappingFound = true; - } - if (debug != null) - debug.println("policyMappingFound = " + policyMappingFound); - if (cert.equals(cpListCert)) { - if ((buildParams.policyMappingInhibited()) || - (!policyMappingFound)){ - if (debug != null) - debug.println("loop detected!!"); - throw new CertPathValidatorException("loop detected"); - } - } - } - } - - /* check if target cert */ - boolean finalCert = cert.getSubjectX500Principal().equals(buildParams.targetSubject()); - - /* check if CA cert */ - boolean caCert = (cert.getBasicConstraints() != -1 ? true : false); - - /* if there are more certs to follow, verify certain constraints */ - if (!finalCert) { - - /* check if CA cert */ - if (!caCert) - throw new CertPathValidatorException("cert is NOT a CA cert"); - - /* If the certificate was not self-issued, verify that - * remainingCerts is greater than zero - */ - if ((currentState.remainingCACerts <= 0) && !X509CertImpl.isSelfIssued(cert)) { - throw new CertPathValidatorException - ("pathLenConstraint violated, path too long", null, - null, -1, PKIXReason.PATH_TOO_LONG); - } - - /* - * Check keyUsage extension (only if CA cert and not final cert) - */ - KeyChecker.verifyCAKeyUsage(cert); - - } else { - - /* - * If final cert, check that it satisfies specified target - * constraints - */ - if (targetCertConstraints.match(cert) == false) { - throw new CertPathValidatorException("target certificate " + - "constraints check failed"); - } - } - - /* - * Check revocation. - */ - if (buildParams.revocationEnabled() && currentState.revChecker != null) { - currentState.revChecker.check(cert, Collections.<String>emptySet()); - } - - /* Check name constraints if this is not a self-issued cert */ - if (finalCert || !X509CertImpl.isSelfIssued(cert)){ - if (currentState.nc != null) { - try { - if (!currentState.nc.verify(cert)){ - throw new CertPathValidatorException - ("name constraints check failed", null, null, -1, - PKIXReason.INVALID_NAME); - } - } catch (IOException ioe) { - throw new CertPathValidatorException(ioe); - } - } - } - - /* - * Check policy - */ - X509CertImpl certImpl = X509CertImpl.toImpl(cert); - currentState.rootNode = PolicyChecker.processPolicies - (currentState.certIndex, initPolicies, - currentState.explicitPolicy, currentState.policyMapping, - currentState.inhibitAnyPolicy, - buildParams.policyQualifiersRejected(), currentState.rootNode, - certImpl, finalCert); - - /* - * Check CRITICAL private extensions - */ - Set<String> unresolvedCritExts = cert.getCriticalExtensionOIDs(); - if (unresolvedCritExts == null) { - unresolvedCritExts = Collections.<String>emptySet(); - } - - /* - * Check that the signature algorithm is not disabled. - */ - currentState.algorithmChecker.check(cert, unresolvedCritExts); - - for (PKIXCertPathChecker checker : currentState.userCheckers) { - checker.check(cert, unresolvedCritExts); - } - - /* - * Look at the remaining extensions and remove any ones we have - * already checked. If there are any left, throw an exception! - */ - if (!unresolvedCritExts.isEmpty()) { - unresolvedCritExts.remove(BasicConstraints_Id.toString()); - unresolvedCritExts.remove(NameConstraints_Id.toString()); - unresolvedCritExts.remove(CertificatePolicies_Id.toString()); - unresolvedCritExts.remove(PolicyMappings_Id.toString()); - unresolvedCritExts.remove(PolicyConstraints_Id.toString()); - unresolvedCritExts.remove(InhibitAnyPolicy_Id.toString()); - unresolvedCritExts.remove(SubjectAlternativeName_Id.toString()); - unresolvedCritExts.remove(KeyUsage_Id.toString()); - unresolvedCritExts.remove(ExtendedKeyUsage_Id.toString()); - - if (!unresolvedCritExts.isEmpty()) - throw new CertPathValidatorException - ("Unrecognized critical extension(s)", null, null, -1, - PKIXReason.UNRECOGNIZED_CRIT_EXT); - } - - /* - * Check signature. - */ - if (buildParams.sigProvider() != null) { - cert.verify(currentState.pubKey, buildParams.sigProvider()); - } else { - cert.verify(currentState.pubKey); - } - } - - /** - * Verifies whether the input certificate completes the path. - * This checks whether the cert is the target certificate. - * - * @param cert the certificate to test - * @return a boolean value indicating whether the cert completes the path. - */ - @Override - boolean isPathCompleted(X509Certificate cert) { - return cert.getSubjectX500Principal().equals(buildParams.targetSubject()); - } - - /** Adds the certificate to the certPathList - * - * @param cert the certificate to be added - * @param certPathList the certification path list - */ - @Override - void addCertToPath(X509Certificate cert, - LinkedList<X509Certificate> certPathList) { - certPathList.addLast(cert); - } - - /** Removes final certificate from the certPathList - * - * @param certPathList the certification path list - */ - @Override - void removeFinalCertFromPath(LinkedList<X509Certificate> certPathList) { - certPathList.removeLast(); - } -}
--- a/src/share/classes/sun/security/provider/certpath/ReverseState.java Thu Dec 03 10:32:59 2015 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,406 +0,0 @@ -/* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.provider.certpath; - -import java.io.IOException; -import java.security.PublicKey; -import java.security.cert.CertificateException; -import java.security.cert.CertPathValidatorException; -import java.security.cert.PKIXCertPathChecker; -import java.security.cert.PKIXRevocationChecker; -import java.security.cert.TrustAnchor; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.ListIterator; -import java.util.Set; -import javax.security.auth.x500.X500Principal; - -import sun.security.provider.certpath.PKIX.BuilderParams; -import sun.security.util.Debug; -import sun.security.x509.NameConstraintsExtension; -import sun.security.x509.SubjectKeyIdentifierExtension; -import sun.security.x509.X509CertImpl; - -/** - * A specification of a reverse PKIX validation state - * which is initialized by each build and updated each time a - * certificate is added to the current path. - * @since 1.4 - * @author Sean Mullan - * @author Yassir Elley - */ - -class ReverseState implements State { - - private static final Debug debug = Debug.getInstance("certpath"); - - /* The subject DN of the last cert in the path */ - X500Principal subjectDN; - - /* The subject public key of the last cert */ - PublicKey pubKey; - - /* The subject key identifier extension (if any) of the last cert */ - SubjectKeyIdentifierExtension subjKeyId; - - /* The PKIX constrained/excluded subtrees state variable */ - NameConstraintsExtension nc; - - /* The PKIX explicit policy, policy mapping, and inhibit_any-policy - state variables */ - int explicitPolicy; - int policyMapping; - int inhibitAnyPolicy; - int certIndex; - PolicyNodeImpl rootNode; - - /* The number of remaining CA certs which may follow in the path. - * -1: previous cert was an EE cert - * 0: only EE certs may follow. - * >0 and <Integer.MAX_VALUE:no more than this number of CA certs may follow - * Integer.MAX_VALUE: unlimited - */ - int remainingCACerts; - - /* The list of user-defined checkers retrieved from the PKIXParameters - * instance */ - ArrayList<PKIXCertPathChecker> userCheckers; - - /* Flag indicating if state is initial (path is just starting) */ - private boolean init = true; - - /* the checker used for revocation status */ - RevocationChecker revChecker; - - /* the algorithm checker */ - AlgorithmChecker algorithmChecker; - - /* the untrusted certificates checker */ - UntrustedChecker untrustedChecker; - - /* the trust anchor used to validate the path */ - TrustAnchor trustAnchor; - - /* Flag indicating if current cert can vouch for the CRL for - * the next cert - */ - boolean crlSign = true; - - /** - * Returns a boolean flag indicating if the state is initial - * (just starting) - * - * @return boolean flag indicating if the state is initial (just starting) - */ - @Override - public boolean isInitial() { - return init; - } - - /** - * Display state for debugging purposes - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("State ["); - sb.append("\n subjectDN of last cert: ").append(subjectDN); - sb.append("\n subjectKeyIdentifier: ").append - (String.valueOf(subjKeyId)); - sb.append("\n nameConstraints: ").append(String.valueOf(nc)); - sb.append("\n certIndex: ").append(certIndex); - sb.append("\n explicitPolicy: ").append(explicitPolicy); - sb.append("\n policyMapping: ").append(policyMapping); - sb.append("\n inhibitAnyPolicy: ").append(inhibitAnyPolicy); - sb.append("\n rootNode: ").append(rootNode); - sb.append("\n remainingCACerts: ").append(remainingCACerts); - sb.append("\n crlSign: ").append(crlSign); - sb.append("\n init: ").append(init); - sb.append("\n]\n"); - return sb.toString(); - } - - /** - * Initialize the state. - * - * @param buildParams builder parameters - */ - public void initState(BuilderParams buildParams) - throws CertPathValidatorException - { - /* - * Initialize number of remainingCACerts. - * Note that -1 maxPathLen implies unlimited. - * 0 implies only an EE cert is acceptable. - */ - int maxPathLen = buildParams.maxPathLength(); - remainingCACerts = (maxPathLen == -1) ? Integer.MAX_VALUE - : maxPathLen; - - /* Initialize explicit policy state variable */ - if (buildParams.explicitPolicyRequired()) { - explicitPolicy = 0; - } else { - // unconstrained if maxPathLen is -1, - // otherwise, we want to initialize this to the value of the - // longest possible path + 1 (i.e. maxpathlen + finalcert + 1) - explicitPolicy = (maxPathLen == -1) ? maxPathLen : maxPathLen + 2; - } - - /* Initialize policy mapping state variable */ - if (buildParams.policyMappingInhibited()) { - policyMapping = 0; - } else { - policyMapping = (maxPathLen == -1) ? maxPathLen : maxPathLen + 2; - } - - /* Initialize inhibit any policy state variable */ - if (buildParams.anyPolicyInhibited()) { - inhibitAnyPolicy = 0; - } else { - inhibitAnyPolicy = (maxPathLen == -1) ? maxPathLen : maxPathLen + 2; - } - - /* Initialize certIndex */ - certIndex = 1; - - /* Initialize policy tree */ - Set<String> initExpPolSet = new HashSet<>(1); - initExpPolSet.add(PolicyChecker.ANY_POLICY); - - rootNode = new PolicyNodeImpl(null, PolicyChecker.ANY_POLICY, null, - false, initExpPolSet, false); - - /* - * Initialize each user-defined checker - * Shallow copy the checkers - */ - userCheckers = new ArrayList<>(buildParams.certPathCheckers()); - /* initialize each checker (just in case) */ - for (PKIXCertPathChecker checker : userCheckers) { - checker.init(false); - } - - /* Start by trusting the cert to sign CRLs */ - crlSign = true; - - init = true; - } - - /** - * Update the state with the specified trust anchor. - * - * @param anchor the most-trusted CA - * @param buildParams builder parameters - */ - public void updateState(TrustAnchor anchor, BuilderParams buildParams) - throws CertificateException, IOException, CertPathValidatorException - { - trustAnchor = anchor; - X509Certificate trustedCert = anchor.getTrustedCert(); - if (trustedCert != null) { - updateState(trustedCert); - } else { - X500Principal caName = anchor.getCA(); - updateState(anchor.getCAPublicKey(), caName); - } - - // The user specified AlgorithmChecker and RevocationChecker may not be - // able to set the trust anchor until now. - boolean revCheckerAdded = false; - for (PKIXCertPathChecker checker : userCheckers) { - if (checker instanceof AlgorithmChecker) { - ((AlgorithmChecker)checker).trySetTrustAnchor(anchor); - } else if (checker instanceof PKIXRevocationChecker) { - if (revCheckerAdded) { - throw new CertPathValidatorException( - "Only one PKIXRevocationChecker can be specified"); - } - // if it's our own, initialize it - if (checker instanceof RevocationChecker) { - ((RevocationChecker)checker).init(anchor, buildParams); - } - ((PKIXRevocationChecker)checker).init(false); - revCheckerAdded = true; - } - } - - // only create a RevocationChecker if revocation is enabled and - // a PKIXRevocationChecker has not already been added - if (buildParams.revocationEnabled() && !revCheckerAdded) { - revChecker = new RevocationChecker(anchor, buildParams); - revChecker.init(false); - } - - init = false; - } - - /** - * Update the state. This method is used when the most-trusted CA is - * a trusted public-key and caName, instead of a trusted cert. - * - * @param pubKey the public key of the trusted CA - * @param subjectDN the subject distinguished name of the trusted CA - */ - private void updateState(PublicKey pubKey, X500Principal subjectDN) { - - /* update subject DN */ - this.subjectDN = subjectDN; - - /* update subject public key */ - this.pubKey = pubKey; - } - - /** - * Update the state with the next certificate added to the path. - * - * @param cert the certificate which is used to update the state - */ - public void updateState(X509Certificate cert) - throws CertificateException, IOException, CertPathValidatorException { - - if (cert == null) { - return; - } - - /* update subject DN */ - subjectDN = cert.getSubjectX500Principal(); - - /* check for key needing to inherit alg parameters */ - X509CertImpl icert = X509CertImpl.toImpl(cert); - PublicKey newKey = cert.getPublicKey(); - if (PKIX.isDSAPublicKeyWithoutParams(newKey)) { - newKey = BasicChecker.makeInheritedParamsKey(newKey, pubKey); - } - - /* update subject public key */ - pubKey = newKey; - - /* - * if this is a trusted cert (init == true), then we - * don't update any of the remaining fields - */ - if (init) { - init = false; - return; - } - - /* update subject key identifier */ - subjKeyId = icert.getSubjectKeyIdentifierExtension(); - - /* update crlSign */ - crlSign = RevocationChecker.certCanSignCrl(cert); - - /* update current name constraints */ - if (nc != null) { - nc.merge(icert.getNameConstraintsExtension()); - } else { - nc = icert.getNameConstraintsExtension(); - if (nc != null) { - // Make sure we do a clone here, because we're probably - // going to modify this object later and we don't want to - // be sharing it with a Certificate object! - nc = (NameConstraintsExtension) nc.clone(); - } - } - - /* update policy state variables */ - explicitPolicy = - PolicyChecker.mergeExplicitPolicy(explicitPolicy, icert, false); - policyMapping = - PolicyChecker.mergePolicyMapping(policyMapping, icert); - inhibitAnyPolicy = - PolicyChecker.mergeInhibitAnyPolicy(inhibitAnyPolicy, icert); - certIndex++; - - /* - * Update remaining CA certs - */ - remainingCACerts = - ConstraintsChecker.mergeBasicConstraints(cert, remainingCACerts); - - init = false; - } - - /** - * Returns a boolean flag indicating if a key lacking necessary key - * algorithm parameters has been encountered. - * - * @return boolean flag indicating if key lacking parameters encountered. - */ - @Override - public boolean keyParamsNeeded() { - /* when building in reverse, we immediately get parameters needed - * or else throw an exception - */ - return false; - } - - /* - * Clone current state. The state is cloned as each cert is - * added to the path. This is necessary if backtracking occurs, - * and a prior state needs to be restored. - * - * Note that this is a SMART clone. Not all fields are fully copied, - * because some of them (e.g., subjKeyId) will - * not have their contents modified by subsequent calls to updateState. - */ - @Override - @SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly - public Object clone() { - try { - ReverseState clonedState = (ReverseState) super.clone(); - - /* clone checkers, if cloneable */ - clonedState.userCheckers = - (ArrayList<PKIXCertPathChecker>)userCheckers.clone(); - ListIterator<PKIXCertPathChecker> li = - clonedState.userCheckers.listIterator(); - while (li.hasNext()) { - PKIXCertPathChecker checker = li.next(); - if (checker instanceof Cloneable) { - li.set((PKIXCertPathChecker)checker.clone()); - } - } - - /* make copy of name constraints */ - if (nc != null) { - clonedState.nc = (NameConstraintsExtension) nc.clone(); - } - - /* make copy of policy tree */ - if (rootNode != null) { - clonedState.rootNode = rootNode.copyTree(); - } - - return clonedState; - } catch (CloneNotSupportedException e) { - throw new InternalError(e.toString(), e); - } - } -}
--- a/src/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java Thu Dec 03 13:27:36 2015 -0800 @@ -35,8 +35,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.LinkedList; import java.util.Set; @@ -47,8 +45,7 @@ import sun.security.util.Debug; /** - * This class is able to build certification paths in either the forward - * or reverse directions. + * This class builds certification paths in the forward direction. * * <p> If successful, it returns a certification path which has successfully * satisfied all the constraints and requirements specified in the @@ -102,10 +99,8 @@ /** * Attempts to build a certification path using the Sun build * algorithm from a trusted anchor(s) to a target subject, which must both - * be specified in the input parameter set. By default, this method will - * attempt to build in the forward direction. In order to build in the - * reverse direction, the caller needs to pass in an instance of - * SunCertPathBuilderParameters with the buildForward flag set to false. + * be specified in the input parameter set. This method will + * attempt to build in the forward direction: from the target to the CA. * * <p>The certification path that is constructed is validated * according to the PKIX specification. @@ -162,11 +157,7 @@ policyTreeResult = null; LinkedList<X509Certificate> certPathList = new LinkedList<>(); try { - if (buildParams.buildForward()) { - buildForward(adjList, certPathList, searchAllCertStores); - } else { - buildReverse(adjList, certPathList); - } + buildForward(adjList, certPathList, searchAllCertStores); } catch (GeneralSecurityException | IOException e) { if (debug != null) { debug.println("SunCertPathBuilder.engineBuild() exception in " @@ -210,81 +201,6 @@ } /* - * Private build reverse method. - */ - private void buildReverse(List<List<Vertex>> adjacencyList, - LinkedList<X509Certificate> certPathList) - throws GeneralSecurityException, IOException - { - if (debug != null) { - debug.println("SunCertPathBuilder.buildReverse()..."); - debug.println("SunCertPathBuilder.buildReverse() InitialPolicies: " - + buildParams.initialPolicies()); - } - - ReverseState currentState = new ReverseState(); - /* Initialize adjacency list */ - adjacencyList.clear(); - adjacencyList.add(new LinkedList<Vertex>()); - - /* - * Perform a search using each trust anchor, until a valid - * path is found - */ - Iterator<TrustAnchor> iter = buildParams.trustAnchors().iterator(); - while (iter.hasNext()) { - TrustAnchor anchor = iter.next(); - - /* check if anchor satisfies target constraints */ - if (anchorIsTarget(anchor, buildParams.targetCertConstraints())) { - this.trustAnchor = anchor; - this.pathCompleted = true; - this.finalPublicKey = anchor.getTrustedCert().getPublicKey(); - break; - } - - // skip anchor if it contains a DSA key with no DSA params - X509Certificate trustedCert = anchor.getTrustedCert(); - PublicKey pubKey = trustedCert != null ? trustedCert.getPublicKey() - : anchor.getCAPublicKey(); - - if (PKIX.isDSAPublicKeyWithoutParams(pubKey)) { - continue; - } - - /* Initialize current state */ - currentState.initState(buildParams); - currentState.updateState(anchor, buildParams); - - currentState.algorithmChecker = new AlgorithmChecker(anchor); - currentState.untrustedChecker = new UntrustedChecker(); - try { - depthFirstSearchReverse(null, currentState, - new ReverseBuilder(buildParams), - adjacencyList, certPathList); - } catch (GeneralSecurityException | IOException e) { - // continue on error if more anchors to try - if (iter.hasNext()) - continue; - else - throw e; - } - - // break out of loop if search is successful - if (pathCompleted) { - break; - } - } - - if (debug != null) { - debug.println("SunCertPathBuilder.buildReverse() returned from " - + "depthFirstSearchReverse()"); - debug.println("SunCertPathBuilder.buildReverse() " - + "certPathList.size: " + certPathList.size()); - } - } - - /* * Private build forward method. */ private void buildForward(List<List<Vertex>> adjacencyList, @@ -632,147 +548,6 @@ } /* - * This method performs a depth first search for a certification - * path while building reverse which meets the requirements set in - * the parameters object. - * It uses an adjacency list to store all certificates which were - * tried (i.e. at one time added to the path - they may not end up in - * the final path if backtracking occurs). This information can - * be used later to debug or demo the build. - * - * See "Data Structure and Algorithms, by Aho, Hopcroft, and Ullman" - * for an explanation of the DFS algorithm. - * - * @param dN the distinguished name being currently searched for certs - * @param currentState the current PKIX validation state - */ - private void depthFirstSearchReverse(X500Principal dN, - ReverseState currentState, - ReverseBuilder builder, - List<List<Vertex>> adjList, - LinkedList<X509Certificate> cpList) - throws GeneralSecurityException, IOException - { - if (debug != null) - debug.println("SunCertPathBuilder.depthFirstSearchReverse(" + dN - + ", " + currentState.toString() + ")"); - - /* - * Find all the certificates issued by dN which - * satisfy the PKIX certification path constraints. - */ - Collection<X509Certificate> certs = - builder.getMatchingCerts(currentState, buildParams.certStores()); - List<Vertex> vertices = addVertices(certs, adjList); - if (debug != null) - debug.println("SunCertPathBuilder.depthFirstSearchReverse(): " - + "certs.size=" + vertices.size()); - - /* - * For each cert in the collection, verify anything - * that hasn't been checked yet (signature, revocation, etc) - * and check for loops. Call depthFirstSearchReverse() - * recursively for each good cert. - */ - for (Vertex vertex : vertices) { - /** - * Restore state to currentState each time through the loop. - * This is important because some of the user-defined - * checkers modify the state, which MUST be restored if - * the cert eventually fails to lead to the target and - * the next matching cert is tried. - */ - ReverseState nextState = (ReverseState) currentState.clone(); - X509Certificate cert = vertex.getCertificate(); - try { - builder.verifyCert(cert, nextState, cpList); - } catch (GeneralSecurityException gse) { - if (debug != null) - debug.println("SunCertPathBuilder.depthFirstSearchReverse()" - + ": validation failed: " + gse); - vertex.setThrowable(gse); - continue; - } - - /* - * Certificate is good, add it to the path (if it isn't a - * self-signed cert) and update state - */ - if (!currentState.isInitial()) - builder.addCertToPath(cert, cpList); - // save trust anchor - this.trustAnchor = currentState.trustAnchor; - - /* - * Check if path is completed, return ASAP if so. - */ - if (builder.isPathCompleted(cert)) { - if (debug != null) - debug.println("SunCertPathBuilder.depthFirstSearchReverse()" - + ": path completed!"); - pathCompleted = true; - - PolicyNodeImpl rootNode = nextState.rootNode; - - if (rootNode == null) - policyTreeResult = null; - else { - policyTreeResult = rootNode.copyTree(); - ((PolicyNodeImpl)policyTreeResult).setImmutable(); - } - - /* - * Extract and save the final target public key - */ - finalPublicKey = cert.getPublicKey(); - if (PKIX.isDSAPublicKeyWithoutParams(finalPublicKey)) { - finalPublicKey = - BasicChecker.makeInheritedParamsKey - (finalPublicKey, currentState.pubKey); - } - - return; - } - - /* Update the PKIX state */ - nextState.updateState(cert); - - /* - * Append an entry for cert in adjacency list and - * set index for current vertex. - */ - adjList.add(new LinkedList<Vertex>()); - vertex.setIndex(adjList.size() - 1); - - /* recursively search for matching certs at next dN */ - depthFirstSearchReverse(cert.getSubjectX500Principal(), nextState, - builder, adjList, cpList); - - /* - * If path has been completed, return ASAP! - */ - if (pathCompleted) { - return; - } else { - /* - * If we get here, it means we have searched all possible - * certs issued by the dN w/o finding any matching certs. This - * means we have to backtrack to the previous cert in the path - * and try some other paths. - */ - if (debug != null) - debug.println("SunCertPathBuilder.depthFirstSearchReverse()" - + ": backtracking"); - if (!currentState.isInitial()) - builder.removeFinalCertFromPath(cpList); - } - } - if (debug != null) - debug.println("SunCertPathBuilder.depthFirstSearchReverse() all " - + "certs in this adjacency list checked"); - } - - /* * Adds a collection of matching certificates to the * adjacency list. */
--- a/src/share/classes/sun/security/provider/certpath/SunCertPathBuilderParameters.java Thu Dec 03 10:32:59 2015 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.provider.certpath; - -import java.security.InvalidAlgorithmParameterException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.cert.*; -import java.util.Set; - -/** - * This class specifies the set of parameters used as input for the Sun - * certification path build algorithm. It is identical to PKIXBuilderParameters - * with the addition of a <code>buildForward</code> parameter which allows - * the caller to specify whether or not the path should be constructed in - * the forward direction. - * - * The default for the <code>buildForward</code> parameter is - * true, which means that the build algorithm should construct paths - * from the target subject back to the trusted anchor. - * - * @since 1.4 - * @author Sean Mullan - * @author Yassir Elley - */ -public class SunCertPathBuilderParameters extends PKIXBuilderParameters { - - private boolean buildForward = true; - - /** - * Creates an instance of <code>SunCertPathBuilderParameters</code> with the - * specified parameter values. - * - * @param trustAnchors a <code>Set</code> of <code>TrustAnchor</code>s - * @param targetConstraints a <code>CertSelector</code> specifying the - * constraints on the target certificate - * @throws InvalidAlgorithmParameterException if the specified - * <code>Set</code> is empty <code>(trustAnchors.isEmpty() == true)</code> - * @throws NullPointerException if the specified <code>Set</code> is - * <code>null</code> - * @throws ClassCastException if any of the elements in the <code>Set</code> - * are not of type <code>java.security.cert.TrustAnchor</code> - */ - public SunCertPathBuilderParameters(Set<TrustAnchor> trustAnchors, - CertSelector targetConstraints) throws InvalidAlgorithmParameterException - { - super(trustAnchors, targetConstraints); - setBuildForward(true); - } - - /** - * Creates an instance of <code>SunCertPathBuilderParameters</code> that - * uses the specified <code>KeyStore</code> to populate the set - * of most-trusted CA certificates. - * - * @param keystore A keystore from which the set of most-trusted - * CA certificates will be populated. - * @param targetConstraints a <code>CertSelector</code> specifying the - * constraints on the target certificate - * @throws KeyStoreException if the keystore has not been initialized. - * @throws InvalidAlgorithmParameterException if the keystore does - * not contain at least one trusted certificate entry - * @throws NullPointerException if the keystore is <code>null</code> - */ - public SunCertPathBuilderParameters(KeyStore keystore, - CertSelector targetConstraints) - throws KeyStoreException, InvalidAlgorithmParameterException - { - super(keystore, targetConstraints); - setBuildForward(true); - } - - /** - * Returns the value of the buildForward flag. - * - * @return the value of the buildForward flag - */ - public boolean getBuildForward() { - return this.buildForward; - } - - /** - * Sets the value of the buildForward flag. If true, paths - * are built from the target subject to the trusted anchor. - * If false, paths are built from the trusted anchor to the - * target subject. The default value if not specified is true. - * - * @param buildForward the value of the buildForward flag - */ - public void setBuildForward(boolean buildForward) { - this.buildForward = buildForward; - } - - /** - * Returns a formatted string describing the parameters. - * - * @return a formatted string describing the parameters. - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("[\n"); - sb.append(super.toString()); - sb.append(" Build Forward Flag: " + String.valueOf(buildForward) + "\n"); - sb.append("]\n"); - return sb.toString(); - } -}
--- a/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java Thu Dec 03 13:27:36 2015 -0800 @@ -111,18 +111,23 @@ } } - boolean needFailover = false; byte[] encoded = null; try { Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1); - needFailover = !KeyUtil.isOracleJCEProvider( - cipher.getProvider().getName()); + boolean needFailover = !KeyUtil.isOracleJCEProvider( + cipher.getProvider().getName()); if (needFailover) { cipher.init(Cipher.DECRYPT_MODE, privateKey); - encoded = cipher.doFinal(encrypted); + boolean failed = false; + try { + encoded = cipher.doFinal(encrypted); + } catch (BadPaddingException bpe) { + // Note: encoded == null + failed = true; + } encoded = KeyUtil.checkTlsPreMasterSecretKey( maxVersion.v, currentVersion.v, - generator, encoded, false); + generator, encoded, failed); preMaster = generatePreMasterSecret( maxVersion.v, currentVersion.v, encoded, generator); @@ -134,18 +139,6 @@ preMaster = (SecretKey)cipher.unwrap(encrypted, "TlsRsaPremasterSecret", Cipher.SECRET_KEY); } - } catch (BadPaddingException bpe) { - if (needFailover) { - encoded = KeyUtil.checkTlsPreMasterSecretKey( - maxVersion.v, currentVersion.v, - generator, null, false); - preMaster = generatePreMasterSecret( - maxVersion.v, currentVersion.v, - encoded, generator); - } else { - // Otherwise, unlikely to happen - throw new RuntimeException("Unexpected exception", bpe); - } } catch (InvalidKeyException ibk) { // the message is too big to process with RSA throw new SSLProtocolException(
--- a/src/share/classes/sun/security/util/KeyUtil.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/util/KeyUtil.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,8 @@ import javax.crypto.spec.DHPublicKeySpec; import java.math.BigInteger; +import sun.security.jca.JCAUtil; + /** * A utility class to get key length, valiate keys, etc. */ @@ -200,7 +202,7 @@ byte[] encoded, boolean isFailOver) { if (random == null) { - random = new SecureRandom(); + random = JCAUtil.getSecureRandom(); } byte[] replacer = new byte[48]; random.nextBytes(replacer);
--- a/src/share/classes/sun/security/util/Resources_zh_CN.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/util/Resources_zh_CN.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,7 +63,7 @@ "\u63D0\u4F9B\u4E86\u65E0\u6548\u7684\u7A7A AccessControlContext"}, {"invalid.null.action.provided", "\u63D0\u4F9B\u4E86\u65E0\u6548\u7684\u7A7A\u64CD\u4F5C"}, {"invalid.null.Class.provided", "\u63D0\u4F9B\u4E86\u65E0\u6548\u7684\u7A7A\u7C7B"}, - {"Subject.", "\u4E3B\u9898: \n"}, + {"Subject.", "\u4E3B\u4F53: \n"}, {".Principal.", "\t\u4E3B\u7528\u6237: "}, {".Public.Credential.", "\t\u516C\u5171\u8EAB\u4EFD\u8BC1\u660E: "}, {".Private.Credentials.inaccessible.", @@ -71,9 +71,9 @@ {".Private.Credential.", "\t\u4E13\u7528\u8EAB\u4EFD\u8BC1\u660E: "}, {".Private.Credential.inaccessible.", "\t\u65E0\u6CD5\u8BBF\u95EE\u4E13\u7528\u8EAB\u4EFD\u8BC1\u660E\n"}, - {"Subject.is.read.only", "\u4E3B\u9898\u4E3A\u53EA\u8BFB"}, + {"Subject.is.read.only", "\u4E3B\u4F53\u4E3A\u53EA\u8BFB"}, {"attempting.to.add.an.object.which.is.not.an.instance.of.java.security.Principal.to.a.Subject.s.Principal.Set", - "\u6B63\u5728\u5C1D\u8BD5\u5C06\u4E00\u4E2A\u975E java.security.Principal \u5B9E\u4F8B\u7684\u5BF9\u8C61\u6DFB\u52A0\u5230\u4E3B\u9898\u7684\u4E3B\u7528\u6237\u96C6\u4E2D"}, + "\u6B63\u5728\u5C1D\u8BD5\u5C06\u4E00\u4E2A\u975E java.security.Principal \u5B9E\u4F8B\u7684\u5BF9\u8C61\u6DFB\u52A0\u5230\u4E3B\u4F53\u7684\u4E3B\u7528\u6237\u96C6\u4E2D"}, {"attempting.to.add.an.object.which.is.not.an.instance.of.class", "\u6B63\u5728\u5C1D\u8BD5\u6DFB\u52A0\u4E00\u4E2A\u975E{0}\u5B9E\u4F8B\u7684\u5BF9\u8C61"}, @@ -84,11 +84,11 @@ {"Invalid.null.input.name", "\u65E0\u6548\u7A7A\u8F93\u5165: \u540D\u79F0"}, {"No.LoginModules.configured.for.name", "\u6CA1\u6709\u4E3A{0}\u914D\u7F6E LoginModules"}, - {"invalid.null.Subject.provided", "\u63D0\u4F9B\u4E86\u65E0\u6548\u7684\u7A7A\u4E3B\u9898"}, + {"invalid.null.Subject.provided", "\u63D0\u4F9B\u4E86\u65E0\u6548\u7684\u7A7A\u4E3B\u4F53"}, {"invalid.null.CallbackHandler.provided", "\u63D0\u4F9B\u4E86\u65E0\u6548\u7684\u7A7A CallbackHandler"}, {"null.subject.logout.called.before.login", - "\u7A7A\u4E3B\u9898 - \u5728\u767B\u5F55\u4E4B\u524D\u8C03\u7528\u4E86\u6CE8\u9500"}, + "\u7A7A\u4E3B\u4F53 - \u5728\u767B\u5F55\u4E4B\u524D\u8C03\u7528\u4E86\u6CE8\u9500"}, {"unable.to.instantiate.LoginModule.module.because.it.does.not.provide.a.no.argument.constructor", "\u65E0\u6CD5\u5B9E\u4F8B\u5316 LoginModule, {0}, \u56E0\u4E3A\u5B83\u672A\u63D0\u4F9B\u4E00\u4E2A\u65E0\u53C2\u6570\u6784\u9020\u5668"}, {"unable.to.instantiate.LoginModule",
--- a/src/share/classes/sun/security/x509/AlgorithmId.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/AlgorithmId.java Thu Dec 03 13:27:36 2015 -0800 @@ -588,7 +588,7 @@ } if (oidTable == null) { - oidTable = new HashMap<String,ObjectIdentifier>(1); + oidTable = Collections.<String,ObjectIdentifier>emptyMap(); } initOidTable = true; }
--- a/src/share/classes/sun/security/x509/CRLDistributionPointsExtension.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/CRLDistributionPointsExtension.java Thu Dec 03 13:27:36 2015 -0800 @@ -29,6 +29,7 @@ import java.io.OutputStream; import java.util.*; +import java.util.Collections; import sun.security.util.DerOutputStream; import sun.security.util.DerValue; @@ -255,11 +256,12 @@ */ public void delete(String name) throws IOException { if (name.equalsIgnoreCase(POINTS)) { - distributionPoints = new ArrayList<DistributionPoint>(); + distributionPoints = + Collections.<DistributionPoint>emptyList(); } else { throw new IOException("Attribute name [" + name + - "] not recognized by " + - "CertAttrSet:" + extensionName + "."); + "] not recognized by " + + "CertAttrSet:" + extensionName + '.'); } encodeThis(); }
--- a/src/share/classes/sun/security/x509/CRLNumberExtension.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/CRLNumberExtension.java Thu Dec 03 13:27:36 2015 -0800 @@ -157,11 +157,10 @@ */ public BigInteger get(String name) throws IOException { if (name.equalsIgnoreCase(NUMBER)) { - if (crlNumber == null) return null; - else return crlNumber; + return crlNumber; } else { - throw new IOException("Attribute name not recognized by" - + " CertAttrSet:" + extensionName + "."); + throw new IOException("Attribute name not recognized by" + + " CertAttrSet:" + extensionName + '.'); } }
--- a/src/share/classes/sun/security/x509/DNSName.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/DNSName.java Thu Dec 03 13:27:36 2015 -0800 @@ -232,15 +232,15 @@ * @throws UnsupportedOperationException if not supported for this name type */ public int subtreeDepth() throws UnsupportedOperationException { - String subtree=name; - int i=1; + // subtree depth is always at least 1 + int sum = 1; - /* count dots */ - for (; subtree.lastIndexOf('.') >= 0; i++) { - subtree=subtree.substring(0,subtree.lastIndexOf('.')); + // count dots + for (int i = name.indexOf('.'); i >= 0; i = name.indexOf('.', i + 1)) { + ++sum; } - return i; + return sum; } }
--- a/src/share/classes/sun/security/x509/EDIPartyName.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/EDIPartyName.java Thu Dec 03 13:27:36 2015 -0800 @@ -197,7 +197,7 @@ */ public int hashCode() { if (myhash == -1) { - myhash = 37 + party.hashCode(); + myhash = 37 + (party == null ? 1 : party.hashCode()); if (assigner != null) { myhash = 37 * myhash + assigner.hashCode(); }
--- a/src/share/classes/sun/security/x509/GeneralSubtrees.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/GeneralSubtrees.java Thu Dec 03 13:27:36 2015 -0800 @@ -191,7 +191,7 @@ // the list: if any subsequent entry matches or widens entry n, // remove entry n. If any subsequent entries narrow entry n, remove // the subsequent entries. - for (int i = 0; i < size(); i++) { + for (int i = 0; i < (size() - 1); i++) { GeneralNameInterface current = getGeneralNameInterface(i); boolean remove1 = false;
--- a/src/share/classes/sun/security/x509/IPAddressName.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/IPAddressName.java Thu Dec 03 13:27:36 2015 -0800 @@ -197,8 +197,10 @@ // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); - if (prefixLen > 128) - throw new IOException("IPv6Address prefix is longer than 128"); + if (prefixLen < 0 || prefixLen > 128) { + throw new IOException("IPv6Address prefix length (" + + prefixLen + ") in out of valid range [0,128]"); + } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); @@ -317,7 +319,8 @@ if (!(obj instanceof IPAddressName)) return false; - byte[] other = ((IPAddressName)obj).getBytes(); + IPAddressName otherName = (IPAddressName)obj; + byte[] other = otherName.address; if (other.length != address.length) return false; @@ -326,12 +329,10 @@ // Two subnet addresses // Mask each and compare masked values int maskLen = address.length/2; - byte[] maskedThis = new byte[maskLen]; - byte[] maskedOther = new byte[maskLen]; for (int i=0; i < maskLen; i++) { - maskedThis[i] = (byte)(address[i] & address[i+maskLen]); - maskedOther[i] = (byte)(other[i] & other[i+maskLen]); - if (maskedThis[i] != maskedOther[i]) { + byte maskedThis = (byte)(address[i] & address[i+maskLen]); + byte maskedOther = (byte)(other[i] & other[i+maskLen]); + if (maskedThis != maskedOther) { return false; } } @@ -400,7 +401,8 @@ else if (((IPAddressName)inputName).equals(this)) constraintType = NAME_MATCH; else { - byte[] otherAddress = ((IPAddressName)inputName).getBytes(); + IPAddressName otherName = (IPAddressName)inputName; + byte[] otherAddress = otherName.address; if (otherAddress.length == 4 && address.length == 4) // Two host addresses constraintType = NAME_SAME_TYPE;
--- a/src/share/classes/sun/security/x509/IssuingDistributionPointExtension.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/IssuingDistributionPointExtension.java Thu Dec 03 13:27:36 2015 -0800 @@ -261,6 +261,7 @@ throw new IOException( "Attribute value should be of type ReasonFlags."); } + revocationReasons = (ReasonFlags)obj; } else if (name.equalsIgnoreCase(INDIRECT_CRL)) { if (!(obj instanceof Boolean)) { @@ -290,7 +291,6 @@ } hasOnlyAttributeCerts = ((Boolean)obj).booleanValue(); - } else { throw new IOException("Attribute name [" + name + "] not recognized by " +
--- a/src/share/classes/sun/security/x509/KeyIdentifier.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/KeyIdentifier.java Thu Dec 03 13:27:36 2015 -0800 @@ -148,7 +148,7 @@ return true; if (!(other instanceof KeyIdentifier)) return false; - return java.util.Arrays.equals(octetString, - ((KeyIdentifier)other).getIdentifier()); + byte[] otherString = ((KeyIdentifier)other).octetString; + return java.util.Arrays.equals(octetString, otherString); } }
--- a/src/share/classes/sun/security/x509/PolicyMappingsExtension.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/PolicyMappingsExtension.java Thu Dec 03 13:27:36 2015 -0800 @@ -102,7 +102,7 @@ public PolicyMappingsExtension() { extensionId = PKIXExtensions.KeyUsage_Id; critical = false; - maps = new ArrayList<CertificatePolicyMap>(); + maps = Collections.<CertificatePolicyMap>emptyList(); } /**
--- a/src/share/classes/sun/security/x509/PrivateKeyUsageExtension.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/PrivateKeyUsageExtension.java Thu Dec 03 13:27:36 2015 -0800 @@ -33,6 +33,7 @@ import java.security.cert.CertificateNotYetValidException; import java.util.Date; import java.util.Enumeration; +import java.util.Objects; import sun.security.util.*; @@ -206,16 +207,17 @@ */ public void valid(Date now) throws CertificateNotYetValidException, CertificateExpiredException { + Objects.requireNonNull(now); /* * we use the internal Dates rather than the passed in Date * because someone could override the Date methods after() * and before() to do something entirely different. */ - if (notBefore.after(now)) { + if (notBefore != null && notBefore.after(now)) { throw new CertificateNotYetValidException("NotBefore: " + notBefore.toString()); } - if (notAfter.before(now)) { + if (notAfter != null && notAfter.before(now)) { throw new CertificateExpiredException("NotAfter: " + notAfter.toString()); }
--- a/src/share/classes/sun/security/x509/RDN.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/RDN.java Thu Dec 03 13:27:36 2015 -0800 @@ -27,6 +27,8 @@ import java.io.IOException; import java.io.StringReader; +import java.util.Arrays; +import java.util.StringJoiner; import java.util.*; import sun.security.util.*; @@ -442,31 +444,19 @@ assertion[0].toRFC2253String(oidMap); } - StringBuilder relname = new StringBuilder(); - if (!canonical) { - for (int i = 0; i < assertion.length; i++) { - if (i > 0) { - relname.append('+'); - } - relname.append(assertion[i].toRFC2253String(oidMap)); - } - } else { + AVA[] toOutput = assertion; + if (canonical) { // order the string type AVA's alphabetically, // followed by the oid type AVA's numerically - List<AVA> avaList = new ArrayList<AVA>(assertion.length); - for (int i = 0; i < assertion.length; i++) { - avaList.add(assertion[i]); - } - java.util.Collections.sort(avaList, AVAComparator.getInstance()); - - for (int i = 0; i < avaList.size(); i++) { - if (i > 0) { - relname.append('+'); - } - relname.append(avaList.get(i).toRFC2253CanonicalString()); - } + toOutput = assertion.clone(); + Arrays.sort(toOutput, AVAComparator.getInstance()); } - return relname.toString(); + StringJoiner sj = new StringJoiner("+"); + for (AVA ava : toOutput) { + sj.add(canonical ? ava.toRFC2253CanonicalString() + : ava.toRFC2253String(oidMap)); + } + return sj.toString(); } }
--- a/src/share/classes/sun/security/x509/SubjectInfoAccessExtension.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/SubjectInfoAccessExtension.java Thu Dec 03 13:27:36 2015 -0800 @@ -28,6 +28,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.util.Collections; import java.util.*; import sun.security.util.DerOutputStream; @@ -200,7 +201,8 @@ */ public void delete(String name) throws IOException { if (name.equalsIgnoreCase(DESCRIPTIONS)) { - accessDescriptions = new ArrayList<AccessDescription>(); + accessDescriptions = + Collections.<AccessDescription>emptyList(); } else { throw new IOException("Attribute name [" + name + "] not recognized by " +
--- a/src/share/classes/sun/security/x509/URIName.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/URIName.java Thu Dec 03 13:27:36 2015 -0800 @@ -165,7 +165,7 @@ String host = uri.getSchemeSpecificPart(); try { DNSName hostDNS; - if (host.charAt(0) == '.') { + if (host.startsWith(".")) { hostDNS = new DNSName(host.substring(1)); } else { hostDNS = new DNSName(host);
--- a/src/share/classes/sun/security/x509/X500Name.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/X500Name.java Thu Dec 03 13:27:36 2015 -0800 @@ -346,6 +346,8 @@ for (int i = 0; i < names.length; i++) { list.addAll(names[i].avas()); } + list = Collections.unmodifiableList(list); + allAvaList = list; } return list; } @@ -364,9 +366,6 @@ */ public boolean isEmpty() { int n = names.length; - if (n == 0) { - return true; - } for (int i = 0; i < n; i++) { if (names[i].assertion.length != 0) { return false; @@ -1109,12 +1108,8 @@ * and speed recognition of common X.500 attributes. */ static ObjectIdentifier intern(ObjectIdentifier oid) { - ObjectIdentifier interned = internedOIDs.get(oid); - if (interned != null) { - return interned; - } - internedOIDs.put(oid, oid); - return oid; + ObjectIdentifier interned = internedOIDs.putIfAbsent(oid, oid); + return (interned == null) ? oid : interned; } private static final Map<ObjectIdentifier,ObjectIdentifier> internedOIDs
--- a/src/share/classes/sun/security/x509/X509AttributeName.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/X509AttributeName.java Thu Dec 03 13:27:36 2015 -0800 @@ -47,7 +47,7 @@ */ public X509AttributeName(String name) { int i = name.indexOf(SEPARATOR); - if (i == (-1)) { + if (i < 0) { prefix = name; } else { prefix = name.substring(0, i);
--- a/src/share/classes/sun/security/x509/X509CRLImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/X509CRLImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -742,9 +742,7 @@ public byte[] getTBSCertList() throws CRLException { if (tbsCertList == null) throw new CRLException("Uninitialized CRL"); - byte[] dup = new byte[tbsCertList.length]; - System.arraycopy(tbsCertList, 0, dup, 0, dup.length); - return dup; + return tbsCertList.clone(); } /** @@ -755,9 +753,7 @@ public byte[] getSignature() { if (signature == null) return null; - byte[] dup = new byte[signature.length]; - System.arraycopy(signature, 0, dup, 0, dup.length); - return dup; + return signature.clone(); } /**
--- a/src/share/classes/sun/security/x509/X509CertImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/security/x509/X509CertImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1008,9 +1008,7 @@ public byte[] getSignature() { if (signature == null) return null; - byte[] dup = new byte[signature.length]; - System.arraycopy(signature, 0, dup, 0, dup.length); - return dup; + return signature.clone(); } /**
--- a/src/share/classes/sun/tools/jar/resources/jar_ja.properties Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/tools/jar/resources/jar_ja.properties Thu Dec 03 13:27:36 2015 -0800 @@ -45,4 +45,4 @@ out.inflated=\ {0}\u304C\u5C55\u958B\u3055\u308C\u307E\u3057\u305F out.size=(\u5165={0})(\u51FA={1}) -usage=\u4F7F\u7528\u65B9\u6CD5: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...\n\u30AA\u30D7\u30B7\u30E7\u30F3:\n -c \u30A2\u30FC\u30AB\u30A4\u30D6\u3092\u65B0\u898F\u4F5C\u6210\u3059\u308B\n -t \u30A2\u30FC\u30AB\u30A4\u30D6\u306E\u5185\u5BB9\u3092\u4E00\u89A7\u8868\u793A\u3059\u308B\n -x \u6307\u5B9A\u306E(\u307E\u305F\u306F\u3059\u3079\u3066\u306E)\u30D5\u30A1\u30A4\u30EB\u3092\u30A2\u30FC\u30AB\u30A4\u30D6\u304B\u3089\u62BD\u51FA\u3059\u308B\n -u \u65E2\u5B58\u30A2\u30FC\u30AB\u30A4\u30D6\u3092\u66F4\u65B0\u3059\u308B\n -v \u6A19\u6E96\u51FA\u529B\u306B\u8A73\u7D30\u306A\u51FA\u529B\u3092\u751F\u6210\u3059\u308B\n -f \u30A2\u30FC\u30AB\u30A4\u30D6\u30FB\u30D5\u30A1\u30A4\u30EB\u540D\u3092\u6307\u5B9A\u3059\u308B\n -m \u6307\u5B9A\u306E\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u60C5\u5831\u3092\u53D6\u308A\u8FBC\u3080\n -n \u65B0\u898F\u30A2\u30FC\u30AB\u30A4\u30D6\u306E\u4F5C\u6210\u5F8C\u306BPack200\u6B63\u898F\u5316\u3092\u5B9F\u884C\u3059\u308B\n -e \u5B9F\u884C\u53EF\u80FDjar\u30D5\u30A1\u30A4\u30EB\u306B\u30D0\u30F3\u30C9\u30EB\u3055\u308C\u305F\u30B9\u30BF\u30F3\u30C9\u30A2\u30ED\u30F3\u30FB\n \u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u306E\u30A8\u30F3\u30C8\u30EA\u30FB\u30DD\u30A4\u30F3\u30C8\u3092\u6307\u5B9A\u3059\u308B\n -0 \u683C\u7D0D\u306E\u307F\u3002ZIP\u5727\u7E2E\u3092\u4F7F\u7528\u3057\u306A\u3044\n -P \u30D5\u30A1\u30A4\u30EB\u540D\u306E\u5148\u982D\u306E'/' (\u7D76\u5BFE\u30D1\u30B9)\u304A\u3088\u3073\\"..\\" (\u89AA\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA)\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u3092\u4FDD\u6301\u3059\u308B\n -M \u30A8\u30F3\u30C8\u30EA\u306E\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u4F5C\u6210\u3057\u306A\u3044\n -i \u6307\u5B9A\u306Ejar\u30D5\u30A1\u30A4\u30EB\u306E\u7D22\u5F15\u60C5\u5831\u3092\u751F\u6210\u3059\u308B\n -C \u6307\u5B9A\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u5909\u66F4\u3057\u3001\u6B21\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u53D6\u308A\u8FBC\u3080\n\u30D5\u30A1\u30A4\u30EB\u304C\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u5834\u5408\u306F\u518D\u5E30\u7684\u306B\u51E6\u7406\u3055\u308C\u307E\u3059\u3002\n\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u540D\u3001\u30A2\u30FC\u30AB\u30A4\u30D6\u30FB\u30D5\u30A1\u30A4\u30EB\u540D\u304A\u3088\u3073\u30A8\u30F3\u30C8\u30EA\u30FB\u30DD\u30A4\u30F3\u30C8\u540D\u306F\u3001\n\u30D5\u30E9\u30B0'm'\u3001'f'\u3001'e'\u306E\u6307\u5B9A\u3068\u540C\u3058\u9806\u756A\u3067\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n\n\u4F8B1: 2\u3064\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u30A2\u30FC\u30AB\u30A4\u30D6classes.jar\u306B\u4FDD\u5B58\u3059\u308B: \n jar cvf classes.jar Foo.class Bar.class \n\u4F8B2: \u65E2\u5B58\u306E\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB'mymanifest'\u3092\u4F7F\u7528\u3057\u3001foo/\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\n \u5168\u30D5\u30A1\u30A4\u30EB\u3092'classes.jar'\u306B\u30A2\u30FC\u30AB\u30A4\u30D6\u3059\u308B: \n jar cvfm classes.jar mymanifest -C foo/ \n +usage=\u4F7F\u7528\u65B9\u6CD5: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...\n\u30AA\u30D7\u30B7\u30E7\u30F3:\n -c \u30A2\u30FC\u30AB\u30A4\u30D6\u3092\u65B0\u898F\u4F5C\u6210\u3059\u308B\n -t \u30A2\u30FC\u30AB\u30A4\u30D6\u306E\u5185\u5BB9\u3092\u4E00\u89A7\u8868\u793A\u3059\u308B\n -x \u6307\u5B9A\u306E(\u307E\u305F\u306F\u3059\u3079\u3066\u306E)\u30D5\u30A1\u30A4\u30EB\u3092\u30A2\u30FC\u30AB\u30A4\u30D6\u304B\u3089\u62BD\u51FA\u3059\u308B\n -u \u65E2\u5B58\u30A2\u30FC\u30AB\u30A4\u30D6\u3092\u66F4\u65B0\u3059\u308B\n -v \u6A19\u6E96\u51FA\u529B\u306B\u8A73\u7D30\u306A\u51FA\u529B\u3092\u751F\u6210\u3059\u308B\n -f \u30A2\u30FC\u30AB\u30A4\u30D6\u30FB\u30D5\u30A1\u30A4\u30EB\u540D\u3092\u6307\u5B9A\u3059\u308B\n -m \u6307\u5B9A\u306E\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u60C5\u5831\u3092\u53D6\u308A\u8FBC\u3080\n -n \u65B0\u898F\u30A2\u30FC\u30AB\u30A4\u30D6\u306E\u4F5C\u6210\u5F8C\u306BPack200\u6B63\u898F\u5316\u3092\u5B9F\u884C\u3059\u308B\n -e \u5B9F\u884C\u53EF\u80FDjar\u30D5\u30A1\u30A4\u30EB\u306B\u30D0\u30F3\u30C9\u30EB\u3055\u308C\u305F\u30B9\u30BF\u30F3\u30C9\u30A2\u30ED\u30F3\u30FB\n \u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u306E\u30A8\u30F3\u30C8\u30EA\u30FB\u30DD\u30A4\u30F3\u30C8\u3092\u6307\u5B9A\u3059\u308B\n -0 \u683C\u7D0D\u306E\u307F\u3002ZIP\u5727\u7E2E\u3092\u4F7F\u7528\u3057\u306A\u3044\n -P \u30D5\u30A1\u30A4\u30EB\u540D\u306E\u5148\u982D\u306E'/' (\u7D76\u5BFE\u30D1\u30B9)\u304A\u3088\u3073\\"..\\" (\u89AA\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA)\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u3092\u4FDD\u6301\u3059\u308B\n -M \u30A8\u30F3\u30C8\u30EA\u306E\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u4F5C\u6210\u3057\u306A\u3044\n -i \u6307\u5B9A\u306Ejar\u30D5\u30A1\u30A4\u30EB\u306E\u7D22\u5F15\u60C5\u5831\u3092\u751F\u6210\u3059\u308B\n -C \u6307\u5B9A\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u5909\u66F4\u3057\u3001\u6B21\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u53D6\u308A\u8FBC\u3080\n\u30D5\u30A1\u30A4\u30EB\u304C\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u5834\u5408\u306F\u518D\u5E30\u7684\u306B\u51E6\u7406\u3055\u308C\u307E\u3059\u3002\n\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u540D\u3001\u30A2\u30FC\u30AB\u30A4\u30D6\u30FB\u30D5\u30A1\u30A4\u30EB\u540D\u304A\u3088\u3073\u30A8\u30F3\u30C8\u30EA\u30FB\u30DD\u30A4\u30F3\u30C8\u540D\u306F\u3001\n\u30D5\u30E9\u30B0'm'\u3001'f'\u3001'e'\u306E\u6307\u5B9A\u3068\u540C\u3058\u9806\u756A\u3067\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n\n\u4F8B1: 2\u3064\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u30A2\u30FC\u30AB\u30A4\u30D6classes.jar\u306B\u4FDD\u5B58\u3059\u308B: \n jar cvf classes.jar Foo.class Bar.class \n\u4F8B2: \u65E2\u5B58\u306E\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB'mymanifest'\u3092\u4F7F\u7528\u3057\u3001foo/\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\n \u5168\u30D5\u30A1\u30A4\u30EB\u3092'classes.jar'\u306B\u30A2\u30FC\u30AB\u30A4\u30D6\u3059\u308B: \n jar cvfm classes.jar mymanifest -C foo/ .\n
--- a/src/share/classes/sun/util/resources/TimeZoneNames.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/TimeZoneNames.java Thu Dec 03 13:27:36 2015 -0800 @@ -430,6 +430,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java Thu Dec 03 13:27:36 2015 -0800 @@ -431,6 +431,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/classes/sun/util/resources/en/TimeZoneNames_en_GB.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/en/TimeZoneNames_en_GB.java Thu Dec 03 13:27:36 2015 -0800 @@ -47,7 +47,8 @@ protected final Object[][] getContents() { return new Object[][] { {"Europe/London", new String[] {"Greenwich Mean Time", "GMT", - "British Summer Time", "BST"}}, + "British Summer Time", "BST", + "British Time", "BT"}}, }; } }
--- a/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java Thu Dec 03 13:27:36 2015 -0800 @@ -431,6 +431,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java Thu Dec 03 13:27:36 2015 -0800 @@ -431,6 +431,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/classes/sun/util/resources/hi/TimeZoneNames_hi.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/hi/TimeZoneNames_hi.java Thu Dec 03 13:27:36 2015 -0800 @@ -40,7 +40,8 @@ {"Asia/Calcutta", new String[] { "\u092d\u093e\u0930\u0924\u0940\u092f \u0938\u092e\u092f", "IST", - "\u092d\u093e\u0930\u0924\u0940\u092f \u0938\u092e\u092f", "IST" + "\u092d\u093e\u0930\u0924\u0940\u092f \u0938\u092e\u092f", "IST", + "\u092d\u093e\u0930\u0924\u0940\u092f \u0938\u092e\u092f", "IT" } }, };
--- a/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java Thu Dec 03 13:27:36 2015 -0800 @@ -431,6 +431,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java Thu Dec 03 13:27:36 2015 -0800 @@ -431,6 +431,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java Thu Dec 03 13:27:36 2015 -0800 @@ -431,6 +431,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java Thu Dec 03 13:27:36 2015 -0800 @@ -431,6 +431,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java Thu Dec 03 13:27:36 2015 -0800 @@ -431,6 +431,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java Thu Dec 03 13:27:36 2015 -0800 @@ -431,6 +431,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java Thu Dec 03 13:27:36 2015 -0800 @@ -431,6 +431,7 @@ {"America/Eirunepe", ACT}, {"America/El_Salvador", CST}, {"America/Ensenada", PST}, + {"America/Fort_Nelson", MST}, {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST},
--- a/src/share/lib/security/java.security-aix Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/lib/security/java.security-aix Thu Dec 03 13:27:36 2015 -0800 @@ -481,7 +481,7 @@ # jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 # # -jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024 +jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 # Algorithm restrictions for Secure Socket Layer/Transport Layer Security # (SSL/TLS) processing
--- a/src/share/lib/security/java.security-linux Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/lib/security/java.security-linux Thu Dec 03 13:27:36 2015 -0800 @@ -481,7 +481,7 @@ # jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 # # -jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024 +jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 # Algorithm restrictions for Secure Socket Layer/Transport Layer Security # (SSL/TLS) processing
--- a/src/share/lib/security/java.security-macosx Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/lib/security/java.security-macosx Thu Dec 03 13:27:36 2015 -0800 @@ -484,7 +484,7 @@ # jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 # # -jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024 +jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 # Algorithm restrictions for Secure Socket Layer/Transport Layer Security # (SSL/TLS) processing
--- a/src/share/lib/security/java.security-solaris Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/lib/security/java.security-solaris Thu Dec 03 13:27:36 2015 -0800 @@ -483,7 +483,7 @@ # jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 # # -jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024 +jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 # Algorithm restrictions for Secure Socket Layer/Transport Layer Security # (SSL/TLS) processing
--- a/src/share/lib/security/java.security-windows Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/lib/security/java.security-windows Thu Dec 03 13:27:36 2015 -0800 @@ -484,7 +484,7 @@ # jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 # # -jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024 +jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 # Algorithm restrictions for Secure Socket Layer/Transport Layer Security # (SSL/TLS) processing
--- a/src/share/native/common/jni_util.h Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/common/jni_util.h Thu Dec 03 13:27:36 2015 -0800 @@ -391,6 +391,7 @@ void buildJniFunctionName(const char *sym, const char *cname, char *jniEntryName); +extern int getErrorString(int err, char *buf, size_t len); #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */
--- a/src/share/native/java/util/zip/Deflater.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/java/util/zip/Deflater.c Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -49,13 +49,21 @@ Java_java_util_zip_Deflater_initIDs(JNIEnv *env, jclass cls) { levelID = (*env)->GetFieldID(env, cls, "level", "I"); + CHECK_NULL(levelID); strategyID = (*env)->GetFieldID(env, cls, "strategy", "I"); + CHECK_NULL(strategyID); setParamsID = (*env)->GetFieldID(env, cls, "setParams", "Z"); + CHECK_NULL(setParamsID); finishID = (*env)->GetFieldID(env, cls, "finish", "Z"); + CHECK_NULL(finishID); finishedID = (*env)->GetFieldID(env, cls, "finished", "Z"); + CHECK_NULL(finishedID); bufID = (*env)->GetFieldID(env, cls, "buf", "[B"); + CHECK_NULL(bufID); offID = (*env)->GetFieldID(env, cls, "off", "I"); + CHECK_NULL(offID); lenID = (*env)->GetFieldID(env, cls, "len", "I"); + CHECK_NULL(lenID); } JNIEXPORT jlong JNICALL @@ -137,14 +145,14 @@ in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0); if (in_buf == NULL) { // Throw OOME only when length is not zero - if (this_len != 0) + if (this_len != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); return 0; } out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0); if (out_buf == NULL) { (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0); - if (len != 0) + if (len != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); return 0; } @@ -163,7 +171,7 @@ this_off += this_len - strm->avail_in; (*env)->SetIntField(env, this, offID, this_off); (*env)->SetIntField(env, this, lenID, strm->avail_in); - return len - strm->avail_out; + return (jint) (len - strm->avail_out); case Z_BUF_ERROR: (*env)->SetBooleanField(env, this, setParamsID, JNI_FALSE); return 0;
--- a/src/share/native/java/util/zip/Inflater.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/java/util/zip/Inflater.c Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,10 +50,15 @@ Java_java_util_zip_Inflater_initIDs(JNIEnv *env, jclass cls) { needDictID = (*env)->GetFieldID(env, cls, "needDict", "Z"); + CHECK_NULL(needDictID); finishedID = (*env)->GetFieldID(env, cls, "finished", "Z"); + CHECK_NULL(finishedID); bufID = (*env)->GetFieldID(env, cls, "buf", "[B"); + CHECK_NULL(bufID); offID = (*env)->GetFieldID(env, cls, "off", "I"); + CHECK_NULL(offID); lenID = (*env)->GetFieldID(env, cls, "len", "I"); + CHECK_NULL(lenID); } JNIEXPORT jlong JNICALL @@ -127,14 +132,14 @@ in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0); if (in_buf == NULL) { - if (this_len != 0) + if (this_len != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); return 0; } out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0); if (out_buf == NULL) { (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0); - if (len != 0) + if (len != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); return 0; } @@ -154,7 +159,7 @@ this_off += this_len - strm->avail_in; (*env)->SetIntField(env, this, offID, this_off); (*env)->SetIntField(env, this, lenID, strm->avail_in); - return len - strm->avail_out; + return (jint) (len - strm->avail_out); case Z_NEED_DICT: (*env)->SetBooleanField(env, this, needDictID, JNI_TRUE); /* Might have consumed some input here! */
--- a/src/share/native/java/util/zip/ZipFile.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/java/util/zip/ZipFile.c Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,11 +71,13 @@ if (msg != NULL) { s = JNU_NewStringPlatform(env, msg); } - x = JNU_NewObjectByName(env, + if (s != NULL) { + x = JNU_NewObjectByName(env, "java/util/zip/ZipException", "(Ljava/lang/String;)V", s); - if (x != NULL) { - (*env)->Throw(env, x); + if (x != NULL) { + (*env)->Throw(env, x); + } } } @@ -363,8 +365,10 @@ /* If some names were found then build array of java strings */ if (count > 0) { - jclass cls = (*env)->FindClass(env, "java/lang/String"); + jclass cls = JNU_ClassString(env); + CHECK_NULL_RETURN(cls, NULL); result = (*env)->NewObjectArray(env, count, cls, 0); + CHECK_NULL_RETURN(result, NULL); if (result != 0) { for (i = 0; i < count; i++) { jstring str = (*env)->NewStringUTF(env, zip->metanames[i]);
--- a/src/share/native/java/util/zip/zip_util.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/java/util/zip/zip_util.c Thu Dec 03 13:27:36 2015 -0800 @@ -1314,12 +1314,23 @@ jint ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len) { - jlong entry_size = (entry->csize != 0) ? entry->csize : entry->size; + jlong entry_size; jlong start; + if (zip == 0) { + return -1; + } + /* Clear previous zip error */ zip->msg = NULL; + if (entry == 0) { + zip->msg = "ZIP_Read: jzentry is NULL"; + return -1; + } + + entry_size = (entry->csize != 0) ? entry->csize : entry->size; + /* Check specified position */ if (pos < 0 || pos > entry_size - 1) { zip->msg = "ZIP_Read: specified offset out of range"; @@ -1449,6 +1460,12 @@ ZIP_ReadEntry(jzfile *zip, jzentry *entry, unsigned char *buf, char *entryname) { char *msg; + char tmpbuf[1024]; + + if (entry == 0) { + jio_fprintf(stderr, "jzentry was invalid"); + return JNI_FALSE; + } strcpy(entryname, entry->name); if (entry->csize == 0) { @@ -1467,8 +1484,11 @@ msg = zip->msg; ZIP_Unlock(zip); if (n == -1) { - jio_fprintf(stderr, "%s: %s\n", zip->name, - msg != 0 ? msg : strerror(errno)); + if (msg == 0) { + getErrorString(errno, tmpbuf, sizeof(tmpbuf)); + msg = tmpbuf; + } + jio_fprintf(stderr, "%s: %s\n", zip->name, msg); return JNI_FALSE; } buf += n; @@ -1481,8 +1501,11 @@ if ((msg == NULL) || (*msg == 0)) { msg = zip->msg; } - jio_fprintf(stderr, "%s: %s\n", zip->name, - msg != 0 ? msg : strerror(errno)); + if (msg == 0) { + getErrorString(errno, tmpbuf, sizeof(tmpbuf)); + msg = tmpbuf; + } + jio_fprintf(stderr, "%s: %s\n", zip->name, msg); return JNI_FALSE; } }
--- a/src/share/native/sun/awt/image/jpeg/jpegdecoder.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/awt/image/jpeg/jpegdecoder.c Thu Dec 03 13:27:36 2015 -0800 @@ -180,6 +180,7 @@ int *ip; unsigned char *bp; } outbuf; + size_t outbufSize; jobject hOutputBuffer; }; @@ -233,6 +234,7 @@ } if (src->hOutputBuffer) { assert(src->outbuf.ip == 0); + src->outbufSize = (*env)->GetArrayLength(env, src->hOutputBuffer); src->outbuf.ip = (int *)(*env)->GetPrimitiveArrayCritical (env, src->hOutputBuffer, 0); if (src->outbuf.ip == 0) { @@ -677,8 +679,8 @@ cinfo.output_scanline - 1); } else { if (hasalpha) { - ip = jsrc.outbuf.ip + cinfo.image_width; - bp = jsrc.outbuf.bp + cinfo.image_width * 4; + ip = jsrc.outbuf.ip + jsrc.outbufSize; + bp = jsrc.outbuf.bp + jsrc.outbufSize * 4; while (ip > jsrc.outbuf.ip) { pixel = (*--bp) << 24; pixel |= (*--bp); @@ -687,8 +689,8 @@ *--ip = pixel; } } else { - ip = jsrc.outbuf.ip + cinfo.image_width; - bp = jsrc.outbuf.bp + cinfo.image_width * 3; + ip = jsrc.outbuf.ip + jsrc.outbufSize; + bp = jsrc.outbuf.bp + jsrc.outbufSize * 3; while (ip > jsrc.outbuf.ip) { pixel = (*--bp); pixel |= (*--bp) << 8;
--- a/src/share/native/sun/font/layout/ContextualSubstSubtables.cpp Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/font/layout/ContextualSubstSubtables.cpp Thu Dec 03 13:27:36 2015 -0800 @@ -243,14 +243,14 @@ le_uint16 srSetCount = SWAPW(subRuleSetCount); if (coverageIndex < srSetCount) { - LEReferenceToArrayOf<Offset> subRuleSetTableOffsetArrayRef(base, success, - &subRuleSetTableOffsetArray[coverageIndex], 1); + LEReferenceToArrayOf<Offset> + subRuleSetTableOffsetArrayRef(base, success, subRuleSetTableOffsetArray, srSetCount); if (LE_FAILURE(success)) { return 0; } Offset subRuleSetTableOffset = SWAPW(subRuleSetTableOffsetArray[coverageIndex]); - LEReferenceTo<SubRuleSetTable> - subRuleSetTable(base, success, (const SubRuleSetTable *) ((char *) this + subRuleSetTableOffset)); + LEReferenceTo<SubRuleSetTable> subRuleSetTable(base, success, subRuleSetTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 subRuleCount = SWAPW(subRuleSetTable->subRuleCount); le_int32 position = glyphIterator->getCurrStreamPosition(); @@ -264,6 +264,7 @@ SWAPW(subRuleSetTable->subRuleTableOffsetArray[subRule]); LEReferenceTo<SubRuleTable> subRuleTable(subRuleSetTable, success, subRuleTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 matchCount = SWAPW(subRuleTable->glyphCount) - 1; le_uint16 substCount = SWAPW(subRuleTable->substCount); LEReferenceToArrayOf<TTGlyphID> inputGlyphArray(base, success, subRuleTable->inputGlyphArray, matchCount+2); @@ -304,8 +305,8 @@ } if (coverageIndex >= 0) { - LEReferenceTo<ClassDefinitionTable> classDefinitionTable(base, success, - (const ClassDefinitionTable *) ((char *) this + SWAPW(classDefTableOffset))); + LEReferenceTo<ClassDefinitionTable> classDefinitionTable(base, success, SWAPW(classDefTableOffset)); + if (LE_FAILURE(success)) { return 0; } le_uint16 scSetCount = SWAPW(subClassSetCount); le_int32 setClass = classDefinitionTable->getGlyphClass(classDefinitionTable, glyphIterator->getCurrGlyphID(), @@ -313,44 +314,45 @@ if (setClass < scSetCount) { LEReferenceToArrayOf<Offset> - subClassSetTableOffsetArrayRef(base, success, subClassSetTableOffsetArray, setClass); + subClassSetTableOffsetArrayRef(base, success, subClassSetTableOffsetArray, scSetCount); if (LE_FAILURE(success)) { return 0; } if (subClassSetTableOffsetArray[setClass] != 0) { - Offset subClassSetTableOffset = SWAPW(subClassSetTableOffsetArray[setClass]); - LEReferenceTo<SubClassSetTable> - subClassSetTable(base, success, (const SubClassSetTable *) ((char *) this + subClassSetTableOffset)); - le_uint16 subClassRuleCount = SWAPW(subClassSetTable->subClassRuleCount); - le_int32 position = glyphIterator->getCurrStreamPosition(); + Offset subClassSetTableOffset = SWAPW(subClassSetTableOffsetArray[setClass]); + LEReferenceTo<SubClassSetTable> subClassSetTable(base, success, subClassSetTableOffset); + if (LE_FAILURE(success)) { return 0; } + le_uint16 subClassRuleCount = SWAPW(subClassSetTable->subClassRuleCount); + le_int32 position = glyphIterator->getCurrStreamPosition(); LEReferenceToArrayOf<Offset> subClassRuleTableOffsetArrayRef(base, success, subClassSetTable->subClassRuleTableOffsetArray, subClassRuleCount); if (LE_FAILURE(success)) { return 0; } - for (le_uint16 scRule = 0; scRule < subClassRuleCount; scRule += 1) { - Offset subClassRuleTableOffset = - SWAPW(subClassSetTable->subClassRuleTableOffsetArray[scRule]); - LEReferenceTo<SubClassRuleTable> - subClassRuleTable(subClassSetTable, success, subClassRuleTableOffset); - le_uint16 matchCount = SWAPW(subClassRuleTable->glyphCount) - 1; - le_uint16 substCount = SWAPW(subClassRuleTable->substCount); + for (le_uint16 scRule = 0; scRule < subClassRuleCount; scRule += 1) { + Offset subClassRuleTableOffset = + SWAPW(subClassSetTable->subClassRuleTableOffsetArray[scRule]); + LEReferenceTo<SubClassRuleTable> + subClassRuleTable(subClassSetTable, success, subClassRuleTableOffset); + if (LE_FAILURE(success)) { return 0; } + le_uint16 matchCount = SWAPW(subClassRuleTable->glyphCount) - 1; + le_uint16 substCount = SWAPW(subClassRuleTable->substCount); - LEReferenceToArrayOf<le_uint16> classArray(base, success, subClassRuleTable->classArray, matchCount+1); + LEReferenceToArrayOf<le_uint16> classArray(base, success, subClassRuleTable->classArray, matchCount+1); - if (LE_FAILURE(success)) { return 0; } - if (matchGlyphClasses(classArray, matchCount, glyphIterator, classDefinitionTable, success)) { - LEReferenceToArrayOf<SubstitutionLookupRecord> - substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) &subClassRuleTable->classArray[matchCount], substCount); + if (LE_FAILURE(success)) { return 0; } + if (matchGlyphClasses(classArray, matchCount, glyphIterator, classDefinitionTable, success)) { + LEReferenceToArrayOf<SubstitutionLookupRecord> + substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) &subClassRuleTable->classArray[matchCount], substCount); - applySubstitutionLookups(lookupProcessor, substLookupRecordArray, substCount, glyphIterator, fontInstance, position, success); + applySubstitutionLookups(lookupProcessor, substLookupRecordArray, substCount, glyphIterator, fontInstance, position, success); - return matchCount + 1; - } + return matchCount + 1; + } - glyphIterator->setCurrStreamPosition(position); + glyphIterator->setCurrStreamPosition(position); + } } } - } // XXX If we get here, the table is mal-formed... } @@ -463,13 +465,13 @@ if (coverageIndex < srSetCount) { LEReferenceToArrayOf<Offset> - chainSubRuleSetTableOffsetArrayRef(base, success, chainSubRuleSetTableOffsetArray, coverageIndex); + chainSubRuleSetTableOffsetArrayRef(base, success, chainSubRuleSetTableOffsetArray, srSetCount); if (LE_FAILURE(success)) { return 0; } Offset chainSubRuleSetTableOffset = SWAPW(chainSubRuleSetTableOffsetArray[coverageIndex]); - LEReferenceTo<ChainSubRuleSetTable> - chainSubRuleSetTable(base, success, (const ChainSubRuleSetTable *) ((char *) this + chainSubRuleSetTableOffset)); + LEReferenceTo<ChainSubRuleSetTable> chainSubRuleSetTable(base, success, chainSubRuleSetTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 chainSubRuleCount = SWAPW(chainSubRuleSetTable->chainSubRuleCount); le_int32 position = glyphIterator->getCurrStreamPosition(); GlyphIterator tempIterator(*glyphIterator, emptyFeatureList); @@ -550,17 +552,17 @@ if (coverageIndex >= 0) { LEReferenceTo<ClassDefinitionTable> - backtrackClassDefinitionTable(base, success, (const ClassDefinitionTable *) ((char *) this + SWAPW(backtrackClassDefTableOffset))); + backtrackClassDefinitionTable(base, success, SWAPW(backtrackClassDefTableOffset)); LEReferenceTo<ClassDefinitionTable> - inputClassDefinitionTable(base, success, (const ClassDefinitionTable *) ((char *) this + SWAPW(inputClassDefTableOffset))); + inputClassDefinitionTable(base, success, SWAPW(inputClassDefTableOffset)); LEReferenceTo<ClassDefinitionTable> - lookaheadClassDefinitionTable(base, success, (const ClassDefinitionTable *) ((char *) this + SWAPW(lookaheadClassDefTableOffset))); + lookaheadClassDefinitionTable(base, success, SWAPW(lookaheadClassDefTableOffset)); le_uint16 scSetCount = SWAPW(chainSubClassSetCount); le_int32 setClass = inputClassDefinitionTable->getGlyphClass(inputClassDefinitionTable, glyphIterator->getCurrGlyphID(), success); LEReferenceToArrayOf<Offset> - chainSubClassSetTableOffsetArrayRef(base, success, chainSubClassSetTableOffsetArray, setClass); + chainSubClassSetTableOffsetArrayRef(base, success, chainSubClassSetTableOffsetArray, scSetCount); if (LE_FAILURE(success)) { return 0; } @@ -568,7 +570,8 @@ if (setClass < scSetCount && chainSubClassSetTableOffsetArray[setClass] != 0) { Offset chainSubClassSetTableOffset = SWAPW(chainSubClassSetTableOffsetArray[setClass]); LEReferenceTo<ChainSubClassSetTable> - chainSubClassSetTable(base, success, (const ChainSubClassSetTable *) ((char *) this + chainSubClassSetTableOffset)); + chainSubClassSetTable(base, success, chainSubClassSetTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 chainSubClassRuleCount = SWAPW(chainSubClassSetTable->chainSubClassRuleCount); le_int32 position = glyphIterator->getCurrStreamPosition(); GlyphIterator tempIterator(*glyphIterator, emptyFeatureList); @@ -582,6 +585,7 @@ SWAPW(chainSubClassSetTable->chainSubClassRuleTableOffsetArray[scRule]); LEReferenceTo<ChainSubClassRuleTable> chainSubClassRuleTable(chainSubClassSetTable, success, chainSubClassRuleTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 backtrackGlyphCount = SWAPW(chainSubClassRuleTable->backtrackGlyphCount); LEReferenceToArrayOf<le_uint16> backtrackClassArray(base, success, chainSubClassRuleTable->backtrackClassArray, backtrackGlyphCount); if( LE_FAILURE(success) ) { return 0; }
--- a/src/share/native/sun/font/layout/CursiveAttachmentSubtables.cpp Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/font/layout/CursiveAttachmentSubtables.cpp Thu Dec 03 13:27:36 2015 -0800 @@ -46,7 +46,7 @@ le_uint16 eeCount = SWAPW(entryExitCount); LEReferenceToArrayOf<EntryExitRecord> - entryExitRecordsArrayRef(base, success, entryExitRecords, coverageIndex); + entryExitRecordsArrayRef(base, success, entryExitRecords, eeCount); if (coverageIndex < 0 || coverageIndex >= eeCount || LE_FAILURE(success)) { glyphIterator->setCursiveGlyph();
--- a/src/share/native/sun/font/layout/Features.cpp Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/font/layout/Features.cpp Thu Dec 03 13:27:36 2015 -0800 @@ -41,7 +41,7 @@ LEReferenceTo<FeatureTable> FeatureListTable::getFeatureTable(const LETableReference &base, le_uint16 featureIndex, LETag *featureTag, LEErrorCode &success) const { LEReferenceToArrayOf<FeatureRecord> - featureRecordArrayRef(base, success, featureRecordArray, featureIndex+1); + featureRecordArrayRef(base, success, featureRecordArray, SWAPW(featureCount)); if (featureIndex >= SWAPW(featureCount) || LE_FAILURE(success)) { return LEReferenceTo<FeatureTable>();
--- a/src/share/native/sun/font/layout/IndicRearrangementProcessor.cpp Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/font/layout/IndicRearrangementProcessor.cpp Thu Dec 03 13:27:36 2015 -0800 @@ -76,11 +76,11 @@ } if (flags & irfMarkFirst) { - firstGlyph = (le_uint32)currGlyph; + firstGlyph = currGlyph; } if (flags & irfMarkLast) { - lastGlyph = (le_uint32)currGlyph; + lastGlyph = currGlyph; } doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask), success); @@ -118,7 +118,7 @@ if (firstGlyph == lastGlyph) break; if (firstGlyph + 1 < firstGlyph) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; - break; + break; } a = glyphStorage[firstGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success);
--- a/src/share/native/sun/font/layout/IndicRearrangementProcessor.h Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/font/layout/IndicRearrangementProcessor.h Thu Dec 03 13:27:36 2015 -0800 @@ -76,8 +76,8 @@ static UClassID getStaticClassID(); protected: - le_uint32 firstGlyph; - le_uint32 lastGlyph; + le_int32 firstGlyph; + le_int32 lastGlyph; LEReferenceTo<IndicRearrangementSubtableHeader> indicRearrangementSubtableHeader; LEReferenceToArrayOf<IndicRearrangementStateEntry> entryTable;
--- a/src/share/native/sun/font/layout/IndicRearrangementProcessor2.cpp Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/font/layout/IndicRearrangementProcessor2.cpp Thu Dec 03 13:27:36 2015 -0800 @@ -74,11 +74,11 @@ } if (flags & irfMarkFirst) { - firstGlyph = (le_uint32)currGlyph; + firstGlyph = currGlyph; } if (flags & irfMarkLast) { - lastGlyph = (le_uint32)currGlyph; + lastGlyph = currGlyph; } doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask), success); @@ -115,7 +115,7 @@ if (firstGlyph == lastGlyph) break; if (firstGlyph + 1 < firstGlyph) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; - break; + break; } a = glyphStorage[firstGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success);
--- a/src/share/native/sun/font/layout/IndicRearrangementProcessor2.h Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/font/layout/IndicRearrangementProcessor2.h Thu Dec 03 13:27:36 2015 -0800 @@ -76,8 +76,8 @@ static UClassID getStaticClassID(); protected: - le_uint32 firstGlyph; - le_uint32 lastGlyph; + le_int32 firstGlyph; + le_int32 lastGlyph; LEReferenceToArrayOf<IndicRearrangementStateEntry2> entryTable; LEReferenceTo<IndicRearrangementSubtableHeader2> indicRearrangementSubtableHeader;
--- a/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp Thu Dec 03 13:27:36 2015 -0800 @@ -93,7 +93,7 @@ } LEReferenceTo<BaseRecord> baseRecord(base, success, &baseArray->baseRecordArray[baseCoverage * mcCount]); if( LE_FAILURE(success) ) { return 0; } - LEReferenceToArrayOf<Offset> baseAnchorTableOffsetArray(base, success, &(baseRecord->baseAnchorTableOffsetArray[0]), markClass+1); + LEReferenceToArrayOf<Offset> baseAnchorTableOffsetArray(base, success, &(baseRecord->baseAnchorTableOffsetArray[0]), mcCount); if( LE_FAILURE(success) ) { return 0; } Offset anchorTableOffset = SWAPW(baseRecord->baseAnchorTableOffsetArray[markClass]);
--- a/src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp Thu Dec 03 13:27:36 2015 -0800 @@ -83,6 +83,7 @@ LEGlyphID ligatureGlyph = findLigatureGlyph(&ligatureIterator); le_int32 ligatureCoverage = getBaseCoverage(base, (LEGlyphID) ligatureGlyph, success); LEReferenceTo<LigatureArray> ligatureArray(base, success, SWAPW(baseArrayOffset)); + if (LE_FAILURE(success)) { return 0; } le_uint16 ligatureCount = SWAPW(ligatureArray->ligatureCount); if (ligatureCoverage < 0 || ligatureCoverage >= ligatureCount) { @@ -95,6 +96,7 @@ le_int32 markPosition = glyphIterator->getCurrStreamPosition(); Offset ligatureAttachOffset = SWAPW(ligatureArray->ligatureAttachTableOffsetArray[ligatureCoverage]); LEReferenceTo<LigatureAttachTable> ligatureAttachTable(ligatureArray, success, ligatureAttachOffset); + if (LE_FAILURE(success)) { return 0; } le_int32 componentCount = SWAPW(ligatureAttachTable->componentCount); le_int32 component = ligatureIterator.getMarkComponent(markPosition); @@ -104,10 +106,12 @@ } LEReferenceTo<ComponentRecord> componentRecord(base, success, &ligatureAttachTable->componentRecordArray[component * mcCount]); - LEReferenceToArrayOf<Offset> ligatureAnchorTableOffsetArray(base, success, &(componentRecord->ligatureAnchorTableOffsetArray[0]), markClass+1); + if (LE_FAILURE(success)) { return 0; } + LEReferenceToArrayOf<Offset> ligatureAnchorTableOffsetArray(base, success, &(componentRecord->ligatureAnchorTableOffsetArray[0]), mcCount); if( LE_FAILURE(success) ) { return 0; } Offset anchorTableOffset = SWAPW(componentRecord->ligatureAnchorTableOffsetArray[markClass]); LEReferenceTo<AnchorTable> anchorTable(ligatureAttachTable, success, anchorTableOffset); + if (LE_FAILURE(success)) { return 0; } LEPoint ligatureAnchor, markAdvance, pixels; anchorTable->getAnchor(anchorTable, ligatureGlyph, fontInstance, ligatureAnchor, success);
--- a/src/share/native/sun/security/pkcs11/wrapper/p11_convert.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/share/native/sun/security/pkcs11/wrapper/p11_convert.c Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 2002 Graz University of Technology. All rights reserved. @@ -474,6 +474,7 @@ jfieldID fieldID; jclass jSsl3RandomDataClass; jobject jRandomInfo, jRIClientRandom, jRIServerRandom, jVersion; + memset(&ckParam, 0, sizeof(CK_SSL3_MASTER_KEY_DERIVE_PARAMS)); /* get RandomInfo */ jSsl3MasterKeyDeriveParamsClass = (*env)->FindClass(env, CLASS_SSL3_MASTER_KEY_DERIVE_PARAMS); @@ -527,6 +528,7 @@ CK_TLS_PRF_PARAMS ckParam; jfieldID fieldID; jobject jSeed, jLabel, jOutput; + memset(&ckParam, 0, sizeof(CK_TLS_PRF_PARAMS)); // TBD: what if jParam == NULL?! @@ -592,6 +594,7 @@ jobject jRandomInfo, jRIClientRandom, jRIServerRandom; jobject jReturnedKeyMaterial, jRMIvClient, jRMIvServer; CK_ULONG ckTemp; + memset(&ckParam, 0, sizeof(CK_SSL3_KEY_MAT_PARAMS)); /* get ulMacSizeInBits */ jSsl3KeyMatParamsClass = (*env)->FindClass(env, CLASS_SSL3_KEY_MAT_PARAMS); @@ -1355,6 +1358,7 @@ jlong jHashAlg, jMgf, jSource; jobject jSourceData; CK_BYTE_PTR ckpByte; + memset(&ckParam, 0, sizeof(CK_RSA_PKCS_OAEP_PARAMS)); /* get hashAlg */ jRsaPkcsOaepParamsClass = (*env)->FindClass(env, CLASS_RSA_PKCS_OAEP_PARAMS); @@ -1404,6 +1408,7 @@ jlong jIteration; jobject jInitVector, jPassword, jSalt; CK_ULONG ckTemp; + memset(&ckParam, 0, sizeof(CK_PBE_PARAMS)); /* get pInitVector */ jPbeParamsClass = (*env)->FindClass(env, CLASS_PBE_PARAMS); @@ -1522,6 +1527,7 @@ jfieldID fieldID; jlong jSaltSource, jIteration, jPrf; jobject jSaltSourceData, jPrfData; + memset(&ckParam, 0, sizeof(CK_PKCS5_PBKD2_PARAMS)); /* get saltSource */ jPkcs5Pbkd2ParamsClass = (*env)->FindClass(env, CLASS_PKCS5_PBKD2_PARAMS); @@ -1734,6 +1740,7 @@ jfieldID fieldID; jlong jKdf; jobject jOtherInfo, jPublicData; + memset(&ckParam, 0, sizeof(CK_X9_42_DH1_DERIVE_PARAMS)); /* get kdf */ jX942Dh1DeriveParamsClass = (*env)->FindClass(env, CLASS_X9_42_DH1_DERIVE_PARAMS); @@ -1779,6 +1786,7 @@ jfieldID fieldID; jlong jKdf, jPrivateDataLen, jPrivateData; jobject jOtherInfo, jPublicData, jPublicData2; + memset(&ckParam, 0, sizeof(CK_X9_42_DH2_DERIVE_PARAMS)); /* get kdf */ jX942Dh2DeriveParamsClass = (*env)->FindClass(env, CLASS_X9_42_DH2_DERIVE_PARAMS);
--- a/src/solaris/classes/java/net/PlainDatagramSocketImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/classes/java/net/PlainDatagramSocketImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007,2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -119,6 +119,8 @@ protected native void disconnect0(int family); + native int dataAvailable(); + /** * Perform class load-time initializations. */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solaris/classes/sun/awt/FcFontManager.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.awt; + +import sun.font.FcFontConfiguration; +import sun.font.FontConfigManager; +import sun.font.SunFontManager; + +/** + * A {@link sun.font.FontManager} that uses fontconfig to find system fonts. + */ +public class FcFontManager extends SunFontManager { + + private FontConfigManager fcManager = null; + + public synchronized FontConfigManager getFontConfigManager() { + + if (fcManager == null) { + fcManager = new FontConfigManager(); + } + + return fcManager; + } + + @Override + protected FontConfiguration createFontConfiguration() { + FcFontConfiguration fcFontConfig = new FcFontConfiguration(this); + if (fcFontConfig.init()) { + return fcFontConfig; + } else { + throw new InternalError("failed to initialize fontconfig"); + } + } + + @Override + public FontConfiguration createFontConfiguration(boolean preferLocaleFonts, + boolean preferPropFonts) { + FcFontConfiguration fcFontConfig = + new FcFontConfiguration(this, preferLocaleFonts, preferPropFonts); + if (fcFontConfig.init()) { + return fcFontConfig; + } else { + throw new InternalError("failed to initialize fontconfig"); + } + } + + @Override + protected String[] getDefaultPlatformFont() { + final String[] info = new String[2]; + getFontConfigManager().initFontConfigFonts(false); + FontConfigManager.FcCompFont[] fontConfigFonts = + getFontConfigManager().getFontConfigFonts(); + for (int i=0; i<fontConfigFonts.length; i++) { + if ("sans".equals(fontConfigFonts[i].fcFamily) && + 0 == fontConfigFonts[i].style) { + info[0] = fontConfigFonts[i].firstFont.familyName; + info[1] = fontConfigFonts[i].firstFont.fontFile; + break; + } + } + /* Absolute last ditch attempt in the face of fontconfig problems. + * If we didn't match, pick the first, or just make something + * up so we don't NPE. + */ + if (info[0] == null) { + if (fontConfigFonts.length > 0 && + fontConfigFonts[0].firstFont.fontFile != null) { + info[0] = fontConfigFonts[0].firstFont.familyName; + info[1] = fontConfigFonts[0].firstFont.fontFile; + } else { + info[0] = "Dialog"; + info[1] = "/dialog.ttf"; + } + } + return info; + } + + protected native String getFontPathNative(boolean noType1Fonts, + boolean isX11GE); + + protected synchronized String getFontPath(boolean noType1Fonts) { + return getFontPathNative(noType1Fonts, false); + } + +}
--- a/src/solaris/classes/sun/awt/X11FontManager.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/classes/sun/awt/X11FontManager.java Thu Dec 03 13:27:36 2015 -0800 @@ -54,7 +54,7 @@ /** * The X11 implementation of {@link FontManager}. */ -public final class X11FontManager extends SunFontManager { +public final class X11FontManager extends FcFontManager { // constants identifying XLFD and font ID fields private static final int FOUNDRY_FIELD = 1; @@ -154,8 +154,6 @@ */ private static String[] fontdirs = null; - private FontConfigManager fcManager = null; - public static X11FontManager getInstance() { return (X11FontManager) SunFontManager.getInstance(); } @@ -784,51 +782,9 @@ preferLocaleFonts, preferPropFonts); } - public synchronized native String getFontPathNative(boolean noType1Fonts); - protected synchronized String getFontPath(boolean noType1Fonts) { isHeadless(); // make sure GE is inited, as its the X11 lock. - return getFontPathNative(noType1Fonts); - } - - @Override - protected String[] getDefaultPlatformFont() { - final String[] info = new String[2]; - getFontConfigManager().initFontConfigFonts(false); - FontConfigManager.FcCompFont[] fontConfigFonts = - getFontConfigManager().getFontConfigFonts(); - for (int i=0; i<fontConfigFonts.length; i++) { - if ("sans".equals(fontConfigFonts[i].fcFamily) && - 0 == fontConfigFonts[i].style) { - info[0] = fontConfigFonts[i].firstFont.familyName; - info[1] = fontConfigFonts[i].firstFont.fontFile; - break; - } - } - /* Absolute last ditch attempt in the face of fontconfig problems. - * If we didn't match, pick the first, or just make something - * up so we don't NPE. - */ - if (info[0] == null) { - if (fontConfigFonts.length > 0 && - fontConfigFonts[0].firstFont.fontFile != null) { - info[0] = fontConfigFonts[0].firstFont.familyName; - info[1] = fontConfigFonts[0].firstFont.fontFile; - } else { - info[0] = "Dialog"; - info[1] = "/dialog.ttf"; - } - } - return info; - } - - public synchronized FontConfigManager getFontConfigManager() { - - if (fcManager == null) { - fcManager = new FontConfigManager(); - } - - return fcManager; + return getFontPathNative(noType1Fonts, true); } @Override
--- a/src/solaris/classes/sun/font/FcFontConfiguration.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/classes/sun/font/FcFontConfiguration.java Thu Dec 03 13:27:36 2015 -0800 @@ -39,10 +39,10 @@ import java.util.HashSet; import java.util.Properties; import java.util.Scanner; +import sun.awt.FcFontManager; import sun.awt.FontConfiguration; import sun.awt.FontDescriptor; import sun.awt.SunToolkit; -import sun.awt.X11FontManager; import sun.font.CompositeFontDescriptor; import sun.font.FontManager; import sun.font.FontConfigManager.FontConfigInfo; @@ -92,7 +92,7 @@ setFontConfiguration(); readFcInfo(); - X11FontManager fm = (X11FontManager) fontManager; + FcFontManager fm = (FcFontManager) fontManager; FontConfigManager fcm = fm.getFontConfigManager(); if (fcCompFonts == null) { fcCompFonts = fcm.loadFontConfig(); @@ -194,7 +194,7 @@ @Override public String[] getPlatformFontNames() { HashSet<String> nameSet = new HashSet<String>(); - X11FontManager fm = (X11FontManager) fontManager; + FcFontManager fm = (FcFontManager) fontManager; FontConfigManager fcm = fm.getFontConfigManager(); FcCompFont[] fcCompFonts = fcm.loadFontConfig(); for (int i=0; i<fcCompFonts.length; i++) { @@ -235,7 +235,7 @@ @Override public CompositeFontDescriptor[] get2DCompositeFontInfo() { - X11FontManager fm = (X11FontManager) fontManager; + FcFontManager fm = (FcFontManager) fontManager; FontConfigManager fcm = fm.getFontConfigManager(); FcCompFont[] fcCompFonts = fcm.loadFontConfig(); @@ -368,7 +368,7 @@ private void writeFcInfo() { Properties props = new Properties(); props.setProperty("version", fileVersion); - X11FontManager fm = (X11FontManager) fontManager; + FcFontManager fm = (FcFontManager) fontManager; FontConfigManager fcm = fm.getFontConfigManager(); FontConfigInfo fcInfo = fcm.getFontConfigInfo(); props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion)); @@ -427,7 +427,7 @@ return; } Properties props = new Properties(); - X11FontManager fm = (X11FontManager) fontManager; + FcFontManager fm = (FcFontManager) fontManager; FontConfigManager fcm = fm.getFontConfigManager(); try { FileInputStream fis = new FileInputStream(fcFile);
--- a/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,9 +68,23 @@ long pipeFds = IOUtil.makePipe(false); fd0 = (int) (pipeFds >>> 32); fd1 = (int) pipeFds; - pollWrapper = new DevPollArrayWrapper(); - pollWrapper.initInterrupt(fd0, fd1); - fdToKey = new HashMap<Integer,SelectionKeyImpl>(); + try { + pollWrapper = new DevPollArrayWrapper(); + pollWrapper.initInterrupt(fd0, fd1); + fdToKey = new HashMap<>(); + } catch (Throwable t) { + try { + FileDispatcherImpl.closeIntFD(fd0); + } catch (IOException ioe0) { + t.addSuppressed(ioe0); + } + try { + FileDispatcherImpl.closeIntFD(fd1); + } catch (IOException ioe1) { + t.addSuppressed(ioe1); + } + throw t; + } } protected int doSelect(long timeout)
--- a/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,9 +65,23 @@ long pipeFds = IOUtil.makePipe(false); fd0 = (int) (pipeFds >>> 32); fd1 = (int) pipeFds; - pollWrapper = new EPollArrayWrapper(); - pollWrapper.initInterrupt(fd0, fd1); - fdToKey = new HashMap<>(); + try { + pollWrapper = new EPollArrayWrapper(); + pollWrapper.initInterrupt(fd0, fd1); + fdToKey = new HashMap<>(); + } catch (Throwable t) { + try { + FileDispatcherImpl.closeIntFD(fd0); + } catch (IOException ioe0) { + t.addSuppressed(ioe0); + } + try { + FileDispatcherImpl.closeIntFD(fd1); + } catch (IOException ioe1) { + t.addSuppressed(ioe1); + } + throw t; + } } protected int doSelect(long timeout) throws IOException {
--- a/src/solaris/classes/sun/nio/ch/PollSelectorImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/classes/sun/nio/ch/PollSelectorImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,9 +57,23 @@ long pipeFds = IOUtil.makePipe(false); fd0 = (int) (pipeFds >>> 32); fd1 = (int) pipeFds; - pollWrapper = new PollArrayWrapper(INIT_CAP); - pollWrapper.initInterrupt(fd0, fd1); - channelArray = new SelectionKeyImpl[INIT_CAP]; + try { + pollWrapper = new PollArrayWrapper(INIT_CAP); + pollWrapper.initInterrupt(fd0, fd1); + channelArray = new SelectionKeyImpl[INIT_CAP]; + } catch (Throwable t) { + try { + FileDispatcherImpl.closeIntFD(fd0); + } catch (IOException ioe0) { + t.addSuppressed(ioe0); + } + try { + FileDispatcherImpl.closeIntFD(fd1); + } catch (IOException ioe1) { + t.addSuppressed(ioe1); + } + throw t; + } } protected int doSelect(long timeout)
--- a/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java Thu Dec 03 13:27:36 2015 -0800 @@ -86,7 +86,7 @@ // GIO private static native boolean initializeGio(); - private static native byte[] probeUsingGio(long pathAddress); + private static synchronized native byte[] probeUsingGio(long pathAddress); // GNOME VFS private static native boolean initializeGnomeVfs();
--- a/src/solaris/classes/sun/nio/fs/MimeTypesFileTypeDetector.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/classes/sun/nio/fs/MimeTypesFileTypeDetector.java Thu Dec 03 13:27:36 2015 -0800 @@ -171,7 +171,7 @@ final String EXTEQUAL = "exts="; String extRegex = "\\b" + EXTEQUAL + - "(\"[\\p{Graph}|\\p{Blank}]+?\"|\\p{Graph}+\\b)"; + "(\"[\\p{Graph}\\p{Blank}]+?\"|\\p{Graph}+\\b)"; Pattern extPattern = Pattern.compile(extRegex); Matcher extMatcher = extPattern.matcher(entry); @@ -181,7 +181,7 @@ if (exts.charAt(0) == '"') { exts = exts.substring(1, exts.length() - 1); } - String[] extList = exts.split("[\\p{Blank}|\\p{Punct}]+"); + String[] extList = exts.split("[\\p{Blank}\\p{Punct}]+"); for (String ext : extList) { putIfAbsent(ext, type); }
--- a/src/solaris/classes/sun/nio/fs/UnixFileStore.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/classes/sun/nio/fs/UnixFileStore.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -186,7 +186,8 @@ return false; UnixFileStore other = (UnixFileStore)ob; return (this.dev == other.dev) && - Arrays.equals(this.entry.dir(), other.entry.dir()); + Arrays.equals(this.entry.dir(), other.entry.dir()) && + this.entry.name().equals(other.entry.name()); } @Override
--- a/src/solaris/native/common/jni_util_md.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/native/common/jni_util_md.c Thu Dec 03 13:27:36 2015 -0800 @@ -37,6 +37,13 @@ return NULL; } +#if defined(LINUX) && (defined(_GNU_SOURCE) || \ + (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE < 200112L \ + && defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 600)) +extern int __xpg_strerror_r(int, char *, size_t); +#define strerror_r(a, b, c) __xpg_strerror_r((a), (b), (c)) +#endif + void* getProcessHandle() { static void *procHandle = NULL; if (procHandle != NULL) { @@ -59,3 +66,9 @@ } } +int +getErrorString(int err, char *buf, size_t len) +{ + if (err == 0 || len < 1) return 0; + return strerror_r(err, buf, len); +}
--- a/src/solaris/native/java/io/io_util_md.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/native/java/io/io_util_md.c Thu Dec 03 13:27:36 2015 -0800 @@ -216,13 +216,6 @@ getLastErrorString(char *buf, size_t len) { if (errno == 0 || len < 1) return 0; - - const char *err = strerror(errno); - size_t n = strlen(err); - if (n >= len) - n = len - 1; - - strncpy(buf, err, n); - buf[n] = '\0'; - return n; + getErrorString(errno, buf, len); + return strlen(buf); }
--- a/src/solaris/native/java/lang/UNIXProcess_md.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/native/java/lang/UNIXProcess_md.c Thu Dec 03 13:27:36 2015 -0800 @@ -292,12 +292,13 @@ static const char * const format = "error=%d, %s"; const char *detail = defaultDetail; char *errmsg; + char tmpbuf[1024]; jstring s; if (errnum != 0) { - const char *s = strerror(errnum); - if (strcmp(s, "Unknown error") != 0) - detail = s; + int ret = getErrorString(errnum, tmpbuf, sizeof(tmpbuf)); + if (ret != EINVAL) + detail = tmpbuf; } /* ASCII Decimal representation uses 2.4 times as many bits as binary. */ errmsg = NEW(char, strlen(format) + strlen(detail) + 3 * sizeof(errnum));
--- a/src/solaris/native/java/net/AbstractPlainDatagramSocketImpl.c Thu Dec 03 10:32:59 2015 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <sys/types.h> -#include <sys/socket.h> - -#ifdef __solaris__ -#include <unistd.h> -#include <stropts.h> - -#ifndef BSD_COMP -#define BSD_COMP -#endif - -#endif - -#include <sys/ioctl.h> - -#include "jvm.h" -#include "jni_util.h" -#include "net_util.h" - -#include "java_net_AbstractPlainDatagramSocketImpl.h" - -static jfieldID IO_fd_fdID; - -static jfieldID apdsi_fdID; - - -/* - * Class: java_net_AbstractPlainDatagramSocketImpl - * Method: init - * Signature: ()V - */ -JNIEXPORT void JNICALL -Java_java_net_AbstractPlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) { - - apdsi_fdID = (*env)->GetFieldID(env, cls, "fd", - "Ljava/io/FileDescriptor;"); - CHECK_NULL(apdsi_fdID); - - IO_fd_fdID = NET_GetFileDescriptorID(env); -} - -/* - * Class: java_net_AbstractPlainDatagramSocketImpl - * Method: dataAvailable - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_java_net_AbstractPlainDatagramSocketImpl_dataAvailable -(JNIEnv *env, jobject this) { - int fd, retval; - - jobject fdObj = (*env)->GetObjectField(env, this, apdsi_fdID); - - if (IS_NULL(fdObj)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", - "Socket closed"); - return -1; - } - fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID); - - if (ioctl(fd, FIONREAD, &retval) < 0) { - return -1; - } - return retval; -}
--- a/src/solaris/native/java/net/PlainDatagramSocketImpl.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/native/java/net/PlainDatagramSocketImpl.c Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,12 @@ #ifdef __solaris__ #include <fcntl.h> +#include <unistd.h> +#include <stropts.h> + +#ifndef BSD_COMP +#define BSD_COMP +#endif #endif #ifdef __linux__ #include <unistd.h> @@ -52,6 +58,8 @@ #endif #endif // __linux__ +#include <sys/ioctl.h> + #ifndef IPTOS_TOS_MASK #define IPTOS_TOS_MASK 0x1e #endif @@ -946,6 +954,7 @@ jobject this) { jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); int arg, fd, t = 1; + char tmpbuf[1024]; #ifdef AF_INET6 int domain = ipv6_available() ? AF_INET6 : AF_INET; #else @@ -981,14 +990,14 @@ arg = 65507; if (JVM_SetSockOpt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&arg, sizeof(arg)) < 0) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", - strerror(errno)); + getErrorString(errno, tmpbuf, sizeof(tmpbuf)); + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", tmpbuf); return; } if (JVM_SetSockOpt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&arg, sizeof(arg)) < 0) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", - strerror(errno)); + getErrorString(errno, tmpbuf, sizeof(tmpbuf)); + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", tmpbuf); return; } #endif /* __APPLE__ */ @@ -996,15 +1005,16 @@ setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char*) &t, sizeof(int)); #if defined(__linux__) - arg = 0; - int level = (domain == AF_INET6) ? IPPROTO_IPV6 : IPPROTO_IP; - if ((setsockopt(fd, level, IP_MULTICAST_ALL, (char*)&arg, sizeof(arg)) < 0) && - (errno != ENOPROTOOPT)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", - strerror(errno)); - close(fd); - return; - } + arg = 0; + int level = (domain == AF_INET6) ? IPPROTO_IPV6 : IPPROTO_IP; + if ((setsockopt(fd, level, IP_MULTICAST_ALL, (char*)&arg, sizeof(arg)) < 0) && + (errno != ENOPROTOOPT)) + { + getErrorString(errno, tmpbuf, sizeof(tmpbuf)); + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", tmpbuf); + close(fd); + return; + } #endif #if defined (__linux__) && defined (AF_INET6) @@ -2265,3 +2275,28 @@ { mcast_join_leave(env, this, iaObj, niObj, JNI_FALSE); } + +/* + * Class: java_net_PlainDatagramSocketImpl + * Method: dataAvailable + * Signature: ()I + */ +JNIEXPORT jint JNICALL +Java_java_net_PlainDatagramSocketImpl_dataAvailable(JNIEnv *env, jobject this) +{ + int fd, retval; + + jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); + + if (IS_NULL(fdObj)) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", + "Socket closed"); + return -1; + } + fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID); + + if (ioctl(fd, FIONREAD, &retval) < 0) { + return -1; + } + return retval; +}
--- a/src/solaris/native/java/util/TimeZone_md.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/native/java/util/TimeZone_md.c Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,14 +35,20 @@ #include <string.h> #include <dirent.h> #include <unistd.h> -#ifdef __solaris__ +#if defined(__solaris__) #include <libscf.h> #endif #include "jvm.h" +#include "TimeZone_md.h" #define SKIP_SPACE(p) while (*p == ' ' || *p == '\t') p++; +#if defined(_ALLBSD_SOURCE) +#define dirent64 dirent +#define readdir64_r readdir_r +#endif + #if !defined(__solaris__) || defined(__sparcv9) || defined(amd64) #define fileopen fopen #define filegets fgets @@ -50,19 +56,20 @@ #endif #if defined(__linux__) || defined(_ALLBSD_SOURCE) - - static const char *ETC_TIMEZONE_FILE = "/etc/timezone"; static const char *ZONEINFO_DIR = "/usr/share/zoneinfo"; static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime"; #else -#ifdef _AIX -static const char *ETC_ENVIRONMENT_FILE = "/etc/environment"; -#endif static const char *SYS_INIT_FILE = "/etc/default/init"; static const char *ZONEINFO_DIR = "/usr/share/lib/zoneinfo"; static const char *DEFAULT_ZONEINFO_FILE = "/usr/share/lib/zoneinfo/localtime"; -#endif /*__linux__*/ +#endif /* defined(__linux__) || defined(_ALLBSD_SOURCE) */ + +#if defined(_AIX) +static const char *ETC_ENVIRONMENT_FILE = "/etc/environment"; +#endif + +#if defined(__linux__) || defined(MACOSX) || defined(__solaris__) /* * Returns a pointer to the zone ID portion of the given zoneinfo file @@ -108,8 +115,8 @@ { DIR *dirp = NULL; struct stat statbuf; - struct dirent *dp = NULL; - struct dirent *entry = NULL; + struct dirent64 *dp = NULL; + struct dirent64 *entry = NULL; char *pathname = NULL; int fd = -1; char *dbuf = NULL; @@ -120,19 +127,13 @@ return NULL; } - entry = (struct dirent *) malloc((size_t) pathconf(dir, _PC_NAME_MAX)); + entry = (struct dirent64 *) malloc((size_t) pathconf(dir, _PC_NAME_MAX)); if (entry == NULL) { (void) closedir(dirp); return NULL; } -#if defined(_AIX) || defined(__linux__) || defined(MACOSX) || (defined(__solaris__) \ - && (defined(_POSIX_PTHREAD_SEMANTICS) || defined(_LP64))) - while (readdir_r(dirp, entry, &dp) == 0 && dp != NULL) { -#else - while ((dp = readdir_r(dirp, entry)) != NULL) { -#endif - + while (readdir64_r(dirp, entry, &dp) == 0 && dp != NULL) { /* * Skip '.' and '..' (and possibly other .* files) */ @@ -145,7 +146,7 @@ */ if ((strcmp(dp->d_name, "ROC") == 0) || (strcmp(dp->d_name, "posixrules") == 0) -#ifdef __solaris__ +#if defined(__solaris__) /* * Skip the "src" and "tab" directories on Solaris. */ @@ -230,7 +231,7 @@ char *buf; size_t size; -#ifdef __linux__ +#if defined(__linux__) /* * Try reading the /etc/timezone file for Debian distros. There's * no spec of the file format available. This parsing assumes that @@ -254,7 +255,7 @@ return tz; } } -#endif /* __linux__ */ +#endif /* defined(__linux__) */ /* * Next, try /etc/localtime to find the zone ID. @@ -318,8 +319,9 @@ free((void *) buf); return tz; } -#else -#ifdef __solaris__ + +#elif defined(__solaris__) + #if !defined(__sparcv9) && !defined(amd64) /* @@ -444,8 +446,7 @@ } /*NOTREACHED*/ } -#endif /* not __sparcv9 */ - +#endif /* !defined(__sparcv9) && !defined(amd64) */ /* * Performs Solaris dependent mapping. Returns a zone ID if @@ -546,7 +547,7 @@ } /* - * Retruns a zone ID of Solaris when the TZ value is "localtime". + * Returns a zone ID of Solaris when the TZ value is "localtime". * First, it tries scf. If scf fails, it looks for the same file as * /usr/share/lib/zoneinfo/localtime under /usr/share/lib/zoneinfo/. */ @@ -615,10 +616,11 @@ free((void *) buf); return tz; } -#endif /*__solaris__*/ -#endif /*__linux__*/ + +#endif /* defined(__solaris__) */ -#ifdef _AIX +#elif defined(_AIX) + static char * getPlatformTimeZoneID() { @@ -644,175 +646,33 @@ return tz; } -static char *mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz); -#endif -/* - * findJavaTZ_md() maps platform time zone ID to Java time zone ID - * using <java_home>/lib/tzmappings. If the TZ value is not found, it - * trys some libc implementation dependent mappings. If it still - * can't map to a Java time zone ID, it falls back to the GMT+/-hh:mm - * form. - */ -/*ARGSUSED1*/ -char * -findJavaTZ_md(const char *java_home_dir) -{ - char *tz; - char *javatz = NULL; - char *freetz = NULL; - - tz = getenv("TZ"); - -#if defined(__linux__) || defined(_ALLBSD_SOURCE) - if (tz == NULL) { -#else -#if defined (__solaris__) || defined(_AIX) - if (tz == NULL || *tz == '\0') { -#endif -#endif - tz = getPlatformTimeZoneID(); - freetz = tz; - } - - /* - * Remove any preceding ':' - */ - if (tz != NULL && *tz == ':') { - tz++; - } - -#ifdef __solaris__ - if (tz != NULL && strcmp(tz, "localtime") == 0) { - tz = getSolarisDefaultZoneID(); - freetz = tz; - } -#endif - - if (tz != NULL) { -#ifdef __linux__ - /* - * Ignore "posix/" prefix. - */ - if (strncmp(tz, "posix/", 6) == 0) { - tz += 6; - } -#endif - javatz = strdup(tz); - if (freetz != NULL) { - free((void *) freetz); - } - -#ifdef _AIX - freetz = mapPlatformToJavaTimezone(java_home_dir, javatz); - if (javatz != NULL) { - free((void *) javatz); - } - javatz = freetz; -#endif - } - - return javatz; -} - -/** - * Returns a GMT-offset-based zone ID. (e.g., "GMT-08:00") - */ - -#ifdef MACOSX - -char * -getGMTOffsetID() -{ - time_t offset; - char sign, buf[32]; - struct tm *local_tm; - time_t clock; - time_t currenttime; - - clock = time(NULL); - tzset(); - local_tm = localtime(&clock); - if (local_tm->tm_gmtoff >= 0) { - offset = (time_t) local_tm->tm_gmtoff; - sign = "+"; - } else { - offset = (time_t) -local_tm->tm_gmtoff; - sign = "-"; - } - sprintf(buf, (const char *)"GMT%c%02d:%02d", - sign, (int)(offset/3600), (int)((offset%3600)/60)); - return strdup(buf); -} -#else - -char * -getGMTOffsetID() -{ - time_t offset; - char sign, buf[32]; -#ifdef __solaris__ - struct tm localtm; - time_t currenttime; - - currenttime = time(NULL); - if (localtime_r(¤ttime, &localtm) == NULL) { - return NULL; - } - - offset = localtm.tm_isdst ? altzone : timezone; -#else - offset = timezone; -#endif /*__linux__*/ - - if (offset == 0) { - return strdup("GMT"); - } - - /* Note that the time offset direction is opposite. */ - if (offset > 0) { - sign = '-'; - } else { - offset = -offset; - sign = '+'; - } - sprintf(buf, (const char *)"GMT%c%02d:%02d", - sign, (int)(offset/3600), (int)((offset%3600)/60)); - return strdup(buf); -} -#endif /* MACOSX */ - -#ifdef _AIX static char * mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz) { FILE *tzmapf; - char mapfilename[PATH_MAX+1]; + char mapfilename[PATH_MAX + 1]; char line[256]; int linecount = 0; - char temp[100], *temp_tz; + char *tz_buf = NULL; + char *temp_tz = NULL; char *javatz = NULL; - char *str_tmp = NULL; - size_t temp_tz_len = 0; + size_t tz_len = 0; /* On AIX, the TZ environment variable may end with a comma - * followed by modifier fields. These are ignored here. - */ - strncpy(temp, tz, 100); - temp_tz = strtok_r(temp, ",", &str_tmp); + * followed by modifier fields. These are ignored here. */ + temp_tz = strchr(tz, ','); + tz_len = (temp_tz == NULL) ? strlen(tz) : temp_tz - tz; + tz_buf = (char *)malloc(tz_len + 1); + memcpy(tz_buf, tz, tz_len); + tz_buf[tz_len] = 0; - if(temp_tz == NULL) - goto tzerr; - - temp_tz_len = strlen(temp_tz); - - if (strlen(java_home_dir) >= (PATH_MAX - 15)) { - jio_fprintf(stderr, "java.home longer than maximum path length \n"); + /* Open tzmappings file, with buffer overrun check */ + if ((strlen(java_home_dir) + 15) > PATH_MAX) { + jio_fprintf(stderr, "Path %s/lib/tzmappings exceeds maximum path length\n", java_home_dir); goto tzerr; } - - strncpy(mapfilename, java_home_dir, PATH_MAX); + strcpy(mapfilename, java_home_dir); strcat(mapfilename, "/lib/tzmappings"); - if ((tzmapf = fopen(mapfilename, "r")) == NULL) { jio_fprintf(stderr, "can't open %s\n", mapfilename); goto tzerr; @@ -845,7 +705,7 @@ } *p++ = '\0'; - if ((result = strncmp(temp_tz, sol, temp_tz_len)) == 0) { + if ((result = strncmp(tz_buf, sol, tz_len)) == 0) { /* * If this is the current platform zone ID, * take the Java time zone ID (2nd field). @@ -871,11 +731,150 @@ (void) fclose(tzmapf); tzerr: + if (tz_buf != NULL ) { + free((void *) tz_buf); + } + if (javatz == NULL) { return getGMTOffsetID(); } return javatz; } + +#endif /* defined(_AIX) */ + +/* + * findJavaTZ_md() maps platform time zone ID to Java time zone ID + * using <java_home>/lib/tzmappings. If the TZ value is not found, it + * trys some libc implementation dependent mappings. If it still + * can't map to a Java time zone ID, it falls back to the GMT+/-hh:mm + * form. + */ +/*ARGSUSED1*/ +char * +findJavaTZ_md(const char *java_home_dir) +{ + char *tz; + char *javatz = NULL; + char *freetz = NULL; + + tz = getenv("TZ"); + + if (tz == NULL || *tz == '\0') { + tz = getPlatformTimeZoneID(); + freetz = tz; + } + + if (tz != NULL) { + /* Ignore preceding ':' */ + if (*tz == ':') { + tz++; + } +#if defined(__linux__) + /* Ignore "posix/" prefix on Linux. */ + if (strncmp(tz, "posix/", 6) == 0) { + tz += 6; + } #endif +#if defined(_AIX) + /* On AIX do the platform to Java mapping. */ + javatz = mapPlatformToJavaTimezone(java_home_dir, tz); + if (freetz != NULL) { + free((void *) freetz); + } +#else +#if defined(__solaris__) + /* Solaris might use localtime, so handle it here. */ + if (strcmp(tz, "localtime") == 0) { + javatz = getSolarisDefaultZoneID(); + if (freetz != NULL) { + free((void *) freetz); + } + } else +#endif + if (freetz == NULL) { + /* strdup if we are still working on getenv result. */ + javatz = strdup(tz); + } else if (freetz != tz) { + /* strdup and free the old buffer, if we moved the pointer. */ + javatz = strdup(tz); + free((void *) freetz); + } else { + /* we are good if we already work on a freshly allocated buffer. */ + javatz = tz; + } +#endif + } + + return javatz; +} + +/** + * Returns a GMT-offset-based zone ID. (e.g., "GMT-08:00") + */ + +#if defined(MACOSX) + +char * +getGMTOffsetID() +{ + time_t offset; + char sign, buf[32]; + struct tm *local_tm; + time_t clock; + time_t currenttime; + + clock = time(NULL); + tzset(); + local_tm = localtime(&clock); + if (local_tm->tm_gmtoff >= 0) { + offset = (time_t) local_tm->tm_gmtoff; + sign = '+'; + } else { + offset = (time_t) -local_tm->tm_gmtoff; + sign = '-'; + } + sprintf(buf, (const char *)"GMT%c%02d:%02d", + sign, (int)(offset/3600), (int)((offset%3600)/60)); + return strdup(buf); +} + +#else + +char * +getGMTOffsetID() +{ + time_t offset; + char sign, buf[32]; +#if defined(__solaris__) + struct tm localtm; + time_t currenttime; + + currenttime = time(NULL); + if (localtime_r(¤ttime, &localtm) == NULL) { + return NULL; + } + + offset = localtm.tm_isdst ? altzone : timezone; +#else + offset = timezone; +#endif + + if (offset == 0) { + return strdup("GMT"); + } + + /* Note that the time offset direction is opposite. */ + if (offset > 0) { + sign = '-'; + } else { + offset = -offset; + sign = '+'; + } + sprintf(buf, (const char *)"GMT%c%02d:%02d", + sign, (int)(offset/3600), (int)((offset%3600)/60)); + return strdup(buf); +} +#endif /* MACOSX */
--- a/src/solaris/native/sun/awt/fontpath.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/native/sun/awt/fontpath.c Thu Dec 03 13:27:36 2015 -0800 @@ -497,7 +497,7 @@ * This also frees us from X11 APIs as JRE is required to function in * a "headless" mode where there is no Xserver. */ -static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) { +static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1, jboolean isX11) { char **fcdirs = NULL, **x11dirs = NULL, **knowndirs = NULL, *path = NULL; @@ -519,6 +519,7 @@ * be initialised. */ #ifndef HEADLESS + if (isX11) { // The following only works in an x11 environment. #if defined(__linux__) /* There's no headless build on linux ... */ if (!AWTIsHeadless()) { /* .. so need to call a function to check */ @@ -538,6 +539,7 @@ #if defined(__linux__) } #endif + } #endif /* !HEADLESS */ path = mergePaths(fcdirs, x11dirs, knowndirs, noType1); if (fcdirs != NULL) { @@ -555,13 +557,13 @@ return path; } -JNIEXPORT jstring JNICALL Java_sun_awt_X11FontManager_getFontPathNative -(JNIEnv *env, jobject thiz, jboolean noType1) { +JNIEXPORT jstring JNICALL Java_sun_awt_FcFontManager_getFontPathNative +(JNIEnv *env, jobject thiz, jboolean noType1, jboolean isX11) { jstring ret; static char *ptr = NULL; /* retain result across calls */ if (ptr == NULL) { - ptr = getPlatformFontPathChars(env, noType1); + ptr = getPlatformFontPathChars(env, noType1, isX11); } ret = (*env)->NewStringUTF(env, ptr); return ret; @@ -1217,10 +1219,11 @@ minGlyphs = val; } } + FcCharSet *unionCharset = NULL; for (j=0; j<nfonts; j++) { FcPattern *fontPattern = fontset->fonts[j]; FcChar8 *fontformat; - FcCharSet *unionCharset = NULL, *charset; + FcCharSet *charset = NULL; fontformat = NULL; (*FcPatternGetString)(fontPattern, FC_FONTFORMAT, 0, &fontformat); @@ -1278,6 +1281,9 @@ if (!includeFallbacks) { break; } + if (fontCount == 254) { + break; // CompositeFont will only use up to 254 slots from here. + } } /* Once we get here 'fontCount' is the number of returned fonts
--- a/src/solaris/native/sun/management/LinuxOperatingSystem.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/native/sun/management/LinuxOperatingSystem.c Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -76,14 +76,17 @@ static int get_totalticks(int which, ticks *pticks) { FILE *fh; uint64_t userTicks, niceTicks, systemTicks, idleTicks; + uint64_t iowTicks = 0, irqTicks = 0, sirqTicks= 0; int n; if((fh = fopen("/proc/stat", "r")) == NULL) { return -1; } - n = fscanf(fh, "cpu " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64, - &userTicks, &niceTicks, &systemTicks, &idleTicks); + n = fscanf(fh, "cpu " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64 " " + DEC_64 " " DEC_64, + &userTicks, &niceTicks, &systemTicks, &idleTicks, + &iowTicks, &irqTicks, &sirqTicks); // Move to next line next_line(fh); @@ -92,24 +95,30 @@ if (which != -1) { int i; for (i = 0; i < which; i++) { - if (fscanf(fh, "cpu%*d " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64, &userTicks, &niceTicks, &systemTicks, &idleTicks) != 4) { + if (fscanf(fh, "cpu%*d " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64 " " + DEC_64 " " DEC_64 " " DEC_64, + &userTicks, &niceTicks, &systemTicks, &idleTicks, + &iowTicks, &irqTicks, &sirqTicks) < 4) { fclose(fh); return -2; } next_line(fh); } - n = fscanf(fh, "cpu%*d " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64 "\n", - &userTicks, &niceTicks, &systemTicks, &idleTicks); + n = fscanf(fh, "cpu%*d " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64 " " + DEC_64 " " DEC_64 " " DEC_64 "\n", + &userTicks, &niceTicks, &systemTicks, &idleTicks, + &iowTicks, &irqTicks, &sirqTicks); } fclose(fh); - if (n != 4) { + if (n < 4) { return -2; } pticks->used = userTicks + niceTicks; - pticks->usedKernel = systemTicks; - pticks->total = userTicks + niceTicks + systemTicks + idleTicks; + pticks->usedKernel = systemTicks + irqTicks + sirqTicks; + pticks->total = userTicks + niceTicks + systemTicks + idleTicks + + iowTicks + irqTicks + sirqTicks; return 0; }
--- a/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c Thu Dec 03 13:27:36 2015 -0800 @@ -308,21 +308,15 @@ JNIEXPORT jbyteArray Java_sun_nio_fs_UnixNativeDispatcher_strerror(JNIEnv* env, jclass this, jint error) { - char* msg; + char tmpbuf[1024]; jsize len; jbyteArray bytes; -#ifdef _AIX - /* strerror() is not thread-safe on AIX so we have to use strerror_r() */ - char buffer[256]; - msg = (strerror_r((int)error, buffer, 256) == 0) ? buffer : "Error while calling strerror_r"; -#else - msg = strerror((int)error); -#endif - len = strlen(msg); + getErrorString((int)errno, tmpbuf, sizeof(tmpbuf)); + len = strlen(tmpbuf); bytes = (*env)->NewByteArray(env, len); if (bytes != NULL) { - (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)msg); + (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)tmpbuf); } return bytes; }
--- a/src/windows/classes/java/net/DefaultDatagramSocketImplFactory.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/classes/java/net/DefaultDatagramSocketImplFactory.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ class DefaultDatagramSocketImplFactory { - static Class<?> prefixImplClass = null; + private final static Class<?> prefixImplClass; /* the windows version. */ private static float version; @@ -54,16 +54,19 @@ private static boolean preferIPv4Stack = false; /* If the version supports a dual stack TCP implementation */ - private static boolean useDualStackImpl = false; + private final static boolean useDualStackImpl; /* sun.net.useExclusiveBind */ private static String exclBindProp; /* True if exclusive binding is on for Windows */ - private static boolean exclusiveBind = true; - + private final static boolean exclusiveBind; static { + Class<?> prefixImplClassLocal = null; + boolean useDualStackImplLocal = false; + boolean exclusiveBindLocal = true; + // Determine Windows Version. java.security.AccessController.doPrivileged( new PrivilegedAction<Object>() { @@ -78,7 +81,7 @@ "java.net.preferIPv4Stack")); exclBindProp = System.getProperty( "sun.net.useExclusiveBind"); - } catch (NumberFormatException e ) { + } catch (NumberFormatException e) { assert false : e; } return null; // nothing to return @@ -87,14 +90,14 @@ // (version >= 6.0) implies Vista or greater. if (version >= 6.0 && !preferIPv4Stack) { - useDualStackImpl = true; + useDualStackImplLocal = true; } if (exclBindProp != null) { // sun.net.useExclusiveBind is true - exclusiveBind = exclBindProp.length() == 0 ? true + exclusiveBindLocal = exclBindProp.length() == 0 ? true : Boolean.parseBoolean(exclBindProp); } else if (version < 6.0) { - exclusiveBind = false; + exclusiveBindLocal = false; } // impl.prefix @@ -103,12 +106,16 @@ prefix = AccessController.doPrivileged( new sun.security.action.GetPropertyAction("impl.prefix", null)); if (prefix != null) - prefixImplClass = Class.forName("java.net."+prefix+"DatagramSocketImpl"); + prefixImplClassLocal = Class.forName("java.net."+prefix+"DatagramSocketImpl"); } catch (Exception e) { System.err.println("Can't find class: java.net." + prefix + "DatagramSocketImpl: check impl.prefix property"); } + + prefixImplClass = prefixImplClassLocal; + useDualStackImpl = useDualStackImplLocal; + exclusiveBind = exclusiveBindLocal; } /** @@ -126,12 +133,10 @@ throw new SocketException("can't instantiate DatagramSocketImpl"); } } else { - if (isMulticast) - exclusiveBind = false; if (useDualStackImpl && !isMulticast) return new DualStackPlainDatagramSocketImpl(exclusiveBind); else - return new TwoStacksPlainDatagramSocketImpl(exclusiveBind); + return new TwoStacksPlainDatagramSocketImpl(exclusiveBind && !isMulticast); } } }
--- a/src/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,10 @@ { static JavaIOFileDescriptorAccess fdAccess = SharedSecrets.getJavaIOFileDescriptorAccess(); + static { + initIDs(); + } + // true if this socket is exclusively bound private final boolean exclusiveBind; @@ -288,4 +292,6 @@ int optionValue) throws SocketException; private static native int socketGetIntOption(int fd, int cmd) throws SocketException; + + native int dataAvailable(); }
--- a/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -207,6 +207,8 @@ protected native void disconnect0(int family); + native int dataAvailable(); + /** * Perform class load-time initializations. */
--- a/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java Thu Dec 03 13:27:36 2015 -0800 @@ -248,14 +248,6 @@ } } - @SuppressWarnings("deprecation") - public boolean requestFocusToEmbedder() { - if (isEmbeddedInIE) { - return ((WEmbeddedFramePeer) getPeer()).requestFocusToEmbedder(); - } - return false; - } - public void registerAccelerator(AWTKeyStroke stroke) {} public void unregisterAccelerator(AWTKeyStroke stroke) {}
--- a/src/windows/classes/sun/awt/windows/WEmbeddedFramePeer.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/classes/sun/awt/windows/WEmbeddedFramePeer.java Thu Dec 03 13:27:36 2015 -0800 @@ -79,10 +79,4 @@ return !Win32GraphicsEnvironment.isDWMCompositionEnabled(); } - /** - * Sets the focus to plugin control window, the parent of embedded frame. - * Eventually, it will synthesizeWindowActivation to activate the embedded frame, - * if plugin control window gets the focus. - */ - public native boolean requestFocusToEmbedder(); }
--- a/src/windows/classes/sun/nio/fs/WindowsConstants.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/classes/sun/nio/fs/WindowsConstants.java Thu Dec 03 13:27:36 2015 -0800 @@ -98,6 +98,7 @@ public static final int ERROR_DISK_FULL = 112; public static final int ERROR_INSUFFICIENT_BUFFER = 122; public static final int ERROR_INVALID_LEVEL = 124; + public static final int ERROR_DIR_NOT_ROOT = 144; public static final int ERROR_DIR_NOT_EMPTY = 145; public static final int ERROR_ALREADY_EXISTS = 183; public static final int ERROR_MORE_DATA = 234;
--- a/src/windows/classes/sun/nio/fs/WindowsFileStore.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/classes/sun/nio/fs/WindowsFileStore.java Thu Dec 03 13:27:36 2015 -0800 @@ -86,14 +86,28 @@ WindowsFileAttributes.get(file, true); target = file.getPathForWin32Calls(); } - String root = GetVolumePathName(target); - return new WindowsFileStore(root); + try { + return createFromPath(target); + } catch (WindowsException e) { + if (e.lastError() != ERROR_DIR_NOT_ROOT) + throw e; + target = WindowsLinkSupport.getFinalPath(file); + if (target == null) + throw new FileSystemException(file.getPathForExceptionMessage(), + null, "Couldn't resolve path"); + return createFromPath(target); + } } catch (WindowsException x) { x.rethrowAsIOException(file); return null; // keep compiler happy } } + private static WindowsFileStore createFromPath(String target) throws WindowsException { + String root = GetVolumePathName(target); + return new WindowsFileStore(root); + } + VolumeInformation volumeInformation() { return volInfo; }
--- a/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java Thu Dec 03 13:27:36 2015 -0800 @@ -66,7 +66,7 @@ * Returns the final path (all symbolic links resolved) or null if this * operation is not supported. */ - private static String getFinalPath(WindowsPath input) throws IOException { + static String getFinalPath(WindowsPath input) throws IOException { long h = 0; try { h = input.openForReadAttributeAccess(true);
--- a/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java Thu Dec 03 13:27:36 2015 -0800 @@ -37,6 +37,17 @@ private WindowsNativeDispatcher() { } /** + * HANDLE CreateEvent( + * LPSECURITY_ATTRIBUTES lpEventAttributes, + * BOOL bManualReset, + * BOOL bInitialState, + * PCTSTR lpName + * ); + */ + static native long CreateEvent(boolean bManualReset, boolean bInitialState) + throws WindowsException; + + /** * HANDLE CreateFile( * LPCTSTR lpFileName, * DWORD dwDesiredAccess, @@ -1041,6 +1052,25 @@ long pOverlapped) throws WindowsException; + + /** + * CancelIo( + * HANDLE hFile + * ) + */ + static native void CancelIo(long hFile) throws WindowsException; + + /** + * GetOverlappedResult( + * HANDLE hFile, + * LPOVERLAPPED lpOverlapped, + * LPDWORD lpNumberOfBytesTransferred, + * BOOL bWait + * ); + */ + static native int GetOverlappedResult(long hFile, long lpOverlapped) + throws WindowsException; + /** * BackupRead( * HANDLE hFile,
--- a/src/windows/classes/sun/nio/fs/WindowsWatchService.java Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/classes/sun/nio/fs/WindowsWatchService.java Thu Dec 03 13:27:36 2015 -0800 @@ -25,9 +25,16 @@ package sun.nio.fs; -import java.nio.file.*; import java.io.IOException; -import java.util.*; +import java.nio.file.NotDirectoryException; +import java.nio.file.Path; +import java.nio.file.StandardWatchEventKinds; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + import com.sun.nio.file.ExtendedWatchEventModifier; import sun.misc.Unsafe; @@ -42,7 +49,6 @@ extends AbstractWatchService { private final static int WAKEUP_COMPLETION_KEY = 0; - private final Unsafe unsafe = Unsafe.getUnsafe(); // background thread to service I/O completion port private final Poller poller; @@ -82,7 +88,7 @@ /** * Windows implementation of WatchKey. */ - private class WindowsWatchKey extends AbstractWatchKey { + private static class WindowsWatchKey extends AbstractWatchKey { // file key (used to detect existing registrations) private final FileKey fileKey; @@ -169,15 +175,9 @@ return completionKey; } - // close directory and release buffer - void releaseResources() { - CloseHandle(handle); - buffer.cleaner().clean(); - } - - // Invalidate key by closing directory and releasing buffer + // Invalidate the key, assumes that resources have been released void invalidate() { - releaseResources(); + ((WindowsWatchService)watcher()).poller.releaseResources(this); handle = INVALID_HANDLE_VALUE; buffer = null; countAddress = 0; @@ -193,7 +193,7 @@ public void cancel() { if (isValid()) { // delegate to poller - poller.cancel(this); + ((WindowsWatchService)watcher()).poller.cancel(this); } } } @@ -241,18 +241,25 @@ /** * Background thread to service I/O completion port. */ - private class Poller extends AbstractPoller { + private static class Poller extends AbstractPoller { + private final static Unsafe UNSAFE = Unsafe.getUnsafe(); + /* * typedef struct _OVERLAPPED { - * DWORD Internal; - * DWORD InternalHigh; - * DWORD Offset; - * DWORD OffsetHigh; - * HANDLE hEvent; + * ULONG_PTR Internal; + * ULONG_PTR InternalHigh; + * union { + * struct { DWORD Offset; DWORD OffsetHigh; }; + * PVOID Pointer; + * }; + * HANDLE hEvent; * } OVERLAPPED; */ private static final short SIZEOF_DWORD = 4; private static final short SIZEOF_OVERLAPPED = 32; // 20 on 32-bit + private static final short OFFSETOF_HEVENT = + (UNSAFE.addressSize() == 4) ? (short) 16 : 24; + /* * typedef struct _FILE_NOTIFY_INFORMATION { @@ -276,10 +283,10 @@ private final long port; // maps completion key to WatchKey - private final Map<Integer,WindowsWatchKey> ck2key; + private final Map<Integer, WindowsWatchKey> ck2key; // maps file key to WatchKey - private final Map<FileKey,WindowsWatchKey> fk2key; + private final Map<FileKey, WindowsWatchKey> fk2key; // unique completion key for each directory // native completion key capacity is 64 bits on Win64. @@ -393,8 +400,13 @@ long overlappedAddress = bufferAddress + size - SIZEOF_OVERLAPPED; long countAddress = overlappedAddress - SIZEOF_DWORD; + // zero the overlapped structure + UNSAFE.setMemory(overlappedAddress, SIZEOF_OVERLAPPED, (byte)0); + // start async read of changes to directory try { + createAndAttachEvent(overlappedAddress); + ReadDirectoryChangesW(handle, bufferAddress, CHANGES_BUFFER_SIZE, @@ -403,6 +415,7 @@ countAddress, overlappedAddress); } catch (WindowsException x) { + closeAttachedEvent(overlappedAddress); buffer.release(); return new IOException(x.getMessage()); } @@ -421,7 +434,7 @@ // 2. release existing key's resources (handle/buffer) // 3. re-initialize key with new handle/buffer ck2key.remove(existing.completionKey()); - existing.releaseResources(); + releaseResources(existing); watchKey = existing.init(handle, events, watchSubtree, buffer, countAddress, overlappedAddress, completionKey); } @@ -436,6 +449,42 @@ } } + /** + * Cancels the outstanding I/O operation on the directory + * associated with the given key and releases the associated + * resources. + */ + private void releaseResources(WindowsWatchKey key) { + try { + CancelIo(key.handle()); + GetOverlappedResult(key.handle(), key.overlappedAddress()); + } catch (WindowsException expected) { + // expected as I/O operation has been cancelled + } + CloseHandle(key.handle()); + closeAttachedEvent(key.overlappedAddress()); + key.buffer().cleaner().clean(); + } + + /** + * Creates an unnamed event and set it as the hEvent field + * in the given OVERLAPPED structure + */ + private void createAndAttachEvent(long ov) throws WindowsException { + long hEvent = CreateEvent(false, false); + UNSAFE.putAddress(ov + OFFSETOF_HEVENT, hEvent); + } + + /** + * Closes the event attached to the given OVERLAPPED structure. A + * no-op if there isn't an event attached. + */ + private void closeAttachedEvent(long ov) { + long hEvent = UNSAFE.getAddress(ov + OFFSETOF_HEVENT); + if (hEvent != 0 && hEvent != INVALID_HANDLE_VALUE) + CloseHandle(hEvent); + } + // cancel single key @Override void implCancelKey(WatchKey obj) { @@ -451,9 +500,8 @@ @Override void implCloseAll() { // cancel all keys - for (Map.Entry<Integer, WindowsWatchKey> entry: ck2key.entrySet()) { - entry.getValue().invalidate(); - } + ck2key.values().forEach(WindowsWatchKey::invalidate); + fk2key.clear(); ck2key.clear(); @@ -462,8 +510,7 @@ } // Translate file change action into watch event - private WatchEvent.Kind<?> translateActionToEvent(int action) - { + private WatchEvent.Kind<?> translateActionToEvent(int action) { switch (action) { case FILE_ACTION_MODIFIED : return StandardWatchEventKinds.ENTRY_MODIFY; @@ -487,18 +534,18 @@ int nextOffset; do { - int action = unsafe.getInt(address + OFFSETOF_ACTION); + int action = UNSAFE.getInt(address + OFFSETOF_ACTION); // map action to event WatchEvent.Kind<?> kind = translateActionToEvent(action); if (key.events().contains(kind)) { // copy the name - int nameLengthInBytes = unsafe.getInt(address + OFFSETOF_FILENAMELENGTH); + int nameLengthInBytes = UNSAFE.getInt(address + OFFSETOF_FILENAMELENGTH); if ((nameLengthInBytes % 2) != 0) { - throw new AssertionError("FileNameLength.FileNameLength is not a multiple of 2"); + throw new AssertionError("FileNameLength is not a multiple of 2"); } char[] nameAsArray = new char[nameLengthInBytes/2]; - unsafe.copyMemory(null, address + OFFSETOF_FILENAME, nameAsArray, + UNSAFE.copyMemory(null, address + OFFSETOF_FILENAME, nameAsArray, Unsafe.ARRAY_CHAR_BASE_OFFSET, nameLengthInBytes); // create FileName and queue event @@ -508,7 +555,7 @@ } // next event - nextOffset = unsafe.getInt(address + OFFSETOF_NEXTENTRYOFFSET); + nextOffset = UNSAFE.getInt(address + OFFSETOF_NEXTENTRYOFFSET); address += (long)nextOffset; } while (nextOffset != 0); }
--- a/src/windows/native/common/jni_util_md.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/common/jni_util_md.c Thu Dec 03 13:27:36 2015 -0800 @@ -142,6 +142,15 @@ return (void*)GetModuleHandle(NULL); } +int +getErrorString(int err, char *buf, size_t len) +{ + int ret = 0; + if (err == 0 || len < 1) return 0; + ret = strerror_s(buf, len, err); + return ret; +} + /* * Windows symbols can be simple like JNI_OnLoad or __stdcall format * like _JNI_OnLoad@8. We need to handle both.
--- a/src/windows/native/java/net/AbstractPlainDatagramSocketImpl.c Thu Dec 03 10:32:59 2015 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <windows.h> -#include <winsock2.h> - -#include "jvm.h" -#include "jni_util.h" -#include "net_util.h" - -#include "java_net_AbstractPlainDatagramSocketImpl.h" - -static jfieldID IO_fd_fdID = NULL; -static jfieldID apdsi_fdID = NULL; - -static jfieldID apdsi_fd1ID = NULL; -static jclass two_stacks_clazz = NULL; - - -/* - * Class: java_net_AbstractPlainDatagramSocketImpl - * Method: init - * Signature: ()V - */ -JNIEXPORT void JNICALL -Java_java_net_AbstractPlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) { - - apdsi_fdID = (*env)->GetFieldID(env, cls, "fd", - "Ljava/io/FileDescriptor;"); - CHECK_NULL(apdsi_fdID); - IO_fd_fdID = NET_GetFileDescriptorID(env); - CHECK_NULL(IO_fd_fdID); - - two_stacks_clazz = (*env)->FindClass(env, "java/net/TwoStacksPlainDatagramSocketImpl"); - CHECK_NULL(two_stacks_clazz); - - /* Handle both TwoStacks and DualStack here */ - - if (JNU_Equals(env, cls, two_stacks_clazz)) { - /* fd1 present only in TwoStack.. */ - apdsi_fd1ID = (*env)->GetFieldID(env, cls, "fd1", - "Ljava/io/FileDescriptor;"); - CHECK_NULL(apdsi_fd1ID); - } - - JNU_CHECK_EXCEPTION(env); -} - -/* - * Class: java_net_AbstractPlainDatagramSocketImpl - * Method: dataAvailable - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_java_net_AbstractPlainDatagramSocketImpl_dataAvailable -(JNIEnv *env, jobject this) { - SOCKET fd; - SOCKET fd1; - int rv = -1, rv1 = -1; - jobject fdObj = (*env)->GetObjectField(env, this, apdsi_fdID); - - if (!IS_NULL(fdObj)) { - int retval = 0; - fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID); - rv = ioctlsocket(fd, FIONREAD, &retval); - if (retval > 0) { - return retval; - } - } - - if (!IS_NULL(apdsi_fd1ID)) { - /* TwoStacks */ - jobject fd1Obj = (*env)->GetObjectField(env, this, apdsi_fd1ID); - if (!IS_NULL(fd1Obj)) { - int retval = 0; - fd1 = (SOCKET)(*env)->GetIntField(env, fd1Obj, IO_fd_fdID); - rv1 = ioctlsocket(fd1, FIONREAD, &retval); - if (retval > 0) { - return retval; - } - } - } - - if (rv < 0 && rv1 < 0) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", - "Socket closed"); - return -1; - } - - return 0; -} -
--- a/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,6 +70,25 @@ return got_icmp; } +static jfieldID IO_fd_fdID = NULL; +static jfieldID pdsi_fdID = NULL; + +/* + * Class: java_net_DualStackPlainDatagramSocketImpl + * Method: initIDs + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_initIDs + (JNIEnv *env, jclass clazz) +{ + pdsi_fdID = (*env)->GetFieldID(env, clazz, "fd", + "Ljava/io/FileDescriptor;"); + CHECK_NULL(pdsi_fdID); + IO_fd_fdID = NET_GetFileDescriptorID(env); + CHECK_NULL(IO_fd_fdID); + JNU_CHECK_EXCEPTION(env); +} + /* * Class: java_net_DualStackPlainDatagramSocketImpl * Method: socketCreate @@ -498,3 +517,32 @@ return result; } + +/* + * Class: java_net_DualStackPlainDatagramSocketImpl + * Method: dataAvailable + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_dataAvailable +(JNIEnv *env, jobject this) { + SOCKET fd; + int rv = -1; + jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); + + if (!IS_NULL(fdObj)) { + int retval = 0; + fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID); + rv = ioctlsocket(fd, FIONREAD, &retval); + if (retval > 0) { + return retval; + } + } + + if (rv < 0) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", + "Socket closed"); + return -1; + } + + return 0; +}
--- a/src/windows/native/java/net/Inet4AddressImpl.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/java/net/Inet4AddressImpl.c Thu Dec 03 13:27:36 2015 -0800 @@ -31,6 +31,8 @@ #include <malloc.h> #include <sys/types.h> #include <process.h> +#include <iphlpapi.h> +#include <icmpapi.h> #include "java_net_InetAddress.h" #include "java_net_Inet4AddressImpl.h" @@ -290,134 +292,36 @@ } -/** - * ping implementation. - * Send a ICMP_ECHO_REQUEST packet every second until either the timeout - * expires or a answer is received. - * Returns true is an ECHO_REPLY is received, otherwise, false. - */ -static jboolean -ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout, - struct sockaddr_in* netif, jint ttl) { - jint size; - jint n, len, hlen1, icmplen; - char sendbuf[1500]; - char recvbuf[1500]; - struct icmp *icmp; - struct ip *ip; - WSAEVENT hEvent; - struct sockaddr sa_recv; - jint tmout2; - u_short pid, seq; - int read_rv = 0; - - /* Initialize the sequence number to a suitable random number and - shift right one place to allow sufficient room for increamenting. */ - seq = ((unsigned short)rand()) >> 1; - - /* icmp_id is a 16 bit data type, therefore down cast the pid */ - pid = (u_short) _getpid(); - size = 60*1024; - setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char *) &size, sizeof(size)); - /** - * A TTL was specified, let's set the socket option. - */ - if (ttl > 0) { - setsockopt(fd, IPPROTO_IP, IP_TTL, (const char *) &ttl, sizeof(ttl)); - } - - /** - * A network interface was specified, let's bind to it. - */ - if (netif != NULL) { - if (bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in)) < 0) { - NET_ThrowNew(env, WSAGetLastError(), "Can't bind socket"); - closesocket(fd); - return JNI_FALSE; - } - } - - /** - * Let's make the socket non blocking - */ - hEvent = WSACreateEvent(); - WSAEventSelect(fd, hEvent, FD_READ|FD_CONNECT|FD_CLOSE); - /** - * send 1 ICMP REQUEST every second until either we get a valid reply - * or the timeout expired. - */ - do { - /** - * construct the ICMP header - */ - memset(sendbuf, 0, 1500); - icmp = (struct icmp *) sendbuf; - icmp->icmp_type = ICMP_ECHO; - icmp->icmp_code = 0; - icmp->icmp_id = htons(pid); - icmp->icmp_seq = htons(seq); - /** - * checksum has to be set to zero before we can calculate the - * real checksum! - */ - icmp->icmp_cksum = 0; - icmp->icmp_cksum = in_cksum((u_short *)icmp, 64); - /** - * Ping! - */ - n = sendto(fd, sendbuf, 64, 0, (struct sockaddr *)him, - sizeof(struct sockaddr)); - if (n < 0 && WSAGetLastError() != WSAEWOULDBLOCK) { - NET_ThrowNew(env, WSAGetLastError(), "Can't send ICMP packet"); - closesocket(fd); - WSACloseEvent(hEvent); - return JNI_FALSE; - } +static BOOL +WindowsVersionCheck(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) { + OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 }; + DWORDLONG const dwlConditionMask = VerSetConditionMask( + VerSetConditionMask( + VerSetConditionMask( + 0, VER_MAJORVERSION, VER_GREATER_EQUAL), + VER_MINORVERSION, VER_GREATER_EQUAL), + VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); - /* - * wait for 1 second at most - */ - tmout2 = timeout > 1000 ? 1000 : timeout; - do { - tmout2 = NET_Wait(env, fd, NET_WAIT_READ, tmout2); - if (tmout2 >= 0) { - len = sizeof(sa_recv); - n = recvfrom(fd, recvbuf, sizeof(recvbuf), 0, &sa_recv, &len); - ip = (struct ip*) recvbuf; - hlen1 = (ip->ip_hl) << 2; - icmp = (struct icmp *) (recvbuf + hlen1); - icmplen = n - hlen1; - /** - * Is that a proper ICMP reply? - */ - if (icmplen >= 8 && icmp->icmp_type == ICMP_ECHOREPLY && - (ntohs(icmp->icmp_seq) == seq) && (ntohs(icmp->icmp_id) == pid)) { - closesocket(fd); - WSACloseEvent(hEvent); - return JNI_TRUE; - } - } - } while (tmout2 > 0); - timeout -= 1000; - seq++; - } while (timeout > 0); - closesocket(fd); - WSACloseEvent(hEvent); - return JNI_FALSE; + osvi.dwMajorVersion = wMajorVersion; + osvi.dwMinorVersion = wMinorVersion; + osvi.wServicePackMajor = wServicePackMajor; + + return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE; } -/* - * Class: java_net_Inet4AddressImpl - * Method: isReachable0 - * Signature: ([bI[bI)Z - */ -JNIEXPORT jboolean JNICALL -Java_java_net_Inet4AddressImpl_isReachable0(JNIEnv *env, jobject this, - jbyteArray addrArray, - jint timeout, - jbyteArray ifArray, - jint ttl) { +static BOOL +isVistaSP1OrGreater() { + return WindowsVersionCheck(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 1); +} + +static jboolean +wxp_ping4(JNIEnv *env, + jbyteArray addrArray, + jint timeout, + jbyteArray ifArray, + jint ttl) +{ jint addr; jbyte caddr[4]; jint fd; @@ -434,7 +338,7 @@ */ sz = (*env)->GetArrayLength(env, addrArray); if (sz != 4) { - return JNI_FALSE; + return JNI_FALSE; } memset((char *) &him, 0, sizeof(him)); memset((char *) caddr, 0, sizeof(caddr)); @@ -456,39 +360,19 @@ * as well. */ if (!(IS_NULL(ifArray))) { - memset((char *) caddr, 0, sizeof(caddr)); - (*env)->GetByteArrayRegion(env, ifArray, 0, 4, caddr); - addr = ((caddr[0]<<24) & 0xff000000); - addr |= ((caddr[1] <<16) & 0xff0000); - addr |= ((caddr[2] <<8) & 0xff00); - addr |= (caddr[3] & 0xff); - addr = htonl(addr); - inf.sin_addr.s_addr = addr; - inf.sin_family = AF_INET; - inf.sin_port = 0; - netif = &inf; + memset((char *) caddr, 0, sizeof(caddr)); + (*env)->GetByteArrayRegion(env, ifArray, 0, 4, caddr); + addr = ((caddr[0]<<24) & 0xff000000); + addr |= ((caddr[1] <<16) & 0xff0000); + addr |= ((caddr[2] <<8) & 0xff00); + addr |= (caddr[3] & 0xff); + addr = htonl(addr); + inf.sin_addr.s_addr = addr; + inf.sin_family = AF_INET; + inf.sin_port = 0; + netif = &inf; } -#if 0 - /* - * Windows implementation of ICMP & RAW sockets is too unreliable for now. - * Therefore it's best not to try it at all and rely only on TCP - * We may revisit and enable this code in the future. - */ - - /* - * Let's try to create a RAW socket to send ICMP packets - * This usually requires "root" privileges, so it's likely to fail. - */ - fd = NET_Socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); - if (fd != -1) { - /* - * It didn't fail, so we can use ICMP_ECHO requests. - */ - return ping4(env, fd, &him, timeout, netif, ttl); - } -#endif - /* * Can't create a raw socket, so let's try a TCP socket */ @@ -502,17 +386,17 @@ return JNI_FALSE; } if (ttl > 0) { - setsockopt(fd, IPPROTO_IP, IP_TTL, (const char *)&ttl, sizeof(ttl)); + setsockopt(fd, IPPROTO_IP, IP_TTL, (const char *)&ttl, sizeof(ttl)); } /* * A network interface was specified, so let's bind to it. */ if (netif != NULL) { - if (bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in)) < 0) { - NET_ThrowNew(env, WSAGetLastError(), "Can't bind socket"); - closesocket(fd); - return JNI_FALSE; - } + if (bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in)) < 0) { + NET_ThrowNew(env, WSAGetLastError(), "Can't bind socket"); + closesocket(fd); + return JNI_FALSE; + } } /* @@ -541,9 +425,9 @@ case WSAENETUNREACH: /* Network Unreachable */ case WSAENETDOWN: /* Network is down */ case WSAEPFNOSUPPORT: /* Protocol Family unsupported */ - WSACloseEvent(hEvent); - closesocket(fd); - return JNI_FALSE; + WSACloseEvent(hEvent); + closesocket(fd); + return JNI_FALSE; } if (WSAGetLastError() != WSAEWOULDBLOCK) { @@ -559,20 +443,141 @@ /* has connection been established */ if (timeout >= 0) { - optlen = sizeof(connect_rv); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv, - &optlen) <0) { - connect_rv = WSAGetLastError(); - } + optlen = sizeof(connect_rv); + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv, + &optlen) <0) { + connect_rv = WSAGetLastError(); + } - if (connect_rv == 0 || connect_rv == WSAECONNREFUSED) { - WSACloseEvent(hEvent); - closesocket(fd); - return JNI_TRUE; - } + if (connect_rv == 0 || connect_rv == WSAECONNREFUSED) { + WSACloseEvent(hEvent); + closesocket(fd); + return JNI_TRUE; + } } } WSACloseEvent(hEvent); closesocket(fd); return JNI_FALSE; } + +/** + * ping implementation. + * Send a ICMP_ECHO_REQUEST packet every second until either the timeout + * expires or a answer is received. + * Returns true is an ECHO_REPLY is received, otherwise, false. + */ +static jboolean +ping4(JNIEnv *env, + unsigned long src_addr, + unsigned long dest_addr, + jint timeout) +{ + // See https://msdn.microsoft.com/en-us/library/aa366050%28VS.85%29.aspx + + HANDLE hIcmpFile; + DWORD dwRetVal = 0; + char SendData[32] = {0}; + LPVOID ReplyBuffer = NULL; + DWORD ReplySize = 0; + + hIcmpFile = IcmpCreateFile(); + if (hIcmpFile == INVALID_HANDLE_VALUE) { + NET_ThrowNew(env, WSAGetLastError(), "Unable to open handle"); + return JNI_FALSE; + } + + ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData); + ReplyBuffer = (VOID*) malloc(ReplySize); + if (ReplyBuffer == NULL) { + IcmpCloseHandle(hIcmpFile); + NET_ThrowNew(env, WSAGetLastError(), "Unable to allocate memory"); + return JNI_FALSE; + } + + if (src_addr == 0) { + dwRetVal = IcmpSendEcho(hIcmpFile, // HANDLE IcmpHandle, + dest_addr, // IPAddr DestinationAddress, + SendData, // LPVOID RequestData, + sizeof(SendData), // WORD RequestSize, + NULL, // PIP_OPTION_INFORMATION RequestOptions, + ReplyBuffer,// LPVOID ReplyBuffer, + ReplySize, // DWORD ReplySize, + timeout); // DWORD Timeout + } else { + dwRetVal = IcmpSendEcho2Ex(hIcmpFile, // HANDLE IcmpHandle, + NULL, // HANDLE Event + NULL, // PIO_APC_ROUTINE ApcRoutine + NULL, // ApcContext + src_addr, // IPAddr SourceAddress, + dest_addr, // IPAddr DestinationAddress, + SendData, // LPVOID RequestData, + sizeof(SendData), // WORD RequestSize, + NULL, // PIP_OPTION_INFORMATION RequestOptions, + ReplyBuffer,// LPVOID ReplyBuffer, + ReplySize, // DWORD ReplySize, + timeout); // DWORD Timeout + } + + free(ReplyBuffer); + IcmpCloseHandle(hIcmpFile); + + if (dwRetVal != 0) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } +} + +/* + * Class: java_net_Inet4AddressImpl + * Method: isReachable0 + * Signature: ([bI[bI)Z + */ +JNIEXPORT jboolean JNICALL +Java_java_net_Inet4AddressImpl_isReachable0(JNIEnv *env, jobject this, + jbyteArray addrArray, + jint timeout, + jbyteArray ifArray, + jint ttl) { + + if (isVistaSP1OrGreater()) { + jint src_addr = 0; + jint dest_addr = 0; + jbyte caddr[4]; + int sz; + + /** + * Convert IP address from byte array to integer + */ + sz = (*env)->GetArrayLength(env, addrArray); + if (sz != 4) { + return JNI_FALSE; + } + memset((char *) caddr, 0, sizeof(caddr)); + (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr); + dest_addr = ((caddr[0]<<24) & 0xff000000); + dest_addr |= ((caddr[1] <<16) & 0xff0000); + dest_addr |= ((caddr[2] <<8) & 0xff00); + dest_addr |= (caddr[3] & 0xff); + dest_addr = htonl(dest_addr); + + /** + * If a network interface was specified, let's convert its address + * as well. + */ + if (!(IS_NULL(ifArray))) { + memset((char *) caddr, 0, sizeof(caddr)); + (*env)->GetByteArrayRegion(env, ifArray, 0, 4, caddr); + src_addr = ((caddr[0]<<24) & 0xff000000); + src_addr |= ((caddr[1] <<16) & 0xff0000); + src_addr |= ((caddr[2] <<8) & 0xff00); + src_addr |= (caddr[3] & 0xff); + src_addr = htonl(src_addr); + } + + return ping4(env, src_addr, dest_addr, timeout); + } else { + wxp_ping4(env, addrArray, timeout, ifArray, ttl); + } +}
--- a/src/windows/native/java/net/Inet6AddressImpl.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/java/net/Inet6AddressImpl.c Thu Dec 03 13:27:36 2015 -0800 @@ -31,6 +31,8 @@ #include <malloc.h> #include <sys/types.h> #include <process.h> +#include <iphlpapi.h> +#include <icmpapi.h> #include "java_net_InetAddress.h" #include "java_net_Inet4AddressImpl.h" @@ -366,139 +368,61 @@ * Returns true is an ECHO_REPLY is received, otherwise, false. */ static jboolean -ping6(JNIEnv *env, jint fd, struct SOCKADDR_IN6* him, jint timeout, - struct SOCKADDR_IN6* netif, jint ttl) { - jint size; - jint n, len, i; - char sendbuf[1500]; - char auxbuf[1500]; - unsigned char recvbuf[1500]; - struct icmp6_hdr *icmp6; - struct SOCKADDR_IN6 sa_recv; - unsigned short pid, seq; - int read_rv = 0; - WSAEVENT hEvent; - struct ip6_pseudo_hdr *pseudo_ip6; - int timestamp; - int tmout2; +ping6(JNIEnv *env, + struct sockaddr_in6* src, + struct sockaddr_in6* dest, + jint timeout) +{ + HANDLE hIcmpFile; + DWORD dwRetVal = 0; + char SendData[32] = {0}; + LPVOID ReplyBuffer = NULL; + DWORD ReplySize = 0; + IP_OPTION_INFORMATION ipInfo = {255, 0, 0, 0, NULL}; + struct sockaddr_in6 sa6Source; - /* Initialize the sequence number to a suitable random number and - shift right one place to allow sufficient room for increamenting. */ - seq = ((unsigned short)rand()) >> 1; - - /* icmp_id is a 16 bit data type, therefore down cast the pid */ - pid = (unsigned short) _getpid(); - - size = 60*1024; - setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char *)&size, sizeof(size)); - /** - * A TTL was specified, let's set the socket option. - */ - if (ttl > 0) { - setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (const char *) &ttl, sizeof(ttl)); + hIcmpFile = Icmp6CreateFile(); + if (hIcmpFile == INVALID_HANDLE_VALUE) { + NET_ThrowNew(env, WSAGetLastError(), "Unable to open handle"); + return JNI_FALSE; } - /** - * A network interface was specified, let's bind to it. - */ - if (netif != NULL) { - if (NET_Bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in6)) < 0){ - NET_ThrowNew(env, WSAGetLastError(), "Can't bind socket to interface"); - closesocket(fd); + ReplySize = sizeof(ICMPV6_ECHO_REPLY) + sizeof(SendData); + ReplyBuffer = (VOID*) malloc(ReplySize); + if (ReplyBuffer == NULL) { + IcmpCloseHandle(hIcmpFile); + NET_ThrowNew(env, WSAGetLastError(), "Unable to allocate memory"); return JNI_FALSE; - } } - /* - * Make the socket non blocking - */ - hEvent = WSACreateEvent(); - WSAEventSelect(fd, hEvent, FD_READ|FD_CONNECT|FD_CLOSE); - - /** - * send 1 ICMP REQUEST every second until either we get a valid reply - * or the timeout expired. - */ - do { - /* let's tag the ECHO packet with our pid so we can identify it */ - timestamp = GetCurrentTime(); - memset(sendbuf, 0, 1500); - icmp6 = (struct icmp6_hdr *) sendbuf; - icmp6->icmp6_type = ICMP6_ECHO_REQUEST; - icmp6->icmp6_code = 0; - icmp6->icmp6_id = htons(pid); - icmp6->icmp6_seq = htons(seq); - icmp6->icmp6_cksum = 0; - memcpy((icmp6 + 1), ×tamp, sizeof(int)); - if (netif != NULL) { - memset(auxbuf, 0, 1500); - pseudo_ip6 = (struct ip6_pseudo_hdr*) auxbuf; - memcpy(&pseudo_ip6->ip6_src, &netif->sin6_addr, sizeof(struct in6_addr)); - memcpy(&pseudo_ip6->ip6_dst, &him->sin6_addr, sizeof(struct in6_addr)); - pseudo_ip6->ip6_plen= htonl( 64 ); - pseudo_ip6->ip6_nxt = htonl( IPPROTO_ICMPV6 ); - memcpy(auxbuf + sizeof(struct ip6_pseudo_hdr), icmp6, 64); - /** - * We shouldn't have to do that as computing the checksum is supposed - * to be done by the IPv6 stack. Unfortunately windows, here too, is - * uterly broken, or non compliant, so let's do it. - * Problem is to compute the checksum I need to know the source address - * which happens only if I know the interface to be used... - */ - icmp6->icmp6_cksum = in_cksum((u_short *)pseudo_ip6, sizeof(struct ip6_pseudo_hdr) + 64); - } + //define local source information + sa6Source.sin6_addr = in6addr_any; + sa6Source.sin6_family = AF_INET6; + sa6Source.sin6_flowinfo = 0; + sa6Source.sin6_port = 0; - /** - * Ping! - */ - n = sendto(fd, sendbuf, 64, 0, (struct sockaddr*) him, sizeof(struct sockaddr_in6)); - if (n < 0 && (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEADDRNOTAVAIL)) { - // Happens when using a "tunnel interface" for instance. - // Or trying to send a packet on a different scope. - closesocket(fd); - WSACloseEvent(hEvent); - return JNI_FALSE; - } - if (n < 0 && WSAGetLastError() != WSAEWOULDBLOCK) { - NET_ThrowNew(env, WSAGetLastError(), "Can't send ICMP packet"); - closesocket(fd); - WSACloseEvent(hEvent); - return JNI_FALSE; - } - - tmout2 = timeout > 1000 ? 1000 : timeout; - do { - tmout2 = NET_Wait(env, fd, NET_WAIT_READ, tmout2); + dwRetVal = Icmp6SendEcho2(hIcmpFile, // HANDLE IcmpHandle, + NULL, // HANDLE Event, + NULL, // PIO_APC_ROUTINE ApcRoutine, + NULL, // PVOID ApcContext, + &sa6Source, // struct sockaddr_in6 *SourceAddress, + dest, // struct sockaddr_in6 *DestinationAddress, + SendData, // LPVOID RequestData, + sizeof(SendData), // WORD RequestSize, + &ipInfo, // PIP_OPTION_INFORMATION RequestOptions, + ReplyBuffer, // LPVOID ReplyBuffer, + ReplySize, // DWORD ReplySize, + timeout); // DWORD Timeout - if (tmout2 >= 0) { - len = sizeof(sa_recv); - memset(recvbuf, 0, 1500); - /** - * For some unknown reason, besides plain stupidity, windows - * truncates the first 4 bytes of the icmpv6 header some we can't - * check for the ICMP_ECHOREPLY value. - * we'll check the other values, though - */ - n = recvfrom(fd, recvbuf + 4, sizeof(recvbuf) - 4, 0, (struct sockaddr*) &sa_recv, &len); - icmp6 = (struct icmp6_hdr *) (recvbuf); - memcpy(&i, (icmp6 + 1), sizeof(int)); - /** - * Is that the reply we were expecting? - */ - if (n >= 8 && ntohs(icmp6->icmp6_seq) == seq && - ntohs(icmp6->icmp6_id) == pid && i == timestamp) { - closesocket(fd); - WSACloseEvent(hEvent); - return JNI_TRUE; - } - } - } while (tmout2 > 0); - timeout -= 1000; - seq++; - } while (timeout > 0); - closesocket(fd); - WSACloseEvent(hEvent); - return JNI_FALSE; + free(ReplyBuffer); + IcmpCloseHandle(hIcmpFile); + + + if (dwRetVal != 0) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } #endif /* AF_INET6 */ @@ -516,11 +440,10 @@ jint ttl, jint if_scope) { #ifdef AF_INET6 jbyte caddr[16]; - jint fd, sz; + jint sz; struct sockaddr_in6 him6; struct sockaddr_in6* netif = NULL; struct sockaddr_in6 inf6; - WSAEVENT hEvent; int len = 0; int connect_rv = -1; @@ -552,6 +475,7 @@ him6.sin6_scope_id = scope; } len = sizeof(struct sockaddr_in6); + /** * A network interface was specified, let's convert the address */ @@ -565,123 +489,7 @@ inf6.sin6_scope_id = if_scope; netif = &inf6; } - -#if 0 - /* - * Windows implementation of ICMP & RAW sockets is too unreliable for now. - * Therefore it's best not to try it at all and rely only on TCP - * We may revisit and enable this code in the future. - */ - - /* - * Right now, windows doesn't generate the ICMP checksum automatically - * so we have to compute it, but we can do it only if we know which - * interface will be used. Therefore, don't try to use ICMP if no - * interface was specified. - * When ICMPv6 support improves in windows, we may change this. - */ - if (!(IS_NULL(ifArray))) { - /* - * If we can create a RAW socket, then when can use the ICMP ECHO_REQUEST - * otherwise we'll try a tcp socket to the Echo port (7). - * Note that this is empiric, and not connecting could mean it's blocked - * or the echo servioe has been disabled. - */ - fd = NET_Socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6); - - if (fd != -1) { /* Good to go, let's do a ping */ - return ping6(env, fd, &him6, timeout, netif, ttl); - } - } -#endif - - /* No good, let's fall back on TCP */ - fd = NET_Socket(AF_INET6, SOCK_STREAM, 0); - if (fd == JVM_IO_ERR) { - /* note: if you run out of fds, you may not be able to load - * the exception class, and get a NoClassDefFoundError - * instead. - */ - NET_ThrowNew(env, errno, "Can't create socket"); - return JNI_FALSE; - } - - /** - * A TTL was specified, let's set the socket option. - */ - if (ttl > 0) { - setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (const char *)&ttl, sizeof(ttl)); - } - - /** - * A network interface was specified, let's bind to it. - */ - if (netif != NULL) { - if (NET_Bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in6)) < 0) { - NET_ThrowNew(env, WSAGetLastError(), "Can't bind socket to interface"); - closesocket(fd); - return JNI_FALSE; - } - } - - /** - * Make the socket non blocking. - */ - hEvent = WSACreateEvent(); - WSAEventSelect(fd, hEvent, FD_READ|FD_CONNECT|FD_CLOSE); - - /* no need to use NET_Connect as non-blocking */ - him6.sin6_port = htons((short) 7); /* Echo port */ - connect_rv = connect(fd, (struct sockaddr *)&him6, len); - - /** - * connection established or refused immediately, either way it means - * we were able to reach the host! - */ - if (connect_rv == 0 || WSAGetLastError() == WSAECONNREFUSED) { - WSACloseEvent(hEvent); - closesocket(fd); - return JNI_TRUE; - } else { - int optlen; - - switch (WSAGetLastError()) { - case WSAEHOSTUNREACH: /* Host Unreachable */ - case WSAENETUNREACH: /* Network Unreachable */ - case WSAENETDOWN: /* Network is down */ - case WSAEPFNOSUPPORT: /* Protocol Family unsupported */ - WSACloseEvent(hEvent); - closesocket(fd); - return JNI_FALSE; - } - - if (WSAGetLastError() != WSAEWOULDBLOCK) { - NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException", - "connect failed"); - WSACloseEvent(hEvent); - closesocket(fd); - return JNI_FALSE; - } - - timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout); - - if (timeout >= 0) { - /* has connection been established? */ - optlen = sizeof(connect_rv); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv, - &optlen) <0) { - connect_rv = WSAGetLastError(); - } - - if (connect_rv == 0 || connect_rv == WSAECONNREFUSED) { - WSACloseEvent(hEvent); - closesocket(fd); - return JNI_TRUE; - } - } - } - WSACloseEvent(hEvent); - closesocket(fd); + return ping6(env, netif, &him6, timeout); #endif /* AF_INET6 */ return JNI_FALSE; }
--- a/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2239,8 +2239,11 @@ optlen = sizeof(optval.i); if (NET_GetSockOpt(fd, level, optname, (void *)&optval, &optlen) < 0) { - char errmsg[255]; - sprintf(errmsg, "error getting socket option: %s\n", strerror(errno)); + char tmpbuf[255]; + int size = 0; + char errmsg[255 + 31]; + getErrorString(errno, tmpbuf, sizeof(tmpbuf)); + sprintf(errmsg, "error getting socket option: %s", tmpbuf); JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", errmsg); return NULL; } @@ -2591,3 +2594,44 @@ { mcast_join_leave (env, this, iaObj, niObj, JNI_FALSE); } + +/* + * Class: java_net_TwoStacksPlainDatagramSocketImpl + * Method: dataAvailable + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_java_net_TwoStacksPlainDatagramSocketImpl_dataAvailable +(JNIEnv *env, jobject this) { + SOCKET fd; + SOCKET fd1; + int rv = -1, rv1 = -1; + jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); + jobject fd1Obj; + + if (!IS_NULL(fdObj)) { + int retval = 0; + fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID); + rv = ioctlsocket(fd, FIONREAD, &retval); + if (retval > 0) { + return retval; + } + } + + fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID); + if (!IS_NULL(fd1Obj)) { + int retval = 0; + fd1 = (SOCKET)(*env)->GetIntField(env, fd1Obj, IO_fd_fdID); + rv1 = ioctlsocket(fd1, FIONREAD, &retval); + if (retval > 0) { + return retval; + } + } + + if (rv < 0 && rv1 < 0) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", + "Socket closed"); + return -1; + } + + return 0; +}
--- a/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -114,8 +114,9 @@ // which may've been disposed by this time, and we have // no means of checking against it. if (oldhDC != NULL) { - MoveDCToPassiveList(oldhDC); + MoveDCToPassiveList(oldhDC, info->hWnd); info->hDC = NULL; + info->hWnd = NULL; } if (wsdo->window != NULL){ @@ -150,6 +151,7 @@ // Finally, set these new values in the info for this thread info->hDC = hDC; + info->hWnd = wsdo->window; } // cached brush and pen are not associated with any DC, and can be @@ -187,7 +189,7 @@ if (info->hDC != NULL) { // move the DC from the active dcs list to // the passive dc list to be released later - MoveDCToPassiveList(info->hDC); + MoveDCToPassiveList(info->hDC, info->hWnd); } if (info->clip != NULL) {
--- a/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -196,6 +196,7 @@ */ typedef struct { HDC hDC; + HWND hWnd; GDIWinSDOps *wsdo; LONG wsdoTimeStamp; // wsdo creation time stamp. // Other threads may deallocate wsdo
--- a/src/windows/native/sun/nio/ch/Net.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/sun/nio/ch/Net.c Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -157,7 +157,7 @@ if (loopback_available) { int rv = NET_EnableFastTcpLoopback((jint)s); if (rv) { - if (rv == WSAEOPNOTSUPP) { + if (rv == WSAEOPNOTSUPP || rv == WSAEINVAL) { loopback_available = 0; } else { NET_ThrowNew(env, rv, "fastLoopback");
--- a/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c Thu Dec 03 13:27:36 2015 -0800 @@ -195,6 +195,17 @@ } } +JNIEXPORT jlong JNICALL +Java_sun_nio_fs_WindowsNativeDispatcher_CreateEvent(JNIEnv* env, jclass this, + jboolean bManualReset, jboolean bInitialState) +{ + HANDLE hEvent = CreateEventW(NULL, bManualReset, bInitialState, NULL); + if (hEvent == NULL) { + throwWindowsException(env, GetLastError()); + } + return ptr_to_jlong(hEvent); +} + JNIEXPORT jstring JNICALL Java_sun_nio_fs_WindowsNativeDispatcher_FormatMessage(JNIEnv* env, jclass this, jint errorCode) { WCHAR message[255]; @@ -1230,23 +1241,38 @@ } JNIEXPORT void JNICALL +Java_sun_nio_fs_WindowsNativeDispatcher_CancelIo(JNIEnv* env, jclass this, jlong hFile) { + if (CancelIo((HANDLE)jlong_to_ptr(hFile)) == 0) { + throwWindowsException(env, GetLastError()); + } +} + +JNIEXPORT jint JNICALL +Java_sun_nio_fs_WindowsNativeDispatcher_GetOverlappedResult(JNIEnv *env, jclass this, + jlong hFile, jlong lpOverlapped) +{ + BOOL res; + DWORD bytesTransferred = -1; + + res = GetOverlappedResult((HANDLE)jlong_to_ptr(hFile), + (LPOVERLAPPED)jlong_to_ptr(lpOverlapped), + &bytesTransferred, + TRUE); + if (res == 0) { + throwWindowsException(env, GetLastError()); + } + + return (jint)bytesTransferred; +} + +JNIEXPORT void JNICALL Java_sun_nio_fs_WindowsNativeDispatcher_ReadDirectoryChangesW(JNIEnv* env, jclass this, jlong hDirectory, jlong bufferAddress, jint bufferLength, jboolean watchSubTree, jint filter, jlong bytesReturnedAddress, jlong pOverlapped) { BOOL res; BOOL subtree = (watchSubTree == JNI_TRUE) ? TRUE : FALSE; - - /* Any unused members of [OVERLAPPED] structure should always be initialized to zero - before the structure is used in a function call. - Otherwise, the function may fail and return ERROR_INVALID_PARAMETER. - http://msdn.microsoft.com/en-us/library/windows/desktop/ms684342%28v=vs.85%29.aspx - - The [Offset] and [OffsetHigh] members of this structure are not used. - http://msdn.microsoft.com/en-us/library/windows/desktop/aa365465%28v=vs.85%29.aspx - - [hEvent] should be zero, other fields are the return values. */ - ZeroMemory((LPOVERLAPPED)jlong_to_ptr(pOverlapped), sizeof(OVERLAPPED)); + LPOVERLAPPED ov = (LPOVERLAPPED)jlong_to_ptr(pOverlapped); res = ReadDirectoryChangesW((HANDLE)jlong_to_ptr(hDirectory), (LPVOID)jlong_to_ptr(bufferAddress),
--- a/src/windows/native/sun/windows/awt_Component.cpp Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/sun/windows/awt_Component.cpp Thu Dec 03 13:27:36 2015 -0800 @@ -1382,7 +1382,7 @@ case WM_AWT_RELEASEDC: { HDC hDC = (HDC)wParam; - MoveDCToPassiveList(hDC); + MoveDCToPassiveList(hDC, GetHWnd()); ReleaseDCList(GetHWnd(), passiveDCList); mr = mrConsume; break; @@ -7174,8 +7174,8 @@ } /** - * Given a DC, remove it from the DC list and return - * TRUE if it exists on the current list. Otherwise + * Given a DC and window handle, remove the DC from the DC list + * and return TRUE if it exists on the current list. Otherwise * return FALSE. * A DC may not exist on the list because it has already * been released elsewhere (for example, the window @@ -7183,14 +7183,14 @@ * thread may also want to release a DC when it notices that * its DC is obsolete for the current window). */ -DCItem *DCList::RemoveDC(HDC hDC) +DCItem *DCList::RemoveDC(HDC hDC, HWND hWnd) { listLock.Enter(); DCItem **prevPtrPtr = &head; DCItem *listPtr = head; while (listPtr) { DCItem *nextPtr = listPtr->next; - if (listPtr->hDC == hDC) { + if (listPtr->hDC == hDC && listPtr->hWnd == hWnd) { *prevPtrPtr = nextPtr; break; } @@ -7244,9 +7244,9 @@ listLock.Leave(); } -void MoveDCToPassiveList(HDC hDC) { +void MoveDCToPassiveList(HDC hDC, HWND hWnd) { DCItem *removedDC; - if ((removedDC = activeDCList.RemoveDC(hDC)) != NULL) { + if ((removedDC = activeDCList.RemoveDC(hDC, hWnd)) != NULL) { passiveDCList.AddDCItem(removedDC); } }
--- a/src/windows/native/sun/windows/awt_Component.h Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/sun/windows/awt_Component.h Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -900,13 +900,13 @@ void AddDC(HDC hDC, HWND hWnd); void AddDCItem(DCItem *newItem); - DCItem *RemoveDC(HDC hDC); + DCItem *RemoveDC(HDC hDC, HWND hWnd); DCItem *RemoveAllDCs(HWND hWnd); void RealizePalettes(int screen); }; void ReleaseDCList(HWND hwnd, DCList &list); -void MoveDCToPassiveList(HDC hDC); +void MoveDCToPassiveList(HDC hDC, HWND hWnd); namespace TimeHelper{ jlong getMessageTimeUTC();
--- a/src/windows/native/sun/windows/awt_Frame.cpp Thu Dec 03 10:32:59 2015 -0800 +++ b/src/windows/native/sun/windows/awt_Frame.cpp Thu Dec 03 13:27:36 2015 -0800 @@ -1961,29 +1961,6 @@ CATCH_BAD_ALLOC; } -JNIEXPORT jboolean JNICALL -Java_sun_awt_windows_WEmbeddedFramePeer_requestFocusToEmbedder(JNIEnv *env, jobject self) -{ - jboolean result = JNI_FALSE; - - TRY; - - AwtFrame *frame = NULL; - - PDATA pData; - JNI_CHECK_PEER_GOTO(self, ret); - frame = (AwtFrame *)pData; - - // JDK-8056915: During initial applet activation, set focus to plugin control window - HWND hwndParent = ::GetParent(frame->GetHWnd()); - - result = SetFocusToPluginControl(hwndParent); - - CATCH_BAD_ALLOC_RET(JNI_FALSE); -ret: - return result; -} - } /* extern "C" */ static bool SetFocusToPluginControl(HWND hwndPlugin)
--- a/test/TEST.groups Thu Dec 03 10:32:59 2015 -0800 +++ b/test/TEST.groups Thu Dec 03 13:27:36 2015 -0800 @@ -327,6 +327,7 @@ java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java \ java/lang/invoke/lambda/LambdaAccessControlTest.java \ java/lang/invoke/lambda/LambdaAsm.java \ + java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java \ java/lang/System/MacEncoding/TestFileEncoding.java \ java/net/URLClassLoader/closetest/GetResourceAsStream.java \ java/util/Collections/EmptyIterator.java \ @@ -489,7 +490,6 @@ java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java \ java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java \ java/lang/System/MacEncoding/TestFileEncoding.java \ - java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java \ java/nio/channels/AsynchronousSocketChannel/Leaky.java \ java/security/PermissionCollection/Concurrent.java \ java/security/Principal/Implies.java \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Toolkit/AutoShutdown/EventQueuePush/EventQueuePushAutoshutdown.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + test + @bug 8081485 + @summary tests that a program terminates automatically after EventQueue.push() + @author Anton Nashatyrev : area=toolkit +*/ + +import java.awt.*; + +public class EventQueuePushAutoshutdown implements Runnable { + private volatile int status = 2; + + public EventQueuePushAutoshutdown() throws Exception { + Runtime.getRuntime().addShutdownHook(new Thread(this)); + Thread thread = new Thread() { + @Override + public void run() { + status = 0; + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + status = 1; + System.exit(status); + } + } + }; + thread.setDaemon(true); + thread.start(); + + System.setProperty("java.awt.headless", "true"); + final EventQueue systemQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); + systemQueue.push(new EventQueue()); + EventQueue.invokeAndWait(new Runnable() { + @Override + public void run() { + System.out.println("Activated EDT"); + } + }); + System.out.println("After EDT activation"); + } + + public static void main(String[] args) throws Exception { + new EventQueuePushAutoshutdown(); + } + + @Override + public void run() { + Runtime.getRuntime().halt(status); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Toolkit/AutoShutdown/EventQueuePush/EventQueuePushAutoshutdown.sh Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,159 @@ +#!/bin/ksh -p + +# +# Copyright (c) 20015, 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 EventQueuePushAutoshutdown.sh +# @bug 8081485 +# @summary tests that a program terminates automatically +# after EventQueue.push() +# @author Anton Nashatyrev : area=toolkit +# +# @compile EventQueuePushAutoshutdown.java +# @run shell EventQueuePushAutoshutdown.sh + + +# Beginning of subroutines: +status=1 + +#Call this from anywhere to fail the test with an error message +# usage: fail "reason why the test failed" +fail() + { echo "The test failed :-(" + echo "$*" 1>&2 + echo "exit status was $status" + exit $status + } #end of fail() + +#Call this from anywhere to pass the test with a message +# usage: pass "reason why the test passed if applicable" +pass() + { echo "The test passed!!!" + echo "$*" 1>&2 + exit 0 + } #end of pass() + +# end of subroutines + + +# The beginning of the script proper +OS=`uname -s` +case "$OS" in + SunOS | Linux | Darwin | CYGWIN* ) + FILESEP="/" + ;; + + Windows_95 | Windows_98 | Windows_NT | Windows_ME ) + FILESEP="\\" + ;; + + # catch all other OSs + * ) + echo "Unrecognized system! $OS" + fail "Unrecognized system! $OS" + ;; +esac + + +# Want this test to run standalone as well as in the harness, so do the +# following to copy the test's directory into the harness's scratch directory +# and set all appropriate variables: + +if [ -z "${TESTJAVA}" ] ; then + # TESTJAVA is not set, so the test is running stand-alone. + # TESTJAVA holds the path to the root directory of the build of the JDK + # to be tested. That is, any java files run explicitly in this shell + # should use TESTJAVA in the path to the java interpreter. + # So, we'll set this to the JDK spec'd on the command line. If none + # is given on the command line, tell the user that and use a cheesy + # default. + # THIS IS THE JDK BEING TESTED. + if [ -n "$1" ] ; + then TESTJAVA=$1 + else fail "no JDK specified on command line!" + fi + TESTSRC=. + TESTCLASSES=. + STANDALONE=1; +fi +echo "JDK under test is: $TESTJAVA" + +#Deal with .class files: +if [ -n "${STANDALONE}" ] ; + then + #if standalone, remind user to cd to dir. containing test before running it + echo "Just a reminder: cd to the dir containing this test when running it" + # then compile all .java files (if there are any) into .class files + if [ -a *.java ] ; + then echo "Reminder, this test should be in its own directory with all" + echo "supporting files it needs in the directory with it." + ${TESTJAVA}/bin/javac ./*.java ; + fi + # else in harness so copy all the class files from where jtreg put them + # over to the scratch directory this test is running in. + else cp ${TESTCLASSES}/*.class . ; +fi + +#if in test harness, then copy the entire directory that the test is in over +# to the scratch directory. This catches any support files needed by the test. +if [ -z "${STANDALONE}" ] ; + then cp ${TESTSRC}/* . +fi + +#Just before executing anything, make sure it has executable permission! +chmod 777 ./* + +############### YOUR TEST CODE HERE!!!!!!! ############# + +#All files required for the test should be in the same directory with +# this file. If converting a standalone test to run with the harness, +# as long as all files are in the same directory and it returns 0 for +# pass, you should be able to cut and paste it into here and it will +# run with the test harness. + +${TESTJAVA}/bin/java EventQueuePushAutoshutdown + +############### END YOUR TEST CODE !!!!! ############ +#Be sure the last command executed above this line returns 0 for success, +# something non-zero for failure. +status=$? + +# pass or fail the test based on status of the command +case "$status" in + 0 ) + pass "" + ;; + + 1 ) + fail "The program didn't automatically shut down" + ;; + + * ) + fail "The program terminated unexpectedly!" + ;; +esac + +#For additional examples of how to write platform independent KSH scripts, +# see the jtreg file itself. It is a KSH script for both Solaris and Win32 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/datatransfer/DataFlavor/MacOsXFileAndMultipleFileCopingTest/MacOsXFileAndMultipleFileCopingTest.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,368 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + @test + @bug 8081787 8136763 + @author Mikhail Cherkasov + @run main/manual MacOsXFileAndMultipleFileCopingTest +*/ + +import javax.swing.*; +import java.awt.*; +import java.awt.datatransfer.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URL; + +public class MacOsXFileAndMultipleFileCopingTest { + private static void init() { + String[] instructions = + {"Test for MacOS X only:", + "1. The aim is to test that java works fine with \"application/" + + "x-java-url;class=java.net.URL\"falvor and support coping of multiple files", + "2. Open finder and select any file.", + "3. Press CMD+C or press \"Copy\" in context menu", + "4. Focus window with \"Test URL\" Button.", + "5. If you see URL for selected file, then test PASSED,", + "otherwise test FAILED.", + + "6. Open finder again and select several files.", + "7. Press CMD+C or press \"Copy\" in context menu", + "8. Focus window with \"Test multiple files coping\" Button.", + "9. If you see list of selected files, then test PASSED,", + "otherwise test FAILED.", + + }; + + Sysout.createDialog(); + Sysout.printInstructions(instructions); + + final Frame frame = new Frame(); + Panel panel = new Panel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); + + frame.add(panel); + Button testUrlBtn = new Button("Test URL"); + final TextArea textArea = new TextArea(5, 80); + testUrlBtn.addActionListener(new AbstractAction() { + @Override + public void actionPerformed(ActionEvent ae) { + try { + Clipboard board = Toolkit.getDefaultToolkit().getSystemClipboard(); + URL url = (URL) board.getData(new DataFlavor("application/x-java-url;class=java.net.URL")); + textArea.setText(url.toString()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }); + panel.add(testUrlBtn); + Button testUriList = new Button("Test multiple files coping"); + testUriList.addActionListener(new AbstractAction() { + @Override + public void actionPerformed(ActionEvent ae) { + try { + Clipboard board = Toolkit.getDefaultToolkit().getSystemClipboard(); + String files = (String) board.getData(new DataFlavor("text/uri-list;class=java.lang.String")); + textArea.setText(files); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }); + panel.add(testUriList); + panel.add(textArea); + frame.setBounds(200, 200, 400, 400); + frame.setVisible(true); + + }//End init() + + + /***************************************************** + * Standard Test Machinery Section + * DO NOT modify anything in this section -- it's a + * standard chunk of code which has all of the + * synchronisation necessary for the test harness. + * By keeping it the same in all tests, it is easier + * to read and understand someone else's test, as + * well as insuring that all tests behave correctly + * with the test harness. + * There is a section following this for test-defined + * classes + ******************************************************/ + private static boolean theTestPassed = false; + private static boolean testGeneratedInterrupt = false; + private static String failureMessage = ""; + + private static Thread mainThread = null; + + private static int sleepTime = 300000; + + public static void main(String args[]) throws InterruptedException { + if (!System.getProperty("os.name").startsWith("Mac")) { + return; + } + mainThread = Thread.currentThread(); + try { + init(); + } catch (TestPassedException e) { + //The test passed, so just return from main and harness will + // interepret this return as a pass + return; + } + //At this point, neither test passed nor test failed has been + // called -- either would have thrown an exception and ended the + // test, so we know we have multiple threads. + + //Test involves other threads, so sleep and wait for them to + // called pass() or fail() + try { + Thread.sleep(sleepTime); + //Timed out, so fail the test + throw new RuntimeException("Timed out after " + sleepTime / 1000 + " seconds"); + } catch (InterruptedException e) { + if (!testGeneratedInterrupt) throw e; + + //reset flag in case hit this code more than once for some reason (just safety) + testGeneratedInterrupt = false; + if (theTestPassed == false) { + throw new RuntimeException(failureMessage); + } + } + + }//main + + public static synchronized void setTimeoutTo(int seconds) { + sleepTime = seconds * 1000; + } + + public static synchronized void pass() { + Sysout.println("The test passed."); + Sysout.println("The test is over, hit Ctl-C to stop Java VM"); + //first check if this is executing in main thread + if (mainThread == Thread.currentThread()) { + //Still in the main thread, so set the flag just for kicks, + // and throw a test passed exception which will be caught + // and end the test. + theTestPassed = true; + throw new TestPassedException(); + } + //pass was called from a different thread, so set the flag and interrupt + // the main thead. + theTestPassed = true; + testGeneratedInterrupt = true; + if (mainThread != null) { + mainThread.interrupt(); + } + }//pass() + + public static synchronized void fail() { + //test writer didn't specify why test failed, so give generic + fail("it just plain failed! :-)"); + } + + public static synchronized void fail(String whyFailed) { + Sysout.println("The test failed: " + whyFailed); + Sysout.println("The test is over, hit Ctl-C to stop Java VM"); + //check if this called from main thread + if (mainThread == Thread.currentThread()) { + //If main thread, fail now 'cause not sleeping + throw new RuntimeException(whyFailed); + } + theTestPassed = false; + testGeneratedInterrupt = true; + failureMessage = whyFailed; + mainThread.interrupt(); + }//fail() + +}// class ManualMainTest + +//This exception is used to exit from any level of call nesting +// when it's determined that the test has passed, and immediately +// end the test. +class TestPassedException extends RuntimeException { +} + +//*********** End Standard Test Machinery Section ********** + + +/**************************************************** + * Standard Test Machinery + * DO NOT modify anything below -- it's a standard + * chunk of code whose purpose is to make user + * interaction uniform, and thereby make it simpler + * to read and understand someone else's test. + ****************************************************/ + +/** + This is part of the standard test machinery. + It creates a dialog (with the instructions), and is the interface + for sending text messages to the user. + To print the instructions, send an array of strings to Sysout.createDialog + WithInstructions method. Put one line of instructions per array entry. + To display a message for the tester to see, simply call Sysout.println + with the string to be displayed. + This mimics System.out.println but works within the test harness as well + as standalone. + */ + +class Sysout { + private static TestDialog dialog; + private static boolean numbering = false; + private static int messageNumber = 0; + + public static void createDialogWithInstructions(String[] instructions) { + dialog = new TestDialog(new Frame(), "Instructions"); + dialog.printInstructions(instructions); + dialog.setVisible(true); + println("Any messages for the tester will display here."); + } + + public static void createDialog() { + dialog = new TestDialog(new Frame(), "Instructions"); + String[] defInstr = {"Instructions will appear here. ", ""}; + dialog.printInstructions(defInstr); + dialog.setVisible(true); + println("Any messages for the tester will display here."); + } + + + /* Enables message counting for the tester. */ + public static void enableNumbering(boolean enable) { + numbering = enable; + } + + public static void printInstructions(String[] instructions) { + dialog.printInstructions(instructions); + } + + + public static void println(String messageIn) { + if (numbering) { + messageIn = "" + messageNumber + " " + messageIn; + messageNumber++; + } + dialog.displayMessage(messageIn); + } + +}// Sysout class + +/** + This is part of the standard test machinery. It provides a place for the + test instructions to be displayed, and a place for interactive messages + to the user to be displayed. + To have the test instructions displayed, see Sysout. + To have a message to the user be displayed, see Sysout. + Do not call anything in this dialog directly. + */ +class TestDialog extends Dialog implements ActionListener { + + TextArea instructionsText; + TextArea messageText; + int maxStringLength = 80; + Panel buttonP = new Panel(); + Button passB = new Button("pass"); + Button failB = new Button("fail"); + + //DO NOT call this directly, go through Sysout + public TestDialog(Frame frame, String name) { + super(frame, name); + int scrollBoth = TextArea.SCROLLBARS_BOTH; + instructionsText = new TextArea("", 15, maxStringLength, scrollBoth); + add("North", instructionsText); + + messageText = new TextArea("", 5, maxStringLength, scrollBoth); + add("Center", messageText); + + passB = new Button("pass"); + passB.setActionCommand("pass"); + passB.addActionListener(this); + buttonP.add("East", passB); + + failB = new Button("fail"); + failB.setActionCommand("fail"); + failB.addActionListener(this); + buttonP.add("West", failB); + + add("South", buttonP); + pack(); + + setVisible(true); + }// TestDialog() + + //DO NOT call this directly, go through Sysout + public void printInstructions(String[] instructions) { + //Clear out any current instructions + instructionsText.setText(""); + + //Go down array of instruction strings + + String printStr, remainingStr; + for (int i = 0; i < instructions.length; i++) { + //chop up each into pieces maxSringLength long + remainingStr = instructions[i]; + while (remainingStr.length() > 0) { + //if longer than max then chop off first max chars to print + if (remainingStr.length() >= maxStringLength) { + //Try to chop on a word boundary + int posOfSpace = remainingStr. + lastIndexOf(' ', maxStringLength - 1); + + if (posOfSpace <= 0) posOfSpace = maxStringLength - 1; + + printStr = remainingStr.substring(0, posOfSpace + 1); + remainingStr = remainingStr.substring(posOfSpace + 1); + } + //else just print + else { + printStr = remainingStr; + remainingStr = ""; + } + + instructionsText.append(printStr + "\n"); + + }// while + + }// for + + }//printInstructions() + + //DO NOT call this directly, go through Sysout + public void displayMessage(String messageIn) { + messageText.append(messageIn + "\n"); + System.out.println(messageIn); + } + + //catch presses of the passed and failed buttons. + //simply call the standard pass() or fail() static methods of + //ManualMainTest + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand() == "pass") { + MacOsXFileAndMultipleFileCopingTest.pass(); + } else { + MacOsXFileAndMultipleFileCopingTest.fail(); + } + } + +}// TestDialog class \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/dnd/MissingEventsOnModalDialog/MissingEventsOnModalDialogTest.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Window; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 8134917 + * @summary [macosx] JOptionPane doesn't receive mouse events when opened from a drop event + * @author Alexandr Scherbatiy + */ +public class MissingEventsOnModalDialogTest { + + private static volatile boolean passed = false; + + public static void main(String[] args) throws Exception { + Frame sourceFrame = createFrame("Source Frame", 0, 0); + Frame targetFrame = createFrame("Target Frame", 250, 250); + + DragSource defaultDragSource + = DragSource.getDefaultDragSource(); + defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame, + DnDConstants.ACTION_COPY_OR_MOVE, + new TestDragGestureListener()); + new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE, + new TestDropTargetListener(targetFrame)); + + Robot robot = new Robot(); + robot.setAutoDelay(50); + + sourceFrame.toFront(); + robot.waitForIdle(); + + Point point = getCenterPoint(sourceFrame); + robot.mouseMove(point.x, point.y); + robot.waitForIdle(); + + mouseDragAndDrop(robot, point, getCenterPoint(targetFrame)); + + long time = System.currentTimeMillis() + 200; + + while (!passed) { + if (time < System.currentTimeMillis()) { + sourceFrame.dispose(); + targetFrame.dispose(); + throw new RuntimeException("Mouse clicked event is lost!"); + } + Thread.sleep(10); + } + sourceFrame.dispose(); + targetFrame.dispose(); + } + + private static Frame createFrame(String title, int x, int y) { + Frame frame = new Frame(); + frame.setSize(200, 200); + frame.setLocation(x, y); + frame.setTitle(title); + frame.setVisible(true); + return frame; + } + + private static Point getCenterPoint(Window window) { + Point centerPoint = window.getLocationOnScreen(); + centerPoint.translate(window.getWidth() / 2, window.getHeight() / 2); + return centerPoint; + } + + public static void mouseDragAndDrop(Robot robot, Point from, Point to) { + mouseDND(robot, from.x, from.y, to.x, to.y); + } + + public static void mouseDND(Robot robot, int x1, int y1, int x2, int y2) { + + int N = 20; + int x = x1; + int y = y1; + int dx = (x2 - x1) / N; + int dy = (y2 - y1) / N; + + robot.mousePress(InputEvent.BUTTON1_MASK); + + for (int i = 0; i < N; i++) { + robot.mouseMove(x += dx, y += dy); + } + + robot.mouseRelease(InputEvent.BUTTON1_MASK); + } + + private static class TestDragGestureListener implements DragGestureListener { + + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, new StringTransferable()); + } + } + + static class StringTransferable implements Transferable { + + @Override + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[]{DataFlavor.stringFlavor}; + } + + @Override + public boolean isDataFlavorSupported(DataFlavor flavor) { + return flavor.equals(DataFlavor.stringFlavor); + } + + @Override + public Object getTransferData(DataFlavor flavor) { + return "Hello World!"; + } + } + + private static class TestDropTargetListener implements DropTargetListener { + + private final Frame targetFrame; + + public TestDropTargetListener(Frame targetFrame) { + this.targetFrame = targetFrame; + } + + @Override + public void dragEnter(DropTargetDragEvent dtde) { + dtde.acceptDrag(dtde.getDropAction()); + } + + @Override + public void dragOver(DropTargetDragEvent dtde) { + dtde.acceptDrag(dtde.getDropAction()); + } + + @Override + public void dropActionChanged(DropTargetDragEvent dtde) { + dtde.acceptDrag(dtde.getDropAction()); + } + + @Override + public void dragExit(DropTargetEvent dte) { + } + + @Override + public void drop(DropTargetDropEvent dtde) { + dtde.acceptDrop(dtde.getDropAction()); + showModalDialog(targetFrame); + dtde.dropComplete(true); + } + } + + private static void showModalDialog(Frame targetFrame) { + + Dialog dialog = new Dialog(targetFrame, true); + + dialog.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + passed = true; + dialog.dispose(); + } + }); + + dialog.setSize(400, 300); + dialog.setTitle("Modal Dialog!"); + + clickOnModalDialog(dialog); + dialog.setVisible(true); + } + + private static void clickOnModalDialog(Dialog dialog) { + new Thread(() -> { + clickOnDialog(dialog); + }).start(); + } + + private static void clickOnDialog(Dialog dialog) { + try { + long time = System.currentTimeMillis() + 200; + + while (!dialog.isVisible()) { + if (time < System.currentTimeMillis()) { + throw new RuntimeException("Dialog is not visible!"); + } + Thread.sleep(10); + } + + Point point = getCenterPoint(dialog); + Robot robot = new Robot(); + robot.setAutoDelay(50); + + robot.mouseMove(point.x, point.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + } catch (Exception e) { + throw new RuntimeException(e); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/invoke/CustomizedLambdaFormTest.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.invoke; + +/* @test + * @summary Assertion in LambdaFormEditor.bindArgumentType is too strong + * + * @run main/bootclasspath -esa java.lang.invoke.CustomizedLambdaFormTest + */ +public class CustomizedLambdaFormTest { + + static void testExtendCustomizedBMH() throws Exception { + // Construct BMH + MethodHandle mh = MethodHandles.Lookup.IMPL_LOOKUP.findVirtual(String.class, "concat", + MethodType.methodType(String.class, String.class)) + .bindTo("a"); + mh.customize(); + mh.bindTo("b"); // Try to extend customized BMH + } + + public static void main(String[] args) throws Throwable { + testExtendCustomizedBMH(); + } +}
--- a/test/java/lang/invoke/ExplicitCastArgumentsTest.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/lang/invoke/ExplicitCastArgumentsTest.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,79 +21,582 @@ * questions. */ -package java.lang.invoke; - +import com.oracle.testlibrary.jsr292.Helper; +import java.io.File; +import java.io.Serializable; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.invoke.WrongMethodTypeException; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; import sun.invoke.util.Wrapper; -/* @test +/* + * @test + * @bug 8060483 8066746 + * @library /lib/testlibrary /lib/testlibrary/jsr292 * @summary unit tests for MethodHandles.explicitCastArguments() - * - * @run main/bootclasspath java.lang.invoke.ExplicitCastArgumentsTest + * @run main ExplicitCastArgumentsTest + */ + +/** + * Tests for MethodHandles.explicitCastArguments(). */ public class ExplicitCastArgumentsTest { - private static final boolean VERBOSE = Boolean.getBoolean("verbose"); + + private static final boolean VERBOSE = Helper.IS_VERBOSE; private static final Class<?> THIS_CLASS = ExplicitCastArgumentsTest.class; + private static final Random RNG = Helper.RNG; + private static final Map<Wrapper, Object> RANDOM_VALUES = new HashMap<>(9); + + static { + RANDOM_VALUES.put(Wrapper.BOOLEAN, RNG.nextBoolean()); + RANDOM_VALUES.put(Wrapper.BYTE, (byte) RNG.nextInt()); + RANDOM_VALUES.put(Wrapper.SHORT, (short) RNG.nextInt()); + RANDOM_VALUES.put(Wrapper.CHAR, (char) RNG.nextInt()); + RANDOM_VALUES.put(Wrapper.INT, RNG.nextInt()); + RANDOM_VALUES.put(Wrapper.LONG, RNG.nextLong()); + RANDOM_VALUES.put(Wrapper.FLOAT, RNG.nextFloat()); + RANDOM_VALUES.put(Wrapper.DOUBLE, RNG.nextDouble()); + RANDOM_VALUES.put(Wrapper.OBJECT, new Object()); + } public static void main(String[] args) throws Throwable { testVarargsCollector(); + testNullRef2Prim(); testRef2Prim(); + testPrim2Ref(); + testPrim2Prim(); + testNonBCPRef2NonBCPRef(); + testBCPRef2BCPRef(); + testNonBCPRef2BCPRef(); + testReturnAny2Void(); + testReturnVoid2Any(); + testMultipleArgs(); System.out.println("TEST PASSED"); } - public static String[] f(String... args) { return args; } + /** + * Dummy method used in {@link #testVarargsCollector} test to form a method + * handle. + * + * @param args - any args + * @return - returns args + */ + public static String[] f(String... args) { + return args; + } + /** + * Tests that MHs.explicitCastArguments does incorrect type checks for + * VarargsCollector. Bug 8066746. + * + * @throws java.lang.Throwable + */ public static void testVarargsCollector() throws Throwable { MethodType mt = MethodType.methodType(String[].class, String[].class); - MethodHandle mh = MethodHandles.publicLookup().findStatic(THIS_CLASS, "f", mt); - mh = MethodHandles.explicitCastArguments(mh, MethodType.methodType(Object.class, Object.class)); - mh.invokeWithArguments((Object)(new String[] {"str1", "str2"})); + MethodHandle mh = MethodHandles.publicLookup() + .findStatic(THIS_CLASS, "f", mt); + mh = MethodHandles.explicitCastArguments(mh, + MethodType.methodType(Object.class, Object.class)); + mh.invokeWithArguments((Object) (new String[]{"str1", "str2"})); + } + + /** + * Tests that null wrapper reference is successfully converted to primitive + * types. Converted result should be zero for a primitive. Bug 8060483. + */ + public static void testNullRef2Prim() { + for (Wrapper from : Wrapper.values()) { + for (Wrapper to : Wrapper.values()) { + if (from == Wrapper.VOID || to == Wrapper.VOID) { + continue; + } + // MHs.eCA javadoc: + // If T0 is a reference and T1 a primitive, and if the reference + // is null at runtime, a zero value is introduced. + for (TestConversionMode mode : TestConversionMode.values()) { + testConversion(mode, from.wrapperType(), + to.primitiveType(), null, to.zero(), false, null); + } + } + } } - public static void testRef2Prim() throws Throwable { + /** + * Tests that non-null wrapper reference is successfully converted to + * primitive types. + */ + public static void testRef2Prim() { + for (Wrapper from : Wrapper.values()) { + for (Wrapper to : Wrapper.values()) { + if (from == Wrapper.VOID || to == Wrapper.VOID + || to == Wrapper.OBJECT) { + continue; + } + Object value = RANDOM_VALUES.get(from); + for (TestConversionMode mode : TestConversionMode.values()) { + if (from != Wrapper.OBJECT) { + Object convValue = to.wrap(value); + testConversion(mode, from.wrapperType(), + to.primitiveType(), value, convValue, false, null); + } else { + testConversion(mode, from.wrapperType(), + to.primitiveType(), value, null, + true, ClassCastException.class); + } + } + } + } + } + + /** + * Tests that primitive is successfully converted to wrapper reference + * types, to the Number type (if possible) and to the Object type. + */ + public static void testPrim2Ref() { for (Wrapper from : Wrapper.values()) { for (Wrapper to : Wrapper.values()) { - if (from == Wrapper.VOID || to == Wrapper.VOID) continue; - testRef2Prim(from, to); + if (from == Wrapper.VOID || from == Wrapper.OBJECT + || to == Wrapper.VOID || to == Wrapper.OBJECT) { + continue; + } + Object value = RANDOM_VALUES.get(from); + for (TestConversionMode mode : TestConversionMode.values()) { + if (from == to) { + testConversion(mode, from.primitiveType(), + to.wrapperType(), value, value, false, null); + } else { + testConversion(mode, from.primitiveType(), + to.wrapperType(), value, null, true, ClassCastException.class); + } + if (from != Wrapper.BOOLEAN && from != Wrapper.CHAR) { + testConversion(mode, from.primitiveType(), + Number.class, value, value, false, null); + } else { + testConversion(mode, from.primitiveType(), + Number.class, value, null, + true, ClassCastException.class); + } + testConversion(mode, from.primitiveType(), + Object.class, value, value, false, null); + } + } + } + } + + /** + * Tests that primitive is successfully converted to other primitive type. + */ + public static void testPrim2Prim() { + for (Wrapper from : Wrapper.values()) { + for (Wrapper to : Wrapper.values()) { + if (from == Wrapper.VOID || to == Wrapper.VOID + || from == Wrapper.OBJECT || to == Wrapper.OBJECT) { + continue; + } + Object value = RANDOM_VALUES.get(from); + Object convValue = to.wrap(value); + for (TestConversionMode mode : TestConversionMode.values()) { + testConversion(mode, from.primitiveType(), + to.primitiveType(), value, convValue, false, null); + } } } } - public static void testRef2Prim(Wrapper from, Wrapper to) throws Throwable { - // MHs.eCA javadoc: - // If T0 is a reference and T1 a primitive, and if the reference is null at runtime, a zero value is introduced. - test(from.wrapperType(), to.primitiveType(), null, false); + /** + * Dummy interface for {@link #testNonBCPRef2Ref} test. + */ + public static interface TestInterface {} + + /** + * Dummy class for {@link #testNonBCPRef2Ref} test. + */ + public static class TestSuperClass implements TestInterface {} + + /** + * Dummy class for {@link #testNonBCPRef2Ref} test. + */ + public static class TestSubClass1 extends TestSuperClass {} + + /** + * Dummy class for {@link #testNonBCPRef2Ref} test. + */ + public static class TestSubClass2 extends TestSuperClass {} + + /** + * Tests non-bootclasspath reference to reference conversions. + * + * @throws java.lang.Throwable + */ + public static void testNonBCPRef2NonBCPRef() throws Throwable { + Class testInterface = TestInterface.class; + Class testSuperClass = TestSuperClass.class; + Class testSubClass1 = TestSubClass1.class; + Class testSubClass2 = TestSubClass2.class; + Object testSuperObj = new TestSuperClass(); + Object testObj01 = new TestSubClass1(); + Object testObj02 = new TestSubClass2(); + Class[] parents = {testInterface, testSuperClass}; + Class[] children = {testSubClass1, testSubClass2}; + Object[] childInst = {testObj01, testObj02}; + for (TestConversionMode mode : TestConversionMode.values()) { + for (Class parent : parents) { + for (int j = 0; j < children.length; j++) { + // Child type to parent type non-null conversion, shoud succeed + testConversion(mode, children[j], parent, childInst[j], childInst[j], false, null); + // Child type to parent type null conversion, shoud succeed + testConversion(mode, children[j], parent, null, null, false, null); + // Parent type to child type non-null conversion with parent + // type instance, should fail + testConversion(mode, parent, children[j], testSuperObj, null, true, ClassCastException.class); + // Parent type to child type non-null conversion with child + // type instance, should succeed + testConversion(mode, parent, children[j], childInst[j], childInst[j], false, null); + // Parent type to child type null conversion, should succeed + testConversion(mode, parent, children[j], null, null, false, null); + } + // Parent type to child type non-null conversion with sibling + // type instance, should fail + testConversion(mode, parent, testSubClass1, testObj02, null, true, ClassCastException.class); + } + // Sibling type non-null conversion, should fail + testConversion(mode, testSubClass1, + testSubClass2, testObj01, null, true, + ClassCastException.class); + // Sibling type null conversion, should succeed + testConversion(mode, testSubClass1, + testSubClass2, null, null, false, null); + } + } + + /** + * Dummy interface for {@link #testNonBCPRef2BCPRef} test. + */ + public static interface TestSerializableInterface extends Serializable {} + + /** + * Dummy class for {@link #testNonBCPRef2BCPRef} test. + */ + public static class TestSerializableClass + implements TestSerializableInterface {} + + /** + * Dummy class for {@link #testNonBCPRef2BCPRef} test. + */ + public static class TestFileChildClass extends File + implements TestSerializableInterface { + public TestFileChildClass(String pathname) { + super(pathname); + } + } + + /** + * Tests non-bootclasspath reference to bootclasspath reference conversions + * and vice-versa. + * + * @throws java.lang.Throwable + */ + public static void testNonBCPRef2BCPRef() throws Throwable { + Class bcpInterface = Serializable.class; + Class bcpSuperClass = File.class; + Class nonBcpInterface = TestSerializableInterface.class; + Class nonBcpSuperSiblingClass = TestSerializableClass.class; + Class nonBcpSubClass = TestFileChildClass.class; + Object bcpSuperObj = new File("."); + Object testSuperSiblingObj = new TestSerializableClass(); + Object testSubObj = new TestFileChildClass("."); + Class[] parents = {bcpInterface, bcpSuperClass}; + for (TestConversionMode mode : TestConversionMode.values()) { + for (Class parent : parents) { + // Child type to parent type non-null conversion, shoud succeed + testConversion(mode, nonBcpSubClass, parent, testSubObj, + testSubObj, false, null); + // Child type to parent type null conversion, shoud succeed + testConversion(mode, nonBcpSubClass, parent, null, null, + false, null); + // Parent type to child type non-null conversion with parent + // type instance, should fail + testConversion(mode, parent, nonBcpSubClass, bcpSuperObj, null, + true, ClassCastException.class); + // Parent type to child type non-null conversion with child + // type instance, should succeed + testConversion(mode, parent, nonBcpSubClass, testSubObj, + testSubObj, false, null); + // Parent type to child type null conversion, should succeed + testConversion(mode, parent, nonBcpSubClass, null, null, + false, null); + } + // Parent type to child type non-null conversion with + // super sibling type instance, should fail + testConversion(mode, bcpInterface, nonBcpSubClass, + testSuperSiblingObj, null, true, ClassCastException.class); + Class[] siblings = {nonBcpSubClass, bcpSuperClass}; + for (Class sibling : siblings) { + // Non-bcp class to bcp/non-bcp sibling class non-null + // conversion with nonBcpSuperSiblingClass instance, should fail + testConversion(mode, nonBcpSuperSiblingClass, sibling, + testSuperSiblingObj, null, true, ClassCastException.class); + // Non-bcp class to bcp/non-bcp sibling class null conversion, + // should succeed + testConversion(mode, nonBcpSuperSiblingClass, sibling, + null, null, false, null); + // Non-bcp interface to bcp/non-bcp sibling class non-null + // conversion with nonBcpSubClass instance, should succeed + testConversion(mode, nonBcpInterface, sibling, testSubObj, + testSubObj, false, null); + // Non-bcp interface to bcp/non-bcp sibling class + // null conversion, should succeed + testConversion(mode, nonBcpInterface, sibling, null, null, + false, null); + // Non-bcp interface to bcp/non-bcp sibling class non-null + // conversion with nonBcpSuperSiblingClass instance, should fail + testConversion(mode, nonBcpInterface, sibling, + testSuperSiblingObj, testSubObj, + true, ClassCastException.class); + } + } } - public static void test(Class<?> from, Class<?> to, Object param, boolean failureExpected) throws Throwable { - if (VERBOSE) System.out.printf("%-10s => %-10s: %5s: ", from.getSimpleName(), to.getSimpleName(), param); + /** + * Tests bootclasspath reference to reference conversions. + */ + public static void testBCPRef2BCPRef() { + Class bcpInterface = CharSequence.class; + Class bcpSubClass1 = String.class; + Class bcpSubClass2 = StringBuffer.class; + Object testObj01 = new String("test"); + Object testObj02 = new StringBuffer("test"); + Class[] children = {bcpSubClass1, bcpSubClass2}; + Object[] childInst = {testObj01, testObj02}; + for (TestConversionMode mode : TestConversionMode.values()) { + for (int i = 0; i < children.length; i++) { + // Child type to parent type non-null conversion, shoud succeed + testConversion(mode, children[i], bcpInterface, childInst[i], + childInst[i], false, null); + // Child type to parent type null conversion, shoud succeed + testConversion(mode, children[i], bcpInterface, null, + null, false, null); + // Parent type to child type non-null conversion with child + // type instance, should succeed + testConversion(mode, bcpInterface, + children[i], childInst[i], childInst[i], false, null); + // Parent type to child type null conversion, should succeed + testConversion(mode, bcpInterface, + children[i], null, null, false, null); + } + // Sibling type non-null conversion, should fail + testConversion(mode, bcpSubClass1, + bcpSubClass2, testObj01, null, true, + ClassCastException.class); + // Sibling type null conversion, should succeed + testConversion(mode, bcpSubClass1, + bcpSubClass2, null, null, false, null); + // Parent type to child type non-null conversion with sibling + // type instance, should fail + testConversion(mode, bcpInterface, bcpSubClass1, testObj02, + null, true, ClassCastException.class); + } + } + + /** + * Dummy method used in {@link #testReturnAny2Void} and + * {@link #testReturnVoid2Any} tests to form a method handle. + */ + public static void retVoid() {} + + /** + * Tests that non-null any return is successfully converted to non-type + * void. + */ + public static void testReturnAny2Void() { + for (Wrapper from : Wrapper.values()) { + testConversion(TestConversionMode.RETURN_VALUE, from.wrapperType(), + void.class, RANDOM_VALUES.get(from), + null, false, null); + testConversion(TestConversionMode.RETURN_VALUE, from.primitiveType(), + void.class, RANDOM_VALUES.get(from), + null, false, null); + } + } + + /** + * Tests that void return is successfully converted to primitive and + * reference. Result should be zero for primitives and null for references. + */ + public static void testReturnVoid2Any() { + for (Wrapper to : Wrapper.values()) { + testConversion(TestConversionMode.RETURN_VALUE, void.class, + to.primitiveType(), null, + to.zero(), false, null); + testConversion(TestConversionMode.RETURN_VALUE, void.class, + to.wrapperType(), null, + null, false, null); + } + } + + private static void checkForWrongMethodTypeException(MethodHandle mh, MethodType mt) { + try { + MethodHandles.explicitCastArguments(mh, mt); + throw new AssertionError("Expected WrongMethodTypeException is not thrown"); + } catch (WrongMethodTypeException wmte) { + if (VERBOSE) { + System.out.printf("Expected exception %s: %s\n", + wmte.getClass(), wmte.getMessage()); + } + } + } - MethodHandle original = MethodHandles.identity(from); - MethodType newType = original.type().changeReturnType(to); + /** + * Tests that MHs.eCA method works correctly with MHs with multiple arguments. + * @throws Throwable + */ + public static void testMultipleArgs() throws Throwable { + int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2); + int arityMinus = RNG.nextInt(arity); + int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1; + MethodType mType = Helper.randomMethodTypeGenerator(arity); + MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity); + MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus); + MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus); + Class<?> rType = mType.returnType(); + MethodHandle original; + if (rType.equals(void.class)) { + MethodType mt = MethodType.methodType(void.class); + original = MethodHandles.publicLookup() + .findStatic(THIS_CLASS, "retVoid", mt); + } else { + Object rValue = Helper.castToWrapper(1, rType); + original = MethodHandles.constant(rType, rValue); + } + original = Helper.addTrailingArgs(original, arity, mType.parameterList()); + MethodHandle target = MethodHandles + .explicitCastArguments(original, mTypeNew); + Object[] parList = Helper.randomArgs(mTypeNew.parameterList()); + for (int i = 0; i < parList.length; i++) { + if (parList[i] instanceof String) { + parList[i] = null; //getting rid of Stings produced by randomArgs + } + } + target.invokeWithArguments(parList); + checkForWrongMethodTypeException(original, mTypeNewMinus); + checkForWrongMethodTypeException(original, mTypeNewPlus); + } + + /** + * Enumeration of test conversion modes. + */ + public enum TestConversionMode { + RETURN_VALUE, + ARGUMENT; + } + /** + * Tests type and value conversion. Comparing with the given expected result. + * + * @param mode - test conversion mode. See {@link #TestConversionMode}. + * @param from - source type. + * @param to - destination type. + * @param param - value to be converted. + * @param expectedResult - expected value after conversion. + * @param failureExpected - true if conversion failure expected. + * @param expectedException - expected exception class if + * {@code failureExpected} is true. + */ + public static void testConversion(TestConversionMode mode, + Class<?> from, Class<?> to, Object param, + Object expectedResult, boolean failureExpected, + Class<? extends Throwable> expectedException) { + if (VERBOSE) { + System.out.printf("Testing return value conversion: " + + "%-10s => %-10s: %5s: ", from.getSimpleName(), + to.getSimpleName(), param); + } + MethodHandle original = null; + MethodType newType = null; + switch (mode) { + case RETURN_VALUE: + if (from.equals(void.class)) { + MethodType mt = MethodType.methodType(void.class); + try { + original = MethodHandles.publicLookup() + .findStatic(THIS_CLASS, "retVoid", mt); + } catch (NoSuchMethodException | IllegalAccessException ex) { + throw new Error("Unexpected issue", ex); + } + } else { + original = MethodHandles.constant(from, param); + } + newType = original.type().changeReturnType(to); + break; + case ARGUMENT: + if (from.equals(void.class) || to.equals(void.class)) { + throw new Error("Test issue: argument conversion does not" + + " work with non-type void"); + } + original = MethodHandles.identity(to); + newType = original.type().changeParameterType(0, from); + break; + default: + String msg = String.format("Test issue: unknown test" + + " convertion mode %s.", mode.name()); + throw new Error(msg); + } try { - MethodHandle target = MethodHandles.explicitCastArguments(original, newType); - Object result = target.invokeWithArguments(param); - + MethodHandle target = MethodHandles + .explicitCastArguments(original, newType); + Object result; + switch (mode) { + case RETURN_VALUE: + result = target.invokeWithArguments(); + break; + case ARGUMENT: + result = target.invokeWithArguments(param); + break; + default: + String msg = String.format("Test issue: unknown test" + + " convertion mode %s.", mode.name()); + throw new Error(msg); + } + if (!failureExpected + && (expectedResult != null && !expectedResult.equals(result) + || expectedResult == null && result != null)) { + String msg = String.format("Conversion result %s is not equal" + + " to the expected result %10s", + result, expectedResult); + throw new AssertionError(msg); + } if (VERBOSE) { String resultStr; if (result != null) { - resultStr = String.format("%10s (%10s)", "'"+result+"'", result.getClass().getSimpleName()); + resultStr = String.format("Converted value and type are" + + " %10s (%10s)", "'" + result + "'", + result.getClass().getSimpleName()); } else { - resultStr = String.format("%10s", result); + resultStr = String.format("Converted value is %10s", result); } System.out.println(resultStr); } - if (failureExpected) { - String msg = String.format("No exception thrown: %s => %s; parameter: %s", from, to, param); + String msg = String.format("No exception thrown while testing" + + " return value conversion: %10s => %10s;" + + " parameter: %10s", + from, to, param); throw new AssertionError(msg); } } catch (AssertionError e) { throw e; // report test failure } catch (Throwable e) { - if (VERBOSE) System.out.printf("%s: %s\n", e.getClass(), e.getMessage()); - if (!failureExpected) { - String msg = String.format("Unexpected exception was thrown: %s => %s; parameter: %s", from, to, param); + if (VERBOSE) { + System.out.printf("%s: %s\n", e.getClass(), e.getMessage()); + } + if (!failureExpected || !e.getClass().equals(expectedException)) { + String msg = String.format("Unexpected exception was thrown" + + " while testing return value conversion:" + + " %s => %s; parameter: %s", from, to, param); throw new AssertionError(msg, e); } }
--- a/test/java/lang/invoke/LFCaching/TestMethods.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/lang/invoke/LFCaching/TestMethods.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -207,7 +207,7 @@ return MethodHandles.filterReturnValue(target, filter); } }, - INSERT_ARGUMENTS("insertArguments") { + INSERT_ARGUMENTS("insertArguments", Helper.MAX_ARITY - 3) { @Override public Map<String, Object> getTestCaseData() { Map<String, Object> data = new HashMap<>(); @@ -610,26 +610,7 @@ * @return MethodType generated randomly. */ private static MethodType randomMethodTypeGenerator(int arity) { - final Class<?>[] CLASSES = { - Object.class, - int.class, - boolean.class, - byte.class, - short.class, - char.class, - long.class, - float.class, - double.class - }; - if (arity > Helper.MAX_ARITY) { - throw new IllegalArgumentException( - String.format("Arity should not exceed %d!", Helper.MAX_ARITY)); - } - List<Class<?>> list = Helper.randomClasses(CLASSES, arity); - list = Helper.getParams(list, false, arity); - int i = Helper.RNG.nextInt(CLASSES.length + 1); - Class<?> rtype = i == CLASSES.length ? void.class : CLASSES[i]; - return MethodType.methodType(rtype, list); + return Helper.randomMethodTypeGenerator(arity); } /**
--- a/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java Thu Dec 03 13:27:36 2015 -0800 @@ -168,6 +168,11 @@ try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { + if (CodeCacheOverflowProcessor.isThrowableCausedByVME(ex)) { + // This error will be treated by CodeCacheOverflowProcessor + // to prevent the test from failing because of code cache overflow. + throw new Error(ex); + } testCase.assertCatch(ex); returned = ex; }
--- a/test/java/lang/management/ThreadMXBean/ThreadInfoArray.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/lang/management/ThreadMXBean/ThreadInfoArray.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,12 @@ /* * @test - * @bug 5058327 - * @summary Test if getThreadInfo(long[]) returns a ThreadInfo[] - * with null elements with no exception. + * @bug 5058327 8074368 + * @summary Tests the correct behaviour of getThreadInfo(long[]) for non-existent + * thread IDs and the empty thread id array. * * @author Mandy Chung + * @author Jaroslav Bachorik * * @build ThreadInfoArray * @run main ThreadInfoArray @@ -35,15 +36,30 @@ import java.lang.management.*; import javax.management.*; -import java.util.*; import static java.lang.management.ManagementFactory.*; public class ThreadInfoArray { public static void main(String[] argv) throws Exception { + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + ObjectName on = new ObjectName(THREAD_MXBEAN_NAME); + ThreadMXBean mbean = ManagementFactory.getThreadMXBean(); + ThreadMXBean proxy = newPlatformMXBeanProxy(mbs, + on.toString(), + ThreadMXBean.class); + checkNullElement(mbean, proxy, mbs, on); + checkEmptyArray(mbean, proxy, mbs, on); + System.out.println("Test passed"); + } + + private static void checkNullElement(ThreadMXBean mbean, ThreadMXBean proxy, + MBeanServer mbs, ObjectName on) + throws Exception { + System.out.println("--- Check null element"); // ID for a new thread long [] ids = {new Thread().getId()}; + // direct call ThreadInfo[] tinfos = mbean.getThreadInfo(ids); if (tinfos[0] != null) { @@ -52,8 +68,6 @@ } // call getThreadInfo through MBeanServer - MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); - ObjectName on = new ObjectName(THREAD_MXBEAN_NAME); Object[] params = {ids}; String[] sigs = {"[J"}; Object[] result = (Object[]) mbs.invoke(on, "getThreadInfo", params, sigs); @@ -64,14 +78,57 @@ } // call getThreadInfo through proxy - ThreadMXBean proxy = newPlatformMXBeanProxy(mbs, - on.toString(), - ThreadMXBean.class); tinfos = proxy.getThreadInfo(ids); if (tinfos[0] != null) { throw new RuntimeException("TEST FAILED: " + "Expected to have a null element"); } - System.out.println("Test passed"); + System.out.println("--- PASSED"); + } + + private static void checkEmptyArray(ThreadMXBean mbean, ThreadMXBean proxy, + MBeanServer mbs, ObjectName on) + throws Exception { + System.out.println("--- Check empty TID array"); + + long[] ids = new long[0]; + // direct call + assertEmptyArray(mbean.getThreadInfo(ids), "Expected empty ThreadInfo array"); + assertEmptyArray(mbean.getThreadInfo(ids, 1), "Expected empty ThreadInfo array"); + assertEmptyArray(mbean.getThreadInfo(ids, true, true), "Expected empty ThreadInfo array"); + + // call getThreadInfo through MBeanServer + assertEmptyArray( + (Object[]) mbs.invoke( + on, "getThreadInfo", new Object[]{ids}, new String[]{"[J"} + ), + "Expected empty ThreadInfo array via MBeanServer" + ); + assertEmptyArray( + (Object[]) mbs.invoke( + on, "getThreadInfo", new Object[]{ids, 1}, + new String[]{"[J", "int"} + ), + "Expected empty ThreadInfo array via MBeanServer" + ); + assertEmptyArray( + (Object[]) mbs.invoke( + on, "getThreadInfo", new Object[]{ids, true, true}, + new String[]{"[J", "boolean", "boolean"} + ), + "Expected empty ThreadInfo array via MBeanServer" + ); + + // call getThreadInfo through proxy + assertEmptyArray(proxy.getThreadInfo(ids), "Expected empty ThreadInfo array"); + assertEmptyArray(proxy.getThreadInfo(ids, 1), "Expected empty ThreadInfo array"); + assertEmptyArray(proxy.getThreadInfo(ids, true, true), "Expected empty ThreadInfo array"); + System.out.println("--- PASSED"); + } + + private static void assertEmptyArray(Object[] arr, String message) throws Exception { + if (arr.length > 0) { + throw new RuntimeException("TEST FAILED: " + message); + } } }
--- a/test/java/net/Inet4Address/PingThis.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/net/Inet4Address/PingThis.java Thu Dec 03 13:27:36 2015 -0800 @@ -26,7 +26,7 @@ */ /* @test - * @bug 7163874 + * @bug 7163874 8133015 * @summary InetAddress.isReachable is returning false * for InetAdress 0.0.0.0 and ::0 * @run main PingThis
--- a/test/java/net/Inet4Address/textToNumericFormat.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/net/Inet4Address/textToNumericFormat.java Thu Dec 03 13:27:36 2015 -0800 @@ -23,7 +23,7 @@ /* * @test - * @bug 4749938 + * @bug 4749938 8087190 * @summary Bug in the parsing IPv4 literal addresses * @compile -XDignore.symbol.file=true DummyNameService.java DummyNameServiceDescriptor.java * @run main/othervm -Dsun.net.spi.nameservice.provider.1=dummy,oracle textToNumericFormat @@ -62,7 +62,11 @@ "2380.255.255.255", "239.255.65536", "239.16777216", - "4294967296" }; + "4294967296", + ".1.1.1", + "1..1.1", + "1.1.1.", + "..." }; for (int i=0; i<goodAddrs.length; i++) { try {
--- a/test/java/net/InetAddress/IsHostReachableBug.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/net/InetAddress/IsHostReachableBug.java Thu Dec 03 13:27:36 2015 -0800 @@ -23,7 +23,7 @@ /** * @test - * @bug 4922568 + * @bug 4922568 8133015 * @run main/othervm -Djava.net.preferIPv4Stack=true IsHostReachableBug * @summary isReachable returns true for IPv6 */
--- a/test/java/net/InetAddress/IsReachable.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/net/InetAddress/IsReachable.java Thu Dec 03 13:27:36 2015 -0800 @@ -23,7 +23,7 @@ /** * @test - * @bug 4639861 + * @bug 4639861 8133015 * @summary API to test reachability of a host */ import java.net.InetAddress;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/net/InetAddress/IsReachableViaLoopbackTest.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,40 @@ +import java.io.*; +import java.net.*; +import java.util.*; + +/** + * @test + * @bug 8135305 + * @summary ensure we can't ping external hosts via loopback if + */ + +public class IsReachableViaLoopbackTest { + public static void main(String[] args) { + try { + InetAddress addr = InetAddress.getByName("localhost"); + InetAddress remoteAddr = InetAddress.getByName("bugs.openjdk.java.net"); + if (!addr.isReachable(10000)) + throw new RuntimeException("Localhost should always be reachable"); + NetworkInterface inf = NetworkInterface.getByInetAddress(addr); + if (inf != null) { + if (!addr.isReachable(inf, 20, 10000)) { + throw new RuntimeException("Localhost should always be reachable"); + } else { + System.out.println(addr + " is reachable"); + } + if (remoteAddr.isReachable(inf, 20, 10000)) { + throw new RuntimeException(remoteAddr + " is reachable"); + } else { + System.out.println(remoteAddr + " is NOT reachable"); + } + } else { + System.out.println("inf == null"); + } + + } catch (IOException e) { + throw new RuntimeException("Unexpected exception:" + e); + } + System.out.println("IsReachableViaLoopbackTest EXIT"); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/net/MulticastSocket/MultiDead.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8072466 + * @summary Deadlock when initializing MulticastSocket and DatagramSocket + * @library /lib/testlibrary + * @build jdk.testlibrary.* + * @run main/othervm MultiDead + */ + +import java.net.DatagramSocket; +import java.net.MulticastSocket; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.CountDownLatch; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import jdk.testlibrary.JDKToolLauncher; +import jdk.testlibrary.Utils; + +public class MultiDead { + private static final int THREAD_PAIR_COUNT = 4; + private static final int CHILDREN_COUNT = 20; + // at least 2.5 seconds for a child to complete + private static final long CHILD_TIMEOUT = 2500; + private static final long TIMEOUT = + Utils.adjustTimeout(CHILDREN_COUNT * CHILD_TIMEOUT * 2); + + public static void main(String[] args) throws Throwable { + if (args.length == 0 || args[0].equals("parent")) { + parentProcess(); + } + + if (args.length > 0 && args[0].equals("child")) { + childProcess(); + } + } + + private static void parentProcess() throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher + .createUsingTestJDK("java") + .addToolArg("MultiDead") + .addToolArg("child"); + ProcessBuilder pb = new ProcessBuilder(launcher.getCommand()); + + AtomicReference<Process> child = new AtomicReference<>(); + AtomicBoolean stopFlag = new AtomicBoolean(false); + + Thread th = new Thread(() -> { + for (int i = 0; i < CHILDREN_COUNT; ++i) { + System.out.println("child #" + (i + 1) + " of " + + CHILDREN_COUNT); + long start = System.nanoTime(); + try { + child.set(pb.start()); + child.get().waitFor(); + if (stopFlag.get()) { + break; + } + } catch (Exception e) { + throw new RuntimeException(e); + } + if (System.nanoTime() - start > + MILLISECONDS.toNanos(CHILD_TIMEOUT)) { + System.err.println("Machine is too slow, " + + "skipping the test..."); + break; + } + } + }); + + th.start(); + th.join(TIMEOUT); + + stopFlag.set(true); + if (th.isAlive()) { + if (child.get() != null) { + child.get().destroyForcibly(); + } + throw new RuntimeException("Failed to complete on time."); + } + } + + private static void childProcess() { + CountDownLatch latch = new CountDownLatch(1); + for (int i = 0; i < THREAD_PAIR_COUNT; ++i) { + new Thread(() -> { + try { + latch.await(); + try (MulticastSocket a = new MulticastSocket(6000)) { + } + } catch (Exception ignore) { + } + }).start(); + + new Thread(() -> { + try { + latch.await(); + try (DatagramSocket b = new DatagramSocket(6000)) { + } + } catch (Exception ignore) { + } + }).start(); + } + latch.countDown(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/nio/Buffer/DirectBufferAllocTest.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,174 @@ +/* + * 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 6857566 + * @summary DirectByteBuffer garbage creation can outpace reclamation + * + * @run main/othervm -XX:MaxDirectMemorySize=128m DirectBufferAllocTest + */ + +import java.nio.ByteBuffer; +import java.util.List; +import java.util.concurrent.*; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class DirectBufferAllocTest { + // defaults + static final int RUN_TIME_SECONDS = 5; + static final int MIN_THREADS = 4; + static final int MAX_THREADS = 64; + static final int CAPACITY = 1024 * 1024; // bytes + + /** + * This test spawns multiple threads that constantly allocate direct + * {@link ByteBuffer}s in a loop, trying to provoke {@link OutOfMemoryError}.<p> + * When run without command-line arguments, it runs as a regression test + * for at most 5 seconds.<p> + * Command line arguments: + * <pre> + * -r run-time-seconds <i>(duration of successful test - default 5 s)</i> + * -t threads <i>(default is 2 * # of CPUs, at least 4 but no more than 64)</i> + * -c capacity <i>(of direct buffers in bytes - default is 1MB)</i> + * -p print-alloc-time-batch-size <i>(every "batch size" iterations, + * average time per allocation is printed)</i> + * </pre> + * Use something like the following to run a 10 minute stress test and + * print allocation times as it goes: + * <pre> + * java -XX:MaxDirectMemorySize=128m DirectBufferAllocTest -r 600 -t 32 -p 5000 + * </pre> + */ + public static void main(String[] args) throws Exception { + int runTimeSeconds = RUN_TIME_SECONDS; + int threads = Math.max( + Math.min( + Runtime.getRuntime().availableProcessors() * 2, + MAX_THREADS + ), + MIN_THREADS + ); + int capacity = CAPACITY; + int printBatchSize = 0; + + // override with command line arguments + for (int i = 0; i < args.length; i++) { + switch (args[i]) { + case "-r": + runTimeSeconds = Integer.parseInt(args[++i]); + break; + case "-t": + threads = Integer.parseInt(args[++i]); + break; + case "-c": + capacity = Integer.parseInt(args[++i]); + break; + case "-p": + printBatchSize = Integer.parseInt(args[++i]); + break; + default: + System.err.println( + "Usage: java" + + " [-XX:MaxDirectMemorySize=XXXm]" + + " DirectBufferAllocTest" + + " [-r run-time-seconds]" + + " [-t threads]" + + " [-c capacity-of-direct-buffers]" + + " [-p print-alloc-time-batch-size]" + ); + System.exit(-1); + } + } + + System.out.printf( + "Allocating direct ByteBuffers with capacity %d bytes, using %d threads for %d seconds...\n", + capacity, threads, runTimeSeconds + ); + + ExecutorService executor = Executors.newFixedThreadPool(threads); + + int pbs = printBatchSize; + int cap = capacity; + + List<Future<Void>> futures = + IntStream.range(0, threads) + .mapToObj( + i -> (Callable<Void>) () -> { + long t0 = System.nanoTime(); + loop: + while (true) { + for (int n = 0; pbs == 0 || n < pbs; n++) { + if (Thread.interrupted()) { + break loop; + } + ByteBuffer.allocateDirect(cap); + } + long t1 = System.nanoTime(); + if (pbs > 0) { + System.out.printf( + "Thread %2d: %5.2f ms/allocation\n", + i, ((double) (t1 - t0) / (1_000_000d * pbs)) + ); + } + t0 = t1; + } + return null; + } + ) + .map(executor::submit) + .collect(Collectors.toList()); + + for (int i = 0; i < runTimeSeconds; i++) { + if (futures.stream().anyMatch(Future::isDone)) { + break; + } + Thread.sleep(1000L); + } + + Exception exception = null; + for (Future<Void> future : futures) { + if (future.isDone()) { + try { + future.get(); + } catch (ExecutionException e) { + if (exception == null) { + exception = new RuntimeException("Errors encountered!"); + } + exception.addSuppressed(e.getCause()); + } + } else { + future.cancel(true); + } + } + + executor.shutdown(); + + if (exception != null) { + throw exception; + } else { + System.out.printf("No errors after %d seconds.\n", runTimeSeconds); + } + } +}
--- a/test/java/nio/channels/AsynchronousSocketChannel/StressLoopback.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/nio/channels/AsynchronousSocketChannel/StressLoopback.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @bug 6834246 6842687 + * @bug 6834246 6842687 8133647 * @summary Stress test connections through the loopback interface * @run main StressLoopback * @run main/othervm -Djdk.net.useFastTcpLoopback StressLoopback
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/nio/channels/FileChannel/LoopingTruncate.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8137121 8137230 + * @summary (fc) Infinite loop FileChannel.truncate + * @library /lib/testlibrary + * @build jdk.testlibrary.Utils + * @run main/othervm LoopingTruncate + */ + +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.channels.ClosedByInterruptException; +import java.nio.file.Files; +import java.nio.file.Path; +import static java.nio.file.StandardOpenOption.*; +import static jdk.testlibrary.Utils.adjustTimeout; + +public class LoopingTruncate { + + // (int)FATEFUL_SIZE == -3 == IOStatus.INTERRUPTED + static long FATEFUL_SIZE = 0x1FFFFFFFDL; + + // At least 20 seconds + static long TIMEOUT = adjustTimeout(20_000); + + public static void main(String[] args) throws Throwable { + Path path = Files.createTempFile("LoopingTruncate.tmp", null); + try (FileChannel fc = FileChannel.open(path, CREATE, WRITE)) { + fc.position(FATEFUL_SIZE + 1L); + fc.write(ByteBuffer.wrap(new byte[] {0})); + + Thread th = new Thread(() -> { + try { + fc.truncate(FATEFUL_SIZE); + } catch (ClosedByInterruptException ignore) { + } catch (Exception e) { + throw new RuntimeException(e); + }}); + th.start(); + th.join(TIMEOUT); + + if (th.isAlive()) { + System.err.println("=== Stack trace of the guilty thread:"); + for (StackTraceElement el : th.getStackTrace()) { + System.err.println("\t" + el); + } + System.err.println("==="); + + th.interrupt(); + th.join(); + throw new RuntimeException("Failed to complete on time"); + } + } finally { + Files.deleteIfExists(path); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/nio/file/Files/probeContentType/ParallelProbes.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; + +/* @test + * @summary Test probing content type simultaneously from multiple threads. + * @requires (os.family == "linux") | (os.family == "solaris") + * @run main ParallelProbes 10 + */ +public class ParallelProbes { + + private static final int REPEATS = 1000; + + private int numThreads = 0; + private ArrayList<Thread> threads; + + public ParallelProbes(int numThreads) { + System.out.println("Using <" + numThreads + "> threads."); + this.numThreads = numThreads; + this.threads = new ArrayList<Thread>(numThreads); + } + + private Path createTmpFile() throws IOException { + final Path p = Files.createTempFile("prefix", ".json"); + Files.write(p, "{\"test\"}".getBytes()); + System.out.println("Write test file <" + p + ">"); + return p; + } + + private Runnable createRunnable(final Path p) { + Runnable r = new Runnable() { + public void run() { + for (int i = 0; i < REPEATS; i++) { + try { + System.out.println(Thread.currentThread().getName() + + " -> " + Files.probeContentType(p)); + } catch (IOException ioException) { + ioException.printStackTrace(); + } + } + } + }; + return r; + } + + public void start() throws IOException { + for (int i = 0; i < numThreads; i++) { + final Path p = createTmpFile(); + Runnable r = createRunnable(p); + Thread thread = new Thread(r, "thread-" + i); + thread.start(); + threads.add(thread); + } + } + + public void join() { + for (Thread thread : threads) { + try { + thread.join(); + } catch (InterruptedException e) { + // ignore it and proceed to the next one + } + } + } + + public static void main(String[] args) throws Exception { + ParallelProbes probes = + new ParallelProbes(args.length < 1 ? 1 : Integer.parseInt(args[0])); + probes.start(); + probes.join(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/nio/file/WatchService/LotsOfCancels.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,119 @@ +/* + * 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 8029516 + * @summary Bash on WatchKey.cancel with a view to causing a crash when + * an outstanding I/O operation on directory completes after the + * directory has been closed + */ + +import java.nio.file.ClosedWatchServiceException; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.WatchKey; +import java.nio.file.WatchService; +import static java.nio.file.StandardWatchEventKinds.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class LotsOfCancels { + + // set to true for any exceptions + static volatile boolean failed; + + public static void main(String[] args) throws Exception { + + // create a bunch of directories. Create two tasks for each directory, + // one to bash on cancel, the other to poll the events + ExecutorService pool = Executors.newCachedThreadPool(); + try { + Path top = Files.createTempDirectory("work"); + top.toFile().deleteOnExit(); + for (int i=1; i<=16; i++) { + Path dir = Files.createDirectory(top.resolve("dir-" + i)); + WatchService watcher = FileSystems.getDefault().newWatchService(); + pool.submit(() -> handle(dir, watcher)); + pool.submit(() -> poll(watcher)); + } + } finally { + pool.shutdown(); + } + + // give thread pool lots of time to terminate + if (!pool.awaitTermination(5L, TimeUnit.MINUTES)) + throw new RuntimeException("Thread pool did not terminate"); + + if (failed) + throw new RuntimeException("Test failed, see log for details"); + } + + /** + * Stress the given WatchService, specifically the cancel method, in + * the given directory. Closes the WatchService when done. + */ + static void handle(Path dir, WatchService watcher) { + try { + try { + Path file = dir.resolve("anyfile"); + for (int i=0; i<2000; i++) { + WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE); + Files.createFile(file); + Files.delete(file); + key.cancel(); + } + } finally { + watcher.close(); + } + } catch (Exception e) { + e.printStackTrace(); + failed = true; + } + } + + /** + * Polls the given WatchService in a tight loop. This keeps the event + * queue drained, it also hogs a CPU core which seems necessary to + * tickle the original bug. + */ + static void poll(WatchService watcher) { + try { + for (;;) { + WatchKey key = watcher.take(); + if (key != null) { + key.pollEvents(); + key.reset(); + } + } + } catch (ClosedWatchServiceException expected) { + // nothing to do + } catch (Exception e) { + e.printStackTrace(); + failed = true; + } + } + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/security/KeyStore/CheckInputStream.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8136534 + * @summary The input stream supplied to KeyStore.load should remain open. + */ + +import java.io.*; +import java.security.*; + +public class CheckInputStream { + private final static String DIR = System.getProperty("test.src", "."); + private static final char[] PASSWORD = "passphrase".toCharArray(); + private static final String KEYSTORE = DIR + "/keystore.jks"; + + public static final void main(String[] args) throws Exception { + + KeyStore keystore = KeyStore.getInstance("JKS"); + try (FileInputStream inStream = new FileInputStream(KEYSTORE)) { + System.out.println("Loading JKS keystore: " + KEYSTORE); + keystore.load(inStream, PASSWORD); + // check that the stream is still open + inStream.available(); + System.out.println("OK"); + } + } +}
--- a/test/java/security/cert/CertPathBuilder/selfIssued/DisableRevocation.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/security/cert/CertPathBuilder/selfIssued/DisableRevocation.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -21,6 +21,12 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * @bug 6852744 @@ -234,6 +240,10 @@ public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPathBuilder builder = CertPathBuilder.getInstance("PKIX"); X509CertSelector selector = generateSelector(args[0]);
--- a/test/java/security/cert/CertPathBuilder/selfIssued/KeyUsageMatters.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/security/cert/CertPathBuilder/selfIssued/KeyUsageMatters.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -21,6 +21,12 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * @bug 6852744 @@ -277,6 +283,10 @@ public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPathBuilder builder = CertPathBuilder.getInstance("PKIX"); X509CertSelector selector = generateSelector(args[0]);
--- a/test/java/security/cert/CertPathBuilder/selfIssued/StatusLoopDependency.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/security/cert/CertPathBuilder/selfIssued/StatusLoopDependency.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -21,6 +21,12 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * @bug 6852744 @@ -283,6 +289,10 @@ public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPathBuilder builder = CertPathBuilder.getInstance("PKIX"); X509CertSelector selector = generateSelector(args[0]);
--- a/test/java/security/cert/CertPathValidator/OCSP/AIACheck.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/security/cert/CertPathValidator/OCSP/AIACheck.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -21,12 +21,19 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * @bug 5072953 * @summary Verify that the URL for an OCSP responder can be extracted from a * certificate's AuthorityInfoAccess extension when OCSP certifiate * validation has been enabled. + * @run main/othervm AIACheck */ import java.io.*; @@ -51,6 +58,10 @@ } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + X509Certificate aiaCert = loadCertificate("AIACert.pem"); X509Certificate rootCert = loadCertificate("RootCert.pem");
--- a/test/java/security/cert/CertPathValidator/OCSP/FailoverToCRL.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/security/cert/CertPathValidator/OCSP/FailoverToCRL.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -21,16 +21,24 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * @bug 6383095 * @summary CRL revoked certificate failures masked by OCSP failures - * + * @run main/othervm FailoverToCRL + * @author Xuelei Fan + */ + +/* * Note that the certificate validity is from Mar 16 14:55:35 2009 GMT to * Dec 1 14:55:35 2028 GMT, please update it with newer certificate if * expires. - * - * @author Xuelei Fan */ /* @@ -229,6 +237,10 @@ } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPath path = generateCertificatePath(); Set<TrustAnchor> anchors = generateTrustAnchors(); CertStore crls = generateCertificateStore();
--- a/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevel.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevel.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -21,11 +21,18 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * * @bug 6720721 * @summary CRL check with circular depency support needed + * @run main/othervm CircularCRLOneLevel * @author Xuelei Fan */ @@ -158,6 +165,10 @@ } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPath path = generateCertificatePath(); Set<TrustAnchor> anchors = generateTrustAnchors(); CertStore crls = generateCertificateStore();
--- a/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevelRevoked.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevelRevoked.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -21,11 +21,18 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * * @bug 6720721 * @summary CRL check with circular depency support needed + * @run main/othervm CircularCRLOneLevelRevoked * @author Xuelei Fan */ @@ -159,6 +166,10 @@ } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPath path = generateCertificatePath(); Set<TrustAnchor> anchors = generateTrustAnchors(); CertStore crls = generateCertificateStore();
--- a/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevel.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevel.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -21,11 +21,18 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * * @bug 6720721 * @summary CRL check with circular depency support needed + * @run main/othervm CircularCRLTwoLevel * @author Xuelei Fan */ @@ -210,6 +217,10 @@ } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPath path = generateCertificatePath(); Set<TrustAnchor> anchors = generateTrustAnchors(); CertStore crls = generateCertificateStore();
--- a/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevelRevoked.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevelRevoked.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -21,11 +21,18 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * * @bug 6720721 * @summary CRL check with circular depency support needed + * @run main/othervm CircularCRLTwoLevelRevoked * @author Xuelei Fan */ @@ -211,6 +218,10 @@ } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPath path = generateCertificatePath(); Set<TrustAnchor> anchors = generateTrustAnchors(); CertStore crls = generateCertificateStore();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/text/Format/DateFormat/Bug8081794.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8081794 + * @summary ParsePosition getErrorIndex should return correct index + */ +import java.text.ParsePosition; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +public class Bug8081794 { + + public static void main(String[] args) { + String date = "13 Jan 2005 21:45:34 ABC"; + String format = "dd MMM yyyy HH:mm:ss z"; + ParsePosition pp = new ParsePosition(0); + pp.setIndex(0); + SimpleDateFormat sd = new SimpleDateFormat(format, Locale.ENGLISH); + Date d = sd.parse(date, pp); + int errorIndex = pp.getErrorIndex(); + if (errorIndex == 21) { + System.out.println(": passed"); + } else { + System.out.println(": failed"); + throw new RuntimeException("Failed with wrong index: " + errorIndex); + } + } +}
--- a/test/java/time/tck/java/time/TCKInstant.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/time/tck/java/time/TCKInstant.java Thu Dec 03 13:27:36 2015 -0800 @@ -112,6 +112,8 @@ /** * Test Instant. + * + * @bug 8133022 */ @Test public class TCKInstant extends AbstractDateTimeTest { @@ -1928,6 +1930,16 @@ Instant.ofEpochSecond(Long.MIN_VALUE / 1000 - 1).toEpochMilli(); } + @Test(expectedExceptions=ArithmeticException.class) + public void test_toEpochMillis_overflow() { + Instant.ofEpochSecond(Long.MAX_VALUE / 1000, 809_000_000).toEpochMilli(); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_toEpochMillis_overflow2() { + Instant.ofEpochSecond(-9223372036854776L, 1).toEpochMilli(); + } + //----------------------------------------------------------------------- // compareTo() //-----------------------------------------------------------------------
--- a/test/java/time/test/java/time/TestInstant.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/java/time/test/java/time/TestInstant.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,6 +62,8 @@ import java.time.Instant; import org.testng.annotations.Test; +import org.testng.annotations.DataProvider; +import static org.testng.Assert.assertEquals; /** * Test Instant. @@ -74,4 +76,24 @@ assertImmutable(Instant.class); } + @DataProvider(name="sampleEpochMillis") + private Object[][] provider_sampleEpochMillis() { + return new Object[][] { + {"Long.MAX_VALUE", Long.MAX_VALUE}, + {"Long.MAX_VALUE-1", Long.MAX_VALUE - 1}, + {"1", 1L}, + {"0", 0L}, + {"-1", -1L}, + {"Long.MIN_VALUE+1", Long.MIN_VALUE + 1}, + {"Long.MIN_VALUE", Long.MIN_VALUE} + }; + } + + @Test(dataProvider="sampleEpochMillis") + public void test_epochMillis(String name, long millis) { + Instant t1 = Instant.ofEpochMilli(millis); + long m = t1.toEpochMilli(); + assertEquals(millis, m, name); + } + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/util/zip/ZipFile/ZipEntryFreeTest.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 6907252 + * @summary ZipFileInputStream Not Thread-Safe + * @library /lib/testlibrary + * @build jdk.testlibrary.* + * @run main ZipEntryFreeTest + */ + +import java.io.*; +import java.nio.file.Paths; +import java.util.Random; +import java.util.Timer; +import java.util.TimerTask; +import java.util.zip.*; +import jdk.testlibrary.FileUtils; + +public class ZipEntryFreeTest extends Thread { + + private static final int NUM_THREADS = 5; + private static final int TEST_ITERATIONS = 5; + private static final String ZIPFILE_NAME = "large.zip"; + private static final String ZIPENTRY_NAME = "random.txt"; + private static InputStream is = null; + final Timer timer = new Timer(); + + public static void main(String args[]) throws Exception { + createZipFile(); + try { + for (int i = 0; i < TEST_ITERATIONS; i++) { + runTest(); + } + } finally { + FileUtils.deleteFileIfExistsWithRetry(Paths.get(ZIPFILE_NAME)); + } + } + + private static void runTest() throws Exception { + try (ZipFile zf = new ZipFile(new File(ZIPFILE_NAME))) { + is = zf.getInputStream(zf.getEntry(ZIPENTRY_NAME + "_0")); + Thread[] threadArray = new Thread[NUM_THREADS]; + for (int i = 0; i < threadArray.length; i++) { + threadArray[i] = new ZipEntryFreeTest(); + } + for (int i = 0; i < threadArray.length; i++) { + threadArray[i].start(); + } + for (int i = 0; i < threadArray.length; i++) { + threadArray[i].join(); + } + } + } + + private static void createZipFile() throws Exception { + Random rnd = new Random(1000L); + byte[] contents = new byte[2_000_000]; + ZipEntry ze = null; + + try (ZipOutputStream zos = + new ZipOutputStream(new FileOutputStream(ZIPFILE_NAME))) { + // uncompressed mode seemed to tickle the crash + zos.setMethod(ZipOutputStream.STORED); + for (int ze_count = 0; ze_count < 10; ze_count++) { + rnd.nextBytes(contents); + ze = createZipEntry(contents, ze_count); + zos.putNextEntry(ze); + zos.write(contents, 0, contents.length); + } + zos.flush(); + } + } + + private static ZipEntry createZipEntry(byte[] b, int i) { + ZipEntry ze = new ZipEntry(ZIPENTRY_NAME + "_" + i); + ze.setCompressedSize(b.length); + ze.setSize(b.length); + CRC32 crc = new CRC32(); + crc.update(b); + ze.setCrc(crc.getValue()); + return ze; + } + + @Override + public void run() { + try { + int iteration = 0; + TimerTask tt = (new TimerTask() { + @Override + public void run() { + try { + is.close(); + } catch (Exception ex) { + ex.printStackTrace(System.out); + } + } + }); + timer.schedule(tt, 50); + while (is.read() != -1 && iteration++ < 1_000) { } + } catch (ZipException ze) { + // ZipException now expected instead of ZIP_Read crash + System.out.println(ze); + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + timer.cancel(); + } + } +}
--- a/test/javax/print/PrintSEUmlauts/PrintSEUmlauts.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/javax/print/PrintSEUmlauts/PrintSEUmlauts.java Thu Dec 03 13:27:36 2015 -0800 @@ -85,7 +85,7 @@ private static final boolean DEBUG = false; private static void testPrintAndExit() { - String expected = "<e4> 7.44 100.0 100.0 S"; + String expected = "<e4>"; String content = ""; File file = new File("out.ps");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/bind/jxc/8073519/InputWithError.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import javax.xml.bind.annotation.XmlType; + +@XmlType +public class InputWithError { + public int a; + int compile-error; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/bind/jxc/8073519/SchemagenErrorReporting.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8073519 + * @summary test that schemagen tool reports errors during + * xsd generation process + * @library /lib/testlibrary + * @run testng/othervm SchemagenErrorReporting + */ +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.Arrays; +import java.util.stream.Collectors; +import jdk.testlibrary.JDKToolLauncher; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class SchemagenErrorReporting { + + @Test + public void schemagenErrorReporting() throws Exception { + //schemagen tool output file name + final String SCHEMA_FILE = "schema1.xsd"; + //Schemagen input java file with not compilable source + final String CLASS_FILE = "InputWithError.java"; + //Test working, src directories and test output file + Path testWorkDir, testSrcDir, testOutput; + + //Prepare test environment + //Create test directory inside scratch + testWorkDir = Paths.get(System.getProperty("user.dir", ".")) + .resolve("SchemagenErrorReporting"); + //Get test source directory + testSrcDir = Paths.get(System.getProperty("test.src", ".")); + //Set test output file path + testOutput = testWorkDir.resolve("stdErrContent"); + //Create test directory inside scratch directory + Files.createDirectory(testWorkDir); + //Copy java source from test.src to the test directory + Files.copy(testSrcDir.resolve(CLASS_FILE), testWorkDir.resolve(CLASS_FILE), + StandardCopyOption.REPLACE_EXISTING); + + //Prepare process builder to run schemagen tool and save its output + JDKToolLauncher sgl = JDKToolLauncher.createUsingTestJDK("schemagen"); + sgl.addToolArg(CLASS_FILE); + System.out.println("Executing: " + Arrays.asList(sgl.getCommand())); + ProcessBuilder pb = new ProcessBuilder(sgl.getCommand()); + //Set schemagen work directory with the input java file + pb.directory(testWorkDir.toFile()); + //Redirect schemagen output to file + pb.redirectError(testOutput.toFile()); + Process p = pb.start(); + int result = p.waitFor(); + p.destroy(); + + //Read schemagen output from the file + String stdErrContent = Files.lines(testOutput) + .collect(Collectors.joining(System.lineSeparator(), System.lineSeparator(), "")); + System.out.println("Schemagen return value:" + result); + System.out.println("Error output:" + stdErrContent); + //Check test results: + //Schemagen finished with non-0 return value + Assert.assertNotEquals(result, 0); + //Schemagen output contains compile error message + Assert.assertTrue(stdErrContent.contains("InputWithError.java:28: error")); + } +}
--- a/test/lib/testlibrary/jdk/testlibrary/Utils.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/lib/testlibrary/jdk/testlibrary/Utils.java Thu Dec 03 13:27:36 2015 -0800 @@ -66,7 +66,7 @@ public static final double TIMEOUT_FACTOR; static { String toFactor = System.getProperty("test.timeout.factor", "1.0"); - TIMEOUT_FACTOR = Double.parseDouble(toFactor); + TIMEOUT_FACTOR = Double.parseDouble(toFactor); } /**
--- a/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/Helper.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/Helper.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -315,4 +315,33 @@ } return null; } + + /** + * Routine used to obtain a randomly generated method type. + * + * @param arity Arity of returned method type. + * @return MethodType generated randomly. + */ + public static MethodType randomMethodTypeGenerator(int arity) { + final Class<?>[] CLASSES = { + Object.class, + int.class, + boolean.class, + byte.class, + short.class, + char.class, + long.class, + float.class, + double.class + }; + if (arity > MAX_ARITY) { + throw new IllegalArgumentException( + String.format("Arity should not exceed %d!", MAX_ARITY)); + } + List<Class<?>> list = randomClasses(CLASSES, arity); + list = getParams(list, false, arity); + int i = RNG.nextInt(CLASSES.length + 1); + Class<?> rtype = i == CLASSES.length ? void.class : CLASSES[i]; + return MethodType.methodType(rtype, list); + } }
--- a/test/sun/net/util/IPAddressUtilTest.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/net/util/IPAddressUtilTest.java Thu Dec 03 13:27:36 2015 -0800 @@ -21,6 +21,12 @@ * questions. */ +/* + * @test + * @bug 8087190 + * @summary Exercise the sun.net.util.IPAddressUtil class + */ + import sun.net.util.*; /* @@ -39,6 +45,10 @@ {"238.255.2550.255", bad}, {"238.2550.255.255", bad}, {"2380.255.255.255", bad}, + {".1.1.1", bad}, + {"1..1.1", bad}, + {"1.1.1.", bad}, + {"...", bad}, {"10::10", good}, {"10::10.1", bad}, {"10::10.1.2", bad},
--- a/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java Thu Dec 03 13:27:36 2015 -0800 @@ -57,6 +57,10 @@ } public void main(Provider p) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + String testWithoutSunEC = System.getProperty("testWithoutSunEC"); if (p.getService("KeyFactory", "EC") == null) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/provider/certpath/DisabledAlgorithms/CPBuilderWithMD5.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,449 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// This test case relies on static security property, no way to re-use +// security property in samevm/agentvm mode. + +/** + * @test + * + * @bug 8141287 + * @summary Add MD5 to jdk.certpath.disabledAlgorithms security property + * + * @run main/othervm CPBuilderWithMD5 trustAnchor_SHA1withRSA_1024 0 true + * @run main/othervm CPBuilderWithMD5 trustAnchor_SHA1withRSA_512 0 true + * @run main/othervm CPBuilderWithMD5 intermediate_SHA1withRSA_1024_1024 1 true + * @run main/othervm CPBuilderWithMD5 intermediate_SHA1withRSA_1024_512 1 false + * @run main/othervm CPBuilderWithMD5 intermediate_SHA1withRSA_512_1024 1 false + * @run main/othervm CPBuilderWithMD5 intermediate_SHA1withRSA_512_512 1 false + * @run main/othervm CPBuilderWithMD5 intermediate_MD5withRSA_1024_1024 1 false + * @run main/othervm CPBuilderWithMD5 intermediate_MD5withRSA_1024_512 1 false + * @run main/othervm CPBuilderWithMD5 endentiry_SHA1withRSA_1024_1024 2 true + * @run main/othervm CPBuilderWithMD5 endentiry_SHA1withRSA_1024_512 2 false + * @run main/othervm CPBuilderWithMD5 endentiry_SHA1withRSA_512_1024 2 false + * @run main/othervm CPBuilderWithMD5 endentiry_SHA1withRSA_512_512 2 false + * @run main/othervm CPBuilderWithMD5 endentiry_MD5withRSA_1024_1024 2 false + * @run main/othervm CPBuilderWithMD5 endentiry_MD5withRSA_1024_512 2 false + * + * @author Xuelei Fan + */ + +/* + * The generate.sh was designed to generate MD2 signed certificates. The + * certificates used in this test are generated by an updated generate.sh that + * replacing MD2 with MD5 algorithm. + */ +import java.io.*; +import java.net.SocketException; +import java.util.*; +import java.security.Security; +import java.security.cert.*; +import sun.security.util.DerInputStream; + +public class CPBuilderWithMD5 { + + // SHA1withRSA 1024 + static String trustAnchor_SHA1withRSA_1024 = + "-----BEGIN CERTIFICATE-----\n" + + "MIICPjCCAaegAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTAeFw0xMzEyMjgxMTA4NTFaFw0zNDEyMDgxMTA4NTFa\n" + + "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" + + "AQUAA4GNADCBiQKBgQDn3JSHACqi/bcohVy7eFqDs3L5ehnXmF9Jrg4rMRUeNrxA\n" + + "61F8bJ9JXx4j8WyqmT0TtokgXuqGxbsXRQVVw4AdXLF2PwCs/y+Y+AwU59uDHA3J\n" + + "AMk4VvjV9MB2Ea6YzuLnbbj/TNrfxB6LZ7KBvh0fYGt2T40yMvOvilU/f6e3zQID\n" + + "AQABo4GJMIGGMB0GA1UdDgQWBBSIxINDFVm8GpUz3v+BbWNmDEKP7TBHBgNVHSME\n" + + "QDA+gBSIxINDFVm8GpUz3v+BbWNmDEKP7aEjpCEwHzELMAkGA1UEBhMCVVMxEDAO\n" + + "BgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQw\n" + + "DQYJKoZIhvcNAQEFBQADgYEAt0mYDXTpInrGvEOylIL2gx65A/bpdz9iDQsSs5sZ\n" + + "r3m0v9zJnzR8lRqN4GbaD1vrFdkUrIoObcvXjXitnf5QqDzmc9BbIYj83Ft8QSUj\n" + + "jCMy04EGT/7ATss4SiFEu6sJpmOBjsgH6wYuobR27wl/01XOu2CXUo3OOjgAoPBs\n" + + "QoQ=\n" + + "-----END CERTIFICATE-----"; + + // SHA1withRSA 512 + static String trustAnchor_SHA1withRSA_512 = + "-----BEGIN CERTIFICATE-----\n" + + "MIIBuTCCAWOgAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTAeFw0xMzEyMjgxMTA4NTFaFw0zNDEyMDgxMTA4NTFa\n" + + "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMFwwDQYJKoZIhvcNAQEB\n" + + "BQADSwAwSAJBANLqQkOpH7rBTo/a2ccYjJxvNib/Lxm6UXO1uAd/0AUzPWzJsOpB\n" + + "u2zyD26UYc0GNyXCkWMZ44FrtSQ8VI146j8CAwEAAaOBiTCBhjAdBgNVHQ4EFgQU\n" + + "5PVLxBY//smN31jHb/MAmCEz5NIwRwYDVR0jBEAwPoAU5PVLxBY//smN31jHb/MA\n" + + "mCEz5NKhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlggEAMA8G\n" + + "A1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0GCSqGSIb3DQEBBQUAA0EAzF9E\n" + + "dXYPLqziCRY45IHCUtxaLjLQmwsjEu91TV4xyuuozGEumcqH7m6Hg6Ohnd1FGfsN\n" + + "X+vt1tdaDIu9+OzGjQ==\n" + + "-----END CERTIFICATE-----"; + + // SHA1withRSA 1024 signed with RSA 1024 + static String intermediate_SHA1withRSA_1024_1024 = + "-----BEGIN CERTIFICATE-----\n" + + "MIICUDCCAbmgAwIBAgIBAzANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTAeFw0xMzEyMjgxMTA5MDlaFw0zMzA5MTQxMTA5MDla\n" + + "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" + + "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC/m9wdJT0HR+exquh2Q2Yq\n" + + "XvL9HtEsCabCikd0Vjuoi3sZJ/5SBbbHTvh7z7enW0NEpLHQee0ry5FW8mLxDtrR\n" + + "38NjE9W7zutucBG5WztwGuvcts13aEw+vH+EwhokJW9PXz9Do+y4PTJo3vdsk7Zs\n" + + "bGVY9+YjvlgEaozWXZ1JhQIDAQABo4GJMIGGMB0GA1UdDgQWBBQIsaDZL94kLug/\n" + + "A1N4EkNOA4z47DBHBgNVHSMEQDA+gBSIxINDFVm8GpUz3v+BbWNmDEKP7aEjpCEw\n" + + "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" + + "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEFBQADgYEA0673aIUF2k20jkpR\n" + + "4USN9UkbfX57Uazhl4n765EeAiteWnTzKztISeH1GTrCw7bSl1r07aaflsnbKOHC\n" + + "RrL2RxbxNwQARvuuCxr664vXnsGrt86xA5F2iNF22uDM/5HA5sIfBmEk5xXSLrgH\n" + + "I7jOaYqAA1b8C+4DU2Z5ZgO4LOA=\n" + + "-----END CERTIFICATE-----"; + + // SHA1withRSA 1024 signed with RSA 512 + static String intermediate_SHA1withRSA_1024_512 = + "-----BEGIN CERTIFICATE-----\n" + + "MIICDzCCAbmgAwIBAgIBBDANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTAeFw0xMzEyMjgxMTA5MDlaFw0zMzA5MTQxMTA5MDla\n" + + "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" + + "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC/m9wdJT0HR+exquh2Q2Yq\n" + + "XvL9HtEsCabCikd0Vjuoi3sZJ/5SBbbHTvh7z7enW0NEpLHQee0ry5FW8mLxDtrR\n" + + "38NjE9W7zutucBG5WztwGuvcts13aEw+vH+EwhokJW9PXz9Do+y4PTJo3vdsk7Zs\n" + + "bGVY9+YjvlgEaozWXZ1JhQIDAQABo4GJMIGGMB0GA1UdDgQWBBQIsaDZL94kLug/\n" + + "A1N4EkNOA4z47DBHBgNVHSMEQDA+gBTk9UvEFj/+yY3fWMdv8wCYITPk0qEjpCEw\n" + + "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" + + "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEFBQADQQAihshnF7RWZ13tUGsH\n" + + "iM4i8HmBjw2+pwW/cs0E8BcycYEy3beWMcL1Np2yfOa/7K5ZvGPhe/piwzTel+Kt\n" + + "5VLm\n" + + "-----END CERTIFICATE-----"; + + // SHA1withRSA 512 signed with RSA 1024 + static String intermediate_SHA1withRSA_512_1024 = + "-----BEGIN CERTIFICATE-----\n" + + "MIICDDCCAXWgAwIBAgIBBTANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTAeFw0xMzEyMjgxMTA5MDlaFw0zMzA5MTQxMTA5MDla\n" + + "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" + + "cy0xMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAK4h/iW3wt+ugR5ObWiFSl394UU/\n" + + "lWNm+N6UAgsBRhSzZz/Iof7xZTQI+usNXzOrTnU3+uZsMgokpjkrko1osxUCAwEA\n" + + "AaOBiTCBhjAdBgNVHQ4EFgQU88OD48Osuh7lJiLnhfMhrySqW8QwRwYDVR0jBEAw\n" + + "PoAUiMSDQxVZvBqVM97/gW1jZgxCj+2hI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" + + "VQQKEwdFeGFtcGxlggEAMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0G\n" + + "CSqGSIb3DQEBBQUAA4GBAAHN8XUTT6asa1MvpfqAvKTH6tNrMOmzoFsUamPxSrUB\n" + + "tnBv/fa/E9+1QvQwl3g6luVXBkQf2/nVD0195IdkEuD/C6psuGKerXmiaRMv5Wcs\n" + + "B+8bTzhNxMzHKPZDJ8Tf/RD3XpPvtxw0T+I5xud68FH/WDhJtu7TiXPAhs7srtHt\n" + + "-----END CERTIFICATE-----"; + + // SHA1withRSA 512 signed with RSA 512 + static String intermediate_SHA1withRSA_512_512 = + "-----BEGIN CERTIFICATE-----\n" + + "MIIByzCCAXWgAwIBAgIBBjANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTAeFw0xMzEyMjgxMTA5MDlaFw0zMzA5MTQxMTA5MDla\n" + + "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" + + "cy0xMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAK4h/iW3wt+ugR5ObWiFSl394UU/\n" + + "lWNm+N6UAgsBRhSzZz/Iof7xZTQI+usNXzOrTnU3+uZsMgokpjkrko1osxUCAwEA\n" + + "AaOBiTCBhjAdBgNVHQ4EFgQU88OD48Osuh7lJiLnhfMhrySqW8QwRwYDVR0jBEAw\n" + + "PoAU5PVLxBY//smN31jHb/MAmCEz5NKhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" + + "VQQKEwdFeGFtcGxlggEAMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0G\n" + + "CSqGSIb3DQEBBQUAA0EASLN+1/pfo+9ty5EaYkoPu4QeYGr+5wmXyDceiaED/Lok\n" + + "RdV0ZH0qwD4kiarlJssNOgMCk+2EzgvXcIhEMDa5hA==\n" + + "-----END CERTIFICATE-----"; + + // MD5withRSA 1024 signed with RSA 1024 + static String intermediate_MD5withRSA_1024_1024 = + "-----BEGIN CERTIFICATE-----\n" + + "MIICUDCCAbmgAwIBAgIBBzANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTAeFw0xMzEyMjgxMTA5MDlaFw0zMzA5MTQxMTA5MDla\n" + + "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" + + "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC/m9wdJT0HR+exquh2Q2Yq\n" + + "XvL9HtEsCabCikd0Vjuoi3sZJ/5SBbbHTvh7z7enW0NEpLHQee0ry5FW8mLxDtrR\n" + + "38NjE9W7zutucBG5WztwGuvcts13aEw+vH+EwhokJW9PXz9Do+y4PTJo3vdsk7Zs\n" + + "bGVY9+YjvlgEaozWXZ1JhQIDAQABo4GJMIGGMB0GA1UdDgQWBBQIsaDZL94kLug/\n" + + "A1N4EkNOA4z47DBHBgNVHSMEQDA+gBSIxINDFVm8GpUz3v+BbWNmDEKP7aEjpCEw\n" + + "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" + + "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEEBQADgYEAerx2je3FBVn2eoPs\n" + + "nTzLKILezqCTCO7mXWiyBidRhh4RGdM8JggMN5SRmuwRurxfYFgPfqmAenWtEFqO\n" + + "xZrTXQUvIrrEgpzqkfppFnkCh4kDsX4roD5Nho3J4MTBQkqE0r676Yq6Rp6cywCq\n" + + "CHQQztRGY7n/ZYRNJ3uzvuoT1tk=\n" + + "-----END CERTIFICATE-----"; + + // MD5withRSA 1024 signed with RSA 512 + static String intermediate_MD5withRSA_1024_512 = + "-----BEGIN CERTIFICATE-----\n" + + "MIICDzCCAbmgAwIBAgIBCDANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTAeFw0xMzEyMjgxMTA5MTBaFw0zMzA5MTQxMTA5MTBa\n" + + "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" + + "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC/m9wdJT0HR+exquh2Q2Yq\n" + + "XvL9HtEsCabCikd0Vjuoi3sZJ/5SBbbHTvh7z7enW0NEpLHQee0ry5FW8mLxDtrR\n" + + "38NjE9W7zutucBG5WztwGuvcts13aEw+vH+EwhokJW9PXz9Do+y4PTJo3vdsk7Zs\n" + + "bGVY9+YjvlgEaozWXZ1JhQIDAQABo4GJMIGGMB0GA1UdDgQWBBQIsaDZL94kLug/\n" + + "A1N4EkNOA4z47DBHBgNVHSMEQDA+gBTk9UvEFj/+yY3fWMdv8wCYITPk0qEjpCEw\n" + + "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" + + "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEEBQADQQA3XGQPNin8cDIsJ4vx\n" + + "tTxUO6XVJoWOdTsjwzlMrPmLvjJNZeXLtQe3pQu0vjgyUpQ59VYLW3qKN/LF3UH0\n" + + "Ep7V\n" + + "-----END CERTIFICATE-----"; + + // SHA1withRSA 1024 signed with RSA 1024 + static String endentiry_SHA1withRSA_1024_1024 = + "-----BEGIN CERTIFICATE-----\n" + + "MIICNzCCAaCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0xMzEyMjgxMTA5\n" + + "MTJaFw0zMzA5MTQxMTA5MTJaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" + + "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" + + "9w0BAQEFAAOBjQAwgYkCgYEAvktJqK4/SvQrTyGgV8tM6zP/K5xQP1pFRipRKS8i\n" + + "2yaXdlW4jQBZWVXdfEsm8YwGwtXFKIlleALmgJcLldPwNm0qaKixL4mRJVMm4bXM\n" + + "UXCfmr+Im1SpA4Yum4VFCfIJ1kkeQkXqc57sCSfS+rFnC+1kSNa9wj+Mc4+5FR4k\n" + + "zqUCAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBRDzLh/sWyTsdq1KKnG\n" + + "8e7JW1tPUDAfBgNVHSMEGDAWgBQIsaDZL94kLug/A1N4EkNOA4z47DANBgkqhkiG\n" + + "9w0BAQUFAAOBgQB2RkWHOaL4WTOGoeTS4J4o9FW+4UXihbocdI/64rMExERjDkE/\n" + + "Jh31TEmatnP1gPrF1AfmqQPubqVSbRtCHrZF+Ilk6L6YeyRNzKvsLiMUtgrLYLas\n" + + "Vop0DFZxR02xHgaJdoJkcWBjNadb9zG7eZtt8OOOJ4lRwg02aLTy+WDqPA==\n" + + "-----END CERTIFICATE-----"; + + // SHA1withRSA 1024 signed with RSA 512 + static String endentiry_SHA1withRSA_1024_512 = + "-----BEGIN CERTIFICATE-----\n" + + "MIIB9jCCAaCgAwIBAgIBAzANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0xMzEyMjgxMTA5\n" + + "MTJaFw0zMzA5MTQxMTA5MTJaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" + + "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" + + "9w0BAQEFAAOBjQAwgYkCgYEAvktJqK4/SvQrTyGgV8tM6zP/K5xQP1pFRipRKS8i\n" + + "2yaXdlW4jQBZWVXdfEsm8YwGwtXFKIlleALmgJcLldPwNm0qaKixL4mRJVMm4bXM\n" + + "UXCfmr+Im1SpA4Yum4VFCfIJ1kkeQkXqc57sCSfS+rFnC+1kSNa9wj+Mc4+5FR4k\n" + + "zqUCAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBRDzLh/sWyTsdq1KKnG\n" + + "8e7JW1tPUDAfBgNVHSMEGDAWgBTzw4Pjw6y6HuUmIueF8yGvJKpbxDANBgkqhkiG\n" + + "9w0BAQUFAANBAIapvjECUm4YD4O99G0v2SM17cKQzjZtSWkScS7FSk4sxS+dP3hM\n" + + "Qb2UpoRl6CGynhOVVy2G/VJN8BEqOfywj8k=\n" + + "-----END CERTIFICATE-----"; + + // SHA1withRSA 512 signed with RSA 1024 + static String endentiry_SHA1withRSA_512_1024 = + "-----BEGIN CERTIFICATE-----\n" + + "MIIB8zCCAVygAwIBAgIBBDANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0xMzEyMjgxMTA5\n" + + "MTJaFw0zMzA5MTQxMTA5MTJaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" + + "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTBcMA0GCSqGSIb3\n" + + "DQEBAQUAA0sAMEgCQQCngiNTE+qngHcfj2jUpdc82gCw+TFRjR7oMSdp7b/3NwpD\n" + + "E+11z9WspoXTDzvbKcGUH9svFl691NyY0ZUmf+4RAgMBAAGjTzBNMAsGA1UdDwQE\n" + + "AwID6DAdBgNVHQ4EFgQUK+oVsFTQbz08evgQZ5Sd82c2y4UwHwYDVR0jBBgwFoAU\n" + + "CLGg2S/eJC7oPwNTeBJDTgOM+OwwDQYJKoZIhvcNAQEFBQADgYEAMd/8XnjRz5jK\n" + + "nbss9DDQQC2mUuCbV/tGdke7eQ1DtBVZLBU6wDgisGr52sUXmyZIPmSVKpQqwCG5\n" + + "8cY5uQhaNwPtPmMMKXzX32zN9NhVkiDNceL+zHs3vdjD1i/QiUTST+NKfLYVb6dF\n" + + "YMG65lxe3gMVxMweiHSZSukmk1k3gUA=\n" + + "-----END CERTIFICATE-----"; + + // SHA1withRSA 512 signed with RSA 512 + static String endentiry_SHA1withRSA_512_512 = + "-----BEGIN CERTIFICATE-----\n" + + "MIIBsjCCAVygAwIBAgIBBTANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0xMzEyMjgxMTA5\n" + + "MTJaFw0zMzA5MTQxMTA5MTJaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" + + "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTBcMA0GCSqGSIb3\n" + + "DQEBAQUAA0sAMEgCQQCngiNTE+qngHcfj2jUpdc82gCw+TFRjR7oMSdp7b/3NwpD\n" + + "E+11z9WspoXTDzvbKcGUH9svFl691NyY0ZUmf+4RAgMBAAGjTzBNMAsGA1UdDwQE\n" + + "AwID6DAdBgNVHQ4EFgQUK+oVsFTQbz08evgQZ5Sd82c2y4UwHwYDVR0jBBgwFoAU\n" + + "88OD48Osuh7lJiLnhfMhrySqW8QwDQYJKoZIhvcNAQEFBQADQQB4xFWtC6ijDBIe\n" + + "/Gkf3B9+ycmP52pTPNiPwMS6u1a5vTRXMn5xRDexWfxJKJVZ2s9UR1jheZvWgPC8\n" + + "VUWO8bbG\n" + + "-----END CERTIFICATE-----"; + + // MD5withRSA 1024 signed with RSA 1024 + static String endentiry_MD5withRSA_1024_1024 = + "-----BEGIN CERTIFICATE-----\n" + + "MIICNzCCAaCgAwIBAgIBBjANBgkqhkiG9w0BAQQFADAxMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0xMzEyMjgxMTA5\n" + + "MTJaFw0zMzA5MTQxMTA5MTJaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" + + "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" + + "9w0BAQEFAAOBjQAwgYkCgYEAvktJqK4/SvQrTyGgV8tM6zP/K5xQP1pFRipRKS8i\n" + + "2yaXdlW4jQBZWVXdfEsm8YwGwtXFKIlleALmgJcLldPwNm0qaKixL4mRJVMm4bXM\n" + + "UXCfmr+Im1SpA4Yum4VFCfIJ1kkeQkXqc57sCSfS+rFnC+1kSNa9wj+Mc4+5FR4k\n" + + "zqUCAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBRDzLh/sWyTsdq1KKnG\n" + + "8e7JW1tPUDAfBgNVHSMEGDAWgBQIsaDZL94kLug/A1N4EkNOA4z47DANBgkqhkiG\n" + + "9w0BAQQFAAOBgQBCVn9/JQxsRTaKIKSrgB+KtEreat+33k3SXuJICuRxcmvjOXIx\n" + + "wSdq+mRCA+DpIPSNtgnDAUyipnyxRxpdmRRUHuRYpkALq4a5QtTJK0Y/CEMfsd2J\n" + + "Yd2zKcfynDLW6LVeNdtjlY7fTemJnbA/WImNhwyW55V9vbnk3J04EZN8jw==\n" + + "-----END CERTIFICATE-----"; + + // MD5withRSA 1024 signed with RSA 512 + static String endentiry_MD5withRSA_1024_512 = + "-----BEGIN CERTIFICATE-----\n" + + "MIIB9jCCAaCgAwIBAgIBBzANBgkqhkiG9w0BAQQFADAxMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0xMzEyMjgxMTA5\n" + + "MTNaFw0zMzA5MTQxMTA5MTNaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" + + "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" + + "9w0BAQEFAAOBjQAwgYkCgYEAvktJqK4/SvQrTyGgV8tM6zP/K5xQP1pFRipRKS8i\n" + + "2yaXdlW4jQBZWVXdfEsm8YwGwtXFKIlleALmgJcLldPwNm0qaKixL4mRJVMm4bXM\n" + + "UXCfmr+Im1SpA4Yum4VFCfIJ1kkeQkXqc57sCSfS+rFnC+1kSNa9wj+Mc4+5FR4k\n" + + "zqUCAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBRDzLh/sWyTsdq1KKnG\n" + + "8e7JW1tPUDAfBgNVHSMEGDAWgBTzw4Pjw6y6HuUmIueF8yGvJKpbxDANBgkqhkiG\n" + + "9w0BAQQFAANBAAbZwmkqb6sfiiIxuLnj6PjhJsXGfvPomkkbLu5CapAMhen/p6ZG\n" + + "6vh69TbIsBR9UHu7qDyTl5Xax7bmYeW+sDQ=\n" + + "-----END CERTIFICATE-----"; + + static HashMap<String, String> certmap = new HashMap<String, String>(); + static { + certmap.put("trustAnchor_SHA1withRSA_1024", + trustAnchor_SHA1withRSA_1024); + certmap.put("trustAnchor_SHA1withRSA_512", + trustAnchor_SHA1withRSA_512); + certmap.put("intermediate_SHA1withRSA_1024_1024", + intermediate_SHA1withRSA_1024_1024); + certmap.put("intermediate_SHA1withRSA_1024_512", + intermediate_SHA1withRSA_1024_512); + certmap.put("intermediate_SHA1withRSA_512_1024", + intermediate_SHA1withRSA_512_1024); + certmap.put("intermediate_SHA1withRSA_512_512", + intermediate_SHA1withRSA_512_512); + certmap.put("intermediate_MD5withRSA_1024_1024", + intermediate_MD5withRSA_1024_1024); + certmap.put("intermediate_MD5withRSA_1024_512", + intermediate_MD5withRSA_1024_512); + certmap.put("endentiry_SHA1withRSA_1024_1024", + endentiry_SHA1withRSA_1024_1024); + certmap.put("endentiry_SHA1withRSA_1024_512", + endentiry_SHA1withRSA_1024_512); + certmap.put("endentiry_SHA1withRSA_512_1024", + endentiry_SHA1withRSA_512_1024); + certmap.put("endentiry_SHA1withRSA_512_512", + endentiry_SHA1withRSA_512_512); + certmap.put("endentiry_MD5withRSA_1024_1024", + endentiry_MD5withRSA_1024_1024); + certmap.put("endentiry_MD5withRSA_1024_512", + endentiry_MD5withRSA_1024_512); + } + + private static Set<TrustAnchor> generateTrustAnchors() + throws CertificateException { + // generate certificate from cert string + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + HashSet<TrustAnchor> anchors = new HashSet<TrustAnchor>(); + + ByteArrayInputStream is = + new ByteArrayInputStream(trustAnchor_SHA1withRSA_1024.getBytes()); + Certificate cert = cf.generateCertificate(is); + TrustAnchor anchor = new TrustAnchor((X509Certificate)cert, null); + anchors.add(anchor); + + is = new ByteArrayInputStream(trustAnchor_SHA1withRSA_512.getBytes()); + cert = cf.generateCertificate(is); + anchor = new TrustAnchor((X509Certificate)cert, null); + anchors.add(anchor); + + return anchors; + } + + private static CertStore generateCertificateStore() throws Exception { + Collection entries = new HashSet(); + + // generate certificate from certificate string + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + + for (String key : certmap.keySet()) { + String certStr = certmap.get(key); + ByteArrayInputStream is = + new ByteArrayInputStream(certStr.getBytes());; + Certificate cert = cf.generateCertificate(is); + entries.add(cert); + } + + return CertStore.getInstance("Collection", + new CollectionCertStoreParameters(entries)); + } + + private static X509CertSelector generateSelector(String name) + throws Exception { + X509CertSelector selector = new X509CertSelector(); + + String certStr = certmap.get(name); + if (certStr == null) { + return null; + } + + // generate certificate from certificate string + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + ByteArrayInputStream is = new ByteArrayInputStream(certStr.getBytes()); + X509Certificate target = (X509Certificate)cf.generateCertificate(is); + + selector.setCertificate(target); + + return selector; + } + + private static boolean match(String name, Certificate cert) + throws Exception { + X509CertSelector selector = new X509CertSelector(); + + String certStr = certmap.get(name); + if (certStr == null) { + return false; + } + + // generate certificate from certificate string + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + ByteArrayInputStream is = new ByteArrayInputStream(certStr.getBytes()); + X509Certificate target = (X509Certificate)cf.generateCertificate(is); + + return target.equals(cert); + } + + public static void main(String args[]) throws Exception { + CertPathBuilder builder = CertPathBuilder.getInstance("PKIX"); + + X509CertSelector selector = generateSelector(args[0]); + if (selector == null) { + // no target certificate, ignore it + return; + } + + Set<TrustAnchor> anchors = generateTrustAnchors(); + CertStore certs = generateCertificateStore(); + + PKIXBuilderParameters params = + new PKIXBuilderParameters(anchors, selector); + params.addCertStore(certs); + params.setRevocationEnabled(false); + params.setDate(new Date(114, 9, 1)); // 2014-09-01 + + boolean success = Boolean.valueOf(args[2]); + try { + PKIXCertPathBuilderResult result = + (PKIXCertPathBuilderResult)builder.build(params); + if (!success) { + throw new Exception("expected algorithm disabled exception"); + } + + int length = Integer.parseInt(args[1]); + List<? extends Certificate> path = + result.getCertPath().getCertificates(); + if (length != path.size()) { + throw new Exception("unexpected certification path length"); + } + + if (!path.isEmpty()) { // the target is not a trust anchor + if (!match(args[0], path.get(0))) { + throw new Exception("unexpected certificate"); + } + } + } catch (CertPathBuilderException cpbe) { + if (success) { + throw new Exception("unexpected exception", cpbe); + } else { + System.out.println("Get the expected exception " + cpbe); + } + } + } + +}
--- a/test/sun/security/provider/certpath/ReverseBuilder/BuildPath.java Thu Dec 03 10:32:59 2015 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2007, 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 6511784 - * @summary Make sure that building a path to a CRL issuer works in the - * reverse direction - * @library ../../../../../java/security/testlibrary - * @build CertUtils - * @run main BuildPath - */ -import java.security.cert.*; -import java.util.Collections; -import sun.security.provider.certpath.SunCertPathBuilderParameters; - -public class BuildPath { - - public static void main(String[] args) throws Exception { - - TrustAnchor anchor = - new TrustAnchor(CertUtils.getCertFromFile("mgrM2mgrM"), null); - X509Certificate target = CertUtils.getCertFromFile("mgrM2leadMA"); - X509CertSelector xcs = new X509CertSelector(); - xcs.setSubject("CN=leadMA,CN=mgrM,OU=prjM,OU=divE,OU=Comp,O=sun,C=us"); - xcs.setCertificate(target); - SunCertPathBuilderParameters params = - new SunCertPathBuilderParameters(Collections.singleton(anchor),xcs); - params.setBuildForward(false); - CertStore cs = CertUtils.createStore(new String[] - {"mgrM2prjM", "prjM2mgrM", "prjM2divE", "mgrM2leadMA" }); - params.addCertStore(cs); - CertStore cs2 = CertUtils.createCRLStore - (new String[] {"mgrMcrl", "prjMcrl"}); - params.addCertStore(cs2); - PKIXCertPathBuilderResult res = CertUtils.build(params); - } -}
--- a/test/sun/security/provider/certpath/ReverseBuilder/ReverseBuild.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/provider/certpath/ReverseBuilder/ReverseBuild.java Thu Dec 03 13:27:36 2015 -0800 @@ -26,6 +26,7 @@ * @bug 7167988 * @summary PKIX CertPathBuilder in reverse mode doesn't work if more than * one trust anchor is specified + * @run main/othervm ReverseBuild */ import java.io.*; import java.util.*; @@ -279,6 +280,9 @@ public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + java.security.Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); // generate certificate from cert string CertificateFactory cf = CertificateFactory.getInstance("X.509");
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/MD2InTrustAnchor.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/MD2InTrustAnchor.java Thu Dec 03 13:27:36 2015 -0800 @@ -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,13 +23,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 7113275 * @summary compatibility issue with MD2 trust anchor and old X509TrustManager - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @run main/othervm MD2InTrustAnchor PKIX TLSv1.1 * @run main/othervm MD2InTrustAnchor SunX509 TLSv1.1 * @run main/othervm MD2InTrustAnchor PKIX TLSv1.2 @@ -40,6 +42,7 @@ import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -283,6 +286,10 @@ volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/TrustTrustedCert.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/TrustTrustedCert.java Thu Dec 03 13:27:36 2015 -0800 @@ -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,13 +23,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 7113275 * @summary compatibility issue with MD2 trust anchor and old X509TrustManager - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @run main/othervm TrustTrustedCert PKIX TLSv1.1 * @run main/othervm TrustTrustedCert SunX509 TLSv1.1 * @run main/othervm TrustTrustedCert PKIX TLSv1.2 @@ -336,6 +338,10 @@ volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/PreferredKey.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/PreferredKey.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -21,11 +21,18 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /* * @test * @bug 6302644 * @summary X509KeyManager implementation for NewSunX509 doesn't return most * preferable key + * @run main/othervm PreferredKey */ import java.io.*; import java.net.*; @@ -49,6 +56,10 @@ public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + KeyStore ks; KeyManagerFactory kmf; X509KeyManager km;
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/BasicConstraints.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/BasicConstraints.java Thu Dec 03 13:27:36 2015 -0800 @@ -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 @@ -21,14 +21,16 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 7166570 * @summary JSSE certificate validation has started to fail for * certificate chains - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @run main/othervm BasicConstraints PKIX * @run main/othervm BasicConstraints SunX509 */ @@ -37,6 +39,7 @@ import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.*; @@ -454,6 +457,10 @@ volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/PKIXExtendedTM.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/PKIXExtendedTM.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -21,21 +21,23 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// /* * @test * @bug 6916074 * @summary Add support for TLS 1.2 * @run main/othervm PKIXExtendedTM - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. */ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -791,6 +793,10 @@ volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SelfIssuedCert.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SelfIssuedCert.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -21,15 +21,17 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 6822460 * @summary support self-issued certificate * @run main/othervm SelfIssuedCert PKIX * @run main/othervm SelfIssuedCert SunX509 - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Xuelei Fan */ @@ -37,6 +39,7 @@ import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -302,6 +305,10 @@ volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -21,20 +21,23 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 6916074 * @summary Add support for TLS 1.2 * @run main/othervm SunX509ExtendedTM - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. */ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -792,6 +795,10 @@ volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/CriticalSubjectAltName.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/CriticalSubjectAltName.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -21,18 +21,21 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 6668231 * @summary Presence of a critical subjectAltName causes JSSE's SunX509 to * fail trusted checks * @run main/othervm CriticalSubjectAltName - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. - * * @author Xuelei Fan - * + */ + +/* * This test depends on binary keystore, crisubn.jks and trusted.jks. Because * JAVA keytool cannot generate X509 certificate with SubjectAltName extension, * the certificates are generated with openssl toolkits and then imported into @@ -47,6 +50,7 @@ import java.io.*; import java.net.*; import javax.net.ssl.*; +import java.security.Security; import java.security.cert.Certificate; public class CriticalSubjectAltName implements HostnameVerifier { @@ -154,6 +158,10 @@ volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + String keyFilename = System.getProperty("test.src", "./") + "/" + pathToStores + "/" + keyStoreFile;
--- a/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketSNISensitive.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketSNISensitive.java Thu Dec 03 13:27:36 2015 -0800 @@ -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 @@ -44,6 +44,7 @@ import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -431,6 +432,10 @@ volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/security/ssl/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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,15 +23,16 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 4873188 * @summary Support TLS 1.1 * @run main/othervm EmptyCertificateAuthorities - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. - * * @author Xuelei Fan */ @@ -228,6 +229,10 @@ volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + String keyFilename = System.getProperty("test.src", ".") + "/" + pathToStores + "/" + keyStoreFile;
--- a/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -21,13 +21,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* @test * @bug 6766775 * @summary X509 certificate hostname checking is broken in JDK1.6.0_10 * @run main/othervm DNSIdentities - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Xuelei Fan */ @@ -35,6 +37,7 @@ import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -743,6 +746,10 @@ volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -21,13 +21,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* @test * @summary X509 certificate hostname checking is broken in JDK1.6.0_10 * @bug 6766775 * @run main/othervm IPAddressIPIdentities - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Xuelei Fan */ @@ -35,6 +37,7 @@ import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -744,6 +747,10 @@ volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -21,13 +21,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* @test * @summary X509 certificate hostname checking is broken in JDK1.6.0_10 * @bug 6766775 * @run main/othervm IPIdentities - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Xuelei Fan */ @@ -35,6 +37,7 @@ import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -743,6 +746,10 @@ volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/Identities.java Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/Identities.java Thu Dec 03 13:27:36 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -21,13 +21,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* @test * @bug 6766775 * @summary X509 certificate hostname checking is broken in JDK1.6.0_10 * @run main/othervm Identities - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Xuelei Fan */ @@ -35,6 +37,7 @@ import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -743,6 +746,10 @@ volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all");
--- a/test/sun/util/calendar/zi/tzdata/VERSION Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/util/calendar/zi/tzdata/VERSION Thu Dec 03 13:27:36 2015 -0800 @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2015f +tzdata2015g
--- a/test/sun/util/calendar/zi/tzdata/asia Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/util/calendar/zi/tzdata/asia Thu Dec 03 13:27:36 2015 -0800 @@ -154,7 +154,8 @@ # Azerbaijan # From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23): # According to the resolution of Cabinet of Ministers, 1997 -# Resolution available at: http://aif.az/docs/daylight_res.pdf +# From Paul Eggert (2015-09-17): It was Resolution No. 21 (1997-03-17). +# http://code.az/files/daylight_res.pdf # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Azer 1997 max - Mar lastSun 4:00 1:00 S Rule Azer 1997 max - Oct lastSun 5:00 0 - @@ -1740,11 +1741,12 @@ # the 8:30 time zone on August 15, one example: # http://www.bbc.com/news/world-asia-33815049 # -# From Paul Eggert (2015-08-07): -# No transition time is specified; assume 00:00. +# From Paul Eggert (2015-08-15): +# Bells rang out midnight (00:00) Friday as part of the celebrations. See: +# Talmadge E. North Korea celebrates new time zone, 'Pyongyang Time' +# http://news.yahoo.com/north-korea-celebrates-time-zone-pyongyang-time-164038128.html # There is no common English-language abbreviation for this time zone. -# Use %z rather than invent one. We can't assume %z works everywhere yet, -# so for now substitute its output manually. +# Use KST, as that's what we already use for 1954-1961 in ROK. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Seoul 8:27:52 - LMT 1908 Apr 1 @@ -1758,7 +1760,7 @@ 8:30 - KST 1912 Jan 1 9:00 - JCST 1937 Oct 1 9:00 - JST 1945 Aug 24 - 9:00 - KST 2015 Aug 15 + 9:00 - KST 2015 Aug 15 00:00 8:30 - KST ###############################################################################
--- a/test/sun/util/calendar/zi/tzdata/australasia Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/util/calendar/zi/tzdata/australasia Thu Dec 03 13:27:36 2015 -0800 @@ -358,10 +358,17 @@ # DST will start Nov. 2 this year. # http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-NOVEMBER-2ND.aspx -# From Paul Eggert (2014-10-20): +# From a government order dated 2015-08-26 and published as Legal Notice No. 77 +# in the Government of Fiji Gazette Supplement No. 24 (2015-08-28), +# via Ken Rylander (2015-09-02): +# the daylight saving period is 1 hour in advance of the standard time +# commencing at 2.00 am on Sunday 1st November, 2015 and ending at +# 3.00 am on Sunday 17th January, 2016. + +# From Paul Eggert (2015-09-01): # For now, guess DST from 02:00 the first Sunday in November to -# 03:00 the first Sunday on or after January 18. Although ad hoc, it -# matches this year's plan and seems more likely to match future +# 03:00 the third Sunday in January. Although ad hoc, it matches +# transitions since late 2014 and seems more likely to match future # practice than guessing no DST. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -374,7 +381,7 @@ Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - Rule Fiji 2014 only - Jan Sun>=18 2:00 0 - Rule Fiji 2014 max - Nov Sun>=1 2:00 1:00 S -Rule Fiji 2015 max - Jan Sun>=18 3:00 0 - +Rule Fiji 2015 max - Jan Sun>=15 3: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 @@ -533,7 +540,10 @@ # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Pacific/Norfolk 11:11:52 - LMT 1901 # Kingston 11:12 - NMT 1951 # Norfolk Mean Time - 11:30 - NFT # Norfolk Time + 11:30 - NFT 1974 Oct 27 02:00 # Norfolk T. + 11:30 1:00 NFST 1975 Mar 2 02:00 + 11:30 - NFT 2015 Oct 4 02:00 + 11:00 - NFT # Palau (Belau) # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -1573,6 +1583,20 @@ # started DST on June 3. Possibly DST was observed other years # in Midway, but we have no record of it. +# Norfolk + +# From Alexander Krivenyshev (2015-09-23): +# Norfolk Island will change ... from +1130 to +1100: +# https://www.comlaw.gov.au/Details/F2015L01483/Explanatory%20Statement/Text +# ... at 12.30 am (by legal time in New South Wales) on 4 October 2015. +# http://www.norfolkisland.gov.nf/nia/MediaRelease/Media%20Release%20Norfolk%20Island%20Standard%20Time%20Change.pdf + +# From Paul Eggert (2015-09-23): +# Transitions before 2015 are from timeanddate.com, which consulted +# the Norfolk Island Museum and the Australian Bureau of Meteorology's +# Norfolk Island station, and found no record of Norfolk observing DST +# other than in 1974/5. See: +# http://www.timeanddate.com/time/australia/norfolk-island.html # Pitcairn
--- a/test/sun/util/calendar/zi/tzdata/europe Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/util/calendar/zi/tzdata/europe Thu Dec 03 13:27:36 2015 -0800 @@ -3173,6 +3173,11 @@ # http://www.balkaneu.com/eventful-elections-turkey/ 2014-03-30. # I guess the best we can do is document the official time. +# From Fatih (2015-09-29): +# It's officially announced now by the Ministry of Energy. +# Turkey delays winter time to 8th of November 04:00 +# http://www.aa.com.tr/tr/turkiye/yaz-saati-uygulamasi-8-kasimda-sona-erecek/362217 + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Turkey 1916 only - May 1 0:00 1:00 S Rule Turkey 1916 only - Oct 1 0:00 0 - @@ -3242,6 +3247,8 @@ 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 2015 Oct 25 1:00u + 2:00 1:00 EEST 2015 Nov 8 1:00u 2:00 EU EE%sT Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents.
--- a/test/sun/util/calendar/zi/tzdata/northamerica Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/util/calendar/zi/tzdata/northamerica Thu Dec 03 13:27:36 2015 -0800 @@ -1849,6 +1849,22 @@ # The transition dates (and times) are guesses. +# From Matt Johnson (2015-09-21): +# Fort Nelson, BC, Canada will cancel DST this year. So while previously they +# were aligned with America/Vancouver, they're now aligned with +# America/Dawson_Creek. +# http://www.northernrockies.ca/EN/meta/news/archives/2015/northern-rockies-time-change.html +# +# From Tim Parenti (2015-09-23): +# This requires a new zone for the Northern Rockies Regional Municipality, +# America/Fort_Nelson. The resolution of 2014-12-08 was reached following a +# 2014-11-15 poll with nearly 75% support. Effectively, the municipality has +# been on MST (-0700) like Dawson Creek since it advanced its clocks on +# 2015-03-08. +# +# From Paul Eggert (2015-09-23): +# Shanks says Fort Nelson did not observe DST in 1946, unlike Vancouver. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Vanc 1918 only - Apr 14 2:00 1:00 D Rule Vanc 1918 only - Oct 27 2:00 0 S @@ -1867,6 +1883,12 @@ -8:00 Canada P%sT 1947 -8:00 Vanc P%sT 1972 Aug 30 2:00 -7:00 - MST +Zone America/Fort_Nelson -8:10:47 - LMT 1884 + -8:00 Vanc P%sT 1946 + -8:00 - PST 1947 + -8:00 Vanc P%sT 1987 + -8:00 Canada P%sT 2015 Mar 8 2:00 + -7:00 - MST Zone America/Creston -7:46:04 - LMT 1884 -7:00 - MST 1916 Oct 1 -8:00 - PST 1918 Jun 2
--- a/test/sun/util/calendar/zi/tzdata/zone.tab Thu Dec 03 10:32:59 2015 -0800 +++ b/test/sun/util/calendar/zi/tzdata/zone.tab Thu Dec 03 13:27:36 2015 -0800 @@ -152,6 +152,7 @@ CA +682059-1334300 America/Inuvik Mountain Time - west Northwest Territories CA +4906-11631 America/Creston Mountain Standard Time - Creston, British Columbia CA +5946-12014 America/Dawson_Creek Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia +CA +5848-12242 America/Fort_Nelson Mountain Standard Time - Fort Nelson, British Columbia CA +4916-12307 America/Vancouver Pacific Time - west British Columbia CA +6043-13503 America/Whitehorse Pacific Time - south Yukon CA +6404-13925 America/Dawson Pacific Time - north Yukon
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/util/resources/TimeZone/Bug8139107.java Thu Dec 03 13:27:36 2015 -0800 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8139107 + * @summary Test that date parsing with DateTimeFormatter pattern + * that contains timezone field doesn't trigger NPE. All supported + * locales are tested. + * @run testng/othervm -Djava.locale.providers=JRE,SPI Bug8139107 + */ +import java.time.format.DateTimeFormatter; +import java.util.Locale; +import org.testng.annotations.Test; + +public class Bug8139107 { + + @Test + public void testSupportedLocales() { + for (Locale loc:Locale.getAvailableLocales()) { + testLocale(loc); + } + } + + //Test one locale + void testLocale(Locale tl) { + System.out.println("Locale:" + tl); + DateTimeFormatter inputDateTimeFormat = DateTimeFormatter + .ofPattern(pattern) + .withLocale(tl); + System.out.println("Parse result: " + inputDateTimeFormat.parse(inputDate)); + } + + // Input date time string with short time zone name + static final String inputDate = "06-10-2015 18:58:04 MSK"; + // Pattern with time zone field + static final String pattern = "dd-MM-yyyy HH:mm:ss z"; +} +