# HG changeset patch # User prr # Date 1513189538 28800 # Node ID 191ae61bd1e92d21f75fd7af601b19eeb3b686cf # Parent 093027a037cf5ea50d832eeaea03605d7bcee0fa# Parent a559b7cd1dea1c2ee8b3c3de5cb8b7c29b747858 Merge diff -r 093027a037cf -r 191ae61bd1e9 make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java --- a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java Wed Dec 13 13:27:45 2017 +0530 +++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java Wed Dec 13 10:25:38 2017 -0800 @@ -37,6 +37,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; +import java.util.stream.IntStream; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.SAXNotRecognizedException; @@ -52,21 +53,32 @@ static final String LDML_DTD_SYSTEM_ID = "http://www.unicode.org/cldr/dtd/2.0/ldml.dtd"; static final String SPPL_LDML_DTD_SYSTEM_ID = "http://www.unicode.org/cldr/dtd/2.0/ldmlSupplemental.dtd"; + static final String BCP47_LDML_DTD_SYSTEM_ID = "http://www.unicode.org/cldr/dtd/2.0/ldmlBCP47.dtd"; + private static String CLDR_BASE = "../CLDR/21.0.1/"; static String LOCAL_LDML_DTD; static String LOCAL_SPPL_LDML_DTD; + static String LOCAL_BCP47_LDML_DTD; private static String SOURCE_FILE_DIR; private static String SPPL_SOURCE_FILE; private static String NUMBERING_SOURCE_FILE; private static String METAZONES_SOURCE_FILE; private static String LIKELYSUBTAGS_SOURCE_FILE; + private static String TIMEZONE_SOURCE_FILE; static String DESTINATION_DIR = "build/gensrc"; static final String LOCALE_NAME_PREFIX = "locale.displayname."; + static final String LOCALE_SEPARATOR = LOCALE_NAME_PREFIX + "separator"; + static final String LOCALE_KEYTYPE = LOCALE_NAME_PREFIX + "keytype"; + static final String LOCALE_KEY_PREFIX = LOCALE_NAME_PREFIX + "key."; + static final String LOCALE_TYPE_PREFIX = LOCALE_NAME_PREFIX + "type."; + static final String LOCALE_TYPE_PREFIX_CA = LOCALE_TYPE_PREFIX + "ca."; static final String CURRENCY_SYMBOL_PREFIX = "currency.symbol."; static final String CURRENCY_NAME_PREFIX = "currency.displayname."; static final String CALENDAR_NAME_PREFIX = "calendarname."; + static final String CALENDAR_FIRSTDAY_PREFIX = "firstDay."; + static final String CALENDAR_MINDAYS_PREFIX = "minDays."; static final String TIMEZONE_ID_PREFIX = "timezone.id."; static final String ZONE_NAME_PREFIX = "timezone.displayname."; static final String METAZONE_ID_PREFIX = "metazone.id."; @@ -76,6 +88,7 @@ private static LikelySubtagsParseHandler handlerLikelySubtags; static NumberingSystemsParseHandler handlerNumbering; static MetaZonesParseHandler handlerMetaZones; + static TimeZoneParseHandler handlerTimeZone; private static BundleGenerator bundleGenerator; // java.base module related @@ -201,11 +214,13 @@ // Set up path names LOCAL_LDML_DTD = CLDR_BASE + "/dtd/ldml.dtd"; LOCAL_SPPL_LDML_DTD = CLDR_BASE + "/dtd/ldmlSupplemental.dtd"; + LOCAL_BCP47_LDML_DTD = CLDR_BASE + "/dtd/ldmlBCP47.dtd"; SOURCE_FILE_DIR = CLDR_BASE + "/main"; SPPL_SOURCE_FILE = CLDR_BASE + "/supplemental/supplementalData.xml"; LIKELYSUBTAGS_SOURCE_FILE = CLDR_BASE + "/supplemental/likelySubtags.xml"; NUMBERING_SOURCE_FILE = CLDR_BASE + "/supplemental/numberingSystems.xml"; METAZONES_SOURCE_FILE = CLDR_BASE + "/supplemental/metaZones.xml"; + TIMEZONE_SOURCE_FILE = CLDR_BASE + "/bcp47/timezone.xml"; if (BASE_LOCALES.isEmpty()) { setupBaseLocales("en-US"); @@ -215,10 +230,10 @@ // Parse data independent of locales parseSupplemental(); + parseBCP47(); List bundles = readBundleList(); convertBundles(bundles); - convertBundles(addedBundles); } private static void usage() { @@ -314,34 +329,19 @@ } private static final Map> cldrBundles = new HashMap<>(); - // this list will contain additional bundles to be generated for Region dependent Data. - private static List addedBundles = new ArrayList<>(); private static Map> metaInfo = new HashMap<>(); static { // For generating information on supported locales. - metaInfo.put("LocaleNames", new TreeSet<>()); - metaInfo.put("CurrencyNames", new TreeSet<>()); - metaInfo.put("TimeZoneNames", new TreeSet<>()); - metaInfo.put("CalendarData", new TreeSet<>()); - metaInfo.put("FormatData", new TreeSet<>()); metaInfo.put("AvailableLocales", new TreeSet<>()); } - - private static Set calendarDataFields = Set.of("firstDayOfWeek", "minimalDaysInFirstWeek"); - static Map getCLDRBundle(String id) throws Exception { Map bundle = cldrBundles.get(id); if (bundle != null) { return bundle; } - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setValidating(true); - SAXParser parser = factory.newSAXParser(); - enableFileAccess(parser); - LDMLParseHandler handler = new LDMLParseHandler(id); File file = new File(SOURCE_FILE_DIR + File.separator + id + ".xml"); if (!file.exists()) { // Skip if the file doesn't exist. @@ -349,14 +349,15 @@ } info("..... main directory ....."); - info("Reading file " + file); - parser.parse(file, handler); + LDMLParseHandler handler = new LDMLParseHandler(id); + parseLDMLFile(file, handler); bundle = handler.getData(); cldrBundles.put(id, bundle); - String country = getCountryCode(id); - if (country != null) { - bundle = handlerSuppl.getData(country); + + if (id.equals("root")) { + // Calendar data (firstDayOfWeek & minDaysInFirstWeek) + bundle = handlerSuppl.getData("root"); if (bundle != null) { //merge two maps into one map Map temp = cldrBundles.remove(id); @@ -379,98 +380,44 @@ // SupplementalData file also provides the "parent" locales which // are othrwise not to be fallen back. Process them here as well. // - info("..... Parsing supplementalData.xml ....."); - SAXParserFactory factorySuppl = SAXParserFactory.newInstance(); - factorySuppl.setValidating(true); - SAXParser parserSuppl = factorySuppl.newSAXParser(); - enableFileAccess(parserSuppl); handlerSuppl = new SupplementDataParseHandler(); - File fileSupply = new File(SPPL_SOURCE_FILE); - parserSuppl.parse(fileSupply, handlerSuppl); + parseLDMLFile(new File(SPPL_SOURCE_FILE), handlerSuppl); Map parentData = handlerSuppl.getData("root"); - parentData.keySet().forEach(key -> { + parentData.keySet().stream() + .filter(key -> key.startsWith(PARENT_LOCALE_PREFIX)) + .forEach(key -> { parentLocalesMap.put(key, new TreeSet( Arrays.asList(((String)parentData.get(key)).split(" ")))); }); // Parse numberingSystems to get digit zero character information. - SAXParserFactory numberingParser = SAXParserFactory.newInstance(); - numberingParser.setValidating(true); - SAXParser parserNumbering = numberingParser.newSAXParser(); - enableFileAccess(parserNumbering); handlerNumbering = new NumberingSystemsParseHandler(); - File fileNumbering = new File(NUMBERING_SOURCE_FILE); - parserNumbering.parse(fileNumbering, handlerNumbering); + parseLDMLFile(new File(NUMBERING_SOURCE_FILE), handlerNumbering); // Parse metaZones to create mappings between Olson tzids and CLDR meta zone names - info("..... Parsing metaZones.xml ....."); - SAXParserFactory metazonesParser = SAXParserFactory.newInstance(); - metazonesParser.setValidating(true); - SAXParser parserMetaZones = metazonesParser.newSAXParser(); - enableFileAccess(parserMetaZones); handlerMetaZones = new MetaZonesParseHandler(); - File fileMetaZones = new File(METAZONES_SOURCE_FILE); - parserMetaZones.parse(fileMetaZones, handlerMetaZones); + parseLDMLFile(new File(METAZONES_SOURCE_FILE), handlerMetaZones); // Parse likelySubtags - info("..... Parsing likelySubtags.xml ....."); - SAXParserFactory likelySubtagsParser = SAXParserFactory.newInstance(); - likelySubtagsParser.setValidating(true); - SAXParser parserLikelySubtags = likelySubtagsParser.newSAXParser(); - enableFileAccess(parserLikelySubtags); handlerLikelySubtags = new LikelySubtagsParseHandler(); - File fileLikelySubtags = new File(LIKELYSUBTAGS_SOURCE_FILE); - parserLikelySubtags.parse(fileLikelySubtags, handlerLikelySubtags); + parseLDMLFile(new File(LIKELYSUBTAGS_SOURCE_FILE), handlerLikelySubtags); } - /** - * This method will check if a new region dependent Bundle needs to be - * generated for this Locale id and targetMap. New Bundle will be generated - * when Locale id has non empty script and country code and targetMap - * contains region dependent data. This method will also remove region - * dependent data from this targetMap after candidate locales check. E.g. It - * will call genRegionDependentBundle() in case of az_Latn_AZ locale and - * remove region dependent data from this targetMap so that az_Latn_AZ - * bundle will not be created. For az_Cyrl_AZ, new Bundle will be generated - * but region dependent data will not be removed from targetMap as its candidate - * locales are [az_Cyrl_AZ, az_Cyrl, root], which does not include az_AZ for - * fallback. - * - */ + // Parsers for data in "bcp47" directory + // + private static void parseBCP47() throws Exception { + // Parse timezone + handlerTimeZone = new TimeZoneParseHandler(); + parseLDMLFile(new File(TIMEZONE_SOURCE_FILE), handlerTimeZone); + } - private static void checkRegionDependentBundle(Map targetMap, String id) { - if ((CLDRConverter.getScript(id) != "") - && (CLDRConverter.getCountryCode(id) != "")) { - Map regionDepDataMap = targetMap - .keySet() - .stream() - .filter(calendarDataFields::contains) - .collect(Collectors.toMap(k -> k, targetMap::get)); - if (!regionDepDataMap.isEmpty()) { - Locale cldrLoc = new Locale(CLDRConverter.getLanguageCode(id), - CLDRConverter.getCountryCode(id)); - genRegionDependentBundle(regionDepDataMap, cldrLoc); - if (checkCandidateLocales(id, cldrLoc)) { - // Remove matchedKeys from this targetMap only if checkCandidateLocales() returns true. - regionDepDataMap.keySet().forEach(targetMap::remove); - } - } - } - } - /** - * This method will generate a new Bundle for region dependent data, - * minimalDaysInFirstWeek and firstDayOfWeek. Newly generated Bundle will be added - * to addedBundles list. - */ - private static void genRegionDependentBundle(Map targetMap, Locale cldrLoc) { - String localeId = cldrLoc.toString(); - StringBuilder sb = getCandLocales(cldrLoc); - if (sb.indexOf(localeId) == -1) { - sb.append(localeId); - } - Bundle bundle = new Bundle(localeId, sb.toString(), null, null); - cldrBundles.put(localeId, targetMap); - addedBundles.add(bundle); + private static void parseLDMLFile(File srcfile, AbstractLDMLHandler handler) throws Exception { + info("..... Parsing " + srcfile.getName() + " ....."); + SAXParserFactory pf = SAXParserFactory.newInstance(); + pf.setValidating(true); + SAXParser parser = pf.newSAXParser(); + enableFileAccess(parser); + parser.parse(srcfile, handler); } private static StringBuilder getCandLocales(Locale cldrLoc) { @@ -491,16 +438,6 @@ return candList; } - /** - * This method will return true, if for a given locale, its language and - * country specific locale will exist in runtime lookup path. E.g. it will - * return true for bs_Latn_BA. - */ - private static boolean checkCandidateLocales(String id, Locale cldrLoc) { - return(getCandidateLocales(Locale.forLanguageTag(id.replaceAll("_", "-"))) - .contains(cldrLoc)); - } - private static void convertBundles(List bundles) throws Exception { // parent locales map. The mappings are put in base metaInfo file // for now. @@ -514,8 +451,6 @@ Map targetMap = bundle.getTargetMap(); - // check if new region DependentBundle needs to be generated for this Locale. - checkRegionDependentBundle(targetMap, bundle.getID()); EnumSet bundleTypes = bundle.getBundleTypes(); if (bundle.isRoot()) { @@ -528,40 +463,30 @@ if (bundleTypes.contains(Bundle.Type.LOCALENAMES)) { Map localeNamesMap = extractLocaleNames(targetMap, bundle.getID()); if (!localeNamesMap.isEmpty() || bundle.isRoot()) { - metaInfo.get("LocaleNames").add(toLanguageTag(bundle.getID())); - addLikelySubtags(metaInfo, "LocaleNames", bundle.getID()); bundleGenerator.generateBundle("util", "LocaleNames", bundle.getJavaID(), true, localeNamesMap, BundleType.OPEN); } } if (bundleTypes.contains(Bundle.Type.CURRENCYNAMES)) { Map currencyNamesMap = extractCurrencyNames(targetMap, bundle.getID(), bundle.getCurrencies()); if (!currencyNamesMap.isEmpty() || bundle.isRoot()) { - metaInfo.get("CurrencyNames").add(toLanguageTag(bundle.getID())); - addLikelySubtags(metaInfo, "CurrencyNames", bundle.getID()); bundleGenerator.generateBundle("util", "CurrencyNames", bundle.getJavaID(), true, currencyNamesMap, BundleType.OPEN); } } if (bundleTypes.contains(Bundle.Type.TIMEZONENAMES)) { Map zoneNamesMap = extractZoneNames(targetMap, bundle.getID()); if (!zoneNamesMap.isEmpty() || bundle.isRoot()) { - metaInfo.get("TimeZoneNames").add(toLanguageTag(bundle.getID())); - addLikelySubtags(metaInfo, "TimeZoneNames", bundle.getID()); bundleGenerator.generateBundle("util", "TimeZoneNames", bundle.getJavaID(), true, zoneNamesMap, BundleType.TIMEZONE); } } if (bundleTypes.contains(Bundle.Type.CALENDARDATA)) { Map calendarDataMap = extractCalendarData(targetMap, bundle.getID()); if (!calendarDataMap.isEmpty() || bundle.isRoot()) { - metaInfo.get("CalendarData").add(toLanguageTag(bundle.getID())); - addLikelySubtags(metaInfo, "CalendarData", bundle.getID()); bundleGenerator.generateBundle("util", "CalendarData", bundle.getJavaID(), true, calendarDataMap, BundleType.PLAIN); } } if (bundleTypes.contains(Bundle.Type.FORMATDATA)) { Map formatDataMap = extractFormatData(targetMap, bundle.getID()); if (!formatDataMap.isEmpty() || bundle.isRoot()) { - metaInfo.get("FormatData").add(toLanguageTag(bundle.getID())); - addLikelySubtags(metaInfo, "FormatData", bundle.getID()); bundleGenerator.generateBundle("text", "FormatData", bundle.getJavaID(), true, formatDataMap, BundleType.PLAIN); } } @@ -570,43 +495,9 @@ metaInfo.get("AvailableLocales").add(toLanguageTag(bundle.getID())); addLikelySubtags(metaInfo, "AvailableLocales", bundle.getID()); } - addCldrImplicitLocales(metaInfo); bundleGenerator.generateMetaInfo(metaInfo); } - /** - * These are the Locales that are implicitly supported by CLDR. - * Adding them explicitly as likelySubtags here, will ensure that - * COMPAT locales do not precede them during ResourceBundle search path. - */ - private static void addCldrImplicitLocales(Map> metaInfo) { - metaInfo.get("LocaleNames").add("zh-Hans-CN"); - metaInfo.get("LocaleNames").add("zh-Hans-SG"); - metaInfo.get("LocaleNames").add("zh-Hant-HK"); - metaInfo.get("LocaleNames").add("zh-Hant-MO"); - metaInfo.get("LocaleNames").add("zh-Hant-TW"); - metaInfo.get("CurrencyNames").add("zh-Hans-CN"); - metaInfo.get("CurrencyNames").add("zh-Hans-SG"); - metaInfo.get("CurrencyNames").add("zh-Hant-HK"); - metaInfo.get("CurrencyNames").add("zh-Hant-MO"); - metaInfo.get("CurrencyNames").add("zh-Hant-TW"); - metaInfo.get("TimeZoneNames").add("zh-Hans-CN"); - metaInfo.get("TimeZoneNames").add("zh-Hans-SG"); - metaInfo.get("TimeZoneNames").add("zh-Hant-HK"); - metaInfo.get("TimeZoneNames").add("zh-Hant-MO"); - metaInfo.get("TimeZoneNames").add("zh-Hant-TW"); - metaInfo.get("TimeZoneNames").add("zh-HK"); - metaInfo.get("CalendarData").add("zh-Hans-CN"); - metaInfo.get("CalendarData").add("zh-Hans-SG"); - metaInfo.get("CalendarData").add("zh-Hant-HK"); - metaInfo.get("CalendarData").add("zh-Hant-MO"); - metaInfo.get("CalendarData").add("zh-Hant-TW"); - metaInfo.get("FormatData").add("zh-Hans-CN"); - metaInfo.get("FormatData").add("zh-Hans-SG"); - metaInfo.get("FormatData").add("zh-Hant-HK"); - metaInfo.get("FormatData").add("zh-Hant-MO"); - metaInfo.get("FormatData").add("zh-Hant-TW"); - } static final Map aliases = new HashMap<>(); /** @@ -656,14 +547,6 @@ return Locale.forLanguageTag(id.replaceAll("_", "-")).getCountry(); } - /* - * Returns the script portion of the given id. - * If id is "root", "" is returned. - */ - static String getScript(String id) { - return "root".equals(id) ? "" : Locale.forLanguageTag(id.replaceAll("_", "-")).getScript(); - } - private static class KeyComparator implements Comparator { static KeyComparator INSTANCE = new KeyComparator(); @@ -695,9 +578,25 @@ Map localeNames = new TreeMap<>(KeyComparator.INSTANCE); for (String key : map.keySet()) { if (key.startsWith(LOCALE_NAME_PREFIX)) { - localeNames.put(key.substring(LOCALE_NAME_PREFIX.length()), map.get(key)); + switch (key) { + case LOCALE_SEPARATOR: + localeNames.put("ListCompositionPattern", map.get(key)); + break; + case LOCALE_KEYTYPE: + localeNames.put("ListKeyTypePattern", map.get(key)); + break; + default: + localeNames.put(key.substring(LOCALE_NAME_PREFIX.length()), map.get(key)); + break; + } } } + + if (id.equals("root")) { + // Add display name pattern, which is not in CLDR + localeNames.put("DisplayNamePattern", "{0,choice,0#|1#{1}|2#{1} ({2})}"); + } + return localeNames; } @@ -778,10 +677,30 @@ return names; } + /** + * Extracts the language independent calendar data. Each of the two keys, + * "firstDayOfWeek" and "minimalDaysInFirstWeek" has a string value consists of + * one or multiple occurrences of: + * i: rg1 rg2 ... rgn; + * where "i" is the data for the following regions (delimited by a space) after + * ":", and ends with a ";". + */ private static Map extractCalendarData(Map map, String id) { Map calendarData = new LinkedHashMap<>(); - copyIfPresent(map, "firstDayOfWeek", calendarData); - copyIfPresent(map, "minimalDaysInFirstWeek", calendarData); + if (id.equals("root")) { + calendarData.put("firstDayOfWeek", + IntStream.range(1, 8) + .mapToObj(String::valueOf) + .filter(d -> map.keySet().contains(CALENDAR_FIRSTDAY_PREFIX + d)) + .map(d -> d + ": " + map.get(CALENDAR_FIRSTDAY_PREFIX + d)) + .collect(Collectors.joining(";"))); + calendarData.put("minimalDaysInFirstWeek", + IntStream.range(0, 7) + .mapToObj(String::valueOf) + .filter(d -> map.keySet().contains(CALENDAR_MINDAYS_PREFIX + d)) + .map(d -> d + ": " + map.get(CALENDAR_MINDAYS_PREFIX + d)) + .collect(Collectors.joining(";"))); + } return calendarData; } @@ -844,17 +763,19 @@ for (String key : map.keySet()) { // Copy available calendar names - if (key.startsWith(CLDRConverter.CALENDAR_NAME_PREFIX)) { - String type = key.substring(CLDRConverter.CALENDAR_NAME_PREFIX.length()); + if (key.startsWith(CLDRConverter.LOCALE_TYPE_PREFIX_CA)) { + String type = key.substring(CLDRConverter.LOCALE_TYPE_PREFIX_CA.length()); for (CalendarType calendarType : CalendarType.values()) { if (calendarType == CalendarType.GENERIC) { continue; } if (type.equals(calendarType.lname())) { Object value = map.get(key); - formatData.put(key, value); - String ukey = CLDRConverter.CALENDAR_NAME_PREFIX + calendarType.uname(); - if (!key.equals(ukey)) { + String dataKey = key.replace(LOCALE_TYPE_PREFIX_CA, + CALENDAR_NAME_PREFIX); + formatData.put(dataKey, value); + String ukey = CALENDAR_NAME_PREFIX + calendarType.uname(); + if (!dataKey.equals(ukey)) { formatData.put(ukey, value); } } @@ -874,6 +795,18 @@ copyIfPresent(map, "NumberElements", formatData); } copyIfPresent(map, "NumberPatterns", formatData); + + // put extra number elements for available scripts into formatData, if it is "root" + if (id.equals("root")) { + handlerNumbering.keySet().stream() + .filter(k -> !numberingScripts.contains(k)) + .forEach(k -> { + String[] ne = (String[])map.get("latn.NumberElements"); + String[] neNew = Arrays.copyOf(ne, ne.length); + neNew[4] = handlerNumbering.get(k).substring(0, 1); + formatData.put(k + ".NumberElements", neNew); + }); + } return formatData; } diff -r 093027a037cf -r 191ae61bd1e9 make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java --- a/make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java Wed Dec 13 13:27:45 2017 +0530 +++ b/make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java Wed Dec 13 10:25:38 2017 -0800 @@ -76,12 +76,16 @@ // ignore this element - it has language and territory elements that aren't locale data pushIgnoredContainer(qName); break; - case "type": - if ("calendar".equals(attributes.getValue("key"))) { - pushStringEntry(qName, attributes, CLDRConverter.CALENDAR_NAME_PREFIX + attributes.getValue("type")); - } else { - pushIgnoredContainer(qName); - } + + // for LocaleNames + // copy string + case "localeSeparator": + pushStringEntry(qName, attributes, + CLDRConverter.LOCALE_SEPARATOR); + break; + case "localeKeyTypePattern": + pushStringEntry(qName, attributes, + CLDRConverter.LOCALE_KEYTYPE); break; case "language": @@ -96,6 +100,24 @@ attributes.getValue("type")); break; + case "key": + // for LocaleNames + // copy string + pushStringEntry(qName, attributes, + CLDRConverter.LOCALE_KEY_PREFIX + + convertOldKeyName(attributes.getValue("type"))); + break; + + case "type": + // for LocaleNames/CalendarNames + // copy string + pushStringEntry(qName, attributes, + CLDRConverter.LOCALE_TYPE_PREFIX + + convertOldKeyName(attributes.getValue("key")) + "." + + attributes.getValue("type")); + + break; + // // Currency information // @@ -515,26 +537,10 @@ currentNumberingSystem = script + "."; String digits = CLDRConverter.handlerNumbering.get(script); if (digits == null) { - throw new InternalError("null digits for " + script); - } - if (Character.isSurrogate(digits.charAt(0))) { - // DecimalFormatSymbols doesn't support supplementary characters as digit zero. pushIgnoredContainer(qName); break; } - // in case digits are in the reversed order, reverse back the order. - if (digits.charAt(0) > digits.charAt(digits.length() - 1)) { - StringBuilder sb = new StringBuilder(digits); - digits = sb.reverse().toString(); - } - // Check if the order is sequential. - char c0 = digits.charAt(0); - for (int i = 1; i < digits.length(); i++) { - if (digits.charAt(i) != c0 + i) { - pushIgnoredContainer(qName); - break symbols; - } - } + @SuppressWarnings("unchecked") List numberingScripts = (List) get("numberingScripts"); if (numberingScripts == null) { @@ -924,17 +930,35 @@ } } } else if (currentContainer instanceof Entry) { - Entry entry = (Entry) currentContainer; - Object value = entry.getValue(); - if (value != null) { - String key = entry.getKey(); - // Tweak for MonthNames for the root locale, Needed for - // SimpleDateFormat.format()/parse() roundtrip. - if (id.equals("root") && key.startsWith("MonthNames")) { - value = new DateFormatSymbols(Locale.US).getShortMonths(); - } - put(entry.getKey(), value); + Entry entry = (Entry) currentContainer; + Object value = entry.getValue(); + if (value != null) { + String key = entry.getKey(); + // Tweak for MonthNames for the root locale, Needed for + // SimpleDateFormat.format()/parse() roundtrip. + if (id.equals("root") && key.startsWith("MonthNames")) { + value = new DateFormatSymbols(Locale.US).getShortMonths(); } + put(entry.getKey(), value); } } } + + public String convertOldKeyName(String key) { + // Explicitly obtained from "alias" attribute in each "key" element. + switch (key) { + case "calendar": + return "ca"; + case "currency": + return "cu"; + case "collation": + return "co"; + case "numbers": + return "nu"; + case "timezone": + return "tz"; + default: + return key; + } + } +} diff -r 093027a037cf -r 191ae61bd1e9 make/jdk/src/classes/build/tools/cldrconverter/NumberingSystemsParseHandler.java --- a/make/jdk/src/classes/build/tools/cldrconverter/NumberingSystemsParseHandler.java Wed Dec 13 13:27:45 2017 +0530 +++ b/make/jdk/src/classes/build/tools/cldrconverter/NumberingSystemsParseHandler.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -54,9 +54,32 @@ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { switch (qName) { case "numberingSystem": - if ("numeric".equals(attributes.getValue("type"))) { - // eg, - put(attributes.getValue("id"), attributes.getValue("digits")); + numberingSystem: { + if ("numeric".equals(attributes.getValue("type"))) { + // eg, + String script = attributes.getValue("id"); + String digits = attributes.getValue("digits"); + + if (Character.isSurrogate(digits.charAt(0))) { + // DecimalFormatSymbols doesn't support supplementary characters as digit zero. + break numberingSystem; + } + // in case digits are in the reversed order, reverse back the order. + if (digits.charAt(0) > digits.charAt(digits.length() - 1)) { + StringBuilder sb = new StringBuilder(digits); + digits = sb.reverse().toString(); + } + // Check if the order is sequential. + char c0 = digits.charAt(0); + for (int i = 1; i < digits.length(); i++) { + if (digits.charAt(i) != c0 + i) { + break numberingSystem; + } + } + + // script/digits are acceptable. + put(script, digits); + } } pushIgnoredContainer(qName); break; diff -r 093027a037cf -r 191ae61bd1e9 make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java --- a/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java Wed Dec 13 13:27:45 2017 +0530 +++ b/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -256,20 +256,21 @@ CLDRConverter.info("Generating file " + file); try (PrintWriter out = new PrintWriter(file, "us-ascii")) { - out.println(CopyrightHeaders.getOpenJDKCopyright()); + out.printf(CopyrightHeaders.getOpenJDKCopyright()); - out.println((CLDRConverter.isBaseModule ? "package sun.util.cldr;\n\n" : + out.printf((CLDRConverter.isBaseModule ? "package sun.util.cldr;\n\n" : "package sun.util.resources.cldr.provider;\n\n") + "import java.util.HashMap;\n" + "import java.util.Locale;\n" + "import java.util.Map;\n" - + "import sun.util.locale.provider.LocaleProviderAdapter;\n" - + "import sun.util.locale.provider.LocaleDataMetaInfo;\n"); + + "import sun.util.locale.provider.LocaleDataMetaInfo;\n" + + "import sun.util.locale.provider.LocaleProviderAdapter;\n\n"); out.printf("public class %s implements LocaleDataMetaInfo {\n", className); - out.println(" private static final Map resourceNameToLocales = new HashMap<>();\n" + - (CLDRConverter.isBaseModule ? - " private static final Map parentLocalesMap = new HashMap<>();\n\n" : "\n") + - " static {\n"); + out.printf(" private static final Map resourceNameToLocales = new HashMap<>();\n" + + (CLDRConverter.isBaseModule ? + " private static final Map parentLocalesMap = new HashMap<>();\n\n" : + "\n") + + " static {\n"); for (String key : metaInfo.keySet()) { if (key.startsWith(CLDRConverter.PARENT_LOCALE_PREFIX)) { @@ -296,30 +297,50 @@ } out.printf("\n });\n"); } else { - out.printf(" resourceNameToLocales.put(\"%s\",\n", key); - out.printf(" \"%s\");\n", - toLocaleList(key.equals("FormatData") ? metaInfo.get("AvailableLocales") : - metaInfo.get(key), false)); + if ("AvailableLocales".equals(key)) { + out.printf(" resourceNameToLocales.put(\"%s\",\n", key); + out.printf(" \"%s\");\n", toLocaleList(metaInfo.get(key), false)); + } } } - out.println(" }\n\n"); + + out.printf(" }\n\n"); + + // end of static initializer block. - out.println(" @Override\n" + + // Short TZ names for delayed initialization + if (CLDRConverter.isBaseModule) { + out.printf(" private static class TZShortIDMapHolder {\n"); + out.printf(" static final Map tzShortIDMap = new HashMap<>();\n"); + out.printf(" static {\n"); + CLDRConverter.handlerTimeZone.getData().entrySet().stream() + .forEach(e -> { + out.printf(" tzShortIDMap.put(\"%s\", \"%s\");\n", e.getKey(), + ((String)e.getValue())); + }); + out.printf(" }\n }\n\n"); + } + + out.printf(" @Override\n" + " public LocaleProviderAdapter.Type getType() {\n" + " return LocaleProviderAdapter.Type.CLDR;\n" + " }\n\n"); - out.println(" @Override\n" + + out.printf(" @Override\n" + " public String availableLanguageTags(String category) {\n" + " return resourceNameToLocales.getOrDefault(category, \"\");\n" + " }\n\n"); if (CLDRConverter.isBaseModule) { + out.printf(" @Override\n" + + " public Map tzShortIDs() {\n" + + " return TZShortIDMapHolder.tzShortIDMap;\n" + + " }\n\n"); out.printf(" public Map parentLocales() {\n" + " return parentLocalesMap;\n" + " }\n}"); } else { - out.println("}"); + out.printf("}"); } } } diff -r 093027a037cf -r 191ae61bd1e9 make/jdk/src/classes/build/tools/cldrconverter/SupplementDataParseHandler.java --- a/make/jdk/src/classes/build/tools/cldrconverter/SupplementDataParseHandler.java Wed Dec 13 13:27:45 2017 +0530 +++ b/make/jdk/src/classes/build/tools/cldrconverter/SupplementDataParseHandler.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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,53 +84,18 @@ values.put(CLDRConverter.PARENT_LOCALE_PREFIX+key, parentLocalesMap.get(key)); }); - } else { - String countryData = getWeekData(id, JAVA_FIRSTDAY, firstDayMap); - if (countryData != null) { - values.put(JAVA_FIRSTDAY, countryData); - } - String minDaysData = getWeekData(id, JAVA_MINDAY, minDaysMap); - if (minDaysData != null) { - values.put(JAVA_MINDAY, minDaysData); - } + firstDayMap.keySet().forEach(key -> { + values.put(CLDRConverter.CALENDAR_FIRSTDAY_PREFIX+firstDayMap.get(key), + key); + }); + minDaysMap.keySet().forEach(key -> { + values.put(CLDRConverter.CALENDAR_MINDAYS_PREFIX+minDaysMap.get(key), + key); + }); } return values.isEmpty() ? null : values; } - /** - * It returns either firstDay or minDays in the JRE format for the country. - * - * @param country territory code of the requested data - * @param jreDataName JAVA_FIRSTDAY or JAVA_MINDAY - * @param dataMap firstDayMap or minDaysMap - * @return the value for the given jreDataName, or null if requested value - * (firstDay/minDays) is not available although that is highly unlikely - * because of the default value for the world (001). - */ - String getWeekData(String country, final String jreDataName, final Map dataMap) { - String countryValue = null; - String defaultWorldValue = null; - for (String key : dataMap.keySet()) { - if (key.contains(country)) { - if (jreDataName.equals(JAVA_FIRSTDAY)) { - countryValue = DAY_OF_WEEK_MAP.get((String) dataMap.get(key)); - } else if (jreDataName.equals(JAVA_MINDAY)) { - countryValue = (String) dataMap.get(key); - } - if (countryValue != null) { - return countryValue; - } - } else if (key.contains(WORLD)) { - if (jreDataName.equals(JAVA_FIRSTDAY)) { - defaultWorldValue = DAY_OF_WEEK_MAP.get((String) dataMap.get(key)); - } else if (jreDataName.equals(JAVA_MINDAY)) { - defaultWorldValue = (String) dataMap.get(key); - } - } - } - return defaultWorldValue; - } - @Override public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException { // avoid HTTP traffic to unicode.org @@ -152,7 +117,33 @@ switch (qName) { case "firstDay": if (!isIgnored(attributes)) { - firstDayMap.put(attributes.getValue("territories"), attributes.getValue("day")); + String fd; + + switch (attributes.getValue("day")) { + case "sun": + fd = "1"; + break; + default: + case "mon": + fd = "2"; + break; + case "tue": + fd = "3"; + break; + case "wed": + fd = "4"; + break; + case "thu": + fd = "5"; + break; + case "fri": + fd = "6"; + break; + case "sat": + fd = "7"; + break; + } + firstDayMap.put(attributes.getValue("territories"), fd); } break; case "minDays": diff -r 093027a037cf -r 191ae61bd1e9 make/jdk/src/classes/build/tools/cldrconverter/TimeZoneParseHandler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/jdk/src/classes/build/tools/cldrconverter/TimeZoneParseHandler.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2017, 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 build.tools.cldrconverter; + +import java.io.File; +import java.io.IOException; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * Handles parsing of timezone.xml and produces a map from short timezone IDs to + * tz database IDs. + */ + +class TimeZoneParseHandler extends AbstractLDMLHandler { + + @Override + public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException { + // avoid HTTP traffic to unicode.org + if (systemID.startsWith(CLDRConverter.BCP47_LDML_DTD_SYSTEM_ID)) { + return new InputSource((new File(CLDRConverter.LOCAL_BCP47_LDML_DTD)).toURI().toString()); + } + return null; + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + switch (qName) { + case "type": + if (!isIgnored(attributes) && !attributes.getValue("deprecated").equals("true")) { + put(attributes.getValue("name"), attributes.getValue("alias")); + } + break; + default: + // treat anything else as a container + pushContainer(qName, attributes); + break; + } + } +} diff -r 093027a037cf -r 191ae61bd1e9 make/nashorn/build.xml --- a/make/nashorn/build.xml Wed Dec 13 13:27:45 2017 +0530 +++ b/make/nashorn/build.xml Wed Dec 13 10:25:38 2017 -0800 @@ -265,7 +265,7 @@ - + diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/io/ByteArrayOutputStream.java --- a/src/java.base/share/classes/java/io/ByteArrayOutputStream.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/io/ByteArrayOutputStream.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package java.io; +import java.nio.charset.Charset; import java.util.Arrays; /** @@ -223,14 +224,27 @@ /** * Converts the buffer's contents into a string by decoding the bytes using - * the named {@link java.nio.charset.Charset charset}. The length of the new - * {@code String} is a function of the charset, and hence may not be equal - * to the length of the byte array. + * the named {@link java.nio.charset.Charset charset}. + * + *

This method is equivalent to {@code #toString(charset)} that takes a + * {@link java.nio.charset.Charset charset}. + * + *

An invocation of this method of the form * - *

This method always replaces malformed-input and unmappable-character - * sequences with this charset's default replacement string. The {@link - * java.nio.charset.CharsetDecoder} class should be used when more control - * over the decoding process is required. + *

 {@code
+     *      ByteArrayOutputStream b = ...
+     *      b.toString("UTF-8")
+     *      }
+     * 
+ * + * behaves in exactly the same way as the expression + * + *
 {@code
+     *      ByteArrayOutputStream b = ...
+     *      b.toString(StandardCharsets.UTF_8)
+     *      }
+     * 
+ * * * @param charsetName the name of a supported * {@link java.nio.charset.Charset charset} @@ -246,6 +260,26 @@ } /** + * Converts the buffer's contents into a string by decoding the bytes using + * the specified {@link java.nio.charset.Charset charset}. The length of the new + * {@code String} is a function of the charset, and hence may not be equal + * to the length of the byte array. + * + *

This method always replaces malformed-input and unmappable-character + * sequences with the charset's default replacement string. The {@link + * java.nio.charset.CharsetDecoder} class should be used when more control + * over the decoding process is required. + * + * @param charset the {@linkplain java.nio.charset.Charset charset} + * to be used to decode the {@code bytes} + * @return String decoded from the buffer's contents. + * @since 10 + */ + public synchronized String toString(Charset charset) { + return new String(buf, 0, count, charset); + } + + /** * Creates a newly allocated string. Its size is the current size of * the output stream and the valid contents of the buffer have been * copied into it. Each character c in the resulting string is @@ -257,9 +291,10 @@ * * @deprecated This method does not properly convert bytes into characters. * As of JDK 1.1, the preferred way to do this is via the - * {@code toString(String enc)} method, which takes an encoding-name - * argument, or the {@code toString()} method, which uses the - * platform's default character encoding. + * {@link #toString(String charsetName)} or {@link #toString(Charset charset)} + * method, which takes an encoding-name or charset argument, + * or the {@code toString()} method, which uses the platform's default + * character encoding. * * @param hibyte the high byte of each resulting Unicode character. * @return the current contents of the output stream, as a string. diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/io/PrintStream.java --- a/src/java.base/share/classes/java/io/PrintStream.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/io/PrintStream.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2017, 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,10 +45,16 @@ * ({@code '\n'}) is written. * *

All characters printed by a {@code PrintStream} are converted into - * bytes using the platform's default character encoding. + * bytes using the given encoding or charset, or platform's default character + * encoding if not specified. * The {@link PrintWriter} class should be used in situations that require * writing characters rather than bytes. * + *

This class always replaces malformed and unmappable character sequences with + * the charset's default replacement string. + * The {@linkplain java.nio.charset.CharsetEncoder} class should be used when more + * control over the encoding process is required. + * * @author Frank Yellin * @author Mark Reinhold * @since 1.0 @@ -105,22 +111,13 @@ this.textOut = new BufferedWriter(charOut); } - private PrintStream(boolean autoFlush, OutputStream out, Charset charset) { - super(out); - this.autoFlush = autoFlush; - this.charOut = new OutputStreamWriter(this, charset); - this.textOut = new BufferedWriter(charOut); - } - /* Variant of the private constructor so that the given charset name * can be verified before evaluating the OutputStream argument. Used * by constructors creating a FileOutputStream that also take a * charset name. */ - private PrintStream(boolean autoFlush, Charset charset, OutputStream out) - throws UnsupportedEncodingException - { - this(autoFlush, out, charset); + private PrintStream(boolean autoFlush, Charset charset, OutputStream out) { + this(out, autoFlush, charset); } /** @@ -172,9 +169,30 @@ public PrintStream(OutputStream out, boolean autoFlush, String encoding) throws UnsupportedEncodingException { - this(autoFlush, - requireNonNull(out, "Null output stream"), - toCharset(encoding)); + this(requireNonNull(out, "Null output stream"), autoFlush, toCharset(encoding)); + } + + /** + * Creates a new print stream, with the specified OutputStream, automatic line + * flushing and charset. This convenience constructor creates the necessary + * intermediate {@link java.io.OutputStreamWriter OutputStreamWriter}, + * which will encode characters using the provided charset. + * + * @param out The output stream to which values and objects will be + * printed + * @param autoFlush A boolean; if true, the output buffer will be flushed + * whenever a byte array is written, one of the + * {@code println} methods is invoked, or a newline + * character or byte ({@code '\n'}) is written + * @param charset A {@linkplain java.nio.charset.Charset charset} + * + * @since 10 + */ + public PrintStream(OutputStream out, boolean autoFlush, Charset charset) { + super(out); + this.autoFlush = autoFlush; + this.charOut = new OutputStreamWriter(this, charset); + this.textOut = new BufferedWriter(charOut); } /** @@ -250,6 +268,36 @@ /** * Creates a new print stream, without automatic line flushing, with the + * specified file name and charset. This convenience constructor creates + * the necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the provided + * charset. + * + * @param fileName + * The name of the file to use as the destination of this print + * stream. If the file exists, then it will be truncated to + * zero size; otherwise, a new file will be created. The output + * will be written to the file and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(fileName)} denies write + * access to the file + * + * @since 10 + */ + public PrintStream(String fileName, Charset charset) throws IOException { + this(false, requireNonNull(charset, "charset"), new FileOutputStream(fileName)); + } + + /** + * Creates a new print stream, without automatic line flushing, with the * specified file. This convenience constructor creates the necessary * intermediate {@link java.io.OutputStreamWriter OutputStreamWriter}, * which will encode characters using the {@linkplain @@ -319,6 +367,37 @@ this(false, toCharset(csn), new FileOutputStream(file)); } + + /** + * Creates a new print stream, without automatic line flushing, with the + * specified file and charset. This convenience constructor creates + * the necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the provided + * charset. + * + * @param file + * The file to use as the destination of this print stream. If the + * file exists, then it will be truncated to zero size; otherwise, + * a new file will be created. The output will be written to the + * file and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(file.getPath())} + * denies write access to the file + * + * @since 10 + */ + public PrintStream(File file, Charset charset) throws IOException { + this(false, requireNonNull(charset, "charset"), new FileOutputStream(file)); + } + /** Check to make sure that the stream has not been closed */ private void ensureOpen() throws IOException { if (out == null) diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/io/PrintWriter.java --- a/src/java.base/share/classes/java/io/PrintWriter.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/io/PrintWriter.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2017, 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 @@ -48,6 +48,11 @@ * constructors may. The client may inquire as to whether any errors have * occurred by invoking {@link #checkError checkError()}. * + *

This class always replaces malformed and unmappable character sequences with + * the charset's default replacement string. + * The {@linkplain java.nio.charset.CharsetEncoder} class should be used when more + * control over the encoding process is required. + * * @author Frank Yellin * @author Mark Reinhold * @since 1.1 @@ -137,7 +142,26 @@ * @see java.io.OutputStreamWriter#OutputStreamWriter(java.io.OutputStream) */ public PrintWriter(OutputStream out, boolean autoFlush) { - this(new BufferedWriter(new OutputStreamWriter(out)), autoFlush); + this(out, autoFlush, Charset.defaultCharset()); + } + + /** + * Creates a new PrintWriter from an existing OutputStream. This + * convenience constructor creates the necessary intermediate + * OutputStreamWriter, which will convert characters into bytes using the + * specified charset. + * + * @param out An output stream + * @param autoFlush A boolean; if true, the {@code println}, + * {@code printf}, or {@code format} methods will + * flush the output buffer + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @since 10 + */ + public PrintWriter(OutputStream out, boolean autoFlush, Charset charset) { + this(new BufferedWriter(new OutputStreamWriter(out, charset)), autoFlush); // save print stream for error propagation if (out instanceof java.io.PrintStream) { @@ -226,6 +250,36 @@ /** * Creates a new PrintWriter, without automatic line flushing, with the + * specified file name and charset. This convenience constructor creates + * the necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the provided + * charset. + * + * @param fileName + * The name of the file to use as the destination of this writer. + * If the file exists then it will be truncated to zero size; + * otherwise, a new file will be created. The output will be + * written to the file and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(fileName)} denies write + * access to the file + * + * @since 10 + */ + public PrintWriter(String fileName, Charset charset) throws IOException { + this(Objects.requireNonNull(charset, "charset"), new File(fileName)); + } + + /** + * Creates a new PrintWriter, without automatic line flushing, with the * specified file. This convenience constructor creates the necessary * intermediate {@link java.io.OutputStreamWriter OutputStreamWriter}, * which will encode characters using the {@linkplain @@ -295,6 +349,36 @@ this(toCharset(csn), file); } + /** + * Creates a new PrintWriter, without automatic line flushing, with the + * specified file and charset. This convenience constructor creates the + * necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the provided + * charset. + * + * @param file + * The file to use as the destination of this writer. If the file + * exists then it will be truncated to zero size; otherwise, a new + * file will be created. The output will be written to the file + * and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(file.getPath())} + * denies write access to the file + * + * @since 10 + */ + public PrintWriter(File file, Charset charset) throws IOException { + this(Objects.requireNonNull(charset, "charset"), file); + } + /** Checks to make sure that the stream has not been closed */ private void ensureOpen() throws IOException { if (out == null) diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/lang/String.java --- a/src/java.base/share/classes/java/lang/String.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/lang/String.java Wed Dec 13 10:25:38 2017 -0800 @@ -3046,6 +3046,10 @@ return COMPACT_STRINGS ? coder : UTF16; } + byte[] value() { + return value; + } + private boolean isLatin1() { return COMPACT_STRINGS && coder == LATIN1; } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/lang/StringCoding.java --- a/src/java.base/share/classes/java/lang/StringCoding.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/lang/StringCoding.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,11 @@ import static java.lang.String.LATIN1; import static java.lang.String.UTF16; import static java.lang.String.COMPACT_STRINGS; +import static java.lang.Character.isSurrogate; +import static java.lang.Character.highSurrogate; +import static java.lang.Character.lowSurrogate; +import static java.lang.Character.isSupplementaryCodePoint; +import static java.lang.StringUTF16.putChar; /** * Utility class for string encoding and decoding. @@ -66,8 +71,6 @@ private static final Charset US_ASCII = sun.nio.cs.US_ASCII.INSTANCE; private static final Charset UTF_8 = sun.nio.cs.UTF_8.INSTANCE; - private static boolean warnUnsupportedCharset = true; - private static T deref(ThreadLocal> tl) { SoftReference sr = tl.get(); if (sr == null) @@ -80,7 +83,6 @@ } // Trim the given byte array to the given length - // private static byte[] safeTrim(byte[] ba, int len, boolean isTrusted) { if (len == ba.length && (isTrusted || System.getSecurityManager() == null)) return ba; @@ -105,17 +107,6 @@ return null; } - private static void warnUnsupportedCharset(String csn) { - if (warnUnsupportedCharset) { - // Use err(String) rather than the Logging API or System.err - // since this method may be called during VM initialization - // before either is available. - err("WARNING: Default charset " + csn + - " not supported, using ISO-8859-1 instead\n"); - warnUnsupportedCharset = false; - } - } - static class Result { byte[] value; byte coder; @@ -224,19 +215,6 @@ } } - private static class StringDecoder8859_1 extends StringDecoder { - StringDecoder8859_1(Charset cs, String rcn) { - super(cs, rcn); - } - Result decode(byte[] ba, int off, int len) { - if (COMPACT_STRINGS) { - return result.with(Arrays.copyOfRange(ba, off, off + len), LATIN1); - } else { - return result.with(StringLatin1.inflate(ba, off, len), UTF16); - } - } - } - static Result decode(String charsetName, byte[] ba, int off, int len) throws UnsupportedEncodingException { @@ -249,12 +227,15 @@ Charset cs = lookupCharset(csn); if (cs != null) { if (cs == UTF_8) { - sd = new StringDecoderUTF8(cs, csn); - } else if (cs == ISO_8859_1) { - sd = new StringDecoder8859_1(cs, csn); - } else { - sd = new StringDecoder(cs, csn); + return decodeUTF8(ba, off, len, true); + } + if (cs == ISO_8859_1) { + return decodeLatin1(ba, off, len); } + if (cs == US_ASCII) { + return decodeASCII(ba, off, len); + } + sd = new StringDecoder(cs, csn); } } catch (IllegalCharsetNameException x) {} if (sd == null) @@ -265,6 +246,16 @@ } static Result decode(Charset cs, byte[] ba, int off, int len) { + if (cs == UTF_8) { + return decodeUTF8(ba, off, len, true); + } + if (cs == ISO_8859_1) { + return decodeLatin1(ba, off, len); + } + if (cs == US_ASCII) { + return decodeASCII(ba, off, len); + } + // (1)We never cache the "external" cs, the only benefit of creating // an additional StringDe/Encoder object to wrap it is to share the // de/encode() method. These SD/E objects are short-lived, the young-gen @@ -280,39 +271,29 @@ // check (... && (isTrusted || SM == null || getClassLoader0())) in trim // but it then can be argued that the SM is null when the operation // is started... - if (cs == UTF_8) { - return StringDecoderUTF8.decode(ba, off, len, new Result()); - } CharsetDecoder cd = cs.newDecoder(); // ascii fastpath - if (cs == ISO_8859_1 || ((cd instanceof ArrayDecoder) && - ((ArrayDecoder)cd).isASCIICompatible() && - !hasNegatives(ba, off, len))) { - if (COMPACT_STRINGS) { - return new Result().with(Arrays.copyOfRange(ba, off, off + len), - LATIN1); - } else { - return new Result().with(StringLatin1.inflate(ba, off, len), UTF16); - } + if ((cd instanceof ArrayDecoder) && + ((ArrayDecoder)cd).isASCIICompatible() && !hasNegatives(ba, off, len)) { + return decodeLatin1(ba, off, len); } int en = scale(len, cd.maxCharsPerByte()); if (len == 0) { return new Result().with(); } - if (cs.getClass().getClassLoader0() != null && - System.getSecurityManager() != null) { - ba = Arrays.copyOfRange(ba, off, off + len); - off = 0; - } cd.onMalformedInput(CodingErrorAction.REPLACE) .onUnmappableCharacter(CodingErrorAction.REPLACE) .reset(); - char[] ca = new char[en]; if (cd instanceof ArrayDecoder) { int clen = ((ArrayDecoder)cd).decode(ba, off, len, ca); return new Result().with(ca, 0, clen); } + if (cs.getClass().getClassLoader0() != null && + System.getSecurityManager() != null) { + ba = Arrays.copyOfRange(ba, off, off + len); + off = 0; + } ByteBuffer bb = ByteBuffer.wrap(ba, off, len); CharBuffer cb = CharBuffer.wrap(ca); try { @@ -331,24 +312,22 @@ } static Result decode(byte[] ba, int off, int len) { - String csn = Charset.defaultCharset().name(); - try { - // use charset name decode() variant which provides caching. - return decode(csn, ba, off, len); - } catch (UnsupportedEncodingException x) { - warnUnsupportedCharset(csn); + Charset cs = Charset.defaultCharset(); + if (cs == UTF_8) { + return decodeUTF8(ba, off, len, true); + } + if (cs == ISO_8859_1) { + return decodeLatin1(ba, off, len); } - try { - return decode("ISO-8859-1", ba, off, len); - } catch (UnsupportedEncodingException x) { - // If this code is hit during VM initialization, err(String) is - // the only way we will be able to get any kind of error message. - err("ISO-8859-1 charset not available: " + x.toString() + "\n"); - // If we can not find ISO-8859-1 (a required encoding) then things - // are seriously wrong with the installation. - System.exit(1); - return null; + if (cs == US_ASCII) { + return decodeASCII(ba, off, len); } + StringDecoder sd = deref(decoder); + if (sd == null || !cs.name().equals(sd.cs.name())) { + sd = new StringDecoder(cs, cs.name()); + set(decoder, sd); + } + return sd.decode(ba, off, len); } // -- Encoding -- @@ -393,9 +372,6 @@ return ba; } if (ce instanceof ArrayEncoder) { - if (!isTrusted) { - val = Arrays.copyOf(val, val.length); - } int blen = (coder == LATIN1 ) ? ((ArrayEncoder)ce).encodeFromLatin1(val, 0, len, ba) : ((ArrayEncoder)ce).encodeFromUTF16(val, 0, len, ba); if (blen != -1) { @@ -423,49 +399,140 @@ } } - @HotSpotIntrinsicCandidate - private static int implEncodeISOArray(byte[] sa, int sp, - byte[] da, int dp, int len) { - int i = 0; - for (; i < len; i++) { - char c = StringUTF16.getChar(sa, sp++); - if (c > '\u00FF') - break; - da[dp++] = (byte)c; + static byte[] encode(String charsetName, byte coder, byte[] val) + throws UnsupportedEncodingException + { + StringEncoder se = deref(encoder); + String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; + if ((se == null) || !(csn.equals(se.requestedCharsetName()) + || csn.equals(se.charsetName()))) { + se = null; + try { + Charset cs = lookupCharset(csn); + if (cs != null) { + if (cs == UTF_8) { + return encodeUTF8(coder, val, true); + } + if (cs == ISO_8859_1) { + return encode8859_1(coder, val); + } + if (cs == US_ASCII) { + return encodeASCII(coder, val); + } + se = new StringEncoder(cs, csn); + } + } catch (IllegalCharsetNameException x) {} + if (se == null) { + throw new UnsupportedEncodingException (csn); + } + set(encoder, se); } - return i; + return se.encode(coder, val); } - static byte[] encode8859_1(byte coder, byte[] val) { - if (coder == LATIN1) { + static byte[] encode(Charset cs, byte coder, byte[] val) { + if (cs == UTF_8) { + return encodeUTF8(coder, val, true); + } + if (cs == ISO_8859_1) { + return encode8859_1(coder, val); + } + if (cs == US_ASCII) { + return encodeASCII(coder, val); + } + CharsetEncoder ce = cs.newEncoder(); + // fastpath for ascii compatible + if (coder == LATIN1 && (((ce instanceof ArrayEncoder) && + ((ArrayEncoder)ce).isASCIICompatible() && + !hasNegatives(val, 0, val.length)))) { return Arrays.copyOf(val, val.length); } - int len = val.length >> 1; - byte[] dst = new byte[len]; - int dp = 0; - int sp = 0; - int sl = len; - while (sp < sl) { - int ret = implEncodeISOArray(val, sp, dst, dp, len); - sp = sp + ret; - dp = dp + ret; - if (ret != len) { - char c = StringUTF16.getChar(val, sp++); - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(StringUTF16.getChar(val, sp))) { - sp++; - } - dst[dp++] = '?'; - len = sl - sp; + int len = val.length >> coder; // assume LATIN1=0/UTF16=1; + int en = scale(len, ce.maxBytesPerChar()); + byte[] ba = new byte[en]; + if (len == 0) { + return ba; + } + ce.onMalformedInput(CodingErrorAction.REPLACE) + .onUnmappableCharacter(CodingErrorAction.REPLACE) + .reset(); + if (ce instanceof ArrayEncoder) { + int blen = (coder == LATIN1 ) ? ((ArrayEncoder)ce).encodeFromLatin1(val, 0, len, ba) + : ((ArrayEncoder)ce).encodeFromUTF16(val, 0, len, ba); + if (blen != -1) { + return safeTrim(ba, blen, true); } } - if (dp == dst.length) { - return dst; + boolean isTrusted = cs.getClass().getClassLoader0() == null || + System.getSecurityManager() == null; + char[] ca = (coder == LATIN1 ) ? StringLatin1.toChars(val) + : StringUTF16.toChars(val); + ByteBuffer bb = ByteBuffer.wrap(ba); + CharBuffer cb = CharBuffer.wrap(ca, 0, len); + try { + CoderResult cr = ce.encode(cb, bb, true); + if (!cr.isUnderflow()) + cr.throwException(); + cr = ce.flush(bb); + if (!cr.isUnderflow()) + cr.throwException(); + } catch (CharacterCodingException x) { + throw new Error(x); } - return Arrays.copyOf(dst, dp); + return safeTrim(ba, bb.position(), isTrusted); } - static byte[] encodeASCII(byte coder, byte[] val) { + static byte[] encode(byte coder, byte[] val) { + Charset cs = Charset.defaultCharset(); + if (cs == UTF_8) { + return encodeUTF8(coder, val, true); + } + if (cs == ISO_8859_1) { + return encode8859_1(coder, val); + } + if (cs == US_ASCII) { + return encodeASCII(coder, val); + } + StringEncoder se = deref(encoder); + if (se == null || !cs.name().equals(se.cs.name())) { + se = new StringEncoder(cs, cs.name()); + set(encoder, se); + } + return se.encode(coder, val); + } + + /** + * Print a message directly to stderr, bypassing all character conversion + * methods. + * @param msg message to print + */ + private static native void err(String msg); + + /* The cached Result for each thread */ + private static final ThreadLocal + resultCached = new ThreadLocal<>() { + protected StringCoding.Result initialValue() { + return new StringCoding.Result(); + }}; + + ////////////////////////// ascii ////////////////////////////// + + private static Result decodeASCII(byte[] ba, int off, int len) { + Result result = resultCached.get(); + if (COMPACT_STRINGS && !hasNegatives(ba, off, len)) { + return result.with(Arrays.copyOfRange(ba, off, off + len), + LATIN1); + } + byte[] dst = new byte[len<<1]; + int dp = 0; + while (dp < len) { + int b = ba[off++]; + putChar(dst, dp++, (b >= 0) ? (char)b : repl); + } + return result.with(dst, UTF16); + } + + private static byte[] encodeASCII(byte coder, byte[] val) { if (coder == LATIN1) { byte[] dst = new byte[val.length]; for (int i = 0; i < val.length; i++) { @@ -498,59 +565,51 @@ return Arrays.copyOf(dst, dp); } - static byte[] encodeUTF8(byte coder, byte[] val) { - int dp = 0; - byte[] dst; + ////////////////////////// latin1/8859_1 /////////////////////////// + + private static Result decodeLatin1(byte[] ba, int off, int len) { + Result result = resultCached.get(); + if (COMPACT_STRINGS) { + return result.with(Arrays.copyOfRange(ba, off, off + len), LATIN1); + } else { + return result.with(StringLatin1.inflate(ba, off, len), UTF16); + } + } + + @HotSpotIntrinsicCandidate + private static int implEncodeISOArray(byte[] sa, int sp, + byte[] da, int dp, int len) { + int i = 0; + for (; i < len; i++) { + char c = StringUTF16.getChar(sa, sp++); + if (c > '\u00FF') + break; + da[dp++] = (byte)c; + } + return i; + } + + private static byte[] encode8859_1(byte coder, byte[] val) { if (coder == LATIN1) { - dst = new byte[val.length << 1]; - for (int sp = 0; sp < val.length; sp++) { - byte c = val[sp]; - if (c < 0) { - dst[dp++] = (byte)(0xc0 | ((c & 0xff) >> 6)); - dst[dp++] = (byte)(0x80 | (c & 0x3f)); - } else { - dst[dp++] = c; + return Arrays.copyOf(val, val.length); + } + int len = val.length >> 1; + byte[] dst = new byte[len]; + int dp = 0; + int sp = 0; + int sl = len; + while (sp < sl) { + int ret = implEncodeISOArray(val, sp, dst, dp, len); + sp = sp + ret; + dp = dp + ret; + if (ret != len) { + char c = StringUTF16.getChar(val, sp++); + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(StringUTF16.getChar(val, sp))) { + sp++; } - } - } else { - int sp = 0; - int sl = val.length >> 1; - dst = new byte[sl * 3]; - char c; - while (sp < sl && (c = StringUTF16.getChar(val, sp)) < '\u0080') { - // ascii fast loop; - dst[dp++] = (byte)c; - sp++; - } - while (sp < sl) { - c = StringUTF16.getChar(val, sp++); - if (c < 0x80) { - dst[dp++] = (byte)c; - } else if (c < 0x800) { - dst[dp++] = (byte)(0xc0 | (c >> 6)); - dst[dp++] = (byte)(0x80 | (c & 0x3f)); - } else if (Character.isSurrogate(c)) { - int uc = -1; - char c2; - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(c2 = StringUTF16.getChar(val, sp))) { - uc = Character.toCodePoint(c, c2); - } - if (uc < 0) { - dst[dp++] = '?'; - } else { - dst[dp++] = (byte)(0xf0 | ((uc >> 18))); - dst[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f)); - dst[dp++] = (byte)(0x80 | ((uc >> 6) & 0x3f)); - dst[dp++] = (byte)(0x80 | (uc & 0x3f)); - sp++; // 2 chars - } - } else { - // 3 bytes, 16 bits - dst[dp++] = (byte)(0xe0 | ((c >> 12))); - dst[dp++] = (byte)(0x80 | ((c >> 6) & 0x3f)); - dst[dp++] = (byte)(0x80 | (c & 0x3f)); - } + dst[dp++] = '?'; + len = sl - sp; } } if (dp == dst.length) { @@ -559,113 +618,333 @@ return Arrays.copyOf(dst, dp); } - static byte[] encode(String charsetName, byte coder, byte[] val) - throws UnsupportedEncodingException - { - StringEncoder se = deref(encoder); - String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; - if ((se == null) || !(csn.equals(se.requestedCharsetName()) - || csn.equals(se.charsetName()))) { - se = null; - try { - Charset cs = lookupCharset(csn); - if (cs != null) { - if (cs == UTF_8) { - return encodeUTF8(coder, val); - } else if (cs == ISO_8859_1) { - return encode8859_1(coder, val); - } else if (cs == US_ASCII) { - return encodeASCII(coder, val); - } - se = new StringEncoder(cs, csn); - } - } catch (IllegalCharsetNameException x) {} - if (se == null) { - throw new UnsupportedEncodingException (csn); - } - set(encoder, se); + //////////////////////////////// utf8 //////////////////////////////////// + + private static boolean isNotContinuation(int b) { + return (b & 0xc0) != 0x80; + } + + private static boolean isMalformed3(int b1, int b2, int b3) { + return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || + (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80; + } + + private static boolean isMalformed3_2(int b1, int b2) { + return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || + (b2 & 0xc0) != 0x80; + } + + private static boolean isMalformed4(int b2, int b3, int b4) { + return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 || + (b4 & 0xc0) != 0x80; + } + + private static boolean isMalformed4_2(int b1, int b2) { + return (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) || + (b1 == 0xf4 && (b2 & 0xf0) != 0x80) || + (b2 & 0xc0) != 0x80; + } + + private static boolean isMalformed4_3(int b3) { + return (b3 & 0xc0) != 0x80; + } + + // for nb == 3/4 + private static int malformedN(byte[] src, int sp, int nb) { + if (nb == 3) { + int b1 = src[sp++]; + int b2 = src[sp++]; // no need to lookup b3 + return ((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || + isNotContinuation(b2)) ? 1 : 2; + } else if (nb == 4) { // we don't care the speed here + int b1 = src[sp++] & 0xff; + int b2 = src[sp++] & 0xff; + if (b1 > 0xf4 || + (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) || + (b1 == 0xf4 && (b2 & 0xf0) != 0x80) || + isNotContinuation(b2)) + return 1; + if (isNotContinuation(src[sp++])) + return 2; + return 3; } - return se.encode(coder, val); + assert false; + return -1; + } + + private static void throwMalformed(int off, int nb) { + throw new IllegalArgumentException("malformed input off : " + off + + ", length : " + nb); + } + + private static char repl = '\ufffd'; + + private static Result decodeUTF8(byte[] src, int sp, int len, boolean doReplace) { + // ascii-bais, which has a relative impact to the non-ascii-only bytes + if (COMPACT_STRINGS && !hasNegatives(src, sp, len)) + return resultCached.get().with(Arrays.copyOfRange(src, sp, sp + len), + LATIN1); + return decodeUTF8_0(src, sp, len, doReplace); } - static byte[] encode(Charset cs, byte coder, byte[] val) { - if (cs == UTF_8) { - return encodeUTF8(coder, val); - } else if (cs == ISO_8859_1) { - return encode8859_1(coder, val); - } else if (cs == US_ASCII) { - return encodeASCII(coder, val); - } - CharsetEncoder ce = cs.newEncoder(); - // fastpath for ascii compatible - if (coder == LATIN1 && (((ce instanceof ArrayEncoder) && - ((ArrayEncoder)ce).isASCIICompatible() && - !hasNegatives(val, 0, val.length)))) { - return Arrays.copyOf(val, val.length); - } - int len = val.length >> coder; // assume LATIN1=0/UTF16=1; - int en = scale(len, ce.maxBytesPerChar()); - byte[] ba = new byte[en]; - if (len == 0) { - return ba; - } - boolean isTrusted = cs.getClass().getClassLoader0() == null || - System.getSecurityManager() == null; - ce.onMalformedInput(CodingErrorAction.REPLACE) - .onUnmappableCharacter(CodingErrorAction.REPLACE) - .reset(); - if (ce instanceof ArrayEncoder) { - if (!isTrusted) { - val = Arrays.copyOf(val, val.length); + private static Result decodeUTF8_0(byte[] src, int sp, int len, boolean doReplace) { + Result ret = resultCached.get(); + + int sl = sp + len; + int dp = 0; + byte[] dst = new byte[len]; + + if (COMPACT_STRINGS) { + while (sp < sl) { + int b1 = src[sp]; + if (b1 >= 0) { + dst[dp++] = (byte)b1; + sp++; + continue; + } + if ((b1 == (byte)0xc2 || b1 == (byte)0xc3) && + sp + 1 < sl) { + int b2 = src[sp + 1]; + if (!isNotContinuation(b2)) { + dst[dp++] = (byte)(((b1 << 6) ^ b2)^ + (((byte) 0xC0 << 6) ^ + ((byte) 0x80 << 0))); + sp += 2; + continue; + } + } + // anything not a latin1, including the repl + // we have to go with the utf16 + break; } - int blen = (coder == LATIN1 ) ? ((ArrayEncoder)ce).encodeFromLatin1(val, 0, len, ba) - : ((ArrayEncoder)ce).encodeFromUTF16(val, 0, len, ba); - if (blen != -1) { - return safeTrim(ba, blen, isTrusted); + if (sp == sl) { + if (dp != dst.length) { + dst = Arrays.copyOf(dst, dp); + } + return ret.with(dst, LATIN1); } } - char[] ca = (coder == LATIN1 ) ? StringLatin1.toChars(val) - : StringUTF16.toChars(val); - ByteBuffer bb = ByteBuffer.wrap(ba); - CharBuffer cb = CharBuffer.wrap(ca, 0, len); - try { - CoderResult cr = ce.encode(cb, bb, true); - if (!cr.isUnderflow()) - cr.throwException(); - cr = ce.flush(bb); - if (!cr.isUnderflow()) - cr.throwException(); - } catch (CharacterCodingException x) { - throw new Error(x); + if (dp == 0) { + dst = new byte[len << 1]; + } else { + byte[] buf = new byte[len << 1]; + StringLatin1.inflate(dst, 0, buf, 0, dp); + dst = buf; } - return safeTrim(ba, bb.position(), isTrusted); + while (sp < sl) { + int b1 = src[sp++]; + if (b1 >= 0) { + putChar(dst, dp++, (char) b1); + } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) { + if (sp < sl) { + int b2 = src[sp++]; + if (isNotContinuation(b2)) { + if (!doReplace) { + throwMalformed(sp - 1, 1); + } + putChar(dst, dp++, repl); + sp--; + } else { + putChar(dst, dp++, (char)(((b1 << 6) ^ b2)^ + (((byte) 0xC0 << 6) ^ + ((byte) 0x80 << 0)))); + } + continue; + } + if (!doReplace) { + throwMalformed(sp, 1); // underflow() + } + putChar(dst, dp++, repl); + break; + } else if ((b1 >> 4) == -2) { + if (sp + 1 < sl) { + int b2 = src[sp++]; + int b3 = src[sp++]; + if (isMalformed3(b1, b2, b3)) { + if (!doReplace) { + throwMalformed(sp - 3, 3); + } + putChar(dst, dp++, repl); + sp -= 3; + sp += malformedN(src, sp, 3); + } else { + char c = (char)((b1 << 12) ^ + (b2 << 6) ^ + (b3 ^ + (((byte) 0xE0 << 12) ^ + ((byte) 0x80 << 6) ^ + ((byte) 0x80 << 0)))); + if (isSurrogate(c)) { + if (!doReplace) { + throwMalformed(sp - 3, 3); + } + putChar(dst, dp++, repl); + } else { + putChar(dst, dp++, c); + } + } + continue; + } + if (sp < sl && isMalformed3_2(b1, src[sp])) { + if (!doReplace) { + throwMalformed(sp - 1, 2); + } + putChar(dst, dp++, repl); + continue; + } + if (!doReplace){ + throwMalformed(sp, 1); + } + putChar(dst, dp++, repl); + break; + } else if ((b1 >> 3) == -2) { + if (sp + 2 < sl) { + int b2 = src[sp++]; + int b3 = src[sp++]; + int b4 = src[sp++]; + int uc = ((b1 << 18) ^ + (b2 << 12) ^ + (b3 << 6) ^ + (b4 ^ + (((byte) 0xF0 << 18) ^ + ((byte) 0x80 << 12) ^ + ((byte) 0x80 << 6) ^ + ((byte) 0x80 << 0)))); + if (isMalformed4(b2, b3, b4) || + !isSupplementaryCodePoint(uc)) { // shortest form check + if (!doReplace) { + throwMalformed(sp - 4, 4); + } + putChar(dst, dp++, repl); + sp -= 4; + sp += malformedN(src, sp, 4); + } else { + putChar(dst, dp++, highSurrogate(uc)); + putChar(dst, dp++, lowSurrogate(uc)); + } + continue; + } + b1 &= 0xff; + if (b1 > 0xf4 || + sp < sl && isMalformed4_2(b1, src[sp] & 0xff)) { + if (!doReplace) { + throwMalformed(sp - 1, 1); // or 2 + } + putChar(dst, dp++, repl); + continue; + } + if (!doReplace) { + throwMalformed(sp - 1, 1); + } + sp++; + putChar(dst, dp++, repl); + if (sp < sl && isMalformed4_3(src[sp])) { + continue; + } + break; + } else { + if (!doReplace) { + throwMalformed(sp - 1, 1); + } + putChar(dst, dp++, repl); + } + } + if (dp != len) { + dst = Arrays.copyOf(dst, dp << 1); + } + return ret.with(dst, UTF16); } - static byte[] encode(byte coder, byte[] val) { - String csn = Charset.defaultCharset().name(); - try { - // use charset name encode() variant which provides caching. - return encode(csn, coder, val); - } catch (UnsupportedEncodingException x) { - warnUnsupportedCharset(csn); + private static byte[] encodeUTF8(byte coder, byte[] val, boolean doReplace) { + if (coder == UTF16) + return encodeUTF8_UTF16(val, doReplace); + + if (!hasNegatives(val, 0, val.length)) + return Arrays.copyOf(val, val.length); + + int dp = 0; + byte[] dst = new byte[val.length << 1]; + for (int sp = 0; sp < val.length; sp++) { + byte c = val[sp]; + if (c < 0) { + dst[dp++] = (byte)(0xc0 | ((c & 0xff) >> 6)); + dst[dp++] = (byte)(0x80 | (c & 0x3f)); + } else { + dst[dp++] = c; + } } - try { - return encode("ISO-8859-1", coder, val); - } catch (UnsupportedEncodingException x) { - // If this code is hit during VM initialization, err(String) is - // the only way we will be able to get any kind of error message. - err("ISO-8859-1 charset not available: " + x.toString() + "\n"); - // If we can not find ISO-8859-1 (a required encoding) then things - // are seriously wrong with the installation. - System.exit(1); - return null; - } + if (dp == dst.length) + return dst; + return Arrays.copyOf(dst, dp); } - /** - * Print a message directly to stderr, bypassing all character conversion - * methods. - * @param msg message to print + private static byte[] encodeUTF8_UTF16(byte[] val, boolean doReplace) { + int dp = 0; + int sp = 0; + int sl = val.length >> 1; + byte[] dst = new byte[sl * 3]; + char c; + while (sp < sl && (c = StringUTF16.getChar(val, sp)) < '\u0080') { + // ascii fast loop; + dst[dp++] = (byte)c; + sp++; + } + while (sp < sl) { + c = StringUTF16.getChar(val, sp++); + if (c < 0x80) { + dst[dp++] = (byte)c; + } else if (c < 0x800) { + dst[dp++] = (byte)(0xc0 | (c >> 6)); + dst[dp++] = (byte)(0x80 | (c & 0x3f)); + } else if (Character.isSurrogate(c)) { + int uc = -1; + char c2; + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(c2 = StringUTF16.getChar(val, sp))) { + uc = Character.toCodePoint(c, c2); + } + if (uc < 0) { + if (doReplace) { + dst[dp++] = '?'; + } else { + throwMalformed(sp - 1, 1); // or 2, does not matter here + } + } else { + dst[dp++] = (byte)(0xf0 | ((uc >> 18))); + dst[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f)); + dst[dp++] = (byte)(0x80 | ((uc >> 6) & 0x3f)); + dst[dp++] = (byte)(0x80 | (uc & 0x3f)); + sp++; // 2 chars + } + } else { + // 3 bytes, 16 bits + dst[dp++] = (byte)(0xe0 | ((c >> 12))); + dst[dp++] = (byte)(0x80 | ((c >> 6) & 0x3f)); + dst[dp++] = (byte)(0x80 | (c & 0x3f)); + } + } + if (dp == dst.length) { + return dst; + } + return Arrays.copyOf(dst, dp); + } + + ////////////////////// for j.u.z.ZipCoder ////////////////////////// + + /* + * Throws iae, instead of replacing, if malformed or unmappble. */ - private static native void err(String msg); + static String newStringUTF8NoRepl(byte[] src, int off, int len) { + if (COMPACT_STRINGS && !hasNegatives(src, off, len)) + return new String(Arrays.copyOfRange(src, off, off + len), LATIN1); + Result ret = decodeUTF8_0(src, off, len, false); + return new String(ret.value, ret.coder); + } + + /* + * Throws iae, instead of replacing, if unmappble. + */ + static byte[] getBytesUTF8NoRepl(String s) { + return encodeUTF8(s.coder(), s.value(), false); + } } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/lang/StringDecoderUTF8.java --- a/src/java.base/share/classes/java/lang/StringDecoderUTF8.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,235 +0,0 @@ -/* - * 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. 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 java.lang; - -import java.nio.charset.Charset; -import java.util.Arrays; - -import static java.lang.String.LATIN1; -import static java.lang.String.UTF16; -import static java.lang.String.COMPACT_STRINGS; -import static java.lang.Character.isSurrogate; -import static java.lang.Character.highSurrogate; -import static java.lang.Character.lowSurrogate; -import static java.lang.Character.isSupplementaryCodePoint; -import static java.lang.StringUTF16.putChar; - -class StringDecoderUTF8 extends StringCoding.StringDecoder { - - StringDecoderUTF8(Charset cs, String rcn) { - super(cs, rcn); - } - - private static boolean isNotContinuation(int b) { - return (b & 0xc0) != 0x80; - } - - private static boolean isMalformed3(int b1, int b2, int b3) { - return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || - (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80; - } - - private static boolean isMalformed3_2(int b1, int b2) { - return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || - (b2 & 0xc0) != 0x80; - } - - private static boolean isMalformed4(int b2, int b3, int b4) { - return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 || - (b4 & 0xc0) != 0x80; - } - - private static boolean isMalformed4_2(int b1, int b2) { - return (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) || - (b1 == 0xf4 && (b2 & 0xf0) != 0x80) || - (b2 & 0xc0) != 0x80; - } - - private static boolean isMalformed4_3(int b3) { - return (b3 & 0xc0) != 0x80; - } - - // for nb == 3/4 - private static int malformedN(byte[] src, int sp, int nb) { - if (nb == 3) { - int b1 = src[sp++]; - int b2 = src[sp++]; // no need to lookup b3 - return ((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || - isNotContinuation(b2)) ? 1 : 2; - } else if (nb == 4) { // we don't care the speed here - int b1 = src[sp++] & 0xff; - int b2 = src[sp++] & 0xff; - if (b1 > 0xf4 || - (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) || - (b1 == 0xf4 && (b2 & 0xf0) != 0x80) || - isNotContinuation(b2)) - return 1; - if (isNotContinuation(src[sp++])) - return 2; - return 3; - } - assert false; - return -1; - } - - private static char repl = '\ufffd'; - - StringCoding.Result decode(byte[] src, int sp, int len) { - return decode(src, sp, len, result); - } - - static StringCoding.Result decode(byte[] src, int sp, int len, - StringCoding.Result ret) { - int sl = sp + len; - byte[] dst = new byte[len]; - int dp = 0; - if (COMPACT_STRINGS) { // Latin1 only loop - while (sp < sl) { - int b1 = src[sp]; - if (b1 >= 0) { - dst[dp++] = (byte)b1; - sp++; - continue; - } - if ((b1 == (byte)0xc2 || b1 == (byte)0xc3) && - sp + 1 < sl) { - int b2 = src[sp + 1]; - if (!isNotContinuation(b2)) { - dst[dp++] = (byte)(((b1 << 6) ^ b2)^ - (((byte) 0xC0 << 6) ^ - ((byte) 0x80 << 0))); - sp += 2; - continue; - } - } - // anything not a latin1, including the repl - // we have to go with the utf16 - break; - } - if (sp == sl) { - if (dp != dst.length) { - dst = Arrays.copyOf(dst, dp); - } - return ret.with(dst, LATIN1); - } - } - if (dp == 0) { - dst = new byte[len << 1]; - } else { - byte[] buf = new byte[len << 1]; - StringLatin1.inflate(dst, 0, buf, 0, dp); - dst = buf; - } - while (sp < sl) { - int b1 = src[sp++]; - if (b1 >= 0) { - putChar(dst, dp++, (char) b1); - } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) { - if (sp < sl) { - int b2 = src[sp++]; - if (isNotContinuation(b2)) { - putChar(dst, dp++, repl); - sp--; - } else { - putChar(dst, dp++, (char)(((b1 << 6) ^ b2)^ - (((byte) 0xC0 << 6) ^ - ((byte) 0x80 << 0)))); - } - continue; - } - putChar(dst, dp++, repl); - break; - } else if ((b1 >> 4) == -2) { - if (sp + 1 < sl) { - int b2 = src[sp++]; - int b3 = src[sp++]; - if (isMalformed3(b1, b2, b3)) { - putChar(dst, dp++, repl); - sp -= 3; - sp += malformedN(src, sp, 3); - } else { - char c = (char)((b1 << 12) ^ - (b2 << 6) ^ - (b3 ^ - (((byte) 0xE0 << 12) ^ - ((byte) 0x80 << 6) ^ - ((byte) 0x80 << 0)))); - putChar(dst, dp++, isSurrogate(c) ? repl : c); - } - continue; - } - if (sp < sl && isMalformed3_2(b1, src[sp])) { - putChar(dst, dp++, repl); - continue; - } - putChar(dst, dp++, repl); - break; - } else if ((b1 >> 3) == -2) { - if (sp + 2 < sl) { - int b2 = src[sp++]; - int b3 = src[sp++]; - int b4 = src[sp++]; - int uc = ((b1 << 18) ^ - (b2 << 12) ^ - (b3 << 6) ^ - (b4 ^ - (((byte) 0xF0 << 18) ^ - ((byte) 0x80 << 12) ^ - ((byte) 0x80 << 6) ^ - ((byte) 0x80 << 0)))); - if (isMalformed4(b2, b3, b4) || - !isSupplementaryCodePoint(uc)) { // shortest form check - putChar(dst, dp++, repl); - sp -= 4; - sp += malformedN(src, sp, 4); - } else { - putChar(dst, dp++, highSurrogate(uc)); - putChar(dst, dp++, lowSurrogate(uc)); - } - continue; - } - b1 &= 0xff; - if (b1 > 0xf4 || - sp < sl && isMalformed4_2(b1, src[sp] & 0xff)) { - putChar(dst, dp++, repl); - continue; - } - sp++; - putChar(dst, dp++, repl); - if (sp < sl && isMalformed4_3(src[sp])) { - continue; - } - break; - } else { - putChar(dst, dp++, repl); - } - } - if (dp != len) { - dst = Arrays.copyOf(dst, dp << 1); - } - return ret.with(dst, UTF16); - } -} diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/lang/System.java --- a/src/java.base/share/classes/java/lang/System.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/lang/System.java Wed Dec 13 10:25:38 2017 -0800 @@ -2184,6 +2184,15 @@ public Stream layers(ClassLoader loader) { return ModuleLayer.layers(loader); } + + public String newStringUTF8NoRepl(byte[] bytes, int off, int len) { + return StringCoding.newStringUTF8NoRepl(bytes, off, len); + } + + public byte[] getBytesUTF8NoRepl(String s) { + return StringCoding.getBytesUTF8NoRepl(s); + } + }); } } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/lang/invoke/MethodType.java --- a/src/java.base/share/classes/java/lang/invoke/MethodType.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/lang/invoke/MethodType.java Wed Dec 13 10:25:38 2017 -0800 @@ -105,23 +105,10 @@ private @Stable String methodDescriptor; // cache for toMethodDescriptorString /** - * Check the given parameters for validity and store them into the final fields. + * Constructor that performs no copying or validation. + * Should only be called from the factory method makeImpl */ - private MethodType(Class rtype, Class[] ptypes, boolean trusted) { - checkRtype(rtype); - checkPtypes(ptypes); - this.rtype = rtype; - // defensively copy the array passed in by the user - this.ptypes = trusted ? ptypes : Arrays.copyOf(ptypes, ptypes.length); - } - - /** - * Construct a temporary unchecked instance of MethodType for use only as a key to the intern table. - * Does not check the given parameters for validity, and must discarded (if untrusted) or checked - * (if trusted) after it has been used as a searching key. - * The parameters are reversed for this constructor, so that it is not accidentally used. - */ - private MethodType(Class[] ptypes, Class rtype) { + private MethodType(Class rtype, Class[] ptypes) { this.rtype = rtype; this.ptypes = ptypes; } @@ -308,18 +295,21 @@ if (ptypes.length == 0) { ptypes = NO_PTYPES; trusted = true; } - MethodType primordialMT = new MethodType(ptypes, rtype); + MethodType primordialMT = new MethodType(rtype, ptypes); MethodType mt = internTable.get(primordialMT); if (mt != null) return mt; // promote the object to the Real Thing, and reprobe + MethodType.checkRtype(rtype); if (trusted) { - MethodType.checkRtype(rtype); MethodType.checkPtypes(ptypes); mt = primordialMT; } else { - mt = new MethodType(rtype, ptypes, false); + // Make defensive copy then validate + ptypes = Arrays.copyOf(ptypes, ptypes.length); + MethodType.checkPtypes(ptypes); + mt = new MethodType(rtype, ptypes); } mt.form = MethodTypeForm.findForm(mt); return internTable.add(mt); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/lang/module/ModuleDescriptor.java --- a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java Wed Dec 13 10:25:38 2017 -0800 @@ -39,6 +39,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -2603,7 +2604,8 @@ * Returns a string containing the given set of modifiers and label. */ private static String toString(Set mods, String what) { - return (Stream.concat(mods.stream().map(e -> e.toString().toLowerCase()), + return (Stream.concat(mods.stream().map(e -> e.toString() + .toLowerCase(Locale.ROOT)), Stream.of(what))) .collect(Collectors.joining(" ")); } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/net/URLClassLoader.java --- a/src/java.base/share/classes/java/net/URLClassLoader.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/net/URLClassLoader.java Wed Dec 13 10:25:38 2017 -0800 @@ -658,8 +658,8 @@ * * @param name the resource name * @exception IOException if an I/O exception occurs - * @return an {@code Enumeration} of {@code URL}s - * If the loader is closed, the Enumeration will be empty. + * @return An {@code Enumeration} of {@code URL}s. + * If the loader is closed, the Enumeration contains no elements. */ public Enumeration findResources(final String name) throws IOException diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/net/URLDecoder.java --- a/src/java.base/share/classes/java/net/URLDecoder.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/net/URLDecoder.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,10 @@ package java.net; import java.io.*; +import java.nio.charset.Charset; +import java.nio.charset.IllegalCharsetNameException; +import java.nio.charset.UnsupportedCharsetException; +import java.util.Objects; /** * Utility class for HTML form decoding. This class contains static methods @@ -108,7 +112,43 @@ /** * Decodes an {@code application/x-www-form-urlencoded} string using * a specific encoding scheme. - * The supplied encoding is used to determine + * + *

+ * This method behaves the same as {@linkplain decode(String s, Charset charset)} + * except that it will {@linkplain java.nio.charset.Charset#forName look up the charset} + * using the given encoding name. + * + * @implNote This implementation will throw an {@link java.lang.IllegalArgumentException} + * when illegal strings are encountered. + * + * @param s the {@code String} to decode + * @param enc The name of a supported + * character + * encoding. + * @return the newly decoded {@code String} + * @throws UnsupportedEncodingException + * If character encoding needs to be consulted, but + * named character encoding is not supported + * @see URLEncoder#encode(java.lang.String, java.lang.String) + * @since 1.4 + */ + public static String decode(String s, String enc) throws UnsupportedEncodingException { + if (enc.length() == 0) { + throw new UnsupportedEncodingException ("URLDecoder: empty string enc parameter"); + } + + try { + Charset charset = Charset.forName(enc); + return decode(s, charset); + } catch (IllegalCharsetNameException | UnsupportedCharsetException e) { + throw new UnsupportedEncodingException(enc); + } + } + + /** + * Decodes an {@code application/x-www-form-urlencoded} string using + * a specific {@linkplain java.nio.charset.Charset Charset}. + * The supplied charset is used to determine * what characters are represented by any consecutive sequences of the * form "{@code %xy}". *

@@ -118,29 +158,25 @@ * UTF-8 should be used. Not doing so may introduce * incompatibilities. * + * @implNote This implementation will throw an {@link java.lang.IllegalArgumentException} + * when illegal strings are encountered. + * * @param s the {@code String} to decode - * @param enc The name of a supported - * character - * encoding. + * @param charset the given charset * @return the newly decoded {@code String} - * @exception UnsupportedEncodingException - * If character encoding needs to be consulted, but - * named character encoding is not supported - * @see URLEncoder#encode(java.lang.String, java.lang.String) - * @since 1.4 + * @throws NullPointerException if {@code s} or {@code charset} is {@code null} + * @throws IllegalArgumentException if the implementation encounters illegal + * characters + * @see URLEncoder#encode(java.lang.String, java.nio.charset.Charset) + * @since 10 */ - public static String decode(String s, String enc) - throws UnsupportedEncodingException{ - + public static String decode(String s, Charset charset) { + Objects.requireNonNull(charset, "Charset"); boolean needToChange = false; int numChars = s.length(); StringBuilder sb = new StringBuilder(numChars > 500 ? numChars / 2 : numChars); int i = 0; - if (enc.length() == 0) { - throw new UnsupportedEncodingException ("URLDecoder: empty string enc parameter"); - } - char c; byte[] bytes = null; while (i < numChars) { @@ -173,7 +209,9 @@ (c=='%')) { int v = Integer.parseInt(s, i + 1, i + 3, 16); if (v < 0) - throw new IllegalArgumentException("URLDecoder: Illegal hex characters in escape (%) pattern - negative value"); + throw new IllegalArgumentException( + "URLDecoder: Illegal hex characters in escape " + + "(%) pattern - negative value"); bytes[pos++] = (byte) v; i+= 3; if (i < numChars) @@ -187,7 +225,7 @@ throw new IllegalArgumentException( "URLDecoder: Incomplete trailing escape (%) pattern"); - sb.append(new String(bytes, 0, pos, enc)); + sb.append(new String(bytes, 0, pos, charset)); } catch (NumberFormatException e) { throw new IllegalArgumentException( "URLDecoder: Illegal hex characters in escape (%) pattern - " diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/net/URLEncoder.java --- a/src/java.base/share/classes/java/net/URLEncoder.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/net/URLEncoder.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.UnsupportedCharsetException ; import java.util.BitSet; +import java.util.Objects; import sun.security.action.GetPropertyAction; /** @@ -168,45 +169,61 @@ /** * Translates a string into {@code application/x-www-form-urlencoded} - * format using a specific encoding scheme. This method uses the - * supplied encoding scheme to obtain the bytes for unsafe - * characters. + * format using a specific encoding scheme. *

- * Note: The - * World Wide Web Consortium Recommendation states that - * UTF-8 should be used. Not doing so may introduce - * incompatibilities. + * This method behaves the same as {@linkplain encode(String s, Charset charset)} + * except that it will {@linkplain java.nio.charset.Charset#forName look up the charset} + * using the given encoding name. * * @param s {@code String} to be translated. * @param enc The name of a supported * character * encoding. * @return the translated {@code String}. - * @exception UnsupportedEncodingException + * @throws UnsupportedEncodingException * If the named encoding is not supported * @see URLDecoder#decode(java.lang.String, java.lang.String) * @since 1.4 */ public static String encode(String s, String enc) throws UnsupportedEncodingException { + if (enc == null) { + throw new NullPointerException("charsetName"); + } + + try { + Charset charset = Charset.forName(enc); + return encode(s, charset); + } catch (IllegalCharsetNameException | UnsupportedCharsetException e) { + throw new UnsupportedEncodingException(enc); + } + } + + /** + * Translates a string into {@code application/x-www-form-urlencoded} + * format using a specific {@linkplain java.nio.charset.Charset Charset}. + * This method uses the supplied charset to obtain the bytes for unsafe + * characters. + *

+ * Note: The + * World Wide Web Consortium Recommendation states that + * UTF-8 should be used. Not doing so may introduce incompatibilities. + * + * @param s {@code String} to be translated. + * @param charset the given charset + * @return the translated {@code String}. + * @throws NullPointerException if {@code s} or {@code charset} is {@code null}. + * @see URLDecoder#decode(java.lang.String, java.nio.charset.Charset) + * @since 10 + */ + public static String encode(String s, Charset charset) { + Objects.requireNonNull(charset, "charset"); boolean needToChange = false; StringBuilder out = new StringBuilder(s.length()); - Charset charset; CharArrayWriter charArrayWriter = new CharArrayWriter(); - if (enc == null) - throw new NullPointerException("charsetName"); - - try { - charset = Charset.forName(enc); - } catch (IllegalCharsetNameException e) { - throw new UnsupportedEncodingException(enc); - } catch (UnsupportedCharsetException e) { - throw new UnsupportedEncodingException(enc); - } - for (int i = 0; i < s.length();) { int c = (int) s.charAt(i); //System.out.println("Examining character: " + c); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/net/URLStreamHandler.java --- a/src/java.base/share/classes/java/net/URLStreamHandler.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/net/URLStreamHandler.java Wed Dec 13 10:25:38 2017 -0800 @@ -480,39 +480,14 @@ * @return a string representation of the {@code URL} argument. */ protected String toExternalForm(URL u) { - - // pre-compute length of StringBuffer - int len = u.getProtocol().length() + 1; - if (u.getAuthority() != null && u.getAuthority().length() > 0) - len += 2 + u.getAuthority().length(); - if (u.getPath() != null) { - len += u.getPath().length(); - } - if (u.getQuery() != null) { - len += 1 + u.getQuery().length(); - } - if (u.getRef() != null) - len += 1 + u.getRef().length(); - - StringBuilder result = new StringBuilder(len); - result.append(u.getProtocol()); - result.append(":"); - if (u.getAuthority() != null && u.getAuthority().length() > 0) { - result.append("//"); - result.append(u.getAuthority()); - } - if (u.getPath() != null) { - result.append(u.getPath()); - } - if (u.getQuery() != null) { - result.append('?'); - result.append(u.getQuery()); - } - if (u.getRef() != null) { - result.append("#"); - result.append(u.getRef()); - } - return result.toString(); + String s; + return u.getProtocol() + + ':' + + (((s = u.getAuthority()) != null && s.length() > 0) + ? "//" + s : "") + + (((s = u.getPath()) != null) ? s : "") + + (((s = u.getQuery()) != null) ? '?' + s : "") + + (((s = u.getRef()) != null) ? '#' + s : ""); } /** diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/nio/channels/Channels.java --- a/src/java.base/share/classes/java/nio/channels/Channels.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/nio/channels/Channels.java Wed Dec 13 10:25:38 2017 -0800 @@ -527,7 +527,7 @@ * behaves in exactly the same way as the expression * *

 {@code
-     *     Channels.newReader(ch, Charset.forName(csName).newDecoder(), -1)
+     *     Channels.newReader(ch, Charset.forName(csName))
      * } 
* * @param ch @@ -550,6 +550,38 @@ } /** + * Constructs a reader that decodes bytes from the given channel according + * to the given charset. + * + *

An invocation of this method of the form + * + *

 {@code
+     *     Channels.newReader(ch, charset)
+     * } 
+ * + * behaves in exactly the same way as the expression + * + *
 {@code
+     *     Channels.newReader(ch, Charset.forName(csName).newDecoder(), -1)
+     * } 
+ * + *

The reader's default action for malformed-input and unmappable-character + * errors is to {@linkplain java.nio.charset.CodingErrorAction#REPORT report} + * them. When more control over the error handling is required, the constructor + * that takes a {@linkplain java.nio.charset.CharsetDecoder} should be used. + * + * @param ch The channel from which bytes will be read + * + * @param charset The charset to be used + * + * @return A new reader + */ + public static Reader newReader(ReadableByteChannel ch, Charset charset) { + Objects.requireNonNull(charset, "charset"); + return newReader(ch, charset.newDecoder(), -1); + } + + /** * Constructs a writer that encodes characters using the given encoder and * writes the resulting bytes to the given channel. * @@ -595,7 +627,7 @@ * behaves in exactly the same way as the expression * *

 {@code
-     *     Channels.newWriter(ch, Charset.forName(csName).newEncoder(), -1)
+     *     Channels.newWriter(ch, Charset.forName(csName))
      * } 
* * @param ch @@ -616,4 +648,38 @@ Objects.requireNonNull(csName, "csName"); return newWriter(ch, Charset.forName(csName).newEncoder(), -1); } + + /** + * Constructs a writer that encodes characters according to the given + * charset and writes the resulting bytes to the given channel. + * + *

An invocation of this method of the form + * + *

 {@code
+     *     Channels.newWriter(ch, charset)
+     * } 
+ * + * behaves in exactly the same way as the expression + * + *
 {@code
+     *     Channels.newWriter(ch, Charset.forName(csName).newEncoder(), -1)
+     * } 
+ * + *

The writer's default action for malformed-input and unmappable-character + * errors is to {@linkplain java.nio.charset.CodingErrorAction#REPORT report} + * them. When more control over the error handling is required, the constructor + * that takes a {@linkplain java.nio.charset.CharsetEncoder} should be used. + * + * @param ch + * The channel to which bytes will be written + * + * @param charset + * The charset to be used + * + * @return A new writer + */ + public static Writer newWriter(WritableByteChannel ch, Charset charset) { + Objects.requireNonNull(charset, "charset"); + return newWriter(ch, charset.newEncoder(), -1); } +} diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/text/DateFormat.java --- a/src/java.base/share/classes/java/text/DateFormat.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/text/DateFormat.java Wed Dec 13 10:25:38 2017 -0800 @@ -97,6 +97,13 @@ * DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE); * } * + * + *

If the specified locale contains "ca" (calendar), "rg" (region override), + * and/or "tz" (timezone) Unicode + * extensions, the calendar, the country and/or the time zone for formatting + * are overridden. If both "ca" and "rg" are specified, the calendar from the "ca" + * extension supersedes the implicit one from the "rg" extension. + * *

You can use a DateFormat to parse also. *

*
{@code
diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/text/DateFormatSymbols.java
--- a/src/java.base/share/classes/java/text/DateFormatSymbols.java	Wed Dec 13 13:27:45 2017 +0530
+++ b/src/java.base/share/classes/java/text/DateFormatSymbols.java	Wed Dec 13 10:25:38 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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,6 +49,7 @@
 import java.util.ResourceBundle;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import sun.util.locale.provider.CalendarDataUtility;
 import sun.util.locale.provider.LocaleProviderAdapter;
 import sun.util.locale.provider.LocaleServiceProviderPool;
 import sun.util.locale.provider.ResourceBundleBasedAdapter;
@@ -82,6 +83,10 @@
  * 
*
* + *

If the locale contains "rg" (region override) + * Unicode extension, + * the symbols are overridden for the designated region. + * *

* DateFormatSymbols objects are cloneable. When you obtain * a DateFormatSymbols object, feel free to modify the @@ -716,15 +721,18 @@ } dfs = new DateFormatSymbols(false); + // check for region override + Locale override = CalendarDataUtility.findRegionOverride(locale); + // Initialize the fields from the ResourceBundle for locale. LocaleProviderAdapter adapter - = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale); + = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, override); // Avoid any potential recursions if (!(adapter instanceof ResourceBundleBasedAdapter)) { adapter = LocaleProviderAdapter.getResourceBundleBased(); } ResourceBundle resource - = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(locale); + = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(override); dfs.locale = locale; // JRE and CLDR use different keys diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/text/DecimalFormatSymbols.java --- a/src/java.base/share/classes/java/text/DecimalFormatSymbols.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/text/DecimalFormatSymbols.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2017, 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.text.spi.DecimalFormatSymbolsProvider; import java.util.Currency; import java.util.Locale; +import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleServiceProviderPool; import sun.util.locale.provider.ResourceBundleBasedAdapter; @@ -56,6 +57,10 @@ * of these symbols, you can get the DecimalFormatSymbols object from * your DecimalFormat and modify it. * + *

If the locale contains "rg" (region override) + * Unicode extension, + * the symbols are overridden for the designated region. + * * @see java.util.Locale * @see DecimalFormat * @author Mark Davis @@ -609,13 +614,18 @@ private void initialize( Locale locale ) { this.locale = locale; + // check for region override + Locale override = locale.getUnicodeLocaleType("nu") == null ? + CalendarDataUtility.findRegionOverride(locale) : + locale; + // get resource bundle data - LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale); + LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, override); // Avoid potential recursions if (!(adapter instanceof ResourceBundleBasedAdapter)) { adapter = LocaleProviderAdapter.getResourceBundleBased(); } - Object[] data = adapter.getLocaleResources(locale).getDecimalFormatSymbolsData(); + Object[] data = adapter.getLocaleResources(override).getDecimalFormatSymbolsData(); String[] numberElements = (String[]) data[0]; decimalSeparator = numberElements[0].charAt(0); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/text/NumberFormat.java --- a/src/java.base/share/classes/java/text/NumberFormat.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/text/NumberFormat.java Wed Dec 13 10:25:38 2017 -0800 @@ -96,7 +96,14 @@ * NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH); * } * - * You can also use a NumberFormat to parse numbers: + * + *

If the locale contains "nu" (numbers) and/or "rg" (region override) + * Unicode extensions, + * the decimal digits, and/or the country used for formatting are overridden. + * If both "nu" and "rg" are specified, the decimal digits from the "nu" + * extension supersedes the implicit one from the "rg" extension. + * + *

You can also use a {@code NumberFormat} to parse numbers: *

*
{@code
  * myNumber = nf.parse(myString);
diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/text/SimpleDateFormat.java
--- a/src/java.base/share/classes/java/text/SimpleDateFormat.java	Wed Dec 13 13:27:45 2017 +0530
+++ b/src/java.base/share/classes/java/text/SimpleDateFormat.java	Wed Dec 13 10:25:38 2017 -0800
@@ -672,7 +672,7 @@
             // However, the calendar should use the current default TimeZone.
             // If this is not contained in the locale zone strings, then the zone
             // will be formatted using generic GMT+/-H:MM nomenclature.
-            calendar = Calendar.getInstance(TimeZone.getDefault(), loc);
+            calendar = Calendar.getInstance(loc);
         }
     }
 
diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/time/format/DateTimeFormatter.java
--- a/src/java.base/share/classes/java/time/format/DateTimeFormatter.java	Wed Dec 13 13:27:45 2017 +0530
+++ b/src/java.base/share/classes/java/time/format/DateTimeFormatter.java	Wed Dec 13 10:25:38 2017 -0800
@@ -97,6 +97,7 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import sun.util.locale.provider.TimeZoneNameUtility;
 
 /**
  * Formatter for printing and parsing date-time objects.
@@ -548,7 +549,7 @@
      * For example, {@code d MMM uuuu} will format 2011-12-03 as '3 Dec 2011'.
      * 

* The formatter will use the {@link Locale#getDefault(Locale.Category) default FORMAT locale}. - * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter + * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter. * Alternatively use the {@link #ofPattern(String, Locale)} variant of this method. *

* The returned formatter has no override chronology or zone. @@ -572,7 +573,7 @@ * For example, {@code d MMM uuuu} will format 2011-12-03 as '3 Dec 2011'. *

* The formatter will use the specified locale. - * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter + * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter. *

* The returned formatter has no override chronology or zone. * It uses {@link ResolverStyle#SMART SMART} resolver style. @@ -1443,10 +1444,17 @@ * This is used to lookup any part of the formatter needing specific * localization, such as the text or localized pattern. *

+ * The locale is stored as passed in, without further processing. + * If the locale has + * Unicode extensions, they may be used later in text + * processing. To set the chronology, time-zone and decimal style from + * unicode extensions, see {@link #localizedBy localizedBy()}. + *

* This instance is immutable and unaffected by this method call. * * @param locale the new locale, not null * @return a formatter based on this formatter with the requested locale, not null + * @see #localizedBy(Locale) */ public DateTimeFormatter withLocale(Locale locale) { if (this.locale.equals(locale)) { @@ -1455,6 +1463,52 @@ return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone); } + /** + * Returns a copy of this formatter with localized values of the locale, + * calendar, region, decimal style and/or timezone, that supercede values in + * this formatter. + *

+ * This is used to lookup any part of the formatter needing specific + * localization, such as the text or localized pattern. If the locale contains the + * "ca" (calendar), "nu" (numbering system), "rg" (region override), and/or + * "tz" (timezone) + * Unicode extensions, + * the chronology, numbering system and/or the zone are overridden. If both "ca" + * and "rg" are specified, the chronology from the "ca" extension supersedes the + * implicit one from the "rg" extension. Same is true for the "nu" extension. + *

+ * Unlike the {@link #withLocale withLocale} method, the call to this method may + * produce a different formatter depending on the order of method chaining with + * other withXXXX() methods. + *

+ * This instance is immutable and unaffected by this method call. + * + * @param locale the locale, not null + * @return a formatter based on this formatter with localized values of + * the calendar, decimal style and/or timezone, that supercede values in this + * formatter. + * @see #withLocale(Locale) + * @since 10 + */ + public DateTimeFormatter localizedBy(Locale locale) { + if (this.locale.equals(locale)) { + return this; + } + + // Check for decimalStyle/chronology/timezone in locale object + Chronology c = locale.getUnicodeLocaleType("ca") != null ? + Chronology.ofLocale(locale) : chrono; + DecimalStyle ds = locale.getUnicodeLocaleType("nu") != null ? + DecimalStyle.of(locale) : decimalStyle; + String tzType = locale.getUnicodeLocaleType("tz"); + ZoneId z = tzType != null ? + TimeZoneNameUtility.convertLDMLShortID(tzType) + .map(ZoneId::of) + .orElse(zone) : + zone; + return new DateTimeFormatter(printerParser, locale, ds, resolverStyle, resolverFields, c, z); + } + //----------------------------------------------------------------------- /** * Gets the DecimalStyle to be used during formatting. diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java --- a/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -120,6 +120,7 @@ import java.util.concurrent.ConcurrentMap; import sun.text.spi.JavaTimeDateTimePatternProvider; +import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; import sun.util.locale.provider.TimeZoneNameUtility; @@ -198,6 +199,10 @@ * Gets the formatting pattern for date and time styles for a locale and chronology. * The locale and chronology are used to lookup the locale specific format * for the requested dateStyle and/or timeStyle. + *

+ * If the locale contains the "rg" (region override) + * Unicode extensions, + * the formatting pattern is overridden with the one appropriate for the region. * * @param dateStyle the FormatStyle for the date, null for time-only pattern * @param timeStyle the FormatStyle for the time, null for date-only pattern @@ -216,7 +221,8 @@ LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(JavaTimeDateTimePatternProvider.class, locale); JavaTimeDateTimePatternProvider provider = adapter.getJavaTimeDateTimePatternProvider(); String pattern = provider.getJavaTimeDateTimePattern(convertStyle(timeStyle), - convertStyle(dateStyle), chrono.getCalendarType(), locale); + convertStyle(dateStyle), chrono.getCalendarType(), + CalendarDataUtility.findRegionOverride(locale)); return pattern; } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/time/format/DateTimeTextProvider.java --- a/src/java.base/share/classes/java/time/format/DateTimeTextProvider.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/time/format/DateTimeTextProvider.java Wed Dec 13 10:25:38 2017 -0800 @@ -510,7 +510,8 @@ @SuppressWarnings("unchecked") static T getLocalizedResource(String key, Locale locale) { LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale); + .getLocaleResources( + CalendarDataUtility.findRegionOverride(locale)); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey(key) ? (T) rb.getObject(key) : null; } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/time/format/DecimalStyle.java --- a/src/java.base/share/classes/java/time/format/DecimalStyle.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/time/format/DecimalStyle.java Wed Dec 13 10:25:38 2017 -0800 @@ -147,6 +147,11 @@ * Obtains the DecimalStyle for the specified locale. *

* This method provides access to locale sensitive decimal style symbols. + * If the locale contains "nu" (Numbering System) and/or "rg" + * (Region Override) + * Unicode extensions, returned instance will reflect the values specified with + * those extensions. If both "nu" and "rg" are specified, the value from + * the "nu" extension supersedes the implicit one from the "rg" extension. * * @param locale the locale, not null * @return the decimal style, not null diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/time/temporal/ChronoField.java --- a/src/java.base/share/classes/java/time/temporal/ChronoField.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/time/temporal/ChronoField.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -79,6 +79,7 @@ import java.util.Locale; import java.util.Objects; import java.util.ResourceBundle; +import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; @@ -632,7 +633,9 @@ } LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale); + .getLocaleResources( + CalendarDataUtility + .findRegionOverride(locale)); ResourceBundle rb = lr.getJavaTimeFormatData(); String key = "field." + displayNameKey; return rb.containsKey(key) ? rb.getString(key) : name; diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/time/temporal/IsoFields.java --- a/src/java.base/share/classes/java/time/temporal/IsoFields.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/time/temporal/IsoFields.java Wed Dec 13 10:25:38 2017 -0800 @@ -81,6 +81,7 @@ import java.util.Objects; import java.util.ResourceBundle; +import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; @@ -430,7 +431,9 @@ public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale); + .getLocaleResources( + CalendarDataUtility + .findRegionOverride(locale)); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : toString(); } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/time/temporal/WeekFields.java --- a/src/java.base/share/classes/java/time/temporal/WeekFields.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/time/temporal/WeekFields.java Wed Dec 13 10:25:38 2017 -0800 @@ -286,13 +286,17 @@ * Obtains an instance of {@code WeekFields} appropriate for a locale. *

* This will look up appropriate values from the provider of localization data. + * If the locale contains "fw" (First day of week) and/or "rg" + * (Region Override) + * Unicode extensions, returned instance will reflect the values specified with + * those extensions. If both "fw" and "rg" are specified, the value from + * the "fw" extension supersedes the implicit one from the "rg" extension. * * @param locale the locale to use, not null * @return the week-definition, not null */ public static WeekFields of(Locale locale) { Objects.requireNonNull(locale, "locale"); - locale = new Locale(locale.getLanguage(), locale.getCountry()); // elminate variants int calDow = CalendarDataUtility.retrieveFirstDayOfWeek(locale); DayOfWeek dow = DayOfWeek.SUNDAY.plus(calDow - 1); @@ -1041,7 +1045,8 @@ Objects.requireNonNull(locale, "locale"); if (rangeUnit == YEARS) { // only have values for week-of-year LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale); + .getLocaleResources( + CalendarDataUtility.findRegionOverride(locale)); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : name; } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/Calendar.java --- a/src/java.base/share/classes/java/util/Calendar.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/Calendar.java Wed Dec 13 10:25:38 2017 -0800 @@ -58,6 +58,7 @@ import sun.util.calendar.ZoneInfo; import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.TimeZoneNameUtility; import sun.util.spi.CalendarProvider; /** @@ -128,9 +129,14 @@ * * Calendar defines a locale-specific seven day week using two * parameters: the first day of the week and the minimal days in first week - * (from 1 to 7). These numbers are taken from the locale resource data when a - * Calendar is constructed. They may also be specified explicitly - * through the methods for setting their values. + * (from 1 to 7). These numbers are taken from the locale resource data or the + * locale itself when a {@code Calendar} is constructed. If the designated + * locale contains "fw" and/or "rg" + * Unicode extensions, the first day of the week will be obtained according to + * those extensions. If both "fw" and "rg" are specified, the value from the "fw" + * extension supersedes the implicit one from the "rg" extension. + * They may also be specified explicitly through the methods for setting their + * values. * *

When setting or getting the WEEK_OF_MONTH or * WEEK_OF_YEAR fields, Calendar must determine the @@ -1444,6 +1450,11 @@ * *

The default values are used for locale and time zone if these * parameters haven't been given explicitly. + *

+ * If the locale contains the time zone with "tz" + * Unicode extension, + * and time zone hasn't been given explicitly, time zone in the locale + * is used. * *

Any out of range field values are either normalized in lenient * mode or detected as an invalid value in non-lenient mode. @@ -1463,7 +1474,7 @@ locale = Locale.getDefault(); } if (zone == null) { - zone = TimeZone.getDefault(); + zone = defaultTimeZone(locale); } Calendar cal; if (type == null) { @@ -1605,12 +1616,17 @@ * Calendar returned is based on the current time * in the default time zone with the default * {@link Locale.Category#FORMAT FORMAT} locale. + *

+ * If the locale contains the time zone with "tz" + * Unicode extension, + * that time zone is used instead. * * @return a Calendar. */ public static Calendar getInstance() { - return createCalendar(TimeZone.getDefault(), Locale.getDefault(Locale.Category.FORMAT)); + Locale aLocale = Locale.getDefault(Locale.Category.FORMAT); + return createCalendar(defaultTimeZone(aLocale), aLocale); } /** @@ -1631,13 +1647,17 @@ * Gets a calendar using the default time zone and specified locale. * The Calendar returned is based on the current time * in the default time zone with the given locale. + *

+ * If the locale contains the time zone with "tz" + * Unicode extension, + * that time zone is used instead. * * @param aLocale the locale for the week data * @return a Calendar. */ public static Calendar getInstance(Locale aLocale) { - return createCalendar(TimeZone.getDefault(), aLocale); + return createCalendar(defaultTimeZone(aLocale), aLocale); } /** @@ -1655,6 +1675,16 @@ return createCalendar(zone, aLocale); } + private static TimeZone defaultTimeZone(Locale l) { + TimeZone defaultTZ = TimeZone.getDefault(); + String shortTZID = l.getUnicodeLocaleType("tz"); + return shortTZID != null ? + TimeZoneNameUtility.convertLDMLShortID(shortTZID) + .map(TimeZone::getTimeZone) + .orElse(defaultTZ) : + defaultTZ; + } + private static Calendar createCalendar(TimeZone zone, Locale aLocale) { diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/Collections.java --- a/src/java.base/share/classes/java/util/Collections.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/Collections.java Wed Dec 13 10:25:38 2017 -0800 @@ -24,9 +24,10 @@ */ package java.util; -import java.io.Serializable; + +import java.io.IOException; import java.io.ObjectOutputStream; -import java.io.IOException; +import java.io.Serializable; import java.lang.reflect.Array; import java.util.function.BiConsumer; import java.util.function.BiFunction; @@ -5164,14 +5165,19 @@ * specified comparator. * @since 1.5 */ + @SuppressWarnings("unchecked") public static Comparator reverseOrder(Comparator cmp) { - if (cmp == null) - return reverseOrder(); - - if (cmp instanceof ReverseComparator2) - return ((ReverseComparator2)cmp).cmp; - - return new ReverseComparator2<>(cmp); + if (cmp == null) { + return (Comparator) ReverseComparator.REVERSE_ORDER; + } else if (cmp == ReverseComparator.REVERSE_ORDER) { + return (Comparator) Comparators.NaturalOrderComparator.INSTANCE; + } else if (cmp == Comparators.NaturalOrderComparator.INSTANCE) { + return (Comparator) ReverseComparator.REVERSE_ORDER; + } else if (cmp instanceof ReverseComparator2) { + return ((ReverseComparator2) cmp).cmp; + } else { + return new ReverseComparator2<>(cmp); + } } /** diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/Currency.java --- a/src/java.base/share/classes/java/util/Currency.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/Currency.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,6 @@ import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileReader; import java.io.InputStream; import java.io.IOException; @@ -42,6 +41,7 @@ import java.util.regex.Pattern; import java.util.regex.Matcher; import java.util.spi.CurrencyNameProvider; +import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleServiceProviderPool; import sun.util.logging.PlatformLogger; @@ -348,6 +348,13 @@ * until December 31, 2001, and the Euro from January 1, 2002, local time * of the respective countries. *

+ * If the specified {@code locale} contains "cu" and/or "rg" + * Unicode extensions, + * the instance returned from this method reflects + * the values specified with those extensions. If both "cu" and "rg" are + * specified, the currency from the "cu" extension supersedes the implicit one + * from the "rg" extension. + *

* The method returns null for territories that don't * have a currency, such as Antarctica. * @@ -361,12 +368,19 @@ * is not a supported ISO 3166 country code. */ public static Currency getInstance(Locale locale) { - String country = locale.getCountry(); - if (country == null) { - throw new NullPointerException(); + // check for locale overrides + String override = locale.getUnicodeLocaleType("cu"); + if (override != null) { + try { + return getInstance(override.toUpperCase(Locale.ROOT)); + } catch (IllegalArgumentException iae) { + // override currency is invalid. Fall through. + } } - if (country.length() != 2) { + String country = CalendarDataUtility.findRegionOverride(locale).getCountry(); + + if (country == null || !country.matches("^[a-zA-Z]{2}$")) { throw new IllegalArgumentException(); } @@ -482,6 +496,12 @@ * locale is the US, while for other locales it may be "US$". If no * symbol can be determined, the ISO 4217 currency code is returned. *

+ * If the default {@link Locale.Category#DISPLAY DISPLAY} locale + * contains "rg" (region override) + * Unicode extension, + * the symbol returned from this method reflects + * the value specified with that extension. + *

* This is equivalent to calling * {@link #getSymbol(Locale) * getSymbol(Locale.getDefault(Locale.Category.DISPLAY))}. @@ -498,6 +518,11 @@ * For example, for the US Dollar, the symbol is "$" if the specified * locale is the US, while for other locales it may be "US$". If no * symbol can be determined, the ISO 4217 currency code is returned. + *

+ * If the specified {@code locale} contains "rg" (region override) + * Unicode extension, + * the symbol returned from this method reflects + * the value specified with that extension. * * @param locale the locale for which a display name for this currency is * needed @@ -507,6 +532,7 @@ public String getSymbol(Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CurrencyNameProvider.class); + locale = CalendarDataUtility.findRegionOverride(locale); String symbol = pool.getLocalizedObject( CurrencyNameGetter.INSTANCE, locale, currencyCode, SYMBOL); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/Formatter.java --- a/src/java.base/share/classes/java/util/Formatter.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/Formatter.java Wed Dec 13 10:25:38 2017 -0800 @@ -2137,6 +2137,39 @@ } /** + * Constructs a new formatter with the specified file name, charset, and + * locale. + * + * @param fileName + * The name of the file to use as the destination of this + * formatter. If the file exists then it will be truncated to + * zero size; otherwise, a new file will be created. The output + * will be written to the file and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @param l + * The {@linkplain java.util.Locale locale} to apply during + * formatting. If {@code l} is {@code null} then no localization + * is applied. + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(fileName)} denies write + * access to the file + * + * @throws NullPointerException + * if {@code fileName} or {@code charset} is {@code null}. + */ + public Formatter(String fileName, Charset charset, Locale l) throws IOException { + this(Objects.requireNonNull(charset, "charset"), l, new File(fileName)); + } + + /** * Constructs a new formatter with the specified file. * *

The charset used is the {@linkplain @@ -2248,6 +2281,40 @@ } /** + * Constructs a new formatter with the specified file, charset, and + * locale. + * + * @param file + * The file to use as the destination of this formatter. If the + * file exists then it will be truncated to zero size; otherwise, + * a new file will be created. The output will be written to the + * file and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @param l + * The {@linkplain java.util.Locale locale} to apply during + * formatting. If {@code l} is {@code null} then no localization + * is applied. + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(file.getPath())} denies + * write access to the file + * + * @throws NullPointerException + * if {@code file} or {@code charset} is {@code null}. + */ + public Formatter(File file, Charset charset, Locale l) throws IOException { + this(Objects.requireNonNull(charset, "charset"), l, file); + } + + + /** * Constructs a new formatter with the specified print stream. * *

The locale used is the {@linkplain @@ -2340,6 +2407,29 @@ this(l, new BufferedWriter(new OutputStreamWriter(os, csn))); } + /** + * Constructs a new formatter with the specified output stream, charset, + * and locale. + * + * @param os + * The output stream to use as the destination of this formatter. + * The output will be buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @param l + * The {@linkplain java.util.Locale locale} to apply during + * formatting. If {@code l} is {@code null} then no localization + * is applied. + * + * @throws NullPointerException + * if {@code os} or {@code charset} is {@code null}. + */ + public Formatter(OutputStream os, Charset charset, Locale l) { + this(l, new BufferedWriter(new OutputStreamWriter(os, charset))); + } + private static char getZero(Locale l) { if ((l != null) && !l.equals(Locale.US)) { DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(l); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/Locale.java --- a/src/java.base/share/classes/java/util/Locale.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/Locale.java Wed Dec 13 10:25:38 2017 -0800 @@ -48,6 +48,7 @@ import java.text.MessageFormat; import java.util.concurrent.ConcurrentHashMap; import java.util.spi.LocaleNameProvider; +import java.util.stream.Collectors; import sun.security.action.GetPropertyAction; import sun.util.locale.BaseLocale; @@ -62,6 +63,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; import sun.util.locale.provider.LocaleServiceProviderPool; +import sun.util.locale.provider.TimeZoneNameUtility; /** * A Locale object represents a specific geographical, political, @@ -665,10 +667,12 @@ /** * Display types for retrieving localized names from the name providers. */ - private static final int DISPLAY_LANGUAGE = 0; - private static final int DISPLAY_COUNTRY = 1; - private static final int DISPLAY_VARIANT = 2; - private static final int DISPLAY_SCRIPT = 3; + private static final int DISPLAY_LANGUAGE = 0; + private static final int DISPLAY_COUNTRY = 1; + private static final int DISPLAY_VARIANT = 2; + private static final int DISPLAY_SCRIPT = 3; + private static final int DISPLAY_UEXT_KEY = 4; + private static final int DISPLAY_UEXT_TYPE = 5; /** * Private constructor used by getInstance method @@ -942,11 +946,14 @@ variant = props.getProperty("user.variant", ""); } - return getInstance(language, script, country, variant, null); + return getInstance(language, script, country, variant, + getDefaultExtensions(props.getProperty("user.extensions", "")) + .orElse(null)); } private static Locale initDefault(Locale.Category category) { Properties props = GetPropertyAction.privilegedGetProperties(); + return getInstance( props.getProperty(category.languageKey, defaultLocale.getLanguage()), @@ -956,7 +963,22 @@ defaultLocale.getCountry()), props.getProperty(category.variantKey, defaultLocale.getVariant()), - null); + getDefaultExtensions(props.getProperty(category.extensionsKey, "")) + .orElse(defaultLocale.getLocaleExtensions())); + } + + private static Optional getDefaultExtensions(String extensionsProp) { + LocaleExtensions exts = null; + + try { + exts = new InternalLocaleBuilder() + .setExtensions(extensionsProp) + .getLocaleExtensions(); + } catch (LocaleSyntaxException e) { + // just ignore this incorrect property + } + + return Optional.ofNullable(exts); } /** @@ -1771,7 +1793,7 @@ * @exception NullPointerException if inLocale is null */ public String getDisplayLanguage(Locale inLocale) { - return getDisplayString(baseLocale.getLanguage(), inLocale, DISPLAY_LANGUAGE); + return getDisplayString(baseLocale.getLanguage(), null, inLocale, DISPLAY_LANGUAGE); } /** @@ -1801,7 +1823,7 @@ * @since 1.7 */ public String getDisplayScript(Locale inLocale) { - return getDisplayString(baseLocale.getScript(), inLocale, DISPLAY_SCRIPT); + return getDisplayString(baseLocale.getScript(), null, inLocale, DISPLAY_SCRIPT); } /** @@ -1844,29 +1866,24 @@ * @exception NullPointerException if inLocale is null */ public String getDisplayCountry(Locale inLocale) { - return getDisplayString(baseLocale.getRegion(), inLocale, DISPLAY_COUNTRY); + return getDisplayString(baseLocale.getRegion(), null, inLocale, DISPLAY_COUNTRY); } - private String getDisplayString(String code, Locale inLocale, int type) { - if (code.length() == 0) { + private String getDisplayString(String code, String cat, Locale inLocale, int type) { + Objects.requireNonNull(inLocale); + Objects.requireNonNull(code); + + if (code.isEmpty()) { return ""; } - if (inLocale == null) { - throw new NullPointerException(); - } - LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(LocaleNameProvider.class); - String key = (type == DISPLAY_VARIANT ? "%%"+code : code); + String rbKey = (type == DISPLAY_VARIANT ? "%%"+code : code); String result = pool.getLocalizedObject( LocaleNameGetter.INSTANCE, - inLocale, key, type, code); - if (result != null) { - return result; - } - - return code; + inLocale, rbKey, type, code, cat); + return result != null ? result : code; } /** @@ -1894,29 +1911,31 @@ if (baseLocale.getVariant().length() == 0) return ""; - LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale); + LocaleResources lr = LocaleProviderAdapter + .getResourceBundleBased() + .getLocaleResources(inLocale); String names[] = getDisplayVariantArray(inLocale); // Get the localized patterns for formatting a list, and use // them to format the list. return formatList(names, - lr.getLocaleName("ListPattern"), lr.getLocaleName("ListCompositionPattern")); } /** * Returns a name for the locale that is appropriate for display to the * user. This will be the values returned by getDisplayLanguage(), - * getDisplayScript(), getDisplayCountry(), and getDisplayVariant() assembled - * into a single string. The non-empty values are used in order, - * with the second and subsequent names in parentheses. For example: + * getDisplayScript(), getDisplayCountry(), getDisplayVariant() and + * optional Unicode extensions + * assembled into a single string. The non-empty values are used in order, with + * the second and subsequent names in parentheses. For example: *

- * language (script, country, variant)
- * language (country)
- * language (variant)
- * script (country)
- * country
+ * language (script, country, variant(, extension)*)
+ * language (country(, extension)*)
+ * language (variant(, extension)*)
+ * script (country(, extension)*)
+ * country (extension)*
*
* depending on which fields are specified in the locale. If the * language, script, country, and variant fields are all empty, @@ -1931,16 +1950,17 @@ /** * Returns a name for the locale that is appropriate for display * to the user. This will be the values returned by - * getDisplayLanguage(), getDisplayScript(),getDisplayCountry(), - * and getDisplayVariant() assembled into a single string. - * The non-empty values are used in order, - * with the second and subsequent names in parentheses. For example: + * getDisplayLanguage(), getDisplayScript(),getDisplayCountry() + * getDisplayVariant(), and optional + * Unicode extensions assembled into a single string. The non-empty + * values are used in order, with the second and subsequent names in + * parentheses. For example: *
- * language (script, country, variant)
- * language (country)
- * language (variant)
- * script (country)
- * country
+ * language (script, country, variant(, extension)*)
+ * language (country(, extension)*)
+ * language (variant(, extension)*)
+ * script (country(, extension)*)
+ * country (extension)*
*
* depending on which fields are specified in the locale. If the * language, script, country, and variant fields are all empty, @@ -1951,7 +1971,9 @@ * @throws NullPointerException if inLocale is null */ public String getDisplayName(Locale inLocale) { - LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale); + LocaleResources lr = LocaleProviderAdapter + .getResourceBundleBased() + .getLocaleResources(inLocale); String languageName = getDisplayLanguage(inLocale); String scriptName = getDisplayScript(inLocale); @@ -1960,7 +1982,6 @@ // Get the localized patterns for formatting a display name. String displayNamePattern = lr.getLocaleName("DisplayNamePattern"); - String listPattern = lr.getLocaleName("ListPattern"); String listCompositionPattern = lr.getLocaleName("ListCompositionPattern"); // The display name consists of a main name, followed by qualifiers. @@ -1977,7 +1998,7 @@ if (variantNames.length == 0) { return ""; } else { - return formatList(variantNames, listPattern, listCompositionPattern); + return formatList(variantNames, listCompositionPattern); } } ArrayList names = new ArrayList<>(4); @@ -1994,6 +2015,16 @@ names.addAll(Arrays.asList(variantNames)); } + // add Unicode extensions + if (localeExtensions != null) { + localeExtensions.getUnicodeLocaleAttributes().stream() + .map(key -> getDisplayString(key, null, inLocale, DISPLAY_UEXT_KEY)) + .forEach(names::add); + localeExtensions.getUnicodeLocaleKeys().stream() + .map(key -> getDisplayKeyTypeExtensionString(key, lr, inLocale)) + .forEach(names::add); + } + // The first one in the main name mainName = names.get(0); @@ -2014,7 +2045,7 @@ // list case, but this is more efficient, and we want it to be // efficient since all the language-only locales will not have any // qualifiers. - qualifierNames.length != 0 ? formatList(qualifierNames, listPattern, listCompositionPattern) : null + qualifierNames.length != 0 ? formatList(qualifierNames, listCompositionPattern) : null }; if (displayNamePattern != null) { @@ -2121,74 +2152,78 @@ // For each variant token, lookup the display name. If // not found, use the variant name itself. for (int i=0; i 3) { - MessageFormat format = new MessageFormat(listCompositionPattern); - stringList = composeList(format, stringList); + if (pattern == null) { + return Arrays.stream(stringList).collect(Collectors.joining(",")); } - // Rebuild the argument list with the list length as the first element - Object[] args = new Object[stringList.length + 1]; - System.arraycopy(stringList, 0, args, 1, stringList.length); - args[0] = stringList.length; - - // Format it using the pattern in the resource - MessageFormat format = new MessageFormat(listPattern); - return format.format(args); - } - - /** - * Given a list of strings, return a list shortened to three elements. - * Shorten it by applying the given format to the first two elements - * recursively. - * @param format a format which takes two arguments - * @param list a list of strings - * @return if the list is three elements or shorter, the same list; - * otherwise, a new list of three elements. - */ - private static String[] composeList(MessageFormat format, String[] list) { - if (list.length <= 3) return list; - - // Use the given format to compose the first two elements into one - String[] listItems = { list[0], list[1] }; - String newItem = format.format(listItems); - - // Form a new list one element shorter - String[] newList = new String[list.length-1]; - System.arraycopy(list, 2, newList, 1, newList.length-1); - newList[0] = newItem; - - // Recurse - return composeList(format, newList); + switch (stringList.length) { + case 0: + return ""; + case 1: + return stringList[0]; + default: + return Arrays.stream(stringList).reduce("", + (s1, s2) -> { + if (s1.equals("")) { + return s2; + } + if (s2.equals("")) { + return s1; + } + return MessageFormat.format(pattern, s1, s2); + }); + } } // Duplicate of sun.util.locale.UnicodeLocaleExtension.isKey in order to @@ -2345,9 +2380,10 @@ Locale locale, String key, Object... params) { - assert params.length == 2; + assert params.length == 3; int type = (Integer)params[0]; String code = (String)params[1]; + String cat = (String)params[2]; switch(type) { case DISPLAY_LANGUAGE: @@ -2358,6 +2394,10 @@ return localeNameProvider.getDisplayVariant(code, locale); case DISPLAY_SCRIPT: return localeNameProvider.getDisplayScript(code, locale); + case DISPLAY_UEXT_KEY: + return localeNameProvider.getDisplayUnicodeExtensionKey(code, locale); + case DISPLAY_UEXT_TYPE: + return localeNameProvider.getDisplayUnicodeExtensionType(code, cat, locale); default: assert false; // shouldn't happen } @@ -2384,7 +2424,8 @@ DISPLAY("user.language.display", "user.script.display", "user.country.display", - "user.variant.display"), + "user.variant.display", + "user.extensions.display"), /** * Category used to represent the default locale for @@ -2393,19 +2434,23 @@ FORMAT("user.language.format", "user.script.format", "user.country.format", - "user.variant.format"); + "user.variant.format", + "user.extensions.format"); - Category(String languageKey, String scriptKey, String countryKey, String variantKey) { + Category(String languageKey, String scriptKey, String countryKey, + String variantKey, String extensionsKey) { this.languageKey = languageKey; this.scriptKey = scriptKey; this.countryKey = countryKey; this.variantKey = variantKey; + this.extensionsKey = extensionsKey; } final String languageKey; final String scriptKey; final String countryKey; final String variantKey; + final String extensionsKey; } /** diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/Properties.java --- a/src/java.base/share/classes/java/util/Properties.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/Properties.java Wed Dec 13 10:25:38 2017 -0800 @@ -37,6 +37,10 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.StreamCorruptedException; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.charset.IllegalCharsetNameException; +import java.nio.charset.UnsupportedCharsetException; import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiConsumer; import java.util.function.BiFunction; @@ -997,6 +1001,11 @@ * *

The specified stream remains open after this method returns. * + *

This method behaves the same as + * {@linkplain #storeToXML(OutputStream os, String comment, Charset charset)} + * except that it will {@linkplain java.nio.charset.Charset#forName look up the charset} + * using the given encoding name. + * * @param os the output stream on which to emit the XML document. * @param comment a description of the property list, or {@code null} * if no comment is desired. @@ -1011,20 +1020,67 @@ * @throws NullPointerException if {@code os} is {@code null}, * or if {@code encoding} is {@code null}. * @throws ClassCastException if this {@code Properties} object - * contains any keys or values that are not - * {@code Strings}. + * contains any keys or values that are not {@code Strings}. * @see #loadFromXML(InputStream) * @see Character * Encoding in Entities * @since 1.5 */ public void storeToXML(OutputStream os, String comment, String encoding) - throws IOException - { + throws IOException { Objects.requireNonNull(os); Objects.requireNonNull(encoding); + + try { + Charset charset = Charset.forName(encoding); + storeToXML(os, comment, charset); + } catch (IllegalCharsetNameException | UnsupportedCharsetException e) { + throw new UnsupportedEncodingException(encoding); + } + } + + /** + * Emits an XML document representing all of the properties contained + * in this table, using the specified encoding. + * + *

The XML document will have the following DOCTYPE declaration: + *

+     * <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+     * 
+ * + *

If the specified comment is {@code null} then no comment + * will be stored in the document. + * + *

An implementation is required to support writing of XML documents + * that use the "{@code UTF-8}" or "{@code UTF-16}" encoding. An + * implementation may support additional encodings. + * + *

Unmappable characters for the specified charset will be encoded as + * numeric character references. + * + *

The specified stream remains open after this method returns. + * + * @param os the output stream on which to emit the XML document. + * @param comment a description of the property list, or {@code null} + * if no comment is desired. + * @param charset the charset + * + * @throws IOException if writing to the specified output stream + * results in an {@code IOException}. + * @throws NullPointerException if {@code os} or {@code charset} is {@code null}. + * @throws ClassCastException if this {@code Properties} object + * contains any keys or values that are not {@code Strings}. + * @see #loadFromXML(InputStream) + * @see Character + * Encoding in Entities + * @since 10 + */ + public void storeToXML(OutputStream os, String comment, Charset charset) + throws IOException { + Objects.requireNonNull(os, "OutputStream"); + Objects.requireNonNull(charset, "Charset"); PropertiesDefaultHandler handler = new PropertiesDefaultHandler(); - handler.store(this, os, comment, encoding); + handler.store(this, os, comment, charset); } /** diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/Scanner.java --- a/src/java.base/share/classes/java/util/Scanner.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/Scanner.java Wed Dec 13 10:25:38 2017 -0800 @@ -33,10 +33,13 @@ import java.nio.file.Path; import java.nio.file.Files; import java.text.*; +import java.text.spi.NumberFormatProvider; import java.util.function.Consumer; import java.util.regex.*; import java.util.stream.Stream; import java.util.stream.StreamSupport; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.ResourceBundleBasedAdapter; /** * A simple text scanner which can parse primitive types and strings using @@ -575,7 +578,21 @@ * does not exist */ public Scanner(InputStream source, String charsetName) { - this(makeReadable(Objects.requireNonNull(source, "source"), toCharset(charsetName)), + this(source, toCharset(charsetName)); + } + + /** + * Constructs a new {@code Scanner} that produces values scanned + * from the specified input stream. Bytes from the stream are converted + * into characters using the specified charset. + * + * @param source an input stream to be scanned + * @param charset the charset used to convert bytes from the file + * into characters to be scanned + * @since 10 + */ + public Scanner(InputStream source, Charset charset) { + this(makeReadable(Objects.requireNonNull(source, "source"), charset), WHITESPACE_PATTERN); } @@ -594,7 +611,18 @@ } } + /* + * This method is added so that null-check on charset can be performed before + * creating InputStream as an existing test required it. + */ + private static Readable makeReadable(Path source, Charset charset) + throws IOException { + Objects.requireNonNull(charset, "charset"); + return makeReadable(Files.newInputStream(source), charset); + } + private static Readable makeReadable(InputStream source, Charset charset) { + Objects.requireNonNull(charset, "charset"); return new InputStreamReader(source, charset); } @@ -629,6 +657,22 @@ this(Objects.requireNonNull(source), toDecoder(charsetName)); } + /** + * Constructs a new {@code Scanner} that produces values scanned + * from the specified file. Bytes from the file are converted into + * characters using the specified charset. + * + * @param source A file to be scanned + * @param charset The charset used to convert bytes from the file + * into characters to be scanned + * @throws IOException + * if an I/O error occurs opening the source + * @since 10 + */ + public Scanner(File source, Charset charset) throws IOException { + this(Objects.requireNonNull(source), charset.newDecoder()); + } + private Scanner(File source, CharsetDecoder dec) throws FileNotFoundException { @@ -649,6 +693,12 @@ return Channels.newReader(source, dec, -1); } + private static Readable makeReadable(ReadableByteChannel source, + Charset charset) { + Objects.requireNonNull(charset, "charset"); + return Channels.newReader(source, charset); + } + /** * Constructs a new {@code Scanner} that produces values scanned * from the specified file. Bytes from the file are converted into @@ -688,8 +738,22 @@ this(Objects.requireNonNull(source), toCharset(charsetName)); } - private Scanner(Path source, Charset charset) throws IOException { - this(makeReadable(Files.newInputStream(source), charset)); + /** + * Constructs a new {@code Scanner} that produces values scanned + * from the specified file. Bytes from the file are converted into + * characters using the specified charset. + * + * @param source + * the path to the file to be scanned + * @param charset + * the charset used to convert bytes from the file + * into characters to be scanned + * @throws IOException + * if an I/O error occurs opening the source + * @since 10 + */ + public Scanner(Path source, Charset charset) throws IOException { + this(makeReadable(source, charset)); } /** @@ -735,6 +799,21 @@ WHITESPACE_PATTERN); } + /** + * Constructs a new {@code Scanner} that produces values scanned + * from the specified channel. Bytes from the source are converted into + * characters using the specified charset. + * + * @param source a channel to scan + * @param charset the encoding type used to convert bytes from the + * channel into characters to be scanned + * @since 10 + */ + public Scanner(ReadableByteChannel source, Charset charset) { + this(makeReadable(Objects.requireNonNull(source, "source"), charset), + WHITESPACE_PATTERN); + } + // Private primitives used to support scanning private void saveState() { @@ -1186,9 +1265,27 @@ modCount++; this.locale = locale; - DecimalFormat df = - (DecimalFormat)NumberFormat.getNumberInstance(locale); + + DecimalFormat df = null; + NumberFormat nf = NumberFormat.getNumberInstance(locale); DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale); + if (nf instanceof DecimalFormat) { + df = (DecimalFormat) nf; + } else { + + // In case where NumberFormat.getNumberInstance() returns + // other instance (non DecimalFormat) based on the provider + // used and java.text.spi.NumberFormatProvider implementations, + // DecimalFormat constructor is used to obtain the instance + LocaleProviderAdapter adapter = LocaleProviderAdapter + .getAdapter(NumberFormatProvider.class, locale); + if (!(adapter instanceof ResourceBundleBasedAdapter)) { + adapter = LocaleProviderAdapter.getResourceBundleBased(); + } + String[] all = adapter.getLocaleResources(locale) + .getNumberPatterns(); + df = new DecimalFormat(all[0], dfs); + } // These must be literalized to avoid collision with regex // metacharacters such as dot or parenthesis diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/SimpleTimeZone.java --- a/src/java.base/share/classes/java/util/SimpleTimeZone.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/SimpleTimeZone.java Wed Dec 13 10:25:38 2017 -0800 @@ -548,12 +548,11 @@ computeOffset: if (useDaylight) { - synchronized (this) { - if (cacheStart != 0) { - if (date >= cacheStart && date < cacheEnd) { - offset += dstSavings; - break computeOffset; - } + Cache cache = this.cache; + if (cache != null) { + if (date >= cache.start && date < cache.end) { + offset += dstSavings; + break computeOffset; } } BaseCalendar cal = date >= GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER ? @@ -671,14 +670,13 @@ } private int getOffset(BaseCalendar cal, BaseCalendar.Date cdate, int year, long time) { - synchronized (this) { - if (cacheStart != 0) { - if (time >= cacheStart && time < cacheEnd) { - return rawOffset + dstSavings; - } - if (year == cacheYear) { - return rawOffset; - } + Cache cache = this.cache; + if (cache != null) { + if (time >= cache.start && time < cache.end) { + return rawOffset + dstSavings; + } + if (year == cache.year) { + return rawOffset; } } @@ -689,11 +687,7 @@ if (time >= start && time < end) { offset += dstSavings; } - synchronized (this) { - cacheYear = year; - cacheStart = start; - cacheEnd = end; - } + this.cache = new Cache(year, start, end); } else { if (time < end) { // TODO: support Gregorian cutover. The previous year @@ -711,12 +705,7 @@ } } if (start <= end) { - synchronized (this) { - // The start and end transitions are in multiple years. - cacheYear = (long) startYear - 1; - cacheStart = start; - cacheEnd = end; - } + this.cache = new Cache((long) startYear - 1, start, end); } } return offset; @@ -876,7 +865,7 @@ * Generates the hash code for the SimpleDateFormat object. * @return the hash code for this object */ - public synchronized int hashCode() + public int hashCode() { return startMonth ^ startDay ^ startDayOfWeek ^ startTime ^ endMonth ^ endDay ^ endDayOfWeek ^ endTime ^ rawOffset; @@ -1201,19 +1190,27 @@ /** * Cache values representing a single period of daylight saving - * time. When the cache values are valid, cacheStart is the start - * time (inclusive) of daylight saving time and cacheEnd is the - * end time (exclusive). + * time. Cache.start is the start time (inclusive) of daylight + * saving time and Cache.end is the end time (exclusive). * - * cacheYear has a year value if both cacheStart and cacheEnd are - * in the same year. cacheYear is set to startYear - 1 if - * cacheStart and cacheEnd are in different years. cacheStart is 0 - * if the cache values are void. cacheYear is a long to support - * Integer.MIN_VALUE - 1 (JCK requirement). + * Cache.year has a year value if both Cache.start and Cache.end are + * in the same year. Cache.year is set to startYear - 1 if + * Cache.start and Cache.end are in different years. + * Cache.year is a long to support Integer.MIN_VALUE - 1 (JCK requirement). */ - private transient long cacheYear; - private transient long cacheStart; - private transient long cacheEnd; + private static final class Cache { + final long year; + final long start; + final long end; + + Cache(long year, long start, long end) { + this.year = year; + this.start = start; + this.end = end; + } + } + + private transient volatile Cache cache; /** * Constants specifying values of startMode and endMode. @@ -1282,9 +1279,8 @@ // Maximum number of rules. private static final int MAX_RULE_NUM = 6; - private synchronized void invalidateCache() { - cacheYear = startYear - 1; - cacheStart = cacheEnd = 0; + private void invalidateCache() { + cache = null; } //---------------------------------------------------------------------- diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/spi/LocaleNameProvider.java --- a/src/java.base/share/classes/java/util/spi/LocaleNameProvider.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/spi/LocaleNameProvider.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package java.util.spi; import java.util.Locale; +import java.util.Objects; /** * An abstract class for service providers that @@ -141,4 +142,54 @@ * @see java.util.Locale#getDisplayVariant(java.util.Locale) */ public abstract String getDisplayVariant(String variant, Locale locale); + + /** + * Returns a localized name for the given + * Unicode extension key, + * and the given locale that is appropriate for display to the user. + * If the name returned cannot be localized according to {@code locale}, + * this method returns null. + * @implSpec the default implementation returns {@code null}. + * @param key the Unicode Extension key, not null. + * @param locale the desired locale, not null. + * @return the name of the given key string for the specified locale, + * or null if it's not available. + * @exception NullPointerException if {@code key} or {@code locale} is null + * @exception IllegalArgumentException if {@code locale} isn't + * one of the locales returned from + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() + * getAvailableLocales()}. + * @since 10 + */ + public String getDisplayUnicodeExtensionKey(String key, Locale locale) { + Objects.requireNonNull(key); + Objects.requireNonNull(locale); + return null; + } + + /** + * Returns a localized name for the given + * Unicode extension type, + * and the given locale that is appropriate for display to the user. + * If the name returned cannot be localized according to {@code locale}, + * this method returns null. + * @implSpec the default implementation returns {@code null}. + * @param type the Unicode Extension type, not null. + * @param key the Unicode Extension key for this {@code type}, not null. + * @param locale the desired locale, not null. + * @return the name of the given type string for the specified locale, + * or null if it's not available. + * @exception NullPointerException if {@code key}, {@code type} or {@code locale} is null + * @exception IllegalArgumentException if {@code locale} isn't + * one of the locales returned from + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() + * getAvailableLocales()}. + * @since 10 + */ + public String getDisplayUnicodeExtensionType(String type, String key, Locale locale) { + Objects.requireNonNull(type); + Objects.requireNonNull(key); + Objects.requireNonNull(locale); + return null; + } } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/zip/Deflater.java --- a/src/java.base/share/classes/java/util/zip/Deflater.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/zip/Deflater.java Wed Dec 13 10:25:38 2017 -0800 @@ -67,12 +67,26 @@ * } *

* + * @apiNote + * To release resources used by this {@code Deflater}, the {@link #end()} method + * should be called explicitly. Subclasses are responsible for the cleanup of resources + * acquired by the subclass. Subclasses that override {@link #finalize()} in order + * to perform cleanup should be modified to use alternative cleanup mechanisms such + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method. + * + * @implSpec + * If this {@code Deflater} has been subclassed and the {@code end} method has been + * overridden, the {@code end} method will be called by the finalization when the + * deflater is unreachable. But the subclasses should not depend on this specific + * implementation; the finalization is not reliable and the {@code finalize} method + * is deprecated to be removed. + * * @see Inflater * @author David Connelly * @since 1.1 */ -public -class Deflater { + +public class Deflater { private final ZStreamRef zsRef; private byte[] buf = new byte[0]; @@ -169,7 +183,9 @@ public Deflater(int level, boolean nowrap) { this.level = level; this.strategy = DEFAULT_STRATEGY; - this.zsRef = new ZStreamRef(init(level, DEFAULT_STRATEGY, nowrap)); + this.zsRef = ZStreamRef.get(this, + () -> init(level, DEFAULT_STRATEGY, nowrap), + Deflater::end); } /** @@ -534,38 +550,32 @@ /** * Closes the compressor and discards any unprocessed input. + * * This method should be called when the compressor is no longer - * being used, but will also be called automatically by the - * finalize() method. Once this method is called, the behavior - * of the Deflater object is undefined. + * being used. Once this method is called, the behavior of the + * Deflater object is undefined. */ public void end() { synchronized (zsRef) { - long addr = zsRef.address(); - zsRef.clear(); - if (addr != 0) { - end(addr); - buf = null; - } + zsRef.clean(); + buf = null; } } /** * Closes the compressor when garbage is collected. * - * @deprecated The {@code finalize} method has been deprecated. - * Subclasses that override {@code finalize} in order to perform cleanup - * should be modified to use alternative cleanup mechanisms and - * to remove the overriding {@code finalize} method. - * When overriding the {@code finalize} method, its implementation must explicitly - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. - * See the specification for {@link Object#finalize()} for further - * information about migration options. + * @deprecated The {@code finalize} method has been deprecated and will be + * removed. It is implemented as a no-op. Subclasses that override + * {@code finalize} in order to perform cleanup should be modified to use + * alternative cleanup mechanisms and to remove the overriding {@code finalize} + * method. The recommended cleanup for compressor is to explicitly call + * {@code end} method when it is no longer in use. If the {@code end} is + * not invoked explicitly the resource of the compressor will be released + * when the instance becomes unreachable. */ - @Deprecated(since="9") - protected void finalize() { - end(); - } + @Deprecated(since="9", forRemoval=true) + protected void finalize() {} private void ensureOpen() { assert Thread.holdsLock(zsRef); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/zip/Inflater.java --- a/src/java.base/share/classes/java/util/zip/Inflater.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/zip/Inflater.java Wed Dec 13 10:25:38 2017 -0800 @@ -66,13 +66,27 @@ * } * * + * @apiNote + * To release resources used by this {@code Inflater}, the {@link #end()} method + * should be called explicitly. Subclasses are responsible for the cleanup of resources + * acquired by the subclass. Subclasses that override {@link #finalize()} in order + * to perform cleanup should be modified to use alternative cleanup mechanisms such + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method. + * + * @implSpec + * If this {@code Inflater} has been subclassed and the {@code end} method has been + * overridden, the {@code end} method will be called by the finalization when the + * inflater is unreachable. But the subclasses should not depend on this specific + * implementation; the finalization is not reliable and the {@code finalize} method + * is deprecated to be removed. + * * @see Deflater * @author David Connelly * @since 1.1 * */ -public -class Inflater { + +public class Inflater { private final ZStreamRef zsRef; private byte[] buf = defaultBuf; @@ -101,7 +115,7 @@ * @param nowrap if true then support GZIP compatible compression */ public Inflater(boolean nowrap) { - zsRef = new ZStreamRef(init(nowrap)); + this.zsRef = ZStreamRef.get(this, () -> init(nowrap), Inflater::end); } /** @@ -361,38 +375,37 @@ /** * Closes the decompressor and discards any unprocessed input. + * * This method should be called when the decompressor is no longer - * being used, but will also be called automatically by the finalize() - * method. Once this method is called, the behavior of the Inflater - * object is undefined. + * being used. Once this method is called, the behavior of the + * Inflater object is undefined. */ public void end() { synchronized (zsRef) { - long addr = zsRef.address(); - zsRef.clear(); - if (addr != 0) { - end(addr); - buf = null; - } + zsRef.clean(); + buf = null; } } /** * Closes the decompressor when garbage is collected. * - * @deprecated The {@code finalize} method has been deprecated. - * Subclasses that override {@code finalize} in order to perform cleanup - * should be modified to use alternative cleanup mechanisms and - * to remove the overriding {@code finalize} method. - * When overriding the {@code finalize} method, its implementation must explicitly - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. - * See the specification for {@link Object#finalize()} for further - * information about migration options. + * @implSpec + * If this {@code Inflater} has been subclassed and the {@code end} method + * has been overridden, the {@code end} method will be called when the + * inflater is unreachable. + * + * @deprecated The {@code finalize} method has been deprecated and will be + * removed. It is implemented as a no-op. Subclasses that override + * {@code finalize} in order to perform cleanup should be modified to use + * alternative cleanup mechanisms and remove the overriding {@code finalize} + * method. The recommended cleanup for compressor is to explicitly call + * {@code end} method when it is no longer in use. If the {@code end} is + * not invoked explicitly the resource of the compressor will be released + * when the instance becomes unreachable, */ - @Deprecated(since="9") - protected void finalize() { - end(); - } + @Deprecated(since="9", forRemoval=true) + protected void finalize() {} private void ensureOpen () { assert Thread.holdsLock(zsRef); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/zip/ZStreamRef.java --- a/src/java.base/share/classes/java/util/zip/ZStreamRef.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/zip/ZStreamRef.java Wed Dec 13 10:25:38 2017 -0800 @@ -25,22 +25,89 @@ package java.util.zip; -/** - * A reference to the native zlib's z_stream structure. - */ +import java.util.function.LongConsumer; +import java.util.function.LongSupplier; +import java.lang.ref.Cleaner.Cleanable; +import jdk.internal.ref.CleanerFactory; -class ZStreamRef { +/** + * A reference to the native zlib's z_stream structure. It also + * serves as the "cleaner" to clean up the native resource when + * the deflater or infalter is ended, closed or cleaned. + */ +class ZStreamRef implements Runnable { - private volatile long address; - ZStreamRef (long address) { - this.address = address; + private LongConsumer end; + private long address; + private final Cleanable cleanable; + + private ZStreamRef (Object owner, LongSupplier addr, LongConsumer end) { + this.cleanable = CleanerFactory.cleaner().register(owner, this); + this.end = end; + this.address = addr.getAsLong(); } long address() { return address; } - void clear() { + void clean() { + cleanable.clean(); + } + + public synchronized void run() { + long addr = address; address = 0; + if (addr != 0) { + end.accept(addr); + } + } + + private ZStreamRef (LongSupplier addr, LongConsumer end) { + this.cleanable = null; + this.end = end; + this.address = addr.getAsLong(); + } + + /* + * If {@code Inflater/Deflater} has been subclassed and the {@code end} method + * is overridden, uses {@code finalizer} mechanism for resource cleanup. So + * {@code end} method can be called when the {@code Inflater/Deflater} is + * unreachable. This mechanism will be removed when the {@code finalize} method + * is removed from {@code Inflater/Deflater}. + */ + static ZStreamRef get(Object owner, LongSupplier addr, LongConsumer end) { + Class clz = owner.getClass(); + while (clz != Deflater.class && clz != Inflater.class) { + try { + clz.getDeclaredMethod("end"); + return new FinalizableZStreamRef(owner, addr, end); + } catch (NoSuchMethodException nsme) {} + clz = clz.getSuperclass(); + } + return new ZStreamRef(owner, addr, end); + } + + private static class FinalizableZStreamRef extends ZStreamRef { + final Object owner; + + FinalizableZStreamRef (Object owner, LongSupplier addr, LongConsumer end) { + super(addr, end); + this.owner = owner; + } + + @Override + void clean() { + run(); + } + + @Override + @SuppressWarnings("deprecation") + protected void finalize() { + if (owner instanceof Inflater) + ((Inflater)owner).end(); + else + ((Deflater)owner).end(); + } } } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/zip/ZipCoder.java --- a/src/java.base/share/classes/java/util/zip/ZipCoder.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/zip/ZipCoder.java Wed Dec 13 10:25:38 2017 -0800 @@ -28,72 +28,60 @@ import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; +import java.nio.charset.CharacterCodingException; import java.nio.charset.CodingErrorAction; -import java.util.Arrays; -import sun.nio.cs.ArrayDecoder; -import sun.nio.cs.ArrayEncoder; + +import static java.nio.charset.StandardCharsets.UTF_8; /** * Utility class for zipfile name and comment decoding and encoding */ -final class ZipCoder { +class ZipCoder { + + private static final jdk.internal.misc.JavaLangAccess JLA = + jdk.internal.misc.SharedSecrets.getJavaLangAccess(); + + static final class UTF8 extends ZipCoder { + + UTF8(Charset utf8) { + super(utf8); + } - private static boolean isASCII(byte[] ba, int off, int len) { - for (int i = off; i < off + len; i++) { - if (ba[i] < 0) - return false; + @Override + boolean isUTF8() { + return true; } - return true; + + @Override + String toString(byte[] ba, int off, int length) { + return JLA.newStringUTF8NoRepl(ba, off, length); + } + + @Override + byte[] getBytes(String s) { + return JLA.getBytesUTF8NoRepl(s); + } } - private static boolean hasReplaceChar(byte[] ba) { - for (int i = 0; i < ba.length; i++) { - if (ba[i] == (byte)'?') - return true; - } - return false; + // UTF_8.ArrayEn/Decoder is stateless, so make it singleton. + private static ZipCoder utf8 = new UTF8(UTF_8); + + public static ZipCoder get(Charset charset) { + if (charset == UTF_8) + return utf8; + return new ZipCoder(charset); } String toString(byte[] ba, int off, int length) { - - // fastpath for UTF-8 cs and ascii only name, leverage the - // compact string impl to avoid the unnecessary char[] copy/ - // paste. A temporary workaround before we have better approach, - // such as a String constructor that throws exception for - // malformed and/or unmappable characters, instead of silently - // replacing with repl char - if (isUTF8 && isASCII(ba, off, length)) { - return new String(ba, off, length, cs); - } + try { + return decoder().decode(ByteBuffer.wrap(ba, off, length)).toString(); - CharsetDecoder cd = decoder().reset(); - int len = (int)(length * cd.maxCharsPerByte()); - char[] ca = new char[len]; - if (len == 0) - return new String(ca); - // UTF-8 only for now. Other ArrayDeocder only handles - // CodingErrorAction.REPLACE mode. ZipCoder uses - // REPORT mode. - if (isUTF8 && cd instanceof ArrayDecoder) { - int clen = ((ArrayDecoder)cd).decode(ba, off, length, ca); - if (clen == -1) // malformed - throw new IllegalArgumentException("MALFORMED"); - return new String(ca, 0, clen); + } catch (CharacterCodingException x) { + throw new IllegalArgumentException(x); } - ByteBuffer bb = ByteBuffer.wrap(ba, off, length); - CharBuffer cb = CharBuffer.wrap(ca); - CoderResult cr = cd.decode(bb, cb, true); - if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); - cr = cd.flush(cb); - if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); - return new String(ca, 0, cb.position()); } String toString(byte[] ba, int length) { @@ -105,84 +93,47 @@ } byte[] getBytes(String s) { - if (isUTF8) { - // fastpath for UTF8. should only occur when the string - // has malformed surrogates. A postscan should still be - // faster and use less memory. - byte[] ba = s.getBytes(cs); - if (!hasReplaceChar(ba)) { - return ba; + try { + ByteBuffer bb = encoder().encode(CharBuffer.wrap(s)); + int pos = bb.position(); + int limit = bb.limit(); + if (bb.hasArray() && pos == 0 && limit == bb.capacity()) { + return bb.array(); } + byte[] bytes = new byte[bb.limit() - bb.position()]; + bb.get(bytes); + return bytes; + } catch (CharacterCodingException x) { + throw new IllegalArgumentException(x); } - CharsetEncoder ce = encoder().reset(); - char[] ca = s.toCharArray(); - int len = (int)(ca.length * ce.maxBytesPerChar()); - byte[] ba = new byte[len]; - if (len == 0) - return ba; - // UTF-8 only for now. Other ArrayDeocder only handles - // CodingErrorAction.REPLACE mode. - if (isUTF8 && ce instanceof ArrayEncoder) { - int blen = ((ArrayEncoder)ce).encode(ca, 0, ca.length, ba); - if (blen == -1) // malformed - throw new IllegalArgumentException("MALFORMED"); - return Arrays.copyOf(ba, blen); - } - ByteBuffer bb = ByteBuffer.wrap(ba); - CharBuffer cb = CharBuffer.wrap(ca); - CoderResult cr = ce.encode(cb, bb, true); - if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); - cr = ce.flush(bb); - if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); - if (bb.position() == ba.length) // defensive copy? - return ba; - else - return Arrays.copyOf(ba, bb.position()); } // assume invoked only if "this" is not utf8 byte[] getBytesUTF8(String s) { - if (isUTF8) - return getBytes(s); - if (utf8 == null) - utf8 = new ZipCoder(StandardCharsets.UTF_8); return utf8.getBytes(s); } String toStringUTF8(byte[] ba, int len) { - return toStringUTF8(ba, 0, len); + return utf8.toString(ba, 0, len); } String toStringUTF8(byte[] ba, int off, int len) { - if (isUTF8) - return toString(ba, off, len); - if (utf8 == null) - utf8 = new ZipCoder(StandardCharsets.UTF_8); return utf8.toString(ba, off, len); } boolean isUTF8() { - return isUTF8; + return false; } private Charset cs; private CharsetDecoder dec; private CharsetEncoder enc; - private boolean isUTF8; - private ZipCoder utf8; private ZipCoder(Charset cs) { this.cs = cs; - this.isUTF8 = cs.name().equals(StandardCharsets.UTF_8.name()); } - static ZipCoder get(Charset charset) { - return new ZipCoder(charset); - } - - private CharsetDecoder decoder() { + protected CharsetDecoder decoder() { if (dec == null) { dec = cs.newDecoder() .onMalformedInput(CodingErrorAction.REPORT) @@ -191,7 +142,7 @@ return dec; } - private CharsetEncoder encoder() { + protected CharsetEncoder encoder() { if (enc == null) { enc = cs.newEncoder() .onMalformedInput(CodingErrorAction.REPORT) diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/java/util/zip/ZipFile.java --- a/src/java.base/share/classes/java/util/zip/ZipFile.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/java/util/zip/ZipFile.java Wed Dec 13 10:25:38 2017 -0800 @@ -31,22 +31,24 @@ import java.io.EOFException; import java.io.File; import java.io.RandomAccessFile; +import java.io.UncheckedIOException; +import java.lang.ref.Cleaner.Cleanable; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.attribute.BasicFileAttributes; -import java.nio.file.Path; import java.nio.file.Files; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Deque; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; -import java.util.Map; import java.util.Objects; import java.util.NoSuchElementException; +import java.util.Set; import java.util.Spliterator; import java.util.Spliterators; import java.util.WeakHashMap; @@ -61,8 +63,8 @@ import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.VM; import jdk.internal.perf.PerfCounter; +import jdk.internal.ref.CleanerFactory; -import static java.util.zip.ZipConstants.*; import static java.util.zip.ZipConstants64.*; import static java.util.zip.ZipUtils.*; @@ -73,6 +75,21 @@ * or method in this class will cause a {@link NullPointerException} to be * thrown. * + * @apiNote + * To release resources used by this {@code ZipFile}, the {@link #close()} method + * should be called explicitly or by try-with-resources. Subclasses are responsible + * for the cleanup of resources acquired by the subclass. Subclasses that override + * {@link #finalize()} in order to perform cleanup should be modified to use alternative + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding + * {@code finalize} method. + * + * @implSpec + * If this {@code ZipFile} has been subclassed and the {@code close} method has + * been overridden, the {@code close} method will be called by the finalization + * when {@code ZipFile} is unreachable. But the subclasses should not depend on + * this specific implementation; the finalization is not reliable and the + * {@code finalize} method is deprecated to be removed. + * * @author David Connelly * @since 1.1 */ @@ -81,9 +98,15 @@ private final String name; // zip file name private volatile boolean closeRequested; - private Source zsrc; private ZipCoder zc; + // The "resource" used by this zip file that needs to be + // cleaned after use. + // a) the input streams that need to be closed + // b) the list of cached Inflater objects + // c) the "native" source of this zip file. + private final CleanableResource res; + private static final int STORED = ZipEntry.STORED; private static final int DEFLATED = ZipEntry.DEFLATED; @@ -214,10 +237,13 @@ } } Objects.requireNonNull(charset, "charset"); + this.zc = ZipCoder.get(charset); this.name = name; long t0 = System.nanoTime(); - this.zsrc = Source.get(file, (mode & OPEN_DELETE) != 0); + + this.res = CleanableResource.get(this, file, mode); + PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0); PerfCounter.getZipFileCount().increment(); } @@ -284,10 +310,10 @@ public String getComment() { synchronized (this) { ensureOpen(); - if (zsrc.comment == null) { + if (res.zsrc.comment == null) { return null; } - return zc.toString(zsrc.comment); + return zc.toString(res.zsrc.comment); } } @@ -318,7 +344,7 @@ synchronized (this) { ensureOpen(); byte[] bname = zc.getBytes(name); - int pos = zsrc.getEntryPos(bname, true); + int pos = res.zsrc.getEntryPos(bname, true); if (pos != -1) { return getZipEntry(name, bname, pos, func); } @@ -326,10 +352,6 @@ return null; } - // The outstanding inputstreams that need to be closed, - // mapped to the inflater objects they use. - private final Map streams = new WeakHashMap<>(); - /** * Returns an input stream for reading the contents of the specified * zip file entry. @@ -348,6 +370,8 @@ Objects.requireNonNull(entry, "entry"); int pos = -1; ZipFileInputStream in = null; + Source zsrc = res.zsrc; + Set istreams = res.istreams; synchronized (this) { ensureOpen(); if (Objects.equals(lastEntryName, entry.name)) { @@ -363,8 +387,8 @@ in = new ZipFileInputStream(zsrc.cen, pos); switch (CENHOW(zsrc.cen, pos)) { case STORED: - synchronized (streams) { - streams.put(in, null); + synchronized (istreams) { + istreams.add(in); } return in; case DEFLATED: @@ -377,10 +401,9 @@ if (size <= 0) { size = 4096; } - Inflater inf = getInflater(); - InputStream is = new ZipFileInflaterInputStream(in, inf, (int)size); - synchronized (streams) { - streams.put(is, inf); + InputStream is = new ZipFileInflaterInputStream(in, res, (int)size); + synchronized (istreams) { + istreams.add(is); } return is; default: @@ -392,25 +415,30 @@ private class ZipFileInflaterInputStream extends InflaterInputStream { private volatile boolean closeRequested; private boolean eof = false; + private final Cleanable cleanable; - ZipFileInflaterInputStream(ZipFileInputStream zfin, Inflater inf, - int size) { + ZipFileInflaterInputStream(ZipFileInputStream zfin, + CleanableResource res, int size) { + this(zfin, res, res.getInflater(), size); + } + + private ZipFileInflaterInputStream(ZipFileInputStream zfin, + CleanableResource res, + Inflater inf, int size) { super(zfin, inf, size); - } + this.cleanable = CleanerFactory.cleaner().register(this, + () -> res.releaseInflater(inf)); + } public void close() throws IOException { if (closeRequested) return; closeRequested = true; - super.close(); - Inflater inf; - synchronized (streams) { - inf = streams.remove(this); + synchronized (res.istreams) { + res.istreams.remove(this); } - if (inf != null) { - releaseInflater(inf); - } + cleanable.clean(); } // Override fill() method to provide an extra "dummy" byte @@ -436,44 +464,8 @@ return (avail > (long) Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) avail); } - - @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - close(); - } } - /* - * Gets an inflater from the list of available inflaters or allocates - * a new one. - */ - private Inflater getInflater() { - Inflater inf; - synchronized (inflaterCache) { - while ((inf = inflaterCache.poll()) != null) { - if (!inf.ended()) { - return inf; - } - } - } - return new Inflater(true); - } - - /* - * Releases the specified inflater to the list of available inflaters. - */ - private void releaseInflater(Inflater inf) { - if (!inf.ended()) { - inf.reset(); - synchronized (inflaterCache) { - inflaterCache.add(inf); - } - } - } - - // List of available Inflater objects for decompression - private final Deque inflaterCache = new ArrayDeque<>(); - /** * Returns the path name of the ZIP file. * @return the path name of the ZIP file @@ -518,7 +510,7 @@ throw new NoSuchElementException(); } // each "entry" has 3 ints in table entries - return (T)getZipEntry(null, null, zsrc.getEntryPos(i++ * 3), gen); + return (T)getZipEntry(null, null, res.zsrc.getEntryPos(i++ * 3), gen); } } @@ -536,14 +528,14 @@ public Enumeration entries() { synchronized (this) { ensureOpen(); - return new ZipEntryIterator(zsrc.total, ZipEntry::new); + return new ZipEntryIterator(res.zsrc.total, ZipEntry::new); } } private Enumeration entries(Function func) { synchronized (this) { ensureOpen(); - return new ZipEntryIterator(zsrc.total, func); + return new ZipEntryIterator(res.zsrc.total, func); } } @@ -568,7 +560,7 @@ if (index >= 0 && index < fence) { synchronized (ZipFile.this) { ensureOpen(); - action.accept(gen.apply(zsrc.getEntryPos(index++ * 3))); + action.accept(gen.apply(res.zsrc.getEntryPos(index++ * 3))); } return true; } @@ -589,13 +581,13 @@ public Stream stream() { synchronized (this) { ensureOpen(); - return StreamSupport.stream(new EntrySpliterator<>(0, zsrc.total, + return StreamSupport.stream(new EntrySpliterator<>(0, res.zsrc.total, pos -> getZipEntry(null, null, pos, ZipEntry::new)), false); } } private String getEntryName(int pos) { - byte[] cen = zsrc.cen; + byte[] cen = res.zsrc.cen; int nlen = CENNAM(cen, pos); int clen = CENCOM(cen, pos); int flag = CENFLG(cen, pos); @@ -620,7 +612,7 @@ synchronized (this) { ensureOpen(); return StreamSupport.stream( - new EntrySpliterator<>(0, zsrc.total, this::getEntryName), false); + new EntrySpliterator<>(0, res.zsrc.total, this::getEntryName), false); } } @@ -638,7 +630,7 @@ private Stream stream(Function func) { synchronized (this) { ensureOpen(); - return StreamSupport.stream(new EntrySpliterator<>(0, zsrc.total, + return StreamSupport.stream(new EntrySpliterator<>(0, res.zsrc.total, pos -> (JarEntry)getZipEntry(null, null, pos, func)), false); } } @@ -649,7 +641,7 @@ /* Checks ensureOpen() before invoke this method */ private ZipEntry getZipEntry(String name, byte[] bname, int pos, Function func) { - byte[] cen = zsrc.cen; + byte[] cen = res.zsrc.cen; int nlen = CENNAM(cen, pos); int elen = CENEXT(cen, pos); int clen = CENCOM(cen, pos); @@ -698,12 +690,170 @@ public int size() { synchronized (this) { ensureOpen(); - return zsrc.total; + return res.zsrc.total; + } + } + + private static class CleanableResource implements Runnable { + // The outstanding inputstreams that need to be closed + final Set istreams; + + // List of cached Inflater objects for decompression + Deque inflaterCache; + + final Cleanable cleanable; + + Source zsrc; + + CleanableResource(ZipFile zf, File file, int mode) throws IOException { + this.cleanable = CleanerFactory.cleaner().register(zf, this); + this.istreams = Collections.newSetFromMap(new WeakHashMap<>()); + this.inflaterCache = new ArrayDeque<>(); + this.zsrc = Source.get(file, (mode & OPEN_DELETE) != 0); + } + + void clean() { + cleanable.clean(); + } + + /* + * Gets an inflater from the list of available inflaters or allocates + * a new one. + */ + Inflater getInflater() { + Inflater inf; + synchronized (inflaterCache) { + if ((inf = inflaterCache.poll()) != null) { + return inf; + } + } + return new Inflater(true); + } + + /* + * Releases the specified inflater to the list of available inflaters. + */ + void releaseInflater(Inflater inf) { + Deque inflaters = this.inflaterCache; + if (inflaters != null) { + synchronized (inflaters) { + // double checked! + if (inflaters == this.inflaterCache) { + inf.reset(); + inflaters.add(inf); + return; + } + } + } + // inflaters cache already closed - just end it. + inf.end(); + } + + public void run() { + IOException ioe = null; + + // Release cached inflaters and close the cache first + Deque inflaters = this.inflaterCache; + if (inflaters != null) { + synchronized (inflaters) { + // no need to double-check as only one thread gets a + // chance to execute run() (Cleaner guarantee)... + Inflater inf; + while ((inf = inflaters.poll()) != null) { + inf.end(); + } + // close inflaters cache + this.inflaterCache = null; + } + } + + // Close streams, release their inflaters + if (istreams != null) { + synchronized (istreams) { + if (!istreams.isEmpty()) { + InputStream[] copy = istreams.toArray(new InputStream[0]); + istreams.clear(); + for (InputStream is : copy) { + try { + is.close(); + } catch (IOException e) { + if (ioe == null) ioe = e; + else ioe.addSuppressed(e); + } + } + } + } + } + + // Release zip src + if (zsrc != null) { + synchronized (zsrc) { + try { + Source.release(zsrc); + zsrc = null; + } catch (IOException e) { + if (ioe == null) ioe = e; + else ioe.addSuppressed(e); + } + } + } + if (ioe != null) { + throw new UncheckedIOException(ioe); + } + } + + CleanableResource(File file, int mode) + throws IOException { + this.cleanable = null; + this.istreams = Collections.newSetFromMap(new WeakHashMap<>()); + this.inflaterCache = new ArrayDeque<>(); + this.zsrc = Source.get(file, (mode & OPEN_DELETE) != 0); + } + + /* + * If {@code ZipFile} has been subclassed and the {@code close} method is + * overridden, uses the {@code finalizer} mechanism for resource cleanup. + * So {@code close} method can be called when the the {@code ZipFile} is + * unreachable. This mechanism will be removed when {@code finalize} method + * is removed from {@code ZipFile}. + */ + static CleanableResource get(ZipFile zf, File file, int mode) + throws IOException { + Class clz = zf.getClass(); + while (clz != ZipFile.class) { + try { + clz.getDeclaredMethod("close"); + return new FinalizableResource(zf, file, mode); + } catch (NoSuchMethodException nsme) {} + clz = clz.getSuperclass(); + } + return new CleanableResource(zf, file, mode); + } + + static class FinalizableResource extends CleanableResource { + ZipFile zf; + FinalizableResource(ZipFile zf, File file, int mode) + throws IOException { + super(file, mode); + this.zf = zf; + } + + @Override + void clean() { + run(); + } + + @Override + @SuppressWarnings("deprecation") + protected void finalize() throws IOException { + zf.close(); + } } } /** * Closes the ZIP file. + * *

Closing this ZIP file will close all of the input streams * previously returned by invocations of the {@link #getInputStream * getInputStream} method. @@ -717,31 +867,12 @@ closeRequested = true; synchronized (this) { - // Close streams, release their inflaters - synchronized (streams) { - if (!streams.isEmpty()) { - Map copy = new HashMap<>(streams); - streams.clear(); - for (Map.Entry e : copy.entrySet()) { - e.getKey().close(); - Inflater inf = e.getValue(); - if (inf != null) { - inf.end(); - } - } - } - } - // Release cached inflaters - synchronized (inflaterCache) { - Inflater inf; - while ((inf = inflaterCache.poll()) != null) { - inf.end(); - } - } - // Release zip src - if (zsrc != null) { - Source.close(zsrc); - zsrc = null; + // Close streams, release their inflaters, release cached inflaters + // and release zip source + try { + res.clean(); + } catch (UncheckedIOException ioe) { + throw ioe.getCause(); } } } @@ -750,34 +881,26 @@ * Ensures that the system resources held by this ZipFile object are * released when there are no more references to it. * - *

- * Since the time when GC would invoke this method is undetermined, - * it is strongly recommended that applications invoke the {@code close} - * method as soon they have finished accessing this {@code ZipFile}. - * This will prevent holding up system resources for an undetermined - * length of time. + * @deprecated The {@code finalize} method has been deprecated and will be + * removed. It is implemented as a no-op. Subclasses that override + * {@code finalize} in order to perform cleanup should be modified to + * use alternative cleanup mechanisms and to remove the overriding + * {@code finalize} method. The recommended cleanup for ZipFile object + * is to explicitly invoke {@code close} method when it is no longer in + * use, or use try-with-resources. If the {@code close} is not invoked + * explicitly the resources held by this object will be released when + * the instance becomes unreachable. * - * @deprecated The {@code finalize} method has been deprecated. - * Subclasses that override {@code finalize} in order to perform cleanup - * should be modified to use alternative cleanup mechanisms and - * to remove the overriding {@code finalize} method. - * When overriding the {@code finalize} method, its implementation must explicitly - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. - * See the specification for {@link Object#finalize()} for further - * information about migration options. * @throws IOException if an I/O error has occurred - * @see java.util.zip.ZipFile#close() */ - @Deprecated(since="9") - protected void finalize() throws IOException { - close(); - } + @Deprecated(since="9", forRemoval=true) + protected void finalize() throws IOException {} private void ensureOpen() { if (closeRequested) { throw new IllegalStateException("zip file closed"); } - if (zsrc == null) { + if (res.zsrc == null) { throw new IllegalStateException("The object is not initialized."); } } @@ -798,7 +921,7 @@ protected long rem; // number of remaining bytes within entry protected long size; // uncompressed size of this entry - ZipFileInputStream(byte[] cen, int cenpos) throws IOException { + ZipFileInputStream(byte[] cen, int cenpos) { rem = CENSIZ(cen, cenpos); size = CENLEN(cen, cenpos); pos = CENOFF(cen, cenpos); @@ -808,10 +931,10 @@ checkZIP64(cen, cenpos); } // negative for lazy initialization, see getDataOffset(); - pos = - (pos + ZipFile.this.zsrc.locpos); + pos = - (pos + ZipFile.this.res.zsrc.locpos); } - private void checkZIP64(byte[] cen, int cenpos) throws IOException { + private void checkZIP64(byte[] cen, int cenpos) { int off = cenpos + CENHDR + CENNAM(cen, cenpos); int end = off + CENEXT(cen, cenpos); while (off + 4 < end) { @@ -857,7 +980,7 @@ if (pos <= 0) { byte[] loc = new byte[LOCHDR]; pos = -pos; - int len = ZipFile.this.zsrc.readFullyAt(loc, 0, loc.length, pos); + int len = ZipFile.this.res.zsrc.readFullyAt(loc, 0, loc.length, pos); if (len != LOCHDR) { throw new ZipException("ZipFile error reading zip file"); } @@ -882,7 +1005,7 @@ if (len <= 0) { return 0; } - len = ZipFile.this.zsrc.readAt(b, off, len, pos); + len = ZipFile.this.res.zsrc.readAt(b, off, len, pos); if (len > 0) { pos += len; rem -= len; @@ -932,15 +1055,11 @@ } closeRequested = true; rem = 0; - synchronized (streams) { - streams.remove(this); + synchronized (res.istreams) { + res.istreams.remove(this); } } - @SuppressWarnings("deprecation") - protected void finalize() { - close(); - } } /** @@ -952,6 +1071,7 @@ private String[] getMetaInfEntryNames() { synchronized (this) { ensureOpen(); + Source zsrc = res.zsrc; if (zsrc.metanames == null) { return null; } @@ -972,7 +1092,7 @@ new JavaUtilZipFileAccess() { @Override public boolean startsWithLocHeader(ZipFile zip) { - return zip.zsrc.startsWithLoc; + return zip.res.zsrc.startsWithLoc; } @Override public String[] getMetaInfEntryNames(ZipFile zip) { @@ -1080,7 +1200,7 @@ private static final HashMap files = new HashMap<>(); - public static Source get(File file, boolean toDelete) throws IOException { + static Source get(File file, boolean toDelete) throws IOException { Key key = new Key(file, Files.readAttributes(file.toPath(), BasicFileAttributes.class)); Source src = null; @@ -1105,9 +1225,9 @@ } } - private static void close(Source src) throws IOException { + static void release(Source src) throws IOException { synchronized (files) { - if (--src.refs == 0) { + if (src != null && --src.refs == 0) { files.remove(src.key); src.close(); } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java --- a/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java Wed Dec 13 10:25:38 2017 -0800 @@ -254,4 +254,23 @@ * given class loader. */ Stream layers(ClassLoader loader); + + /** + * Returns a new string by decoding from the given utf8 bytes array. + * + * @param off the index of the first byte to decode + * @param len the number of bytes to decode + * @return the newly created string + * @throws IllegalArgumentException for malformed or unmappable bytes. + */ + String newStringUTF8NoRepl(byte[] bytes, int off, int len); + + /** + * Encode the given string into a sequence of bytes using utf8. + * + * @param s the string to encode + * @return the encoded bytes in utf8 + * @throws IllegalArgumentException for malformed surrogates + */ + byte[] getBytesUTF8NoRepl(String s); } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java --- a/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package jdk.internal.util.xml; import java.io.*; +import java.nio.charset.Charset; import java.util.InvalidPropertiesFormatException; import java.util.Map.Entry; import java.util.Properties; @@ -94,11 +95,11 @@ */ } - public void store(Properties props, OutputStream os, String comment, String encoding) + public void store(Properties props, OutputStream os, String comment, Charset charset) throws IOException { try { - XMLStreamWriter writer = new XMLStreamWriterImpl(os, encoding); + XMLStreamWriter writer = new XMLStreamWriterImpl(os, charset); writer.writeStartDocument(); writer.writeDTD(PROPS_DTD_DECL); writer.writeStartElement(ELEMENT_ROOT); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/jdk/internal/util/xml/XMLStreamWriter.java --- a/src/java.base/share/classes/jdk/internal/util/xml/XMLStreamWriter.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/jdk/internal/util/xml/XMLStreamWriter.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,9 @@ package jdk.internal.util.xml; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + /** * Basic XMLStreamWriter for writing simple XML files such as those * defined in java.util.Properties @@ -38,6 +41,7 @@ //Defaults the XML version to 1.0, and the encoding to utf-8 public static final String DEFAULT_XML_VERSION = "1.0"; public static final String DEFAULT_ENCODING = "UTF-8"; + public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; /** * Writes a start tag to the output. All writeStartElement methods diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java --- a/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -66,7 +66,7 @@ private int _state = 0; private Element _currentEle; private XMLWriter _writer; - private String _encoding; + private Charset _charset; /** * This flag can be used to turn escaping off for content. It does * not apply to attribute content. @@ -79,26 +79,23 @@ System.getProperty("line.separator").toCharArray(); public XMLStreamWriterImpl(OutputStream os) throws XMLStreamException { - this(os, XMLStreamWriter.DEFAULT_ENCODING); + this(os, XMLStreamWriter.DEFAULT_CHARSET); } - public XMLStreamWriterImpl(OutputStream os, String encoding) + public XMLStreamWriterImpl(OutputStream os, Charset cs) throws XMLStreamException { - Charset cs = null; - if (encoding == null) { - _encoding = XMLStreamWriter.DEFAULT_ENCODING; + if (cs == null) { + _charset = XMLStreamWriter.DEFAULT_CHARSET; } else { try { - cs = getCharset(encoding); + _charset = checkCharset(cs); } catch (UnsupportedEncodingException e) { throw new XMLStreamException(e); } - - this._encoding = encoding; } - _writer = new XMLWriter(os, encoding, cs); + _writer = new XMLWriter(os, null, _charset); } /** @@ -108,7 +105,7 @@ * @throws XMLStreamException */ public void writeStartDocument() throws XMLStreamException { - writeStartDocument(_encoding, XMLStreamWriter.DEFAULT_XML_VERSION); + writeStartDocument(_charset.name(), XMLStreamWriter.DEFAULT_XML_VERSION); } /** @@ -118,7 +115,7 @@ * @throws XMLStreamException */ public void writeStartDocument(String version) throws XMLStreamException { - writeStartDocument(_encoding, version, null); + writeStartDocument(_charset.name(), version, null); } /** @@ -155,7 +152,7 @@ _state = STATE_XML_DECL; String enc = encoding; if (enc == null) { - enc = _encoding; + enc = _charset.name(); } else { //check if the encoding is supported try { @@ -564,6 +561,20 @@ return cs; } + /** + * Checks for charset support. + * @param charset the specified charset + * @return the charset + * @throws UnsupportedEncodingException if the charset is not supported + */ + private Charset checkCharset(Charset charset) throws UnsupportedEncodingException { + if (charset.name().equalsIgnoreCase("UTF-32")) { + throw new UnsupportedEncodingException("The basic XMLWriter does " + + "not support " + charset.name()); + } + return charset; + } + /* * Start of Internal classes. * diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/launcher/LauncherHelper.java --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java Wed Dec 13 10:25:38 2017 -0800 @@ -268,7 +268,7 @@ Locale locale = Locale.getDefault(); ostream.println(LOCALE_SETTINGS); ostream.println(INDENT + "default locale = " + - locale.getDisplayLanguage()); + locale.getDisplayName()); ostream.println(INDENT + "default display locale = " + Locale.getDefault(Category.DISPLAY).getDisplayName()); ostream.println(INDENT + "default format locale = " + diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java --- a/src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java Wed Dec 13 10:25:38 2017 -0800 @@ -63,8 +63,8 @@ return new Encoder(this); } - private static class Decoder extends CharsetDecoder - implements ArrayDecoder { + private static class Decoder extends CharsetDecoder { + private Decoder(Charset cs) { super(cs, 1.0f, 1.0f); } @@ -124,23 +124,10 @@ else return decodeBufferLoop(src, dst); } - - public int decode(byte[] src, int sp, int len, char[] dst) { - if (len > dst.length) - len = dst.length; - int dp = 0; - while (dp < len) - dst[dp++] = (char)(src[sp++] & 0xff); - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } - private static class Encoder extends CharsetEncoder - implements ArrayEncoder { + private static class Encoder extends CharsetEncoder { + private Encoder(Charset cs) { super(cs, 1.0f, 1.0f); } @@ -271,39 +258,5 @@ else return encodeBufferLoop(src, dst); } - - private byte repl = (byte)'?'; - protected void implReplaceWith(byte[] newReplacement) { - repl = newReplacement[0]; - } - - public int encode(char[] src, int sp, int len, byte[] dst) { - int dp = 0; - int slen = Math.min(len, dst.length); - int sl = sp + slen; - while (sp < sl) { - int ret = encodeISOArray(src, sp, dst, dp, slen); - sp = sp + ret; - dp = dp + ret; - if (ret != slen) { - char c = src[sp++]; - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(src[sp])) { - if (len > dst.length) { - sl++; - len--; - } - sp++; - } - dst[dp++] = repl; - slen = Math.min((sl - sp), (dst.length - dp)); - } - } - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/nio/cs/US_ASCII.java --- a/src/java.base/share/classes/sun/nio/cs/US_ASCII.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/nio/cs/US_ASCII.java Wed Dec 13 10:25:38 2017 -0800 @@ -58,8 +58,7 @@ return new Encoder(this); } - private static class Decoder extends CharsetDecoder - implements ArrayDecoder { + private static class Decoder extends CharsetDecoder { private Decoder(Charset cs) { super(cs, 1.0f, 1.0f); @@ -128,32 +127,9 @@ else return decodeBufferLoop(src, dst); } - - private char repl = '\uFFFD'; - protected void implReplaceWith(String newReplacement) { - repl = newReplacement.charAt(0); - } - - public int decode(byte[] src, int sp, int len, char[] dst) { - int dp = 0; - len = Math.min(len, dst.length); - while (dp < len) { - byte b = src[sp++]; - if (b >= 0) - dst[dp++] = (char)b; - else - dst[dp++] = repl; - } - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } - private static class Encoder extends CharsetEncoder - implements ArrayEncoder { + private static class Encoder extends CharsetEncoder { private Encoder(Charset cs) { super(cs, 1.0f, 1.0f); @@ -237,36 +213,5 @@ return encodeBufferLoop(src, dst); } - private byte repl = (byte)'?'; - protected void implReplaceWith(byte[] newReplacement) { - repl = newReplacement[0]; - } - - public int encode(char[] src, int sp, int len, byte[] dst) { - int dp = 0; - int sl = sp + Math.min(len, dst.length); - while (sp < sl) { - char c = src[sp++]; - if (c < 0x80) { - dst[dp++] = (byte)c; - continue; - } - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(src[sp])) { - if (len > dst.length) { - sl++; - len--; - } - sp++; - } - dst[dp++] = repl; - } - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } - } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/nio/cs/UTF_8.java --- a/src/java.base/share/classes/sun/nio/cs/UTF_8.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/nio/cs/UTF_8.java Wed Dec 13 10:25:38 2017 -0800 @@ -80,8 +80,8 @@ dst.position(dp - dst.arrayOffset()); } - private static class Decoder extends CharsetDecoder - implements ArrayDecoder { + private static class Decoder extends CharsetDecoder { + private Decoder(Charset cs) { super(cs, 1.0f, 1.0f); } @@ -423,142 +423,9 @@ bb.position(sp); return bb; } - - // returns -1 if there is/are malformed byte(s) and the - // "action" for malformed input is not REPLACE. - public int decode(byte[] sa, int sp, int len, char[] da) { - final int sl = sp + len; - int dp = 0; - int dlASCII = Math.min(len, da.length); - ByteBuffer bb = null; // only necessary if malformed - - // ASCII only optimized loop - while (dp < dlASCII && sa[sp] >= 0) - da[dp++] = (char) sa[sp++]; - - while (sp < sl) { - int b1 = sa[sp++]; - if (b1 >= 0) { - // 1 byte, 7 bits: 0xxxxxxx - da[dp++] = (char) b1; - } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) { - // 2 bytes, 11 bits: 110xxxxx 10xxxxxx - if (sp < sl) { - int b2 = sa[sp++]; - if (isNotContinuation(b2)) { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - sp--; // malformedN(bb, 2) always returns 1 - } else { - da[dp++] = (char) (((b1 << 6) ^ b2)^ - (((byte) 0xC0 << 6) ^ - ((byte) 0x80 << 0))); - } - continue; - } - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - return dp; - } else if ((b1 >> 4) == -2) { - // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx - if (sp + 1 < sl) { - int b2 = sa[sp++]; - int b3 = sa[sp++]; - if (isMalformed3(b1, b2, b3)) { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - sp -= 3; - bb = getByteBuffer(bb, sa, sp); - sp += malformedN(bb, 3).length(); - } else { - char c = (char)((b1 << 12) ^ - (b2 << 6) ^ - (b3 ^ - (((byte) 0xE0 << 12) ^ - ((byte) 0x80 << 6) ^ - ((byte) 0x80 << 0)))); - if (Character.isSurrogate(c)) { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - } else { - da[dp++] = c; - } - } - continue; - } - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - if (sp < sl && isMalformed3_2(b1, sa[sp])) { - da[dp++] = replacement().charAt(0); - continue; - - } - da[dp++] = replacement().charAt(0); - return dp; - } else if ((b1 >> 3) == -2) { - // 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - if (sp + 2 < sl) { - int b2 = sa[sp++]; - int b3 = sa[sp++]; - int b4 = sa[sp++]; - int uc = ((b1 << 18) ^ - (b2 << 12) ^ - (b3 << 6) ^ - (b4 ^ - (((byte) 0xF0 << 18) ^ - ((byte) 0x80 << 12) ^ - ((byte) 0x80 << 6) ^ - ((byte) 0x80 << 0)))); - if (isMalformed4(b2, b3, b4) || - // shortest form check - !Character.isSupplementaryCodePoint(uc)) { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - sp -= 4; - bb = getByteBuffer(bb, sa, sp); - sp += malformedN(bb, 4).length(); - } else { - da[dp++] = Character.highSurrogate(uc); - da[dp++] = Character.lowSurrogate(uc); - } - continue; - } - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - b1 &= 0xff; - if (b1 > 0xf4 || - sp < sl && isMalformed4_2(b1, sa[sp] & 0xff)) { - da[dp++] = replacement().charAt(0); - continue; - } - sp++; - if (sp < sl && isMalformed4_3(sa[sp])) { - da[dp++] = replacement().charAt(0); - continue; - } - da[dp++] = replacement().charAt(0); - return dp; - } else { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - } - } - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } - private static final class Encoder extends CharsetEncoder - implements ArrayEncoder { + private static final class Encoder extends CharsetEncoder { private Encoder(Charset cs) { super(cs, 1.1f, 3.0f); @@ -699,58 +566,5 @@ return encodeBufferLoop(src, dst); } - private byte repl = (byte)'?'; - protected void implReplaceWith(byte[] newReplacement) { - repl = newReplacement[0]; - } - - // returns -1 if there is malformed char(s) and the - // "action" for malformed input is not REPLACE. - public int encode(char[] sa, int sp, int len, byte[] da) { - int sl = sp + len; - int dp = 0; - int dlASCII = dp + Math.min(len, da.length); - - // ASCII only optimized loop - while (dp < dlASCII && sa[sp] < '\u0080') - da[dp++] = (byte) sa[sp++]; - - while (sp < sl) { - char c = sa[sp++]; - if (c < 0x80) { - // Have at most seven bits - da[dp++] = (byte)c; - } else if (c < 0x800) { - // 2 bytes, 11 bits - da[dp++] = (byte)(0xc0 | (c >> 6)); - da[dp++] = (byte)(0x80 | (c & 0x3f)); - } else if (Character.isSurrogate(c)) { - if (sgp == null) - sgp = new Surrogate.Parser(); - int uc = sgp.parse(c, sa, sp - 1, sl); - if (uc < 0) { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = repl; - } else { - da[dp++] = (byte)(0xf0 | ((uc >> 18))); - da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f)); - da[dp++] = (byte)(0x80 | ((uc >> 6) & 0x3f)); - da[dp++] = (byte)(0x80 | (uc & 0x3f)); - sp++; // 2 chars - } - } else { - // 3 bytes, 16 bits - da[dp++] = (byte)(0xe0 | ((c >> 12))); - da[dp++] = (byte)(0x80 | ((c >> 6) & 0x3f)); - da[dp++] = (byte)(0x80 | (c & 0x3f)); - } - } - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/cldr/CLDRCalendarDataProviderImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java.base/share/classes/sun/util/cldr/CLDRCalendarDataProviderImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2017, 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.util.cldr; + +import static sun.util.locale.provider.LocaleProviderAdapter.Type; + +import java.util.Arrays; +import java.util.Map; +import java.util.Locale; +import java.util.Set; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; +import sun.util.locale.provider.CalendarDataProviderImpl; +import sun.util.locale.provider.CalendarDataUtility; + +/** + * Concrete implementation of the + * {@link java.util.spi.CalendarDataProvider CalendarDataProvider} class + * for the CLDR LocaleProviderAdapter. + * + * @author Naoto Sato + */ +public class CLDRCalendarDataProviderImpl extends CalendarDataProviderImpl { + + private static Map firstDay = new ConcurrentHashMap<>(); + private static Map minDays = new ConcurrentHashMap<>(); + + public CLDRCalendarDataProviderImpl(Type type, Set langtags) { + super(type, langtags); + } + + @Override + public int getFirstDayOfWeek(Locale locale) { + return findValue(CalendarDataUtility.FIRST_DAY_OF_WEEK, locale); + } + + @Override + public int getMinimalDaysInFirstWeek(Locale locale) { + return findValue(CalendarDataUtility.MINIMAL_DAYS_IN_FIRST_WEEK, locale); + } + + /** + * Finds the requested integer value for the locale. + * Each resource consists of the following: + * + * (n: cc1 cc2 ... ccx;)* + * + * where 'n' is the integer for the following region codes, terminated by + * a ';'. + * + */ + private static int findValue(String key, Locale locale) { + Map map = CalendarDataUtility.FIRST_DAY_OF_WEEK.equals(key) ? + firstDay : minDays; + String region = locale.getCountry(); + + if (region.isEmpty()) { + return 0; + } + + Integer val = map.get(region); + if (val == null) { + String valStr = + LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(Locale.ROOT) + .getCalendarData(key); + val = retrieveInteger(valStr, region) + .orElse(retrieveInteger(valStr, "001").orElse(0)); + map.putIfAbsent(region, val); + } + + return val; + } + + private static Optional retrieveInteger(String src, String region) { + return Arrays.stream(src.split(";")) + .filter(entry -> entry.contains(region)) + .map(entry -> entry.substring(0, entry.indexOf(":"))) + .findAny() + .map(Integer::parseInt); + } +} diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java --- a/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java Wed Dec 13 10:25:38 2017 -0800 @@ -27,6 +27,7 @@ import java.security.AccessController; import java.security.AccessControlException; +import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.text.spi.BreakIteratorProvider; @@ -37,15 +38,16 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Objects; +import java.util.Optional; import java.util.ServiceLoader; import java.util.ServiceConfigurationError; import java.util.Set; import java.util.StringTokenizer; import java.util.concurrent.ConcurrentHashMap; +import java.util.spi.CalendarDataProvider; import sun.util.locale.provider.JRELocaleProviderAdapter; +import sun.util.locale.provider.LocaleDataMetaInfo; import sun.util.locale.provider.LocaleProviderAdapter; -import sun.util.locale.provider.LocaleDataMetaInfo; /** * LocaleProviderAdapter implementation for the CLDR locale data. @@ -106,6 +108,24 @@ } @Override + public CalendarDataProvider getCalendarDataProvider() { + if (calendarDataProvider == null) { + CalendarDataProvider provider = AccessController.doPrivileged( + (PrivilegedAction) () -> + new CLDRCalendarDataProviderImpl( + getAdapterType(), + getLanguageTagSet("CalendarData"))); + + synchronized (this) { + if (calendarDataProvider == null) { + calendarDataProvider = provider; + } + } + } + return calendarDataProvider; + } + + @Override public CollatorProvider getCollatorProvider() { return null; } @@ -123,6 +143,10 @@ @Override protected Set createLanguageTagSet(String category) { + // Assume all categories support the same set as AvailableLocales + // in CLDR adapter. + category = "AvailableLocales"; + // Directly call Base tags, as we know it's in the base module. String supportedLocaleString = baseMetaInfo.availableLanguageTags(category); String nonBaseTags = null; @@ -220,4 +244,11 @@ || langtags.contains(locale.stripExtensions().toLanguageTag()) || langtags.contains(getEquivalentLoc(locale).toLanguageTag()); } + + /** + * Returns the time zone ID from an LDML's short ID + */ + public Optional getTimeZoneID(String shortID) { + return Optional.ofNullable(baseMetaInfo.tzShortIDs().get(shortID)); + } } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/locale/provider/CalendarDataProviderImpl.java --- a/src/java.base/share/classes/sun/util/locale/provider/CalendarDataProviderImpl.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/locale/provider/CalendarDataProviderImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,14 +46,16 @@ @Override public int getFirstDayOfWeek(Locale locale) { - return LocaleProviderAdapter.forType(type).getLocaleResources(locale) + String fw = LocaleProviderAdapter.forType(type).getLocaleResources(locale) .getCalendarData(CalendarDataUtility.FIRST_DAY_OF_WEEK); + return convertToCalendarData(fw); } @Override public int getMinimalDaysInFirstWeek(Locale locale) { - return LocaleProviderAdapter.forType(type).getLocaleResources(locale) + String md = LocaleProviderAdapter.forType(type).getLocaleResources(locale) .getCalendarData(CalendarDataUtility.MINIMAL_DAYS_IN_FIRST_WEEK); + return convertToCalendarData(md); } @Override @@ -65,4 +67,9 @@ public Set getAvailableLanguageTags() { return langtags; } + + private int convertToCalendarData(String src) { + int val = Integer.parseInt(src); + return (src.isEmpty() || val <= 0 || val > 7) ? 0 : val; + } } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/locale/provider/CalendarDataUtility.java --- a/src/java.base/share/classes/sun/util/locale/provider/CalendarDataUtility.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/locale/provider/CalendarDataUtility.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,10 +47,34 @@ } public static int retrieveFirstDayOfWeek(Locale locale) { + // Look for the Unicode Extension in the locale parameter + if (locale.hasExtensions()) { + String fw = locale.getUnicodeLocaleType("fw"); + if (fw != null) { + switch (fw.toLowerCase(Locale.ROOT)) { + case "mon": + return MONDAY; + case "tue": + return TUESDAY; + case "wed": + return WEDNESDAY; + case "thu": + return THURSDAY; + case "fri": + return FRIDAY; + case "sat": + return SATURDAY; + case "sun": + return SUNDAY; + } + } + } + LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarDataProvider.class); Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE, - locale, true, FIRST_DAY_OF_WEEK); + findRegionOverride(locale), + true, FIRST_DAY_OF_WEEK); return (value != null && (value >= SUNDAY && value <= SATURDAY)) ? value : SUNDAY; } @@ -58,7 +82,8 @@ LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarDataProvider.class); Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE, - locale, true, MINIMAL_DAYS_IN_FIRST_WEEK); + findRegionOverride(locale), + true, MINIMAL_DAYS_IN_FIRST_WEEK); return (value != null && (value >= 1 && value <= 7)) ? value : 1; } @@ -102,6 +127,32 @@ return map; } + /** + * Utility to look for a region override extension. + * If no region override is found, returns the original locale. + */ + public static Locale findRegionOverride(Locale l) { + String rg = l.getUnicodeLocaleType("rg"); + Locale override = l; + + if (rg != null && rg.length() == 6) { + // UN M.49 code should not be allowed here + // cannot use regex here, as it could be a recursive call + rg = rg.toUpperCase(Locale.ROOT); + if (rg.charAt(0) >= 0x0041 && + rg.charAt(0) <= 0x005A && + rg.charAt(1) >= 0x0041 && + rg.charAt(1) <= 0x005A && + rg.substring(2).equals("ZZZZ")) { + override = new Locale.Builder().setLocale(l) + .setRegion(rg.substring(0, 2)) + .build(); + } + } + + return override; + } + static String normalizeCalendarType(String requestID) { String type; if (requestID.equals("gregorian") || requestID.equals("iso8601")) { @@ -179,7 +230,7 @@ } } - private static class CalendarWeekParameterGetter + private static class CalendarWeekParameterGetter implements LocaleServiceProviderPool.LocalizedObjectGetter { private static final CalendarWeekParameterGetter INSTANCE = diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/locale/provider/DateFormatProviderImpl.java --- a/src/java.base/share/classes/sun/util/locale/provider/DateFormatProviderImpl.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/locale/provider/DateFormatProviderImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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,7 @@ import java.util.Locale; import java.util.MissingResourceException; import java.util.Set; +import java.util.TimeZone; /** * Concrete implementation of the {@link java.text.spi.DateFormatProvider @@ -147,11 +148,14 @@ throw new NullPointerException(); } - SimpleDateFormat sdf = new SimpleDateFormat("", locale); + // Check for region override + Locale rg = CalendarDataUtility.findRegionOverride(locale); + + SimpleDateFormat sdf = new SimpleDateFormat("", rg); Calendar cal = sdf.getCalendar(); try { String pattern = LocaleProviderAdapter.forType(type) - .getLocaleResources(locale).getDateTimePattern(timeStyle, dateStyle, + .getLocaleResources(rg).getDateTimePattern(timeStyle, dateStyle, cal); sdf.applyPattern(pattern); } catch (MissingResourceException mre) { @@ -159,6 +163,15 @@ sdf.applyPattern("M/d/yy h:mm a"); } + // Check for timezone override + String tz = locale.getUnicodeLocaleType("tz"); + if (tz != null) { + sdf.setTimeZone( + TimeZoneNameUtility.convertLDMLShortID(tz) + .map(TimeZone::getTimeZone) + .orElseGet(sdf::getTimeZone)); + } + return sdf; } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java --- a/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -130,7 +130,7 @@ private volatile CurrencyNameProvider currencyNameProvider; private volatile LocaleNameProvider localeNameProvider; private volatile TimeZoneNameProvider timeZoneNameProvider; - private volatile CalendarDataProvider calendarDataProvider; + protected volatile CalendarDataProvider calendarDataProvider; private volatile CalendarNameProvider calendarNameProvider; private volatile CalendarProvider calendarProvider; diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo.java --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package sun.util.locale.provider; +import java.util.Map; + /** * LocaleData meta info SPI * @@ -46,4 +48,13 @@ * @return concatenated language tags, separated by a space. */ public String availableLanguageTags(String category); + + /** + * Returns a map for short time zone ids in BCP47 Unicode extension and + * the long time zone ids. + * @return map of short id to long ids, separated by a space. + */ + default public Map tzShortIDs() { + return null; + } } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/locale/provider/LocaleNameProviderImpl.java --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleNameProviderImpl.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleNameProviderImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -168,6 +168,28 @@ return getDisplayString("%%"+vrnt, locale); } + /** + * @inheritDoc + */ + @Override + public String getDisplayUnicodeExtensionKey(String key, Locale locale) { + super.getDisplayUnicodeExtensionKey(key, locale); // null check + String rbKey = "key." + key; + String name = getDisplayString(rbKey, locale); + return rbKey.equals(name) ? key : name; + } + + /** + * @inheritDoc + */ + @Override + public String getDisplayUnicodeExtensionType(String extType, String key, Locale locale) { + super.getDisplayUnicodeExtensionType(extType, key, locale); // null check + String rbKey = "type." + key + "." + extType; + String name = getDisplayString(rbKey, locale); + return rbKey.equals(name) ? extType : name; + } + private String getDisplayString(String key, Locale locale) { if (key == null || locale == null) { throw new NullPointerException(); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -122,23 +122,21 @@ return (byte[]) localeData.getBreakIteratorResources(locale).getObject(key); } - int getCalendarData(String key) { - Integer caldata; + public String getCalendarData(String key) { + String caldata = ""; String cacheKey = CALENDAR_DATA + key; removeEmptyReferences(); ResourceReference data = cache.get(cacheKey); - if (data == null || ((caldata = (Integer) data.get()) == null)) { + if (data == null || ((caldata = (String) data.get()) == null)) { ResourceBundle rb = localeData.getCalendarData(locale); if (rb.containsKey(key)) { - caldata = Integer.parseInt(rb.getString(key)); - } else { - caldata = 0; + caldata = rb.getString(key); } cache.put(cacheKey, - new ResourceReference(cacheKey, (Object) caldata, referenceQueue)); + new ResourceReference(cacheKey, caldata, referenceQueue)); } return caldata; diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java --- a/src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -173,9 +173,14 @@ throw new NullPointerException(); } + // Check for region override + Locale override = locale.getUnicodeLocaleType("nu") == null ? + CalendarDataUtility.findRegionOverride(locale) : + locale; + LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); - String[] numberPatterns = adapter.getLocaleResources(locale).getNumberPatterns(); - DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locale); + String[] numberPatterns = adapter.getLocaleResources(override).getNumberPatterns(); + DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(override); int entry = (choice == INTEGERSTYLE) ? NUMBERSTYLE : choice; DecimalFormat format = new DecimalFormat(numberPatterns[entry], symbols); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java --- a/src/java.base/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -160,28 +160,24 @@ @Override public BreakIterator getWordInstance(Locale locale) { BreakIteratorProvider bip = getImpl(locale); - assert bip != null; return bip.getWordInstance(locale); } @Override public BreakIterator getLineInstance(Locale locale) { BreakIteratorProvider bip = getImpl(locale); - assert bip != null; return bip.getLineInstance(locale); } @Override public BreakIterator getCharacterInstance(Locale locale) { BreakIteratorProvider bip = getImpl(locale); - assert bip != null; return bip.getCharacterInstance(locale); } @Override public BreakIterator getSentenceInstance(Locale locale) { BreakIteratorProvider bip = getImpl(locale); - assert bip != null; return bip.getSentenceInstance(locale); } @@ -215,7 +211,6 @@ @Override public Collator getInstance(Locale locale) { CollatorProvider cp = getImpl(locale); - assert cp != null; return cp.getInstance(locale); } } @@ -249,21 +244,18 @@ @Override public DateFormat getTimeInstance(int style, Locale locale) { DateFormatProvider dfp = getImpl(locale); - assert dfp != null; return dfp.getTimeInstance(style, locale); } @Override public DateFormat getDateInstance(int style, Locale locale) { DateFormatProvider dfp = getImpl(locale); - assert dfp != null; return dfp.getDateInstance(style, locale); } @Override public DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) { DateFormatProvider dfp = getImpl(locale); - assert dfp != null; return dfp.getDateTimeInstance(dateStyle, timeStyle, locale); } } @@ -297,7 +289,6 @@ @Override public DateFormatSymbols getInstance(Locale locale) { DateFormatSymbolsProvider dfsp = getImpl(locale); - assert dfsp != null; return dfsp.getInstance(locale); } } @@ -331,7 +322,6 @@ @Override public DecimalFormatSymbols getInstance(Locale locale) { DecimalFormatSymbolsProvider dfsp = getImpl(locale); - assert dfsp != null; return dfsp.getInstance(locale); } } @@ -365,28 +355,24 @@ @Override public NumberFormat getCurrencyInstance(Locale locale) { NumberFormatProvider nfp = getImpl(locale); - assert nfp != null; return nfp.getCurrencyInstance(locale); } @Override public NumberFormat getIntegerInstance(Locale locale) { NumberFormatProvider nfp = getImpl(locale); - assert nfp != null; return nfp.getIntegerInstance(locale); } @Override public NumberFormat getNumberInstance(Locale locale) { NumberFormatProvider nfp = getImpl(locale); - assert nfp != null; return nfp.getNumberInstance(locale); } @Override public NumberFormat getPercentInstance(Locale locale) { NumberFormatProvider nfp = getImpl(locale); - assert nfp != null; return nfp.getPercentInstance(locale); } } @@ -420,14 +406,12 @@ @Override public int getFirstDayOfWeek(Locale locale) { CalendarDataProvider cdp = getImpl(locale); - assert cdp != null; return cdp.getFirstDayOfWeek(locale); } @Override public int getMinimalDaysInFirstWeek(Locale locale) { CalendarDataProvider cdp = getImpl(locale); - assert cdp != null; return cdp.getMinimalDaysInFirstWeek(locale); } } @@ -463,7 +447,6 @@ int field, int value, int style, Locale locale) { CalendarNameProvider cdp = getImpl(locale); - assert cdp != null; return cdp.getDisplayName(calendarType, field, value, style, locale); } @@ -472,7 +455,6 @@ int field, int style, Locale locale) { CalendarNameProvider cdp = getImpl(locale); - assert cdp != null; return cdp.getDisplayNames(calendarType, field, style, locale); } } @@ -506,14 +488,12 @@ @Override public String getSymbol(String currencyCode, Locale locale) { CurrencyNameProvider cnp = getImpl(locale); - assert cnp != null; return cnp.getSymbol(currencyCode, locale); } @Override public String getDisplayName(String currencyCode, Locale locale) { CurrencyNameProvider cnp = getImpl(locale); - assert cnp != null; return cnp.getDisplayName(currencyCode, locale); } } @@ -547,30 +527,38 @@ @Override public String getDisplayLanguage(String languageCode, Locale locale) { LocaleNameProvider lnp = getImpl(locale); - assert lnp != null; return lnp.getDisplayLanguage(languageCode, locale); } @Override public String getDisplayScript(String scriptCode, Locale locale) { LocaleNameProvider lnp = getImpl(locale); - assert lnp != null; return lnp.getDisplayScript(scriptCode, locale); } @Override public String getDisplayCountry(String countryCode, Locale locale) { LocaleNameProvider lnp = getImpl(locale); - assert lnp != null; return lnp.getDisplayCountry(countryCode, locale); } @Override public String getDisplayVariant(String variant, Locale locale) { LocaleNameProvider lnp = getImpl(locale); - assert lnp != null; return lnp.getDisplayVariant(variant, locale); } + + @Override + public String getDisplayUnicodeExtensionKey(String key, Locale locale) { + LocaleNameProvider lnp = getImpl(locale); + return lnp.getDisplayUnicodeExtensionKey(key, locale); + } + + @Override + public String getDisplayUnicodeExtensionType(String extType, String key, Locale locale) { + LocaleNameProvider lnp = getImpl(locale); + return lnp.getDisplayUnicodeExtensionType(extType, key, locale); + } } static class TimeZoneNameProviderDelegate extends TimeZoneNameProvider @@ -602,14 +590,12 @@ @Override public String getDisplayName(String ID, boolean daylight, int style, Locale locale) { TimeZoneNameProvider tznp = getImpl(locale); - assert tznp != null; return tznp.getDisplayName(ID, daylight, style, locale); } @Override public String getGenericDisplayName(String ID, int style, Locale locale) { TimeZoneNameProvider tznp = getImpl(locale); - assert tznp != null; return tznp.getGenericDisplayName(ID, style, locale); } } diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java --- a/src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,10 +31,13 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.spi.TimeZoneNameProvider; import sun.util.calendar.ZoneInfo; +import sun.util.cldr.CLDRLocaleProviderAdapter; +import static sun.util.locale.provider.LocaleProviderAdapter.Type; /** * Utility class that deals with the localized time zone names @@ -152,6 +155,18 @@ } } + /** + * Converts the time zone id from LDML's 5-letter id to tzdb's id + * + * @param shortID time zone short ID defined in LDML + * @return the tzdb's time zone ID + */ + public static Optional convertLDMLShortID(String shortID) { + return ((CLDRLocaleProviderAdapter)LocaleProviderAdapter.forType(Type.CLDR)) + .getTimeZoneID(shortID) + .map(id -> id.replaceAll("\\s.*", "")); + } + private static String[] retrieveDisplayNamesImpl(String id, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(TimeZoneNameProvider.class); diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/classes/sun/util/resources/LocaleNames.properties --- a/src/java.base/share/classes/sun/util/resources/LocaleNames.properties Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/share/classes/sun/util/resources/LocaleNames.properties Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2017, 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 @@ -1164,8 +1164,7 @@ # locale name patterns -# rarely localized DisplayNamePattern={0,choice,0#|1#{1}|2#{1} ({2})} -ListPattern={0,choice,0#|1#{1}|2#{1},{2}|3#{1},{2},{3}} +ListKeyTypePattern={0}:{1} ListCompositionPattern={0},{1} diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/share/lib/security/cacerts Binary file src/java.base/share/lib/security/cacerts has changed diff -r 093027a037cf -r 191ae61bd1e9 src/java.base/windows/native/libnio/ch/SocketDispatcher.c --- a/src/java.base/windows/native/libnio/ch/SocketDispatcher.c Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.base/windows/native/libnio/ch/SocketDispatcher.c Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, 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 @@ -179,7 +179,7 @@ } } - count += written; + count += (jint)written; address += written; } while ((count < total) && (written == MAX_BUFFER_SIZE)); diff -r 093027a037cf -r 191ae61bd1e9 src/java.xml/share/classes/org/w3c/dom/ls/DOMImplementationLS.java --- a/src/java.xml/share/classes/org/w3c/dom/ls/DOMImplementationLS.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.xml/share/classes/org/w3c/dom/ls/DOMImplementationLS.java Wed Dec 13 10:25:38 2017 -0800 @@ -51,12 +51,13 @@ * binding-specific casting methods on an instance of the * DOMImplementation interface or, if the Document * supports the feature "Core" version "3.0" - * defined in [DOM Level 3 Core] + * defined in + * [DOM Level 3 Core] * , by using the method DOMImplementation.getFeature with * parameter values "LS" (or "LS-Async") and * "3.0" (respectively). - *

See also the Document Object Model (DOM) Level 3 Load -and Save Specification. + *

See also the +Document Object Model (DOM) Level 3 Load and Save Specification. * * @since 1.5 */ @@ -90,9 +91,11 @@ * LSParser for any kind of schema types (i.e. the * LSParser will be free to use any schema found), use the value * null. - *

Note: For W3C XML Schema [XML Schema Part 1] + *

Note: For W3C XML Schema + * [XML Schema Part 1] * , applications must use the value - * "http://www.w3.org/2001/XMLSchema". For XML DTD [XML 1.0], + * "http://www.w3.org/2001/XMLSchema". For XML DTD + * [XML 1.0], * applications must use the value * "http://www.w3.org/TR/REC-xml". Other Schema languages * are outside the scope of the W3C and therefore should recommend an @@ -102,8 +105,8 @@ * depending on the value of the mode argument. *

Note: By default, the newly created LSParser * does not contain a DOMErrorHandler, i.e. the value of - * the " - * error-handler" configuration parameter is null. However, implementations + * the "error-handler" + * configuration parameter is null. However, implementations * may provide a default error handler at creation time. In that case, * the initial value of the "error-handler" configuration * parameter on the new LSParser object contains a diff -r 093027a037cf -r 191ae61bd1e9 src/java.xml/share/classes/org/w3c/dom/ls/LSParser.java --- a/src/java.xml/share/classes/org/w3c/dom/ls/LSParser.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.xml/share/classes/org/w3c/dom/ls/LSParser.java Wed Dec 13 10:25:38 2017 -0800 @@ -53,7 +53,8 @@ * corresponding DOM document structure. A LSParser instance * can be obtained by invoking the * DOMImplementationLS.createLSParser() method. - *

As specified in [DOM Level 3 Core] + *

As specified in + * [DOM Level 3 Core] * , when a document is first made available via the LSParser: *

    *
  • there will @@ -63,16 +64,18 @@ *
  • it is expected that the value and * nodeValue attributes of an Attr node initially * return the XML 1.0 - * normalized value. However, if the parameters " - * validate-if-schema" and " - * datatype-normalization" are set to true, depending on the attribute normalization + * normalized value. However, if the parameters + * "validate-if-schema" and + * "datatype-normalization" + * are set to true, depending on the attribute normalization * used, the attribute values may differ from the ones obtained by the XML - * 1.0 attribute normalization. If the parameters " - * datatype-normalization" is set to false, the XML 1.0 attribute normalization is + * 1.0 attribute normalization. If the parameters + * "datatype-normalization" + * is set to false, the XML 1.0 attribute normalization is * guaranteed to occur, and if the attributes list does not contain * namespace declarations, the attributes attribute on - * Element node represents the property [attributes] defined in [XML Information Set] - * . + * Element node represents the property [attributes] defined in + * [XML Information Set]. *
  • *
*

Asynchronous LSParser objects are expected to also @@ -102,17 +105,18 @@ *

Note: All events defined in this specification use the * namespace URI "http://www.w3.org/2002/DOMLS". *

While parsing an input source, errors are reported to the application - * through the error handler (LSParser.domConfig's " - * error-handler" parameter). This specification does in no way try to define all possible + * through the error handler (LSParser.domConfig's + * "error-handler" + * parameter). This specification does in no way try to define all possible * errors that can occur while parsing XML, or any other markup, but some * common error cases are defined. The types (DOMError.type) of * errors and warnings defined by this specification are: *

*
* "check-character-normalization-failure" [error]
- *
Raised if - * the parameter " - * check-character-normalization" is set to true and a string is encountered that fails normalization + *
Raised if the parameter + * "check-character-normalization" + * is set to true and a string is encountered that fails normalization * checking.
*
"doctype-not-allowed" [fatal]
*
Raised if the @@ -127,8 +131,9 @@ *
Raised if a processing * instruction is encountered in a location where the base URI of the * processing instruction can not be preserved. One example of a case where - * this warning will be raised is if the configuration parameter " - * entities" is set to false and the following XML file is parsed: + * this warning will be raised is if the configuration parameter + * "entities" + * is set to false and the following XML file is parsed: *
  * <!DOCTYPE root [ <!ENTITY e SYSTEM 'subdir/myentity.ent' ]>
  * <root> &e; </root>
@@ -139,9 +144,9 @@ *
*
"unbound-prefix-in-entity" [warning]
*
An - * implementation dependent warning that may be raised if the configuration - * parameter " - * namespaces" is set to true and an unbound namespace prefix is + * implementation dependent warning that may be raised if the configuration parameter + * "namespaces" + * is set to true and an unbound namespace prefix is * encountered in an entity's replacement text. Raising this warning is not * enforced since some existing parsers may not recognize unbound namespace * prefixes in the replacement text of entities.
@@ -164,8 +169,8 @@ * are expected to raise implementation specific errors and warnings for any * other error and warning cases such as IO errors (file not found, * permission denied,...), XML well-formedness errors, and so on. - *

See also the Document Object Model (DOM) Level 3 Load -and Save Specification. + *

See also the + * Document Object Model (DOM) Level 3 Load and Save Specification. * * @since 1.5 */ @@ -180,8 +185,10 @@ * needed parameter values from this DOMConfiguration * object to the DOMConfiguration object referenced by the * Document object. - *
In addition to the parameters recognized in on the - * DOMConfiguration interface defined in [DOM Level 3 Core] + *
In addition to the parameters recognized in on the + * DOMConfiguration + * interface defined in + * [DOM Level 3 Core] * , the DOMConfiguration objects for LSParser * add or modify the following parameters: *

@@ -190,7 +197,8 @@ *
*
*
true
- *
[optional] (default) If a higher level protocol such as HTTP [IETF RFC 2616] provides an + *
[optional] (default) If a higher level protocol such as HTTP + * [IETF RFC 2616] provides an * indication of the character encoding of the input stream being * processed, that will override any encoding specified in the XML * declaration or the Text declaration (see also section 4.3.3, @@ -206,7 +214,8 @@ *
*
* true
- *
[optional] Throw a fatal "doctype-not-allowed" error if a doctype node is found while parsing the document. This is + *
[optional] Throw a fatal "doctype-not-allowed" error + * if a doctype node is found while parsing the document. This is * useful when dealing with things like SOAP envelopes where doctype * nodes are not allowed.
*
false
@@ -218,14 +227,17 @@ *
*
* true
- *
[required] (default) If, while verifying full normalization when [XML 1.1] is + *
[required] (default) If, while verifying full normalization when + * [XML 1.1] is * supported, a processor encounters characters for which it cannot * determine the normalization properties, then the processor will * ignore any possible denormalizations caused by these characters. - * This parameter is ignored for [XML 1.0].
+ * This parameter is ignored for [XML 1.0]. + *
*
* false
- *
[optional] Report an fatal "unknown-character-denormalization" error if a character is encountered for which the processor cannot + *
[optional] Report an fatal "unknown-character-denormalization" + * error if a character is encountered for which the processor cannot * determine the normalization properties.
*
*
"infoset"
@@ -238,7 +250,8 @@ *
*
*
true
- *
[required] (default) Perform the namespace processing as defined in [XML Namespaces] + *
[required] (default) Perform the namespace processing as defined in + * [XML Namespaces] * and [XML Namespaces 1.1] * .
*
false
@@ -259,7 +272,8 @@ * true *
[optional] Check that the media type of the parsed resource is a supported media * type. If an unsupported media type is encountered, a fatal error of - * type "unsupported-media-type" will be raised. The media types defined in [IETF RFC 3023] must always + * type "unsupported-media-type" will be raised. The media types defined in + * [IETF RFC 3023] must always * be accepted.
*
false
*
[required] (default) Accept any media type.
@@ -294,8 +308,8 @@ * terminate the parsing early. *
The filter is invoked after the operations requested by the * DOMConfiguration parameters have been applied. For - * example, if " - * validate" is set to true, the validation is done before invoking the + * example, if "validate" + * is set to true, the validation is done before invoking the * filter. */ public LSParserFilter getFilter(); @@ -306,8 +320,8 @@ * terminate the parsing early. *
The filter is invoked after the operations requested by the * DOMConfiguration parameters have been applied. For - * example, if " - * validate" is set to true, the validation is done before invoking the + * example, if "validate" + * is set to true, the validation is done before invoking the * filter. */ public void setFilter(LSParserFilter filter); @@ -340,15 +354,18 @@ * @exception LSException * PARSE_ERR: Raised if the LSParser was unable to load * the XML document. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public Document parse(LSInput input) throws DOMException, LSException; /** - * Parse an XML document from a location identified by a URI reference [IETF RFC 2396]. If the URI - * contains a fragment identifier (see section 4.1 in [IETF RFC 2396]), the + * Parse an XML document from a location identified by a URI reference + * [IETF RFC 2396]. If the URI + * contains a fragment identifier (see section 4.1 in + * [IETF RFC 2396]), the * behavior is not defined by this specification, future versions of * this specification may define the behavior. * @param uri The location of the XML document to be read. @@ -364,8 +381,9 @@ * @exception LSException * PARSE_ERR: Raised if the LSParser was unable to load * the XML document. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public Document parseURI(String uri) throws DOMException, LSException; @@ -431,14 +449,17 @@ * LSParser is asynchronous (LSParser.async is * true). *
If an error occurs while parsing, the caller is notified through - * the ErrorHandler instance associated with the " - * error-handler" parameter of the DOMConfiguration. + * the ErrorHandler instance associated with the + * "error-handler" + * parameter of the DOMConfiguration. *
When calling parseWithContext, the values of the * following configuration parameters will be ignored and their default - * values will always be used instead: " - * validate", " - * validate-if-schema", and " - * element-content-whitespace". Other parameters will be treated normally, and the parser is expected + * values will always be used instead: + * "validate", + * "validate-if-schema", + * and + * "element-content-whitespace". + * Other parameters will be treated normally, and the parser is expected * to call the LSParserFilter just as if a whole document * was parsed. * @param input The LSInput from which the source document @@ -463,7 +484,8 @@ * @exception DOMException * HIERARCHY_REQUEST_ERR: Raised if the content cannot replace, be * inserted before, after, or as a child of the context node (see also - * Node.insertBefore or Node.replaceChild in [DOM Level 3 Core] + * Node.insertBefore or Node.replaceChild in + * [DOM Level 3 Core] * ). *
NOT_SUPPORTED_ERR: Raised if the LSParser doesn't * support this method, or if the context node is of type @@ -479,8 +501,9 @@ * @exception LSException * PARSE_ERR: Raised if the LSParser was unable to load * the XML fragment. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public Node parseWithContext(LSInput input, Node contextArg, diff -r 093027a037cf -r 191ae61bd1e9 src/java.xml/share/classes/org/w3c/dom/ls/LSParserFilter.java --- a/src/java.xml/share/classes/org/w3c/dom/ls/LSParserFilter.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.xml/share/classes/org/w3c/dom/ls/LSParserFilter.java Wed Dec 13 10:25:38 2017 -0800 @@ -56,10 +56,11 @@ * Document, DocumentType, Notation, * Entity, and Attr nodes are never passed to the * acceptNode method on the filter. The child nodes of an - * EntityReference node are passed to the filter if the - * parameter " - * entities" is set to false. Note that, as described by the parameter " - * entities", unexpanded entity reference nodes are never discarded and are always + * EntityReference node are passed to the filter if the parameter + * "entities" + * is set to false. Note that, as described by the parameter + * "entities", + * unexpanded entity reference nodes are never discarded and are always * passed to the filter. *

All validity checking while parsing a document occurs on the source * document as it appears on the input stream, not on the DOM document as it @@ -71,8 +72,8 @@ * passed to the filter methods. *

DOM applications must not raise exceptions in a filter. The effect of * throwing exceptions from a filter is DOM implementation dependent. - *

See also the Document Object Model (DOM) Level 3 Load -and Save Specification. + *

See also the +Document Object Model (DOM) Level 3 Load and Save Specification. * * @since 1.5 */ @@ -195,8 +196,8 @@ * SHOW_NOTATION, SHOW_ENTITY, and * SHOW_DOCUMENT_FRAGMENT are meaningless here. Those nodes * will never be passed to LSParserFilter.acceptNode. - *
The constants used here are defined in [DOM Level 2 Traversal and Range] - * . + *
The constants used here are defined in + * [DOM Level 2 Traversal and Range]. */ public int getWhatToShow(); diff -r 093027a037cf -r 191ae61bd1e9 src/java.xml/share/classes/org/w3c/dom/ls/LSSerializer.java --- a/src/java.xml/share/classes/org/w3c/dom/ls/LSSerializer.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/java.xml/share/classes/org/w3c/dom/ls/LSSerializer.java Wed Dec 13 10:25:38 2017 -0800 @@ -51,7 +51,8 @@ * output stream. Any changes or fixups made during the serialization affect * only the serialized data. The Document object and its * children are never altered by the serialization operation. - *

During serialization of XML data, namespace fixup is done as defined in [DOM Level 3 Core] + *

During serialization of XML data, namespace fixup is done as defined in + * [DOM Level 3 Core] * , Appendix B. [DOM Level 2 Core] * allows empty strings as a real namespace URI. If the * namespaceURI of a Node is empty string, the @@ -80,12 +81,14 @@ * namespace fixup is done. The resulting output will be valid as an * external entity. * - *

  • If the parameter " - * entities" is set to true, EntityReference nodes are + *
  • If the parameter + * "entities" + * is set to true, EntityReference nodes are * serialized as an entity reference of the form " * &entityName;" in the output. Child nodes (the expansion) - * of the entity reference are ignored. If the parameter " - * entities" is set to false, only the children of the entity reference + * of the entity reference are ignored. If the parameter + * "entities" + * is set to false, only the children of the entity reference * are serialized. EntityReference nodes with no children (no * corresponding Entity node or the corresponding * Entity nodes have no children) are always serialized. @@ -93,15 +96,16 @@ *
  • * CDATAsections containing content characters that cannot be * represented in the specified output encoding are handled according to the - * " - * split-cdata-sections" parameter. If the parameter is set to true, + * "split-cdata-sections" + * parameter. If the parameter is set to true, * CDATAsections are split, and the unrepresentable characters * are serialized as numeric character references in ordinary content. The * exact position and number of splits is not specified. If the parameter * is set to false, unrepresentable characters in a * CDATAsection are reported as - * "wf-invalid-character" errors if the parameter " - * well-formed" is set to true. The error is not recoverable - there is no + * "wf-invalid-character" errors if the parameter + * "well-formed" + * is set to true. The error is not recoverable - there is no * mechanism for supplying alternative characters and continuing with the * serialization. *
  • @@ -138,12 +142,15 @@ * as a DOMError fatal error. An example would be serializing * the element <LaCañada/> with encoding="us-ascii". * This will result with a generation of a DOMError - * "wf-invalid-character-in-node-name" (as proposed in " - * well-formed"). - *

    When requested by setting the parameter " - * normalize-characters" on LSSerializer to true, character normalization is - * performed according to the definition of fully - * normalized characters included in appendix E of [XML 1.1] on all + * "wf-invalid-character-in-node-name" (as proposed in + * "well-formed"). + *

    When requested by setting the parameter + * "normalize-characters" + * on LSSerializer to true, character normalization is + * performed according to the definition of + * fully + * normalized characters included in appendix E of + * [XML 1.1] on all * data to be serialized, both markup and character data. The character * normalization process affects only the data as it is being written; it * does not alter the DOM's view of the document after serialization has @@ -170,13 +177,15 @@ * inconsistencies are found, the serialized form of the document will be * altered to remove them. The method used for doing the namespace fixup * while serializing a document is the algorithm defined in Appendix B.1, - * "Namespace normalization", of [DOM Level 3 Core] + * "Namespace normalization", of + * [DOM Level 3 Core] * . *

    While serializing a document, the parameter "discard-default-content" * controls whether or not non-specified data is serialized. *

    While serializing, errors and warnings are reported to the application - * through the error handler (LSSerializer.domConfig's " - * error-handler" parameter). This specification does in no way try to define all possible + * through the error handler (LSSerializer.domConfig's + * "error-handler" + * parameter). This specification does in no way try to define all possible * errors and warnings that can occur while serializing a DOM node, but some * common error and warning cases are defined. The types ( * DOMError.type) of errors and warnings defined by this @@ -189,8 +198,9 @@ *

    * "unbound-prefix-in-entity-reference" [fatal]
    *
    Raised if the - * configuration parameter " - * namespaces" is set to true and an entity whose replacement text + * configuration parameter + * "namespaces" + * is set to true and an entity whose replacement text * contains unbound namespace prefixes is referenced in a location where * there are no bindings for the namespace prefixes.
    *
    @@ -202,8 +212,9 @@ * are expected to raise implementation specific errors and warnings for any * other error and warning cases such as IO errors (file not found, * permission denied,...) and so on. - *

    See also the Document Object Model (DOM) Level 3 Load -and Save Specification. + *

    See also the + * +Document Object Model (DOM) Level 3 Load and Save Specification. * * @since 1.5 */ @@ -211,8 +222,10 @@ /** * The DOMConfiguration object used by the * LSSerializer when serializing a DOM node. - *
    In addition to the parameters recognized by the - * DOMConfiguration interface defined in [DOM Level 3 Core] + *
    In addition to the parameters recognized by the + * DOMConfiguration + * interface defined in + * [DOM Level 3 Core] * , the DOMConfiguration objects for * LSSerializer adds, or modifies, the following * parameters: @@ -221,9 +234,11 @@ *

    *
    *
    true
    - *
    [optional] Writes the document according to the rules specified in [Canonical XML]. - * In addition to the behavior described in " - * canonical-form" [DOM Level 3 Core] + *
    [optional] Writes the document according to the rules specified in + * [Canonical XML]. + * In addition to the behavior described in + * "canonical-form" + * [DOM Level 3 Core] * , setting this parameter to true will set the parameters * "format-pretty-print", "discard-default-content", and "xml-declaration * ", to false. Setting one of those parameters to @@ -267,7 +282,8 @@ *
    *
    * true
    - *
    [required] (default) If, while verifying full normalization when [XML 1.1] is + *
    [required] (default) If, while verifying full normalization when + * [XML 1.1] is * supported, a character is encountered for which the normalization * properties cannot be determined, then raise a * "unknown-character-denormalization" warning (instead of @@ -281,18 +297,21 @@ *
    * "normalize-characters"
    *
    This parameter is equivalent to - * the one defined by DOMConfiguration in [DOM Level 3 Core] + * the one defined by DOMConfiguration in + * [DOM Level 3 Core] * . Unlike in the Core, the default value for this parameter is * true. While DOM implementations are not required to * support fully - * normalizing the characters in the document according to appendix E of [XML 1.1], this + * normalizing the characters in the document according to appendix E of + * [XML 1.1], this * parameter must be activated by default if supported.
    *
    * "xml-declaration"
    *
    *
    *
    true
    - *
    [required] (default) If a Document, Element, or Entity + *
    [required] (default) If a Document, + * Element, or Entity * node is serialized, the XML declaration, or text declaration, should * be included. The version (Document.xmlVersion if the * document is a Level 3 document and the version is non-null, otherwise @@ -303,7 +322,8 @@ * false *
    [required] Do not serialize the XML and text declarations. Report a * "xml-declaration-needed" warning if this will cause - * problems (i.e. the serialized data is of an XML version other than [XML 1.0], or an + * problems (i.e. the serialized data is of an XML version other than + * [XML 1.0], or an * encoding would be needed to be able to re-parse the serialized data).
    *
    *
    @@ -314,8 +334,8 @@ * The end-of-line sequence of characters to be used in the XML being * written out. Any string is supported, but XML treats only a certain * set of characters sequence as end-of-line (See section 2.11, - * "End-of-Line Handling" in [XML 1.0], if the - * serialized content is XML 1.0 or section 2.11, "End-of-Line Handling" + * "End-of-Line Handling" in [XML 1.0], + * if the serialized content is XML 1.0 or section 2.11, "End-of-Line Handling" * in [XML 1.1], if the * serialized content is XML 1.1). Using other character sequences than * the recommended ones can result in a document that is either not @@ -335,8 +355,8 @@ * The end-of-line sequence of characters to be used in the XML being * written out. Any string is supported, but XML treats only a certain * set of characters sequence as end-of-line (See section 2.11, - * "End-of-Line Handling" in [XML 1.0], if the - * serialized content is XML 1.0 or section 2.11, "End-of-Line Handling" + * "End-of-Line Handling" in [XML 1.0], + * if the serialized content is XML 1.0 or section 2.11, "End-of-Line Handling" * in [XML 1.1], if the * serialized content is XML 1.1). Using other character sequences than * the recommended ones can result in a document that is either not @@ -360,8 +380,9 @@ * serialization early. *
    The filter is invoked after the operations requested by the * DOMConfiguration parameters have been applied. For - * example, CDATA sections won't be passed to the filter if " - * cdata-sections" is set to false. + * example, CDATA sections won't be passed to the filter if + * "cdata-sections" + * is set to false. */ public LSSerializerFilter getFilter(); /** @@ -371,8 +392,9 @@ * serialization early. *
    The filter is invoked after the operations requested by the * DOMConfiguration parameters have been applied. For - * example, CDATA sections won't be passed to the filter if " - * cdata-sections" is set to false. + * example, CDATA sections won't be passed to the filter if + * "cdata-sections" + * is set to false. */ public void setFilter(LSSerializerFilter filter); @@ -414,8 +436,9 @@ * @exception LSException * SERIALIZE_ERR: Raised if the LSSerializer was unable to * serialize the node. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public boolean write(Node nodeArg, LSOutput destination) @@ -436,8 +459,9 @@ * @exception LSException * SERIALIZE_ERR: Raised if the LSSerializer was unable to * serialize the node. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public boolean writeToURI(Node nodeArg, String uri) @@ -458,8 +482,9 @@ * @exception LSException * SERIALIZE_ERR: Raised if the LSSerializer was unable to * serialize the node. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public String writeToString(Node nodeArg) throws DOMException, LSException; diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Wed Dec 13 10:25:38 2017 -0800 @@ -4238,9 +4238,6 @@ public void visitTypeArray(JCArrayTypeTree tree) { Type etype = attribType(tree.elemtype, env); Type type = new ArrayType(etype, syms.arrayClass); - if (etype.isErroneous()) { - type = types.createErrorType(type); - } result = check(tree, type, KindSelector.TYP, resultInfo); } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Secmod.java --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Secmod.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Secmod.java Wed Dec 13 10:25:38 2017 -0800 @@ -196,13 +196,23 @@ } if (configDir != null) { - File configBase = new File(configDir); - if (configBase.isDirectory() == false ) { - throw new IOException("configDir must be a directory: " + configDir); + String configDirPath = null; + String sqlPrefix = "sql:/"; + if (!configDir.startsWith(sqlPrefix)) { + configDirPath = configDir; + } else { + StringBuilder configDirPathSB = new StringBuilder(configDir); + configDirPath = configDirPathSB.substring(sqlPrefix.length()); } - File secmodFile = new File(configBase, "secmod.db"); - if (secmodFile.isFile() == false) { - throw new FileNotFoundException(secmodFile.getPath()); + File configBase = new File(configDirPath); + if (configBase.isDirectory() == false ) { + throw new IOException("configDir must be a directory: " + configDirPath); + } + if (!configDir.startsWith(sqlPrefix)) { + File secmodFile = new File(configBase, "secmod.db"); + if (secmodFile.isFile() == false) { + throw new FileNotFoundException(secmodFile.getPath()); + } } } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.dynalink/share/classes/jdk/dynalink/StandardOperation.java --- a/src/jdk.dynalink/share/classes/jdk/dynalink/StandardOperation.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.dynalink/share/classes/jdk/dynalink/StandardOperation.java Wed Dec 13 10:25:38 2017 -0800 @@ -111,6 +111,15 @@ */ SET, /** + * Removes the value from a namespace defined on an object. Call sites with this + * operation should have a signature of + * (receiver, name)→void or + * (receiver)→void when used with {@link NamedOperation}, + * with all parameters being of any type (either primitive + * or reference). This operation must always be used as part of a {@link NamespaceOperation}. + */ + REMOVE, + /** * Call a callable object. Call sites with this operation should have a * signature of (callable, receiver, arguments...)→value, * with all parameters and return type being of any type (either primitive or diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java --- a/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java Wed Dec 13 10:25:38 2017 -0800 @@ -107,7 +107,8 @@ /** * A class that provides linking capabilities for a single POJO class. Normally not used directly, but managed by - * {@link BeansLinker}. + * {@link BeansLinker}. Most of the functionality is provided by the {@link AbstractJavaLinker} superclass; this + * class adds length and element operations for arrays and collections. */ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicLinker { BeanLinker(final Class clazz) { @@ -147,6 +148,8 @@ return getElementGetter(req.popNamespace()); } else if (op == StandardOperation.SET) { return getElementSetter(req.popNamespace()); + } else if (op == StandardOperation.REMOVE) { + return getElementRemover(req.popNamespace()); } } } @@ -228,7 +231,7 @@ // dealing with an array, or a list or map, but hey... // Note that for arrays and lists, using LinkerServices.asType() will ensure that any language specific linkers // in use will get a chance to perform any (if there's any) implicit conversion to integer for the indices. - if(declaredType.isArray()) { + if(declaredType.isArray() && arrayMethod != null) { return new GuardedInvocationComponentAndCollectionType( createInternalFilteredGuardedInvocationComponent(arrayMethod.apply(declaredType), linkerServices), CollectionType.ARRAY); @@ -240,7 +243,7 @@ return new GuardedInvocationComponentAndCollectionType( createInternalFilteredGuardedInvocationComponent(mapMethod, linkerServices), CollectionType.MAP); - } else if(clazz.isArray()) { + } else if(clazz.isArray() && arrayMethod != null) { return new GuardedInvocationComponentAndCollectionType( getClassGuardedInvocationComponent(linkerServices.filterInternalObjects(arrayMethod.apply(clazz)), callSiteType), CollectionType.ARRAY); @@ -450,7 +453,7 @@ } @SuppressWarnings("unused") - private static void noOpSetter() { + private static void noOp() { } private static final MethodHandle SET_LIST_ELEMENT = Lookup.PUBLIC.findVirtual(List.class, "set", @@ -459,12 +462,14 @@ private static final MethodHandle PUT_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "put", MethodType.methodType(Object.class, Object.class, Object.class)); - private static final MethodHandle NO_OP_SETTER_2; - private static final MethodHandle NO_OP_SETTER_3; + private static final MethodHandle NO_OP_1; + private static final MethodHandle NO_OP_2; + private static final MethodHandle NO_OP_3; static { - final MethodHandle noOpSetter = Lookup.findOwnStatic(MethodHandles.lookup(), "noOpSetter", void.class); - NO_OP_SETTER_2 = dropObjectArguments(noOpSetter, 2); - NO_OP_SETTER_3 = dropObjectArguments(noOpSetter, 3); + final MethodHandle noOp = Lookup.findOwnStatic(MethodHandles.lookup(), "noOp", void.class); + NO_OP_1 = dropObjectArguments(noOp, 1); + NO_OP_2 = dropObjectArguments(noOp, 2); + NO_OP_3 = dropObjectArguments(noOp, 3); } private GuardedInvocationComponent getElementSetter(final ComponentLinkRequest req) throws Exception { @@ -503,7 +508,39 @@ return gic.replaceInvocation(binder.bind(invocation)); } - return guardComponentWithRangeCheck(gicact, callSiteType, nextComponent, binder, isFixedKey ? NO_OP_SETTER_2 : NO_OP_SETTER_3); + return guardComponentWithRangeCheck(gicact, callSiteType, nextComponent, binder, isFixedKey ? NO_OP_2 : NO_OP_3); + } + + private static final MethodHandle REMOVE_LIST_ELEMENT = Lookup.PUBLIC.findVirtual(List.class, "remove", + MethodType.methodType(Object.class, int.class)); + + private static final MethodHandle REMOVE_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "remove", + MethodType.methodType(Object.class, Object.class)); + + private GuardedInvocationComponent getElementRemover(final ComponentLinkRequest req) throws Exception { + final CallSiteDescriptor callSiteDescriptor = req.getDescriptor(); + final Object name = req.name; + final boolean isFixedKey = name != null; + assertParameterCount(callSiteDescriptor, isFixedKey ? 1 : 2); + final LinkerServices linkerServices = req.linkerServices; + final MethodType callSiteType = callSiteDescriptor.getMethodType(); + final GuardedInvocationComponent nextComponent = getNextComponent(req); + + final GuardedInvocationComponentAndCollectionType gicact = guardedInvocationComponentAndCollectionType( + callSiteType, linkerServices, null, REMOVE_LIST_ELEMENT, REMOVE_MAP_ELEMENT); + + if (gicact == null) { + // Can't remove elements for objects that are neither lists, nor maps. + return nextComponent; + } + + final Object typedName = getTypedName(name, gicact.collectionType == CollectionType.MAP, linkerServices); + if (typedName == INVALID_NAME) { + return nextComponent; + } + + return guardComponentWithRangeCheck(gicact, callSiteType, nextComponent, + new Binder(linkerServices, callSiteType, typedName), isFixedKey ? NO_OP_1: NO_OP_2); } private static final MethodHandle GET_COLLECTION_LENGTH = Lookup.PUBLIC.findVirtual(Collection.class, "size", diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java --- a/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java Wed Dec 13 10:25:38 2017 -0800 @@ -113,6 +113,8 @@ *
  • expose elements of native Java arrays, {@link java.util.List} and {@link java.util.Map} objects as * {@link StandardOperation#GET} and {@link StandardOperation#SET} operations in the * {@link StandardNamespace#ELEMENT} namespace;
  • + *
  • expose removal of elements of {@link java.util.List} and {@link java.util.Map} objects as + * {@link StandardOperation#REMOVE} operation in the {@link StandardNamespace#ELEMENT} namespace;
  • *
  • expose a virtual property named {@code length} on Java arrays, {@link java.util.Collection} and * {@link java.util.Map} objects;
  • *
  • expose {@link StandardOperation#NEW} on instances of {@link StaticClass} diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java Wed Dec 13 10:25:38 2017 -0800 @@ -128,6 +128,9 @@ /** Returns List */ public List getMonitors() { + if (getScope() == null) { + return new ArrayList<>(); + } List monitors = getScope().getMonitors(); if (monitors == null) { return new ArrayList<>(); diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2ClientImpl.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2ClientImpl.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2ClientImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -36,6 +36,8 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CompletableFuture; + +import jdk.incubator.http.internal.common.Log; import jdk.incubator.http.internal.common.MinimalFuture; import jdk.incubator.http.internal.common.Utils; import jdk.incubator.http.internal.frame.SettingsFrame; @@ -78,10 +80,6 @@ } } -// boolean haveConnectionFor(URI uri, InetSocketAddress proxy) { -// return connections.containsKey(Http2Connection.keyFor(uri,proxy)); -// } - /** * If a https request then async waits until a connection is opened. * Returns null if the request is 'http' as a different (upgrade) @@ -188,18 +186,64 @@ private static final int K = 1024; + private static int getParameter(String property, int min, int max, int defaultValue) { + int value = Utils.getIntegerNetProperty(property, defaultValue); + // use default value if misconfigured + if (value < min || value > max) { + Log.logError("Property value for {0}={1} not in [{2}..{3}]: " + + "using default={4}", property, value, min, max, defaultValue); + value = defaultValue; + } + return value; + } + + // used for the connection window, to have a connection window size + // bigger than the initial stream window size. + int getConnectionWindowSize(SettingsFrame clientSettings) { + // Maximum size is 2^31-1. Don't allow window size to be less + // than the stream window size. HTTP/2 specify a default of 64 * K -1, + // but we use 2^26 by default for better performance. + int streamWindow = clientSettings.getParameter(INITIAL_WINDOW_SIZE); + + // The default is the max between the stream window size + // and the connection window size. + int defaultValue = Math.min(Integer.MAX_VALUE, + Math.max(streamWindow, K*K*32)); + + return getParameter( + "jdk.httpclient.connectionWindowSize", + streamWindow, Integer.MAX_VALUE, defaultValue); + } + SettingsFrame getClientSettings() { SettingsFrame frame = new SettingsFrame(); - frame.setParameter(HEADER_TABLE_SIZE, Utils.getIntegerNetProperty( - "jdk.httpclient.hpack.maxheadertablesize", 16 * K)); - frame.setParameter(ENABLE_PUSH, Utils.getIntegerNetProperty( - "jdk.httpclient.enablepush", 1)); - frame.setParameter(MAX_CONCURRENT_STREAMS, Utils.getIntegerNetProperty( - "jdk.httpclient.maxstreams", 16)); - frame.setParameter(INITIAL_WINDOW_SIZE, Utils.getIntegerNetProperty( - "jdk.httpclient.windowsize", 64 * K - 1)); - frame.setParameter(MAX_FRAME_SIZE, Utils.getIntegerNetProperty( - "jdk.httpclient.maxframesize", 16 * K)); + // default defined for HTTP/2 is 4 K, we use 16 K. + frame.setParameter(HEADER_TABLE_SIZE, getParameter( + "jdk.httpclient.hpack.maxheadertablesize", + 0, Integer.MAX_VALUE, 16 * K)); + // O: does not accept push streams. 1: accepts push streams. + frame.setParameter(ENABLE_PUSH, getParameter( + "jdk.httpclient.enablepush", + 0, 1, 1)); + // HTTP/2 recommends to set the number of concurrent streams + // no lower than 100. We use 100. 0 means no stream would be + // accepted. That would render the client to be non functional, + // so we won't let 0 be configured for our Http2ClientImpl. + frame.setParameter(MAX_CONCURRENT_STREAMS, getParameter( + "jdk.httpclient.maxstreams", + 1, Integer.MAX_VALUE, 100)); + // Maximum size is 2^31-1. Don't allow window size to be less + // than the minimum frame size as this is likely to be a + // configuration error. HTTP/2 specify a default of 64 * K -1, + // but we use 16 M for better performance. + frame.setParameter(INITIAL_WINDOW_SIZE, getParameter( + "jdk.httpclient.windowsize", + 16 * K, Integer.MAX_VALUE, 16*K*K)); + // HTTP/2 specify a minimum size of 16 K, a maximum size of 2^24-1, + // and a default of 16 K. We use 16 K as default. + frame.setParameter(MAX_FRAME_SIZE, getParameter( + "jdk.httpclient.maxframesize", + 16 * K, 16 * K * K -1, 16 * K)); return frame; } } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java Wed Dec 13 10:25:38 2017 -0800 @@ -228,7 +228,7 @@ private final WindowController windowController = new WindowController(); private final FramesController framesController = new FramesController(); private final Http2TubeSubscriber subscriber = new Http2TubeSubscriber(); - final WindowUpdateSender windowUpdater; + final ConnectionWindowUpdateSender windowUpdater; private volatile Throwable cause; private volatile Supplier initial; @@ -247,7 +247,8 @@ this.nextstreamid = nextstreamid; this.key = key; this.clientSettings = this.client2.getClientSettings(); - this.framesDecoder = new FramesDecoder(this::processFrame, clientSettings.getParameter(SettingsFrame.MAX_FRAME_SIZE)); + this.framesDecoder = new FramesDecoder(this::processFrame, + clientSettings.getParameter(SettingsFrame.MAX_FRAME_SIZE)); // serverSettings will be updated by server this.serverSettings = SettingsFrame.getDefaultSettings(); this.hpackOut = new Encoder(serverSettings.getParameter(HEADER_TABLE_SIZE)); @@ -255,7 +256,8 @@ debugHpack.log(Level.DEBUG, () -> "For the record:" + super.toString()); debugHpack.log(Level.DEBUG, "Decoder created: %s", hpackIn); debugHpack.log(Level.DEBUG, "Encoder created: %s", hpackOut); - this.windowUpdater = new ConnectionWindowUpdateSender(this, client().getReceiveBufferSize()); + this.windowUpdater = new ConnectionWindowUpdateSender(this, + client2.getConnectionWindowSize(clientSettings)); } /** @@ -774,7 +776,8 @@ Log.logTrace("{0}: start sending connection preface to {1}", connection.channel().getLocalAddress(), connection.address()); - SettingsFrame sf = client2.getClientSettings(); + SettingsFrame sf = new SettingsFrame(clientSettings); + int initialWindowSize = sf.getParameter(INITIAL_WINDOW_SIZE); ByteBuffer buf = framesEncoder.encodeConnectionPreface(PREFACE_BYTES, sf); Log.logFrames(sf, "OUT"); // send preface bytes and SettingsFrame together @@ -788,8 +791,10 @@ // send a Window update for the receive buffer we are using // minus the initial 64 K specified in protocol - final int len = client2.client().getReceiveBufferSize() - (64 * 1024 - 1); - windowUpdater.sendWindowUpdate(len); + final int len = windowUpdater.initialWindowSize - initialWindowSize; + if (len > 0) { + windowUpdater.sendWindowUpdate(len); + } // there will be an ACK to the windows update - which should // cause any pending data stored before the preface was sent to be // flushed (see PrefaceController). @@ -1202,9 +1207,11 @@ static final class ConnectionWindowUpdateSender extends WindowUpdateSender { + final int initialWindowSize; public ConnectionWindowUpdateSender(Http2Connection connection, int initialWindowSize) { super(connection, initialWindowSize); + this.initialWindowSize = initialWindowSize; } @Override diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -1038,7 +1038,7 @@ // used for the connection window int getReceiveBufferSize() { return Utils.getIntegerNetProperty( - "jdk.httpclient.connectionWindowSize", 256 * 1024 + "jdk.httpclient.receiveBufferSize", 2 * 1024 * 1024 ); } } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java Wed Dec 13 10:25:38 2017 -0800 @@ -143,7 +143,9 @@ this.chan = SocketChannel.open(); chan.configureBlocking(false); int bufsize = client.getReceiveBufferSize(); - chan.setOption(StandardSocketOptions.SO_RCVBUF, bufsize); + if (!trySetReceiveBufferSize(bufsize)) { + trySetReceiveBufferSize(256*1024); + } chan.setOption(StandardSocketOptions.TCP_NODELAY, true); // wrap the connected channel in a Tube for async reading and writing tube = new SocketTube(client(), chan, Utils::getBuffer); @@ -152,6 +154,18 @@ } } + private boolean trySetReceiveBufferSize(int bufsize) { + try { + chan.setOption(StandardSocketOptions.SO_RCVBUF, bufsize); + return true; + } catch(IOException x) { + debug.log(Level.DEBUG, + "Failed to set receive buffer size to %d on %s", + bufsize, chan); + } + return false; + } + @Override HttpPublisher publisher() { return writePublisher; } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowUpdateSender.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowUpdateSender.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowUpdateSender.java Wed Dec 13 10:25:38 2017 -0800 @@ -59,6 +59,8 @@ // or // - remaining window size reached max frame size. limit = Math.min(v0, v1); + debug.log(Level.DEBUG, "maxFrameSize=%d, initWindowSize=%d, limit=%d", + maxFrameSize, initWindowSize, limit); } abstract int getStreamId(); diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/SettingsFrame.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/SettingsFrame.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/SettingsFrame.java Wed Dec 13 10:25:38 2017 -0800 @@ -100,6 +100,11 @@ this(0); } + public SettingsFrame(SettingsFrame other) { + super(0, other.flags); + parameters = Arrays.copyOf(other.parameters, MAX_PARAM); + } + @Override public int type() { return TYPE; diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java Wed Dec 13 10:25:38 2017 -0800 @@ -117,8 +117,10 @@ SourceToHTMLConverter.convertRoot(configuration, docEnv, DocPaths.SOURCE_OUTPUT); } - - if (configuration.topFile.isEmpty()) { + // Modules with no documented classes may be specified on the + // command line to specify a service provider, allow these. + if (configuration.getSpecifiedModuleElements().isEmpty() && + configuration.topFile.isEmpty()) { messages.error("doclet.No_Non_Deprecated_Classes_To_Document"); return; } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java Wed Dec 13 10:25:38 2017 -0800 @@ -193,7 +193,11 @@ * @throws DocletException if there is a problem while generating the documentation */ private void startGeneration(DocletEnvironment docEnv) throws DocletException { - if (configuration.getIncludedTypeElements().isEmpty()) { + + // Modules with no documented classes may be specified on the + // command line to specify a service provider, allow these. + if (configuration.getSpecifiedModuleElements().isEmpty() && + configuration.getIncludedTypeElements().isEmpty()) { messages.error("doclet.No_Public_Classes_To_Document"); return; } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java Wed Dec 13 10:25:38 2017 -0800 @@ -489,6 +489,10 @@ continue; } + // Skip static methods in interfaces they are not inherited + if (utils.isInterface(inheritedClass) && utils.isStatic(inheritedMember)) + continue; + // If applicable, filter those overridden methods that // should not be documented in the summary/detail sections, // and instead document them in the footnote. Care must be taken @@ -496,9 +500,8 @@ // but comments for these are synthesized on the output. ExecutableElement inheritedMethod = (ExecutableElement)inheritedMember; if (enclosedSuperMethods.stream() - .anyMatch(e -> utils.executableMembersEqual(inheritedMethod, e) - && (!utils.isSimpleOverride(e) - || visibleMemberMap.getPropertyElement(e) != null))) { + .anyMatch(e -> utils.executableMembersEqual(inheritedMethod, e) && + (!utils.isSimpleOverride(e) || visibleMemberMap.getPropertyElement(e) != null))) { inheritedMembers.add(inheritedMember); } } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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,18 +25,14 @@ package com.sun.tools.jdeps; import java.io.PrintWriter; -import java.lang.module.ModuleDescriptor; -import java.lang.module.ModuleFinder; -import java.lang.module.ModuleReference; +import java.util.ArrayDeque; import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.Map; import java.util.Set; import java.util.function.Consumer; -import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -161,7 +157,7 @@ * Returns all nodes reachable from the given set of roots. */ public Set dfs(Set roots) { - Deque deque = new LinkedList<>(roots); + Deque deque = new ArrayDeque<>(roots); Set visited = new HashSet<>(); while (!deque.isEmpty()) { T u = deque.pop(); @@ -197,7 +193,7 @@ if (includeAdjacent && isAdjacent(u, v)) { return true; } - Deque stack = new LinkedList<>(); + Deque stack = new ArrayDeque<>(); Set visited = new HashSet<>(); stack.push(u); while (!stack.isEmpty()) { @@ -292,12 +288,10 @@ * Topological sort */ static class TopoSorter { - final Deque result = new LinkedList<>(); - final Deque nodes; + final Deque result = new ArrayDeque<>(); final Graph graph; TopoSorter(Graph graph) { this.graph = graph; - this.nodes = new LinkedList<>(graph.nodes); sort(); } @@ -310,17 +304,16 @@ } private void sort() { - Deque visited = new LinkedList<>(); - Deque done = new LinkedList<>(); - T node; - while ((node = nodes.poll()) != null) { + Set visited = new HashSet<>(); + Set done = new HashSet<>(); + for (T node : graph.nodes()) { if (!visited.contains(node)) { visit(node, visited, done); } } } - private void visit(T node, Deque visited, Deque done) { + private void visit(T node, Set visited, Set done) { if (visited.contains(node)) { if (!done.contains(node)) { throw new IllegalArgumentException("Cyclic detected: " + @@ -330,7 +323,7 @@ } visited.add(node); graph.edges().get(node).stream() - .forEach(x -> visit(x, visited, done)); + .forEach(x -> visit(x, visited, done)); done.add(node); result.addLast(node); } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java Wed Dec 13 10:25:38 2017 -0800 @@ -38,8 +38,6 @@ import java.io.UncheckedIOException; import java.lang.module.Configuration; import java.lang.module.ModuleDescriptor; -import java.lang.module.ModuleDescriptor.Exports; -import java.lang.module.ModuleDescriptor.Opens; import java.lang.module.ModuleFinder; import java.lang.module.ModuleReader; import java.lang.module.ModuleReference; @@ -71,6 +69,7 @@ public static final String ALL_MODULE_PATH = "ALL-MODULE-PATH"; public static final String ALL_DEFAULT = "ALL-DEFAULT"; public static final String ALL_SYSTEM = "ALL-SYSTEM"; + public static final String MODULE_INFO = "module-info.class"; private final SystemModuleFinder system; @@ -91,8 +90,7 @@ Set roots, List classpaths, List initialArchives, - boolean allDefaultModules, - boolean allSystemModules, + Set tokens, Runtime.Version version) throws IOException { @@ -104,16 +102,13 @@ // build root set for resolution Set mods = new HashSet<>(roots); - - // add all system modules to the root set for unnamed module or set explicitly - boolean unnamed = !initialArchives.isEmpty() || !classpaths.isEmpty(); - if (allSystemModules || (unnamed && !allDefaultModules)) { + if (tokens.contains(ALL_SYSTEM)) { systemModulePath.findAll().stream() .map(mref -> mref.descriptor().name()) .forEach(mods::add); } - if (allDefaultModules) { + if (tokens.contains(ALL_DEFAULT)) { mods.addAll(systemModulePath.defaultSystemRoots()); } @@ -200,10 +195,10 @@ return m!= null ? Optional.of(m.descriptor()) : Optional.empty(); } - boolean isValidToken(String name) { + public static boolean isToken(String name) { return ALL_MODULE_PATH.equals(name) || - ALL_DEFAULT.equals(name) || - ALL_SYSTEM.equals(name); + ALL_DEFAULT.equals(name) || + ALL_SYSTEM.equals(name); } /** @@ -482,13 +477,10 @@ final List initialArchives = new ArrayList<>(); final List paths = new ArrayList<>(); final List classPaths = new ArrayList<>(); + final Set tokens = new HashSet<>(); ModuleFinder upgradeModulePath; ModuleFinder appModulePath; - boolean addAllApplicationModules; - boolean addAllDefaultModules; - boolean addAllSystemModules; - boolean allModules; Runtime.Version version; public Builder() { @@ -513,34 +505,15 @@ public Builder addmods(Set addmods) { for (String mn : addmods) { - switch (mn) { - case ALL_MODULE_PATH: - this.addAllApplicationModules = true; - break; - case ALL_DEFAULT: - this.addAllDefaultModules = true; - break; - case ALL_SYSTEM: - this.addAllSystemModules = true; - break; - default: - this.rootModules.add(mn); + if (isToken(mn)) { + tokens.add(mn); + } else { + rootModules.add(mn); } } return this; } - /* - * This method is for --check option to find all target modules specified - * in qualified exports. - * - * Include all system modules and modules found on modulepath - */ - public Builder allModules() { - this.allModules = true; - return this; - } - public Builder multiRelease(Runtime.Version version) { this.version = version; return this; @@ -579,7 +552,9 @@ .forEach(rootModules::add); } - if ((addAllApplicationModules || allModules) && appModulePath != null) { + // add all modules to the root set for unnamed module or set explicitly + boolean unnamed = !initialArchives.isEmpty() || !classPaths.isEmpty(); + if ((unnamed || tokens.contains(ALL_MODULE_PATH)) && appModulePath != null) { appModulePath.findAll().stream() .map(mref -> mref.descriptor().name()) .forEach(rootModules::add); @@ -587,7 +562,7 @@ // no archive is specified for analysis // add all system modules as root if --add-modules ALL-SYSTEM is specified - if (addAllSystemModules && rootModules.isEmpty() && + if (tokens.contains(ALL_SYSTEM) && rootModules.isEmpty() && initialArchives.isEmpty() && classPaths.isEmpty()) { systemModulePath.findAll() .stream() @@ -595,13 +570,16 @@ .forEach(rootModules::add); } + if (unnamed && !tokens.contains(ALL_DEFAULT)) { + tokens.add(ALL_SYSTEM); + } + return new JdepsConfiguration(systemModulePath, finder, rootModules, classPaths, initialArchives, - addAllDefaultModules, - allModules, + tokens, version); } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -540,7 +540,7 @@ } boolean run() throws IOException { - try (JdepsConfiguration config = buildConfig(command.allModules())) { + try (JdepsConfiguration config = buildConfig()) { if (!options.nowarning) { // detect split packages config.splitPackages().entrySet() @@ -553,7 +553,7 @@ // check if any module specified in --add-modules, --require, and -m is missing options.addmods.stream() - .filter(mn -> !config.isValidToken(mn)) + .filter(mn -> !JdepsConfiguration.isToken(mn)) .forEach(mn -> config.findModule(mn).orElseThrow(() -> new UncheckedBadArgs(new BadArgs("err.module.not.found", mn)))); @@ -561,18 +561,14 @@ } } - private JdepsConfiguration buildConfig(boolean allModules) throws IOException { + private JdepsConfiguration buildConfig() throws IOException { JdepsConfiguration.Builder builder = new JdepsConfiguration.Builder(options.systemModulePath); builder.upgradeModulePath(options.upgradeModulePath) .appModulePath(options.modulePath) - .addmods(options.addmods); - - if (allModules) { - // check all system modules in the image - builder.allModules(); - } + .addmods(options.addmods) + .addmods(command.addModules()); if (options.classpath != null) builder.addClassPath(options.classpath); @@ -655,8 +651,8 @@ * only. The method should be overridden when this command should * analyze all modules instead. */ - boolean allModules() { - return false; + Set addModules() { + return Set.of(); } @Override @@ -871,8 +867,8 @@ * analyzed to find all modules that depend on the modules specified in the * --require option directly and indirectly */ - public boolean allModules() { - return options.requires.size() > 0; + Set addModules() { + return options.requires.size() > 0 ? Set.of("ALL-SYSTEM") : Set.of(); } } @@ -975,8 +971,8 @@ /* * Returns true to analyze all modules */ - public boolean allModules() { - return true; + Set addModules() { + return Set.of("ALL-SYSTEM", "ALL-MODULE-PATH"); } } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java Wed Dec 13 10:25:38 2017 -0800 @@ -32,7 +32,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Optional; import java.util.Set; /** @@ -138,7 +137,7 @@ // for debugging public static void main(String[] args) throws IOException { // initialize Profiles - new JdepsConfiguration.Builder().allModules().build(); + new JdepsConfiguration.Builder().addmods(Set.of("ALL-SYSTEM")).build(); // find platform modules if (Profile.getProfileCount() == 0) { diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c --- a/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -111,7 +111,7 @@ jint tmpInt; total_length = str->type.cmd.len; - data_length = total_length - 11; + data_length = total_length - JDWP_HEADER_SIZE; /* total packet length is header + data */ array = (*env)->NewByteArray(env, total_length); @@ -142,7 +142,7 @@ /* finally the data */ if (data_length > 0) { - (*env)->SetByteArrayRegion(env, array, 11, + (*env)->SetByteArrayRegion(env, array, JDWP_HEADER_SIZE, data_length, str->type.cmd.data); if ((*env)->ExceptionOccurred(env)) { return NULL; @@ -168,7 +168,7 @@ { jsize total_length, data_length; jbyte *data; - unsigned char pktHeader[11]; /* sizeof length + id + flags + cmdSet + cmd */ + unsigned char pktHeader[JDWP_HEADER_SIZE]; /* * Get the packet header diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdi/share/native/libdt_shmem/shmemBack.c --- a/src/jdk.jdi/share/native/libdt_shmem/shmemBack.c Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdi/share/native/libdt_shmem/shmemBack.c Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -270,7 +270,7 @@ if (packet == NULL) { RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, "packet is null"); } - if (packet->type.cmd.len < 11) { + if (packet->type.cmd.len < JDWP_HEADER_SIZE) { RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, "invalid length"); } if (connection == NULL) { diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdi/share/native/libdt_shmem/shmemBase.c --- a/src/jdk.jdi/share/native/libdt_shmem/shmemBase.c Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdi/share/native/libdt_shmem/shmemBase.c Wed Dec 13 10:25:38 2017 -0800 @@ -1049,7 +1049,7 @@ CHECK_ERROR(sendBytes(connection, &packet->type.cmd.cmd, sizeof(jbyte))); } - data_length = packet->type.cmd.len - 11; + data_length = packet->type.cmd.len - JDWP_HEADER_SIZE; SHMEM_GUARANTEE(data_length >= 0); CHECK_ERROR(sendBytes(connection, &data_length, sizeof(jint))); @@ -1125,10 +1125,10 @@ if (data_length < 0) { return SYS_ERR; } else if (data_length == 0) { - packet->type.cmd.len = 11; + packet->type.cmd.len = JDWP_HEADER_SIZE; packet->type.cmd.data = NULL; } else { - packet->type.cmd.len = data_length + 11; + packet->type.cmd.len = data_length + JDWP_HEADER_SIZE; packet->type.cmd.data = (*callback->alloc)(data_length); if (packet->type.cmd.data == NULL) { return SYS_ERR; diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdwp.agent/share/native/include/jdwpTransport.h --- a/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h Wed Dec 13 10:25:38 2017 -0800 @@ -96,6 +96,8 @@ * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html */ +#define JDWP_HEADER_SIZE 11 + enum { /* * If additional flags are added that apply to jdwpCmdPacket, diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c --- a/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c Wed Dec 13 10:25:38 2017 -0800 @@ -70,7 +70,6 @@ RETURN_IO_ERROR("recv error"); \ } -#define HEADER_SIZE 11 #define MAX_DATA_SIZE 1000 static jint recv_fully(int, char *, int); @@ -790,7 +789,7 @@ /* * room for header and up to MAX_DATA_SIZE data bytes */ - char header[HEADER_SIZE + MAX_DATA_SIZE]; + char header[JDWP_HEADER_SIZE + MAX_DATA_SIZE]; jbyte *data; /* packet can't be null */ @@ -799,7 +798,7 @@ } len = packet->type.cmd.len; /* includes header */ - data_len = len - HEADER_SIZE; + data_len = len - JDWP_HEADER_SIZE; /* bad packet */ if (data_len < 0) { @@ -825,15 +824,15 @@ data = packet->type.cmd.data; /* Do one send for short packets, two for longer ones */ if (data_len <= MAX_DATA_SIZE) { - memcpy(header + HEADER_SIZE, data, data_len); - if (send_fully(socketFD, (char *)&header, HEADER_SIZE + data_len) != - HEADER_SIZE + data_len) { + memcpy(header + JDWP_HEADER_SIZE, data, data_len); + if (send_fully(socketFD, (char *)&header, JDWP_HEADER_SIZE + data_len) != + JDWP_HEADER_SIZE + data_len) { RETURN_IO_ERROR("send failed"); } } else { - memcpy(header + HEADER_SIZE, data, MAX_DATA_SIZE); - if (send_fully(socketFD, (char *)&header, HEADER_SIZE + MAX_DATA_SIZE) != - HEADER_SIZE + MAX_DATA_SIZE) { + memcpy(header + JDWP_HEADER_SIZE, data, MAX_DATA_SIZE); + if (send_fully(socketFD, (char *)&header, JDWP_HEADER_SIZE + MAX_DATA_SIZE) != + JDWP_HEADER_SIZE + MAX_DATA_SIZE) { RETURN_IO_ERROR("send failed"); } /* Send the remaining data bytes right out of the data area. */ diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdwp.agent/share/native/libjdwp/inStream.c --- a/src/jdk.jdwp.agent/share/native/libjdwp/inStream.c Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/inStream.c Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -43,7 +43,7 @@ { stream->packet = packet; stream->error = JDWP_ERROR(NONE); - stream->left = packet.type.cmd.len; + stream->left = packet.type.cmd.len - JDWP_HEADER_SIZE; stream->current = packet.type.cmd.data; stream->refs = bagCreateBag(sizeof(jobject), INITIAL_REF_ALLOC); if (stream->refs == NULL) { @@ -411,12 +411,6 @@ return string; } -jboolean -inStream_endOfInput(PacketInputStream *stream) -{ - return (stream->left > 0); -} - jdwpError inStream_error(PacketInputStream *stream) { @@ -424,7 +418,8 @@ } void -inStream_clearError(PacketInputStream *stream) { +inStream_clearError(PacketInputStream *stream) +{ stream->error = JDWP_ERROR(NONE); } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdwp.agent/share/native/libjdwp/inStream.h --- a/src/jdk.jdwp.agent/share/native/libjdwp/inStream.h Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/inStream.h Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -74,7 +74,6 @@ jdwpError inStream_skipBytes(PacketInputStream *stream, jint count); -jboolean inStream_endOfInput(PacketInputStream *stream); jdwpError inStream_error(PacketInputStream *stream); void inStream_clearError(PacketInputStream *stream); void inStream_destroy(PacketInputStream *stream); diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jdwp.agent/share/native/libjdwp/outStream.c --- a/src/jdk.jdwp.agent/share/native/libjdwp/outStream.c Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/outStream.c Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -418,7 +418,7 @@ * packet. */ if (stream->firstSegment.next == NULL) { - stream->packet.type.cmd.len = 11 + stream->firstSegment.length; + stream->packet.type.cmd.len = JDWP_HEADER_SIZE + stream->firstSegment.length; stream->packet.type.cmd.data = stream->firstSegment.data; rc = transport_sendPacket(&stream->packet); return rc; @@ -447,7 +447,7 @@ segment = segment->next; } - stream->packet.type.cmd.len = 11 + len; + stream->packet.type.cmd.len = JDWP_HEADER_SIZE + len; stream->packet.type.cmd.data = data; rc = transport_sendPacket(&stream->packet); stream->packet.type.cmd.data = NULL; diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Wed Dec 13 10:25:38 2017 -0800 @@ -43,6 +43,7 @@ import java.nio.charset.Charset; import java.nio.file.FileSystems; import java.nio.file.Files; +import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; import java.text.MessageFormat; @@ -387,7 +388,7 @@ private Collection validPaths(Collection vals, String context, boolean isModulePath) { Stream result = vals.stream() .map(s -> Arrays.stream(s.split(File.pathSeparator)) - .map(sp -> toPathResolvingUserHome(sp)) + .flatMap(sp -> toPathImpl(sp, context)) .filter(p -> checkValidPathEntry(p, context, isModulePath)) .map(p -> p.toString()) .collect(Collectors.joining(File.pathSeparator))); @@ -427,6 +428,16 @@ return false; } + private Stream toPathImpl(String path, String context) { + try { + return Stream.of(toPathResolvingUserHome(path)); + } catch (InvalidPathException ex) { + msg("jshell.err.file.not.found", context, path); + failed = true; + return Stream.empty(); + } + } + Options parse(OptionSet options) { addOptions(OptionKind.CLASS_PATH, validPaths(options.valuesOf(argClassPath), "--class-path", false)); diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.localedata/share/classes/sun/util/cldr/resources/common/bcp47/timezone.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.localedata/share/classes/sun/util/cldr/resources/common/bcp47/timezone.xml Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,470 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.localedata/share/classes/sun/util/cldr/resources/common/dtd/ldmlBCP47.dtd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.localedata/share/classes/sun/util/cldr/resources/common/dtd/ldmlBCP47.dtd Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java Wed Dec 13 10:25:38 2017 -0800 @@ -346,28 +346,30 @@ assert identNode.getSymbol().isScope() : identNode + " is not in scope!"; final int flags = getScopeCallSiteFlags(symbol); - if (isFastScope(symbol)) { - // Only generate shared scope getter for fast-scope symbols so we know we can dial in correct scope. - if (symbol.getUseCount() > SharedScopeCall.FAST_SCOPE_GET_THRESHOLD && !identNode.isOptimistic()) { - // As shared scope vars are only used with non-optimistic identifiers, we switch from using TypeBounds to - // just a single definitive type, resultBounds.widest. - new OptimisticOperation(identNode, TypeBounds.OBJECT) { - @Override - void loadStack() { - method.loadCompilerConstant(SCOPE); - } - - @Override - void consumeStack() { - loadSharedScopeVar(resultBounds.widest, symbol, flags); - } - }.emit(); - } else { - new LoadFastScopeVar(identNode, resultBounds, flags).emit(); - } + if (!isFastScope(symbol)) { + // slow scope load, prototype chain must be inspected at runtime + new LoadScopeVar(identNode, resultBounds, flags).emit(); + } else if (identNode.isCompileTimePropertyName() || symbol.getUseCount() < SharedScopeCall.SHARED_GET_THRESHOLD) { + // fast scope load with known prototype depth + new LoadFastScopeVar(identNode, resultBounds, flags).emit(); } else { - //slow scope load, we have no proto depth - new LoadScopeVar(identNode, resultBounds, flags).emit(); + // Only generate shared scope getter for often used fast-scope symbols. + new OptimisticOperation(identNode, resultBounds) { + @Override + void loadStack() { + method.loadCompilerConstant(SCOPE); + final int depth = getScopeProtoDepth(lc.getCurrentBlock(), symbol); + assert depth >= 0; + method.load(depth); + method.load(getProgramPoint()); + } + + @Override + void consumeStack() { + final Type resultType = isOptimistic ? getOptimisticCoercedType() : resultBounds.widest; + lc.getScopeGet(unit, symbol, resultType, flags, isOptimistic).generateInvoke(method); + } + }.emit(); } return method; @@ -467,12 +469,6 @@ throw new AssertionError(); } - private MethodEmitter loadSharedScopeVar(final Type valueType, final Symbol symbol, final int flags) { - assert isFastScope(symbol); - method.load(getScopeProtoDepth(lc.getCurrentBlock(), symbol)); - return lc.getScopeGet(unit, symbol, valueType, flags).generateInvoke(method); - } - private class LoadScopeVar extends OptimisticOperation { final IdentNode identNode; private final int flags; @@ -551,18 +547,23 @@ if (swap) { method.swap(); } - if (depth > 1) { - method.load(depth); - method.invoke(ScriptObject.GET_PROTO_DEPTH); - } else { - method.invoke(ScriptObject.GET_PROTO); - } + invokeGetProto(depth); if (swap) { method.swap(); } } } + private void invokeGetProto(final int depth) { + assert depth > 0; + if (depth > 1) { + method.load(depth); + method.invoke(ScriptObject.GET_PROTO_DEPTH); + } else { + method.invoke(ScriptObject.GET_PROTO); + } + } + /** * Generate code that loads this node to the stack, not constraining its type * @@ -1386,12 +1387,7 @@ return; } method.loadCompilerConstant(SCOPE); - if (count > 1) { - method.load(count); - method.invoke(ScriptObject.GET_PROTO_DEPTH); - } else { - method.invoke(ScriptObject.GET_PROTO); - } + invokeGetProto(count); method.storeCompilerConstant(SCOPE); } @@ -1444,20 +1440,22 @@ final CodeGeneratorLexicalContext codegenLexicalContext = lc; function.accept(new SimpleNodeVisitor() { + private MethodEmitter sharedScopeCall(final IdentNode identNode, final int flags) { final Symbol symbol = identNode.getSymbol(); - final boolean isFastScope = isFastScope(symbol); + assert isFastScope(symbol); + new OptimisticOperation(callNode, resultBounds) { @Override void loadStack() { method.loadCompilerConstant(SCOPE); - if (isFastScope) { - method.load(getScopeProtoDepth(currentBlock, symbol)); - } else { - method.load(-1); // Bypass fast-scope code in shared callsite - } + final int depth = getScopeProtoDepth(currentBlock, symbol); + assert depth >= 0; + method.load(depth); + method.load(getProgramPoint()); loadArgs(args); } + @Override void consumeStack() { final Type[] paramTypes = method.getTypesFromStack(args.size()); @@ -1466,13 +1464,14 @@ for(int i = 0; i < paramTypes.length; ++i) { paramTypes[i] = Type.generic(paramTypes[i]); } - // As shared scope calls are only used in non-optimistic compilation, we switch from using - // TypeBounds to just a single definitive type, resultBounds.widest. + + final Type resultType = isOptimistic ? getOptimisticCoercedType() : resultBounds.widest; final SharedScopeCall scopeCall = codegenLexicalContext.getScopeCall(unit, symbol, - identNode.getType(), resultBounds.widest, paramTypes, flags); + identNode.getType(), resultType, paramTypes, flags, isOptimistic); scopeCall.generateInvoke(method); } }.emit(); + return method; } @@ -1573,15 +1572,10 @@ final int flags = getScopeCallSiteFlags(symbol); final int useCount = symbol.getUseCount(); - // Threshold for generating shared scope callsite is lower for fast scope symbols because we know - // we can dial in the correct scope. However, we also need to enable it for non-fast scopes to - // support huge scripts like mandreel.js. + // We only use shared scope calls for fast scopes if (callNode.isEval()) { evalCall(node, flags); - } else if (useCount <= SharedScopeCall.FAST_SCOPE_CALL_THRESHOLD - || !isFastScope(symbol) && useCount <= SharedScopeCall.SLOW_SCOPE_CALL_THRESHOLD - || CodeGenerator.this.lc.inDynamicScope() - || callNode.isOptimistic()) { + } else if (!isFastScope(symbol) || symbol.getUseCount() < SharedScopeCall.SHARED_CALL_THRESHOLD) { scopeCall(node, flags); } else { sharedScopeCall(node, flags); @@ -4650,7 +4644,7 @@ } private abstract class OptimisticOperation { - private final boolean isOptimistic; + final boolean isOptimistic; // expression and optimistic are the same reference private final Expression expression; private final Optimistic optimistic; @@ -4966,7 +4960,7 @@ * affect it. * @return */ - private Type getOptimisticCoercedType() { + Type getOptimisticCoercedType() { final Type optimisticType = expression.getType(); assert resultBounds.widest.widerThan(optimisticType); final Type narrowest = resultBounds.narrowest; diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java Wed Dec 13 10:25:38 2017 -0800 @@ -184,10 +184,14 @@ * @param returnType the return type * @param paramTypes the parameter types * @param flags the callsite flags + * @param isOptimistic is this an optimistic call * @return an object representing a shared scope call */ - SharedScopeCall getScopeCall(final CompileUnit unit, final Symbol symbol, final Type valueType, final Type returnType, final Type[] paramTypes, final int flags) { - final SharedScopeCall scopeCall = new SharedScopeCall(symbol, valueType, returnType, paramTypes, flags); + SharedScopeCall getScopeCall(final CompileUnit unit, final Symbol symbol, final Type valueType, + final Type returnType, final Type[] paramTypes, final int flags, + final boolean isOptimistic) { + final SharedScopeCall scopeCall = new SharedScopeCall(symbol, valueType, returnType, paramTypes, flags, + isOptimistic); if (scopeCalls.containsKey(scopeCall)) { return scopeCalls.get(scopeCall); } @@ -203,10 +207,12 @@ * @param symbol the symbol * @param valueType the type of the variable * @param flags the callsite flags - * @return an object representing a shared scope call + * @param isOptimistic is this an optimistic get + * @return an object representing a shared scope get */ - SharedScopeCall getScopeGet(final CompileUnit unit, final Symbol symbol, final Type valueType, final int flags) { - return getScopeCall(unit, symbol, valueType, valueType, null, flags); + SharedScopeCall getScopeGet(final CompileUnit unit, final Symbol symbol, final Type valueType, final int flags, + final boolean isOptimistic) { + return getScopeCall(unit, symbol, valueType, valueType, null, flags, isOptimistic); } void onEnterBlock(final Block block) { diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java Wed Dec 13 10:25:38 2017 -0800 @@ -702,19 +702,21 @@ } pushType(Type.typeFor(Throwable.class)); } + /** * Start a try/catch block. * - * @param entry start label for try - * @param exit end label for try - * @param recovery start label for catch - * @param typeDescriptor type descriptor for exception + * @param entry start label for try + * @param exit end label for try + * @param recovery start label for catch + * @param clazz exception class or null for any Throwable * @param isOptimismHandler true if this is a hander for {@code UnwarrantedOptimismException}. Normally joining on a * catch handler kills temporary variables, but optimism handlers are an exception, as they need to capture * temporaries as well, so they must remain live. */ - private void _try(final Label entry, final Label exit, final Label recovery, final String typeDescriptor, final boolean isOptimismHandler) { + void _try(final Label entry, final Label exit, final Label recovery, final Class clazz, final boolean isOptimismHandler) { recovery.joinFromTry(entry.getStack(), isOptimismHandler); + final String typeDescriptor = clazz == null ? null : CompilerConstants.className(clazz); method.visitTryCatchBlock(entry.getLabel(), exit.getLabel(), recovery.getLabel(), typeDescriptor); } @@ -727,7 +729,7 @@ * @param clazz exception class */ void _try(final Label entry, final Label exit, final Label recovery, final Class clazz) { - _try(entry, exit, recovery, CompilerConstants.className(clazz), clazz == UnwarrantedOptimismException.class); + _try(entry, exit, recovery, clazz, clazz == UnwarrantedOptimismException.class); } /** diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SharedScopeCall.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SharedScopeCall.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SharedScopeCall.java Wed Dec 13 10:25:38 2017 -0800 @@ -25,6 +25,7 @@ package jdk.nashorn.internal.codegen; +import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup; import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_OPTIMISTIC; import java.util.Arrays; @@ -32,39 +33,52 @@ import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.Symbol; import jdk.nashorn.internal.runtime.ScriptObject; +import jdk.nashorn.internal.runtime.UnwarrantedOptimismException; +import jdk.nashorn.internal.runtime.options.Options; /** - * A scope call or get operation that can be shared by several callsites. This generates a static + * A scope call or get operation that can be shared by several call sites. This generates a static * method that wraps the invokedynamic instructions to get or call scope variables. - * The rationale for this is that initial linking of invokedynamic callsites is expensive, - * so by sharing them we can reduce startup overhead and allow very large scripts to run that otherwise wouldn't. + * The reason for this is to reduce memory footprint and initial linking overhead of huge scripts. * - *

    Static methods generated by this class expect two parameters in addition to the parameters of the - * function call: The current scope object and the depth of the target scope relative to the scope argument - * for when this is known at compile-time (fast-scope access).

    + *

    Static methods generated by this class expect three parameters in addition to the parameters of the + * function call: The current scope object, the depth of the target scope relative to the scope argument, + * and the program point in case the target operation is optimistic.

    * - *

    The second argument may be -1 for non-fast-scope symbols, in which case the scope chain is checked - * for each call. This may cause callsite invalidation when the shared method is used from different - * scopes, but such sharing of non-fast scope calls may still be necessary for very large scripts.

    + *

    Optimistic operations are called with program point 0. If an UnwarrentedOptimismException + * is thrown, it is caught by the shared call method and rethrown with the program point of the invoking call site.

    * - *

    Scope calls must not be shared between normal callsites and callsites contained in a with - * statement as this condition is not handled by current guards and will cause a runtime error.

    + *

    Shared scope calls are not used if the scope contains a with statement or a call to + * eval.

    */ class SharedScopeCall { - /** Threshold for using shared scope calls with fast scope access. */ - public static final int FAST_SCOPE_CALL_THRESHOLD = 4; - /** Threshold for using shared scope calls with slow scope access. */ - public static final int SLOW_SCOPE_CALL_THRESHOLD = 500; - /** Threshold for using shared scope gets with fast scope access. */ - public static final int FAST_SCOPE_GET_THRESHOLD = 200; + /** + * Threshold for using shared scope function calls. + */ + public static final int SHARED_CALL_THRESHOLD = + Options.getIntProperty("nashorn.shared.scope.call.threshold", 5); + /** + * Threshold for using shared scope variable getter. This is higher than for calls as lower values + * degrade performance on many scripts. + */ + public static final int SHARED_GET_THRESHOLD = + Options.getIntProperty("nashorn.shared.scope.get.threshold", 100); - final Type valueType; - final Symbol symbol; - final Type returnType; - final Type[] paramTypes; - final int flags; - final boolean isCall; + private static final CompilerConstants.Call REPLACE_PROGRAM_POINT = virtualCallNoLookup( + UnwarrantedOptimismException.class, "replaceProgramPoint", + UnwarrantedOptimismException.class, int.class); + + /** Number of fixed parameters */ + private static final int FIXED_PARAM_COUNT = 3; + + private final Type valueType; + private final Symbol symbol; + private final Type returnType; + private final Type[] paramTypes; + private final int flags; + private final boolean isCall; + private final boolean isOptimistic; private CompileUnit compileUnit; private String methodName; private String staticSignature; @@ -77,21 +91,22 @@ * @param returnType the return type * @param paramTypes the function parameter types * @param flags the callsite flags + * @param isOptimistic whether target call is optimistic and we need to handle UnwarrentedOptimismException */ - SharedScopeCall(final Symbol symbol, final Type valueType, final Type returnType, final Type[] paramTypes, final int flags) { + SharedScopeCall(final Symbol symbol, final Type valueType, final Type returnType, final Type[] paramTypes, + final int flags, final boolean isOptimistic) { this.symbol = symbol; this.valueType = valueType; this.returnType = returnType; this.paramTypes = paramTypes; - assert (flags & CALLSITE_OPTIMISTIC) == 0; this.flags = flags; - // If paramTypes is not null this is a call, otherwise it's just a get. - this.isCall = paramTypes != null; + this.isCall = paramTypes != null; // If paramTypes is not null this is a call, otherwise it's just a get. + this.isOptimistic = isOptimistic; } @Override public int hashCode() { - return symbol.hashCode() ^ returnType.hashCode() ^ Arrays.hashCode(paramTypes) ^ flags; + return symbol.hashCode() ^ returnType.hashCode() ^ Arrays.hashCode(paramTypes) ^ flags ^ Boolean.hashCode(isOptimistic); } @Override @@ -101,7 +116,8 @@ return symbol.equals(c.symbol) && flags == c.flags && returnType.equals(c.returnType) - && Arrays.equals(paramTypes, c.paramTypes); + && Arrays.equals(paramTypes, c.paramTypes) + && isOptimistic == c.isOptimistic; } return false; } @@ -119,10 +135,9 @@ /** * Generate the invoke instruction for this shared scope call. * @param method the method emitter - * @return the method emitter */ - public MethodEmitter generateInvoke(final MethodEmitter method) { - return method.invokestatic(compileUnit.getUnitClassName(), methodName, getStaticSignature()); + public void generateInvoke(final MethodEmitter method) { + method.invokestatic(compileUnit.getUnitClassName(), methodName, getStaticSignature()); } /** @@ -140,51 +155,79 @@ final MethodEmitter method = classEmitter.method(methodFlags, methodName, getStaticSignature()); method.begin(); - // Load correct scope by calling getProto() on the scope argument as often as specified - // by the second argument. - final Label parentLoopStart = new Label("parent_loop_start"); - final Label parentLoopDone = new Label("parent_loop_done"); + // Load correct scope by calling getProto(int) on the scope argument with the supplied depth argument method.load(Type.OBJECT, 0); - method.label(parentLoopStart); method.load(Type.INT, 1); - method.iinc(1, -1); - method.ifle(parentLoopDone); - method.invoke(ScriptObject.GET_PROTO); - method._goto(parentLoopStart); - method.label(parentLoopDone); + method.invoke(ScriptObject.GET_PROTO_DEPTH); + + assert !isCall || valueType.isObject(); // Callables are always loaded as object + + // Labels for catch of UnsupportedOptimismException + final Label beginTry; + final Label endTry; + final Label catchLabel; - assert !isCall || valueType.isObject(); // Callables are always objects - // If flags are optimistic, but we're doing a call, remove optimistic flags from the getter, as they obviously - // only apply to the call. - method.dynamicGet(valueType, symbol.getName(), isCall ? CodeGenerator.nonOptimisticFlags(flags) : flags, isCall, false); + if(isOptimistic) { + beginTry = new Label("begin_try"); + endTry = new Label("end_try"); + catchLabel = new Label("catch_label"); + method.label(beginTry); + method._try(beginTry, endTry, catchLabel, UnwarrantedOptimismException.class, false); + } else { + beginTry = endTry = catchLabel = null; + } + + // If this is an optimistic get we set the optimistic flag but don't set the program point, + // which implies a program point of 0. If optimism fails we'll replace it with the actual + // program point which caller supplied as third argument. + final int getFlags = isOptimistic && !isCall ? flags | CALLSITE_OPTIMISTIC : flags; + method.dynamicGet(valueType, symbol.getName(), getFlags, isCall, false); // If this is a get we're done, otherwise call the value as function. if (isCall) { method.convert(Type.OBJECT); // ScriptFunction will see CALLSITE_SCOPE and will bind scope accordingly. method.loadUndefined(Type.OBJECT); - int slot = 2; + int slot = FIXED_PARAM_COUNT; for (final Type type : paramTypes) { method.load(type, slot); slot += type.getSlots(); } - // Shared scope calls disabled in optimistic world. TODO is this right? - method.dynamicCall(returnType, 2 + paramTypes.length, flags, symbol.getName()); + + // Same as above, set optimistic flag but leave program point as 0. + final int callFlags = isOptimistic ? flags | CALLSITE_OPTIMISTIC : flags; + + method.dynamicCall(returnType, 2 + paramTypes.length, callFlags, symbol.getName()); + + } + + if (isOptimistic) { + method.label(endTry); } method._return(returnType); + + if (isOptimistic) { + // We caught a UnwarrantedOptimismException, replace 0 program point with actual program point + method._catch(catchLabel); + method.load(Type.INT, 2); + method.invoke(REPLACE_PROGRAM_POINT); + method.athrow(); + } + method.end(); } private String getStaticSignature() { if (staticSignature == null) { if (paramTypes == null) { - staticSignature = Type.getMethodDescriptor(returnType, Type.typeFor(ScriptObject.class), Type.INT); + staticSignature = Type.getMethodDescriptor(returnType, Type.typeFor(ScriptObject.class), Type.INT, Type.INT); } else { - final Type[] params = new Type[paramTypes.length + 2]; + final Type[] params = new Type[paramTypes.length + FIXED_PARAM_COUNT]; params[0] = Type.typeFor(ScriptObject.class); params[1] = Type.INT; - System.arraycopy(paramTypes, 0, params, 2, paramTypes.length); + params[2] = Type.INT; + System.arraycopy(paramTypes, 0, params, FIXED_PARAM_COUNT, paramTypes.length); staticSignature = Type.getMethodDescriptor(returnType, params); } } diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Wed Dec 13 10:25:38 2017 -0800 @@ -1229,9 +1229,8 @@ * @return proto at given depth */ public final ScriptObject getProto(final int n) { - assert n > 0; - ScriptObject p = getProto(); - for (int i = n; --i > 0;) { + ScriptObject p = this; + for (int i = n; i > 0; i--) { p = p.getProto(); } return p; diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java Wed Dec 13 10:25:38 2017 -0800 @@ -153,12 +153,15 @@ } /** - * Check if we ended up with a primitive return value (even though it may be - * too wide for what we tried to do, e.g. double instead of int) - * @return true if return value is primitive + * Return a new {@code UnwarrantedOptimismException} with the same return value and the + * new program point. + * + * @param newProgramPoint new new program point + * @return the new exception instance */ - public boolean hasPrimitiveReturnValue() { - return returnValue instanceof Number || returnValue instanceof Boolean; + public UnwarrantedOptimismException replaceProgramPoint(final int newProgramPoint) { + assert isValid(newProgramPoint); + return new UnwarrantedOptimismException(returnValue, newProgramPoint, returnType); } @Override diff -r 093027a037cf -r 191ae61bd1e9 test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java Wed Dec 13 10:25:38 2017 -0800 @@ -38,14 +38,17 @@ public class ClhsdbJstack { - public static void main(String[] args) throws Exception { - System.out.println("Starting ClhsdbJstack test"); - + private static void testJstack(boolean withXcomp) throws Exception { LingeredApp theApp = null; try { ClhsdbLauncher test = new ClhsdbLauncher(); - theApp = LingeredApp.startApp(); - System.out.println("Started LingeredApp with pid " + theApp.getPid()); + theApp = withXcomp ? LingeredApp.startApp(List.of("-Xcomp")) + : LingeredApp.startApp(); + System.out.print("Started LingeredApp "); + if (withXcomp) { + System.out.print("(-Xcomp) "); + } + System.out.println("with pid " + theApp.getPid()); List cmds = List.of("jstack -v"); @@ -61,10 +64,16 @@ test.run(theApp.getPid(), cmds, expStrMap, null); } catch (Exception ex) { - throw new RuntimeException("Test ERROR " + ex, ex); + throw new RuntimeException("Test ERROR (with -Xcomp=" + withXcomp + ") " + ex, ex); } finally { LingeredApp.stopApp(theApp); } + } + + public static void main(String[] args) throws Exception { + System.out.println("Starting ClhsdbJstack test"); + testJstack(false); + testJstack(true); System.out.println("Test PASSED"); } } diff -r 093027a037cf -r 191ae61bd1e9 test/java/util/Calendar/Bug8185841.java --- a/test/java/util/Calendar/Bug8185841.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2017, 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 8185841 - * @summary Test that Region dependent Bundles are added/removed correctly. - * @modules jdk.localedata - */ - - /* -This test is dependent on a particular version of CLDR. - */ -import java.net.URI; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; - -public class Bug8185841 { - // Golden data for Region dependent Bundles in CLDR29. - - private static final Set expectedBundles - = Set.of("CalendarData_af_NA.class", "CalendarData_af_ZA.class", "CalendarData_agq_CM.class", - "CalendarData_ak_GH.class", "CalendarData_am_ET.class", "CalendarData_ar_AE.class", - "CalendarData_ar_BH.class", "CalendarData_ar_DJ.class", "CalendarData_ar_DZ.class", - "CalendarData_ar_EG.class", "CalendarData_ar_EH.class", "CalendarData_ar_ER.class", - "CalendarData_ar_IL.class", "CalendarData_ar_IQ.class", "CalendarData_ar_JO.class", - "CalendarData_ar_KM.class", "CalendarData_ar_KW.class", "CalendarData_ar_LB.class", - "CalendarData_ar_LY.class", "CalendarData_ar_MA.class", "CalendarData_ar_MR.class", - "CalendarData_ar_OM.class", "CalendarData_ar_PS.class", "CalendarData_ar_QA.class", - "CalendarData_ar_SA.class", "CalendarData_ar_SD.class", "CalendarData_ar_SO.class", - "CalendarData_ar_SS.class", "CalendarData_ar_SY.class", "CalendarData_ar_TD.class", - "CalendarData_ar_TN.class", "CalendarData_ar_YE.class", "CalendarData_as_IN.class", - "CalendarData_asa_TZ.class", "CalendarData_ast_ES.class", "CalendarData_az_AZ.class", - "CalendarData_az_Cyrl_AZ.class", "CalendarData_bas_CM.class", "CalendarData_be_BY.class", - "CalendarData_bem_ZM.class", "CalendarData_bez_TZ.class", "CalendarData_bg_BG.class", - "CalendarData_bm_ML.class", "CalendarData_bn_BD.class", "CalendarData_bn_IN.class", - "CalendarData_bo_CN.class", "CalendarData_bo_IN.class", "CalendarData_br_FR.class", - "CalendarData_brx_IN.class", "CalendarData_bs_BA.class", "CalendarData_bs_Cyrl_BA.class", - "CalendarData_ca_AD.class", "CalendarData_ca_ES.class", "CalendarData_ca_FR.class", - "CalendarData_ca_IT.class", "CalendarData_ce_RU.class", "CalendarData_cgg_UG.class", - "CalendarData_chr_US.class", "CalendarData_ckb_IQ.class", "CalendarData_ckb_IR.class", - "CalendarData_cs_CZ.class", "CalendarData_cu_RU.class", "CalendarData_cy_GB.class", - "CalendarData_da_DK.class", "CalendarData_da_GL.class", "CalendarData_dav_KE.class", - "CalendarData_de_AT.class", "CalendarData_de_BE.class", "CalendarData_de_CH.class", - "CalendarData_de_DE.class", "CalendarData_de_LI.class", "CalendarData_de_LU.class", - "CalendarData_dje_NE.class", "CalendarData_dsb_DE.class", "CalendarData_dua_CM.class", - "CalendarData_dyo_SN.class", "CalendarData_dz_BT.class", "CalendarData_ebu_KE.class", - "CalendarData_ee_GH.class", "CalendarData_ee_TG.class", "CalendarData_el_CY.class", - "CalendarData_el_GR.class", "CalendarData_en_AG.class", "CalendarData_en_AI.class", - "CalendarData_en_AS.class", "CalendarData_en_AT.class", "CalendarData_en_AU.class", - "CalendarData_en_BB.class", "CalendarData_en_BE.class", "CalendarData_en_BI.class", - "CalendarData_en_BM.class", "CalendarData_en_BS.class", "CalendarData_en_BW.class", - "CalendarData_en_BZ.class", "CalendarData_en_CA.class", "CalendarData_en_CC.class", - "CalendarData_en_CH.class", "CalendarData_en_CK.class", "CalendarData_en_CM.class", - "CalendarData_en_CX.class", "CalendarData_en_CY.class", "CalendarData_en_DE.class", - "CalendarData_en_DG.class", "CalendarData_en_DK.class", "CalendarData_en_DM.class", - "CalendarData_en_ER.class", "CalendarData_en_FI.class", "CalendarData_en_FJ.class", - "CalendarData_en_FK.class", "CalendarData_en_FM.class", "CalendarData_en_GB.class", - "CalendarData_en_GD.class", "CalendarData_en_GG.class", "CalendarData_en_GH.class", - "CalendarData_en_GI.class", "CalendarData_en_GM.class", "CalendarData_en_GU.class", - "CalendarData_en_GY.class", "CalendarData_en_HK.class", "CalendarData_en_IE.class", - "CalendarData_en_IL.class", "CalendarData_en_IM.class", "CalendarData_en_IN.class", - "CalendarData_en_IO.class", "CalendarData_en_JE.class", "CalendarData_en_JM.class", - "CalendarData_en_KE.class", "CalendarData_en_KI.class", "CalendarData_en_KN.class", - "CalendarData_en_KY.class", "CalendarData_en_LC.class", "CalendarData_en_LR.class", - "CalendarData_en_LS.class", "CalendarData_en_MG.class", "CalendarData_en_MH.class", - "CalendarData_en_MO.class", "CalendarData_en_MP.class", "CalendarData_en_MS.class", - "CalendarData_en_MT.class", "CalendarData_en_MU.class", "CalendarData_en_MW.class", - "CalendarData_en_MY.class", "CalendarData_en_NA.class", "CalendarData_en_NF.class", - "CalendarData_en_NG.class", "CalendarData_en_NL.class", "CalendarData_en_NR.class", - "CalendarData_en_NU.class", "CalendarData_en_NZ.class", "CalendarData_en_PG.class", - "CalendarData_en_PH.class", "CalendarData_en_PK.class", "CalendarData_en_PN.class", - "CalendarData_en_PR.class", "CalendarData_en_PW.class", "CalendarData_en_RW.class", - "CalendarData_en_SB.class", "CalendarData_en_SC.class", "CalendarData_en_SD.class", - "CalendarData_en_SE.class", "CalendarData_en_SG.class", "CalendarData_en_SH.class", - "CalendarData_en_SI.class", "CalendarData_en_SL.class", "CalendarData_en_SS.class", - "CalendarData_en_SX.class", "CalendarData_en_SZ.class", "CalendarData_en_TC.class", - "CalendarData_en_TK.class", "CalendarData_en_TO.class", "CalendarData_en_TT.class", - "CalendarData_en_TV.class", "CalendarData_en_TZ.class", "CalendarData_en_UG.class", - "CalendarData_en_UM.class", "CalendarData_en_VC.class", "CalendarData_en_VG.class", - "CalendarData_en_VI.class", "CalendarData_en_VU.class", "CalendarData_en_WS.class", - "CalendarData_en_ZA.class", "CalendarData_en_ZM.class", "CalendarData_en_ZW.class", - "CalendarData_es_AR.class", "CalendarData_es_BO.class", "CalendarData_es_BR.class", - "CalendarData_es_CL.class", "CalendarData_es_CO.class", "CalendarData_es_CR.class", - "CalendarData_es_CU.class", "CalendarData_es_DO.class", "CalendarData_es_EA.class", - "CalendarData_es_EC.class", "CalendarData_es_ES.class", "CalendarData_es_GQ.class", - "CalendarData_es_GT.class", "CalendarData_es_HN.class", "CalendarData_es_IC.class", - "CalendarData_es_MX.class", "CalendarData_es_NI.class", "CalendarData_es_PA.class", - "CalendarData_es_PE.class", "CalendarData_es_PH.class", "CalendarData_es_PR.class", - "CalendarData_es_PY.class", "CalendarData_es_SV.class", "CalendarData_es_US.class", - "CalendarData_es_UY.class", "CalendarData_es_VE.class", "CalendarData_et_EE.class", - "CalendarData_eu_ES.class", "CalendarData_ewo_CM.class", "CalendarData_fa_AF.class", - "CalendarData_fa_IR.class", "CalendarData_ff_CM.class", "CalendarData_ff_GN.class", - "CalendarData_ff_MR.class", "CalendarData_ff_SN.class", "CalendarData_fi_FI.class", - "CalendarData_fil_PH.class", "CalendarData_fo_DK.class", "CalendarData_fo_FO.class", - "CalendarData_fr_BE.class", "CalendarData_fr_BF.class", "CalendarData_fr_BI.class", - "CalendarData_fr_BJ.class", "CalendarData_fr_BL.class", "CalendarData_fr_CA.class", - "CalendarData_fr_CD.class", "CalendarData_fr_CF.class", "CalendarData_fr_CG.class", - "CalendarData_fr_CH.class", "CalendarData_fr_CI.class", "CalendarData_fr_CM.class", - "CalendarData_fr_DJ.class", "CalendarData_fr_DZ.class", "CalendarData_fr_FR.class", - "CalendarData_fr_GA.class", "CalendarData_fr_GF.class", "CalendarData_fr_GN.class", - "CalendarData_fr_GP.class", "CalendarData_fr_GQ.class", "CalendarData_fr_HT.class", - "CalendarData_fr_KM.class", "CalendarData_fr_LU.class", "CalendarData_fr_MA.class", - "CalendarData_fr_MC.class", "CalendarData_fr_MF.class", "CalendarData_fr_MG.class", - "CalendarData_fr_ML.class", "CalendarData_fr_MQ.class", "CalendarData_fr_MR.class", - "CalendarData_fr_MU.class", "CalendarData_fr_NC.class", "CalendarData_fr_NE.class", - "CalendarData_fr_PF.class", "CalendarData_fr_PM.class", "CalendarData_fr_RE.class", - "CalendarData_fr_RW.class", "CalendarData_fr_SC.class", "CalendarData_fr_SN.class", - "CalendarData_fr_SY.class", "CalendarData_fr_TD.class", "CalendarData_fr_TG.class", - "CalendarData_fr_TN.class", "CalendarData_fr_VU.class", "CalendarData_fr_WF.class", - "CalendarData_fr_YT.class", "CalendarData_fur_IT.class", "CalendarData_fy_NL.class", - "CalendarData_ga_IE.class", "CalendarData_gd_GB.class", "CalendarData_gl_ES.class", - "CalendarData_gsw_CH.class", "CalendarData_gsw_FR.class", "CalendarData_gsw_LI.class", - "CalendarData_gu_IN.class", "CalendarData_guz_KE.class", "CalendarData_gv_IM.class", - "CalendarData_ha_GH.class", "CalendarData_ha_NE.class", "CalendarData_ha_NG.class", - "CalendarData_haw_US.class", "CalendarData_hi_IN.class", "CalendarData_hr_BA.class", - "CalendarData_hr_HR.class", "CalendarData_hsb_DE.class", "CalendarData_hu_HU.class", - "CalendarData_hy_AM.class", "CalendarData_ig_NG.class", "CalendarData_ii_CN.class", - "CalendarData_in_ID.class", "CalendarData_is_IS.class", "CalendarData_it_CH.class", - "CalendarData_it_IT.class", "CalendarData_it_SM.class", "CalendarData_iw_IL.class", - "CalendarData_ja_JP.class", "CalendarData_jgo_CM.class", "CalendarData_jmc_TZ.class", - "CalendarData_ka_GE.class", "CalendarData_kab_DZ.class", "CalendarData_kam_KE.class", - "CalendarData_kde_TZ.class", "CalendarData_kea_CV.class", "CalendarData_khq_ML.class", - "CalendarData_ki_KE.class", "CalendarData_kk_KZ.class", "CalendarData_kkj_CM.class", - "CalendarData_kl_GL.class", "CalendarData_kln_KE.class", "CalendarData_km_KH.class", - "CalendarData_kn_IN.class", "CalendarData_ko_KP.class", "CalendarData_ko_KR.class", - "CalendarData_kok_IN.class", "CalendarData_ks_IN.class", "CalendarData_ksb_TZ.class", - "CalendarData_ksf_CM.class", "CalendarData_ksh_DE.class", "CalendarData_kw_GB.class", - "CalendarData_ky_KG.class", "CalendarData_lag_TZ.class", "CalendarData_lb_LU.class", - "CalendarData_lg_UG.class", "CalendarData_lkt_US.class", "CalendarData_ln_AO.class", - "CalendarData_ln_CD.class", "CalendarData_ln_CF.class", "CalendarData_ln_CG.class", - "CalendarData_lo_LA.class", "CalendarData_lrc_IQ.class", "CalendarData_lrc_IR.class", - "CalendarData_lt_LT.class", "CalendarData_lu_CD.class", "CalendarData_luo_KE.class", - "CalendarData_luy_KE.class", "CalendarData_lv_LV.class", "CalendarData_mas_KE.class", - "CalendarData_mas_TZ.class", "CalendarData_mer_KE.class", "CalendarData_mfe_MU.class", - "CalendarData_mg_MG.class", "CalendarData_mgh_MZ.class", "CalendarData_mgo_CM.class", - "CalendarData_mk_MK.class", "CalendarData_ml_IN.class", "CalendarData_mn_MN.class", - "CalendarData_mr_IN.class", "CalendarData_ms_BN.class", "CalendarData_ms_MY.class", - "CalendarData_ms_SG.class", "CalendarData_mt_MT.class", "CalendarData_mua_CM.class", - "CalendarData_my_MM.class", "CalendarData_mzn_IR.class", "CalendarData_naq_NA.class", - "CalendarData_nb_NO.class", "CalendarData_nb_SJ.class", "CalendarData_nd_ZW.class", - "CalendarData_ne_IN.class", "CalendarData_ne_NP.class", "CalendarData_nl_AW.class", - "CalendarData_nl_BE.class", "CalendarData_nl_BQ.class", "CalendarData_nl_CW.class", - "CalendarData_nl_NL.class", "CalendarData_nl_SR.class", "CalendarData_nl_SX.class", - "CalendarData_nmg_CM.class", "CalendarData_nnh_CM.class", "CalendarData_nus_SS.class", - "CalendarData_nyn_UG.class", "CalendarData_om_ET.class", "CalendarData_om_KE.class", - "CalendarData_or_IN.class", "CalendarData_os_GE.class", "CalendarData_os_RU.class", - "CalendarData_pa_Arab_PK.class", "CalendarData_pa_IN.class", "CalendarData_pa_PK.class", - "CalendarData_pl_PL.class", "CalendarData_ps_AF.class", "CalendarData_pt_AO.class", - "CalendarData_pt_BR.class", "CalendarData_pt_CV.class", "CalendarData_pt_GQ.class", - "CalendarData_pt_GW.class", "CalendarData_pt_MO.class", "CalendarData_pt_MZ.class", - "CalendarData_pt_PT.class", "CalendarData_pt_ST.class", "CalendarData_pt_TL.class", - "CalendarData_qu_BO.class", "CalendarData_qu_EC.class", "CalendarData_qu_PE.class", - "CalendarData_rm_CH.class", "CalendarData_rn_BI.class", "CalendarData_ro_MD.class", - "CalendarData_ro_RO.class", "CalendarData_rof_TZ.class", "CalendarData_ru_BY.class", - "CalendarData_ru_KG.class", "CalendarData_ru_KZ.class", "CalendarData_ru_MD.class", - "CalendarData_ru_RU.class", "CalendarData_ru_UA.class", "CalendarData_rw_RW.class", - "CalendarData_rwk_TZ.class", "CalendarData_sah_RU.class", "CalendarData_saq_KE.class", - "CalendarData_sbp_TZ.class", "CalendarData_se_FI.class", "CalendarData_se_NO.class", - "CalendarData_se_SE.class", "CalendarData_seh_MZ.class", "CalendarData_ses_ML.class", - "CalendarData_sg_CF.class", "CalendarData_shi_Latn_MA.class", "CalendarData_shi_MA.class", - "CalendarData_si_LK.class", "CalendarData_sk_SK.class", "CalendarData_sl_SI.class", - "CalendarData_smn_FI.class", "CalendarData_sn_ZW.class", "CalendarData_so_DJ.class", - "CalendarData_so_ET.class", "CalendarData_so_KE.class", "CalendarData_so_SO.class", - "CalendarData_sq_AL.class", "CalendarData_sq_MK.class", "CalendarData_sq_XK.class", - "CalendarData_sr_BA.class", "CalendarData_sr_Latn_BA.class", "CalendarData_sr_Latn_ME.class", - "CalendarData_sr_Latn_RS.class", "CalendarData_sr_Latn_XK.class", "CalendarData_sr_ME.class", - "CalendarData_sr_RS.class", "CalendarData_sr_XK.class", "CalendarData_sv_AX.class", - "CalendarData_sv_FI.class", "CalendarData_sv_SE.class", "CalendarData_sw_CD.class", - "CalendarData_sw_KE.class", "CalendarData_sw_TZ.class", "CalendarData_sw_UG.class", - "CalendarData_ta_IN.class", "CalendarData_ta_LK.class", "CalendarData_ta_MY.class", - "CalendarData_ta_SG.class", "CalendarData_te_IN.class", "CalendarData_teo_KE.class", - "CalendarData_teo_UG.class", "CalendarData_th_TH.class", "CalendarData_ti_ER.class", - "CalendarData_ti_ET.class", "CalendarData_tk_TM.class", "CalendarData_to_TO.class", - "CalendarData_tr_CY.class", "CalendarData_tr_TR.class", "CalendarData_twq_NE.class", - "CalendarData_tzm_MA.class", "CalendarData_ug_CN.class", "CalendarData_uk_UA.class", - "CalendarData_ur_IN.class", "CalendarData_ur_PK.class", "CalendarData_uz_AF.class", - "CalendarData_uz_Arab_AF.class", "CalendarData_uz_Cyrl_UZ.class", "CalendarData_uz_UZ.class", - "CalendarData_vai_LR.class", "CalendarData_vai_Latn_LR.class", "CalendarData_vi_VN.class", - "CalendarData_vun_TZ.class", "CalendarData_wae_CH.class", "CalendarData_xog_UG.class", - "CalendarData_yav_CM.class", "CalendarData_yo_BJ.class", "CalendarData_yo_NG.class", - "CalendarData_yue_HK.class", "CalendarData_zgh_MA.class", "CalendarData_zh_CN.class", - "CalendarData_zh_HK.class", "CalendarData_zh_Hant_HK.class", "CalendarData_zh_Hant_TW.class", - "CalendarData_zh_MO.class", "CalendarData_zh_SG.class", "CalendarData_zh_TW.class", "CalendarData_zu_ZA.class"); - - private static Set removedBundles = Set.of( - "CalendarData_az_Latn_AZ.class", "CalendarData_bs_Latn_BA.class", - "CalendarData_pa_Guru_IN.class", "CalendarData_shi_Tfng_MA.class", - "CalendarData_sr_Cyrl_BA.class", "CalendarData_sr_Cyrl_ME.class", - "CalendarData_sr_Cyrl_RS.class", "CalendarData_sr_Cyrl_XK.class", - "CalendarData_uz_Latn_UZ.class", "CalendarData_vai_Vaii_LR.class", - "CalendarData_zh_Hans_CN.class", "CalendarData_zh_Hans_HK.class", - "CalendarData_zh_Hans_MO.class", "CalendarData_zh_Hans_SG.class"); - - private static Set addedBundles = Set.of( - "CalendarData_az_AZ.class", "CalendarData_bs_BA.class", - "CalendarData_pa_IN.class", "CalendarData_pa_PK.class", - "CalendarData_shi_MA.class", "CalendarData_sr_BA.class", - "CalendarData_sr_ME.class", "CalendarData_sr_RS.class", - "CalendarData_sr_XK.class", "CalendarData_uz_UZ.class", - "CalendarData_uz_AF.class", "CalendarData_vai_LR.class", - "CalendarData_zh_CN.class", "CalendarData_zh_HK.class", - "CalendarData_zh_MO.class", "CalendarData_zh_SG.class", "CalendarData_zh_TW.class"); - - private static Set retrievedBundles = Collections.EMPTY_SET; - - public static void main(String[] args) throws Exception { - FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"), - Collections.emptyMap()); - Path path = fs.getPath("/", "modules", "jdk.localedata", "sun/util/resources/cldr/ext"); - retrievedBundles = Files.walk(path) - .map(p -> p.getFileName().toString()) - .filter(p -> p.startsWith("CalendarData_")) - .collect(Collectors.toSet()); - if (!retrievedBundles.equals(expectedBundles)) { - checkAddedBundles(); - checkRemovedBundles(); - Set retrievedBundlesSet = new HashSet<>(retrievedBundles); - retrievedBundlesSet.removeAll(expectedBundles); - throw new RuntimeException("Unexpected " - + " bundles " + retrievedBundlesSet + " are present in jdk.localedata module "); - - } - } - - /** - * This method checks that bundles which have been additionally generated - * are present in jdk.localedata module. - */ - private static void checkAddedBundles() { - Set addedBundlesSet = new HashSet<>(addedBundles); - addedBundlesSet.removeAll(retrievedBundles); - if (!addedBundlesSet.isEmpty()) { - throw new RuntimeException("expected CalendarData" - + " bundles " + addedBundlesSet + " are not present in jdk.localedata module "); - } - - } - - /** - * This method checks that bundles which have been removed are not present - * in jdk.localedata module. - */ - private static void checkRemovedBundles() { - Set unexpectedBundles = removedBundles.stream(). - filter(retrievedBundles::contains).collect(Collectors.toSet()); - if (!unexpectedBundles.isEmpty()) { - throw new RuntimeException("Unexpected CalendarData" - + " bundles " + unexpectedBundles + " are present in jdk.localedata module "); - } - } -} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/TEST.groups --- a/test/jdk/TEST.groups Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/TEST.groups Wed Dec 13 10:25:38 2017 -0800 @@ -202,6 +202,9 @@ :jdk_security3 \ :jdk_security4 +jdk_security_infra = \ + security/infra/java/security/cert/CertPathValidator/certification + jdk_text = \ java/text \ sun/text diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/io/ByteArrayOutputStream/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/io/ByteArrayOutputStream/EncodingTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2017, 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.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + /* + * DataProvider for the toString method test. Provides the following fields: + * byte array, charset name string, charset object + */ + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + byte[] data = getData(); + return new Object[][]{ + {data, StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8}, + {data, StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1}, + }; + } + + /** + * Verifies that the new overload method that takes a Charset is equivalent to + * the existing one that takes a charset name. + * @param data a byte array + * @param csn the charset name + * @param charset the charset + * @throws Exception if the test fails + */ + @Test(dataProvider = "parameters") + public void test(byte[] data, String csn, Charset charset) throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + baos.write(data); + String str1 = baos.toString(csn); + String str2 = baos.toString(charset); + Assert.assertEquals(str1, str2); + } + + /* + * Returns an array containing a character that's invalid for UTF-8 + * but valid for ISO-8859-1 + */ + byte[] getData() throws IOException { + String str1 = "A string that contains "; + String str2 = " , an invalid character for UTF-8."; + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + baos.write(str1.getBytes()); + baos.write(0xFA); + baos.write(str2.getBytes()); + return baos.toByteArray(); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/io/PrintStream/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/io/PrintStream/EncodingTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2017, 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.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + static String USER_DIR = System.getProperty("user.dir", "."); + static boolean AUTOFLUSH = true; + public static enum ConstructorType { + STRING, + FILE, + OUTPUTSTREAM + } + + /* + * DataProvider fields: + * Type of the constructor, a file to be written with a charset name, + * a file to be written with a charset, charset name, charset. + */ + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + String csn = StandardCharsets.UTF_8.name(); + Charset charset = StandardCharsets.UTF_8; + File file1 = new File(USER_DIR, "PSCharsetTest1.txt"); + File file2 = new File(USER_DIR, "PSCharsetTest2.txt"); + + return new Object[][]{ + {ConstructorType.STRING, file1, file2, csn, charset}, + {ConstructorType.FILE, file1, file2, csn, charset}, + {ConstructorType.OUTPUTSTREAM, file1, file2, csn, charset} + }; + } + + /** + * Verifies that the overloading constructor behaves the same as the existing + * one. + * @param type the type of the constructor + * @param file1 file1 written with the name of a charset + * @param file2 file2 written with a charset + * @param csn the charset name + * @param charset the charset + * @throws IOException + */ + @Test(dataProvider = "parameters") + public void test(ConstructorType type, File file1, File file2, String csn, Charset charset) + throws Exception { + createFile(getPrintStream(type, file1.getPath(), csn, null)); + createFile(getPrintStream(type, file2.getPath(), null, charset)); + + Assert.assertEquals(Files.readAllLines(Paths.get(file1.getPath()), charset), + Files.readAllLines(Paths.get(file2.getPath()), charset)); + } + + public void createFile(PrintStream out) throws IOException { + out.println("high surrogate"); + out.println(Character.MIN_HIGH_SURROGATE); + out.println("low surrogate"); + out.println(Character.MIN_LOW_SURROGATE); + out.flush(); + out.close(); + } + + PrintStream getPrintStream(ConstructorType type, String path, String csn, Charset charset) + throws IOException { + PrintStream out = null; + if (csn != null) { + switch (type) { + case STRING: + out = new PrintStream(path, csn); + break; + case FILE: + out = new PrintStream(new File(path), csn); + break; + case OUTPUTSTREAM: + FileOutputStream fout = new FileOutputStream(path); + out = new PrintStream(fout, AUTOFLUSH, csn); + break; + } + } else { + switch (type) { + case STRING: + out = new PrintStream(path, charset); + break; + case FILE: + out = new PrintStream(new File(path), charset); + break; + case OUTPUTSTREAM: + FileOutputStream fout = new FileOutputStream(path); + out = new PrintStream(fout, AUTOFLUSH, charset); + break; + } + } + + return out; + } + +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/io/PrintStream/FailingConstructors.java --- a/test/jdk/java/io/PrintStream/FailingConstructors.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/io/PrintStream/FailingConstructors.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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,7 +23,7 @@ /** * @test - * @bug 7000511 + * @bug 7000511 8190577 * @summary PrintStream, PrintWriter, Formatter, Scanner leave files open when * exception thrown */ @@ -68,7 +68,7 @@ check(exists, file); try { - new PrintStream(file, null); + new PrintStream(file, (String)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); @@ -87,7 +87,7 @@ check(exists, file); try { - new PrintStream(file.getName(), null); + new PrintStream(file.getName(), (String)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/io/PrintWriter/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/io/PrintWriter/EncodingTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2017, 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.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + static String USER_DIR = System.getProperty("user.dir", "."); + static boolean AUTOFLUSH = true; + public static enum ConstructorType { + STRING, + FILE, + OUTPUTSTREAM + } + + /* + * DataProvider fields: + * Type of the constructor, a file to be written with a charset name, + * a file to be written with a charset, charset name, charset. + */ + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + String csn = StandardCharsets.UTF_8.name(); + Charset charset = StandardCharsets.UTF_8; + File file1 = new File(USER_DIR, "PWCharsetTest1.txt"); + File file2 = new File(USER_DIR, "PWCharsetTest2.txt"); + + return new Object[][]{ + {ConstructorType.STRING, file1, file2, csn, charset}, + {ConstructorType.FILE, file1, file2, csn, charset}, + {ConstructorType.OUTPUTSTREAM, file1, file2, csn, charset} + }; + } + + /** + * Verifies that the overloading constructor behaves the same as the existing + * one. + * + * @param type the type of the constructor + * @param file1 file1 written with the name of a charset + * @param file2 file2 written with a charset + * @param csn the charset name + * @param charset the charset + * @throws IOException + */ + @Test(dataProvider = "parameters") + public void test(ConstructorType type, File file1, File file2, String csn, Charset charset) + throws Exception { + createFile(getWriter(type, file1.getPath(), csn, null)); + createFile(getWriter(type, file2.getPath(), null, charset)); + + Assert.assertEquals(Files.readAllLines(Paths.get(file1.getPath()), charset), + Files.readAllLines(Paths.get(file2.getPath()), charset)); + } + + void createFile(PrintWriter out) throws IOException { + out.println("high surrogate"); + out.println(Character.MIN_HIGH_SURROGATE); + out.println("low surrogate"); + out.println(Character.MIN_LOW_SURROGATE); + out.flush(); + out.close(); + } + + PrintWriter getWriter(ConstructorType type, String path, String csn, Charset charset) + throws IOException { + PrintWriter out = null; + if (csn != null) { + switch (type) { + case STRING: + out = new PrintWriter(path, csn); + break; + case FILE: + out = new PrintWriter(new File(path), csn); + break; + case OUTPUTSTREAM: + // No corresponding method with charset name + // compare with PrintWriter(path, csn) instead + out = new PrintWriter(path, csn); + break; + } + } else { + switch (type) { + case STRING: + out = new PrintWriter(path, charset); + break; + case FILE: + out = new PrintWriter(new File(path), charset); + break; + case OUTPUTSTREAM: + FileOutputStream fout = new FileOutputStream(path); + out = new PrintWriter(fout, AUTOFLUSH, charset); + break; + } + } + + return out; + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/io/PrintWriter/FailingConstructors.java --- a/test/jdk/java/io/PrintWriter/FailingConstructors.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/io/PrintWriter/FailingConstructors.java Wed Dec 13 10:25:38 2017 -0800 @@ -67,7 +67,7 @@ check(exists, file); try { - new PrintWriter(file, null); + new PrintWriter(file, (String)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); @@ -86,7 +86,7 @@ check(exists, file); try { - new PrintWriter(file.getName(), null); + new PrintWriter(file.getName(), (String)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/net/URLDecoder/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/net/URLDecoder/EncodingTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017, 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.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the + * same as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + public static enum ParameterType { + STRING, + CHARSET + } + + @DataProvider(name = "illegalArgument") + public Object[][] getParameters() { + return new Object[][]{ + {ParameterType.STRING}, + {ParameterType.CHARSET} + }; + } + + @DataProvider(name = "decode") + public Object[][] getDecodeParameters() { + return new Object[][]{ + {"The string \u00FC@foo-bar"}, + // the string from javadoc example + + {""}, // an empty string + + {"x"}, // a string of length 1 + + {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.*"}, + // the string of characters should remain the same + + {charactersRange('\u0000', '\u007F')}, + // a string of characters from 0 to 127 + + {charactersRange('\u0080', '\u00FF')}, + // a string of characters from 128 to 255 + + {"\u0100 \u0101 \u0555 \u07FD \u07FF"}, + // a string of Unicode values can be expressed as 2 bytes + + {"\u8000 \u8001 \uA000 \uFFFD \uFFFF"}, // a string of Unicode values can be expressed as 3 bytes + }; + } + + /** + * Verifies that IAE is thrown when decoding an invalid string using the + * existing method or the new overload method. + * + * @param type the type of the argument, e.g a String charset name or + * charset + */ + @Test(dataProvider = "illegalArgument", expectedExceptions = IllegalArgumentException.class) + public void testIllegalArgument(ParameterType type) throws Exception { + String encoded = URLEncoder.encode("http://www.xyz.com/find?key=\u0100\u0101", + StandardCharsets.UTF_8.name()); + String illegal = "%" + encoded; + String returned; + if (type == ParameterType.STRING) { + returned = URLDecoder.decode(illegal, StandardCharsets.UTF_8.name()); + } else { + returned = URLDecoder.decode(illegal, StandardCharsets.UTF_8); + } + } + + /** + * Verifies that the returned values of decoding with the existing + * and the overload methods match. + * + * @param s the string to be encoded and then decoded with both existing + * and the overload methods. + * @throws Exception + */ + @Test(dataProvider = "decode") + public void decode(String s) throws Exception { + String encoded = URLEncoder.encode(s, StandardCharsets.UTF_8.name()); + String returned1 = URLDecoder.decode(encoded, StandardCharsets.UTF_8.name()); + String returned2 = URLDecoder.decode(encoded, StandardCharsets.UTF_8); + Assert.assertEquals(returned1, returned2); + } + + String charactersRange(char c1, char c2) { + StringBuilder sb = new StringBuilder(c2 - c1); + for (char c = c1; c < c2; c++) { + sb.append(c); + } + + return sb.toString(); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/net/URLDecoder/URLDecoderArgs.java --- a/test/jdk/java/net/URLDecoder/URLDecoderArgs.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/net/URLDecoder/URLDecoderArgs.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, 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,7 +23,7 @@ /** * @test - * @bug 4444194 + * @bug 4444194 8190577 * @summary java.net.URLDecoder.decode(s, enc) treats an empty encoding name as "UTF-8" */ import java.net.URLDecoder; @@ -32,7 +32,7 @@ public class URLDecoderArgs { public static void main (String[] args) { try { - String s1 = URLDecoder.decode ("Hello World", null); + String s1 = URLDecoder.decode ("Hello World", (String)null); } catch (UnsupportedEncodingException e) { throw new RuntimeException ("NPE should have been thrown"); } catch (NullPointerException e) { diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/net/URLEncoder/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/net/URLEncoder/EncodingTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017, 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.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + public static enum ParameterType { + STRING, + CHARSET + } + + @DataProvider(name = "encode") + public Object[][] getDecodeParameters() { + return new Object[][]{ + {"The string \u00FC@foo-bar"}, + // the string from javadoc example + + {""}, // an empty string + + {"x"}, // a string of length 1 + + {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.*"}, + // the string of characters should remain the same + + {charactersRange('\u0000', '\u007F')}, + // a string of characters from 0 to 127 + + {charactersRange('\u0080', '\u00FF')}, + // a string of characters from 128 to 255 + + {"\u0100 \u0101 \u0555 \u07FD \u07FF"}, + // a string of Unicode values can be expressed as 2 bytes + + {"\u8000 \u8001 \uA000 \uFFFD \uFFFF"}, // a string of Unicode values can be expressed as 3 bytes + }; + } + + /** + * Verifies that the new overload method returns the same result as the + * existing method. + * + * @param s the string to be encoded + * @throws Exception if the test fails + */ + @Test(dataProvider = "encode") + public void encode(String s) throws Exception { + String encoded1 = URLEncoder.encode(s, StandardCharsets.UTF_8.name()); + String encoded2 = URLEncoder.encode(s, StandardCharsets.UTF_8); + Assert.assertEquals(encoded1, encoded2); + + // cross check + String returned1 = URLDecoder.decode(encoded1, StandardCharsets.UTF_8.name()); + String returned2 = URLDecoder.decode(encoded2, StandardCharsets.UTF_8); + Assert.assertEquals(returned1, returned2); + } + + String charactersRange(char c1, char c2) { + StringBuilder sb = new StringBuilder(c2 - c1); + for (char c = c1; c < c2; c++) { + sb.append(c); + } + + return sb.toString(); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/net/URLEncoder/URLEncoderEncodeArgs.java --- a/test/jdk/java/net/URLEncoder/URLEncoderEncodeArgs.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/net/URLEncoder/URLEncoderEncodeArgs.java Wed Dec 13 10:25:38 2017 -0800 @@ -32,7 +32,7 @@ public class URLEncoderEncodeArgs { public static void main (String[] args) { try { - String s1 = URLEncoder.encode ("Hello World", null); + String s1 = URLEncoder.encode ("Hello World", (String)null); } catch (UnsupportedEncodingException e) { throw new RuntimeException ("NPE should have been thrown"); } catch (NullPointerException e) { diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/net/httpclient/security/filePerms/httpclient.policy --- a/test/jdk/java/net/httpclient/security/filePerms/httpclient.policy Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/net/httpclient/security/filePerms/httpclient.policy Wed Dec 13 10:25:38 2017 -0800 @@ -49,6 +49,7 @@ permission java.util.PropertyPermission "jdk.httpclient.maxstreams","read"; permission java.util.PropertyPermission "jdk.httpclient.redirects.retrylimit","read"; permission java.util.PropertyPermission "jdk.httpclient.windowsize","read"; + permission java.util.PropertyPermission "jdk.httpclient.receiveBufferSize","read"; permission java.util.PropertyPermission "jdk.httpclient.bufsize","read"; permission java.util.PropertyPermission "jdk.httpclient.internal.selector.timeout","read"; permission java.util.PropertyPermission "jdk.internal.httpclient.debug","read"; diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/net/httpclient/websocket/security/httpclient.policy --- a/test/jdk/java/net/httpclient/websocket/security/httpclient.policy Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/net/httpclient/websocket/security/httpclient.policy Wed Dec 13 10:25:38 2017 -0800 @@ -49,6 +49,7 @@ permission java.util.PropertyPermission "jdk.httpclient.maxstreams","read"; permission java.util.PropertyPermission "jdk.httpclient.redirects.retrylimit","read"; permission java.util.PropertyPermission "jdk.httpclient.windowsize","read"; + permission java.util.PropertyPermission "jdk.httpclient.receiveBufferSize","read"; permission java.util.PropertyPermission "jdk.httpclient.bufsize","read"; permission java.util.PropertyPermission "jdk.httpclient.internal.selector.timeout","read"; permission java.util.PropertyPermission "jdk.internal.httpclient.debug","read"; diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/nio/channels/Channels/Basic.java --- a/test/jdk/java/nio/channels/Channels/Basic.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/nio/channels/Channels/Basic.java Wed Dec 13 10:25:38 2017 -0800 @@ -108,13 +108,24 @@ } catch (NullPointerException npe) {} try { - Channels.newReader(rbc, null); + Channels.newReader(rbc, (String)null); failNpeExpected(); } catch (NullPointerException npe) {} try { - Channels.newReader(null, null); + Channels.newReader(null, (String)null); + failNpeExpected(); + } catch (NullPointerException npe) {} + + try { + Channels.newReader(rbc, (Charset)null); + failNpeExpected(); + } catch (NullPointerException npe) {} + + + try { + Channels.newReader(null, (Charset)null); failNpeExpected(); } catch (NullPointerException npe) {} @@ -142,15 +153,24 @@ } catch (NullPointerException npe) {} try { - Channels.newWriter(wbc, null); + Channels.newWriter(wbc, (String)null); failNpeExpected(); } catch (NullPointerException npe) {} try { - Channels.newWriter(null, null); + Channels.newWriter(null, (String)null); failNpeExpected(); } catch (NullPointerException npe) {} + try { + Channels.newWriter(wbc, (Charset)null); + failNpeExpected(); + } catch (NullPointerException npe) {} + + try { + Channels.newWriter(null, (Charset)null); + failNpeExpected(); + } catch (NullPointerException npe) {} try { blah = File.createTempFile("blah", null); diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/nio/channels/Channels/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/nio/channels/Channels/EncodingTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2017, 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.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.nio.channels.WritableByteChannel; +import java.nio.charset.Charset; +import java.nio.charset.MalformedInputException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Paths; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + static final int ITERATIONS = 2; + public static final String CS_UTF8 = StandardCharsets.UTF_8.name(); + public static final String CS_ISO8859 = StandardCharsets.ISO_8859_1.name(); + static String USER_DIR = System.getProperty("user.dir", "."); + + // malformed input: a high surrogate without the low surrogate + static char[] illChars = { + '\u00fa', '\ud800' + }; + + static byte[] data = getData(); + + static byte[] getData() { + try { + String str1 = "A string that contains "; + String str2 = " , an invalid character for UTF-8."; + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + baos.write(str1.getBytes()); + baos.write(0xFA); + baos.write(str2.getBytes()); + return baos.toByteArray(); + } catch (IOException ex) { + return null; //shouldn't happen + } + } + + String testFile = Paths.get(USER_DIR, "channelsEncodingTest.txt").toString(); + String testIllegalInput = Paths.get(USER_DIR, "channelsIllegalInputTest.txt").toString(); + String testIllegalOutput = Paths.get(USER_DIR, "channelsIllegalOutputTest.txt").toString(); + + + /* + * DataProvider for read and write test. + * Writes and reads with the same encoding + */ + @DataProvider(name = "writeAndRead") + public Object[][] getWRParameters() { + return new Object[][]{ + {testFile, StandardCharsets.ISO_8859_1.name(), null, + StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1}, + {testFile, null, StandardCharsets.ISO_8859_1, + StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1}, + {testFile, StandardCharsets.UTF_8.name(), null, + StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8}, + {testFile, null, StandardCharsets.UTF_8, + StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8} + }; + } + + /* + * DataProvider for illegal input test + * Writes the data in ISO8859 and reads with UTF8, expects MalformedInputException + */ + @DataProvider(name = "illegalInput") + public Object[][] getParameters() { + return new Object[][]{ + {testIllegalInput, StandardCharsets.ISO_8859_1.name(), null, StandardCharsets.UTF_8.name(), null}, + {testIllegalInput, StandardCharsets.ISO_8859_1.name(), null, null, StandardCharsets.UTF_8}, + {testIllegalInput, null, StandardCharsets.ISO_8859_1, StandardCharsets.UTF_8.name(), null}, + {testIllegalInput, null, StandardCharsets.ISO_8859_1, null, StandardCharsets.UTF_8}, + }; + } + + /* + * DataProvider for illegal output test + * Attemps to write some malformed chars, expects MalformedInputException + */ + @DataProvider(name = "illegalOutput") + public Object[][] getWriteParameters() { + return new Object[][]{ + {testIllegalOutput, StandardCharsets.UTF_8.name(), null}, + {testIllegalOutput, null, StandardCharsets.UTF_8} + }; + } + + /** + * Verifies that the Readers created with the following methods are + * equivalent: + * newReader(ReadableByteChannel ch, String csName) + * newReader(ReadableByteChannel ch, Charset charset) + * + * The verification follows the following steps: + * Writes a file with a writer created with the specified charset + * Reads it with a reader created with newReader using the same charset; + * Compares that the results are the same. + * + * @param file the file name + * @param csnWriter the charset name for creating the writer + * @param charsetWriter the charset for creating the writer + * @param csnReader the charset name for creating the reader + * @param charsetReader the charset for creating the reader + * @throws Exception + */ + @Test(dataProvider = "writeAndRead") + public void testWriteAndRead(String file, String csnWriter, Charset charsetWriter, + String csnReader, Charset charsetReader) throws Exception { + writeToFile(data, file, csnWriter, charsetWriter); + // read using charset name + String result1 = readFileToString(file, csnReader, null); + String result2 = readFileToString(file, null, charsetReader); + + Assert.assertEquals(result1, result2); + } + + /** + * Verifies that MalformedInputException is thrown when an input byte sequence + * is illegal for given charset that is configured for the reader. + * + * @param file the file to be read + * @param csnWriter the charset name for creating the writer + * @param charsetWriter the charset for creating the writer + * @param csnReader the charset name for creating the reader + * @param charsetReader the charset for creating the reader + * @throws Exception + */ + @Test(dataProvider = "illegalInput", expectedExceptions = MalformedInputException.class) + void testMalformedInput(String file, String csnWriter, Charset charsetWriter, + String csnReader, Charset charsetReader) throws Exception { + writeToFile(data, file, csnWriter, charsetWriter); + readFileToString(file, csnReader, charsetReader); + } + + /** + * Attempts to write illegal characters using a writer created by calling + * the newWriter method and expects a MalformedInputException. + * + * @param fileName the file name + * @param csn the charset name + * @param charset the charset + * @throws Exception + */ + @Test(dataProvider = "illegalOutput", expectedExceptions = MalformedInputException.class) + public void testMalformedOutput(String fileName, String csn, Charset charset) + throws Exception { + try (FileOutputStream fos = new FileOutputStream(fileName); + WritableByteChannel wbc = (WritableByteChannel) fos.getChannel();) { + Writer writer; + if (csn != null) { + writer = Channels.newWriter(wbc, csn); + } else { + writer = Channels.newWriter(wbc, charset); + } + + for (int i = 0; i < ITERATIONS; i++) { + writer.write(illChars); + } + writer.flush(); + writer.close(); + } + } + + /** + * Writes the data to a file using a writer created by calling the newWriter + * method. + * + * @param data the data to be written + * @param fileName the file name + * @param csn the charset name + * @param charset the charset + * @throws Exception + */ + private void writeToFile(byte[] data, String fileName, String csn, Charset charset) throws Exception { + try (FileOutputStream fos = new FileOutputStream(fileName); + WritableByteChannel wbc = (WritableByteChannel) fos.getChannel()) { + Writer writer; + String temp; + if (csn != null) { + writer = Channels.newWriter(wbc, csn); + temp = new String(data, csn); + } else { + writer = Channels.newWriter(wbc, charset); + temp = new String(data, charset); + } + + for (int i = 0; i < ITERATIONS; i++) { + writer.write(temp); + } + writer.flush(); + writer.close(); + } + } + + /** + * Reads a file into a String. + * + * @param file the file to be read + * @param csn the charset name + * @param charset the charset + * @throws Exception + */ + String readFileToString(String file, String csn, Charset charset) throws Exception { + String result; + try (FileInputStream fis = new FileInputStream(file); + ReadableByteChannel rbc = (ReadableByteChannel) fis.getChannel()) { + Reader reader; + if (csn != null) { + reader = Channels.newReader(rbc, csn); + } else { + reader = Channels.newReader(rbc, charset); + } + + int messageSize = data.length * ITERATIONS; + char data1[] = new char[messageSize]; + int totalRead = 0; + int charsRead = 0; + while (totalRead < messageSize) { + totalRead += charsRead; + charsRead = reader.read(data1, totalRead, messageSize - totalRead); + } + + result = new String(data1, 0, totalRead); + reader.close(); + } + + return result; + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,852 @@ +/* + * Copyright (c) 2017, 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 8176841 + * @summary Tests java.time classes deals with Unicode extensions + * correctly. + * @modules jdk.localedata + */ +package test.java.time.format; + +import static org.testng.Assert.assertEquals; + +import java.time.DayOfWeek; +import java.time.ZonedDateTime; +import java.time.ZoneId; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.FormatStyle; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalField; +import java.time.temporal.WeekFields; +import java.util.Locale; +import java.util.TimeZone; + +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test JavaTime with BCP47 U extensions + */ +@Test +public class TestUnicodeExtension { + private static TimeZone defaultTZ; + + private static final Chronology JAPANESE = JapaneseChronology.INSTANCE; + private static final Chronology HIJRAH = HijrahChronology.INSTANCE; + + private static final ZoneId ASIATOKYO = ZoneId.of("Asia/Tokyo"); + private static final ZoneId AMLA = ZoneId.of("America/Los_Angeles"); + + private static final Locale JPTYO = Locale.forLanguageTag("en-u-tz-jptyo"); + private static final Locale JCAL = Locale.forLanguageTag("en-u-ca-japanese"); + private static final Locale HCAL = Locale.forLanguageTag("en-u-ca-islamic-umalqura"); + + private static final Locale FW_SUN = Locale.forLanguageTag("en-US-u-fw-sun"); + private static final Locale FW_MON = Locale.forLanguageTag("en-US-u-fw-mon"); + private static final Locale FW_TUE = Locale.forLanguageTag("en-US-u-fw-tue"); + private static final Locale FW_WED = Locale.forLanguageTag("en-US-u-fw-wed"); + private static final Locale FW_THU = Locale.forLanguageTag("en-US-u-fw-thu"); + private static final Locale FW_FRI = Locale.forLanguageTag("en-US-u-fw-fri"); + private static final Locale FW_SAT = Locale.forLanguageTag("en-US-u-fw-sat"); + + private static final Locale RG_GB = Locale.forLanguageTag("en-US-u-rg-gbzzzz"); + + private static final ZonedDateTime ZDT = ZonedDateTime.of(2017, 8, 10, 15, 15, 0, 0, AMLA); + + private static final String PATTERN = "GGGG MMMM-dd-uu HH:mm:ss zzzz"; + + @BeforeTest + public void beforeTest() { + defaultTZ = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone(AMLA)); + } + + @AfterTest + public void afterTest() { + TimeZone.setDefault(defaultTZ); + } + + @DataProvider(name="localizedBy") + Object[][] localizedBy() { + return new Object[][] { + // Locale, Chrono override, Zone override, Expected Chrono, Expected Zone, + // Expected formatted string + {Locale.JAPAN, null, null, null, null, + "2017\u5e748\u670810\u65e5\u6728\u66dc\u65e5 15\u664215\u520600\u79d2 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593" + }, + {Locale.JAPAN, JAPANESE, null, JAPANESE, null, + "\u5e73\u621029\u5e748\u670810\u65e5\u6728\u66dc\u65e5 15\u664215\u520600\u79d2 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593" + }, + {Locale.JAPAN, JAPANESE, ASIATOKYO, JAPANESE, ASIATOKYO, + "\u5e73\u621029\u5e748\u670811\u65e5\u91d1\u66dc\u65e5 7\u664215\u520600\u79d2 \u65e5\u672c\u6a19\u6e96\u6642" + }, + + {JCAL, null, null, JAPANESE, null, + "Thursday, August 10, 29 Heisei at 3:15:00 PM Pacific Daylight Time" + }, + {JCAL, HIJRAH, null, JAPANESE, null, + "Thursday, August 10, 29 Heisei at 3:15:00 PM Pacific Daylight Time" + }, + {HCAL, JAPANESE, null, HIJRAH, null, + "Thursday, Dhu\u02bbl-Qi\u02bbdah 18, 1438 AH at 3:15:00 PM Pacific Daylight Time" + }, + + + {JPTYO, null, null, null, ASIATOKYO, + "Friday, August 11, 2017 at 7:15:00 AM Japan Standard Time" + }, + {JPTYO, null, AMLA, null, ASIATOKYO, + "Friday, August 11, 2017 at 7:15:00 AM Japan Standard Time" + }, + // invalid tz + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), null, AMLA, null, AMLA, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + + {RG_GB, null, null, null, null, + "Thursday, 10 August 2017 at 15:15:00 Pacific Daylight Time" + }, + + // DecimalStyle + {Locale.forLanguageTag("en-US-u-nu-thai"), null, null, null, null, + "Thursday, August \u0e51\u0e50, \u0e52\u0e50\u0e51\u0e57 at \u0e53:\u0e51\u0e55:\u0e50\u0e50 PM Pacific Daylight Time" + }, + // DecimalStyle, "nu" vs "rg" + {Locale.forLanguageTag("en-US-u-nu-thai-rg-uszzzz"), null, null, null, null, + "Thursday, August \u0e51\u0e50, \u0e52\u0e50\u0e51\u0e57 at \u0e53:\u0e51\u0e55:\u0e50\u0e50 PM Pacific Daylight Time" + }, + // DecimalStyle, invalid + {Locale.forLanguageTag("en-US-u-nu-foo"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + }; + } + + @DataProvider(name="withLocale") + Object[][] withLocale() { + return new Object[][] { + // Locale, Chrono override, Zone override, Expected Chrono, Expected Zone, + // Expected formatted string + {Locale.JAPAN, null, null, null, null, + "2017\u5e748\u670810\u65e5\u6728\u66dc\u65e5 15\u664215\u520600\u79d2 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593" + }, + {Locale.JAPAN, JAPANESE, null, JAPANESE, null, + "\u5e73\u621029\u5e748\u670810\u65e5\u6728\u66dc\u65e5 15\u664215\u520600\u79d2 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593" + }, + {Locale.JAPAN, JAPANESE, ASIATOKYO, JAPANESE, ASIATOKYO, + "\u5e73\u621029\u5e748\u670811\u65e5\u91d1\u66dc\u65e5 7\u664215\u520600\u79d2 \u65e5\u672c\u6a19\u6e96\u6642" + }, + + {JCAL, null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + {JCAL, HIJRAH, null, HIJRAH, null, + "Thursday, Dhu\u02bbl-Qi\u02bbdah 18, 1438 AH at 3:15:00 PM Pacific Daylight Time" + }, + {HCAL, JAPANESE, null, JAPANESE, null, + "Thursday, August 10, 29 Heisei at 3:15:00 PM Pacific Daylight Time" + }, + + + {JPTYO, null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + {JPTYO, null, AMLA, null, AMLA, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + // invalid tz + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + + {RG_GB, null, null, null, null, + "Thursday, 10 August 2017 at 15:15:00 Pacific Daylight Time" + }, + + // DecimalStyle + {Locale.forLanguageTag("en-US-u-nu-thai"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + // DecimalStyle, "nu" vs "rg" + {Locale.forLanguageTag("en-US-u-nu-thai-rg-uszzzz"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + // DecimalStyle, invalid + {Locale.forLanguageTag("en-US-u-nu-foo"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + }; + } + + @DataProvider(name="firstDayOfWeek") + Object[][] firstDayOfWeek () { + return new Object[][] { + // Locale, Expected DayOfWeek, + {Locale.US, DayOfWeek.SUNDAY}, + {FW_SUN, DayOfWeek.SUNDAY}, + {FW_MON, DayOfWeek.MONDAY}, + {FW_TUE, DayOfWeek.TUESDAY}, + {FW_WED, DayOfWeek.WEDNESDAY}, + {FW_THU, DayOfWeek.THURSDAY}, + {FW_FRI, DayOfWeek.FRIDAY}, + {FW_SAT, DayOfWeek.SATURDAY}, + + // invalid case + {Locale.forLanguageTag("en-US-u-fw-xxx"), DayOfWeek.SUNDAY}, + + // region override + {RG_GB, DayOfWeek.MONDAY}, + {Locale.forLanguageTag("zh-CN-u-rg-eszzzz"), DayOfWeek.MONDAY}, + + // "fw" and "rg". + {Locale.forLanguageTag("en-US-u-fw-wed-rg-gbzzzz"), DayOfWeek.WEDNESDAY}, + {Locale.forLanguageTag("en-US-u-fw-xxx-rg-gbzzzz"), DayOfWeek.MONDAY}, + {Locale.forLanguageTag("en-US-u-fw-xxx-rg-zzzz"), DayOfWeek.SUNDAY}, + }; + } + + @DataProvider(name="minDaysInFirstWeek") + Object[][] minDaysInFrstWeek () { + return new Object[][] { + // Locale, Expected minDay, + {Locale.US, 1}, + + // region override + {RG_GB, 4}, + {Locale.forLanguageTag("zh-CN-u-rg-eszzzz"), 4}, + }; + } + + @DataProvider(name="ofPattern") + Object[][] ofPattern() { + return new Object[][] { + // Locale, Expected Chrono, Expected Zone, + // Expected formatted string + {JCAL, null, null, + "Anno Domini August-10-17 15:15:00 Pacific Daylight Time" + }, + {HCAL, null, null, + "Anno Domini August-10-17 15:15:00 Pacific Daylight Time" + }, + + {JPTYO, null, null, + "Anno Domini August-10-17 15:15:00 Pacific Daylight Time" + }, + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), null, null, + "Anno Domini August-10-17 15:15:00 Pacific Daylight Time" + }, + + {RG_GB, null, null, + "Anno Domini August-10-17 15:15:00 Pacific Daylight Time" + }, + + }; + } + + @DataProvider(name="shortTZID") + Object[][] shortTZID() { + return new Object[][] { + // LDML's short ID, Expected Zone, + {"adalv", "Europe/Andorra"}, + {"aedxb", "Asia/Dubai"}, + {"afkbl", "Asia/Kabul"}, + {"aganu", "America/Antigua"}, + {"aiaxa", "America/Anguilla"}, + {"altia", "Europe/Tirane"}, + {"amevn", "Asia/Yerevan"}, + {"ancur", "America/Curacao"}, + {"aolad", "Africa/Luanda"}, + {"aqcas", "Antarctica/Casey"}, + {"aqdav", "Antarctica/Davis"}, + {"aqddu", "Antarctica/DumontDUrville"}, + {"aqmaw", "Antarctica/Mawson"}, + {"aqmcm", "Antarctica/McMurdo"}, + {"aqplm", "Antarctica/Palmer"}, + {"aqrot", "Antarctica/Rothera"}, + {"aqsyw", "Antarctica/Syowa"}, + {"aqtrl", "Antarctica/Troll"}, + {"aqvos", "Antarctica/Vostok"}, + {"arbue", "America/Buenos_Aires"}, + {"arcor", "America/Cordoba"}, + {"arctc", "America/Catamarca"}, + {"arirj", "America/Argentina/La_Rioja"}, + {"arjuj", "America/Jujuy"}, + {"arluq", "America/Argentina/San_Luis"}, + {"armdz", "America/Mendoza"}, + {"arrgl", "America/Argentina/Rio_Gallegos"}, + {"arsla", "America/Argentina/Salta"}, + {"artuc", "America/Argentina/Tucuman"}, + {"aruaq", "America/Argentina/San_Juan"}, + {"arush", "America/Argentina/Ushuaia"}, + {"asppg", "Pacific/Pago_Pago"}, + {"atvie", "Europe/Vienna"}, + {"auadl", "Australia/Adelaide"}, + {"aubhq", "Australia/Broken_Hill"}, + {"aubne", "Australia/Brisbane"}, + {"audrw", "Australia/Darwin"}, + {"aueuc", "Australia/Eucla"}, + {"auhba", "Australia/Hobart"}, + {"aukns", "Australia/Currie"}, + {"auldc", "Australia/Lindeman"}, + {"auldh", "Australia/Lord_Howe"}, + {"aumel", "Australia/Melbourne"}, + {"aumqi", "Antarctica/Macquarie"}, + {"auper", "Australia/Perth"}, + {"ausyd", "Australia/Sydney"}, + {"awaua", "America/Aruba"}, + {"azbak", "Asia/Baku"}, + {"basjj", "Europe/Sarajevo"}, + {"bbbgi", "America/Barbados"}, + {"bddac", "Asia/Dhaka"}, + {"bebru", "Europe/Brussels"}, + {"bfoua", "Africa/Ouagadougou"}, + {"bgsof", "Europe/Sofia"}, + {"bhbah", "Asia/Bahrain"}, + {"bibjm", "Africa/Bujumbura"}, + {"bjptn", "Africa/Porto-Novo"}, + {"bmbda", "Atlantic/Bermuda"}, + {"bnbwn", "Asia/Brunei"}, + {"bolpb", "America/La_Paz"}, + {"bqkra", "America/Kralendijk"}, + {"braux", "America/Araguaina"}, + {"brbel", "America/Belem"}, + {"brbvb", "America/Boa_Vista"}, + {"brcgb", "America/Cuiaba"}, + {"brcgr", "America/Campo_Grande"}, + {"brern", "America/Eirunepe"}, + {"brfen", "America/Noronha"}, + {"brfor", "America/Fortaleza"}, + {"brmao", "America/Manaus"}, + {"brmcz", "America/Maceio"}, + {"brpvh", "America/Porto_Velho"}, + {"brrbr", "America/Rio_Branco"}, + {"brrec", "America/Recife"}, + {"brsao", "America/Sao_Paulo"}, + {"brssa", "America/Bahia"}, + {"brstm", "America/Santarem"}, + {"bsnas", "America/Nassau"}, + {"btthi", "Asia/Thimphu"}, + {"bwgbe", "Africa/Gaborone"}, + {"bymsq", "Europe/Minsk"}, + {"bzbze", "America/Belize"}, + {"cacfq", "America/Creston"}, + {"caedm", "America/Edmonton"}, + {"caffs", "America/Rainy_River"}, + {"cafne", "America/Fort_Nelson"}, + {"caglb", "America/Glace_Bay"}, + {"cagoo", "America/Goose_Bay"}, + {"cahal", "America/Halifax"}, + {"caiql", "America/Iqaluit"}, + {"camon", "America/Moncton"}, + {"capnt", "America/Pangnirtung"}, + {"careb", "America/Resolute"}, + {"careg", "America/Regina"}, + {"casjf", "America/St_Johns"}, + {"canpg", "America/Nipigon"}, + {"cathu", "America/Thunder_Bay"}, + {"cator", "America/Toronto"}, + {"cavan", "America/Vancouver"}, + {"cawnp", "America/Winnipeg"}, + {"caybx", "America/Blanc-Sablon"}, + {"caycb", "America/Cambridge_Bay"}, + {"cayda", "America/Dawson"}, + {"caydq", "America/Dawson_Creek"}, + {"cayek", "America/Rankin_Inlet"}, + {"cayev", "America/Inuvik"}, + {"cayxy", "America/Whitehorse"}, + {"cayyn", "America/Swift_Current"}, + {"cayzf", "America/Yellowknife"}, + {"cayzs", "America/Coral_Harbour"}, + {"cccck", "Indian/Cocos"}, + {"cdfbm", "Africa/Lubumbashi"}, + {"cdfih", "Africa/Kinshasa"}, + {"cfbgf", "Africa/Bangui"}, + {"cgbzv", "Africa/Brazzaville"}, + {"chzrh", "Europe/Zurich"}, + {"ciabj", "Africa/Abidjan"}, + {"ckrar", "Pacific/Rarotonga"}, + {"clipc", "Pacific/Easter"}, + {"clscl", "America/Santiago"}, + {"cmdla", "Africa/Douala"}, + {"cnsha", "Asia/Shanghai"}, + {"cnurc", "Asia/Urumqi"}, + {"cobog", "America/Bogota"}, + {"crsjo", "America/Costa_Rica"}, + {"cst6cdt", "CST6CDT"}, + {"cuhav", "America/Havana"}, + {"cvrai", "Atlantic/Cape_Verde"}, + {"cxxch", "Indian/Christmas"}, + {"cynic", "Asia/Nicosia"}, + {"czprg", "Europe/Prague"}, + {"deber", "Europe/Berlin"}, + {"debsngn", "Europe/Busingen"}, + {"djjib", "Africa/Djibouti"}, + {"dkcph", "Europe/Copenhagen"}, + {"dmdom", "America/Dominica"}, + {"dosdq", "America/Santo_Domingo"}, + {"dzalg", "Africa/Algiers"}, + {"ecgps", "Pacific/Galapagos"}, + {"ecgye", "America/Guayaquil"}, + {"eetll", "Europe/Tallinn"}, + {"egcai", "Africa/Cairo"}, + {"eheai", "Africa/El_Aaiun"}, + {"erasm", "Africa/Asmera"}, + {"esceu", "Africa/Ceuta"}, + {"eslpa", "Atlantic/Canary"}, + {"esmad", "Europe/Madrid"}, + {"est5edt", "EST5EDT"}, + {"etadd", "Africa/Addis_Ababa"}, + {"fihel", "Europe/Helsinki"}, + {"fimhq", "Europe/Mariehamn"}, + {"fjsuv", "Pacific/Fiji"}, + {"fkpsy", "Atlantic/Stanley"}, + {"fmksa", "Pacific/Kosrae"}, + {"fmpni", "Pacific/Ponape"}, + {"fmtkk", "Pacific/Truk"}, + {"fotho", "Atlantic/Faeroe"}, + {"frpar", "Europe/Paris"}, + {"galbv", "Africa/Libreville"}, + {"gaza", "Asia/Gaza"}, + {"gblon", "Europe/London"}, + {"gdgnd", "America/Grenada"}, + {"getbs", "Asia/Tbilisi"}, + {"gfcay", "America/Cayenne"}, + {"gggci", "Europe/Guernsey"}, + {"ghacc", "Africa/Accra"}, + {"gigib", "Europe/Gibraltar"}, + {"gldkshvn", "America/Danmarkshavn"}, + {"glgoh", "America/Godthab"}, + {"globy", "America/Scoresbysund"}, + {"glthu", "America/Thule"}, + {"gmbjl", "Africa/Banjul"}, + {"gncky", "Africa/Conakry"}, + {"gpbbr", "America/Guadeloupe"}, + {"gpmsb", "America/Marigot"}, + {"gpsbh", "America/St_Barthelemy"}, + {"gqssg", "Africa/Malabo"}, + {"grath", "Europe/Athens"}, + {"gsgrv", "Atlantic/South_Georgia"}, + {"gtgua", "America/Guatemala"}, + {"gugum", "Pacific/Guam"}, + {"gwoxb", "Africa/Bissau"}, + {"gygeo", "America/Guyana"}, + {"hebron", "Asia/Hebron"}, + {"hkhkg", "Asia/Hong_Kong"}, + {"hntgu", "America/Tegucigalpa"}, + {"hrzag", "Europe/Zagreb"}, + {"htpap", "America/Port-au-Prince"}, + {"hubud", "Europe/Budapest"}, + {"iddjj", "Asia/Jayapura"}, + {"idjkt", "Asia/Jakarta"}, + {"idmak", "Asia/Makassar"}, + {"idpnk", "Asia/Pontianak"}, + {"iedub", "Europe/Dublin"}, + {"imdgs", "Europe/Isle_of_Man"}, + {"inccu", "Asia/Calcutta"}, + {"iodga", "Indian/Chagos"}, + {"iqbgw", "Asia/Baghdad"}, + {"irthr", "Asia/Tehran"}, + {"isrey", "Atlantic/Reykjavik"}, + {"itrom", "Europe/Rome"}, + {"jeruslm", "Asia/Jerusalem"}, + {"jesth", "Europe/Jersey"}, + {"jmkin", "America/Jamaica"}, + {"joamm", "Asia/Amman"}, + {"jptyo", "Asia/Tokyo"}, + {"kenbo", "Africa/Nairobi"}, + {"kgfru", "Asia/Bishkek"}, + {"khpnh", "Asia/Phnom_Penh"}, + {"kicxi", "Pacific/Kiritimati"}, + {"kipho", "Pacific/Enderbury"}, + {"kitrw", "Pacific/Tarawa"}, + {"kmyva", "Indian/Comoro"}, + {"knbas", "America/St_Kitts"}, + {"kpfnj", "Asia/Pyongyang"}, + {"krsel", "Asia/Seoul"}, + {"kwkwi", "Asia/Kuwait"}, + {"kygec", "America/Cayman"}, + {"kzaau", "Asia/Aqtau"}, + {"kzakx", "Asia/Aqtobe"}, + {"kzala", "Asia/Almaty"}, + {"kzkzo", "Asia/Qyzylorda"}, + {"kzura", "Asia/Oral"}, + {"lavte", "Asia/Vientiane"}, + {"lbbey", "Asia/Beirut"}, + {"lccas", "America/St_Lucia"}, + {"livdz", "Europe/Vaduz"}, + {"lkcmb", "Asia/Colombo"}, + {"lrmlw", "Africa/Monrovia"}, + {"lsmsu", "Africa/Maseru"}, + {"ltvno", "Europe/Vilnius"}, + {"lulux", "Europe/Luxembourg"}, + {"lvrix", "Europe/Riga"}, + {"lytip", "Africa/Tripoli"}, + {"macas", "Africa/Casablanca"}, + {"mcmon", "Europe/Monaco"}, + {"mdkiv", "Europe/Chisinau"}, + {"metgd", "Europe/Podgorica"}, + {"mgtnr", "Indian/Antananarivo"}, + {"mhkwa", "Pacific/Kwajalein"}, + {"mhmaj", "Pacific/Majuro"}, + {"mkskp", "Europe/Skopje"}, + {"mlbko", "Africa/Bamako"}, + {"mmrgn", "Asia/Rangoon"}, + {"mncoq", "Asia/Choibalsan"}, + {"mnhvd", "Asia/Hovd"}, + {"mnuln", "Asia/Ulaanbaatar"}, + {"momfm", "Asia/Macau"}, + {"mpspn", "Pacific/Saipan"}, + {"mqfdf", "America/Martinique"}, + {"mrnkc", "Africa/Nouakchott"}, + {"msmni", "America/Montserrat"}, + {"mst7mdt", "MST7MDT"}, + {"mtmla", "Europe/Malta"}, + {"muplu", "Indian/Mauritius"}, + {"mvmle", "Indian/Maldives"}, + {"mwblz", "Africa/Blantyre"}, + {"mxchi", "America/Chihuahua"}, + {"mxcun", "America/Cancun"}, + {"mxhmo", "America/Hermosillo"}, + {"mxmam", "America/Matamoros"}, + {"mxmex", "America/Mexico_City"}, + {"mxmid", "America/Merida"}, + {"mxmty", "America/Monterrey"}, + {"mxmzt", "America/Mazatlan"}, + {"mxoji", "America/Ojinaga"}, + {"mxpvr", "America/Bahia_Banderas"}, + {"mxstis", "America/Santa_Isabel"}, + {"mxtij", "America/Tijuana"}, + {"mykch", "Asia/Kuching"}, + {"mykul", "Asia/Kuala_Lumpur"}, + {"mzmpm", "Africa/Maputo"}, + {"nawdh", "Africa/Windhoek"}, + {"ncnou", "Pacific/Noumea"}, + {"nenim", "Africa/Niamey"}, + {"nfnlk", "Pacific/Norfolk"}, + {"nglos", "Africa/Lagos"}, + {"nimga", "America/Managua"}, + {"nlams", "Europe/Amsterdam"}, + {"noosl", "Europe/Oslo"}, + {"npktm", "Asia/Katmandu"}, + {"nrinu", "Pacific/Nauru"}, + {"nuiue", "Pacific/Niue"}, + {"nzakl", "Pacific/Auckland"}, + {"nzcht", "Pacific/Chatham"}, + {"ommct", "Asia/Muscat"}, + {"papty", "America/Panama"}, + {"pelim", "America/Lima"}, + {"pfgmr", "Pacific/Gambier"}, + {"pfnhv", "Pacific/Marquesas"}, + {"pfppt", "Pacific/Tahiti"}, + {"pgpom", "Pacific/Port_Moresby"}, + {"pgraw", "Pacific/Bougainville"}, + {"phmnl", "Asia/Manila"}, + {"pkkhi", "Asia/Karachi"}, + {"plwaw", "Europe/Warsaw"}, + {"pmmqc", "America/Miquelon"}, + {"pnpcn", "Pacific/Pitcairn"}, + {"prsju", "America/Puerto_Rico"}, + {"pst8pdt", "PST8PDT"}, + {"ptfnc", "Atlantic/Madeira"}, + {"ptlis", "Europe/Lisbon"}, + {"ptpdl", "Atlantic/Azores"}, + {"pwror", "Pacific/Palau"}, + {"pyasu", "America/Asuncion"}, + {"qadoh", "Asia/Qatar"}, + {"rereu", "Indian/Reunion"}, + {"robuh", "Europe/Bucharest"}, + {"rsbeg", "Europe/Belgrade"}, + {"ruchita", "Asia/Chita"}, + {"rudyr", "Asia/Anadyr"}, + {"rugdx", "Asia/Magadan"}, + {"ruikt", "Asia/Irkutsk"}, + {"rukgd", "Europe/Kaliningrad"}, + {"rukhndg", "Asia/Khandyga"}, + {"rukra", "Asia/Krasnoyarsk"}, + {"rukuf", "Europe/Samara"}, + {"rumow", "Europe/Moscow"}, + {"runoz", "Asia/Novokuznetsk"}, + {"ruoms", "Asia/Omsk"}, + {"ruovb", "Asia/Novosibirsk"}, + {"rupkc", "Asia/Kamchatka"}, + {"rusred", "Asia/Srednekolymsk"}, + {"ruunera", "Asia/Ust-Nera"}, + {"ruuus", "Asia/Sakhalin"}, + {"ruvog", "Europe/Volgograd"}, + {"ruvvo", "Asia/Vladivostok"}, + {"ruyek", "Asia/Yekaterinburg"}, + {"ruyks", "Asia/Yakutsk"}, + {"rwkgl", "Africa/Kigali"}, + {"saruh", "Asia/Riyadh"}, + {"sbhir", "Pacific/Guadalcanal"}, + {"scmaw", "Indian/Mahe"}, + {"sdkrt", "Africa/Khartoum"}, + {"sesto", "Europe/Stockholm"}, + {"sgsin", "Asia/Singapore"}, + {"shshn", "Atlantic/St_Helena"}, + {"silju", "Europe/Ljubljana"}, + {"sjlyr", "Arctic/Longyearbyen"}, + {"skbts", "Europe/Bratislava"}, + {"slfna", "Africa/Freetown"}, + {"smsai", "Europe/San_Marino"}, + {"sndkr", "Africa/Dakar"}, + {"somgq", "Africa/Mogadishu"}, + {"srpbm", "America/Paramaribo"}, + {"ssjub", "Africa/Juba"}, + {"sttms", "Africa/Sao_Tome"}, + {"svsal", "America/El_Salvador"}, + {"sxphi", "America/Lower_Princes"}, + {"sydam", "Asia/Damascus"}, + {"szqmn", "Africa/Mbabane"}, + {"tcgdt", "America/Grand_Turk"}, + {"tdndj", "Africa/Ndjamena"}, + {"tfpfr", "Indian/Kerguelen"}, + {"tglfw", "Africa/Lome"}, + {"thbkk", "Asia/Bangkok"}, + {"tjdyu", "Asia/Dushanbe"}, + {"tkfko", "Pacific/Fakaofo"}, + {"tldil", "Asia/Dili"}, + {"tmasb", "Asia/Ashgabat"}, + {"tntun", "Africa/Tunis"}, + {"totbu", "Pacific/Tongatapu"}, + {"trist", "Europe/Istanbul"}, + {"ttpos", "America/Port_of_Spain"}, + {"tvfun", "Pacific/Funafuti"}, + {"twtpe", "Asia/Taipei"}, + {"tzdar", "Africa/Dar_es_Salaam"}, + {"uaiev", "Europe/Kiev"}, + {"uaozh", "Europe/Zaporozhye"}, + {"uasip", "Europe/Simferopol"}, + {"uauzh", "Europe/Uzhgorod"}, + {"ugkla", "Africa/Kampala"}, + {"umawk", "Pacific/Wake"}, + {"umjon", "Pacific/Johnston"}, + {"ummdy", "Pacific/Midway"}, +// {"unk", "Etc/Unknown"}, + {"usadk", "America/Adak"}, + {"usaeg", "America/Indiana/Marengo"}, + {"usanc", "America/Anchorage"}, + {"usboi", "America/Boise"}, + {"uschi", "America/Chicago"}, + {"usden", "America/Denver"}, + {"usdet", "America/Detroit"}, + {"ushnl", "Pacific/Honolulu"}, + {"usind", "America/Indianapolis"}, + {"usinvev", "America/Indiana/Vevay"}, + {"usjnu", "America/Juneau"}, + {"usknx", "America/Indiana/Knox"}, + {"uslax", "America/Los_Angeles"}, + {"uslui", "America/Louisville"}, + {"usmnm", "America/Menominee"}, + {"usmtm", "America/Metlakatla"}, + {"usmoc", "America/Kentucky/Monticello"}, + {"usndcnt", "America/North_Dakota/Center"}, + {"usndnsl", "America/North_Dakota/New_Salem"}, + {"usnyc", "America/New_York"}, + {"usoea", "America/Indiana/Vincennes"}, + {"usome", "America/Nome"}, + {"usphx", "America/Phoenix"}, + {"ussit", "America/Sitka"}, + {"ustel", "America/Indiana/Tell_City"}, + {"uswlz", "America/Indiana/Winamac"}, + {"uswsq", "America/Indiana/Petersburg"}, + {"usxul", "America/North_Dakota/Beulah"}, + {"usyak", "America/Yakutat"}, + {"utc", "Etc/GMT"}, + {"utce01", "Etc/GMT-1"}, + {"utce02", "Etc/GMT-2"}, + {"utce03", "Etc/GMT-3"}, + {"utce04", "Etc/GMT-4"}, + {"utce05", "Etc/GMT-5"}, + {"utce06", "Etc/GMT-6"}, + {"utce07", "Etc/GMT-7"}, + {"utce08", "Etc/GMT-8"}, + {"utce09", "Etc/GMT-9"}, + {"utce10", "Etc/GMT-10"}, + {"utce11", "Etc/GMT-11"}, + {"utce12", "Etc/GMT-12"}, + {"utce13", "Etc/GMT-13"}, + {"utce14", "Etc/GMT-14"}, + {"utcw01", "Etc/GMT+1"}, + {"utcw02", "Etc/GMT+2"}, + {"utcw03", "Etc/GMT+3"}, + {"utcw04", "Etc/GMT+4"}, + {"utcw05", "Etc/GMT+5"}, + {"utcw06", "Etc/GMT+6"}, + {"utcw07", "Etc/GMT+7"}, + {"utcw08", "Etc/GMT+8"}, + {"utcw09", "Etc/GMT+9"}, + {"utcw10", "Etc/GMT+10"}, + {"utcw11", "Etc/GMT+11"}, + {"utcw12", "Etc/GMT+12"}, + {"uymvd", "America/Montevideo"}, + {"uzskd", "Asia/Samarkand"}, + {"uztas", "Asia/Tashkent"}, + {"vavat", "Europe/Vatican"}, + {"vcsvd", "America/St_Vincent"}, + {"veccs", "America/Caracas"}, + {"vgtov", "America/Tortola"}, + {"vistt", "America/St_Thomas"}, + {"vnsgn", "Asia/Saigon"}, + {"vuvli", "Pacific/Efate"}, + {"wfmau", "Pacific/Wallis"}, + {"wsapw", "Pacific/Apia"}, + {"yeade", "Asia/Aden"}, + {"ytmam", "Indian/Mayotte"}, + {"zajnb", "Africa/Johannesburg"}, + {"zmlun", "Africa/Lusaka"}, + {"zwhre", "Africa/Harare"}, + + }; + } + + @DataProvider(name="getLocalizedDateTimePattern") + Object[][] getLocalizedDateTimePattern() { + return new Object[][] { + // Locale, Expected pattern, + {Locale.US, FormatStyle.FULL, "EEEE, MMMM d, y 'at' h:mm:ss a zzzz"}, + {Locale.US, FormatStyle.LONG, "MMMM d, y 'at' h:mm:ss a z"}, + {Locale.US, FormatStyle.MEDIUM, "MMM d, y, h:mm:ss a"}, + {Locale.US, FormatStyle.SHORT, "M/d/yy, h:mm a"}, + {RG_GB, FormatStyle.FULL, "EEEE, d MMMM y 'at' HH:mm:ss zzzz"}, + {RG_GB, FormatStyle.LONG, "d MMMM y 'at' HH:mm:ss z"}, + {RG_GB, FormatStyle.MEDIUM, "d MMM y, HH:mm:ss"}, + {RG_GB, FormatStyle.SHORT, "dd/MM/y, HH:mm"}, + }; + } + + @DataProvider(name="getDisplayName") + Object[][] getDisplayName() { + return new Object[][] { + // Locale, field, Expected name, + {Locale.US, ChronoField.AMPM_OF_DAY, "AM/PM"}, + {RG_GB, ChronoField.AMPM_OF_DAY, "am/pm"}, + }; + } + + @Test(dataProvider="localizedBy") + public void test_localizedBy(Locale locale, Chronology chrono, ZoneId zone, + Chronology chronoExpected, ZoneId zoneExpected, + String formatExpected) { + DateTimeFormatter dtf = + DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) + .withChronology(chrono).withZone(zone).localizedBy(locale); + assertEquals(dtf.getChronology(), chronoExpected); + assertEquals(dtf.getZone(), zoneExpected); + String formatted = dtf.format(ZDT); + assertEquals(formatted, formatExpected); + assertEquals(dtf.parse(formatted, ZonedDateTime::from), + zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + } + + @Test(dataProvider="withLocale") + public void test_withLocale(Locale locale, Chronology chrono, ZoneId zone, + Chronology chronoExpected, ZoneId zoneExpected, + String formatExpected) { + DateTimeFormatter dtf = + DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) + .withChronology(chrono).withZone(zone).withLocale(locale); + assertEquals(dtf.getChronology(), chronoExpected); + assertEquals(dtf.getZone(), zoneExpected); + String formatted = dtf.format(ZDT); + assertEquals(formatted, formatExpected); + assertEquals(dtf.parse(formatted, ZonedDateTime::from), + zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + } + + @Test(dataProvider="firstDayOfWeek") + public void test_firstDayOfWeek(Locale locale, DayOfWeek dowExpected) { + DayOfWeek dow = WeekFields.of(locale).getFirstDayOfWeek(); + assertEquals(dow, dowExpected); + } + + @Test(dataProvider="minDaysInFirstWeek") + public void test_minDaysInFirstWeek(Locale locale, int minDaysExpected) { + int minDays = WeekFields.of(locale).getMinimalDaysInFirstWeek(); + assertEquals(minDays, minDaysExpected); + } + + @Test(dataProvider="ofPattern") + public void test_ofPattern(Locale locale, + Chronology chronoExpected, ZoneId zoneExpected, + String formatExpected) { + DateTimeFormatter dtf = + DateTimeFormatter.ofPattern(PATTERN, locale); + assertEquals(dtf.getChronology(), chronoExpected); + assertEquals(dtf.getZone(), zoneExpected); + String formatted = dtf.format(ZDT); + assertEquals(formatted, formatExpected); + assertEquals(dtf.parse(formatted, ZonedDateTime::from), + zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + } + + @Test(dataProvider="ofPattern") + public void test_toFormatter(Locale locale, + Chronology chronoExpected, ZoneId zoneExpected, + String formatExpected) { + DateTimeFormatter dtf = + new DateTimeFormatterBuilder().appendPattern(PATTERN).toFormatter(locale); + assertEquals(dtf.getChronology(), chronoExpected); + assertEquals(dtf.getZone(), zoneExpected); + String formatted = dtf.format(ZDT); + assertEquals(formatted, formatExpected); + assertEquals(dtf.parse(formatted, ZonedDateTime::from), + zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + } + + @Test(dataProvider="shortTZID") + public void test_shortTZID(String shortID, String expectedZone) { + Locale l = Locale.forLanguageTag("en-US-u-tz-" + shortID); + DateTimeFormatter dtf = + DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) + .localizedBy(l); + assertEquals(dtf.getZone(), ZoneId.of(expectedZone)); + } + + @Test(dataProvider="getLocalizedDateTimePattern") + public void test_getLocalizedDateTimePattern(Locale l, FormatStyle s, String expectedPattern) { + DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); + assertEquals(dtfb.getLocalizedDateTimePattern(s, s, IsoChronology.INSTANCE, l), + expectedPattern); + } + + @Test(dataProvider="getDisplayName") + public void test_getDisplayName(Locale l, TemporalField f, String expectedName) { + assertEquals(f.getDisplayName(l), expectedName); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Calendar/Bug4302966.java --- a/test/jdk/java/util/Calendar/Bug4302966.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/util/Calendar/Bug4302966.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, 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,7 +23,7 @@ /* * @test - * @bug 4302966 + * @bug 4302966 8176841 * @modules jdk.localedata * @summary In Czech Republic first day of week is Monday not Sunday */ @@ -34,7 +34,7 @@ public class Bug4302966 { public static void main(String[] args) { - Calendar czechCalendar = Calendar.getInstance(new Locale("cs")); + Calendar czechCalendar = Calendar.getInstance(new Locale("cs", "CZ")); int firstDayOfWeek = czechCalendar.getFirstDayOfWeek(); if (firstDayOfWeek != Calendar.MONDAY) { throw new RuntimeException(); diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Calendar/CalendarDataTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Calendar/CalendarDataTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2017, 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 8190918 + * @summary Tests for region dependent calendar data, i.e., + * firstDayOfWeek and minimalDaysInFirstWeek. + * @modules jdk.localedata + * @run main CalendarDataTest + */ + +import java.util.Calendar; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.stream.IntStream; + +public class CalendarDataTest { + + // golden data from CLDR + private static final List> FIRSTDAYDATA = List.of( + List.of("1", "AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT " + + "GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ " + + "NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE " + + "VI WS YE ZA ZW"), + List.of("2", "001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY " + + "CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP " + + "GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ " + + "MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ " + + "VA VN XK"), + List.of("6", "BD MV"), + List.of("7", "AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY")); + + private static final List> MINDAYSDATA = List.of( + List.of("1", "001 GU UM US VI"), + List.of("4", "AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR " + + "GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO " + + "PL PT RE SE SJ SK SM VA")); + + public static void main(String... args) throws Exception { + // world + Calendar cal = Calendar.getInstance(new Locale("", "001")); + checkResult("001", + cal.getFirstDayOfWeek(), + cal.getMinimalDaysInFirstWeek()); + + // two letter country codes + IntStream.range(0x41, 0x5b) + .forEach(c1 -> { + IntStream.range(0x41, 0x5b) + .mapToObj(c2 -> String.valueOf((char)c1) + String.valueOf((char)c2)) + .forEach(region -> { + Calendar c = Calendar.getInstance(new Locale("", region)); + checkResult(region, + c.getFirstDayOfWeek(), + c.getMinimalDaysInFirstWeek()); + }); + }); + } + + private static void checkResult(String region, int firstDay, int minDays) { + // first day of week + int expected = Integer.parseInt(findEntry(region, FIRSTDAYDATA) + .orElse(findEntry("001", FIRSTDAYDATA).orElse(List.of("1"))) + .get(0)); + if (firstDay != expected) { + throw new RuntimeException("firstDayOfWeek is incorrect for the region: " + + region + ". Returned: " + firstDay + ", Expected: " + expected); + } + + // minimal days in first week + expected = Integer.parseInt(findEntry(region, MINDAYSDATA) + .orElse(findEntry("001", MINDAYSDATA).orElse(List.of("1"))) + .get(0)); + if (minDays != expected) { + throw new RuntimeException("minimalDaysInFirstWeek is incorrect for the region: " + + region + ". Returned: " + firstDay + ", Expected: " + expected); + } + } + + private static Optional> findEntry(String region, List> data) { + return data.stream() + .filter(l -> l.get(1).contains(region)) + .findAny(); + } +} + diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Comparator/BasicTest.java --- a/test/jdk/java/util/Comparator/BasicTest.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/util/Comparator/BasicTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017 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,22 +23,21 @@ /** * @test + * @bug 8171826 * @summary Comparator default method tests * @run testng BasicTest */ -import java.util.TreeMap; -import java.util.Comparator; import org.testng.annotations.Test; +import java.util.Collections; +import java.util.Comparator; import java.util.function.Function; +import java.util.function.ToDoubleFunction; import java.util.function.ToIntFunction; import java.util.function.ToLongFunction; -import java.util.function.ToDoubleFunction; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.testng.Assert.*; @Test(groups = "unit") public class BasicTest { @@ -366,4 +365,29 @@ fail("comparing(null) should throw NPE"); } catch (NullPointerException npe) {} } + + public void testNaturalAndReverseIdentity() { + var naturalOrder = Comparator.naturalOrder(); + var reverseOrder = Comparator.reverseOrder(); + + assertEquals( + naturalOrder, + Collections.reverseOrder(reverseOrder), + "Comparator.naturalOrder() and Collections.reverseOrder(Comparator.reverseOrder()) not equal"); + + assertEquals( + reverseOrder, + Collections.reverseOrder(naturalOrder), + "Comparator.reverseOrder() and Collections.reverseOrder(Comparator.naturalOrder()) not equal"); + + assertEquals( + naturalOrder.reversed(), + reverseOrder, + "Comparator.naturalOrder().reversed() amd Comparator.reverseOrder() not equal"); + + assertEquals( + reverseOrder.reversed(), + naturalOrder, + "Comparator.reverseOrder().reversed() and Comparator.naturalOrder() not equal"); + } } diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Formatter/Constructors.java --- a/test/jdk/java/util/Formatter/Constructors.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/util/Formatter/Constructors.java Wed Dec 13 10:25:38 2017 -0800 @@ -401,12 +401,23 @@ } try (PrintStream ps = new PrintStream("foo")) { - new Formatter(ps, null, Locale.UK); - fail("new Formatter(new PrintStream(\"foo\"), null, Locale.UK)"); + new Formatter(ps, (String)null, Locale.UK); + fail("new Formatter(new PrintStream(\"foo\"), (String)null, Locale.UK)"); } catch (NullPointerException x) { pass(); } catch (Exception x) { - fail("new Formatter(new PrintStream(\"foo\"), null, Locale.UK)", + fail("new Formatter(new PrintStream(\"foo\"), (String)null, Locale.UK)", + x); + } + + // Formatter(OutputStream os, Charset charset, Locale l) + try (PrintStream ps = new PrintStream("foo")) { + new Formatter(ps, (Charset)null, Locale.UK); + fail("new Formatter(new PrintStream(\"foo\"), (Charset)null, Locale.UK)"); + } catch (NullPointerException x) { + pass(); + } catch (Exception x) { + fail("new Formatter(new PrintStream(\"foo\"), (Charset)null, Locale.UK)", x); } @@ -438,12 +449,22 @@ // PrintStream(String fileName, String csn) try { - new PrintStream("foo", null); - fail("new PrintStream(\"foo\", null)"); + new PrintStream("foo", (String)null); + fail("new PrintStream(\"foo\", (String)null)"); } catch (NullPointerException x) { pass(); } catch (Exception x) { - fail("new PrintStream(\"foo\", null)", x); + fail("new PrintStream(\"foo\", (String)null)", x); + } + + // PrintStream(String fileName, Charset charset) + try { + new PrintStream("foo", (Charset)null); + fail("new PrintStream(\"foo\", (Charset)null)"); + } catch (NullPointerException x) { + pass(); + } catch (Exception x) { + fail("new PrintStream(\"foo\", (Charset)null)", x); } // PrintStream(File file) @@ -455,12 +476,22 @@ // PrintStream(File file, String csn) try { - new PrintStream(new File("foo"), null); - fail("new PrintStream(new File(\"foo\"), null)"); + new PrintStream(new File("foo"), (String)null); + fail("new PrintStream(new File(\"foo\"), (String)null)"); } catch (NullPointerException x) { pass(); } catch (Exception x) { - fail("new PrintStream(new File(\"foo\"), null)", x); + fail("new PrintStream(new File(\"foo\"), (String)null)", x); + } + + // PrintStream(File file, Charset charset) + try { + new PrintStream(new File("foo"), (Charset)null); + fail("new PrintStream(new File(\"foo\"), (Charset)null)"); + } catch (NullPointerException x) { + pass(); + } catch (Exception x) { + fail("new PrintStream(new File(\"foo\"), (Charset)null)", x); } // PrintWriter(String fileName) @@ -472,12 +503,22 @@ // PrintWriter(String fileName, String csn) try { - new PrintWriter("foo", null); - fail("new PrintWriter(\"foo\"), null"); + new PrintWriter("foo", (String)null); + fail("new PrintWriter(\"foo\"), (String)null"); } catch (NullPointerException x) { pass(); } catch (Exception x) { - fail("new PrintWriter(\"foo\"), null", x); + fail("new PrintWriter(\"foo\"), (String)null", x); + } + + // PrintWriter(String fileName, Charset charset) + try { + new PrintWriter("foo", (Charset)null); + fail("new PrintWriter(\"foo\"), (Charset)null"); + } catch (NullPointerException x) { + pass(); + } catch (Exception x) { + fail("new PrintWriter(\"foo\"), (Charset)null", x); } // PrintWriter(File file) @@ -489,12 +530,22 @@ // PrintWriter(File file, String csn) try { - new PrintWriter(new File("foo"), null); - fail("new PrintWriter(new File(\"foo\")), null"); + new PrintWriter(new File("foo"), (String)null); + fail("new PrintWriter(new File(\"foo\")), (String)null"); } catch (NullPointerException x) { pass(); } catch (Exception x) { - fail("new PrintWriter(new File(\"foo\")), null", x); + fail("new PrintWriter(new File(\"foo\")), (String)null", x); + } + + // PrintWriter(File file, Charset charset) + try { + new PrintWriter(new File("foo"), (Charset)null); + fail("new PrintWriter(new File(\"foo\")), (Charset)null"); + } catch (NullPointerException x) { + pass(); + } catch (Exception x) { + fail("new PrintWriter(new File(\"foo\")), (Charset)null", x); } if (fail != 0) diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Formatter/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Formatter/EncodingTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017, 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.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Formatter; +import java.util.Locale; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + static String USER_DIR = System.getProperty("user.dir", "."); + + // Charset added only for the 3-parameter constructors + public static enum ConstructorType { + STRING3, + FILE3, + OUTPUTSTREAM3 + } + + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + Locale l = Locale.getDefault(); + String csn1 = StandardCharsets.ISO_8859_1.name(); + Charset charset1 = StandardCharsets.ISO_8859_1; + String csn2 = StandardCharsets.UTF_8.name(); + Charset charset2 = StandardCharsets.UTF_8; + + File file1 = new File(USER_DIR, "FormatterCharsetTest1.txt"); + File file2 = new File(USER_DIR, "FormatterCharsetTest2.txt"); + + return new Object[][]{ + {ConstructorType.STRING3, file1, file2, csn1, charset1}, + {ConstructorType.FILE3, file1, file2, csn1, charset1}, + {ConstructorType.OUTPUTSTREAM3, file1, file2, csn1, charset1}, + {ConstructorType.STRING3, file1, file2, csn2, charset2}, + {ConstructorType.FILE3, file1, file2, csn2, charset2}, + {ConstructorType.OUTPUTSTREAM3, file1, file2, csn2, charset2}, + }; + } + + /** + * Verifies that the overloading constructor behaves the same as the existing + * one. + * @param type the type of the constructor + * @param file1 file1 written with the name of a charset + * @param file2 file2 written with a charset + * @param csn the charset name + * @param charset the charset + * @throws IOException + */ + @Test(dataProvider = "parameters") + public void testConstructor(ConstructorType type, File file1, File file2, + String csn, Charset charset) throws Exception { + format(getFormatter(type, file1.getPath(), csn, null)); + format(getFormatter(type, file2.getPath(), null, charset)); + Assert.assertEquals(Files.readAllLines(Paths.get(file1.getPath()), charset), + Files.readAllLines(Paths.get(file2.getPath()), charset)); + } + + void format(Formatter formatter) + throws IOException { + formatter.format("abcde \u00FA\u00FB\u00FC\u00FD"); + formatter.format("Java \uff08\u8ba1\u7b97\u673a\u7f16\u7a0b\u8bed\u8a00\uff09"); + formatter.flush(); + formatter.close(); + } + + + Formatter getFormatter(ConstructorType type, String path, String csn, Charset charset) + throws IOException { + Formatter formatter = null; + if (csn != null) { + switch (type) { + case STRING3: + formatter = new Formatter(path, csn, Locale.getDefault()); + break; + case FILE3: + formatter = new Formatter(new File(path), csn, Locale.getDefault()); + break; + case OUTPUTSTREAM3: + formatter = new Formatter(new FileOutputStream(path), csn, Locale.getDefault()); + break; + } + } else { + switch (type) { + case STRING3: + formatter = new Formatter(path, charset, Locale.getDefault()); + break; + case FILE3: + formatter = new Formatter(new File(path), charset, Locale.getDefault()); + break; + case OUTPUTSTREAM3: + formatter = new Formatter(new FileOutputStream(path), charset, Locale.getDefault()); + break; + } + } + return formatter; + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Locale/bcp47u/CalendarTests.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Locale/bcp47u/CalendarTests.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2017, 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 8176841 + * @summary Tests Calendar class deals with Unicode extensions + * correctly. + * @modules jdk.localedata + * @run testng/othervm CalendarTests + */ + +import static org.testng.Assert.assertEquals; + +import java.text.DateFormat; +import java.util.Calendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test Calendar with BCP47 U extensions + */ +@Test +public class CalendarTests { + private static TimeZone defaultTZ; + + private static final TimeZone ASIATOKYO = TimeZone.getTimeZone("Asia/Tokyo"); + private static final TimeZone AMLA = TimeZone.getTimeZone("America/Los_Angeles"); + + private static final Locale JPTYO = Locale.forLanguageTag("en-u-tz-jptyo"); + private static final Locale USLAX = Locale.forLanguageTag("en-u-tz-uslax"); + + private static final Locale FW_SUN = Locale.forLanguageTag("en-US-u-fw-sun"); + private static final Locale FW_MON = Locale.forLanguageTag("en-US-u-fw-mon"); + private static final Locale FW_TUE = Locale.forLanguageTag("en-US-u-fw-tue"); + private static final Locale FW_WED = Locale.forLanguageTag("en-US-u-fw-wed"); + private static final Locale FW_THU = Locale.forLanguageTag("en-US-u-fw-thu"); + private static final Locale FW_FRI = Locale.forLanguageTag("en-US-u-fw-fri"); + private static final Locale FW_SAT = Locale.forLanguageTag("en-US-u-fw-sat"); + + @BeforeTest + public void beforeTest() { + defaultTZ = TimeZone.getDefault(); + TimeZone.setDefault(AMLA); + } + + @AfterTest + public void afterTest() { + TimeZone.setDefault(defaultTZ); + } + + @DataProvider(name="tz") + Object[][] tz() { + return new Object[][] { + // Locale, Expected Zone, + {JPTYO, ASIATOKYO}, + {USLAX, AMLA}, + + // invalid + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), AMLA} + }; + } + + @DataProvider(name="firstDayOfWeek") + Object[][] firstDayOfWeek () { + return new Object[][] { + // Locale, Expected DayOfWeek, + {Locale.US, Calendar.SUNDAY}, + {FW_SUN, Calendar.SUNDAY}, + {FW_MON, Calendar.MONDAY}, + {FW_TUE, Calendar.TUESDAY}, + {FW_WED, Calendar.WEDNESDAY}, + {FW_THU, Calendar.THURSDAY}, + {FW_FRI, Calendar.FRIDAY}, + {FW_SAT, Calendar.SATURDAY}, + + // invalid case + {Locale.forLanguageTag("en-US-u-fw-xxx"), Calendar.SUNDAY}, + + // region override + {Locale.forLanguageTag("en-US-u-rg-gbzzzz"), Calendar.MONDAY}, + {Locale.forLanguageTag("zh-CN-u-rg-eszzzz"), Calendar.MONDAY}, + + // "fw" and "rg". + {Locale.forLanguageTag("en-US-u-fw-wed-rg-gbzzzz"), Calendar.WEDNESDAY}, + {Locale.forLanguageTag("en-US-u-fw-xxx-rg-gbzzzz"), Calendar.MONDAY}, + {Locale.forLanguageTag("en-US-u-fw-xxx-rg-zzzz"), Calendar.SUNDAY}, + }; + } + + @DataProvider(name="minDaysInFirstWeek") + Object[][] minDaysInFrstWeek () { + return new Object[][] { + // Locale, Expected minDay, + {Locale.US, 1}, + + // region override + {Locale.forLanguageTag("en-US-u-rg-gbzzzz"), 4}, + {Locale.forLanguageTag("zh-CN-u-rg-eszzzz"), 4}, + }; + } + + @Test(dataProvider="tz") + public void test_tz(Locale locale, TimeZone zoneExpected) { + DateFormat df = DateFormat.getTimeInstance(DateFormat.FULL, locale); + assertEquals(df.getTimeZone(), zoneExpected); + + Calendar c = Calendar.getInstance(locale); + assertEquals(c.getTimeZone(), zoneExpected); + + c = new Calendar.Builder().setLocale(locale).build(); + assertEquals(c.getTimeZone(), zoneExpected); + } + + @Test(dataProvider="firstDayOfWeek") + public void test_firstDayOfWeek(Locale locale, int dowExpected) { + Calendar c = Calendar.getInstance(locale); + assertEquals(c.getFirstDayOfWeek(), dowExpected); + + c = new Calendar.Builder().setLocale(locale).build(); + assertEquals(c.getFirstDayOfWeek(), dowExpected); + } + + @Test(dataProvider="minDaysInFirstWeek") + public void test_minDaysInFirstWeek(Locale locale, int minDaysExpected) { + Calendar c = Calendar.getInstance(locale); + assertEquals(c.getMinimalDaysInFirstWeek(), minDaysExpected); + + c = new Calendar.Builder().setLocale(locale).build(); + assertEquals(c.getMinimalDaysInFirstWeek(), minDaysExpected); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Locale/bcp47u/CurrencyTests.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Locale/bcp47u/CurrencyTests.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2017, 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 8176841 + * @summary Tests Currency class instantiates correctly with Unicode + * extensions + * @modules jdk.localedata + * @run testng/othervm CurrencyTests + */ + +import static org.testng.Assert.assertEquals; + +import java.util.Currency; +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test Currency with BCP47 U extensions + */ +@Test +public class CurrencyTests { + private static final Currency USD = Currency.getInstance("USD"); + private static final Currency CAD = Currency.getInstance("CAD"); + private static final Currency JPY = Currency.getInstance("JPY"); + + @DataProvider(name="getInstanceData") + Object[][] getInstanceData() { + return new Object[][] { + // Locale, Expected Currency + // "cu" + {Locale.forLanguageTag("en-US-u-cu-jpy"), JPY}, + {Locale.forLanguageTag("ja-JP-u-cu-usd"), USD}, + {Locale.forLanguageTag("en-US-u-cu-foobar"), USD}, + {Locale.forLanguageTag("en-US-u-cu-zzz"), USD}, + + // "rg" + {Locale.forLanguageTag("en-US-u-rg-jpzzzz"), JPY}, + {Locale.forLanguageTag("ja-JP-u-rg-uszzzz"), USD}, + {Locale.forLanguageTag("ja-JP-u-rg-001zzzz"), JPY}, + {Locale.forLanguageTag("en-US-u-rg-jpz"), USD}, + + // "cu" and "rg". "cu" should win + {Locale.forLanguageTag("en-CA-u-cu-jpy-rg-uszzzz"), JPY}, + + // invaid "cu" and valid "rg". "rg" should win + {Locale.forLanguageTag("en-CA-u-cu-jpyy-rg-uszzzz"), USD}, + {Locale.forLanguageTag("en-CA-u-cu-zzz-rg-uszzzz"), USD}, + + // invaid "cu" and invalid "rg". both should be ignored + {Locale.forLanguageTag("en-CA-u-cu-jpyy-rg-jpzz"), CAD}, + }; + } + + @DataProvider(name="getSymbolData") + Object[][] getSymbolData() { + return new Object[][] { + // Currency, DisplayLocale, expected Symbol + {USD, Locale.forLanguageTag("en-US-u-rg-jpzzzz"), "$"}, + {USD, Locale.forLanguageTag("en-US-u-rg-cazzzz"), "US$"}, + {USD, Locale.forLanguageTag("en-CA-u-rg-uszzzz"), "$"}, + + {CAD, Locale.forLanguageTag("en-US-u-rg-jpzzzz"), "CA$"}, + {CAD, Locale.forLanguageTag("en-US-u-rg-cazzzz"), "$"}, + {CAD, Locale.forLanguageTag("en-CA-u-rg-uszzzz"), "CA$"}, + + {JPY, Locale.forLanguageTag("ja-JP-u-rg-uszzzz"), "\uffe5"}, + {JPY, Locale.forLanguageTag("en-US-u-rg-jpzzzz"), "\u00a5"}, + {JPY, Locale.forLanguageTag("ko-KR-u-rg-jpzzzz"), "JP\u00a5"}, + }; + } + + @Test(dataProvider="getInstanceData") + public void test_getInstance(Locale locale, Currency currencyExpected) { + assertEquals(Currency.getInstance(locale), currencyExpected); + } + + @Test(dataProvider="getSymbolData") + public void test_getSymbol(Currency c, Locale locale, String expected) { + assertEquals(c.getSymbol(locale), expected); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Locale/bcp47u/DefaultLocaleTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Locale/bcp47u/DefaultLocaleTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017, 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.util.Locale; + +/* + * Test application that verifies default locales. Invoked from + * SystemPropertyTests + */ +public class DefaultLocaleTest { + public static void main(String... args) { + String defLoc = Locale.getDefault().toString(); + String defFmtLoc = Locale.getDefault(Locale.Category.FORMAT).toString(); + String defDspLoc = Locale.getDefault(Locale.Category.DISPLAY).toString(); + + if (!defLoc.equals(args[0]) || + !defFmtLoc.equals(args[1]) || + !defDspLoc.equals(args[2])) { + System.err.println("Some default locale(s) don't match.\n" + + "Default Locale expected: " + args[0] + ", result: " + defLoc + "\n" + + "Default Format Locale expected: " + args[1] + ", result: " + defFmtLoc + "\n" + + "Default Display Locale expected: " + args[2] + ", result: " + defDspLoc); + System.exit(-1); + } + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Locale/bcp47u/DisplayNameTests.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Locale/bcp47u/DisplayNameTests.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2017, 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 8176841 + * @summary Tests the display names for BCP 47 U extensions + * @modules jdk.localedata + * @run testng/othervm -Djava.locale.providers=CLDR DisplayNameTests + */ + +import static org.testng.Assert.assertEquals; + +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test Locale.getDisplayName() with BCP47 U extensions. Note that the + * result may change depending on the CLDR releases. + */ +@Test +public class DisplayNameTests { + private static final Locale loc1 = Locale.forLanguageTag("en-Latn-US-u" + + "-ca-japanese" + + "-cf-account" + + "-co-pinyin" + + "-cu-jpy" + + "-em-emoji" + + "-fw-wed" + + "-hc-h23" + + "-lb-loose" + + "-lw-breakall" + + "-ms-uksystem" + + "-nu-roman" + + "-rg-gbzzzz" + + "-sd-gbsct" + + "-ss-standard" + + "-tz-jptyo" + + "-va-posix"); + private static final Locale loc2 = new Locale("ja", "JP", "JP"); + private static final Locale loc3 = new Locale.Builder() + .setRegion("US") + .setScript("Latn") + .setUnicodeLocaleKeyword("ca", "japanese") + .build(); + private static final Locale loc4 = new Locale.Builder() + .setRegion("US") + .setUnicodeLocaleKeyword("ca", "japanese") + .build(); + private static final Locale loc5 = new Locale.Builder() + .setUnicodeLocaleKeyword("ca", "japanese") + .build(); + private static final Locale loc6 = Locale.forLanguageTag( "zh-CN-u-ca-dddd-nu-ddd-cu-ddd-fw-moq-tz-unknown-rg-twzz"); + + @DataProvider(name="locales") + Object[][] tz() { + return new Object[][] { + // Locale for display, Test Locale, Expected output, + {Locale.US, loc1, + "English (Latin, United States, Japanese Calendar, Accounting Currency Format, Pinyin Sort Order, Currency: Japanese Yen, Prefer Emoji Presentation For Emoji Characters, First Day of Week Is Wednesday, 24 Hour System (0\u201323), Loose Line Break Style, Allow Line Breaks In All Words, Imperial Measurement System, Roman Numerals, Region For Supplemental Data: United Kingdom, Region Subdivision: gbsct, Suppress Sentence Breaks After Standard Abbreviations, Time Zone: Japan Time, POSIX Compliant Locale)"}, + {Locale.JAPAN, loc1, + "\u82f1\u8a9e (\u30e9\u30c6\u30f3\u6587\u5b57\u3001\u30a2\u30e1\u30ea\u30ab\u5408\u8846\u56fd\u3001\u548c\u66a6\u3001cf: account\u3001\u30d4\u30f3\u30a4\u30f3\u9806\u3001\u901a\u8ca8: \u65e5\u672c\u5186\u3001em: emoji\u3001fw: wed\u300124\u6642\u9593\u5236(0\u301c23)\u3001\u7981\u5247\u51e6\u7406(\u5f31)\u3001lw: breakall\u3001\u30e4\u30fc\u30c9\u30fb\u30dd\u30f3\u30c9\u6cd5\u3001\u30ed\u30fc\u30de\u6570\u5b57\u3001rg: \u30a4\u30ae\u30ea\u30b9\u3001sd: gbsct\u3001ss: standard\u3001\u30bf\u30a4\u30e0\u30be\u30fc\u30f3: \u65e5\u672c\u6642\u9593\u3001\u30ed\u30b1\u30fc\u30eb\u306e\u30d0\u30ea\u30a2\u30f3\u30c8: posix)"}, + {Locale.forLanguageTag("hi-IN"), loc1, + "\u0905\u0902\u0917\u094d\u0930\u0947\u091c\u093c\u0940 (\u0932\u0948\u091f\u093f\u0928, \u0938\u0902\u092f\u0941\u0915\u094d\u0924 \u0930\u093e\u091c\u094d\u092f, \u091c\u093e\u092a\u093e\u0928\u0940 \u092a\u0902\u091a\u093e\u0902\u0917, cf: account, \u092a\u093f\u0928\u092f\u0940\u0928 \u0935\u0930\u094d\u0917\u0940\u0915\u0930\u0923, \u092e\u0941\u0926\u094d\u0930\u093e: \u091c\u093e\u092a\u093e\u0928\u0940 \u092f\u0947\u0928, em: emoji, fw: wed, 24 \u0918\u0902\u091f\u094b\u0902 \u0915\u0940 \u092a\u094d\u0930\u0923\u093e\u0932\u0940 (0\u201323), \u0922\u0940\u0932\u0940 \u092a\u0902\u0915\u094d\u0924\u093f \u0935\u093f\u091a\u094d\u091b\u0947\u0926 \u0936\u0948\u0932\u0940, lw: breakall, \u0907\u092e\u094d\u092a\u0940\u0930\u093f\u092f\u0932 \u092e\u093e\u092a\u0928 \u092a\u094d\u0930\u0923\u093e\u0932\u0940, \u0930\u094b\u092e\u0928 \u0938\u0902\u0916\u094d\u092f\u093e\u090f\u0901, rg: \u092f\u0942\u0928\u093e\u0907\u091f\u0947\u0921 \u0915\u093f\u0902\u0917\u0921\u092e, sd: gbsct, ss: standard, \u0938\u092e\u092f \u0915\u094d\u0937\u0947\u0924\u094d\u0930: \u091c\u093e\u092a\u093e\u0928 \u0938\u092e\u092f, \u0938\u094d\u0925\u093e\u0928\u0940\u092f \u092a\u094d\u0930\u0915\u093e\u0930: posix)"}, + + // cases where no localized types are available. fall back to "key: type" + {Locale.US, Locale.forLanguageTag("en-u-ca-unknown"), "English (Calendar: unknown)"}, + + // cases with variant, w/o language, script + {Locale.US, loc2, "Japanese (Japan, JP, Japanese Calendar)"}, + {Locale.US, loc3, "Latin (United States, Japanese Calendar)"}, + {Locale.US, loc4, "United States (Japanese Calendar)"}, + {Locale.US, loc5, ""}, + + // invalid cases + {loc6, loc6, "\u4e2d\u6587 (\u4e2d\u56fd\u3001\u65e5\u5386\uff1adddd\u3001\u8d27\u5e01\uff1addd\u3001fw\uff1amoq\u3001\u6570\u5b57\uff1addd\u3001rg\uff1atwzz\u3001\u65f6\u533a\uff1aunknown)"}, + {Locale.US, loc6, "Chinese (China, Calendar: dddd, Currency: ddd, First day of week: moq, Numbers: ddd, Region For Supplemental Data: twzz, Time Zone: unknown)"}, + }; + } + + @Test(dataProvider="locales") + public void test_locales(Locale inLocale, Locale testLocale, String expected) { + String result = testLocale.getDisplayName(inLocale); + assertEquals(result, expected); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Locale/bcp47u/FormatTests.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Locale/bcp47u/FormatTests.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2017, 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 8176841 + * @summary Tests *Format class deals with Unicode extensions + * correctly. + * @modules jdk.localedata + * @run testng/othervm -Djava.locale.providers=CLDR FormatTests + */ + +import static org.testng.Assert.assertEquals; + +import java.text.DateFormat; +import java.text.NumberFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test *Format classes with BCP47 U extensions + */ +@Test +public class FormatTests { + private static TimeZone defaultTZ; + + private static final TimeZone ASIATOKYO = TimeZone.getTimeZone("Asia/Tokyo"); + private static final TimeZone AMLA = TimeZone.getTimeZone("America/Los_Angeles"); + + private static final Locale JPTYO = Locale.forLanguageTag("en-u-tz-jptyo"); + private static final Locale JCAL = Locale.forLanguageTag("en-u-ca-japanese"); + private static final Locale USLAX = Locale.forLanguageTag("en-u-tz-uslax"); + + private static final Locale RG_GB = Locale.forLanguageTag("en-US-u-rg-gbzzzz"); + private static final Locale RG_DE = Locale.forLanguageTag("en-US-u-rg-dezzzz"); + + private static final Locale NU_DEVA = Locale.forLanguageTag("en-US-u-nu-deva"); + private static final Locale NU_SINH = Locale.forLanguageTag("en-US-u-nu-sinh"); + private static final Locale NU_ZZZZ = Locale.forLanguageTag("en-US-u-nu-zzzz"); + + private static final double testNum = 12345.6789; + private static final String NUM_US = "12,345.6789"; + private static final String NUM_DE = "12.345,6789"; + private static final String NUM_DEVA = "\u0967\u0968,\u0969\u096a\u096b.\u096c\u096d\u096e\u096f"; + private static final String NUM_SINH = "\u0de7\u0de8,\u0de9\u0dea\u0deb.\u0dec\u0ded\u0dee\u0def"; + + private static final Date testDate = new Calendar.Builder() + .setDate(2017, 7, 10) + .setTimeOfDay(15, 15, 0) + .setTimeZone(AMLA) + .build() + .getTime(); + + @BeforeTest + public void beforeTest() { + defaultTZ = TimeZone.getDefault(); + TimeZone.setDefault(AMLA); + } + + @AfterTest + public void afterTest() { + TimeZone.setDefault(defaultTZ); + } + + @DataProvider(name="dateFormatData") + Object[][] dateFormatData() { + return new Object[][] { + // Locale, Expected calendar, Expected timezone, Expected formatted string + + // -ca + {JCAL, "java.util.JapaneseImperialCalendar", null, + "Thursday, August 10, 29 Heisei at 3:15:00 PM Pacific Daylight Time" + }, + + // -tz + {JPTYO, null, ASIATOKYO, + "Friday, August 11, 2017 at 7:15:00 AM Japan Standard Time" + }, + {USLAX, null, AMLA, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + + // -rg + {RG_GB, null, null, + "Thursday, 10 August 2017 at 15:15:00 Pacific Daylight Time" + }, + }; + } + + @DataProvider(name="numberFormatData") + Object[][] numberFormatData() { + return new Object[][] { + // Locale, number, expected format + + // -nu + {NU_DEVA, testNum, NUM_DEVA}, + {NU_SINH, testNum, NUM_SINH}, + {NU_ZZZZ, testNum, NUM_US}, + + // -rg + {RG_DE, testNum, NUM_DE}, + + // -nu & -rg, valid & invalid + {Locale.forLanguageTag("en-US-u-nu-deva-rg-dezzzz"), testNum, NUM_DEVA}, + {Locale.forLanguageTag("en-US-u-nu-zzzz-rg-dezzzz"), testNum, NUM_US}, + {Locale.forLanguageTag("en-US-u-nu-zzzz-rg-zzzz"), testNum, NUM_US}, + }; + } + + @Test(dataProvider="dateFormatData") + public void test_DateFormat(Locale locale, String calClass, TimeZone tz, + String formatExpected) throws Exception { + DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locale); + if (calClass != null) { + try { + Class expected = Class.forName(calClass); + assertEquals(df.getCalendar().getClass(), expected); + } catch (Exception e) { + throw e; + } + } + if (tz != null) { + assertEquals(df.getTimeZone(), tz); + } + String formatted = df.format(testDate); + assertEquals(formatted, formatExpected); + assertEquals(df.parse(formatted), testDate); + } + + @Test(dataProvider="numberFormatData") + public void test_NumberFormat(Locale locale, double num, + String formatExpected) throws Exception { + NumberFormat nf = NumberFormat.getNumberInstance(locale); + nf.setMaximumFractionDigits(4); + String formatted = nf.format(num); + assertEquals(nf.format(num), formatExpected); + assertEquals(nf.parse(formatted), num); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Locale/bcp47u/SymbolsTests.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Locale/bcp47u/SymbolsTests.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2017, 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 8176841 + * @summary Tests *FormatSymbols class deals with Unicode extensions + * correctly. + * @modules jdk.localedata + * @run testng/othervm -Djava.locale.providers=CLDR FormatTests + */ + +import static org.testng.Assert.assertEquals; + +import java.text.DateFormatSymbols; +import java.text.DecimalFormatSymbols; +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test *FormatSymbols classes with BCP47 U extensions + */ +@Test +public class SymbolsTests { + + private static final Locale RG_GB = Locale.forLanguageTag("en-US-u-rg-gbzzzz"); + private static final Locale RG_IE = Locale.forLanguageTag("en-US-u-rg-iezzzz"); + private static final Locale RG_AT = Locale.forLanguageTag("en-US-u-rg-atzzzz"); + + @DataProvider(name="dateFormatSymbolsData") + Object[][] dateFormatSymbolsData() { + return new Object[][] { + // Locale, expected AM string, expected PM string + + {RG_GB, "am", "pm"}, + {RG_IE, "a.m.", "p.m."}, + {Locale.US, "AM", "PM"}, + }; + } + + @DataProvider(name="decimalFormatSymbolsData") + Object[][] decimalFormatSymbolsData() { + return new Object[][] { + // Locale, expected decimal separator, expected grouping separator + + {RG_AT, ",", "."}, + {Locale.US, ".", ","}, + + // -nu & -rg mixed. -nu should win + {Locale.forLanguageTag("ar-EG-u-nu-latn-rg-mazzzz"), ".", ","}, + }; + } + + @Test(dataProvider="dateFormatSymbolsData") + public void test_DateFormatSymbols(Locale locale, String amExpected, String pmExpected) { + DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale); + String[] ampm = dfs.getAmPmStrings(); + assertEquals(ampm[0], amExpected); + assertEquals(ampm[1], pmExpected); + } + + @Test(dataProvider="decimalFormatSymbolsData") + public void test_DecimalFormatSymbols(Locale locale, char decimal, char grouping) { + DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale); + assertEquals(dfs.getDecimalSeparator(), decimal); + assertEquals(dfs.getGroupingSeparator(), grouping); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @library /lib/testlibrary + * @bug 8189134 + * @summary Tests the system properties + * @modules jdk.localedata + * @build DefaultLocaleTest jdk.testlibrary.* + * @run testng/othervm SystemPropertyTests + */ + +import static jdk.testlibrary.ProcessTools.executeTestJava; +import static org.testng.Assert.assertTrue; + +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test Locale.getDefault() reflects the system property. Note that the + * result may change depending on the CLDR releases. + */ +@Test +public class SystemPropertyTests { + + private static String LANGPROP = "-Duser.language=en"; + private static String CTRYPROP = "-Duser.country=US"; + + @DataProvider(name="data") + Object[][] data() { + return new Object[][] { + // system property, expected default, expected format, expected display + {"-Duser.extensions=u-ca-japanese", + "en_US_#u-ca-japanese", + "en_US_#u-ca-japanese", + "en_US_#u-ca-japanese", + }, + + {"-Duser.extensions=u-ca-japanese-nu-thai", + "en_US_#u-ca-japanese-nu-thai", + "en_US_#u-ca-japanese-nu-thai", + "en_US_#u-ca-japanese-nu-thai", + }, + + {"-Duser.extensions=foo", + "en_US", + "en_US", + "en_US", + }, + + {"-Duser.extensions.format=u-ca-japanese", + "en_US", + "en_US_#u-ca-japanese", + "en_US", + }, + + {"-Duser.extensions.display=u-ca-japanese", + "en_US", + "en_US", + "en_US_#u-ca-japanese", + }, + }; + } + + @Test(dataProvider="data") + public void runTest(String extprop, String defLoc, + String defFmtLoc, String defDspLoc) throws Exception { + int exitValue = executeTestJava(LANGPROP, CTRYPROP, + extprop, "DefaultLocaleTest", defLoc, defFmtLoc, defDspLoc) + .outputTo(System.out) + .errorTo(System.out) + .getExitValue(); + + assertTrue(exitValue == 0); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Locale/bcp47u/spi/LocaleNameProviderTests.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Locale/bcp47u/spi/LocaleNameProviderTests.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017, 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 8176841 + * @summary Tests LocaleNameProvider SPIs + * @library provider + * @build provider/module-info provider/foo.LocaleNameProviderImpl + * @run main/othervm -Djava.locale.providers=SPI LocaleNameProviderTests + */ + +import java.util.Locale; + +/** + * Test LocaleNameProvider SPI with BCP47 U extensions + * + * Verifies getUnicodeExtensionKey() and getUnicodeExtensionType() methods in + * LocaleNameProvider works. + */ +public class LocaleNameProviderTests { + private static final String expected = "foo (foo_ca:foo_japanese)"; + + public static void main(String... args) { + String name = Locale.forLanguageTag("foo-u-ca-japanese").getDisplayName(new Locale("foo")); + if (!name.equals(expected)) { + throw new RuntimeException("Unicode extension key and/or type name(s) is incorrect. " + + "Expected: \"" + expected + "\", got: \"" + name + "\""); + } + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Locale/bcp47u/spi/provider/foo/LocaleNameProviderImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Locale/bcp47u/spi/provider/foo/LocaleNameProviderImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2017, 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 foo; + +import java.util.Locale; +import java.util.spi.LocaleNameProvider; + +/* + * Implements LocaleNameProvider SPI, augmenting the default + * values for Unicode Locale Extension key/type names. + */ +public class LocaleNameProviderImpl extends LocaleNameProvider { + private static final Locale[] avail = {new Locale("foo")}; + + @Override + public Locale[] getAvailableLocales() { + return avail; + } + + @Override + public String getDisplayLanguage(String lang, Locale target) { + return null; + } + + @Override + public String getDisplayCountry(String ctry, Locale target) { + return null; + } + + @Override + public String getDisplayVariant(String vrnt, Locale target) { + return null; + } + + @Override + public String getDisplayUnicodeExtensionKey(String key, Locale target) { + return "foo_" + key; + } + + @Override + public String getDisplayUnicodeExtensionType(String extType, String key, Locale target) { + return "foo_" + key + ":foo_" + extType; + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Locale/bcp47u/spi/provider/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Locale/bcp47u/spi/provider/module-info.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2017, 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. + */ + +module provider { + exports foo; + provides java.util.spi.LocaleNameProvider with foo.LocaleNameProviderImpl; +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Properties/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Properties/EncodingTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2017, 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.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.Properties; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the + * same as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + return new Object[][]{ + {StandardCharsets.UTF_8.name(), null}, + {null, StandardCharsets.UTF_8},}; + } + + /** + * Tests that properties saved with Properties#storeToXML with either an + * encoding name or a charset can be read with Properties#loadFromXML that + * returns the same Properties object. + */ + @Test(dataProvider = "parameters") + void testLoadAndStore(String encoding, Charset charset) throws IOException { + Properties props = new Properties(); + props.put("k0", "\u6C34"); + props.put("k1", "foo"); + props.put("k2", "bar"); + props.put("k3", "\u0020\u0391\u0392\u0393\u0394\u0395\u0396\u0397"); + props.put("k4", "\u7532\u9aa8\u6587"); + props.put("k5", "/conf/jaxp.properties"); + props.put("k6", "\ud800\u00fa"); + + Properties p; + try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { + if (encoding != null) { + props.storeToXML(out, null, encoding); + } else { + props.storeToXML(out, null, charset); + } p = new Properties(); + try (ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray())) { + p.loadFromXML(in); + } + } + + Assert.assertEquals(props, p); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Scanner/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Scanner/EncodingTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2017, 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.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Paths; +import java.util.Scanner; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the + * same as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + static String USER_DIR = System.getProperty("user.dir", "."); + + public static enum ConstructorType { + FILE, + PATH, + INPUTSTREAM, + READABLEBYTECHANNEL + } + + static final String TEST_STRING = "abc \u0100 \u0101 \u0555 \u07FD \u07FF"; + + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + String csn = StandardCharsets.UTF_8.name(); + Charset charset = StandardCharsets.UTF_8; + File file1 = new File(USER_DIR, "ScannerCharsetTest1.txt"); + File file2 = new File(USER_DIR, "ScannerCharsetTest2.txt"); + + return new Object[][]{ + {ConstructorType.FILE, file1, file2, csn, charset}, + {ConstructorType.PATH, file1, file2, csn, charset}, + {ConstructorType.INPUTSTREAM, file1, file2, csn, charset}, + {ConstructorType.READABLEBYTECHANNEL, file1, file2, csn, charset},}; + } + + /** + * Verifies that the overloading constructor behaves the same as the + * existing one. + * + * @param type the type of the constructor + * @param file1 file1 written with the name of a charset + * @param file2 file2 written with a charset + * @param csn the charset name + * @param charset the charset + * @throws IOException + */ + @Test(dataProvider = "parameters") + void test(ConstructorType type, File file1, File file2, String csn, Charset charset) + throws Exception { + prepareFile(file1, TEST_STRING); + prepareFile(file2, TEST_STRING); + + try (Scanner s1 = getScanner(type, file1.getPath(), csn, null); + Scanner s2 = getScanner(type, file2.getPath(), null, charset);) { + String result1 = s1.findInLine(TEST_STRING); + String result2 = s2.findInLine(TEST_STRING); + Assert.assertEquals(result1, result2); + } + } + + /* + * Creates a Scanner over the given input file. + */ + Scanner getScanner(ConstructorType type, String file, String csn, Charset charset) + throws Exception { + if (csn != null) { + switch (type) { + case FILE: + return new Scanner(new File(file), csn); + case PATH: + return new Scanner(Paths.get(file), csn); + case INPUTSTREAM: + FileInputStream fis = new FileInputStream(file); + return new Scanner(fis, csn); + case READABLEBYTECHANNEL: + FileInputStream fis1 = new FileInputStream(file); + return new Scanner(fis1.getChannel(), csn); + } + } else { + switch (type) { + case FILE: + return new Scanner(new File(file), charset); + case PATH: + return new Scanner(Paths.get(file), charset); + case INPUTSTREAM: + FileInputStream fis = new FileInputStream(file); + return new Scanner(fis, charset); + case READABLEBYTECHANNEL: + FileInputStream fis1 = new FileInputStream(file); + return new Scanner(fis1.getChannel(), charset); + } + } + + return null; + } + + void prepareFile(File file, String content) throws IOException { + try (FileWriter writer = new FileWriter(file);) { + writer.write(content); + } + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Scanner/FailingConstructors.java --- a/test/jdk/java/util/Scanner/FailingConstructors.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/util/Scanner/FailingConstructors.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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,7 +23,7 @@ /** * @test - * @bug 7000511 + * @bug 7000511 8190577 * @summary PrintStream, PrintWriter, Formatter, Scanner leave files open when * exception thrown */ @@ -33,6 +33,7 @@ import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.charset.Charset; import java.nio.file.Files; import java.util.Scanner; @@ -65,7 +66,14 @@ check(exists, file); try { - new Scanner(file, null); + new Scanner(file, (String)null); + fail(); + } catch(FileNotFoundException|NullPointerException e) { + pass(); + } + + try { + new Scanner(file, (Charset)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); @@ -84,7 +92,14 @@ check(exists, file); try { - new Scanner(file.toPath(), null); + new Scanner(file.toPath(), (String)null); + fail(); + } catch(FileNotFoundException|NullPointerException e) { + pass(); + } + + try { + new Scanner(file.toPath(), (Charset)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Scanner/spi/UseLocaleWithProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Scanner/spi/UseLocaleWithProvider.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017, 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 8190278 + * @summary checks the Scanner.useLocale() with java.locale.providers=SPI, + * COMPAT. It should not throw ClassCastException if any SPI is + * used and NumberFormat.getInstance() does not return a + * DecimalFormat object. Also, to test the behaviour of Scanner + * while scanning numbers in the format of Scanner's locale. + * @modules jdk.localedata + * @library provider + * @build provider/module-info provider/test.NumberFormatProviderImpl + * provider/test.NumberFormatImpl + * @run main/othervm -Djava.locale.providers=SPI,COMPAT UseLocaleWithProvider + */ + +import java.util.Locale; +import java.util.Scanner; + +public class UseLocaleWithProvider { + + public static void main(String[] args) { + + try { + testScannerUseLocale("-123.4", Locale.US, -123.4); + testScannerUseLocale("-123,45", new Locale("fi", "FI"), -123.45); + testScannerUseLocale("334,65", Locale.FRENCH, 334.65); + testScannerUseLocale("4.334,65", Locale.GERMAN, 4334.65); + } catch (ClassCastException ex) { + throw new RuntimeException("[FAILED: With" + + " java.locale.providers=SPI,COMPAT, Scanner.useLocale()" + + " shouldn't throw ClassCastException]"); + } + } + + private static void testScannerUseLocale(String number, Locale locale, + Number actual) { + Scanner sc = new Scanner(number).useLocale(locale); + if (!sc.hasNextFloat() || sc.nextFloat() != actual.floatValue()) { + throw new RuntimeException("[FAILED: With" + + " java.locale.providers=SPI,COMPAT, Scanner" + + ".hasNextFloat() or Scanner.nextFloat() is unable to" + + " scan the given number: " + number + ", in the given" + + " locale:" + locale + "]"); + } + } +} + diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Scanner/spi/provider/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Scanner/spi/provider/module-info.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017, 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. +*/ +module provider { + exports test; + provides java.text.spi.NumberFormatProvider with test.NumberFormatProviderImpl; +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Scanner/spi/provider/test/NumberFormatImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Scanner/spi/provider/test/NumberFormatImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017, 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 test; + +import java.text.FieldPosition; +import java.text.NumberFormat; +import java.text.ParsePosition; + +public class NumberFormatImpl extends NumberFormat { + + @Override + public StringBuffer format(double number, StringBuffer toAppendTo, + FieldPosition pos) { + return null; + } + + @Override + public StringBuffer format(long number, StringBuffer toAppendTo, + FieldPosition pos) { + return null; + } + + @Override + public Number parse(String source, ParsePosition parsePosition) { + return null; + } +} + diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/Scanner/spi/provider/test/NumberFormatProviderImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/Scanner/spi/provider/test/NumberFormatProviderImpl.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 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 test; + +import java.text.NumberFormat; +import java.text.spi.NumberFormatProvider; +import java.util.Locale; + +public class NumberFormatProviderImpl extends NumberFormatProvider { + + private static final Locale[] locales = {Locale.US, Locale.FRENCH, + Locale.GERMAN, new Locale("fi", "FI")}; + + @Override + public NumberFormat getCurrencyInstance(Locale locale) { + return null; + } + + @Override + public NumberFormat getIntegerInstance(Locale locale) { + return null; + } + + @Override + public NumberFormat getNumberInstance(Locale locale) { + return new NumberFormatImpl(); + } + + @Override + public NumberFormat getPercentInstance(Locale locale) { + return null; + } + + @Override + public Locale[] getAvailableLocales() { + return locales; + } +} + diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/TimeZone/SimpleTimeZoneCloneRaceTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/TimeZone/SimpleTimeZoneCloneRaceTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2017, 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.util.Calendar; +import java.util.Locale; +import java.util.SimpleTimeZone; +import java.util.TimeZone; +import java.util.function.Supplier; + +/* + * @test + * @bug 8191216 + * @summary test that provokes race between cloning and lazily initializing + * SimpleTimeZone cache fields + */ +public class SimpleTimeZoneCloneRaceTest { + + public static void main(String[] args) throws InterruptedException { + + // shared TZ user repeatedly samples sharedTZ and calculates offset + // using the shared instance + TimeZoneUser sharedTZuser = new TimeZoneUser(() -> sharedTZ); + + // cloned TZ user repeatedly samples sharedTZ then clones it and + // calculates offset using the clone... + TimeZoneUser clonedTZuser = new TimeZoneUser(() -> { + // sample shared TZ + TimeZone tz = sharedTZ; + // do some computation that takes roughly the same time as it takes + // sharedTZUser to start changing cache fields in shared TZ + cpuHogTZ.getOffset(time); + // now clone the sampled TZ and return it, hoping the clone is done + // at about the right time.... + return (TimeZone) tz.clone(); + }); + + // start threads + Thread t1 = new Thread(sharedTZuser); + Thread t2 = new Thread(clonedTZuser); + t1.start(); + t2.start(); + + // plant new SimpleTimeZone instances for 2 seconds + long t0 = System.currentTimeMillis(); + do { + TimeZone tz1 = createSTZ(); + TimeZone tz2 = createSTZ(); + cpuHogTZ = tz1; + sharedTZ = tz2; + } while (System.currentTimeMillis() - t0 < 2000L); + + sharedTZuser.stop = true; + clonedTZuser.stop = true; + t1.join(); + t2.join(); + + System.out.println( + String.format("shared TZ: %d correct, %d incorrect calculations", + sharedTZuser.correctCount, sharedTZuser.incorrectCount) + ); + System.out.println( + String.format("cloned TZ: %d correct, %d incorrect calculations", + clonedTZuser.correctCount, clonedTZuser.incorrectCount) + ); + if (clonedTZuser.incorrectCount > 0) { + throw new RuntimeException(clonedTZuser.incorrectCount + + " fatal data races detected"); + } + } + + static SimpleTimeZone createSTZ() { + return new SimpleTimeZone(-28800000, + "America/Los_Angeles", + Calendar.APRIL, 1, -Calendar.SUNDAY, + 7200000, + Calendar.OCTOBER, -1, Calendar.SUNDAY, + 7200000, + 3600000); + } + + static volatile TimeZone cpuHogTZ = createSTZ(); + static volatile TimeZone sharedTZ = createSTZ(); + static final long time; + static final long correctOffset; + + static { + TimeZone tz = createSTZ(); + Calendar cal = Calendar.getInstance(tz, Locale.ROOT); + cal.set(2000, Calendar.MAY, 1, 0, 0, 0); + time = cal.getTimeInMillis(); + correctOffset = tz.getOffset(time); + } + + static class TimeZoneUser implements Runnable { + private final Supplier tzSupplier; + + TimeZoneUser(Supplier tzSupplier) { + this.tzSupplier = tzSupplier; + } + + volatile boolean stop; + int correctCount, incorrectCount; + + @Override + public void run() { + while (!stop) { + TimeZone tz = tzSupplier.get(); + int offset = tz.getOffset(time); + if (offset == correctOffset) { + correctCount++; + } else { + incorrectCount++; + } + } + } + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java --- a/test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java Wed Dec 13 10:25:38 2017 -0800 @@ -31,6 +31,7 @@ import java.util.Random; import java.util.zip.*; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class FinalizeZipFile { @@ -78,10 +79,9 @@ public static void realMain(String[] args) throws Throwable { makeGarbage(); - - System.gc(); - finalizersDone.await(); - + while (!finalizersDone.await(10, TimeUnit.MILLISECONDS)) { + System.gc(); + } // Not all ZipFiles were collected? equal(finalizersDone.getCount(), 0L); } diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/java/util/zip/ZipFile/TestCleaner.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/util/zip/ZipFile/TestCleaner.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2017, 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 8185582 + * @modules java.base/java.util.zip:open + * @summary Check the resources of Inflater, Deflater and ZipFile are always + * cleaned/released when the instance is not unreachable + */ + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.zip.*; +import static java.nio.charset.StandardCharsets.US_ASCII; + +public class TestCleaner { + + public static void main(String[] args) throws Throwable { + testDeInflater(); + testZipFile(); + } + + private static long addrOf(Object obj) { + try { + Field addr = obj.getClass().getDeclaredField("address"); + if (!addr.trySetAccessible()) { + return -1; + } + return addr.getLong(obj); + } catch (Exception x) { + return -1; + } + } + + private static class SubclassedInflater extends Inflater { + CountDownLatch endCountDown; + + SubclassedInflater(CountDownLatch endCountDown) { + this.endCountDown = endCountDown; + } + + @Override + public void end() { + super.end(); + endCountDown.countDown(); + } + } + + private static class SubclassedDeflater extends Deflater { + CountDownLatch endCountDown; + + SubclassedDeflater(CountDownLatch endCountDown) { + this.endCountDown = endCountDown; + } + + @Override + public void end() { + super.end(); + endCountDown.countDown(); + } + } + + // verify the "native resource" of In/Deflater has been cleaned + private static void testDeInflater() throws Throwable { + Field zsRefDef = Deflater.class.getDeclaredField("zsRef"); + Field zsRefInf = Inflater.class.getDeclaredField("zsRef"); + if (!zsRefDef.trySetAccessible() || !zsRefInf.trySetAccessible()) { + throw new RuntimeException("'zsRef' is not accesible"); + } + if (addrOf(zsRefDef.get(new Deflater())) == -1 || + addrOf(zsRefInf.get(new Inflater())) == -1) { + throw new RuntimeException("'addr' is not accesible"); + } + List list = new ArrayList<>(); + byte[] buf1 = new byte[1024]; + byte[] buf2 = new byte[1024]; + for (int i = 0; i < 10; i++) { + var def = new Deflater(); + list.add(zsRefDef.get(def)); + def.setInput("hello".getBytes()); + def.finish(); + int n = def.deflate(buf1); + + var inf = new Inflater(); + list.add(zsRefInf.get(inf)); + inf.setInput(buf1, 0, n); + n = inf.inflate(buf2); + if (!"hello".equals(new String(buf2, 0, n))) { + throw new RuntimeException("compression/decompression failed"); + } + } + + int n = 10; + long cnt = list.size(); + while (n-- > 0 && cnt != 0) { + Thread.sleep(100); + System.gc(); + cnt = list.stream().filter(o -> addrOf(o) != 0).count(); + } + if (cnt != 0) + throw new RuntimeException("cleaner failed to clean : " + cnt); + + // test subclassed Deflater/Inflater, for behavioral compatibility. + // should be removed if the finalize() method is finally removed. + var endCountDown = new CountDownLatch(20); + for (int i = 0; i < 10; i++) { + var def = new SubclassedDeflater(endCountDown); + def.setInput("hello".getBytes()); + def.finish(); + n = def.deflate(buf1); + + var inf = new SubclassedInflater(endCountDown); + inf.setInput(buf1, 0, n); + n = inf.inflate(buf2); + if (!"hello".equals(new String(buf2, 0, n))) { + throw new RuntimeException("compression/decompression failed"); + } + } + while (!endCountDown.await(10, TimeUnit.MILLISECONDS)) { + System.gc(); + } + if (endCountDown.getCount() != 0) + throw new RuntimeException("finalizer failed to clean : " + + endCountDown.getCount()); + } + + private static class SubclassedZipFile extends ZipFile { + CountDownLatch closeCountDown; + + SubclassedZipFile(File f, CountDownLatch closeCountDown) + throws IOException { + super(f); + this.closeCountDown = closeCountDown; + } + + @Override + public void close() throws IOException { + closeCountDown.countDown(); + super.close(); + } + } + + private static void testZipFile() throws Throwable { + File dir = new File(System.getProperty("test.dir", ".")); + File zip = File.createTempFile("testzf", "zip", dir); + Object zsrc = null; + try { + try (var fos = new FileOutputStream(zip); + var zos = new ZipOutputStream(fos)) { + zos.putNextEntry(new ZipEntry("hello")); + zos.write("hello".getBytes(US_ASCII)); + zos.closeEntry(); + } + + var zf = new ZipFile(zip); + var es = zf.entries(); + while (es.hasMoreElements()) { + zf.getInputStream(es.nextElement()).read(); + } + + Field fieldRes = ZipFile.class.getDeclaredField("res"); + if (!fieldRes.trySetAccessible()) { + throw new RuntimeException("'ZipFile.res' is not accesible"); + } + Object zfRes = fieldRes.get(zf); + if (zfRes == null) { + throw new RuntimeException("'ZipFile.res' is null"); + } + Field fieldZsrc = zfRes.getClass().getDeclaredField("zsrc"); + if (!fieldZsrc.trySetAccessible()) { + throw new RuntimeException("'ZipFile.zsrc' is not accesible"); + } + zsrc = fieldZsrc.get(zfRes); + + } finally { + zip.delete(); + } + + if (zsrc != null) { + Field zfileField = zsrc.getClass().getDeclaredField("zfile"); + if (!zfileField.trySetAccessible()) { + throw new RuntimeException("'ZipFile.Source.zfile' is not accesible"); + } + //System.out.println("zffile: " + zfileField.get(zsrc)); + int n = 10; + while (n-- > 0 && zfileField.get(zsrc) != null) { + System.out.println("waiting gc ... " + n); + System.gc(); + Thread.sleep(100); + } + if (zfileField.get(zsrc) != null) { + throw new RuntimeException("cleaner failed to clean zipfile."); + } + } + + // test subclassed ZipFile, for behavioral compatibility. + // should be removed if the finalize() method is finally removed. + var closeCountDown = new CountDownLatch(1); + try { + try (var fos = new FileOutputStream(zip); + var zos = new ZipOutputStream(fos)) { + zos.putNextEntry(new ZipEntry("hello")); + zos.write("hello".getBytes(US_ASCII)); + zos.closeEntry(); + } + var zf = new SubclassedZipFile(zip, closeCountDown); + var es = zf.entries(); + while (es.hasMoreElements()) { + zf.getInputStream(es.nextElement()).read(); + } + es = null; + zf = null; + } finally { + zip.delete(); + } + while (!closeCountDown.await(10, TimeUnit.MILLISECONDS)) { + System.gc(); + } + if (closeCountDown.getCount() != 0) + throw new RuntimeException("finalizer failed to clean : " + + closeCountDown.getCount()); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/lib/security/cacerts/VerifyCACerts.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/lib/security/cacerts/VerifyCACerts.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2017, 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 8189131 + * @requires java.runtime.name ~= "OpenJDK.*" + * @summary Check root CA entries in cacerts file + */ +import java.io.File; +import java.io.FileInputStream; +import java.security.KeyStore; +import java.security.MessageDigest; +import java.security.cert.*; +import java.util.*; + +public class VerifyCACerts { + + private static final String CACERTS + = System.getProperty("java.home") + File.separator + "lib" + + File.separator + "security" + File.separator + "cacerts"; + + private static final String BASE = System.getProperty("test.src", "./"); + + // The numbers of certs now. + private static final int COUNT = 80; + + // map of cert alias to SHA-256 fingerprint + private static final Map FINGERPRINT_MAP + = new HashMap() {{ + put("actalisauthenticationrootca [jdk]", + "55:92:60:84:EC:96:3A:64:B9:6E:2A:BE:01:CE:0B:A8:6A:64:FB:FE:BC:C7:AA:B5:AF:C1:55:B3:7F:D7:60:66"); + put("buypassclass2ca [jdk]", + "9A:11:40:25:19:7C:5B:B9:5D:94:E6:3D:55:CD:43:79:08:47:B6:46:B2:3C:DF:11:AD:A4:A0:0E:FF:15:FB:48"); + put("buypassclass3ca [jdk]", + "ED:F7:EB:BC:A2:7A:2A:38:4D:38:7B:7D:40:10:C6:66:E2:ED:B4:84:3E:4C:29:B4:AE:1D:5B:93:32:E6:B2:4D"); + put("camerfirmachambersca [jdk]", + "06:3E:4A:FA:C4:91:DF:D3:32:F3:08:9B:85:42:E9:46:17:D8:93:D7:FE:94:4E:10:A7:93:7E:E2:9D:96:93:C0"); + put("camerfirmachambersignca [jdk]", + "13:63:35:43:93:34:A7:69:80:16:A0:D3:24:DE:72:28:4E:07:9D:7B:52:20:BB:8F:BD:74:78:16:EE:BE:BA:CA"); + put("camerfirmachamberscommerceca [jdk]", + "0C:25:8A:12:A5:67:4A:EF:25:F2:8B:A7:DC:FA:EC:EE:A3:48:E5:41:E6:F5:CC:4E:E6:3B:71:B3:61:60:6A:C3"); + put("certumca [jdk]", + "D8:E0:FE:BC:1D:B2:E3:8D:00:94:0F:37:D2:7D:41:34:4D:99:3E:73:4B:99:D5:65:6D:97:78:D4:D8:14:36:24"); + put("certumtrustednetworkca [jdk]", + "5C:58:46:8D:55:F5:8E:49:7E:74:39:82:D2:B5:00:10:B6:D1:65:37:4A:CF:83:A7:D4:A3:2D:B7:68:C4:40:8E"); + put("chunghwaepkirootca [jdk]", + "C0:A6:F4:DC:63:A2:4B:FD:CF:54:EF:2A:6A:08:2A:0A:72:DE:35:80:3E:2F:F5:FF:52:7A:E5:D8:72:06:DF:D5"); + put("comodorsaca [jdk]", + "52:F0:E1:C4:E5:8E:C6:29:29:1B:60:31:7F:07:46:71:B8:5D:7E:A8:0D:5B:07:27:34:63:53:4B:32:B4:02:34"); + put("comodoaaaca [jdk]", + "D7:A7:A0:FB:5D:7E:27:31:D7:71:E9:48:4E:BC:DE:F7:1D:5F:0C:3E:0A:29:48:78:2B:C8:3E:E0:EA:69:9E:F4"); + put("comodoeccca [jdk]", + "17:93:92:7A:06:14:54:97:89:AD:CE:2F:8F:34:F7:F0:B6:6D:0F:3A:E3:A3:B8:4D:21:EC:15:DB:BA:4F:AD:C7"); + put("usertrustrsaca [jdk]", + "E7:93:C9:B0:2F:D8:AA:13:E2:1C:31:22:8A:CC:B0:81:19:64:3B:74:9C:89:89:64:B1:74:6D:46:C3:D4:CB:D2"); + put("usertrusteccca [jdk]", + "4F:F4:60:D5:4B:9C:86:DA:BF:BC:FC:57:12:E0:40:0D:2B:ED:3F:BC:4D:4F:BD:AA:86:E0:6A:DC:D2:A9:AD:7A"); + put("utnuserfirstobjectca [jdk]", + "6F:FF:78:E4:00:A7:0C:11:01:1C:D8:59:77:C4:59:FB:5A:F9:6A:3D:F0:54:08:20:D0:F4:B8:60:78:75:E5:8F"); + put("utnuserfirstclientauthemailca [jdk]", + "43:F2:57:41:2D:44:0D:62:74:76:97:4F:87:7D:A8:F1:FC:24:44:56:5A:36:7A:E6:0E:DD:C2:7A:41:25:31:AE"); + put("utnuserfirsthardwareca [jdk]", + "6E:A5:47:41:D0:04:66:7E:ED:1B:48:16:63:4A:A3:A7:9E:6E:4B:96:95:0F:82:79:DA:FC:8D:9B:D8:81:21:37"); + put("addtrustclass1ca [jdk]", + "8C:72:09:27:9A:C0:4E:27:5E:16:D0:7F:D3:B7:75:E8:01:54:B5:96:80:46:E3:1F:52:DD:25:76:63:24:E9:A7"); + put("addtrustexternalca [jdk]", + "68:7F:A4:51:38:22:78:FF:F0:C8:B1:1F:8D:43:D5:76:67:1C:6E:B2:BC:EA:B4:13:FB:83:D9:65:D0:6D:2F:F2"); + put("addtrustqualifiedca [jdk]", + "80:95:21:08:05:DB:4B:BC:35:5E:44:28:D8:FD:6E:C2:CD:E3:AB:5F:B9:7A:99:42:98:8E:B8:F4:DC:D0:60:16"); + put("baltimorecybertrustca [jdk]", + "16:AF:57:A9:F6:76:B0:AB:12:60:95:AA:5E:BA:DE:F2:2A:B3:11:19:D6:44:AC:95:CD:4B:93:DB:F3:F2:6A:EB"); + put("baltimorecodesigningca [jdk]", + "A9:15:45:DB:D2:E1:9C:4C:CD:F9:09:AA:71:90:0D:18:C7:35:1C:89:B3:15:F0:F1:3D:05:C1:3A:8F:FB:46:87"); + put("digicertglobalrootca [jdk]", + "43:48:A0:E9:44:4C:78:CB:26:5E:05:8D:5E:89:44:B4:D8:4F:96:62:BD:26:DB:25:7F:89:34:A4:43:C7:01:61"); + put("digicertglobalrootg2 [jdk]", + "CB:3C:CB:B7:60:31:E5:E0:13:8F:8D:D3:9A:23:F9:DE:47:FF:C3:5E:43:C1:14:4C:EA:27:D4:6A:5A:B1:CB:5F"); + put("digicertglobalrootg3 [jdk]", + "31:AD:66:48:F8:10:41:38:C7:38:F3:9E:A4:32:01:33:39:3E:3A:18:CC:02:29:6E:F9:7C:2A:C9:EF:67:31:D0"); + put("digicerttrustedrootg4 [jdk]", + "55:2F:7B:DC:F1:A7:AF:9E:6C:E6:72:01:7F:4F:12:AB:F7:72:40:C7:8E:76:1A:C2:03:D1:D9:D2:0A:C8:99:88"); + put("digicertassuredidrootca [jdk]", + "3E:90:99:B5:01:5E:8F:48:6C:00:BC:EA:9D:11:1E:E7:21:FA:BA:35:5A:89:BC:F1:DF:69:56:1E:3D:C6:32:5C"); + put("digicertassuredidg2 [jdk]", + "7D:05:EB:B6:82:33:9F:8C:94:51:EE:09:4E:EB:FE:FA:79:53:A1:14:ED:B2:F4:49:49:45:2F:AB:7D:2F:C1:85"); + put("digicertassuredidg3 [jdk]", + "7E:37:CB:8B:4C:47:09:0C:AB:36:55:1B:A6:F4:5D:B8:40:68:0F:BA:16:6A:95:2D:B1:00:71:7F:43:05:3F:C2"); + put("digicerthighassuranceevrootca [jdk]", + "74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF"); + put("equifaxsecureca [jdk]", + "08:29:7A:40:47:DB:A2:36:80:C7:31:DB:6E:31:76:53:CA:78:48:E1:BE:BD:3A:0B:01:79:A7:07:F9:2C:F1:78"); + put("equifaxsecureebusinessca1 [jdk]", + "2E:3A:2B:B5:11:25:05:83:6C:A8:96:8B:E2:CB:37:27:CE:9B:56:84:5C:6E:E9:8E:91:85:10:4A:FB:9A:F5:96"); + put("equifaxsecureglobalebusinessca1 [jdk]", + "86:AB:5A:65:71:D3:32:9A:BC:D2:E4:E6:37:66:8B:A8:9C:73:1E:C2:93:B6:CB:A6:0F:71:63:40:A0:91:CE:AE"); + put("geotrustglobalca [jdk]", + "FF:85:6A:2D:25:1D:CD:88:D3:66:56:F4:50:12:67:98:CF:AB:AA:DE:40:79:9C:72:2D:E4:D2:B5:DB:36:A7:3A"); + put("geotrustprimaryca [jdk]", + "37:D5:10:06:C5:12:EA:AB:62:64:21:F1:EC:8C:92:01:3F:C5:F8:2A:E9:8E:E5:33:EB:46:19:B8:DE:B4:D0:6C"); + put("geotrustprimarycag2 [jdk]", + "5E:DB:7A:C4:3B:82:A0:6A:87:61:E8:D7:BE:49:79:EB:F2:61:1F:7D:D7:9B:F9:1C:1C:6B:56:6A:21:9E:D7:66"); + put("geotrustprimarycag3 [jdk]", + "B4:78:B8:12:25:0D:F8:78:63:5C:2A:A7:EC:7D:15:5E:AA:62:5E:E8:29:16:E2:CD:29:43:61:88:6C:D1:FB:D4"); + put("geotrustuniversalca [jdk]", + "A0:45:9B:9F:63:B2:25:59:F5:FA:5D:4C:6D:B3:F9:F7:2F:F1:93:42:03:35:78:F0:73:BF:1D:1B:46:CB:B9:12"); + put("gtecybertrustglobalca [jdk]", + "A5:31:25:18:8D:21:10:AA:96:4B:02:C7:B7:C6:DA:32:03:17:08:94:E5:FB:71:FF:FB:66:67:D5:E6:81:0A:36"); + put("thawteprimaryrootca [jdk]", + "8D:72:2F:81:A9:C1:13:C0:79:1D:F1:36:A2:96:6D:B2:6C:95:0A:97:1D:B4:6B:41:99:F4:EA:54:B7:8B:FB:9F"); + put("thawteprimaryrootcag2 [jdk]", + "A4:31:0D:50:AF:18:A6:44:71:90:37:2A:86:AF:AF:8B:95:1F:FB:43:1D:83:7F:1E:56:88:B4:59:71:ED:15:57"); + put("thawteprimaryrootcag3 [jdk]", + "4B:03:F4:58:07:AD:70:F2:1B:FC:2C:AE:71:C9:FD:E4:60:4C:06:4C:F5:FF:B6:86:BA:E5:DB:AA:D7:FD:D3:4C"); + put("thawtepremiumserverca [jdk]", + "3F:9F:27:D5:83:20:4B:9E:09:C8:A3:D2:06:6C:4B:57:D3:A2:47:9C:36:93:65:08:80:50:56:98:10:5D:BC:E9"); + put("verisigntsaca [jdk]", + "CB:6B:05:D9:E8:E5:7C:D8:82:B1:0B:4D:B7:0D:E4:BB:1D:E4:2B:A4:8A:7B:D0:31:8B:63:5B:F6:E7:78:1A:9D"); + put("verisignclass1ca [jdk]", + "51:84:7C:8C:BD:2E:9A:72:C9:1E:29:2D:2A:E2:47:D7:DE:1E:3F:D2:70:54:7A:20:EF:7D:61:0F:38:B8:84:2C"); + put("verisignclass1g2ca [jdk]", + "34:1D:E9:8B:13:92:AB:F7:F4:AB:90:A9:60:CF:25:D4:BD:6E:C6:5B:9A:51:CE:6E:D0:67:D0:0E:C7:CE:9B:7F"); + put("verisignclass1g3ca [jdk]", + "CB:B5:AF:18:5E:94:2A:24:02:F9:EA:CB:C0:ED:5B:B8:76:EE:A3:C1:22:36:23:D0:04:47:E4:F3:BA:55:4B:65"); + put("verisignclass2g2ca [jdk]", + "3A:43:E2:20:FE:7F:3E:A9:65:3D:1E:21:74:2E:AC:2B:75:C2:0F:D8:98:03:05:BC:50:2C:AF:8C:2D:9B:41:A1"); + put("verisignclass2g3ca [jdk]", + "92:A9:D9:83:3F:E1:94:4D:B3:66:E8:BF:AE:7A:95:B6:48:0C:2D:6C:6C:2A:1B:E6:5D:42:36:B6:08:FC:A1:BB"); + put("verisignclass3ca [jdk]", + "A4:B6:B3:99:6F:C2:F3:06:B3:FD:86:81:BD:63:41:3D:8C:50:09:CC:4F:A3:29:C2:CC:F0:E2:FA:1B:14:03:05"); + put("verisignclass3g2ca [jdk]", + "83:CE:3C:12:29:68:8A:59:3D:48:5F:81:97:3C:0F:91:95:43:1E:DA:37:CC:5E:36:43:0E:79:C7:A8:88:63:8B"); + put("verisignuniversalrootca [jdk]", + "23:99:56:11:27:A5:71:25:DE:8C:EF:EA:61:0D:DF:2F:A0:78:B5:C8:06:7F:4E:82:82:90:BF:B8:60:E8:4B:3C"); + put("verisignclass3g3ca [jdk]", + "EB:04:CF:5E:B1:F3:9A:FA:76:2F:2B:B1:20:F2:96:CB:A5:20:C1:B9:7D:B1:58:95:65:B8:1C:B9:A1:7B:72:44"); + put("verisignclass3g4ca [jdk]", + "69:DD:D7:EA:90:BB:57:C9:3E:13:5D:C8:5E:A6:FC:D5:48:0B:60:32:39:BD:C4:54:FC:75:8B:2A:26:CF:7F:79"); + put("verisignclass3g5ca [jdk]", + "9A:CF:AB:7E:43:C8:D8:80:D0:6B:26:2A:94:DE:EE:E4:B4:65:99:89:C3:D0:CA:F1:9B:AF:64:05:E4:1A:B7:DF"); + put("certplusclass2primaryca [jdk]", + "0F:99:3C:8A:EF:97:BA:AF:56:87:14:0E:D5:9A:D1:82:1B:B4:AF:AC:F0:AA:9A:58:B5:D5:7A:33:8A:3A:FB:CB"); + put("certplusclass3pprimaryca [jdk]", + "CC:C8:94:89:37:1B:AD:11:1C:90:61:9B:EA:24:0A:2E:6D:AD:D9:9F:9F:6E:1D:4D:41:E5:8E:D6:DE:3D:02:85"); + put("keynectisrootca [jdk]", + "42:10:F1:99:49:9A:9A:C3:3C:8D:E0:2B:A6:DB:AA:14:40:8B:DD:8A:6E:32:46:89:C1:92:2D:06:97:15:A3:32"); + put("dtrustclass3ca2 [jdk]", + "49:E7:A4:42:AC:F0:EA:62:87:05:00:54:B5:25:64:B6:50:E4:F4:9E:42:E3:48:D6:AA:38:E0:39:E9:57:B1:C1"); + put("dtrustclass3ca2ev [jdk]", + "EE:C5:49:6B:98:8C:E9:86:25:B9:34:09:2E:EC:29:08:BE:D0:B0:F3:16:C2:D4:73:0C:84:EA:F1:F3:D3:48:81"); + put("identrustdstx3 [jdk]", + "06:87:26:03:31:A7:24:03:D9:09:F1:05:E6:9B:CF:0D:32:E1:BD:24:93:FF:C6:D9:20:6D:11:BC:D6:77:07:39"); + put("identrustpublicca [jdk]", + "30:D0:89:5A:9A:44:8A:26:20:91:63:55:22:D1:F5:20:10:B5:86:7A:CA:E1:2C:78:EF:95:8F:D4:F4:38:9F:2F"); + put("identrustcommercial [jdk]", + "5D:56:49:9B:E4:D2:E0:8B:CF:CA:D0:8A:3E:38:72:3D:50:50:3B:DE:70:69:48:E4:2F:55:60:30:19:E5:28:AE"); + put("letsencryptisrgx1 [jdk]", + "96:BC:EC:06:26:49:76:F3:74:60:77:9A:CF:28:C5:A7:CF:E8:A3:C0:AA:E1:1A:8F:FC:EE:05:C0:BD:DF:08:C6"); + put("luxtrustglobalrootca [jdk]", + "A1:B2:DB:EB:64:E7:06:C6:16:9E:3C:41:18:B2:3B:AA:09:01:8A:84:27:66:6D:8B:F0:E2:88:91:EC:05:19:50"); + put("quovadisrootca [jdk]", + "A4:5E:DE:3B:BB:F0:9C:8A:E1:5C:72:EF:C0:72:68:D6:93:A2:1C:99:6F:D5:1E:67:CA:07:94:60:FD:6D:88:73"); + put("quovadisrootca1g3 [jdk]", + "8A:86:6F:D1:B2:76:B5:7E:57:8E:92:1C:65:82:8A:2B:ED:58:E9:F2:F2:88:05:41:34:B7:F1:F4:BF:C9:CC:74"); + put("quovadisrootca2 [jdk]", + "85:A0:DD:7D:D7:20:AD:B7:FF:05:F8:3D:54:2B:20:9D:C7:FF:45:28:F7:D6:77:B1:83:89:FE:A5:E5:C4:9E:86"); + put("quovadisrootca2g3 [jdk]", + "8F:E4:FB:0A:F9:3A:4D:0D:67:DB:0B:EB:B2:3E:37:C7:1B:F3:25:DC:BC:DD:24:0E:A0:4D:AF:58:B4:7E:18:40"); + put("quovadisrootca3 [jdk]", + "18:F1:FC:7F:20:5D:F8:AD:DD:EB:7F:E0:07:DD:57:E3:AF:37:5A:9C:4D:8D:73:54:6B:F4:F1:FE:D1:E1:8D:35"); + put("quovadisrootca3g3 [jdk]", + "88:EF:81:DE:20:2E:B0:18:45:2E:43:F8:64:72:5C:EA:5F:BD:1F:C2:D9:D2:05:73:07:09:C5:D8:B8:69:0F:46"); + put("secomscrootca1 [jdk]", + "E7:5E:72:ED:9F:56:0E:EC:6E:B4:80:00:73:A4:3F:C3:AD:19:19:5A:39:22:82:01:78:95:97:4A:99:02:6B:6C"); + put("secomscrootca2 [jdk]", + "51:3B:2C:EC:B8:10:D4:CD:E5:DD:85:39:1A:DF:C6:C2:DD:60:D8:7B:B7:36:D2:B5:21:48:4A:A4:7A:0E:BE:F6"); + put("secomevrootca1 [jdk]", + "A2:2D:BA:68:1E:97:37:6E:2D:39:7D:72:8A:AE:3A:9B:62:96:B9:FD:BA:60:BC:2E:11:F6:47:F2:C6:75:FB:37"); + put("swisssigngoldg2ca [jdk]", + "62:DD:0B:E9:B9:F5:0A:16:3E:A0:F8:E7:5C:05:3B:1E:CA:57:EA:55:C8:68:8F:64:7C:68:81:F2:C8:35:7B:95"); + put("swisssignplatinumg2ca [jdk]", + "3B:22:2E:56:67:11:E9:92:30:0D:C0:B1:5A:B9:47:3D:AF:DE:F8:C8:4D:0C:EF:7D:33:17:B4:C1:82:1D:14:36"); + put("swisssignsilverg2ca [jdk]", + "BE:6C:4D:A2:BB:B9:BA:59:B6:F3:93:97:68:37:42:46:C3:C0:05:99:3F:A9:8F:02:0D:1D:ED:BE:D4:8A:81:D5"); + put("soneraclass2ca [jdk]", + "79:08:B4:03:14:C1:38:10:0B:51:8D:07:35:80:7F:FB:FC:F8:51:8A:00:95:33:71:05:BA:38:6B:15:3D:D9:27"); + put("securetrustca [jdk]", + "F1:C1:B5:0A:E5:A2:0D:D8:03:0E:C9:F6:BC:24:82:3D:D3:67:B5:25:57:59:B4:E7:1B:61:FC:E9:F7:37:5D:73"); + put("xrampglobalca [jdk]", + "CE:CD:DC:90:50:99:D8:DA:DF:C5:B1:D2:09:B7:37:CB:E2:C1:8C:FB:2C:10:C0:FF:0B:CF:0D:32:86:FC:1A:A2"); + }}; + + // Ninety days in milliseconds + private static final long NINETY_DAYS = 7776000000L; + + private static boolean atLeastOneFailed = false; + + private static MessageDigest md; + + public static void main(String[] args) throws Exception { + System.out.println("cacerts file: " + CACERTS); + md = MessageDigest.getInstance("SHA-256"); + KeyStore ks = KeyStore.getInstance("JKS"); + ks.load(new FileInputStream(CACERTS), "changeit".toCharArray()); + + // check the count of certs inside + if (ks.size() != COUNT) { + atLeastOneFailed = true; + System.err.println("ERROR: " + ks.size() + " entries, should be " + + COUNT); + } + + // check that all entries in the map are in the keystore + for (String alias : FINGERPRINT_MAP.keySet()) { + if (!ks.isCertificateEntry(alias)) { + atLeastOneFailed = true; + System.err.println("ERROR: " + alias + " is not in cacerts"); + } + } + + // pull all the trusted self-signed CA certs out of the cacerts file + // and verify their signatures + Enumeration aliases = ks.aliases(); + while (aliases.hasMoreElements()) { + String alias = aliases.nextElement(); + System.out.println("\nVerifying " + alias); + if (!ks.isCertificateEntry(alias)) { + atLeastOneFailed = true; + System.err.println("ERROR: " + alias + + " is not a trusted cert entry"); + } + X509Certificate cert = (X509Certificate) ks.getCertificate(alias); + if (!checkFingerprint(alias, cert)) { + atLeastOneFailed = true; + System.err.println("ERROR: " + alias + " SHA-256 fingerprint is incorrect"); + } + // Make sure cert can be self-verified + try { + cert.verify(cert.getPublicKey()); + } catch (Exception e) { + atLeastOneFailed = true; + System.err.println("ERROR: cert cannot be verified:" + + e.getMessage()); + } + + // Make sure cert is not expired or not yet valid + try { + cert.checkValidity(); + } catch (CertificateExpiredException cee) { + atLeastOneFailed = true; + System.err.println("ERROR: cert is expired"); + } catch (CertificateNotYetValidException cne) { + atLeastOneFailed = true; + System.err.println("ERROR: cert is not yet valid"); + } + + // If cert is within 90 days of expiring, mark as failure so + // that cert can be scheduled to be removed/renewed. + Date notAfter = cert.getNotAfter(); + if (notAfter.getTime() - System.currentTimeMillis() < NINETY_DAYS) { + atLeastOneFailed = true; + System.err.println("WARNING: cert will expire within 90 days"); + } + } + + if (atLeastOneFailed) { + throw new Exception("At least one cacert test failed"); + } + } + + private static boolean checkFingerprint(String alias, Certificate cert) + throws Exception { + String fingerprint = FINGERPRINT_MAP.get(alias); + if (fingerprint == null) { + // no entry for alias + return true; + } + System.out.println("Checking fingerprint of " + alias); + byte[] digest = md.digest(cert.getEncoded()); + return fingerprint.equals(toHexString(digest)); + } + + private static String toHexString(byte[] block) { + StringBuilder buf = new StringBuilder(); + int len = block.length; + for (int i = 0; i < len; i++) { + buf.append(String.format("%02X", block[i])); + if (i < len - 1) { + buf.append(":"); + } + } + return buf.toString(); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2017, 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 8189131 + * @summary Interoperability tests with Actalis CA + * @build ValidatePathWithParams + * @run main/othervm/timeout=180 -Djava.security.debug=certpath ActalisCA OCSP + * @run main/othervm/timeout=180 -Djava.security.debug=certpath ActalisCA CRL + */ + + /* + * Obtain test artifacts for Actalis CA from: + * + * Test web site with *active *TLS Server certificate: + * https://ssltest-a.actalis.it:8443 + * If doesn't work then use certificate of https://www.actalis.it + * + * Test web site with *revoked *TLS Server certificate: + * https://ssltest-r.actalis.it:8444 + * + * Test web site with *expired *TLS Server certificate: + * https://ssltest-e.actalis.it:8445 + */ +public class ActalisCA { + + // Owner: CN=Actalis Extended Validation Server CA G1, + // O=Actalis S.p.A./03358520967, L=Milano, ST=Milano, C=IT + // Issuer: CN=Actalis Authentication Root CA, O=Actalis S.p.A./03358520967, + // L=Milan, C=IT + private static final String INT_VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIGTDCCBDSgAwIBAgIIMtYr/GdQGsswDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" + + "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" + + "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" + + "IENBMB4XDTE1MDUxNDA3MDAzOFoXDTMwMDUxNDA3MDAzOFowgYcxCzAJBgNVBAYT\n" + + "AklUMQ8wDQYDVQQIDAZNaWxhbm8xDzANBgNVBAcMBk1pbGFubzEjMCEGA1UECgwa\n" + + "QWN0YWxpcyBTLnAuQS4vMDMzNTg1MjA5NjcxMTAvBgNVBAMMKEFjdGFsaXMgRXh0\n" + + "ZW5kZWQgVmFsaWRhdGlvbiBTZXJ2ZXIgQ0EgRzEwggEiMA0GCSqGSIb3DQEBAQUA\n" + + "A4IBDwAwggEKAoIBAQD1Ygc1CwmqXqjd3dTEKMLUwGdb/3+00ytg0uBb4RB+89/O\n" + + "4K/STFZcGUjcCq6Job5cmxZBGyRRBYfCEn4vg8onedFztkO0NvD04z4wLFyxjSRT\n" + + "bcMm2d+/Xci5XLA3Q9wG8TGzHTVQKmdvFpQ7b7EsmOc0uXA7w3UGhLjb2EYpu/Id\n" + + "uZ1LUTyEOHc3XHXI3a3udkRBDs/bObTcbte80DPbNetRFB+jHbIw5sH171IeBFGN\n" + + "PB92Iebp01yE8g3X9RqPXrrV7ririEtwFMYp+KgA8BRHxsoNV3xZmhdzJm0AMzC2\n" + + "waLM3H562xPM0UntAYh2pRrAUUtgURRizCT1kr6tAgMBAAGjggHVMIIB0TBBBggr\n" + + "BgEFBQcBAQQ1MDMwMQYIKwYBBQUHMAGGJWh0dHA6Ly9vY3NwMDUuYWN0YWxpcy5p\n" + + "dC9WQS9BVVRILVJPT1QwHQYDVR0OBBYEFGHB5IYeTW10dLzZlzsxcXjLP5/cMA8G\n" + + "A1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbtifN7OHCUyQICNtAw\n" + + "RQYDVR0gBD4wPDA6BgRVHSAAMDIwMAYIKwYBBQUHAgEWJGh0dHBzOi8vd3d3LmFj\n" + + "dGFsaXMuaXQvYXJlYS1kb3dubG9hZDCB4wYDVR0fBIHbMIHYMIGWoIGToIGQhoGN\n" + + "bGRhcDovL2xkYXAwNS5hY3RhbGlzLml0L2NuJTNkQWN0YWxpcyUyMEF1dGhlbnRp\n" + + "Y2F0aW9uJTIwUm9vdCUyMENBLG8lM2RBY3RhbGlzJTIwUy5wLkEuJTJmMDMzNTg1\n" + + "MjA5NjcsYyUzZElUP2NlcnRpZmljYXRlUmV2b2NhdGlvbkxpc3Q7YmluYXJ5MD2g\n" + + "O6A5hjdodHRwOi8vY3JsMDUuYWN0YWxpcy5pdC9SZXBvc2l0b3J5L0FVVEgtUk9P\n" + + "VC9nZXRMYXN0Q1JMMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEA\n" + + "OD8D2Z2fw76+GIu+mDEgygH/y7F9K4I6rZOc3LqGBecO3C0fGcIuuG7APtxGGk7Y\n" + + "nk97Qt+3pDoek9EP65/1u128pRncZcjEAeMgKb7UuJxwoR6Sj5zhOadotKcCQqmF\n" + + "Si99ExNo6dTq5Eyp1KrqepLmezbO9owx4Q44mtNpfKLMgzDqOn/dwNMo/pGYbMfP\n" + + "DjhxEnta1HXgcEcgCk1Au16xkdzapwY4sXpKuwB24phfWF+cveKAQ0Rncmvrm34i\n" + + "9B6leZUkSHDe4mRkbO5nObhKHYRmVSr0Q/wvGCmTgGTKuw/Gj8+RFb5MEkOKEcJn\n" + + "I32CPohpiW/jlpeLaFBIgJnXuZTxmfTX55sqtXDlKxRxFwq1W3kML4UfGZsgjx1l\n" + + "hX5fQ1QlEZeO9CyPpgGO5Py2KXXKhUxCtF7tawAYimWwslxvPCjHDND/WhM1Fz9e\n" + + "2yqwHcSQAOUVv5mk9uYc6/NSLwLb5in3R728GNEpHHhbx5QZhtdqR8mb56uJUDKI\n" + + "AwnnZckcR+SLGL2Agx7hY7YCMOQhSsO6PA81M/mGW2hGCiZw3GULJe9ejL/vdS0I\n" + + "PWrp7YLnXUa6mtXVSBKGrVrlbpJaN10+fB4Yrlk4O2sF4WNUAHMBn9T+zOXaBAhj\n" + + "vNlMU7+elLkTcKIB7qJJuSZChxzoevM2ciO3BpGuRxg=\n" + + "-----END CERTIFICATE-----"; + + // Owner: OID.1.3.6.1.4.1.311.60.2.1.3=IT, STREET=Via S. Clemente 53, + // OID.2.5.4.15=Private Organization, CN=www.actalis.it, + // SERIALNUMBER=03358520967, O=Actalis S.p.A., L=Ponte San Pietro, ST=Bergamo, C=IT + // Issuer: CN=Actalis Extended Validation Server CA G1, + // O=Actalis S.p.A./03358520967, L=Milano, ST=Milano, C=IT + // Serial number: eeeee6d6463bde2 + // Valid from: Sat Jun 17 05:59:17 PDT 2017 until: Mon Jun 17 05:59:17 PDT 2019 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIHwTCCBqmgAwIBAgIIDu7ubWRjveIwDQYJKoZIhvcNAQELBQAwgYcxCzAJBgNV\n" + + "BAYTAklUMQ8wDQYDVQQIDAZNaWxhbm8xDzANBgNVBAcMBk1pbGFubzEjMCEGA1UE\n" + + "CgwaQWN0YWxpcyBTLnAuQS4vMDMzNTg1MjA5NjcxMTAvBgNVBAMMKEFjdGFsaXMg\n" + + "RXh0ZW5kZWQgVmFsaWRhdGlvbiBTZXJ2ZXIgQ0EgRzEwHhcNMTcwNjE3MTI1OTE3\n" + + "WhcNMTkwNjE3MTI1OTE3WjCB0zELMAkGA1UEBhMCSVQxEDAOBgNVBAgMB0Jlcmdh\n" + + "bW8xGTAXBgNVBAcMEFBvbnRlIFNhbiBQaWV0cm8xFzAVBgNVBAoMDkFjdGFsaXMg\n" + + "Uy5wLkEuMRQwEgYDVQQFEwswMzM1ODUyMDk2NzEXMBUGA1UEAwwOd3d3LmFjdGFs\n" + + "aXMuaXQxHTAbBgNVBA8MFFByaXZhdGUgT3JnYW5pemF0aW9uMRswGQYDVQQJDBJW\n" + + "aWEgUy4gQ2xlbWVudGUgNTMxEzARBgsrBgEEAYI3PAIBAxMCSVQwggEiMA0GCSqG\n" + + "SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCwZ3++4pQYGfhXSqin1CKRJ6SOqkTcX3O0\n" + + "6b4jZbSNomyqyn6aHOz6ztOlj++fPzxmIzErEySOTd3G0pr+iwpYQVdeg1Y27KL8\n" + + "OiwwUrlV4ZMa8KKXr4BnWlDbFIo+eIcSew5V7CiodDyxpj9zjqJK497LF1jxgXtr\n" + + "IoMRwrh2Y0NbJCZGUCL30sQr/W4xBnO1+pi2DbCieGe/XoK8yEtx9FdnEFvyT9qn\n" + + "zYyrXvnTvfVSwzwtEIn+akjomI4WfCFLBF0M7v4dAHypfnPAAoW1c0BBqNB32zf0\n" + + "rYwNnD7UwZlcDihEYlgC70Dfy7bPsdq2spmOMk/VUqb3U0LHRVM3AgMBAAGjggPh\n" + + "MIID3TB9BggrBgEFBQcBAQRxMG8wOgYIKwYBBQUHMAKGLmh0dHA6Ly9jYWNlcnQu\n" + + "YWN0YWxpcy5pdC9jZXJ0cy9hY3RhbGlzLWF1dGV2ZzEwMQYIKwYBBQUHMAGGJWh0\n" + + "dHA6Ly9vY3NwMDUuYWN0YWxpcy5pdC9WQS9BVVRIRVYtRzEwHQYDVR0OBBYEFK9y\n" + + "954QoY/5XV6TayD1gWVy0gQOMAwGA1UdEwEB/wQCMAAwHwYDVR0jBBgwFoAUYcHk\n" + + "hh5NbXR0vNmXOzFxeMs/n9wwUAYDVR0gBEkwRzA8BgYrgR8BEQEwMjAwBggrBgEF\n" + + "BQcCARYkaHR0cHM6Ly93d3cuYWN0YWxpcy5pdC9hcmVhLWRvd25sb2FkMAcGBWeB\n" + + "DAEBMIHvBgNVHR8EgecwgeQwgaKggZ+ggZyGgZlsZGFwOi8vbGRhcDA1LmFjdGFs\n" + + "aXMuaXQvY24lM2RBY3RhbGlzJTIwRXh0ZW5kZWQlMjBWYWxpZGF0aW9uJTIwU2Vy\n" + + "dmVyJTIwQ0ElMjBHMSxvJTNkQWN0YWxpcyUyMFMucC5BLi8wMzM1ODUyMDk2Nyxj\n" + + "JTNkSVQ/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdDtiaW5hcnkwPaA7oDmGN2h0\n" + + "dHA6Ly9jcmwwNS5hY3RhbGlzLml0L1JlcG9zaXRvcnkvQVVUSEVWLUcxL2dldExh\n" + + "c3RDUkwwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEF\n" + + "BQcDAjAZBgNVHREEEjAQgg53d3cuYWN0YWxpcy5pdDCCAX4GCisGAQQB1nkCBAIE\n" + + "ggFuBIIBagFoAHYApLkJkLQYWBSHuxOizGdwCjw1mAT5G9+443fNDsgN3BAAAAFc\n" + + "tiwHywAABAMARzBFAiEA7GC5/kja3l8cBw1/wBpHl/AKH6eL1MKpmICtf5G09c4C\n" + + "IBM887DQEwD2E4Xx/IP+33NMvUOhSwZ4XODgqFVXsz0wAHYA7ku9t3XOYLrhQmkf\n" + + "q+GeZqMPfl+wctiDAMR7iXqo/csAAAFctiwIqwAABAMARzBFAiEAwwiR95ozXdKs\n" + + "+uULfrzgENbHc2rLgGIac6ZMv0xHDLACIFLQVpvQBRQfys2KVRGHQKGxqAeghQZw\n" + + "9nJL+U5huzfaAHYA3esdK3oNT6Ygi4GtgWhwfi6OnQHVXIiNPRHEzbbsvswAAAFc\n" + + "tiwMqwAABAMARzBFAiEAifV9ocxbO6b3I22jb2zxBvG2e83hXHitOhYXkHdSmZkC\n" + + "IDJLuPvGOczF9axgphImlUbT9dX3wRpjEi5IeV+pxMiYMA0GCSqGSIb3DQEBCwUA\n" + + "A4IBAQB5U6k1Onv9Y7POHGnUOI0ATHevbpbS/7r68DZQ6cRmDIpsZyjW6PxYs9nc\n" + + "3ob3Pjomm+S7StDl9ehI7rYLlZC52QlXlsq1fzEQ9xSkf+VSD70A91dPIFAdI/jQ\n" + + "aWvIUvQEbhfUZc0ihIple0VyWGH5bza0DLW+C8ttF8KqICUfL8S8mZgjbXvVg2fY\n" + + "HLW9lWR/Pkco2yRc8gZyr9FGkXOcmJ8aFaCuJnGm/IVRCieYp60If4DoAKz49xpF\n" + + "CF6RjOAJ//UGSp/ySjHMmT8PLO7NvhsT4XDDGTSeIYYpO++tbEIcLcjW9m2k5Gnh\n" + + "kmEenr0hdcpeLgsP3Fsy7JxyQNpL\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Actalis Authentication CA G3, O=Actalis S.p.A./03358520967, L=Milano, ST=Milano, C=IT + // Issuer: CN=Actalis Authentication Root CA, O=Actalis S.p.A./03358520967, L=Milan, C=IT + // SN: 741d584a 72fc06bc + // Valid from: Wed Feb 12 22:32:23 PST 2014 + // Valid till: Mon Feb 12 22:32:23 PST 2024 + private static final String INT_REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGTTCCBDWgAwIBAgIIdB1YSnL8BrwwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" + + "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" + + "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" + + "IENBMB4XDTE0MDIxMzE1MDIyM1oXDTI0MDIxMzE1MDIyM1owezELMAkGA1UEBhMC\n" + + "SVQxDzANBgNVBAgMBk1pbGFubzEPMA0GA1UEBwwGTWlsYW5vMSMwIQYDVQQKDBpB\n" + + "Y3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzElMCMGA1UEAwwcQWN0YWxpcyBBdXRo\n" + + "ZW50aWNhdGlvbiBDQSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" + + "AMzhDjmhNDym6ze3PegbIKmiavXpAjgVCZ344k1DOtdSCV6k3h3rqfHqFn3mrayA\n" + + "btmJ0NeC886WxUUsJwHJ3bOnNBQZIHxLV+1RVD/6TQqb6/bPJu4rDwEfhbJSmErc\n" + + "29wUJWqxXMhSAWTHi3Pq0vrkx59e5KTEyfB2kHo6InlR72sCCRdtCL9aDuDm8nYK\n" + + "pTSAJr36ultwME5NyCNSyN2JIK0wYbEi7MVNbp5KN9MusTp3cOMDoVBreYulmnEu\n" + + "TNazmoAv0K8oLS7iX7c9x+zGjUUAucFEuSlRn3sL6hFAiKjy4PDClvnyqQHBBdZr\n" + + "/3JOxAcgXv7aZ4/STeXeDXsCAwEAAaOCAeMwggHfMEEGCCsGAQUFBwEBBDUwMzAx\n" + + "BggrBgEFBQcwAYYlaHR0cDovL3BvcnRhbC5hY3RhbGlzLml0L1ZBL0FVVEgtUk9P\n" + + "VDAdBgNVHQ4EFgQUqqr9yowdTfEug+EG/PqO6g4jrj0wDwYDVR0TAQH/BAUwAwEB\n" + + "/zAfBgNVHSMEGDAWgBRS2Ig6yJ94Zu2J83s4cJTJAgI20DBUBgNVHSAETTBLMEkG\n" + + "BFUdIAAwQTA/BggrBgEFBQcCARYzaHR0cHM6Ly9wb3J0YWwuYWN0YWxpcy5pdC9S\n" + + "ZXBvc2l0b3J5L1BvbGljeS9TU0wvQ1BTMIHiBgNVHR8EgdowgdcwgZSggZGggY6G\n" + + "gYtsZGFwOi8vbGRhcC5hY3RhbGlzLml0L2NuJTNkQWN0YWxpcyUyMEF1dGhlbnRp\n" + + "Y2F0aW9uJTIwUm9vdCUyMENBLG8lM2RBY3RhbGlzJTIwUy5wLkEuJTJmMDMzNTg1\n" + + "MjA5NjcsYyUzZElUP2NlcnRpZmljYXRlUmV2b2NhdGlvbkxpc3Q7YmluYXJ5MD6g\n" + + "PKA6hjhodHRwOi8vcG9ydGFsLmFjdGFsaXMuaXQvUmVwb3NpdG9yeS9BVVRILVJP\n" + + "T1QvZ2V0TGFzdENSTDAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggIB\n" + + "ABP93l+9QBgzHF0Clf3gMAelGqwXT25DwZVFIkBw6YyqOPcaqzw1XKHJJEMQ8xOp\n" + + "8uuiPLP/ObxEXBBvH7ofNW7nRUIzGsuLPhzdfJhdzilCVAvz4WRsX44nWOQS4Qu0\n" + + "npo7dbq/KxFUCUO9yNEJp6YxNloy8XFIlazkHFTKGJqoUpsGoc7B9YmPchhE2FPb\n" + + "OZiOCg4Y2Qp43UJfnENgZ3gJFh16juQE1uS8Q/JJI7ZzJfJ/W0uQoDnCprOPUpLF\n" + + "G03e0asFxwQqhL84Jvf7rJZaWvwydHP4hH47nzpHWEGXwfJLXXoO7LHgqVB7K9Ar\n" + + "Zf3pY0S/3Fs+AN/PrEY3Z3rb7ypQLRiot1oJLl8matiGEF4aFL5DDkr9wfRAZ8S8\n" + + "WT69vN68ENGgEwyeZSlQxn+4g6quHRav0fmF2fGnLaq7tteSPVocT7XaMEpkHqNs\n" + + "x1q/PJbr39s/1QVZtS9CrdoCr0QAnBaX//PPB6ansSLFcvEqM9QcV9xQZex88ToX\n" + + "nk3TcHtA0ezWJlCkg626MhdQZrhHbkauHfIGSOmCkn3zHp0BZQ6Vo7UOdRMT7QS7\n" + + "y7AkET9Qmapwh2CFUdCJSXklVRd+06XhhOB37NQU0pGJQJ3xjEPrILZ8kLhW3Tyq\n" + + "Iv30LW7MXZ4yQn/JHEZbuiOOb4R45hsPZxe6gOq/e+sf\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=ssltest-r.actalis.it, O=Actalis S.p.A., L=Ponte San Pietro, ST=Bergamo, C=IT + // Issuer: CN=Actalis Authentication CA G3, O=Actalis S.p.A./03358520967, L=Milano, ST=Milano, C=IT + // SN: 0455de97 5c71c96f + // Valid from: Thu Jan 28 16:23:52 PST 2016 + // Valid till: Mon Jan 28 16:23:52 PST 2019 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIFmDCCBICgAwIBAgIIBFXel1xxyW8wDQYJKoZIhvcNAQELBQAwezELMAkGA1UE\n" + + "BhMCSVQxDzANBgNVBAgMBk1pbGFubzEPMA0GA1UEBwwGTWlsYW5vMSMwIQYDVQQK\n" + + "DBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzElMCMGA1UEAwwcQWN0YWxpcyBB\n" + + "dXRoZW50aWNhdGlvbiBDQSBHMzAeFw0xNjAxMjkwODUzNTJaFw0xOTAxMjkwODUz\n" + + "NTJaMHIxCzAJBgNVBAYTAklUMRAwDgYDVQQIDAdCZXJnYW1vMRkwFwYDVQQHDBBQ\n" + + "b250ZSBTYW4gUGlldHJvMRcwFQYDVQQKDA5BY3RhbGlzIFMucC5BLjEdMBsGA1UE\n" + + "AwwUc3NsdGVzdC1yLmFjdGFsaXMuaXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw\n" + + "ggEKAoIBAQClbzoXCvD21FD7Oy/TKZu4fmDFJrISrNfasLlC3krLHkgb1vg23Z1P\n" + + "+7rIymDgrJSzjvYmisl+VM7xXxTsyI2pp9Qp/uzTMAMML9ISd/s0LaMBiNN5iPyj\n" + + "W91gGzGe30Jc319afKwFBaveSv7NO3DWsmHw9koezWkKUug2dnQCVXk1uTSdobnq\n" + + "wOgwxdd86LpZnFLxBIYdU68S4vogAQZjdja/S1+tF6JnfvY6o/xRJmQckVtNmUs6\n" + + "Dj3KoN2o/8BEgSCYcJz8tfoZcVazVkWOp/u6moUnm1/IKSYNgtHnB1ub0fB2AttW\n" + + "Vi7cs3SG/tDMMP8yc1kWScWf8CYj/AI1AgMBAAGjggInMIICIzA/BggrBgEFBQcB\n" + + "AQQzMDEwLwYIKwYBBQUHMAGGI2h0dHA6Ly9vY3NwMDMuYWN0YWxpcy5pdC9WQS9B\n" + + "VVRILUczMB0GA1UdDgQWBBRIKN5WmrjivlnT1rDzsH1WZ+PuvTAMBgNVHRMBAf8E\n" + + "AjAAMB8GA1UdIwQYMBaAFKqq/cqMHU3xLoPhBvz6juoOI649MGAGA1UdIARZMFcw\n" + + "SwYGK4EfARQBMEEwPwYIKwYBBQUHAgEWM2h0dHBzOi8vcG9ydGFsLmFjdGFsaXMu\n" + + "aXQvUmVwb3NpdG9yeS9Qb2xpY3kvU1NML0NQUzAIBgZngQwBAgIwgd8GA1UdHwSB\n" + + "1zCB1DCBlKCBkaCBjoaBi2xkYXA6Ly9sZGFwMDMuYWN0YWxpcy5pdC9jbiUzZEFj\n" + + "dGFsaXMlMjBBdXRoZW50aWNhdGlvbiUyMENBJTIwRzMsbyUzZEFjdGFsaXMlMjBT\n" + + "LnAuQS4lMmYwMzM1ODUyMDk2NyxjJTNkSVQ/Y2VydGlmaWNhdGVSZXZvY2F0aW9u\n" + + "TGlzdDtiaW5hcnkwO6A5oDeGNWh0dHA6Ly9jcmwwMy5hY3RhbGlzLml0L1JlcG9z\n" + + "aXRvcnkvQVVUSC1HMy9nZXRMYXN0Q1JMMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUE\n" + + "FjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwHwYDVR0RBBgwFoIUc3NsdGVzdC1yLmFj\n" + + "dGFsaXMuaXQwDQYJKoZIhvcNAQELBQADggEBAHZLND53/CZoMlDtfln0ZByCEhoF\n" + + "/XtA9cYy2azRGgS/VY4WUccvg99MM50cwn5GPRsJpoaFXeDrjV3DkOUK1jERzjx4\n" + + "5y83K/AkCGe7uU17aS+tweETizBAfHNj78oHmZDmkDSEY2STaeuHNDJ9ft0v3QTb\n" + + "VW54R5W3OBU7L/sJoEUdRxzGN7vO82PboGvyApMCWDRLKE7bPP4genQtF3XPcaFl\n" + + "ekuSiEVYS+KnM2v9tCWHqw6x7raWHFB9w1kAKNwv0hbEJkeC+a2bCdPwv8hs//sa\n" + + "gUF4p61mIpf+5qmQ6gcZOClPWyrbYdQdfCvKgbEdKhwB0v5KS0NIRRn41SE=\n" + + "-----END CERTIFICATE-----"; + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + boolean ocspEnabled = false; + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + ocspEnabled = true; + } + + // Validate valid + pathValidator.validate(new String[]{VALID, INT_VALID}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Revoked certificate is using SHA1 signature + if (ocspEnabled) { + // Revoked test certificate is expired + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("July 01, 2016"); + } + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT_REVOKED}, + ValidatePathWithParams.Status.REVOKED, + "Fri Jan 29 01:06:42 PST 2016", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/BuypassCA.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/BuypassCA.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2017, 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 8189131 + * @summary Interoperability tests with Buypass Class 2 and Class 3 CA + * @build ValidatePathWithParams + * @run main/othervm/timeout=180 -Djava.security.debug=certpath BuypassCA OCSP + * @run main/othervm/timeout=180 -Djava.security.debug=certpath BuypassCA CRL + */ + + /* + * Obtain test artifacts for Buypass Class 2 and Class 3 CAs from: + * Class 2: + * https://valid.domainplus.ca22.ssl.buypass.no/CA2Class2 (valid) + * https://revoked.domainplus.ca22.ssl.buypass.no (revoked) + * + * Class3: + * https://valid.business.ca23.ssl.buypass.no (valid) + * https://revoked.business.ca23.ssl.buypass.no (revoked) + */ +public class BuypassCA { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + boolean ocspEnabled = true; + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + ocspEnabled = false; + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + new BuypassClass2().runTest(pathValidator); + new BuypassClass3().runTest(pathValidator, ocspEnabled); + } +} + +class BuypassClass2 { + + // Owner: CN=Buypass Class 2 CA 2, O=Buypass AS-983163327, C=NO + // Issuer: CN=Buypass Class 2 Root CA, O=Buypass AS-983163327, C=NO + private static final String INT_CLASS_2 = "-----BEGIN CERTIFICATE-----\n" + + "MIIFCzCCAvOgAwIBAgIBGDANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + + "Q2xhc3MgMiBSb290IENBMB4XDTEwMTAyNjEwMTYxN1oXDTMwMTAyNjEwMTYxN1ow\n" + + "SzELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MR0w\n" + + "GwYDVQQDDBRCdXlwYXNzIENsYXNzIDIgQ0EgMjCCASIwDQYJKoZIhvcNAQEBBQAD\n" + + "ggEPADCCAQoCggEBAJyrZ8aWSw0PkdLsyswzK/Ny/A5/uU6EqQ99c6omDMpI+yNo\n" + + "HjUO42ryrATs4YHla+xj+MieWyvz9HYaCnrGL0CE4oX8M7WzD+g8h6tUCS0AakJx\n" + + "dC5PBocUkjQGZ5ZAoF92ms6C99qfQXhHx7lBP/AZT8sCWP0chOf9/cNxCplspYVJ\n" + + "HkQjKN3VGa+JISavCcBqf33ihbPZ+RaLjOTxoaRaWTvlkFxHqsaZ3AsW71qSJwaE\n" + + "55l9/qH45vn5mPrHQJ8h5LjgQcN5KBmxUMoA2iT/VSLThgcgl+Iklbcv9rs6aaMC\n" + + "JH+zKbub+RyRijmyzD9YBr+ZTaowHvJs9G59uZMCAwEAAaOB9jCB8zAPBgNVHRMB\n" + + "Af8EBTADAQH/MB8GA1UdIwQYMBaAFMmAd+BikoL1RpzzuvdMw964o605MB0GA1Ud\n" + + "DgQWBBSSrWWJsgAPy1ENwSPslE6PwQQ/dzAOBgNVHQ8BAf8EBAMCAQYwEQYDVR0g\n" + + "BAowCDAGBgRVHSAAMD0GA1UdHwQ2MDQwMqAwoC6GLGh0dHA6Ly9jcmwuYnV5cGFz\n" + + "cy5uby9jcmwvQlBDbGFzczJSb290Q0EuY3JsMD4GCCsGAQUFBwEBBDIwMDAuBggr\n" + + "BgEFBQcwAYYiaHR0cDovL29jc3AuYnV5cGFzcy5uby9vY3NwL0JQT2NzcDANBgkq\n" + + "hkiG9w0BAQsFAAOCAgEAq8IVUouNdeHQljyp8xpa9GC7rpSRXGRRTolSXNa9TUfU\n" + + "48Z0Vj3x9jT58I+I8P7fKp+p4Wdu0kcwxOXsooP8hdGLqXY4nV9amkNRiTs99xa3\n" + + "Qu/KdLeAPEeeKztxDCLXGmsC4+1G6DuDrOkwSm9Tm+HxSZRGR4Qo3mU3CCSz37us\n" + + "q7I0mnY4cCeBPQ3zW5J7k7KmMpUlxOPnLpaASY2JhoeiWIWddH6LUsMkZk1jDv+M\n" + + "Hyw2JWZUEUMCZoxLZ7F+4xP7v8wcEtICFo6tZIaawq9p/S6+mJLcoQ7wdQBM0+NA\n" + + "cc1MnSbPz75WP4cFhVf1SFq5gBBMCgzYaw+A9bJxDgqV3IMG6TtWfOWz7KhMV+EL\n" + + "iVp0fXua2GITRwr+htWnID3ShbHOtCMUm9qrqC6aWNPvJqqKLdhgU9bQ/s5o05a0\n" + + "D8NFT07l8yY6+ge+PPHOidnZrTNFIF9dtEdtyXGNrcqhZF0QvqeV1yZ/Kf2+W4pa\n" + + "Wor82CuDZNfcf0lje3guk+oZexxpIO57eGJQh9iGLM5dBeEMF7+f5j/1/rGsf6vA\n" + + "KkudpjiTl1v/GoO2zMDTTQVcjEsLSYSV0+s2p5QTXuAXrL0/ER3KQRvewIAtmzFg\n" + + "IaPy7t2TV0olHISRMvaEz4Guh2biuO/N6SP3pkk3dsMxiEVw7Xc+ouCb03Rz3aA=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=valid.domainplus.ca22.ssl.buypass.no + // Issuer: CN=Buypass Class 2 CA 2, O=Buypass AS-983163327, C=NO + // Serial number: f0673c7183c95b38c93 + // Valid from: Mon Jan 25 00:20:55 PST 2016 until: Fri Jan 25 14:59:00 PST 2019 + private static final String VALID_CLASS_2 = "-----BEGIN CERTIFICATE-----\n" + + "MIIEgzCCA2ugAwIBAgIKDwZzxxg8lbOMkzANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + + "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + + "FEJ1eXBhc3MgQ2xhc3MgMiBDQSAyMB4XDTE2MDEyNTA4MjA1NVoXDTE5MDEyNTIy\n" + + "NTkwMFowLzEtMCsGA1UEAwwkdmFsaWQuZG9tYWlucGx1cy5jYTIyLnNzbC5idXlw\n" + + "YXNzLm5vMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwhA0eVz8ADqx\n" + + "dcrIZUzCf1n+kaBFyEF4WteUMtM4ta7szTm19f1/O4LRwr+pI5qQDgWHnHMX9sit\n" + + "rKOJPfMRgWrViaQ5y9QCZ4h2BIuDe61XVGkEcUiOoNojLRvDrbjpknI69nb1wbjn\n" + + "fpmCQVjYXoandr7RsexdWG4e+s6rk5Jk/zAUzU3Vbi0lmDJ62Dd+Dk3/IVrSebOp\n" + + "eIDniRX4vjIeucnDDTQ1VqSIN+gYNR/bMxXKFbScGAG+BpgZMwetJBJhTi7zlOgR\n" + + "4zAtdvvpJNN1pmNCsmJaM25WQgH6a05cTQtgYN//MKqTDww7z+LfK37mOxh3vBTu\n" + + "TR5S6VxzQQIDAQABo4IBgzCCAX8wCQYDVR0TBAIwADAfBgNVHSMEGDAWgBSSrWWJ\n" + + "sgAPy1ENwSPslE6PwQQ/dzAdBgNVHQ4EFgQUIs9OWkfc6S1c8mbYgi6Ns1kzh0Mw\n" + + "DgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAf\n" + + "BgNVHSAEGDAWMAoGCGCEQgEaAQIEMAgGBmeBDAECATA6BgNVHR8EMzAxMC+gLaAr\n" + + "hilodHRwOi8vY3JsLmJ1eXBhc3Mubm8vY3JsL0JQQ2xhc3MyQ0EyLmNybDAvBgNV\n" + + "HREEKDAmgiR2YWxpZC5kb21haW5wbHVzLmNhMjIuc3NsLmJ1eXBhc3Mubm8wdQYI\n" + + "KwYBBQUHAQEEaTBnMC4GCCsGAQUFBzABhiJodHRwOi8vb2NzcC5idXlwYXNzLm5v\n" + + "L29jc3AvQlBPY3NwMDUGCCsGAQUFBzAChilodHRwOi8vY3J0LmJ1eXBhc3Mubm8v\n" + + "Y3J0L0JQQ2xhc3MyQ0EyLmNlcjANBgkqhkiG9w0BAQsFAAOCAQEAjDPxDQnnzH+v\n" + + "Mnj8dRM6NPBVXl4JNofWlwqzYdu+HauFeF3AOZVVyr/YbOR9/ewDrScOvrGohndV\n" + + "7Si0l5hz3fo51Ra81TyR8kWR7nJC2joidT1X4a0hF9zu8CNQNVmkOhoACgeuv42R\n" + + "NDwmj9TfpNRyC4RA7/NzXMeRJYfOrh18S9VHhCzsWScd9td3u7hrhBOPPOql9f2K\n" + + "t9Hcevo+cceE6bGYwbW6xNr3iPOh31shMxgRUMojVamtH70tYMi+0e0lrzXdxgGO\n" + + "ISnXBS2HptakUIxF3feTOjBhhh5vb9RJxfdJA///ggkR3L51MfjrusucpNoz3k3P\n" + + "f5e7ZlSJ6g==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=revoked.domainplus.ca22.ssl.buypass.no + // Issuer: CN=Buypass Class 2 CA 2, O=Buypass AS-983163327, C=NO + // Serial number: f07a517dfc19ea8bf8f + // Valid from: Mon Jan 25 00:22:09 PST 2016 until: Fri Jan 25 14:59:00 PST 2019 + private static final String REVOKED_CLASS_2 = "-----BEGIN CERTIFICATE-----\n" + + "MIIEhzCCA2+gAwIBAgIKDwelF9/Bnqi/jzANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + + "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + + "FEJ1eXBhc3MgQ2xhc3MgMiBDQSAyMB4XDTE2MDEyNTA4MjIwOVoXDTE5MDEyNTIy\n" + + "NTkwMFowMTEvMC0GA1UEAwwmcmV2b2tlZC5kb21haW5wbHVzLmNhMjIuc3NsLmJ1\n" + + "eXBhc3Mubm8wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDjp/5BLRjH\n" + + "03XNNT2YXqg+txclRaUu88Rjbj4oEudFbkGTl+oBhmXX4QjM4WGvgw1AHW7nePWF\n" + + "/j3aR1kWJCl/ZOe097mb0V0dIwK6u6RVx9ERd4ITa/cmUJjy1+D+vCsT0elJY1vf\n" + + "vbwCdaloS7MZDG3wmJGxrUz7fo7t/JdsW481Ymau3xVTQ+45MusPmOE8RZ6nggIQ\n" + + "dZIA00XPhlQwg5ivuPwtcNNZIkk1fkU+5J+RUOI5qHA9zH2s1Hly6PzTATCxSDSi\n" + + "zqAmBH0ehrWqCWiKH5P3J8dCRA6qa2n5pD71CweLrUsbmztkBHUlYKlZ0fP6bGiI\n" + + "ZDMBLL/aFQybAgMBAAGjggGFMIIBgTAJBgNVHRMEAjAAMB8GA1UdIwQYMBaAFJKt\n" + + "ZYmyAA/LUQ3BI+yUTo/BBD93MB0GA1UdDgQWBBQZICByGObE/pJISOcMavbKRl2L\n" + + "+zAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMC\n" + + "MB8GA1UdIAQYMBYwCgYIYIRCARoBAgQwCAYGZ4EMAQIBMDoGA1UdHwQzMDEwL6At\n" + + "oCuGKWh0dHA6Ly9jcmwuYnV5cGFzcy5uby9jcmwvQlBDbGFzczJDQTIuY3JsMDEG\n" + + "A1UdEQQqMCiCJnJldm9rZWQuZG9tYWlucGx1cy5jYTIyLnNzbC5idXlwYXNzLm5v\n" + + "MHUGCCsGAQUFBwEBBGkwZzAuBggrBgEFBQcwAYYiaHR0cDovL29jc3AuYnV5cGFz\n" + + "cy5uby9vY3NwL0JQT2NzcDA1BggrBgEFBQcwAoYpaHR0cDovL2NydC5idXlwYXNz\n" + + "Lm5vL2NydC9CUENsYXNzMkNBMi5jZXIwDQYJKoZIhvcNAQELBQADggEBAAdjMdlP\n" + + "qYNK+YkrqTgQV0dblIazL/cIhMPByjnEkfxew9tDxpcMWafIFKcgM/QxYJG/mzoL\n" + + "sSQ9pzzuGLQX7eAPA3rlWoQBusOeOaC3HQqy73kGStd7H8HPa3m+q47Z6JG0w+Fb\n" + + "rk8odrml+8rAEPLBlldB39xJuNVHjmlyTEDSC4azEXjfV4+kj8uE86sm+AoTt4Ba\n" + + "tEZSbKp70oH63QKBAEHORMM4gXeP+WG276p3kTcL1VUfgQw7vVmGN0C8DjhK4BAC\n" + + "0PUChr8agu0F5YcqpGxjLemMnDrqW+Bi/JYmGhEjWTiLSyYSlvJb1dAFUyPlc958\n" + + "pmOu5xTMEatiPFI=\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID_CLASS_2, INT_CLASS_2}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED_CLASS_2, INT_CLASS_2}, + ValidatePathWithParams.Status.REVOKED, + "Mon Jan 25 00:24:47 PST 2016", System.out); + } +} + +class BuypassClass3 { + + // Owner: CN=Buypass Class 3 CA 2, O=Buypass AS-983163327, C=NO + // Issuer: CN=Buypass Class 3 Root CA, O=Buypass AS-983163327, C=NO + private static final String INT_CLASS_3 = "-----BEGIN CERTIFICATE-----\n" + + "MIIFCzCCAvOgAwIBAgIBGDANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + + "Q2xhc3MgMyBSb290IENBMB4XDTEwMTAyNjA5MTYxN1oXDTMwMTAyNjA5MTYxN1ow\n" + + "SzELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MR0w\n" + + "GwYDVQQDDBRCdXlwYXNzIENsYXNzIDMgQ0EgMjCCASIwDQYJKoZIhvcNAQEBBQAD\n" + + "ggEPADCCAQoCggEBAL1OFdoURRXuCuwTBJpuCKDE8Euzcg0AeCRGq3VdagbChyCE\n" + + "CQ5vYWwmpHCyFl1b+r2KyWdQBBdG+msAcIYZal5cjZzrTWvbkfiAD/OneMjhqYB0\n" + + "pTQIXbTjpPUMOjFM8waNZcqGJqC9H+Z9NkjK5THAK0oOOfKNPHg1MeImbOHVw0fR\n" + + "48WnNrPpnQDt+SbPFSvw+dACDAybx1XgjMPq7pmZDWbkajOz4yCvrgZm6jvAPeT3\n" + + "qkBFh7zOZ3IZVdfmRjVahx0iXp5TJ1SsrRr/uCiae1O+NR//XDG3dl9j17HsFlhY\n" + + "Rl6EvEfVV0OcW94Ret9uBUF73ANZl0b+gwCXnV0CAwEAAaOB9jCB8zAPBgNVHRMB\n" + + "Af8EBTADAQH/MB8GA1UdIwQYMBaAFEe4zf/lb+74suwvTg75JbCOPGvDMB0GA1Ud\n" + + "DgQWBBQiMC7S+/ZLysC4O9IExOly5pebDDAOBgNVHQ8BAf8EBAMCAQYwEQYDVR0g\n" + + "BAowCDAGBgRVHSAAMD0GA1UdHwQ2MDQwMqAwoC6GLGh0dHA6Ly9jcmwuYnV5cGFz\n" + + "cy5uby9jcmwvQlBDbGFzczNSb290Q0EuY3JsMD4GCCsGAQUFBwEBBDIwMDAuBggr\n" + + "BgEFBQcwAYYiaHR0cDovL29jc3AuYnV5cGFzcy5uby9vY3NwL0JQT2NzcDANBgkq\n" + + "hkiG9w0BAQsFAAOCAgEAaOLyxpj2t9k9Rzkxkcj/teTNOWxBLPZDi+eFx3u7laf2\n" + + "mX/ZUSSE4g7OiKnD7ozWk9Qgocn3rBWGDKsp676RwWV97Elofz73Oebei6P3Gg/9\n" + + "CD8y6rf8xHRxru5d1ZQ1NkWdPwYI38jlt3LaDjJKZjJW7pOPIMRvw1Y1AY3mYgCJ\n" + + "Qqpw8jgukHIP0454DPzkUXzg/ZVJG0swmFmjYfARleSPidcs5BJx5ngpcUS4745g\n" + + "mN9PQ578+ROIbML4Jx83myivlyTQSPdYSwzSswb1RVBJmiF9qC0B1hivCrs4BATu\n" + + "YeaPV6CiNDr0jGnbxAskz7QDNR6uJSUKX3L9iY2TB/4/5hJ9TZ/YDI6OEG/wVtBz\n" + + "5FkU0ucztyQa4UG1mXR8Zbs/zt9Fj0Xn8f5IM3dB/s/r8c1AFDIcLRUqP/LkI9Wj\n" + + "XovWr79PEJcIfIln0AfzYfBBxCRE+4QHcVhci6p/mbyl2a+Rf8ZGNTiDLaWSZp5x\n" + + "jqdaq5UQaoZK8XQ+JVR0etep/KPgVMXq5Zv16YEb2vjs//RfxT8psDZLe/37+Bs4\n" + + "AG9sdT/bsH7HDQwodTon/HvMmxt4EiU/1Sjco4Fok9VmSE2UVjIghajbbTSKR3LV\n" + + "UuU19x12fKp+htO8L+wVlGgxXb9WvDBNHCe6RmR4jqavmvrAyCPtrx3cXwqGmXA=\n" + + "-----END CERTIFICATE-----"; + + // Owner: SERIALNUMBER=983163327, CN=valid.business.ca23.ssl.buypass.no, + // O=BUYPASS AS, L=OSLO, OID.2.5.4.17=0484, C=NO + // Issuer: CN=Buypass Class 3 CA 2, O=Buypass AS-983163327, C=NO + // Serial number: 97631b91e98293b35c8 + // Valid from: Fri Feb 06 00:57:04 PST 2015 until: Fri Feb 09 14:59:00 PST 2018 + private static final String VALID_CLASS_3 = "-----BEGIN CERTIFICATE-----\n" + + "MIIE1DCCA7ygAwIBAgIKCXYxuR6YKTs1yDANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + + "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + + "FEJ1eXBhc3MgQ2xhc3MgMyBDQSAyMB4XDTE1MDIwNjA4NTcwNFoXDTE4MDIwOTIy\n" + + "NTkwMFowgYExCzAJBgNVBAYTAk5PMQ0wCwYDVQQRDAQwNDg0MQ0wCwYDVQQHDARP\n" + + "U0xPMRMwEQYDVQQKDApCVVlQQVNTIEFTMSswKQYDVQQDDCJ2YWxpZC5idXNpbmVz\n" + + "cy5jYTIzLnNzbC5idXlwYXNzLm5vMRIwEAYDVQQFEwk5ODMxNjMzMjcwggEiMA0G\n" + + "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbahUoF2A7upqIxDQKraZ+aEOzNkHF\n" + + "1fIQEtUMQS1OTB8la7pWsBnv1gk9Ja2ifIrwdSxAjefL3SXR47h4vxUMnufMnkTk\n" + + "PERXft/XR8/jZQZRpznnN/V89ctb8qcVhHCooTIELOBzF9QAmDnawZQogwhDNLNy\n" + + "kLtWsl75X547DS/Z5hsqCqXPyOiFzkHY59uamYu48TF9d7HwQ741H0YhehoxTl/O\n" + + "YqzW2wqYxqhQuCX5IuYER7G/P3G6UAm+VB9aujtWW+TBT9+iWh0aT+C7ezDtREse\n" + + "lwb44svf8S3iW18KlSF8EMT0qwqNpA8njOCQiSgluYD+Uk9E5f8505UzAgMBAAGj\n" + + "ggGBMIIBfTAJBgNVHRMEAjAAMB8GA1UdIwQYMBaAFCIwLtL79kvKwLg70gTE6XLm\n" + + "l5sMMB0GA1UdDgQWBBQncKIaP6HdQV8RIBO+dddWDSKvJjAOBgNVHQ8BAf8EBAMC\n" + + "BaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMB8GA1UdIAQYMBYwCgYI\n" + + "YIRCARoBAwQwCAYGZ4EMAQICMDoGA1UdHwQzMDEwL6AtoCuGKWh0dHA6Ly9jcmwu\n" + + "YnV5cGFzcy5uby9jcmwvQlBDbGFzczNDQTIuY3JsMC0GA1UdEQQmMCSCInZhbGlk\n" + + "LmJ1c2luZXNzLmNhMjMuc3NsLmJ1eXBhc3Mubm8wdQYIKwYBBQUHAQEEaTBnMC4G\n" + + "CCsGAQUFBzABhiJodHRwOi8vb2NzcC5idXlwYXNzLm5vL29jc3AvQlBPY3NwMDUG\n" + + "CCsGAQUFBzAChilodHRwOi8vY3J0LmJ1eXBhc3Mubm8vY3J0L0JQQ2xhc3MzQ0Ey\n" + + "LmNlcjANBgkqhkiG9w0BAQsFAAOCAQEAqeA3IqMPn/az52twbNnimXIhIb7tWj7U\n" + + "NSBqr+httoQvNo7NbtVCgO/fM3/t0YN7rgZfP07QTn7L7CwoddrgHbnuCuFr9UhD\n" + + "df7cfY3cwDhWx+YKgXTkRZpXXrOPqeY2+9gaJlcQCnw66t5EBa4lSBnN0ZtkB4lT\n" + + "ujFP6BAyzZAjRdXWUidtErDWZri1uLmWAP0kQNez2toOcQ0XpbrbL8+nQtvOVOJv\n" + + "b/c8WoaoC14C32mAeC5bx4dQ3mpf3hQv9man1SPjY/rsDsWWjsaJAijl3YPtP2bU\n" + + "JRCCM7qfZWrY8/uBLG2llfjviKV9I6sT76w7TnawPsz+SkDXFm/nwg==\n" + + "-----END CERTIFICATE-----"; + + // Owner: SERIALNUMBER=983163327, CN=revoked.business.ca23.ssl.buypass.no, + // O=BUYPASS AS, L=OSLO, OID.2.5.4.17=0402, C=NO + // Issuer: CN=Buypass Class 3 CA 2, O=Buypass AS-983163327, C=NO + private static final String REVOKED_CLASS_3 = "-----BEGIN CERTIFICATE-----\n" + + "MIIE2DCCA8CgAwIBAgIKARno/wYhPtNtmjANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + + "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + + "FEJ1eXBhc3MgQ2xhc3MgMyBDQSAyMB4XDTEzMDIwMTA5MTE0NFoXDTE2MDIwMTA5\n" + + "MTE0NFowgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQRDAQwNDAyMQ0wCwYDVQQHDARP\n" + + "U0xPMRMwEQYDVQQKDApCVVlQQVNTIEFTMS0wKwYDVQQDDCRyZXZva2VkLmJ1c2lu\n" + + "ZXNzLmNhMjMuc3NsLmJ1eXBhc3Mubm8xEjAQBgNVBAUTCTk4MzE2MzMyNzCCASIw\n" + + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMmBUI0wNCz4kLikR5wog4QTUEmO\n" + + "XoGgjnQv0cKfDogbewK+0ngdyyR8dZOqSauQTGLlPTpo6DEWpD3Jqrr444MV6Vc1\n" + + "AGWnjk3T+KT5tKl6qJOQq17Y+HEnsTEzCo1kieVygpSu7FBa2OnhHNmLWThhGUEi\n" + + "mLqrEyfjMSb9zacvo06Zr7S8BauLRB3aM5BeMVF7Bj/9f/FvnB/y1cRDLG32WRCx\n" + + "K9IAFwCaJkfWsXx+bnaO4uEQwLFZ96p7L5mr+QNvI6QuweIY1hDM3RDM6HQkGTK9\n" + + "8iHSzGBSCGwOM24Ym3XM5vTbiV5uLno+QEYlJL/+qbYvarbO2gPF+6A6M10CAwEA\n" + + "AaOCAYMwggF/MAkGA1UdEwQCMAAwHwYDVR0jBBgwFoAUIjAu0vv2S8rAuDvSBMTp\n" + + "cuaXmwwwHQYDVR0OBBYEFNI2C2XKZkNRHZrHLkBhCMeDRN0KMA4GA1UdDwEB/wQE\n" + + "AwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwHwYDVR0gBBgwFjAK\n" + + "BghghEIBGgEDBDAIBgZngQwBAgIwOgYDVR0fBDMwMTAvoC2gK4YpaHR0cDovL2Ny\n" + + "bC5idXlwYXNzLm5vL2NybC9CUENsYXNzM0NBMi5jcmwwLwYDVR0RBCgwJoIkcmV2\n" + + "b2tlZC5idXNpbmVzcy5jYTIzLnNzbC5idXlwYXNzLm5vMHUGCCsGAQUFBwEBBGkw\n" + + "ZzAuBggrBgEFBQcwAYYiaHR0cDovL29jc3AuYnV5cGFzcy5uby9vY3NwL0JQT2Nz\n" + + "cDA1BggrBgEFBQcwAoYpaHR0cDovL2NydC5idXlwYXNzLm5vL2NydC9CUENsYXNz\n" + + "M0NBMi5jZXIwDQYJKoZIhvcNAQELBQADggEBAGNQe9cgrw/mN7bChof205NRS+TH\n" + + "A8f0JcKk1KrPYYW+ilyp6j3My26Sm9a4ZyKRhAS8fCxYUXWzfNvJNFYv2ttLuegl\n" + + "SFfeXjSJJZW9+wC5oRLta++62UTTxXp0Zf5UkMsHZCIjvnk0yGWZa0phyRCH89ca\n" + + "4vfRTOGNTNfX3d0jm/+fm70UNYHKZ/VcxVj0vH2Ij/kDUy7r2cw1gQ65RDUotnTu\n" + + "Yt59y3COyMZeYNMcuoss2XWnedFoD7fwCSkNqVbwjCxGVkL1+ivbWhqlCefaniZX\n" + + "Wy35oP1635RSxHbCMU9msmUO7FS8n1VH2edEC797gduK5pn2aBhy/MW0unU=\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID_CLASS_3, INT_CLASS_3}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + if (ocspEnabled) { + // Revoked test certificate is expired + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("July 01, 2013"); + } + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED_CLASS_3, INT_CLASS_3}, + ValidatePathWithParams.Status.REVOKED, + "Wed Feb 06 02:56:32 PST 2013", System.out); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ComodoCA.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ComodoCA.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,674 @@ +/* + * Copyright (c) 2017, 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 8189131 + * @summary Interoperability tests with Comodo RSA, ECC, userTrust RSA, and + * userTrust ECC CAs + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath ComodoCA OCSP + * @run main/othervm -Djava.security.debug=certpath ComodoCA CRL + */ + + /* + * Obtain TLS test artifacts for Comodo CAs from: + * + * Valid TLS Certificates: + * https://comodorsacertificationauthority-ev.comodoca.com + * https://comodoecccertificationauthority-ev.comodoca.com + * https://usertrustrsacertificationauthority-ev.comodoca.com + * https://usertrustecccertificationauthority-ev.comodoca.com + * + * Revoked TLS Certificates: + * https://comodorsacertificationauthority-ev.comodoca.com:444 + * https://comodoecccertificationauthority-ev.comodoca.com:444 + * https://usertrustrsacertificationauthority-ev.comodoca.com:444 + * https://usertrustecccertificationauthority-ev.comodoca.com:444 + */ +public class ComodoCA { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + new ComodoRSA().runTest(pathValidator); + new ComodoECC().runTest(pathValidator); + new ComodoUserTrustRSA().runTest(pathValidator); + new ComodoUserTrustECC().runTest(pathValidator); + } +} + +class ComodoRSA { + + // Owner: CN=COMODO RSA Extended Validation Secure Server CA, + // O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB + // Issuer: CN=COMODO RSA Certification Authority, O=COMODO CA Limited, + // L=Salford, ST=Greater Manchester, C=GB + // Serial number: 6a74380d4ebfed435b5a3f7e16abdd8 + // Valid from: Sat Feb 11 16:00:00 PST 2012 until: Thu Feb 11 15:59:59 PST 2027 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGDjCCA/agAwIBAgIQBqdDgNTr/tQ1taP34Wq92DANBgkqhkiG9w0BAQwFADCB\n" + + "hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV\n" + + "BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTIwMjEy\n" + + "MDAwMDAwWhcNMjcwMjExMjM1OTU5WjCBkjELMAkGA1UEBhMCR0IxGzAZBgNVBAgT\n" + + "EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR\n" + + "Q09NT0RPIENBIExpbWl0ZWQxODA2BgNVBAMTL0NPTU9ETyBSU0EgRXh0ZW5kZWQg\n" + + "VmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC\n" + + "AQ8AMIIBCgKCAQEAlVbeVLTf1QJJe9FbXKKyHo+cK2JMK40SKPMalaPGEP0p3uGf\n" + + "CzhAk9HvbpUQ/OGQF3cs7nU+e2PsYZJuTzurgElr3wDqAwB/L3XVKC/sVmePgIOj\n" + + "vdwDmZOLlJFWW6G4ajo/Br0OksxgnP214J9mMF/b5pTwlWqvyIqvgNnmiDkBfBzA\n" + + "xSr3e5Wg8narbZtyOTDr0VdVAZ1YEZ18bYSPSeidCfw8/QpKdhQhXBZzQCMZdMO6\n" + + "WAqmli7eNuWf0MLw4eDBYuPCGEUZUaoXHugjddTI0JYT/8ck0YwLJ66eetw6YWNg\n" + + "iJctXQUL5Tvrrs46R3N2qPos3cCHF+msMJn4HwIDAQABo4IBaTCCAWUwHwYDVR0j\n" + + "BBgwFoAUu69+Aj36pvE8hI6t7jiY7NkyMtQwHQYDVR0OBBYEFDna/8ooFIqodBMI\n" + + "ueQOqdL6fp1pMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgEAMD4G\n" + + "A1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1odHRwczovL3NlY3VyZS5j\n" + + "b21vZG8uY29tL0NQUzBMBgNVHR8ERTBDMEGgP6A9hjtodHRwOi8vY3JsLmNvbW9k\n" + + "b2NhLmNvbS9DT01PRE9SU0FDZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDBxBggr\n" + + "BgEFBQcBAQRlMGMwOwYIKwYBBQUHMAKGL2h0dHA6Ly9jcnQuY29tb2RvY2EuY29t\n" + + "L0NPTU9ET1JTQUFkZFRydXN0Q0EuY3J0MCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz\n" + + "cC5jb21vZG9jYS5jb20wDQYJKoZIhvcNAQEMBQADggIBAERCnUFRK0iIXZebeV4R\n" + + "AUpSGXtBLMeJPNBy3IX6WK/VJeQT+FhlZ58N/1eLqYVeyqZLsKeyLeCMIs37/3mk\n" + + "jCuN/gI9JN6pXV/kD0fQ22YlPodHDK4ixVAihNftSlka9pOlk7DgG4HyVsTIEFPk\n" + + "1Hax0VtpS3ey4E/EhOfUoFDuPPpE/NBXueEoU/1Tzdy5H3pAvTA/2GzS8+cHnx8i\n" + + "teoiccsq8FZ8/qyo0QYPFBRSTP5kKwxpKrgNUG4+BAe/eiCL+O5lCeHHSQgyPQ0o\n" + + "fkkdt0rvAucNgBfIXOBhYsvss2B5JdoaZXOcOBCgJjqwyBZ9kzEi7nQLiMBciUEA\n" + + "KKlHMd99SUWa9eanRRrSjhMQ34Ovmw2tfn6dNVA0BM7pINae253UqNpktNEvWS5e\n" + + "ojZh1CSggjMziqHRbO9haKPl0latxf1eYusVqHQSTC8xjOnB3xBLAer2VBvNfzu9\n" + + "XJ/B288ByvK6YBIhMe2pZLiySVgXbVrXzYxtvp5/4gJYp9vDLVj2dAZqmvZh+fYA\n" + + "tmnYOosxWd2R5nwnI4fdAw+PKowegwFOAWEMUnNt/AiiuSpm5HZNMaBWm9lTjaK2\n" + + "jwLI5jqmBNFI+8NKAnb9L9K8E7bobTQk+p0pisehKxTxlgBzuRPpwLk6R1YCcYAn\n" + + "pLwltum95OmYdBbxN4SBB7SC\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=COMODO RSA Extended Validation Secure Server CA, + // O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB + // Issuer: CN=COMODO RSA Certification Authority, O=COMODO CA Limited, + // L=Salford, ST=Greater Manchester, C=GB + // Serial number: 6a74380d4ebfed435b5a3f7e16abdd8 + // Valid from: Sat Feb 11 16:00:00 PST 2012 until: Thu Feb 11 15:59:59 PST 2027 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIH8jCCBtqgAwIBAgIQcgqiz6QAlFISJPkBqYSxZzANBgkqhkiG9w0BAQsFADCB\n" + + "kjELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxODA2BgNV\n" + + "BAMTL0NPTU9ETyBSU0EgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVy\n" + + "IENBMB4XDTE3MDYzMDAwMDAwMFoXDTE5MDkyOTIzNTk1OVowggFdMREwDwYDVQQF\n" + + "EwgwNDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJpdmF0\n" + + "ZSBPcmdhbml6YXRpb24xCzAJBgNVBAYTAkdCMQ8wDQYDVQQREwZNNSAzRVExGzAZ\n" + + "BgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEWMBQG\n" + + "A1UECRMNVHJhZmZvcmQgUm9hZDEWMBQGA1UECRMNRXhjaGFuZ2UgUXVheTElMCMG\n" + + "A1UECRMcM3JkIEZsb29yLCAyNiBPZmZpY2UgVmlsbGFnZTEaMBgGA1UEChMRQ09N\n" + + "T0RPIENBIExpbWl0ZWQxGjAYBgNVBAsTEUNPTU9ETyBFViBTR0MgU1NMMTgwNgYD\n" + + "VQQDEy9jb21vZG9yc2FjZXJ0aWZpY2F0aW9uYXV0aG9yaXR5LWV2LmNvbW9kb2Nh\n" + + "LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAND/eZQBTjpBDsut\n" + + "eKwl+zpTitF8tJzwHAhcQHC2AaLF/GJl1rnjx4OfelMhKhN1Od9KU6onHGOd2w4m\n" + + "D4EiYK9TpXwuwTyzfkCmnkqxZjYK3KAJN013o4L+8y1zsGVUulpN/GfMaxTb4Xdm\n" + + "eSekTP91Phw3xezijBq3sa++1rO5RBaT1IHeHhHviC9WNrG8CIg/j5MyC9i43LZH\n" + + "iRXLER1LzT/MCIRsiG5AEbiYXV5BNd5SiiHtBJ1q0ZJH+AxL2ERaT41VCppboZwT\n" + + "hmJGGoky9FWjp6z8U6Enx0fAMJIZNEzW6LAJFKPEynEU004jFFCEumPUqqCC4ogx\n" + + "ulphY80CAwEAAaOCA3QwggNwMB8GA1UdIwQYMBaAFDna/8ooFIqodBMIueQOqdL6\n" + + "fp1pMB0GA1UdDgQWBBQ+S4ZhIrwOoeGs9BBT4uXq89Ux/jAOBgNVHQ8BAf8EBAMC\n" + + "BaAwDAYDVR0TAQH/BAIwADAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIw\n" + + "TwYDVR0gBEgwRjA7BgwrBgEEAbIxAQIBBQEwKzApBggrBgEFBQcCARYdaHR0cHM6\n" + + "Ly9zZWN1cmUuY29tb2RvLmNvbS9DUFMwBwYFZ4EMAQEwVgYDVR0fBE8wTTBLoEmg\n" + + "R4ZFaHR0cDovL2NybC5jb21vZG9jYS5jb20vQ09NT0RPUlNBRXh0ZW5kZWRWYWxp\n" + + "ZGF0aW9uU2VjdXJlU2VydmVyQ0EuY3JsMIGHBggrBgEFBQcBAQR7MHkwUQYIKwYB\n" + + "BQUHMAKGRWh0dHA6Ly9jcnQuY29tb2RvY2EuY29tL0NPTU9ET1JTQUV4dGVuZGVk\n" + + "VmFsaWRhdGlvblNlY3VyZVNlcnZlckNBLmNydDAkBggrBgEFBQcwAYYYaHR0cDov\n" + + "L29jc3AuY29tb2RvY2EuY29tMDoGA1UdEQQzMDGCL2NvbW9kb3JzYWNlcnRpZmlj\n" + + "YXRpb25hdXRob3JpdHktZXYuY29tb2RvY2EuY29tMIIBgAYKKwYBBAHWeQIEAgSC\n" + + "AXAEggFsAWoAdgCkuQmQtBhYFIe7E6LMZ3AKPDWYBPkb37jjd80OyA3cEAAAAVz5\n" + + "cV7GAAAEAwBHMEUCIQCpgc0Eqw3g4pr+oX88h5xgL1VEAiDpqAhbRtilgYwBbgIg\n" + + "UaIm+n8AHi55nB//Sb4Nz18GYVcfELfpIzRh1vW9HbYAdwBWFAaaL9fC7NP14b1E\n" + + "sj7HRna5vJkRXMDvlJhV1onQ3QAAAVz5cVybAAAEAwBIMEYCIQDdsgC4KZ++OP44\n" + + "X7LbUcNaxe0kFzbctF2L3bnmhp9nXQIhAM0/g+PrZBIBpYlOtzidePi8bBHrLWn2\n" + + "uBiP3pYIntl4AHcA7ku9t3XOYLrhQmkfq+GeZqMPfl+wctiDAMR7iXqo/csAAAFc\n" + + "+XFeoQAABAMASDBGAiEAoySTb/QKw7JwtZtPHnECEMzgENQSFy58Kl+Mvcd3SmcC\n" + + "IQD8cU66Ih3ejvt0OTX+lfxQPKyggQfm4Uk/lwn5LEJXbDANBgkqhkiG9w0BAQsF\n" + + "AAOCAQEAKEaSYWn3Hi8rfJS4cMTJoMkVp2vpPH2dGXySBEy67TEGRw9+f75w3q95\n" + + "r1m3P+xsR6dBoidTq/6wqUYI51lB4Fq9ylh1Stp5Gj54CuyT+S31l7lD7sl0KMsn\n" + + "HDUDQHId7hKeORYpiIZOcrKOglKdi1uiGwDgoiLKh98lUrZA6durrhH+sl69wqp2\n" + + "0XAu+3hurXzCoZFJfyngTO1kt9qcFUAxc5LofIa9QvC6VR7dI4aAh7dUpIRlnjG3\n" + + "jJ1mUMTqWO6TFTtddb+uQjDqNgkYYYNuSax1WMEIZWbIi13EjXK1GPQUXJe6gQin\n" + + "NUq9JH9NPK6m8A1YKT+wgzfTDeaV2Q==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=comodorsacertificationauthority-ev.comodoca.com, + // OU=COMODO EV SGC SSL, O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", + // STREET=Exchange Quay, STREET=Trafford Road, L=Salford, ST=Greater Manchester, + // OID.2.5.4.17=M5 3EQ, C=GB, OID.2.5.4.15=Private Organization, + // OID.1.3.6.1.4.1.311.60.2.1.3=GB, SERIALNUMBER=04058690 + // Issuer: CN=COMODO RSA Extended Validation Secure Server CA, + // O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB + // Serial number: ff6ecae8c73f9b5ca811a1d2b14768be + // Valid from: Tue Aug 16 17:00:00 PDT 2016 until: Fri Nov 16 15:59:59 PST 2018 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIIGzCCBwOgAwIBAgIRAP9uyujHP5tcqBGh0rFHaL4wDQYJKoZIhvcNAQELBQAw\n" + + "gZIxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO\n" + + "BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMTgwNgYD\n" + + "VQQDEy9DT01PRE8gUlNBIEV4dGVuZGVkIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZl\n" + + "ciBDQTAeFw0xNjA4MTcwMDAwMDBaFw0xODExMTYyMzU5NTlaMIIBXTERMA8GA1UE\n" + + "BRMIMDQwNTg2OTAxEzARBgsrBgEEAYI3PAIBAxMCR0IxHTAbBgNVBA8TFFByaXZh\n" + + "dGUgT3JnYW5pemF0aW9uMQswCQYDVQQGEwJHQjEPMA0GA1UEERMGTTUgM0VRMRsw\n" + + "GQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxFjAU\n" + + "BgNVBAkTDVRyYWZmb3JkIFJvYWQxFjAUBgNVBAkTDUV4Y2hhbmdlIFF1YXkxJTAj\n" + + "BgNVBAkTHDNyZCBGbG9vciwgMjYgT2ZmaWNlIFZpbGxhZ2UxGjAYBgNVBAoTEUNP\n" + + "TU9ETyBDQSBMaW1pdGVkMRowGAYDVQQLExFDT01PRE8gRVYgU0dDIFNTTDE4MDYG\n" + + "A1UEAxMvY29tb2RvcnNhY2VydGlmaWNhdGlvbmF1dGhvcml0eS1ldi5jb21vZG9j\n" + + "YS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQ/3mUAU46QQ7L\n" + + "rXisJfs6U4rRfLSc8BwIXEBwtgGixfxiZda548eDn3pTISoTdTnfSlOqJxxjndsO\n" + + "Jg+BImCvU6V8LsE8s35App5KsWY2CtygCTdNd6OC/vMtc7BlVLpaTfxnzGsU2+F3\n" + + "ZnknpEz/dT4cN8Xs4owat7GvvtazuUQWk9SB3h4R74gvVjaxvAiIP4+TMgvYuNy2\n" + + "R4kVyxEdS80/zAiEbIhuQBG4mF1eQTXeUooh7QSdatGSR/gMS9hEWk+NVQqaW6Gc\n" + + "E4ZiRhqJMvRVo6es/FOhJ8dHwDCSGTRM1uiwCRSjxMpxFNNOIxRQhLpj1KqgguKI\n" + + "MbpaYWPNAgMBAAGjggOcMIIDmDAfBgNVHSMEGDAWgBQ52v/KKBSKqHQTCLnkDqnS\n" + + "+n6daTAdBgNVHQ4EFgQUPkuGYSK8DqHhrPQQU+Ll6vPVMf4wDgYDVR0PAQH/BAQD\n" + + "AgWgMAwGA1UdEwEB/wQCMAAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMC\n" + + "MEYGA1UdIAQ/MD0wOwYMKwYBBAGyMQECAQUBMCswKQYIKwYBBQUHAgEWHWh0dHBz\n" + + "Oi8vc2VjdXJlLmNvbW9kby5jb20vQ1BTMFYGA1UdHwRPME0wS6BJoEeGRWh0dHA6\n" + + "Ly9jcmwuY29tb2RvY2EuY29tL0NPTU9ET1JTQUV4dGVuZGVkVmFsaWRhdGlvblNl\n" + + "Y3VyZVNlcnZlckNBLmNybDCBhwYIKwYBBQUHAQEEezB5MFEGCCsGAQUFBzAChkVo\n" + + "dHRwOi8vY3J0LmNvbW9kb2NhLmNvbS9DT01PRE9SU0FFeHRlbmRlZFZhbGlkYXRp\n" + + "b25TZWN1cmVTZXJ2ZXJDQS5jcnQwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmNv\n" + + "bW9kb2NhLmNvbTBvBgNVHREEaDBmgi9jb21vZG9yc2FjZXJ0aWZpY2F0aW9uYXV0\n" + + "aG9yaXR5LWV2LmNvbW9kb2NhLmNvbYIzd3d3LmNvbW9kb3JzYWNlcnRpZmljYXRp\n" + + "b25hdXRob3JpdHktZXYuY29tb2RvY2EuY29tMIIBfAYKKwYBBAHWeQIEAgSCAWwE\n" + + "ggFoAWYAdQBo9pj4H2SCvjqM7rkoHUz8cVFdZ5PURNEKZ6y7T0/7xAAAAVaYyfL5\n" + + "AAAEAwBGMEQCIBW1F2heN1IccknFpDVED66I/tb4BpkqWLwqzn5dwWQXAiAzSPv7\n" + + "1zuXUelPvK6l1gOLB/6VlD7gwVGg7M3B1+Vt7wB1AFYUBpov18Ls0/XhvUSyPsdG\n" + + "drm8mRFcwO+UmFXWidDdAAABVpjJ8k0AAAQDAEYwRAIgfTjxLr4edpWLyOGi32TW\n" + + "48I3c0YWQMM5qsMe7zDzdrACIBng0I2+XksdOXoz5CKMAZGYict+TnZ/p7sRPAYo\n" + + "dl05AHYA7ku9t3XOYLrhQmkfq+GeZqMPfl+wctiDAMR7iXqo/csAAAFWmMnyzgAA\n" + + "BAMARzBFAiBiTeFCsfBnC4gKolnPUpL5S0eEkb0esucY40qhPqUnDgIhAOZrZz3G\n" + + "fLtEq73nEdAfvocUQC7IdMTEJRceb25Pk5J/MA0GCSqGSIb3DQEBCwUAA4IBAQBB\n" + + "YldVJKeAwqpPejxa0h3n3G8WefmAJXJtBcMKMDZ8thofgOyVDnVTkNVtY5UwwV8D\n" + + "a0bt0UhCzr88v7BrZ8PNci3qiTQgGz9q27s4x64og47sGREoil/0h3xdZ8cWVsAa\n" + + "i/aIHD0frCktX/PUZClpAuTQwJgKHurl1Apn1+RVZ3gozebOOopXmopscgp3FQV0\n" + + "RqBVietPoq6koeaJKf2ux102yW/Ef4RxXLJOLZ7ynV4tbIGyz4q+RhXbDknNrUcZ\n" + + "ugRTCaWUQ3cxtFQjA6MvY4G4eTycyiQTf/qFH5D7mrqY9ZLUuwH3AgLx49UZvQMk\n" + + "03iaUVSV6CNAsQVv4S5p\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Fri Jun 30 07:20:56 PDT 2017", System.out); + } +} + +class ComodoECC { + + // Owner: CN=COMODO ECC Extended Validation Secure Server CA, + // O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB + // Issuer: CN=COMODO ECC Certification Authority, O=COMODO CA Limited, + // L=Salford, ST=Greater Manchester, C=GB + // Serial number: 61d4643b412b5d8d715499d8553aa03 + // Valid from: Sun Apr 14 17:00:00 PDT 2013 until: Fri Apr 14 16:59:59 PDT 2028 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIDojCCAyigAwIBAgIQBh1GQ7QStdjXFUmdhVOqAzAKBggqhkjOPQQDAzCBhTEL\n" + + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT\n" + + "IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTMwNDE1MDAw\n" + + "MDAwWhcNMjgwNDE0MjM1OTU5WjCBkjELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy\n" + + "ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N\n" + + "T0RPIENBIExpbWl0ZWQxODA2BgNVBAMTL0NPTU9ETyBFQ0MgRXh0ZW5kZWQgVmFs\n" + + "aWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD\n" + + "QgAEV3AaPyeTQy0aWXXkBJMR42DsJ5pnbliJe7ndaHzCDslVlY8ofpxeFiqluZrK\n" + + "KNcJeBU/Jl1YI9jLMyMZKsfSoaOCAWkwggFlMB8GA1UdIwQYMBaAFHVxpxlIGbyd\n" + + "nepBR9+UxEh3mdN5MB0GA1UdDgQWBBTTTsMZulhZ0Rxgt2FTRzund4/4ijAOBgNV\n" + + "HQ8BAf8EBAMCAYYwEgYDVR0TAQH/BAgwBgEB/wIBADA+BgNVHSAENzA1MDMGBFUd\n" + + "IAAwKzApBggrBgEFBQcCARYdaHR0cHM6Ly9zZWN1cmUuY29tb2RvLmNvbS9DUFMw\n" + + "TAYDVR0fBEUwQzBBoD+gPYY7aHR0cDovL2NybC5jb21vZG9jYS5jb20vQ09NT0RP\n" + + "RUNDQ2VydGlmaWNhdGlvbkF1dGhvcml0eS5jcmwwcQYIKwYBBQUHAQEEZTBjMDsG\n" + + "CCsGAQUFBzAChi9odHRwOi8vY3J0LmNvbW9kb2NhLmNvbS9DT01PRE9FQ0NBZGRU\n" + + "cnVzdENBLmNydDAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29t\n" + + "MAoGCCqGSM49BAMDA2gAMGUCMQDmPWS98nREWdt4xB83r9MVvgG5INpKHi6V1dUY\n" + + "lCqvSvXXjK0QvZSrOB7cj9RavGgCMG2xJNG+SvlTWEYpmK7eXSgmRUgoBDeQ0yDK\n" + + "lnxmeeOBnnCaDIxAcA3aCj2Gtdt3sA==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=comodoecccertificationauthority-ev.comodoca.com, OU=COMODO EV SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=COMODO ECC Extended Validation Secure Server CA, O=COMODO CA Limited, + // L=Salford, ST=Greater Manchester, C=GB + // Serial number: 414e5d66ec7d15ca504213f2811d57af + // Valid from: Mon Jul 03 17:00:00 PDT 2017 until: Thu Oct 03 16:59:59 PDT 2019 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIGYDCCBgWgAwIBAgIQQU5dZux9FcpQQhPygR1XrzAKBggqhkjOPQQDAjCBkjEL\n" + + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxODA2BgNVBAMT\n" + + "L0NPTU9ETyBFQ0MgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENB\n" + + "MB4XDTE3MDcwNDAwMDAwMFoXDTE5MTAwMzIzNTk1OVowggFZMREwDwYDVQQFEwgw\n" + + "NDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJpdmF0ZSBP\n" + + "cmdhbml6YXRpb24xCzAJBgNVBAYTAkdCMQ8wDQYDVQQREwZNNSAzRVExGzAZBgNV\n" + + "BAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEWMBQGA1UE\n" + + "CRMNVHJhZmZvcmQgUm9hZDEWMBQGA1UECRMNRXhjaGFuZ2UgUXVheTElMCMGA1UE\n" + + "CRMcM3JkIEZsb29yLCAyNiBPZmZpY2UgVmlsbGFnZTEaMBgGA1UEChMRQ09NT0RP\n" + + "IENBIExpbWl0ZWQxFjAUBgNVBAsTDUNPTU9ETyBFViBTU0wxODA2BgNVBAMTL2Nv\n" + + "bW9kb2VjY2NlcnRpZmljYXRpb25hdXRob3JpdHktZXYuY29tb2RvY2EuY29tMFkw\n" + + "EwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEt26qBS7TRu/yfR+RiqLAzW2C+UspFZlO\n" + + "Rc4EhLfNYMgFkoZKjEnwJzudH6a+uRPqPOhPgUd6PFfRQFOcLjmhgaOCA3EwggNt\n" + + "MB8GA1UdIwQYMBaAFNNOwxm6WFnRHGC3YVNHO6d3j/iKMB0GA1UdDgQWBBTpZ0tz\n" + + "KscFw6Z3vCEDFzGR5VSkVzAOBgNVHQ8BAf8EBAMCBYAwDAYDVR0TAQH/BAIwADAd\n" + + "BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwTwYDVR0gBEgwRjA7BgwrBgEE\n" + + "AbIxAQIBBQEwKzApBggrBgEFBQcCARYdaHR0cHM6Ly9zZWN1cmUuY29tb2RvLmNv\n" + + "bS9DUFMwBwYFZ4EMAQEwVgYDVR0fBE8wTTBLoEmgR4ZFaHR0cDovL2NybC5jb21v\n" + + "ZG9jYS5jb20vQ09NT0RPRUNDRXh0ZW5kZWRWYWxpZGF0aW9uU2VjdXJlU2VydmVy\n" + + "Q0EuY3JsMIGHBggrBgEFBQcBAQR7MHkwUQYIKwYBBQUHMAKGRWh0dHA6Ly9jcnQu\n" + + "Y29tb2RvY2EuY29tL0NPTU9ET0VDQ0V4dGVuZGVkVmFsaWRhdGlvblNlY3VyZVNl\n" + + "cnZlckNBLmNydDAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29t\n" + + "MDoGA1UdEQQzMDGCL2NvbW9kb2VjY2NlcnRpZmljYXRpb25hdXRob3JpdHktZXYu\n" + + "Y29tb2RvY2EuY29tMIIBfQYKKwYBBAHWeQIEAgSCAW0EggFpAWcAdgCkuQmQtBhY\n" + + "FIe7E6LMZ3AKPDWYBPkb37jjd80OyA3cEAAAAV0NLqsqAAAEAwBHMEUCIAz9Jjq3\n" + + "qLUd/a2PYZnLGsEG/MrL7vab5rmGBg8RGAJxAiEA7JJnar07NIjCLLO77xJ3UFcu\n" + + "UMM3M8JgGC8wbuRwxbUAdgBWFAaaL9fC7NP14b1Esj7HRna5vJkRXMDvlJhV1onQ\n" + + "3QAAAV0NLqjmAAAEAwBHMEUCIHRvPWKr7vPMBWx1gLPkt8inPINWPNSoax178e5A\n" + + "D0cPAiEAvRL/VP4DLiyHvcU9AOqTzQXGuWCzswWKG59hSm7gS4kAdQDuS723dc5g\n" + + "uuFCaR+r4Z5mow9+X7By2IMAxHuJeqj9ywAAAV0NLqsDAAAEAwBGMEQCIFALT043\n" + + "X5IffLsxIAGXTrWgkZHf12QKgrYKXVB629eOAiAIeci2xi3fUW6mU8tT4LwyjowV\n" + + "DkrSCw1ZMo0JApsfzTAKBggqhkjOPQQDAgNJADBGAiEA7HUxjwx0MBC+4PuPx4Z1\n" + + "WpKz7jdHOMTh1sdaoVV5hNoCIQDrnjBFUopXHTvm/rj+aMFIeYejggPqv14KJOqT\n" + + "gym+uA==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=comodoecccertificationauthority-ev.comodoca.com, OU=COMODO EV SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=COMODO ECC Extended Validation Secure Server CA, O=COMODO CA Limited, + // L=Salford, ST=Greater Manchester, C=GB + // Serial number: 6923086d88824ee9800742fcb82fdaa + // Valid from: Tue Aug 16 17:00:00 PDT 2016 until: Fri Nov 16 15:59:59 PST 2018 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGizCCBjGgAwIBAgIQBpIwhtiIJO6YAHQvy4L9qjAKBggqhkjOPQQDAjCBkjEL\n" + + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxODA2BgNVBAMT\n" + + "L0NPTU9ETyBFQ0MgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENB\n" + + "MB4XDTE2MDgxNzAwMDAwMFoXDTE4MTExNjIzNTk1OVowggFZMREwDwYDVQQFEwgw\n" + + "NDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJpdmF0ZSBP\n" + + "cmdhbml6YXRpb24xCzAJBgNVBAYTAkdCMQ8wDQYDVQQREwZNNSAzRVExGzAZBgNV\n" + + "BAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEWMBQGA1UE\n" + + "CRMNVHJhZmZvcmQgUm9hZDEWMBQGA1UECRMNRXhjaGFuZ2UgUXVheTElMCMGA1UE\n" + + "CRMcM3JkIEZsb29yLCAyNiBPZmZpY2UgVmlsbGFnZTEaMBgGA1UEChMRQ09NT0RP\n" + + "IENBIExpbWl0ZWQxFjAUBgNVBAsTDUNPTU9ETyBFViBTU0wxODA2BgNVBAMTL2Nv\n" + + "bW9kb2VjY2NlcnRpZmljYXRpb25hdXRob3JpdHktZXYuY29tb2RvY2EuY29tMFkw\n" + + "EwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEt26qBS7TRu/yfR+RiqLAzW2C+UspFZlO\n" + + "Rc4EhLfNYMgFkoZKjEnwJzudH6a+uRPqPOhPgUd6PFfRQFOcLjmhgaOCA50wggOZ\n" + + "MB8GA1UdIwQYMBaAFNNOwxm6WFnRHGC3YVNHO6d3j/iKMB0GA1UdDgQWBBTpZ0tz\n" + + "KscFw6Z3vCEDFzGR5VSkVzAOBgNVHQ8BAf8EBAMCBYAwDAYDVR0TAQH/BAIwADAd\n" + + "BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwRgYDVR0gBD8wPTA7BgwrBgEE\n" + + "AbIxAQIBBQEwKzApBggrBgEFBQcCARYdaHR0cHM6Ly9zZWN1cmUuY29tb2RvLmNv\n" + + "bS9DUFMwVgYDVR0fBE8wTTBLoEmgR4ZFaHR0cDovL2NybC5jb21vZG9jYS5jb20v\n" + + "Q09NT0RPRUNDRXh0ZW5kZWRWYWxpZGF0aW9uU2VjdXJlU2VydmVyQ0EuY3JsMIGH\n" + + "BggrBgEFBQcBAQR7MHkwUQYIKwYBBQUHMAKGRWh0dHA6Ly9jcnQuY29tb2RvY2Eu\n" + + "Y29tL0NPTU9ET0VDQ0V4dGVuZGVkVmFsaWRhdGlvblNlY3VyZVNlcnZlckNBLmNy\n" + + "dDAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMG8GA1UdEQRo\n" + + "MGaCL2NvbW9kb2VjY2NlcnRpZmljYXRpb25hdXRob3JpdHktZXYuY29tb2RvY2Eu\n" + + "Y29tgjN3d3cuY29tb2RvZWNjY2VydGlmaWNhdGlvbmF1dGhvcml0eS1ldi5jb21v\n" + + "ZG9jYS5jb20wggF9BgorBgEEAdZ5AgQCBIIBbQSCAWkBZwB3AGj2mPgfZIK+Oozu\n" + + "uSgdTPxxUV1nk9RE0QpnrLtPT/vEAAABVpjKocAAAAQDAEgwRgIhAKIobm0UJdom\n" + + "Hrg1HZv6ESYoYQtlqBj5bR5Ge8RGF+7pAiEAupYu0q3X27KNIsrQpmSzfiEsCQWY\n" + + "C97ToQgEhbBNZUYAdQBWFAaaL9fC7NP14b1Esj7HRna5vJkRXMDvlJhV1onQ3QAA\n" + + "AVaYyqEdAAAEAwBGMEQCIEWbMoAJpig9oTbuW2R1x/sZwDbt0Z1iUhkbEwqhkRWu\n" + + "AiByCmEY/MEtEmVcsu3uMXtJ/SMBo1JcfFCHbPf5VleQpAB1AO5Lvbd1zmC64UJp\n" + + "H6vhnmajD35fsHLYgwDEe4l6qP3LAAABVpjKoaYAAAQDAEYwRAIgVB/p/u8amjg4\n" + + "Qlq0rKv4oYYqIVKL/kFtpeH3Lm4hpnwCIDYdBZBo2cpF+KjKDn68kqFysy7MbP9r\n" + + "h/zPjAm72GeRMAoGCCqGSM49BAMCA0gAMEUCIHL5pdruv0yoFggKHPN7PXT4BfRr\n" + + "1ksLXKgF/xANjsuFAiEA9bt7u96U5OrAzJBgSkJFmNE20vEdwoQDL+99JeX4bAc=\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Tue Jul 04 03:34:40 PDT 2017", System.out); + } +} + +class ComodoUserTrustRSA { + + // Owner: CN=USERTrust RSA Extended Validation Secure Server CA, + // O=The USERTRUST Network, L=Jersey City, ST=New Jersey, C=US + // Issuer: CN=USERTrust RSA Certification Authority, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: f6bb751efa7d2e8368e606407334f83 + // Valid from: Sat Feb 11 16:00:00 PST 2012 until: Thu Feb 11 15:59:59 PST 2027 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGGTCCBAGgAwIBAgIQD2u3Ue+n0ug2jmBkBzNPgzANBgkqhkiG9w0BAQwFADCB\n" + + "iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + + "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV\n" + + "BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTIw\n" + + "MjEyMDAwMDAwWhcNMjcwMjExMjM1OTU5WjCBlTELMAkGA1UEBhMCVVMxEzARBgNV\n" + + "BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU\n" + + "aGUgVVNFUlRSVVNUIE5ldHdvcmsxOzA5BgNVBAMTMlVTRVJUcnVzdCBSU0EgRXh0\n" + + "ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMIIBIjANBgkqhkiG9w0B\n" + + "AQEFAAOCAQ8AMIIBCgKCAQEAlJwjjGNzAgMFwLu05RnhYFJS1PpbcyPH6VZOij+z\n" + + "PyvCILGvwXC8A+EgBthY080+kIlSxrNyOdnrUfNj8IsBtBlmtOF9nMWgD0Cb4HB1\n" + + "Y/tCNas8IHMtKr6eI4nJa4NjPhTcST+GtC8r+bVGHk0QpX4LbT+Z8WeE7pXIOUGs\n" + + "9j66/hsMwgnBxkQ9xXN0jhTFITUZfnCuM0vOo5hRYlCNtwD8iaHJPaKxYe6qHSKH\n" + + "WCBK7GUQiQRngry+YKLx3YtC3k/NQIyhaTLY/gUFi57kPcpZoa0h3RGfS9MpPFoe\n" + + "mk3rGH3jwjVFxR1ep1FtP/kprzLaR1UL81gxENhWvZEWXQIDAQABo4IBbjCCAWow\n" + + "HwYDVR0jBBgwFoAUU3m/WqorSs9UgOHYm8Cd8rIDZsswHQYDVR0OBBYEFC+BT+Jm\n" + + "+rxov5lDhFKJIDqC86SlMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/\n" + + "AgEAMDoGA1UdIAQzMDEwLwYEVR0gADAnMCUGCCsGAQUFBwIBFhlodHRwczovL2Nw\n" + + "cy51c2VydHJ1c3QuY29tMFAGA1UdHwRJMEcwRaBDoEGGP2h0dHA6Ly9jcmwudXNl\n" + + "cnRydXN0LmNvbS9VU0VSVHJ1c3RSU0FDZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNy\n" + + "bDB2BggrBgEFBQcBAQRqMGgwPwYIKwYBBQUHMAKGM2h0dHA6Ly9jcnQudXNlcnRy\n" + + "dXN0LmNvbS9VU0VSVHJ1c3RSU0FBZGRUcnVzdENBLmNydDAlBggrBgEFBQcwAYYZ\n" + + "aHR0cDovL29jc3AudXNlcnRydXN0LmNvbTANBgkqhkiG9w0BAQwFAAOCAgEAa2bX\n" + + "Xf22zjY/QLzzdZwJ9JO86qH/czwCFPK4o9Cb7rixQL9S7zHw1dm3n/+Lx5kT9lqx\n" + + "wB0dqoZ8o0XwFgVcksGz7QRhEBjrB0nSUNYG8kuFaMxRWa9ze6Ovov44WDrq1uyF\n" + + "npi3eeQiwMr3xHmY76b1NX0WqvlTTFw4L5DrcIohBz1zKVkRp7LH/s5vxjDECM+/\n" + + "erdy1WTILNFv09gwz4iFyfu/WmYYNUKlQJaSoUqja/KHcqY8zYKKjq5o982Ji3Ti\n" + + "/Odkx1NJA1Yf5ivDxxRFQmij6knL1pi1wgQxGjd67V3/+HfHF7MCRWk8mXnT32B9\n" + + "1Hk3jm10GL0R6y/XFsLhv0mGkmKD1vTP7vz1hdMLlVgxEs1k5dLMybtjUJ3LuENz\n" + + "avmZ/G/vOi284ZRo/gA/YjT5CeeWgI11IHbpRDAqKy4BWhmtIi11u12i9ftPxxrD\n" + + "/VwHtC0hTTOBnYgbJAK9ZLvaJUBU22EimU4Jv3ELkeV7SWedbAdfjXolI1mCcAbq\n" + + "RgzRC+RaTloSmO2dWicDBW7KlRHmKZXrkDUAExSBY/1j9HmNcYzWv4NCTtK7t0en\n" + + "gsE/OP2b7zHrHWtC/F1JwOCrH1JkbPA7c/6nNJVY2AscGM16pIU89OL0Ez1PyZYG\n" + + "4fokbdNREXoShKClNIPbB5iY+WdSzb9CKLyb96g=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=usertrustrsacertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=USERTrust RSA Extended Validation Secure Server CA, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: ffcada019c9fb1155a32300083cb99c9 + // Valid from: Mon Jul 03 17:00:00 PDT 2017 until: Thu Oct 03 16:59:59 PDT 2019 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIIATCCBumgAwIBAgIRAP/K2gGcn7EVWjIwAIPLmckwDQYJKoZIhvcNAQELBQAw\n" + + "gZUxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5MRQwEgYDVQQHEwtK\n" + + "ZXJzZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMTswOQYD\n" + + "VQQDEzJVU0VSVHJ1c3QgUlNBIEV4dGVuZGVkIFZhbGlkYXRpb24gU2VjdXJlIFNl\n" + + "cnZlciBDQTAeFw0xNzA3MDQwMDAwMDBaFw0xOTEwMDMyMzU5NTlaMIIBYDERMA8G\n" + + "A1UEBRMIMDQwNTg2OTAxEzARBgsrBgEEAYI3PAIBAxMCR0IxHTAbBgNVBA8TFFBy\n" + + "aXZhdGUgT3JnYW5pemF0aW9uMQswCQYDVQQGEwJHQjEPMA0GA1UEERMGTTUgM0VR\n" + + "MRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQx\n" + + "FjAUBgNVBAkTDVRyYWZmb3JkIFJvYWQxFjAUBgNVBAkTDUV4Y2hhbmdlIFF1YXkx\n" + + "JTAjBgNVBAkTHDNyZCBGbG9vciwgMjYgT2ZmaWNlIFZpbGxhZ2UxGjAYBgNVBAoT\n" + + "EUNPTU9ETyBDQSBMaW1pdGVkMRowGAYDVQQLExFDT01PRE8gRVYgU0dDIFNTTDE7\n" + + "MDkGA1UEAxMydXNlcnRydXN0cnNhY2VydGlmaWNhdGlvbmF1dGhvcml0eS1ldi5j\n" + + "b21vZG9jYS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCeH+vF\n" + + "6JjCktrrnV4u8adH5ESuENaRNm2plwfD07Lskva4QvIQ9sz6/RrPjRwEdLRtBkll\n" + + "taZc26QxQxLAhvjPu3w5eXHP26/ES5++WoGXip4L/PcukUFFEcR6ujfIYpXCSh7V\n" + + "o/Y+rtR2L7uLt5Vll0DW2JzFlaj9QFT2bBsg5ip//jHNnobz3WEpv40C64R/Ebna\n" + + "9dmXyh0xOF8e4OWR9LudkxAFo7jQol5IQGGv7lMhLt3u1ZbJ78XqgRDT50cGIX0/\n" + + "JnV1eg7xq57/zSY/7QUxhOZEWwoeB7pmOiN8f1wuVHmROq0/lOqHkYFDjOne7IgE\n" + + "FTrKUqn080eR7AZRAgMBAAGjggN8MIIDeDAfBgNVHSMEGDAWgBQvgU/iZvq8aL+Z\n" + + "Q4RSiSA6gvOkpTAdBgNVHQ4EFgQUfPty8OfUth7Yz7PimXBCfuu33fwwDgYDVR0P\n" + + "AQH/BAQDAgWgMAwGA1UdEwEB/wQCMAAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsG\n" + + "AQUFBwMCMEsGA1UdIAREMEIwNwYMKwYBBAGyMQECAQUBMCcwJQYIKwYBBQUHAgEW\n" + + "GWh0dHBzOi8vY3BzLnVzZXJ0cnVzdC5jb20wBwYFZ4EMAQEwWgYDVR0fBFMwUTBP\n" + + "oE2gS4ZJaHR0cDovL2NybC51c2VydHJ1c3QuY29tL1VTRVJUcnVzdFJTQUV4dGVu\n" + + "ZGVkVmFsaWRhdGlvblNlY3VyZVNlcnZlckNBLmNybDCBjQYIKwYBBQUHAQEEgYAw\n" + + "fjBVBggrBgEFBQcwAoZJaHR0cDovL2NydC51c2VydHJ1c3QuY29tL1VTRVJUcnVz\n" + + "dFJTQUV4dGVuZGVkVmFsaWRhdGlvblNlY3VyZVNlcnZlckNBLmNydDAlBggrBgEF\n" + + "BQcwAYYZaHR0cDovL29jc3AudXNlcnRydXN0LmNvbTA9BgNVHREENjA0gjJ1c2Vy\n" + + "dHJ1c3Ryc2FjZXJ0aWZpY2F0aW9uYXV0aG9yaXR5LWV2LmNvbW9kb2NhLmNvbTCC\n" + + "AX8GCisGAQQB1nkCBAIEggFvBIIBawFpAHYApLkJkLQYWBSHuxOizGdwCjw1mAT5\n" + + "G9+443fNDsgN3BAAAAFdDU2iYQAABAMARzBFAiB0o4GnVHD8MeVQ32D0XYu+EQQW\n" + + "jvN78rmCfk0OEBxyFAIhAKgyctIn0IaDJiZzsrtAiqEnkcMtuh8o+R0Rqw1ygAjk\n" + + "AHcAVhQGmi/XwuzT9eG9RLI+x0Z2ubyZEVzA75SYVdaJ0N0AAAFdDU2gFgAABAMA\n" + + "SDBGAiEA7mcmZ8H5uHuNCdI0CVxsqDZQcZX/gVk94KckePkzQoACIQCHwm5hcvNC\n" + + "M8vNmFkboQN79DglRctHrlh143A6mUTk8QB2AO5Lvbd1zmC64UJpH6vhnmajD35f\n" + + "sHLYgwDEe4l6qP3LAAABXQ1NojoAAAQDAEcwRQIhAPqwijgE0Fr6uJ+yF+TvyXco\n" + + "Hduv9h7R5WWwJfghXiMyAiBB4+fJm4rIcOnJBZmOqFnRpIjPN0jwDqJT0nDHxaXA\n" + + "nDANBgkqhkiG9w0BAQsFAAOCAQEACXitF1bTEvV1HX11WrT/XuoMhsoPK4TS16rs\n" + + "FqztV4iXKlA1/h5qbsjYY1gVrM+/6kQkmEs5qrxsek2WNxY80NO3WAzroRJ3H9Sd\n" + + "mPn0No2P8LZ5Fs5hvaD/PfWO5xxey80c3kGyvWOej90P3IrL/1RiULyh95TrXBjI\n" + + "ddCBsZ28904wsQUrPBPMpiu0DKl1HR/em9WkcipMi+onJxxFWjucssz5PW/BzGYF\n" + + "jfWLDEI0tN5L4CWV3iVXFXOURY1Mwhtsey9jvlEyxSsys55QdKF40yGgtV9VC+os\n" + + "7hJP33+qA0cvCTaRytiPP6z/l2G/KSIXTyv6SxzGhsTFfzLAOg==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=usertrustrsacertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=USERTrust RSA Extended Validation Secure Server CA, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: 643d7e2b0112d51a05a4efb266ebd70d + // Valid from: Tue Aug 16 17:00:00 PDT 2016 until: Fri Nov 16 15:59:59 PST 2018 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIILjCCBxagAwIBAgIQZD1+KwES1RoFpO+yZuvXDTANBgkqhkiG9w0BAQsFADCB\n" + + "lTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + + "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxOzA5BgNV\n" + + "BAMTMlVTRVJUcnVzdCBSU0EgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2Vy\n" + + "dmVyIENBMB4XDTE2MDgxNzAwMDAwMFoXDTE4MTExNjIzNTk1OVowggFgMREwDwYD\n" + + "VQQFEwgwNDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJp\n" + + "dmF0ZSBPcmdhbml6YXRpb24xCzAJBgNVBAYTAkdCMQ8wDQYDVQQREwZNNSAzRVEx\n" + + "GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEW\n" + + "MBQGA1UECRMNVHJhZmZvcmQgUm9hZDEWMBQGA1UECRMNRXhjaGFuZ2UgUXVheTEl\n" + + "MCMGA1UECRMcM3JkIEZsb29yLCAyNiBPZmZpY2UgVmlsbGFnZTEaMBgGA1UEChMR\n" + + "Q09NT0RPIENBIExpbWl0ZWQxGjAYBgNVBAsTEUNPTU9ETyBFViBTR0MgU1NMMTsw\n" + + "OQYDVQQDEzJ1c2VydHJ1c3Ryc2FjZXJ0aWZpY2F0aW9uYXV0aG9yaXR5LWV2LmNv\n" + + "bW9kb2NhLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ4f68Xo\n" + + "mMKS2uudXi7xp0fkRK4Q1pE2bamXB8PTsuyS9rhC8hD2zPr9Gs+NHAR0tG0GSWW1\n" + + "plzbpDFDEsCG+M+7fDl5cc/br8RLn75agZeKngv89y6RQUURxHq6N8hilcJKHtWj\n" + + "9j6u1HYvu4u3lWWXQNbYnMWVqP1AVPZsGyDmKn/+Mc2ehvPdYSm/jQLrhH8Rudr1\n" + + "2ZfKHTE4Xx7g5ZH0u52TEAWjuNCiXkhAYa/uUyEu3e7VlsnvxeqBENPnRwYhfT8m\n" + + "dXV6DvGrnv/NJj/tBTGE5kRbCh4HumY6I3x/XC5UeZE6rT+U6oeRgUOM6d7siAQV\n" + + "OspSqfTzR5HsBlECAwEAAaOCA6owggOmMB8GA1UdIwQYMBaAFC+BT+Jm+rxov5lD\n" + + "hFKJIDqC86SlMB0GA1UdDgQWBBR8+3Lw59S2HtjPs+KZcEJ+67fd/DAOBgNVHQ8B\n" + + "Af8EBAMCBaAwDAYDVR0TAQH/BAIwADAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYB\n" + + "BQUHAwIwQgYDVR0gBDswOTA3BgwrBgEEAbIxAQIBBQEwJzAlBggrBgEFBQcCARYZ\n" + + "aHR0cHM6Ly9jcHMudXNlcnRydXN0LmNvbTBaBgNVHR8EUzBRME+gTaBLhklodHRw\n" + + "Oi8vY3JsLnVzZXJ0cnVzdC5jb20vVVNFUlRydXN0UlNBRXh0ZW5kZWRWYWxpZGF0\n" + + "aW9uU2VjdXJlU2VydmVyQ0EuY3JsMIGNBggrBgEFBQcBAQSBgDB+MFUGCCsGAQUF\n" + + "BzAChklodHRwOi8vY3J0LnVzZXJ0cnVzdC5jb20vVVNFUlRydXN0UlNBRXh0ZW5k\n" + + "ZWRWYWxpZGF0aW9uU2VjdXJlU2VydmVyQ0EuY3J0MCUGCCsGAQUFBzABhhlodHRw\n" + + "Oi8vb2NzcC51c2VydHJ1c3QuY29tMHUGA1UdEQRuMGyCMnVzZXJ0cnVzdHJzYWNl\n" + + "cnRpZmljYXRpb25hdXRob3JpdHktZXYuY29tb2RvY2EuY29tgjZ3d3cudXNlcnRy\n" + + "dXN0cnNhY2VydGlmaWNhdGlvbmF1dGhvcml0eS1ldi5jb21vZG9jYS5jb20wggF+\n" + + "BgorBgEEAdZ5AgQCBIIBbgSCAWoBaAB2AGj2mPgfZIK+OozuuSgdTPxxUV1nk9RE\n" + + "0QpnrLtPT/vEAAABVpjLYnEAAAQDAEcwRQIhAL6/noD1PEwlZBByj9MKJSXPrEpW\n" + + "jpL335zhD+hrmvuqAiBizohmz9W29E8DoEuhca5PzKL8lSl5DpAOUGjMN0ihmgB2\n" + + "AFYUBpov18Ls0/XhvUSyPsdGdrm8mRFcwO+UmFXWidDdAAABVpjLYOgAAAQDAEcw\n" + + "RQIhAIRRWFG7M/XEgivLEdgEHWVNN7hk2QdVTvjr1DfRV2c3AiADq0LWpJ3dV7Je\n" + + "2Z3zKvqJEmRFNj5Pn9TwsIcEe1iNNgB2AO5Lvbd1zmC64UJpH6vhnmajD35fsHLY\n" + + "gwDEe4l6qP3LAAABVpjLYZ8AAAQDAEcwRQIge8b8UhHJWJ8/XWGIg6rQpaVXGP6q\n" + + "evL01KFNB28t8VQCIQCzddHCr/LLTVE+dB4kZHxuW5pOB+AtZlrAAQcuLoEauDAN\n" + + "BgkqhkiG9w0BAQsFAAOCAQEAPYqfbjlMjMJ2CEoIOUih/1BBnzXXkmmqXsXFI9gJ\n" + + "/tV1u4OzYOXHwOPhy/1JHv5dtNDSzyoeagYcjxEpl64kAJHrtzYwFlrqCU1xSIwd\n" + + "qrfmupyc5JwRqGE0Q01lryCxflUikh/pyDBtsxED4r+Topb+QwVZCzIMtOr49/S9\n" + + "GHA7HJo6nwSoV6rfrnLDCtcJN4ezEzOs7MOOq9K1MiAoAOXa/maelXwqbNGVpN2p\n" + + "HihRuBRDqusdS8zNGPxhvbviCDf8mJRvFoPgk/5o6mxf6bKfjmtkWOxMApvJU3Nd\n" + + "ib1aMX9KArEiNFwHFxOSYmE8c8x/zhLlk1btOo7gQrVNyw==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Tue Jul 04 04:09:55 PDT 2017", System.out); + } +} + +class ComodoUserTrustECC { + + // Owner: CN=USERTrust ECC Extended Validation Secure Server CA, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Issuer: CN=USERTrust ECC Certification Authority, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: 3d09b24f5c08a7ce8eb85a51d3c1aa52 + // Valid from: Sun Apr 14 17:00:00 PDT 2013 until: Fri Apr 14 16:59:59 PDT 2028 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIDwTCCA0igAwIBAgIQPQmyT1wIp86OuFpR08GqUjAKBggqhkjOPQQDAzCBiDEL\n" + + "MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl\n" + + "eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT\n" + + "JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTMwNDE1\n" + + "MDAwMDAwWhcNMjgwNDE0MjM1OTU5WjCBlTELMAkGA1UEBhMCVVMxEzARBgNVBAgT\n" + + "Ck5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVUaGUg\n" + + "VVNFUlRSVVNUIE5ldHdvcmsxOzA5BgNVBAMTMlVTRVJUcnVzdCBFQ0MgRXh0ZW5k\n" + + "ZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMFkwEwYHKoZIzj0CAQYIKoZI\n" + + "zj0DAQcDQgAEkSRGk0F0N82ZCZ+kVZ/StqVUiWRirw1ebViS06+j+HgS9xZKRGh7\n" + + "bqSas/gNMyg1LZusGu5IvEmXmNC5hzOT06OCAYMwggF/MB8GA1UdIwQYMBaAFDrh\n" + + "CYbUzxnClnZ0SXbc4DXGY2OaMB0GA1UdDgQWBBQqnFr5TqEw2kBLK+lL8fWc3AL5\n" + + "LjAOBgNVHQ8BAf8EBAMCAYYwEgYDVR0TAQH/BAgwBgEB/wIBADA/BgNVHSAEODA2\n" + + "MDQGBFUdIAAwLDAqBggrBgEFBQcCARYeaHR0cHM6Ly9jcHMudHJ1c3QtcHJvdmlk\n" + + "ZXIuY29tMFUGA1UdHwROMEwwSqBIoEaGRGh0dHA6Ly9jcmwudHJ1c3QtcHJvdmlk\n" + + "ZXIuY29tL1VTRVJUcnVzdEVDQ0NlcnRpZmljYXRpb25BdXRob3JpdHkuY3JsMIGA\n" + + "BggrBgEFBQcBAQR0MHIwRAYIKwYBBQUHMAKGOGh0dHA6Ly9jcnQudHJ1c3QtcHJv\n" + + "dmlkZXIuY29tL1VTRVJUcnVzdEVDQ0FkZFRydXN0Q0EuY3J0MCoGCCsGAQUFBzAB\n" + + "hh5odHRwOi8vb2NzcC50cnVzdC1wcm92aWRlci5jb20wCgYIKoZIzj0EAwMDZwAw\n" + + "ZAIwSzIqrW8TN9/aCfkhUtz0t8IIK+Z46z3wm+crwjThpQ/VoPgTNbvP/lGTi1xR\n" + + "qJvLAjBFa27l4uqeAQZHNJnIx1Mu9OXzoJelx1cYP7ToQUms/g+PK77yImJcXUU3\n" + + "s1rWGRU=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=usertrustecccertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=USERTrust ECC Extended Validation Secure Server CA, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: 9bd0c93cac9ca2edc1a7dd923316b3c6 + // Valid from: Mon Jul 03 17:00:00 PDT 2017 until: Thu Oct 03 16:59:59 PDT 2019 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIGhzCCBi2gAwIBAgIRAJvQyTysnKLtwafdkjMWs8YwCgYIKoZIzj0EAwIwgZUx\n" + + "CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5MRQwEgYDVQQHEwtKZXJz\n" + + "ZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMTswOQYDVQQD\n" + + "EzJVU0VSVHJ1c3QgRUNDIEV4dGVuZGVkIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZl\n" + + "ciBDQTAeFw0xNzA3MDQwMDAwMDBaFw0xOTEwMDMyMzU5NTlaMIIBYDERMA8GA1UE\n" + + "BRMIMDQwNTg2OTAxEzARBgsrBgEEAYI3PAIBAxMCR0IxHTAbBgNVBA8TFFByaXZh\n" + + "dGUgT3JnYW5pemF0aW9uMQswCQYDVQQGEwJHQjEPMA0GA1UEERMGTTUgM0VRMRsw\n" + + "GQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxFjAU\n" + + "BgNVBAkTDVRyYWZmb3JkIFJvYWQxFjAUBgNVBAkTDUV4Y2hhbmdlIFF1YXkxJTAj\n" + + "BgNVBAkTHDNyZCBGbG9vciwgMjYgT2ZmaWNlIFZpbGxhZ2UxGjAYBgNVBAoTEUNP\n" + + "TU9ETyBDQSBMaW1pdGVkMRowGAYDVQQLExFDT01PRE8gRVYgU0dDIFNTTDE7MDkG\n" + + "A1UEAxMydXNlcnRydXN0ZWNjY2VydGlmaWNhdGlvbmF1dGhvcml0eS1ldi5jb21v\n" + + "ZG9jYS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQtMl8R33ZaWD6H8BW0\n" + + "+wybBf0+6+L5YYK/eyAVGm6vwjLaQZWlcdFBMKfaP1qTLi0VAabs4baSUkD8wR56\n" + + "8pVpo4IDjjCCA4owHwYDVR0jBBgwFoAUKpxa+U6hMNpASyvpS/H1nNwC+S4wHQYD\n" + + "VR0OBBYEFLOtYfOaIfDHZGubtKNELRR6A2srMA4GA1UdDwEB/wQEAwIFgDAMBgNV\n" + + "HRMBAf8EAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBQBgNVHSAE\n" + + "STBHMDwGDCsGAQQBsjEBAgEFATAsMCoGCCsGAQUFBwIBFh5odHRwczovL2Nwcy50\n" + + "cnVzdC1wcm92aWRlci5jb20wBwYFZ4EMAQEwXwYDVR0fBFgwVjBUoFKgUIZOaHR0\n" + + "cDovL2NybC50cnVzdC1wcm92aWRlci5jb20vVVNFUlRydXN0RUNDRXh0ZW5kZWRW\n" + + "YWxpZGF0aW9uU2VjdXJlU2VydmVyQ0EuY3JsMIGYBggrBgEFBQcBAQSBizCBiDBa\n" + + "BggrBgEFBQcwAoZOaHR0cDovL2NydC50cnVzdC1wcm92aWRlci5jb20vVVNFUlRy\n" + + "dXN0RUNDRXh0ZW5kZWRWYWxpZGF0aW9uU2VjdXJlU2VydmVyQ0EuY3J0MCoGCCsG\n" + + "AQUFBzABhh5odHRwOi8vb2NzcC50cnVzdC1wcm92aWRlci5jb20wPQYDVR0RBDYw\n" + + "NIIydXNlcnRydXN0ZWNjY2VydGlmaWNhdGlvbmF1dGhvcml0eS1ldi5jb21vZG9j\n" + + "YS5jb20wggF8BgorBgEEAdZ5AgQCBIIBbASCAWgBZgB1AKS5CZC0GFgUh7sTosxn\n" + + "cAo8NZgE+RvfuON3zQ7IDdwQAAABXQ0/jQ0AAAQDAEYwRAIgPbaNWgoi6OfyNwL2\n" + + "+jiySsoLrkx+0d4NJE1WnZQcfzwCICW4yvsXaMxoOXpQp3EPgrYk5Ajfvy/dY3Ui\n" + + "0/dbQtHxAHYAVhQGmi/XwuzT9eG9RLI+x0Z2ubyZEVzA75SYVdaJ0N0AAAFdDT+K\n" + + "xwAABAMARzBFAiB3GQasrX+akoHX02ZvXCcvhWCqv6qQOhLCUqflPoRbuAIhALwe\n" + + "hrQo8S1Tm5vbMcxGiViq5ZcawxENWhxZ9hS0BZweAHUA7ku9t3XOYLrhQmkfq+Ge\n" + + "ZqMPfl+wctiDAMR7iXqo/csAAAFdDT+M4AAABAMARjBEAiAjvp8w/fdTVW1VGE0T\n" + + "I0YcCIXTYFDgzUMsEUiKHANAgwIgETQUcac7Hiis2fgQ+GdGF9yuh+xMo2Z8QXNu\n" + + "1Cknf+8wCgYIKoZIzj0EAwIDSAAwRQIgQ5UiUI7xodmmMYNs3CmqlZHw/04BQRAR\n" + + "4gRm7blZSIMCIQDHvIWTaPzSO6vwVzs6wSD6FqebLiFxoddC6aZG8Nm0wQ==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=usertrustecccertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=USERTrust ECC Extended Validation Secure Server CA, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: 4a2545ad661540057c81281ff8c101b9 + // Valid from: Tue Aug 16 17:00:00 PDT 2016 until: Fri Nov 16 15:59:59 PST 2018 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGtzCCBlygAwIBAgIQSiVFrWYVQAV8gSgf+MEBuTAKBggqhkjOPQQDAjCBlTEL\n" + + "MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl\n" + + "eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxOzA5BgNVBAMT\n" + + "MlVTRVJUcnVzdCBFQ0MgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVy\n" + + "IENBMB4XDTE2MDgxNzAwMDAwMFoXDTE4MTExNjIzNTk1OVowggFgMREwDwYDVQQF\n" + + "EwgwNDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJpdmF0\n" + + "ZSBPcmdhbml6YXRpb24xCzAJBgNVBAYTAkdCMQ8wDQYDVQQREwZNNSAzRVExGzAZ\n" + + "BgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEWMBQG\n" + + "A1UECRMNVHJhZmZvcmQgUm9hZDEWMBQGA1UECRMNRXhjaGFuZ2UgUXVheTElMCMG\n" + + "A1UECRMcM3JkIEZsb29yLCAyNiBPZmZpY2UgVmlsbGFnZTEaMBgGA1UEChMRQ09N\n" + + "T0RPIENBIExpbWl0ZWQxGjAYBgNVBAsTEUNPTU9ETyBFViBTR0MgU1NMMTswOQYD\n" + + "VQQDEzJ1c2VydHJ1c3RlY2NjZXJ0aWZpY2F0aW9uYXV0aG9yaXR5LWV2LmNvbW9k\n" + + "b2NhLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABC0yXxHfdlpYPofwFbT7\n" + + "DJsF/T7r4vlhgr97IBUabq/CMtpBlaVx0UEwp9o/WpMuLRUBpuzhtpJSQPzBHnry\n" + + "lWmjggO+MIIDujAfBgNVHSMEGDAWgBQqnFr5TqEw2kBLK+lL8fWc3AL5LjAdBgNV\n" + + "HQ4EFgQUs61h85oh8Mdka5u0o0QtFHoDayswDgYDVR0PAQH/BAQDAgWAMAwGA1Ud\n" + + "EwEB/wQCMAAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMEcGA1UdIARA\n" + + "MD4wPAYMKwYBBAGyMQECAQUBMCwwKgYIKwYBBQUHAgEWHmh0dHBzOi8vY3BzLnRy\n" + + "dXN0LXByb3ZpZGVyLmNvbTBfBgNVHR8EWDBWMFSgUqBQhk5odHRwOi8vY3JsLnRy\n" + + "dXN0LXByb3ZpZGVyLmNvbS9VU0VSVHJ1c3RFQ0NFeHRlbmRlZFZhbGlkYXRpb25T\n" + + "ZWN1cmVTZXJ2ZXJDQS5jcmwwgZgGCCsGAQUFBwEBBIGLMIGIMFoGCCsGAQUFBzAC\n" + + "hk5odHRwOi8vY3J0LnRydXN0LXByb3ZpZGVyLmNvbS9VU0VSVHJ1c3RFQ0NFeHRl\n" + + "bmRlZFZhbGlkYXRpb25TZWN1cmVTZXJ2ZXJDQS5jcnQwKgYIKwYBBQUHMAGGHmh0\n" + + "dHA6Ly9vY3NwLnRydXN0LXByb3ZpZGVyLmNvbTB1BgNVHREEbjBsgjJ1c2VydHJ1\n" + + "c3RlY2NjZXJ0aWZpY2F0aW9uYXV0aG9yaXR5LWV2LmNvbW9kb2NhLmNvbYI2d3d3\n" + + "LnVzZXJ0cnVzdGVjY2NlcnRpZmljYXRpb25hdXRob3JpdHktZXYuY29tb2RvY2Eu\n" + + "Y29tMIIBfQYKKwYBBAHWeQIEAgSCAW0EggFpAWcAdQBo9pj4H2SCvjqM7rkoHUz8\n" + + "cVFdZ5PURNEKZ6y7T0/7xAAAAVaYy/EsAAAEAwBGMEQCIATN694opYRAY9yCNZXZ\n" + + "TBJapGSqKHg1GBtlifmy+WB+AiACeljNAF3VK9Ma1bbJiRtB9ZRAN7mPbzaC3wha\n" + + "+5riaAB2AFYUBpov18Ls0/XhvUSyPsdGdrm8mRFcwO+UmFXWidDdAAABVpjL8F8A\n" + + "AAQDAEcwRQIgLq1mfWnNQWNTtQYtNCWm8wUm1Jez6AqfzmFLKJc4NC8CIQCsaHIH\n" + + "b/nKPPyKL9hxi2o5n0K3DpnHFv5V+0dtTBjOCgB2AO5Lvbd1zmC64UJpH6vhnmaj\n" + + "D35fsHLYgwDEe4l6qP3LAAABVpjL8RMAAAQDAEcwRQIhAOR5Hx0Mq6iX7lE6mfIR\n" + + "efJknMqXCnjcDsvzk6ZiXwSQAiB31TTkVHIVyscNYsup34Vcid7nWMuZiLjEElBo\n" + + "vYYh3jAKBggqhkjOPQQDAgNJADBGAiEA0CZ8Utr9boJ2y9mfVkOv2US4Nk9oWT/y\n" + + "P5YGb+ox/EICIQCBHZdD3tPNJ5BDkIdUCjnaFkNsHJchsU8e5a+1CV4knQ==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Tue Jul 04 03:51:20 PDT 2017", System.out); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/DTrustCA.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/DTrustCA.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,280 @@ +/* + * Copyright (c) 2017, 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 8189131 + * @summary Interoperability tests with "D-Trust Root Class 3 CA 2 2009" and + * "D-Trust Root Class 3 CA 2 EV 2009" CAs + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath DTrustCA OCSP + * @run main/othervm -Djava.security.debug=certpath DTrustCA CRL + */ +public class DTrustCA { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + boolean ocspEnabled = true; + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + ocspEnabled = false; + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + new RootClass3CA2().runTest(pathValidator, ocspEnabled); + new RootClass3CA2EV().runTest(pathValidator, ocspEnabled); + } +} + +class RootClass3CA2 { + + // Owner: CN=D-TRUST SSL Class 3 CA 1 2009, O=D-Trust GmbH, C=DE + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIFMjCCBBqgAwIBAgIDCZBjMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF\n" + + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD\n" + + "bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMTIxMjQ2NTVaFw0yOTExMDUwODM1NTha\n" + + "MEwxCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJjAkBgNVBAMM\n" + + "HUQtVFJVU1QgU1NMIENsYXNzIDMgQ0EgMSAyMDA5MIIBIjANBgkqhkiG9w0BAQEF\n" + + "AAOCAQ8AMIIBCgKCAQEAoal0SyLSijE0JkuhHJmOCbmQznyxuSY7DaEwhUsdUpI+\n" + + "2llkDLz6s9BWQe1zCVXDhrt3qz5U5H4h6jxm5Ec+ZbFiU3Gv2yxpI5cRPrqj9mJU\n" + + "1CGgy1+29khuUnoopzSq66HPuGZGh06I7bJkXTQ7AQ92z1MdL2wATj1UWdNid3sQ\n" + + "NiWIm+69nURHY6tmCNenNcG6aV4qjHMUPsjpCRabNY9nUO12rsmiDW2mbAC3gcxQ\n" + + "lqLgLYur9HvB8cW0xu2JZ/B3PXmNphVuWskp3Y1u0SvIYzuEsE7lWDbBmtWZtabB\n" + + "hzThkDQvd+3keQ1sU/beq1NeXfgKzQ5G+4Ql2PUY/wIDAQABo4ICGjCCAhYwHwYD\n" + + "VR0jBBgwFoAU/doUxJ8w3iG9HkI5/KtjI0ng8YQwRAYIKwYBBQUHAQEEODA2MDQG\n" + + "CCsGAQUFBzABhihodHRwOi8vcm9vdC1jMy1jYTItMjAwOS5vY3NwLmQtdHJ1c3Qu\n" + + "bmV0MF8GA1UdIARYMFYwVAYEVR0gADBMMEoGCCsGAQUFBwIBFj5odHRwOi8vd3d3\n" + + "LmQtdHJ1c3QubmV0L2ludGVybmV0L2ZpbGVzL0QtVFJVU1RfUm9vdF9QS0lfQ1BT\n" + + "LnBkZjAzBgNVHREELDAqgRBpbmZvQGQtdHJ1c3QubmV0hhZodHRwOi8vd3d3LmQt\n" + + "dHJ1c3QubmV0MIHTBgNVHR8EgcswgcgwgYCgfqB8hnpsZGFwOi8vZGlyZWN0b3J5\n" + + "LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El\n" + + "MjAyJTIwMjAwOSxPPUQtVHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZv\n" + + "Y2F0aW9ubGlzdDBDoEGgP4Y9aHR0cDovL3d3dy5kLXRydXN0Lm5ldC9jcmwvZC10\n" + + "cnVzdF9yb290X2NsYXNzXzNfY2FfMl8yMDA5LmNybDAdBgNVHQ4EFgQUUBkylJrE\n" + + "tQRNVtDAgyHVNVWwsXowDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8C\n" + + "AQAwDQYJKoZIhvcNAQELBQADggEBABM5QRHX/yInsmZLWVlvmWmKb3c4IB3hAIVR\n" + + "sAGhkvQJ/RD1GZjZUBBYMWkD1P37fTQxlqTOe3NecVvElkYZuCq7HSM6o7awzb3m\n" + + "yLn1kN+hDCsxX0EYbVSNjEjkW3QEkqJH9owH4qeMDxf7tfXB7BVKO+rarYPa2PR8\n" + + "Wz2KhjFDmAeFg2J89YcpeJJEEJXoweAkgJEEwwEIfJ2yLjYo78RD0Rvij/+zkfj9\n" + + "+dSvTiZTuqicyo37qNoYHgchuqXnKodhWkW89oo2NKhfeNHHbqvXEJmx0PbI6YyQ\n" + + "50GnYECZRHNKhgbPEtNy/QetU53aWlTlvu4NIwLW5XVsrxlQ2Zw=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=certdemo-ov-valid.ssl.d-trust.net, O=D-Trust GmbH, OU=IT, + // L=Berlin, ST=Berlin, C=DE, SERIALNUMBER=DTRWS354803406304201, DNQ=7223150018 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIF1jCCBL6gAwIBAgIDD07RMA0GCSqGSIb3DQEBCwUAMEwxCzAJBgNVBAYTAkRF\n" + + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJjAkBgNVBAMMHUQtVFJVU1QgU1NMIENs\n" + + "YXNzIDMgQ0EgMSAyMDA5MB4XDTEyMTIxMTEwMTgzN1oXDTE1MTIyMTExMTgwOVow\n" + + "gbMxEzARBgNVBC4TCjcyMjMxNTAwMTgxHTAbBgNVBAUTFERUUldTMzU0ODAzNDA2\n" + + "MzA0MjAxMQswCQYDVQQGEwJERTEPMA0GA1UECAwGQmVybGluMQ8wDQYDVQQHDAZC\n" + + "ZXJsaW4xCzAJBgNVBAsMAklUMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNV\n" + + "BAMMIWNlcnRkZW1vLW92LXZhbGlkLnNzbC5kLXRydXN0Lm5ldDCCASIwDQYJKoZI\n" + + "hvcNAQEBBQADggEPADCCAQoCggEBAMbo9ih0Bo4zKaKwl+mClCxhedC3YOpBzrun\n" + + "zbqYJuy6vbHuZdMtU3nO7ziTPbnoVFboKmyEtAMwJ+qudHdWaa/nA4Hlhmg5+CWZ\n" + + "OolX3VmMlrZ+LpaeajduOgDa7DQDcixZ+ndd24Xc/u9L83CH7ziQDs4XNJxx63Wf\n" + + "lSMKBKkmvry7CfCXcsR4dYW8tTBm1PESJZVNqOKkOiwHwMA69knpXwghmDbKgZro\n" + + "01chjeyYb39ZhwHNWlxh5rgd2HZpgrl8kUY3yV9PrQcjFPbKT6ZgHfRiHlax4vbX\n" + + "qiHHcHRr7iVPruyCf0DU3BqhDVUhnrJ+vqTyg+m/OJduznF2nXcCAwEAAaOCAlcw\n" + + "ggJTMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAfBgNVHSMEGDAWgBRQ\n" + + "GTKUmsS1BE1W0MCDIdU1VbCxejBDBggrBgEFBQcBAQQ3MDUwMwYIKwYBBQUHMAGG\n" + + "J2h0dHA6Ly9zc2wtYzMtY2ExLTIwMDkub2NzcC5kLXRydXN0Lm5ldDBmBgNVHSAE\n" + + "XzBdMFsGCysGAQQBpTQCgUgBMEwwSgYIKwYBBQUHAgEWPmh0dHA6Ly93d3cuZC10\n" + + "cnVzdC5uZXQvaW50ZXJuZXQvZmlsZXMvRC1UUlVTVF9Sb290X1BLSV9DUFMucGRm\n" + + "MIHRBgNVHR8EgckwgcYwgcOggcCggb2GeWxkYXA6Ly9kaXJlY3RvcnkuZC10cnVz\n" + + "dC5uZXQvQ049RC1UUlVTVCUyMFNTTCUyMENsYXNzJTIwMyUyMENBJTIwMSUyMDIw\n" + + "MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxp\n" + + "c3SGQGh0dHA6Ly9jcmwuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfc3NsX2NsYXNz\n" + + "XzNfY2FfMV8yMDA5LmRlci5jcmwwMwYDVR0SBCwwKoEQaW5mb0BkLXRydXN0Lm5l\n" + + "dIYWaHR0cDovL3d3dy5kLXRydXN0Lm5ldDAdBgNVHQ4EFgQUHjGMR/EdDBRf+Ejf\n" + + "WW5a8beoBrwwDgYDVR0PAQH/BAQDAgSwMCwGA1UdEQQlMCOCIWNlcnRkZW1vLW92\n" + + "LXZhbGlkLnNzbC5kLXRydXN0Lm5ldDANBgkqhkiG9w0BAQsFAAOCAQEAGN4yxyF3\n" + + "sszODgDSkCNX1s4R874jmBmMYy4Af9/kwKNp2GtqPPhnDu8VFtq0bqs1e06XZ4/W\n" + + "6pUPRZIlynjPASkQl+aJGzyZlaH+K0Al80M/7FRRmLCW9Do/RszRihdhcjeyG+Bi\n" + + "2k+A35aVqKMAWzoH4M7TCPg4+ECltaFgJ+25loXl3j0yiP/DmBwATO80Nx78ILl5\n" + + "D6cDyftMKUwdKKlUsB2RMOJsVBcotBMGTB1i/YoSKIu6t7QnoVFMHEia2wZegPCj\n" + + "hBKhLf/Zde/VrSN3IIft93XRabqXWqjpDCvpb/b06/0o5aZIycrj+Kya54dsdXMO\n" + + "FRy9N0HZYzvt9g==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=certdemo-ov-revoked.ssl.d-trust.net, O=D-Trust GmbH, OU=IT, + // L=Berlin, ST=Berlin, C=DE, DNQ=5562882417 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIFuzCCBKOgAwIBAgIDExFnMA0GCSqGSIb3DQEBCwUAMEwxCzAJBgNVBAYTAkRF\n" + + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJjAkBgNVBAMMHUQtVFJVU1QgU1NMIENs\n" + + "YXNzIDMgQ0EgMSAyMDA5MB4XDTE0MDYyNjE2MTg1NloXDTE1MDYyOTE2MTg1Nlow\n" + + "gZYxEzARBgNVBC4TCjU1NjI4ODI0MTcxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZC\n" + + "ZXJsaW4xDzANBgNVBAcTBkJlcmxpbjELMAkGA1UECxMCSVQxFTATBgNVBAoTDEQt\n" + + "VHJ1c3QgR21iSDEsMCoGA1UEAxMjY2VydGRlbW8tb3YtcmV2b2tlZC5zc2wuZC10\n" + + "cnVzdC5uZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtdH2wqHgG\n" + + "tqlekrfRQzJuhMzRllfYcmmsxr7jsnwgPe0+zib+GeTDm9U5+XKjT1uYETL501ov\n" + + "HfKsZ/aK+k58iFF5evEtdHic/2v868uwxcm/Kcn+zt2uX9QvfSUzJPQkW/Ynu3w2\n" + + "IhuBNBlFAJgxjYr2xMUmDrVDx1/ZfBc0ddyo87MccLZOdmqLhef8bJQ+3q6DA+Z1\n" + + "bGk1wHl9KgFNtOjlKws5nKzCzyugy+MhLo+4wPxi0UhUA7QA7fk7lWBwJ9fZRTT/\n" + + "cKfP4lUucXdQBS2ZhvpEZggjjBDhTHtZLwdfEUlf1GZ+GwD8IB9whlwqT2cS9WUR\n" + + "XI9b14TJM2zfAgMBAAGjggJZMIICVTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYB\n" + + "BQUHAwIwHwYDVR0jBBgwFoAUUBkylJrEtQRNVtDAgyHVNVWwsXowQwYIKwYBBQUH\n" + + "AQEENzA1MDMGCCsGAQUFBzABhidodHRwOi8vc3NsLWMzLWNhMS0yMDA5Lm9jc3Au\n" + + "ZC10cnVzdC5uZXQwZgYDVR0gBF8wXTBbBgsrBgEEAaU0AoFIATBMMEoGCCsGAQUF\n" + + "BwIBFj5odHRwOi8vd3d3LmQtdHJ1c3QubmV0L2ludGVybmV0L2ZpbGVzL0QtVFJV\n" + + "U1RfUm9vdF9QS0lfQ1BTLnBkZjCB0QYDVR0fBIHJMIHGMIHDoIHAoIG9hnlsZGFw\n" + + "Oi8vZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBTU0wlMjBDbGFz\n" + + "cyUyMDMlMjBDQSUyMDElMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0\n" + + "aWZpY2F0ZXJldm9jYXRpb25saXN0hkBodHRwOi8vY3JsLmQtdHJ1c3QubmV0L2Ny\n" + + "bC9kLXRydXN0X3NzbF9jbGFzc18zX2NhXzFfMjAwOS5kZXIuY3JsMDMGA1UdEgQs\n" + + "MCqBEGluZm9AZC10cnVzdC5uZXSGFmh0dHA6Ly93d3cuZC10cnVzdC5uZXQwHQYD\n" + + "VR0OBBYEFC4+5qwI2S+t/TaZ/kMADTR7FjdOMA4GA1UdDwEB/wQEAwIEsDAuBgNV\n" + + "HREEJzAlgiNjZXJ0ZGVtby1vdi1yZXZva2VkLnNzbC5kLXRydXN0Lm5ldDANBgkq\n" + + "hkiG9w0BAQsFAAOCAQEAO3sbXee7GbEyXSRZOgwk2LloPNIFriFGP8WAWnsaf056\n" + + "jxHRnjjPQRyqhBmGQAGwrEp3a3uF+6gbM2XuoKPjNFqjqnQNR2+lVRs8pVTTjJ+r\n" + + "SekcOUbCx6nIe98OBheAljAxfeal3e8bBrP3VA+QvOscaLJiC1ZsGfqvrGYJDt6b\n" + + "UFMKbNuwDcfpKkrB0AyW0NvYALwgTPr+SgbxB0Xrp0W+dg6XfHmpuRSSPUkZqzEY\n" + + "uPTmIgs7qCtVEIpV91gDFBDNfr4QbFVCNvDmMIZNMnXUEmTW81N1KUVTNdz8k5TY\n" + + "HO/7TeeAi2u0m3ERrLXE9SKtNwUMJujEOQ/UmQkIQw==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + if (ocspEnabled) { + // Test certificates are expired in 2015 + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("Jan 01, 2015"); + } + + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Thu Jun 26 09:28:39 PDT 2014", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} + +class RootClass3CA2EV { + + // Owner: CN=D-TRUST SSL Class 3 CA 1 EV 2009, O=D-Trust GmbH, C=DE + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIFRTCCBC2gAwIBAgIDCZBkMA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF\n" + + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD\n" + + "bGFzcyAzIENBIDIgRVYgMjAwOTAeFw0wOTExMTIxMjUyNDNaFw0yOTExMDUwODUw\n" + + "NDZaME8xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKTAnBgNV\n" + + "BAMMIEQtVFJVU1QgU1NMIENsYXNzIDMgQ0EgMSBFViAyMDA5MIIBIjANBgkqhkiG\n" + + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAygp+ZziakFyPq80fk1QIT9UCcPy0R3UIyq56\n" + + "hXA6lhgfs1l9R9wRM9/DIVX2olb0gHCXdpnHRm+jwzeL3dHJO8Im5Om/c24ZfSVE\n" + + "zBcgKxS5X7X5e7oCYb9tozd9xs04WqYd5kWrvCJsSQf5gtv5gAeJt+QiU7dtXs3A\n" + + "YDflWv4g9eEaDExxM0VQmceEAo5qc7I7dk5ry356G14zQmr29cxie6YS0kH+7qn5\n" + + "g+c21M01sENle0tBPxIfkv+nV95Ih3JkpHSPm/wgFKfCtwRtG+5VehUoMEpgfi0X\n" + + "fmVkag558aQpaaeQCtYZnXuq6g1D1LAcjIqMpOP4wNRp1ldLzQIDAQABo4ICJzCC\n" + + "AiMwHwYDVR0jBBgwFoAU05SKTGITKhkuzK9yin0215oc3GcwRwYIKwYBBQUHAQEE\n" + + "OzA5MDcGCCsGAQUFBzABhitodHRwOi8vcm9vdC1jMy1jYTItZXYtMjAwOS5vY3Nw\n" + + "LmQtdHJ1c3QubmV0MF8GA1UdIARYMFYwVAYEVR0gADBMMEoGCCsGAQUFBwIBFj5o\n" + + "dHRwOi8vd3d3LmQtdHJ1c3QubmV0L2ludGVybmV0L2ZpbGVzL0QtVFJVU1RfUm9v\n" + + "dF9QS0lfQ1BTLnBkZjAzBgNVHREELDAqgRBpbmZvQGQtdHJ1c3QubmV0hhZodHRw\n" + + "Oi8vd3d3LmQtdHJ1c3QubmV0MIHdBgNVHR8EgdUwgdIwgYeggYSggYGGf2xkYXA6\n" + + "Ly9kaXJlY3RvcnkuZC10cnVzdC5uZXQvQ049RC1UUlVTVCUyMFJvb3QlMjBDbGFz\n" + + "cyUyMDMlMjBDQSUyMDIlMjBFViUyMDIwMDksTz1ELVRydXN0JTIwR21iSCxDPURF\n" + + "P2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwRqBEoEKGQGh0dHA6Ly93d3cuZC10\n" + + "cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfZXZfMjAwOS5j\n" + + "cmwwHQYDVR0OBBYEFKztpZ16orZD8RiKJWpsscyo8lrUMA4GA1UdDwEB/wQEAwIB\n" + + "BjASBgNVHRMBAf8ECDAGAQH/AgEAMA0GCSqGSIb3DQEBCwUAA4IBAQA6I3sGyvb4\n" + + "MdTyEZFBBWBN/5Kx1SVkkPsll8DvgosJiuuK4I7mD6FFKDjKgogr407EoDSS2t1+\n" + + "pSmQCb0rNXoJT3YIlpZGqPYU2rcwrelabJQZWAfoRnbkDx2aqofhp5u45dyQpM2t\n" + + "R93/oA36iuHYc9Ewq8CaLGolrpT138RD7i4nN7sZFuFH0IseNz0+EZm88NHi9WeJ\n" + + "UyshWFKBKARi+589Y4P/G2XnbckxFKUxa7uEroZcMwvKBy469K0Au0zVTxs1zNtf\n" + + "Ol3QkNgPwzOPeHhOnpzcenyPgNEm+HQ0FPTnB4HeKBqTeLpkM7h4gq5MZ2TPmfuX\n" + + "KDz3AHrWLLdH\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=certdemo-ev-revoked.ssl.d-trust.net, O=D-Trust GmbH, OU=IT, + // STREET=Berlin, OID.2.5.4.17=10969, L=Berlin, ST=Berlin, C=DE, + // SERIALNUMBER=HRB74346, OID.2.5.4.15=Private Organization, + // OID.1.3.6.1.4.1.311.60.2.1.1=Berlin, OID.1.3.6.1.4.1.311.60.2.1.2=Berlin, + // OID.1.3.6.1.4.1.311.60.2.1.3=DE, DNQ=4028175542 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGZDCCBUygAwIBAgIDExFtMA0GCSqGSIb3DQEBCwUAME8xCzAJBgNVBAYTAkRF\n" + + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKTAnBgNVBAMMIEQtVFJVU1QgU1NMIENs\n" + + "YXNzIDMgQ0EgMSBFViAyMDA5MB4XDTE0MDYyNjE2NDMyOFoXDTE1MDYyOTE2NDMy\n" + + "OFowggEwMRMwEQYDVQQuEwo0MDI4MTc1NTQyMRMwEQYLKwYBBAGCNzwCAQMMAkRF\n" + + "MRcwFQYLKwYBBAGCNzwCAQIMBkJlcmxpbjEXMBUGCysGAQQBgjc8AgEBDAZCZXJs\n" + + "aW4xHTAbBgNVBA8MFFByaXZhdGUgT3JnYW5pemF0aW9uMREwDwYDVQQFEwhIUkI3\n" + + "NDM0NjELMAkGA1UEBhMCREUxDzANBgNVBAgTBkJlcmxpbjEPMA0GA1UEBxMGQmVy\n" + + "bGluMQ4wDAYDVQQRDAUxMDk2OTEPMA0GA1UECRMGQmVybGluMQswCQYDVQQLEwJJ\n" + + "VDEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSwwKgYDVQQDEyNjZXJ0ZGVtby1ldi1y\n" + + "ZXZva2VkLnNzbC5kLXRydXN0Lm5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC\n" + + "AQoCggEBAMjX4zZxaSl+7eLXXVyO1HzQTymgsI4WlMpVMczyA21kXnx4iBZ9JeHW\n" + + "W3Jv4SxxqtHut98eCq30r7yniCy7zGX35iuSy2zMf0u0tRraP5b2c590UMRgKOSU\n" + + "DvahC+SlyJWGimt2Dtej2T1kcQvhUmonUkIimQOpM0MOIFxB5d494TzkQAYOV6yb\n" + + "AHoIsMWMeMm24Rr6o8QnJqhb9A13keYRK8t0u7F5+fvONlFT2YnjbCoRlxa48i1b\n" + + "PZwtE/NZ4bpZmv765tyfl9R5FatANnuja04Dd9StbTbjDezYzilF4qpSWtSKwmEl\n" + + "J6fRxJ1kNAEThyzNZMnFjh8htZ7PL18CAwEAAaOCAmQwggJgMB0GA1UdJQQWMBQG\n" + + "CCsGAQUFBwMBBggrBgEFBQcDAjAfBgNVHSMEGDAWgBSs7aWdeqK2Q/EYiiVqbLHM\n" + + "qPJa1DBGBggrBgEFBQcBAQQ6MDgwNgYIKwYBBQUHMAGGKmh0dHA6Ly9zc2wtYzMt\n" + + "Y2ExLWV2LTIwMDkub2NzcC5kLXRydXN0Lm5ldDBmBgNVHSAEXzBdMFsGCysGAQQB\n" + + "pTQCgUoBMEwwSgYIKwYBBQUHAgEWPmh0dHA6Ly93d3cuZC10cnVzdC5uZXQvaW50\n" + + "ZXJuZXQvZmlsZXMvRC1UUlVTVF9Sb290X1BLSV9DUFMucGRmMIHZBgNVHR8EgdEw\n" + + "gc4wgcuggciggcWGfmxkYXA6Ly9kaXJlY3RvcnkuZC10cnVzdC5uZXQvQ049RC1U\n" + + "UlVTVCUyMFNTTCUyMENsYXNzJTIwMyUyMENBJTIwMSUyMEVWJTIwMjAwOSxPPUQt\n" + + "VHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdIZDaHR0\n" + + "cDovL2NybC5kLXRydXN0Lm5ldC9jcmwvZC10cnVzdF9zc2xfY2xhc3NfM19jYV8x\n" + + "X2V2XzIwMDkuZGVyLmNybDAzBgNVHRIELDAqgRBpbmZvQGQtdHJ1c3QubmV0hhZo\n" + + "dHRwOi8vd3d3LmQtdHJ1c3QubmV0MB0GA1UdDgQWBBTFei056yoNM1HWYbBCixQw\n" + + "wXnf0TAOBgNVHQ8BAf8EBAMCBLAwLgYDVR0RBCcwJYIjY2VydGRlbW8tZXYtcmV2\n" + + "b2tlZC5zc2wuZC10cnVzdC5uZXQwDQYJKoZIhvcNAQELBQADggEBALv0OA+x401T\n" + + "CvGQL1Ah7rclRgtxT3UjmphiLs9EE1YbweIUrN3R4tZuryyv9xslAoLCfMrHUe+f\n" + + "jv1hsKqw+gGlrA8d5VnAqKfUR+KCiZivdlQ2sl4PDTZWpUQYlBnjQrD8h6UrcgTA\n" + + "g1zUpDnioAKAQSWWxHVpcOX0IXCl3RgRz0GqUIZQ0Q8ZwYbIDEI+JzDEJgKkTzet\n" + + "uzin8P54PjuJO801gENp43z++xHVuBcEWkU0TMDbmdL9vPZqnxsaoL5e/llGzor5\n" + + "6JbU6Fc0MkuziaLPUsIxVVx3ZhZ6UFdv34swKyq6ycvKW2fgccwsQCFMrVjIo6HR\n" + + "qiZC9Z+23vM=\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + // Valid cert received as test artifact was revoked so remove test + + // Validate Revoked + if (ocspEnabled) { + // Revoked certificates are expired in 2015 + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("Jan 01, 2015"); + } + + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Thu Jun 26 09:45:14 PDT 2014", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2017, 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 8189131 + * @summary Interoperability tests with Let's Encrypt CA + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath LetsEncryptCA OCSP + * @run main/othervm -Djava.security.debug=certpath LetsEncryptCA CRL + */ + + /* + * "Lets Encrypt Authority X1" intermediate CA is retired. + * Test certs should be chained through "Lets Encrypt Authority X3" CA. + * + * Obtain TLS test artifacts for Let's Encrypt CA from: + * + * Valid TLS Certificates: + * https://valid-isrgrootx1.letsencrypt.org/ + * + * Revoked TLS Certificates: + * https://revoked-isrgrootx1.letsencrypt.org/ + * + * Test artifacts don't have CRLs listed. + */ +public class LetsEncryptCA { + + // Owner: CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US + // Issuer: CN=ISRG Root X1, O=Internet Security Research Group, C=US + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIFjTCCA3WgAwIBAgIRANOxciY0IzLc9AUoUSrsnGowDQYJKoZIhvcNAQELBQAw\n" + + "TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n" + + "cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTYxMDA2MTU0MzU1\n" + + "WhcNMjExMDA2MTU0MzU1WjBKMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNTGV0J3Mg\n" + + "RW5jcnlwdDEjMCEGA1UEAxMaTGV0J3MgRW5jcnlwdCBBdXRob3JpdHkgWDMwggEi\n" + + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCc0wzwWuUuR7dyXTeDs2hjMOrX\n" + + "NSYZJeG9vjXxcJIvt7hLQQWrqZ41CFjssSrEaIcLo+N15Obzp2JxunmBYB/XkZqf\n" + + "89B4Z3HIaQ6Vkc/+5pnpYDxIzH7KTXcSJJ1HG1rrueweNwAcnKx7pwXqzkrrvUHl\n" + + "Npi5y/1tPJZo3yMqQpAMhnRnyH+lmrhSYRQTP2XpgofL2/oOVvaGifOFP5eGr7Dc\n" + + "Gu9rDZUWfcQroGWymQQ2dYBrrErzG5BJeC+ilk8qICUpBMZ0wNAxzY8xOJUWuqgz\n" + + "uEPxsR/DMH+ieTETPS02+OP88jNquTkxxa/EjQ0dZBYzqvqEKbbUC8DYfcOTAgMB\n" + + "AAGjggFnMIIBYzAOBgNVHQ8BAf8EBAMCAYYwEgYDVR0TAQH/BAgwBgEB/wIBADBU\n" + + "BgNVHSAETTBLMAgGBmeBDAECATA/BgsrBgEEAYLfEwEBATAwMC4GCCsGAQUFBwIB\n" + + "FiJodHRwOi8vY3BzLnJvb3QteDEubGV0c2VuY3J5cHQub3JnMB0GA1UdDgQWBBSo\n" + + "SmpjBH3duubRObemRWXv86jsoTAzBgNVHR8ELDAqMCigJqAkhiJodHRwOi8vY3Js\n" + + "LnJvb3QteDEubGV0c2VuY3J5cHQub3JnMHIGCCsGAQUFBwEBBGYwZDAwBggrBgEF\n" + + "BQcwAYYkaHR0cDovL29jc3Aucm9vdC14MS5sZXRzZW5jcnlwdC5vcmcvMDAGCCsG\n" + + "AQUFBzAChiRodHRwOi8vY2VydC5yb290LXgxLmxldHNlbmNyeXB0Lm9yZy8wHwYD\n" + + "VR0jBBgwFoAUebRZ5nu25eQBc4AIiMgaWPbpm24wDQYJKoZIhvcNAQELBQADggIB\n" + + "ABnPdSA0LTqmRf/Q1eaM2jLonG4bQdEnqOJQ8nCqxOeTRrToEKtwT++36gTSlBGx\n" + + "A/5dut82jJQ2jxN8RI8L9QFXrWi4xXnA2EqA10yjHiR6H9cj6MFiOnb5In1eWsRM\n" + + "UM2v3e9tNsCAgBukPHAg1lQh07rvFKm/Bz9BCjaxorALINUfZ9DD64j2igLIxle2\n" + + "DPxW8dI/F2loHMjXZjqG8RkqZUdoxtID5+90FgsGIfkMpqgRS05f4zPbCEHqCXl1\n" + + "eO5HyELTgcVlLXXQDgAWnRzut1hFJeczY1tjQQno6f6s+nMydLN26WuU4s3UYvOu\n" + + "OsUxRlJu7TSRHqDC3lSE5XggVkzdaPkuKGQbGpny+01/47hfXXNB7HntWNZ6N2Vw\n" + + "p7G6OfY+YQrZwIaQmhrIqJZuigsrbe3W+gdn5ykE9+Ky0VgVUsfxo52mwFYs1JKY\n" + + "2PGDuWx8M6DlS6qQkvHaRUo0FMd8TsSlbF0/v965qGFKhSDeQoMpYnwcmQilRh/0\n" + + "ayLThlHLN81gSkJjVrPI0Y8xCVPB4twb1PFUd2fPM3sA1tJ83sZ5v8vgFv2yofKR\n" + + "PB0t6JzUA81mSqM3kxl5e+IZwhYAyO0OTg3/fs8HqGTNKd9BqoUwSRBzp06JMg5b\n" + + "rUCGwbCUDI0mxadJ3Bz4WxR6fyNpBK2yAinWEsikxqEt\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=valid-isrgrootx1.letsencrypt.org + // Issuer: CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US + // Serial number: 36916d6db9151ad4428d458a32eae518671 + // Valid from: Wed Nov 08 07:00:24 PST 2017 until: Tue Feb 06 07:00:24 PST 2018 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIFIzCCBAugAwIBAgISA2kW1tuRUa1EKNRYoy6uUYZxMA0GCSqGSIb3DQEBCwUA\n" + + "MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD\n" + + "ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xNzExMDgxNTAwMjRaFw0x\n" + + "ODAyMDYxNTAwMjRaMCsxKTAnBgNVBAMTIHZhbGlkLWlzcmdyb290eDEubGV0c2Vu\n" + + "Y3J5cHQub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyugIOCxl\n" + + "4p0Rrs4aggnzKGYezhMyyvqlBgVBkf3DJV5uHbz/B/CxcoFo2rZzIetJEsb7Qnt1\n" + + "U8L2O5BKnBeOsI5eFv6WUAQs96VayQ09+xCV3jSNjVpbmKKp1TNWboF/V+EDFq6f\n" + + "fxK9h+b88RhBn4gfe+BorPnVTmZZQHgcZCjMGyzlXt68r45dXmZOuh0855Y7z6Et\n" + + "wCHTT8k/7VC0DTIs0+veKv+yblUqwGD0htdOh7POkQGfBeJ432FsCCcLCDjg2Jj2\n" + + "oYQNpLao55ZnVJGXfP8dJpHqJvuEQVuNT1TbHTs4x7IMftqGcPuhXKhA5FCVf0Hb\n" + + "osbVmZ/b2b/WswIDAQABo4ICIDCCAhwwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQW\n" + + "MBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBQZ\n" + + "Mod3QzNPUL56tDMtELpCiwkQOTAfBgNVHSMEGDAWgBSoSmpjBH3duubRObemRWXv\n" + + "86jsoTBvBggrBgEFBQcBAQRjMGEwLgYIKwYBBQUHMAGGImh0dHA6Ly9vY3NwLmlu\n" + + "dC14My5sZXRzZW5jcnlwdC5vcmcwLwYIKwYBBQUHMAKGI2h0dHA6Ly9jZXJ0Lmlu\n" + + "dC14My5sZXRzZW5jcnlwdC5vcmcvMCsGA1UdEQQkMCKCIHZhbGlkLWlzcmdyb290\n" + + "eDEubGV0c2VuY3J5cHQub3JnMIH+BgNVHSAEgfYwgfMwCAYGZ4EMAQIBMIHmBgsr\n" + + "BgEEAYLfEwEBATCB1jAmBggrBgEFBQcCARYaaHR0cDovL2Nwcy5sZXRzZW5jcnlw\n" + + "dC5vcmcwgasGCCsGAQUFBwICMIGeDIGbVGhpcyBDZXJ0aWZpY2F0ZSBtYXkgb25s\n" + + "eSBiZSByZWxpZWQgdXBvbiBieSBSZWx5aW5nIFBhcnRpZXMgYW5kIG9ubHkgaW4g\n" + + "YWNjb3JkYW5jZSB3aXRoIHRoZSBDZXJ0aWZpY2F0ZSBQb2xpY3kgZm91bmQgYXQg\n" + + "aHR0cHM6Ly9sZXRzZW5jcnlwdC5vcmcvcmVwb3NpdG9yeS8wDQYJKoZIhvcNAQEL\n" + + "BQADggEBAFBiwKeCZfIh8a7x0Y5QEqGwejil/BY6MOVuIU9FRIJKmhJGdh6lI6ln\n" + + "zlBbMZBAjZ+TqDxU0pvM1AsRDyCqt8GbCAC2xQsGyATLdCjedLQ7U7ORm7pBZdbe\n" + + "cT7h9Sblj53o5MKa1yFeS89WGjI4UueUemGxp7EQjat0NeAvbnpU+YmuevNYKX2M\n" + + "kK33reMC+rgD+wKet1CXcB/ZYl3fDzVH3SwkT/bKW5bsuwxBuD2noScnKCitRgiv\n" + + "Ew7YjwqNOm2naki/xr2sfJirR+lJtZ9KC3H8xWeEHrD8Cf7pnmMYqV59uR+hJwMP\n" + + "YsjjDbDFCmNN9FBqDwvXs7g86ttkdC8=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=revoked-isrgrootx1.letsencrypt.org + // Issuer: CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US + // Serial number: 3ddd39c0755648d6687a5d8ded37775657e + // Valid from: Wed Nov 08 07:00:32 PST 2017 until: Tue Feb 06 07:00:32 PST 2018 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIFJzCCBA+gAwIBAgISA93TnAdVZI1mh6XY3tN3dWV+MA0GCSqGSIb3DQEBCwUA\n" + + "MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD\n" + + "ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xNzExMDgxNTAwMzJaFw0x\n" + + "ODAyMDYxNTAwMzJaMC0xKzApBgNVBAMTInJldm9rZWQtaXNyZ3Jvb3R4MS5sZXRz\n" + + "ZW5jcnlwdC5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC5qlZ0\n" + + "jslNLn/1uICdZPwflcvsoA2S2Nk+O7cPNew+KQmSIf+LK9AbaWHCkABKx1GdMtfN\n" + + "4Q/nKBtzqZ5jX1V1XbPqPd1eeyJo0rNaDFk/gEUHw/zIYi1AtsxVHztMqOXRcsw+\n" + + "6QHRKU2XFVsfSctMv+MKnMTEJZARyhr5ur9bQ4/LmxPMhrlHAst97hiSsXKXeyMK\n" + + "DWPHmUDn1vz/1mwLMaeYYmuhuRP5HNwYq+LdYvjMV580i6LHY72TwQCfVgOHfqI0\n" + + "larISk2p4q6DmTEEiAzJB3yEYaxDn0kEXbKhL9efDC+eirVFa0ta2OnH87s9L8z9\n" + + "fm9JIiSFM9ATQ16/AgMBAAGjggIiMIICHjAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0l\n" + + "BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYE\n" + + "FP64lxiV8KwkkzoNaM7iuwX8UBG/MB8GA1UdIwQYMBaAFKhKamMEfd265tE5t6ZF\n" + + "Ze/zqOyhMG8GCCsGAQUFBwEBBGMwYTAuBggrBgEFBQcwAYYiaHR0cDovL29jc3Au\n" + + "aW50LXgzLmxldHNlbmNyeXB0Lm9yZzAvBggrBgEFBQcwAoYjaHR0cDovL2NlcnQu\n" + + "aW50LXgzLmxldHNlbmNyeXB0Lm9yZy8wLQYDVR0RBCYwJIIicmV2b2tlZC1pc3Jn\n" + + "cm9vdHgxLmxldHNlbmNyeXB0Lm9yZzCB/gYDVR0gBIH2MIHzMAgGBmeBDAECATCB\n" + + "5gYLKwYBBAGC3xMBAQEwgdYwJgYIKwYBBQUHAgEWGmh0dHA6Ly9jcHMubGV0c2Vu\n" + + "Y3J5cHQub3JnMIGrBggrBgEFBQcCAjCBngyBm1RoaXMgQ2VydGlmaWNhdGUgbWF5\n" + + "IG9ubHkgYmUgcmVsaWVkIHVwb24gYnkgUmVseWluZyBQYXJ0aWVzIGFuZCBvbmx5\n" + + "IGluIGFjY29yZGFuY2Ugd2l0aCB0aGUgQ2VydGlmaWNhdGUgUG9saWN5IGZvdW5k\n" + + "IGF0IGh0dHBzOi8vbGV0c2VuY3J5cHQub3JnL3JlcG9zaXRvcnkvMA0GCSqGSIb3\n" + + "DQEBCwUAA4IBAQCBiokogdgIZxwuPSr43S4GZ9FwrpZNMHADMEZB8ykuotJBGyr1\n" + + "QLWDVeoAJ8OIi1AzjcdwKFQks/MKUJwxJ9hYmm9aM14d5lMKGTyoLSI/Z/Vrpx8w\n" + + "0GpktSK0WfPeLBHuSpMdrIMWyziSu/bdZtiOIIvMasFwyRhDgII++CIdsnboWXF+\n" + + "DZcwy0Yd6XzirXuwENwaWrkrbZPr/JB0xLFmydqXAnA1VFTudwL87q4CTlEo8EiD\n" + + "ucKZ/vAhD+ip3/kQFXg90om+9TdHo8D8GxTC1CLZteJt+nqWFRj0e/7eCXIZuUBE\n" + + "aSsFCd5RNTHs6tioN9vYJqLojObgF75MgIAC\n" + + "-----END CERTIFICATE-----"; + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + + // Validate int, EE certs don't have CRLs + pathValidator.validate(new String[]{INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + return; + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Wed Nov 08 08:00:35 PST 2017", System.out); + + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/QuoVadisCA.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/QuoVadisCA.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,473 @@ +/* + * Copyright (c) 2017, 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 8189131 + * @summary Interoperability tests with QuoVadis Root CA1, CA2, and CA3 CAs + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath QuoVadisCA OCSP + * @run main/othervm -Djava.security.debug=certpath QuoVadisCA CRL + */ + + /* + * Obtain TLS test artifacts for QuoVadis CAs from: + * + * Valid TLS Certificates: + * CA1: https://qvica1g3-v.quovadisglobal.com + * CA2: https://qvsslicag3-v.quovadisglobal.com + * CA2 EV: https://evsslicag3-v.quovadisglobal.com + * CA3: https://qvica3g3-v.quovadisglobal.com + * + * Revoked TLS Certificates: + * CA1: https://qvica1g3-r.quovadisglobal.com + * CA2: https://qvsslicag3-r.quovadisglobal.com + * CA2 EV: https://evsslicag3-r.quovadisglobal.com + * CA3: https://qvica3g3-r.quovadisglobal.com + */ +public class QuoVadisCA { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + boolean ocspEnabled = true; + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + ocspEnabled = false; + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + new RootCA1().runTest(pathValidator, ocspEnabled); + new RootCA2().runTest(pathValidator, ocspEnabled); + new RootCA3().runTest(pathValidator, ocspEnabled); + } +} + +class RootCA1 { + + // Owner: CN=QuoVadis Issuing CA 1 G3, O=QuoVadis Limited, C=BM + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGFTCCA/2gAwIBAgIUPybG62jqpxKYOV5MlXAGPJYDy9MwDQYJKoZIhvcNAQEL\n" + + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMSBHMzAeFw0xMjExMDYxNjA5NTJaFw0y\n" + + "MjExMDYxNjA5NTJaMEsxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + + "aW1pdGVkMSEwHwYDVQQDExhRdW9WYWRpcyBJc3N1aW5nIENBIDEgRzMwggIiMA0G\n" + + "CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2Ud42yCfjYm4WlQ+nhTpZ9aPp0r8a\n" + + "yz+kKpPxc8ZWvEi7HDPhr7f5nWnEruHE0HbH8WyFGE+sICF788VpZLbFhL4wbIWV\n" + + "tHIrYan7+yL2yoNbHUBgeWxa48P96WxrW34K/OyQkJoSvY4iNk4BGI0wOYD9wsl9\n" + + "6wIaQFNu25Wsv0CcDSsyNjw8O8Ib6dmS6iib+KnZlKJnYqSTrzbnzf/2CU+Wb9V0\n" + + "yExk7shcfDpqxo9yyyEBPP1GUEb5SSr9qXYP2d4UsrRIgzKpD5feqdjk6ZGA4xeM\n" + + "JHo6GLjddNvVvopaKaLrDzlOXgqgbMIPQu+xkzpKW3IJOylxN55oVuH25MwbS9IL\n" + + "kDMv//kdiTUl1wXERZiUmcBdpWt9D9liyVxe5+HeI5VlhDuHsxDoPFmoOGTa6brX\n" + + "PXlNc0xji+grBQjIRNs43T5+GyYzCyjzG3dSb0BTYGLnfUAEQ1+MCC3K33DKL/me\n" + + "iUrWNclh85BQQigJr5HNLym3+J6Jf0OCnq4VmD1OFrhZrui02Xmz/hOECK2Mciga\n" + + "DxRgXBKjLebV0RW3j6libuPiKbxSinfqNqf2Q9eCfKrzgWQkuCHZvkt0Cqgzjbm1\n" + + "n5xu9zXR8YG5/680Nyb3tywUb6FhA8l1L/KLoK79RGjKgPotCog6Ykvy/667jlyo\n" + + "ZII0YUf6S3uyeQIDAQABo4HzMIHwMBIGA1UdEwEB/wQIMAYBAf8CAQEwEQYDVR0g\n" + + "BAowCDAGBgRVHSAAMDoGCCsGAQUFBwEBBC4wLDAqBggrBgEFBQcwAYYeaHR0cDov\n" + + "L29jc3AucXVvdmFkaXNnbG9iYWwuY29tMA4GA1UdDwEB/wQEAwIBBjAfBgNVHSME\n" + + "GDAWgBSjl9bzXqIQ4atFnzwXZDzuAXCczDA7BgNVHR8ENDAyMDCgLqAshipodHRw\n" + + "Oi8vY3JsLnF1b3ZhZGlzZ2xvYmFsLmNvbS9xdnJjYTFnMy5jcmwwHQYDVR0OBBYE\n" + + "FF0EGBL7w+p4fbRXCaH+bf6Cn2TNMA0GCSqGSIb3DQEBCwUAA4ICAQAF6qNCo3LP\n" + + "Qk8jthU1aiuo5WW9jQC+PqWeyVe4JjHK+5PRM+BtoErOItfZyPqoIBMedC/Ya9L1\n" + + "Sv0gncvifjtTD3jIBz0FVCbIMJLRp63b4qtmAGuB00XTXgCFcYoiIq5kyNedJnLe\n" + + "IxMqb0xx8IAqvP9kfEVNdGfvYraSswiGXADftZ3yM24zIc3Ysewi3JeTbzDhEGfb\n" + + "yv9eBplkfKfcoKyOds4sLcxj1QpUxcXgjX1mKTbfOSD5ac/Cjrz6Kqnl2+PNrc5N\n" + + "kXBVKhcCAjpqX5OyI86IUg9XY8i7Lz+tXzAQhllh+rPyTyAmieGf2iV9wrl//OZB\n" + + "l2nXwbgfA7QwQ2VdsmGJfW3a7Zc13GCNx0M2RUGJKLMJOavY72d41wAYPQ46AXls\n" + + "Ic7RJi6EWmwLi6lvw4kKFfWZ0c6vIJur1hLUUmLOt0UBZ226eIREVpmFbDGOLzfl\n" + + "gU0xKhqmU0aIOORzBGDfOrnctvaXORNNhCZ78zS96Egzu2w2OC47Zry7k+EOatzA\n" + + "5zrdJJM3UP7aMSNPvEygbcFUw2I04vpxUuPYTwCtogqNMHqFbCjLM9YxhzsGMdh/\n" + + "9aD1krboaSXUjrS9cOr5P2A9kFHCMsXBaDoaijQXNeyhu+oCeYsdv4S3djFwDW3+\n" + + "iPLo51aqZGsTZ1S22vYdkp+QFByLtArVMQ==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvica1g3-v.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIF9DCCA9ygAwIBAgIUGug3BoLw4/auIdDQ0mHS6QnPHB8wDQYJKoZIhvcNAQEL\n" + + "BQAwSzELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxITAf\n" + + "BgNVBAMTGFF1b1ZhZGlzIElzc3VpbmcgQ0EgMSBHMzAeFw0xNDExMTQxNDA1MDda\n" + + "Fw0xNzExMTQxNDA0NTFaMHYxCzAJBgNVBAYTAkJNMREwDwYDVQQIEwhQZW1icm9r\n" + + "ZTERMA8GA1UEBxMISGFtaWx0b24xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQx\n" + + "JjAkBgNVBAMTHXF2aWNhMWczLXYucXVvdmFkaXNnbG9iYWwuY29tMIIBIjANBgkq\n" + + "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwHoNPHE0C/tEwI5jeYvKJdo5SXSccB/c\n" + + "nCHJVs/4i9F8oRmPqNiFMD99UVylk4nn8iqi8MoxrFAhqtmplPslgRDLwyLMmnGO\n" + + "1cNoPKGMKxQq9EerBgSk4wqeSsSH+7qnZhCamIlvEm0PUaEH8rcjXokTs0fyjadF\n" + + "UmVwcmSZdmnNjseOMgm+G6C8tEPHRQl/Oezy6DzS9PQVLUFCBSyOaAgDnr4EvwGE\n" + + "u2fd3m+ys80XXGq4eLy1MmuC7U+bIQuupuydk/S7kVh7Rl+5nT1eTv0LEOj5gYFc\n" + + "C5SBnhiLibuRTOr+LsC9HpvN4vnoCaOogWxDQj/f1KRn45PNJncsbwIDAQABo4IB\n" + + "ozCCAZ8wdAYIKwYBBQUHAQEEaDBmMCoGCCsGAQUFBzABhh5odHRwOi8vb2NzcC5x\n" + + "dW92YWRpc2dsb2JhbC5jb20wOAYIKwYBBQUHMAKGLGh0dHA6Ly90cnVzdC5xdW92\n" + + "YWRpc2dsb2JhbC5jb20vcXZpY2ExZzMuY3J0MCgGA1UdEQQhMB+CHXF2aWNhMWcz\n" + + "LXYucXVvdmFkaXNnbG9iYWwuY29tMFEGA1UdIARKMEgwRgYMKwYBBAG+WAACZAEB\n" + + "MDYwNAYIKwYBBQUHAgEWKGh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL3Jl\n" + + "cG9zaXRvcnkwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggr\n" + + "BgEFBQcDAjAfBgNVHSMEGDAWgBRdBBgS+8PqeH20Vwmh/m3+gp9kzTA7BgNVHR8E\n" + + "NDAyMDCgLqAshipodHRwOi8vY3JsLnF1b3ZhZGlzZ2xvYmFsLmNvbS9xdmljYTFn\n" + + "My5jcmwwHQYDVR0OBBYEFJO98+S7NZMTz2JRogpUwLuxjTa0MA0GCSqGSIb3DQEB\n" + + "CwUAA4ICAQCq1O/BnzpQjbTbmEob/bWH/p92ZYRV0Lr01CdYkRXl4XKL2ZLusel6\n" + + "126AIvAK51o65wiGVaLGs49AKXOjcaAnTfwoFembqFRlBiGFSOdglTIsZUGdmhtP\n" + + "x1meetkOY8bY79viGkVCufAVq0hAF+AYh4nYM+/n7IijIcM5uhzIDb2Vw8+wKPTB\n" + + "7k2K/e1GGwbqrIAkjrZ6kpRg632RkbR18anaDVOgXuKzmZMRbIAii/N+lo7u3DhC\n" + + "5mJEIjP4cQXd569AfKQzvBO+syGDAJyX5PbTrd59IXZ+EjiisIq/DNQi6QalWMfS\n" + + "BnK97nUzH/BjAofMaUufbB8dxg+RT0QC/Yl1lmlA3CYmr6YWn06DiAuWL14ZFFwh\n" + + "2HQ7juU9oQ1I/HTfhVBoTzuKGCW1ZNXA64IdKlBsYp8NO9xKjBWIxwU/+S/IgoQP\n" + + "aTNkY4Mc353bdLi9082JwaiQ9B5eH0V9pZ17OSRU44o2TeDDT85sjF+krqCnnolR\n" + + "3lk7iqYDRHsvgqJqtkhhX/boF3wJAnKqaZ6j97PVqV75kwAak7XaH7C50RsPQGk2\n" + + "j5OFa6ioobW7tN5PfWAZPMZn98yX2Wh8Z95aGhdsHSJHsrlcUiWa+X2D1kF/dOKd\n" + + "R8rPqdPIPjUglrXS4yP+cJHx6fCJxW7me1R60lpuL6JNvHp54u7GGA==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvica1g3-r.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIF9DCCA9ygAwIBAgIUBAG4l0ZPYhEdLJSMWYCr7LHngvswDQYJKoZIhvcNAQEL\n" + + "BQAwSzELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxITAf\n" + + "BgNVBAMTGFF1b1ZhZGlzIElzc3VpbmcgQ0EgMSBHMzAeFw0xMjExMTQxMzQ4MDda\n" + + "Fw0xNDExMTQxMzQ4MDdaMHYxCzAJBgNVBAYTAkJNMREwDwYDVQQIEwhQZW1icm9r\n" + + "ZTERMA8GA1UEBxMISGFtaWx0b24xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQx\n" + + "JjAkBgNVBAMTHXF2aWNhMWczLXIucXVvdmFkaXNnbG9iYWwuY29tMIIBIjANBgkq\n" + + "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqlof1qJLTiqI7bf0IU7zOxy0HqjIn0pW\n" + + "lNIEVAjQRR1jnfpsMapicIGZfnnNaYpwdsIjGPwpvWXGA+30ezJNGfWMjhb/tiis\n" + + "qjrHdwXAob5MyXOXP5ZS8K34GwKeL45oJZZG0cf2FSta9/CSsRC9wnDUp/kA+VkH\n" + + "n5vlg7VpUExYO0CBXe4C4ehnvCZHjW5nqpVpm993f9i8E0W3vHPxjGuyuqVEEfma\n" + + "WfOV78+HF4hxALnr+73mp0i6Do2oa/v85mZzyKeBm2YHhwdQ6CC7UZtABlHyWuz9\n" + + "h/ocTGbX92rbUaW6icu9bKQkQ9jsomnQkU5b8CWseo2O0NXBevvCowIDAQABo4IB\n" + + "ozCCAZ8wdAYIKwYBBQUHAQEEaDBmMCoGCCsGAQUFBzABhh5odHRwOi8vb2NzcC5x\n" + + "dW92YWRpc2dsb2JhbC5jb20wOAYIKwYBBQUHMAKGLGh0dHA6Ly90cnVzdC5xdW92\n" + + "YWRpc2dsb2JhbC5jb20vcXZpY2ExZzMuY3J0MCgGA1UdEQQhMB+CHXF2aWNhMWcz\n" + + "LXIucXVvdmFkaXNnbG9iYWwuY29tMFEGA1UdIARKMEgwRgYMKwYBBAG+WAACZAEB\n" + + "MDYwNAYIKwYBBQUHAgEWKGh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL3Jl\n" + + "cG9zaXRvcnkwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggr\n" + + "BgEFBQcDAjAfBgNVHSMEGDAWgBRdBBgS+8PqeH20Vwmh/m3+gp9kzTA7BgNVHR8E\n" + + "NDAyMDCgLqAshipodHRwOi8vY3JsLnF1b3ZhZGlzZ2xvYmFsLmNvbS9xdmljYTFn\n" + + "My5jcmwwHQYDVR0OBBYEFNrefqnat67/DMlw0Z/xdQ478leyMA0GCSqGSIb3DQEB\n" + + "CwUAA4ICAQBG1TxJNbWzG4ShZefK4wEdScBzxSB7StYO3mmIP2D3LTlEk+zWjDVP\n" + + "ERPL41Si92asMHvMai7GcFT82XyHxsQGZIPcgIm+rC2NiSPDx2Vd6lkMaO8J9mrU\n" + + "3Z4Ks3G5HmszQ/gXRT3DCoNng+k+JqdZjrvMcsGTH+AzRdoinwOi+QnpphAcZRhS\n" + + "Io8C7w9osUPYFdDaE3Io+oYr2mWJg4n+FGsjxunQgIhLiiNaVF8zHxER7gW0YsCW\n" + + "vw1jX0dmfQZSdo2ybVeHuznUxtUWRHJ/nv6v2B2anUsVEbPyrpQ3i9+BzWaYolPU\n" + + "ZYxfMHBQ7HvncRP6rgrHF4x+iOnIxWsErYdEj5nQJkptYbVl41VzO6xMP7WvXFPa\n" + + "dqxwihqILRmAZrI9p/6k/HqV9xMPKprUhnWDGQ/bYnPKyXoTx6uwamaonX4DpW83\n" + + "b3CJTvBHwKh5eJQoBykAkakPdrmbOhe4/XWnDqQVUgJNmEvkg33AexviJo4mW3HG\n" + + "K2MdM60GRIC3Lcnd+Q8SnSCCxp+YtuE/C3Fu8VI/8vz9MC159GGtDzyC7OeKPCpU\n" + + "7H1X0X/OhBkiv7anK/oIhtSw+4DrM2eaVjdWkEa+di2jvI/2us8TXxO1LL+eeSxT\n" + + "E+LbdNO0jSp8azw2Aw4zL+Q41Fzt7OlH7mTkw1mxLF3aWsUNUz/p4w==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + if (ocspEnabled) { + // Revoked certificates are expired in Nov 2014 + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("Jan 01, 2014"); + } + + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Thu Jan 03 23:47:34 PST 2013", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} + +class RootCA2 { + + // Owner: CN=QuoVadis Global SSL ICA G3, O=QuoVadis Limited, C=BM + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGFzCCA/+gAwIBAgIUftbnnMmtgcTIGT75XUQodw40ExcwDQYJKoZIhvcNAQEL\n" + + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMiBHMzAeFw0xMjExMDYxNDUwMThaFw0y\n" + + "MjExMDYxNDUwMThaME0xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + + "aW1pdGVkMSMwIQYDVQQDExpRdW9WYWRpcyBHbG9iYWwgU1NMIElDQSBHMzCCAiIw\n" + + "DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANf8Od17be6c6lTGJDhEXpmkTs4y\n" + + "Q39Rr5VJyBeWCg06nSS71s6xF3sZvKcV0MbXlXCYM2ZX7cNTbJ81gs7uDsKFp+vK\n" + + "EymiKyEiI2SImOtECNnSg+RVR4np/xz/UlC0yFUisH75cZsJ8T1pkGMfiEouR0EM\n" + + "7O0uFgoboRfUP582TTWy0F7ynSA6YfGKnKj0OFwZJmGHVkLs1VevWjhj3R1fsPan\n" + + "H05P5moePFnpQdj1FofoSxUHZ0c7VB+sUimboHm/uHNY1LOsk77qiSuVC5/yrdg3\n" + + "2EEfP/mxJYT4r/5UiD7VahySzeZHzZ2OibQm2AfgfMN3l57lCM3/WPQBhMAPS1jz\n" + + "kE+7MjajM2f0aZctimW4Hasrj8AQnfAdHqZehbhtXaAlffNEzCdpNK584oCTVR7N\n" + + "UR9iZFx83ruTqpo+GcLP/iSYqhM4g7fy45sNhU+IS+ca03zbxTl3TTlkofXunI5B\n" + + "xxE30eGSQpDZ5+iUJcEOAuVKrlYocFbB3KF45hwcbzPWQ1DcO2jFAapOtQzeS+MZ\n" + + "yZzT2YseJ8hQHKu8YrXZWwKaNfyl8kFkHUBDICowNEoZvBwRCQp8sgqL6YRZy0uD\n" + + "JGxmnC2e0BVKSjcIvmq/CRWH7yiTk9eWm73xrsg9iIyD/kwJEnLyIk8tR5V8p/hc\n" + + "1H2AjDrZH12PsZ45AgMBAAGjgfMwgfAwEgYDVR0TAQH/BAgwBgEB/wIBATARBgNV\n" + + "HSAECjAIMAYGBFUdIAAwOgYIKwYBBQUHAQEELjAsMCoGCCsGAQUFBzABhh5odHRw\n" + + "Oi8vb2NzcC5xdW92YWRpc2dsb2JhbC5jb20wDgYDVR0PAQH/BAQDAgEGMB8GA1Ud\n" + + "IwQYMBaAFO3nb3Zav2DsSVvGpXe7chZxm8Q9MDsGA1UdHwQ0MDIwMKAuoCyGKmh0\n" + + "dHA6Ly9jcmwucXVvdmFkaXNnbG9iYWwuY29tL3F2cmNhMmczLmNybDAdBgNVHQ4E\n" + + "FgQUsxKJtalLNbwVAPCA6dh4h/ETfHYwDQYJKoZIhvcNAQELBQADggIBAFGm1Fqp\n" + + "RMiKr7a6h707M+km36PVXZnX1NZocCn36MrfRvphotbOCDm+GmRkar9ZMGhc8c/A\n" + + "Vn7JSCjwF9jNOFIOUyNLq0w4luk+Pt2YFDbgF8IDdx53xIo8Gv05e9xpTvQYaIto\n" + + "qeHbQjGXfSGc91olfX6JUwZlxxbhdJH+rxTFAg0jcbqToJoScWTfXSr1QRcNbSTs\n" + + "Y4CPG6oULsnhVvrzgldGSK+DxFi2OKcDsOKkV7W4IGg8Do2L/M588AfBnV8ERzpl\n" + + "qgMBBQxC2+0N6RdFHbmZt0HQE/NIg1s0xcjGx1XW3YTOfje31rmAXKHOehm4Bu48\n" + + "gr8gePq5cdQ2W9tA0Dnytb9wzH2SyPPIXRI7yNxaX9H8wYeDeeiKSSmQtfh1v5cV\n" + + "7RXvm8F6hLJkkco/HOW3dAUwZFcKsUH+1eUJKLN18eDGwB8yGawjHvOKqcfg5Lf/\n" + + "TvC7hgcx7pDYaCCaqHaekgUwXbB2Enzqr1fdwoU1c01W5YuQAtAx5wk1bf34Yq/J\n" + + "ph7wNXGvo88N0/EfP9AdVGmJzy7VuRXeVAOyjKAIeADMlwpjBRhcbs9m3dkqvoMb\n" + + "SXKJxv/hFmNgEOvOlaFsXX1dbKg1v+C1AzKAFdiuAIa62JzASiEhigqNSdqdTsOh\n" + + "8W8hdONuKKpe9zKedhBFAvuxhDgKmnySglYc\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvsslicag3-v.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIF+DCCA+CgAwIBAgIUE3XHqPhbZc2CY3aRtVHRlQwm3tcwDQYJKoZIhvcNAQEL\n" + + "BQAwTTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxIzAh\n" + + "BgNVBAMTGlF1b1ZhZGlzIEdsb2JhbCBTU0wgSUNBIEczMB4XDTE0MTExNDE0MDUz\n" + + "MVoXDTE3MTExNDE0MDUxM1oweDELMAkGA1UEBhMCQk0xETAPBgNVBAgTCFBlbWJy\n" + + "b2tlMREwDwYDVQQHEwhIYW1pbHRvbjEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRl\n" + + "ZDEoMCYGA1UEAxMfcXZzc2xpY2FnMy12LnF1b3ZhZGlzZ2xvYmFsLmNvbTCCASIw\n" + + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK621GAU2/hywjuxi2Q9rCMncWIY\n" + + "FbDngS69N6+qe9NUktfs/Rlh+jKUDHyf27G79xYGmDGZ0NTYI7tUyOvRanaq8ngd\n" + + "NkZI4DS/Au2vpwuXucrtm3V/XRcsWHAsyevVzfiqfZzu+vU7/2KT/k7sByRzED4x\n" + + "B4tMGaodvzIAzhFAmnmVXSUw7zvU07G/6/mfwYy9gwegJwVby/ZPWXefzHbLGDUz\n" + + "xtO/6Ow9e5T2hedpo3IgfKptkzy0kA501DNaTMulW1gJwB+1duJ9OxZOAVgGCANX\n" + + "IzWvgbONLEdkYGK+K8EAuMaa57WlG0wBZ9Y62iuvgw4XRd90/PS2RAFf/DsCAwEA\n" + + "AaOCAaMwggGfMHMGCCsGAQUFBwEBBGcwZTAqBggrBgEFBQcwAYYeaHR0cDovL29j\n" + + "c3AucXVvdmFkaXNnbG9iYWwuY29tMDcGCCsGAQUFBzAChitodHRwOi8vdHJ1c3Qu\n" + + "cXVvdmFkaXNnbG9iYWwuY29tL3F2c3NsZzMuY3J0MCoGA1UdEQQjMCGCH3F2c3Ns\n" + + "aWNhZzMtdi5xdW92YWRpc2dsb2JhbC5jb20wUQYDVR0gBEowSDBGBgwrBgEEAb5Y\n" + + "AAJkAQEwNjA0BggrBgEFBQcCARYoaHR0cDovL3d3dy5xdW92YWRpc2dsb2JhbC5j\n" + + "b20vcmVwb3NpdG9yeTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUH\n" + + "AwEGCCsGAQUFBwMCMB8GA1UdIwQYMBaAFLMSibWpSzW8FQDwgOnYeIfxE3x2MDoG\n" + + "A1UdHwQzMDEwL6AtoCuGKWh0dHA6Ly9jcmwucXVvdmFkaXNnbG9iYWwuY29tL3F2\n" + + "c3NsZzMuY3JsMB0GA1UdDgQWBBSSYP84MQGz6cU/fyXfebv/8zn93TANBgkqhkiG\n" + + "9w0BAQsFAAOCAgEAbqX71QIeoOJ36Aoiwg+oEwdDSRzXkR05kZU2y9qOCArrkgSj\n" + + "ycdIRQFjHYNAWJrPP17PErk6+6NDWiwxLXbeHaY7pFIDCsgcCTWpixVlpVPKKxAE\n" + + "uaomHo5K2AWWkJYNNPSLF411CmyN4eJjYQVrkCfJwFSUrQml8pFDedNDNuTaDsZo\n" + + "klvUDYWM18gFrAbNF4Wi+dvj3qPOpTVyrTk2oBXtVUesNu4JF/O6li10YJ+kdox+\n" + + "DUeq4Gk4B8zoWRTKa9Pp/RALI8TeNcfjBKbPtuXyfly1Cm8AXoQA5sus2SMMPQXE\n" + + "S1+IsdnnKb60pT1EOX571SIBKV16xpRpbC3mDU6IG/+Sjm0TJxwSGbBO5bX69+bq\n" + + "F8Im1QAKqVSYCtoypvieG3iGqHmj4SAaSqdmDDzmOPEtgX63ZmYVs+ey6tN+VThi\n" + + "eaLRs+pHeBLMhh7Npt85c+xqRlIFBp0e84EzST0oE7pjuZcFFWstFXD2Pt1JQfXo\n" + + "9szkw6EMhYbrgNqsh8lxkg8cZKHnP8KGLefyHajp3EIfC2MX7nUOeNmNoCxdsfBW\n" + + "lmzRbv7H7eeAmQYHmxUaRnDMGR6QVX8/NrF1w0hqLkIpDj+29Mvv/Gp2azJrvqrL\n" + + "w2bJ2mPD8rzBDmEFY317RWc8VBd8ZUxO/dYPWqsXNwBTdPMRQpYcN55po3g=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvsslicag3-r.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIF+DCCA+CgAwIBAgIUMJWFWsVjz9o3zQoG9bZ/IsdRWDkwDQYJKoZIhvcNAQEL\n" + + "BQAwTTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxIzAh\n" + + "BgNVBAMTGlF1b1ZhZGlzIEdsb2JhbCBTU0wgSUNBIEczMB4XDTEyMTExNDEzMTI1\n" + + "NFoXDTE0MTExNDEzMTI1NFoweDELMAkGA1UEBhMCQk0xETAPBgNVBAgTCFBlbWJy\n" + + "b2tlMREwDwYDVQQHEwhIYW1pbHRvbjEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRl\n" + + "ZDEoMCYGA1UEAxMfcXZzc2xpY2FnMy1yLnF1b3ZhZGlzZ2xvYmFsLmNvbTCCASIw\n" + + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALlwpCyabhrQYeRzEn0O7S505Fv4\n" + + "ScJlJRHskcyZHBt0vt2tsDJNh2xJKJpnXzW14oGh+xrccEGeUw77qeFgfy+LTIHD\n" + + "YDkYVHVhfs4NJD5wdyWL9Fn3A7pMFpapPBPJdsAAwByfzYFjRJsPHMSlGcroyGNm\n" + + "+LquU5r965afaRkWQzZy+lY+OHO19Jis8EfUusYj2fQ3SXB8tBwFylDTnbCoM1HZ\n" + + "BlbksbtLjFYKtyaNeQuoA7NnB3Q9XEONNK9KZ0S87KIqEKjIWK7ThO6lvhMQy2Zk\n" + + "k+UVXVLpop7+Nkz3Fn08pE4OMfLjn1KVnk5l40WGabinfE6hz4vk0XREaKcCAwEA\n" + + "AaOCAaMwggGfMHMGCCsGAQUFBwEBBGcwZTAqBggrBgEFBQcwAYYeaHR0cDovL29j\n" + + "c3AucXVvdmFkaXNnbG9iYWwuY29tMDcGCCsGAQUFBzAChitodHRwOi8vdHJ1c3Qu\n" + + "cXVvdmFkaXNnbG9iYWwuY29tL3F2c3NsZzMuY3J0MCoGA1UdEQQjMCGCH3F2c3Ns\n" + + "aWNhZzMtci5xdW92YWRpc2dsb2JhbC5jb20wUQYDVR0gBEowSDBGBgwrBgEEAb5Y\n" + + "AAJkAQEwNjA0BggrBgEFBQcCARYoaHR0cDovL3d3dy5xdW92YWRpc2dsb2JhbC5j\n" + + "b20vcmVwb3NpdG9yeTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUH\n" + + "AwEGCCsGAQUFBwMCMB8GA1UdIwQYMBaAFLMSibWpSzW8FQDwgOnYeIfxE3x2MDoG\n" + + "A1UdHwQzMDEwL6AtoCuGKWh0dHA6Ly9jcmwucXVvdmFkaXNnbG9iYWwuY29tL3F2\n" + + "c3NsZzMuY3JsMB0GA1UdDgQWBBSS2t3Itp/XsAppEeGyH+Ew8vEQ0zANBgkqhkiG\n" + + "9w0BAQsFAAOCAgEAo8MJ2ek95Cs3chn1ecEMdGkUANnCBmgdvQjFt6XVLzYWs37n\n" + + "j6Ac/nGj+Tzb30nTVdE2laRuTeLuGfYmd1AdBLHuRhWYG6A6jnlzqhmDRL3fvRYk\n" + + "wjeWQn6Kx/lOoWC1xOa2EJYOWDr/rUY2PKo9rSVdGKmU6NFI/+FOFLaUD8tU77Qq\n" + + "p9rfOYJwekckA2I2891lTRbnJfQhPD8mQjttd+nS46RwZxxAI5Pr6Jcr+BG3ARP5\n" + + "oM/ifTCLXCc4L/0nozUDSweU17TCuFXWGEpIXbOVmE3kpmHaVe1FRQ0PUr2XHCbJ\n" + + "H1vumQcJmOaUxiB4EzP+M+HnKg6rwhWlfgQEAnCcKkMF5ei1NAaHCwhRMC7ijJFA\n" + + "Wt7s0/PpP2tChU7uXctMk2d36Dpibyn6Rc5a/QJX444ZRFEGrSe4nO/MXt3iEcat\n" + + "fgYHOWoBunLIm7x/fd611xvyhifjqKVCPpqodpwFrXOlCQhXehhRvJSPDXWgDJeR\n" + + "cDLLIcit4Sn1uyebQcZafaxgYPWpaYHFd7dzkO+kTVqOVAm7LukC5QQ9qFY1z7a5\n" + + "IDUAFtEYg/c4XxX+pReOxydnnHeYZBrfRTTxOfMrg6dxsb1QcOeElXHgXRpHyiMh\n" + + "XYsZWE2WHT7of4wMfNzCUrVSN0tCGDRW0MI48RM4BYbRnz3YNKafjnszeXI=\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + if (ocspEnabled) { + // Revoked certificates are expired in Nov 2014 + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("Jan 01, 2014"); + } + + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Fri Jan 04 03:49:46 PST 2013", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} + +class RootCA3 { + + // wner: CN=QuoVadis Issuing CA 3 G3, O=QuoVadis Limited, C=BM + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGFTCCA/2gAwIBAgIUHZxbikClihb+1PM2ck0SDEZ8/dIwDQYJKoZIhvcNAQEL\n" + + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMyBHMzAeFw0xMjExMDYxODM5MDVaFw0y\n" + + "MjExMDYxODM5MDVaMEsxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + + "aW1pdGVkMSEwHwYDVQQDExhRdW9WYWRpcyBJc3N1aW5nIENBIDMgRzMwggIiMA0G\n" + + "CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCs6x3rpBdA1tTXgPYNjL1MKHuoDyb9\n" + + "d4mxxk41t5Cvo3BnS0/cBlRIl91oqu3Iv9goVCMStla+GW9iRdX/53jYM1rXePDa\n" + + "OnE/MJNLcVjmABZmEUtpzxUYLftwGEg1w/Wgi6z68vqZn7vbHJtFV8inlMIsdBVY\n" + + "o3VmU9h+pGZU8JrF8x8U3voX4vm56OBCAM/1osUGXsVL2AY3z2Gjyb1Hv6fqHma7\n" + + "PWrWV1hYS/EAnRUPO8iQqJwrbT/j7Mlo3khULV+T02M+oqs1ckIihl38n1eGvYcp\n" + + "z40cceA2Ej5aglyF9i+ypA4XnxKF3f+6vvEYRPCMQB8Hiwuyy6naj6lPoLZ+nolT\n" + + "t++xSkZ5imAoTXewA9JxyGCdiO9G4sZFIy4jjW7HBmKx6pZy3wWf48eawXPIpjop\n" + + "EC+Kayf3foeyq40CAOjysVkblhUBawvVjAqKJ5aoKD4Ghnv02jdVvI4W7ME/fYYb\n" + + "gm+XD7KJv4gHks+SIV93eXiUhYHvofJ3AG/1kp1p4tvIKCUtm2LCihmp53n9uLGA\n" + + "NvizEnkuQmwlXtqOquKDluwSpHVFPxePMdRICUOnoZBdHv6f3LQCOU7AczRJYh8+\n" + + "WYSKQy675/Itucgd+ABfY1H07F4FisCP75j8YknBdv4nfQsb0RcTg2P89dJNwAhL\n" + + "rpk452WD4LuvsQIDAQABo4HzMIHwMBIGA1UdEwEB/wQIMAYBAf8CAQEwEQYDVR0g\n" + + "BAowCDAGBgRVHSAAMDoGCCsGAQUFBwEBBC4wLDAqBggrBgEFBQcwAYYeaHR0cDov\n" + + "L29jc3AucXVvdmFkaXNnbG9iYWwuY29tMA4GA1UdDwEB/wQEAwIBBjAfBgNVHSME\n" + + "GDAWgBTGF9C8qOoCQ/IbBpldK5Agudec5DA7BgNVHR8ENDAyMDCgLqAshipodHRw\n" + + "Oi8vY3JsLnF1b3ZhZGlzZ2xvYmFsLmNvbS9xdnJjYTNnMy5jcmwwHQYDVR0OBBYE\n" + + "FBPyQfSNOURHBZ37q8ZaNQwelu9eMA0GCSqGSIb3DQEBCwUAA4ICAQAsbJU89ZB9\n" + + "1XVlOLmw8MaoWwOgI3DwM/g30YyIV1SERtDMKDOUnLVGTORTGv7Y8X789nGkMbKq\n" + + "OEEa9Hty4jwyTnt2OISpCAb4GwBtH+FxNcLkJwZU2qtpTX8zDndofE/JLGo0rte5\n" + + "bKchF2JTg+oby/Wpu2IO0CMd1phou3LLi8sWQGcY/f5vk+MUDnskH6NRXte4m8HW\n" + + "FtYb7nOgLzY5FOJDtQuUFFioNoQzUHuj3SpUjIBxXf4VRFXz+FKIQ4jqzD/SnHG6\n" + + "/7g/28x66LNpYjvaQ0T45EqxqPDCztfJO67GsNLXeSKq+BteqXcnKI77ZkqmwnWl\n" + + "cYt5qek0GBYRYVOM8dUIvDryWHZIEqbeI0DAu06dyPuvIJNQ6WweqxJ+hH++BqGh\n" + + "P4bViNNuP/Lqarb1RP7JiJW3wlyIUDD34JLzkusBgU++ptdYg1o0VnEB8KWDG8Of\n" + + "cABL+TMoUldUp9DFFgFJIfnPX5XjXyG9mw2wwiUvClo93qFvC8+rhEGeZFd29rKi\n" + + "dmmCc8FaCfBV9XdHHx/0ORTQp3HxnRDDiz+MN7p1Y4SXbHE3XXyQAUVTISGpPe3X\n" + + "TUhmoARNmBBPALDm3EAvEBikTUMBFGR63wtu0pjA2cF5nvOyY8mBSsNk0R6+ZJSl\n" + + "Cok3lH5oBM2H+KBk+sNZIBQ8BHcgbwlghg==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvica3g3-v.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIF9DCCA9ygAwIBAgIUTkK7g7zoijtiLY/YV9ASX+pEsx0wDQYJKoZIhvcNAQEL\n" + + "BQAwSzELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxITAf\n" + + "BgNVBAMTGFF1b1ZhZGlzIElzc3VpbmcgQ0EgMyBHMzAeFw0xNDExMTQxNDA1NTJa\n" + + "Fw0xNzExMTQxNDA1MzhaMHYxCzAJBgNVBAYTAkJNMREwDwYDVQQIEwhQZW1icm9r\n" + + "ZTERMA8GA1UEBxMISGFtaWx0b24xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQx\n" + + "JjAkBgNVBAMTHXF2aWNhM2czLXYucXVvdmFkaXNnbG9iYWwuY29tMIIBIjANBgkq\n" + + "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAosZjGbZtvAM45zdlTtT+uL12F5nebQrE\n" + + "F9Fb8z1uhRJKgXAfjlfsMIjv7Xc7F80Li39yO0CmWHTMJS41auktW8IGVEkVV2og\n" + + "EL7SKLjtgDJ1I3HAX02hfuOW0b/jkfPEcqTeZVE5Xew/HTAuTJMTqCEHM5hFieWL\n" + + "tADPm7kANu5q6HaFXndKN/k1ozZXQn9YNTpDvvH6oD0Kqn/Peezi+C+6asTMSCk0\n" + + "Xoi2TBHNi9dl2tfb6hu+T5VFwFsC9dGqYt07V8TbvKRAVV0MC8DnXnS89quFVmPS\n" + + "I3ZSKeU4dlp8FzmTrd5nk3y9GL8GTkCsSN3RZbeAbLCpzcG5weS3GQIDAQABo4IB\n" + + "ozCCAZ8wdAYIKwYBBQUHAQEEaDBmMCoGCCsGAQUFBzABhh5odHRwOi8vb2NzcC5x\n" + + "dW92YWRpc2dsb2JhbC5jb20wOAYIKwYBBQUHMAKGLGh0dHA6Ly90cnVzdC5xdW92\n" + + "YWRpc2dsb2JhbC5jb20vcXZpY2EzZzMuY3J0MCgGA1UdEQQhMB+CHXF2aWNhM2cz\n" + + "LXYucXVvdmFkaXNnbG9iYWwuY29tMFEGA1UdIARKMEgwRgYMKwYBBAG+WAACZAEB\n" + + "MDYwNAYIKwYBBQUHAgEWKGh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL3Jl\n" + + "cG9zaXRvcnkwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggr\n" + + "BgEFBQcDAjAfBgNVHSMEGDAWgBQT8kH0jTlERwWd+6vGWjUMHpbvXjA7BgNVHR8E\n" + + "NDAyMDCgLqAshipodHRwOi8vY3JsLnF1b3ZhZGlzZ2xvYmFsLmNvbS9xdmljYTNn\n" + + "My5jcmwwHQYDVR0OBBYEFINCE86z3wESNeL4rz3eiaYA5LIWMA0GCSqGSIb3DQEB\n" + + "CwUAA4ICAQBPe+Y5xDGZLYaVNOxxiyqFZrntGJGGQW1w4GtEfkH9oD8WGs5kBhMM\n" + + "/XPGqw2FzzrvA5GfSdh+EMuXUfJY933AxwPcNfwGHzYGAHIDFsW17y5ZdKfBMN4Y\n" + + "82e13iSfHQrbI0P6l8IIExfCw4HC8PxuEalg6H9fj9/1Q7mzdpwT3uG/HP6Dr2z+\n" + + "PGYFMaH77MsOjfANT8UIdo5SAyXiJI5Y0cyKjuXhR6eJEKwNfri27UaV5cJJuV7I\n" + + "fRcjb0h0Grr6gpKFb7JnhDZVGR3fDHTzuybuCqZk9TYKQ2sn1YfBFDqDpWODpykt\n" + + "vyFO7eugpvSUgdTKRMPCtyppYgo2RwIsMmLrU4wPzdnPi8oo+cM0f5zXrmrkOLY0\n" + + "PZo+K8QT/SrNT+9yZnHupLy01aYGJ4RJ047Wthr7a9S6i6DxbQ+ps4Ajh0X1bvOK\n" + + "KCEKq5aoivYQMLn8pjudiMjbnKU4mgpmZK15D6lLmAprW3L6F8AEBJsK1BunPWhJ\n" + + "nkQUyBnFgq2epmDfZ4f6SztNoLfDbatYNRb2KJfW1lks7UHDjuZ4PM20KkmmFJEE\n" + + "LKR76WJzKi/+aks/csdFD7+/TMXrkY+JWlT4mCoHR1ol0m3DiqApKvRFZkMARfJq\n" + + "npjt2cXyzDnguyQuLrHhdkKW+/LYeNckmVX+cPIxShLbuVhqMgdnWg==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvica3g3-r.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIF9DCCA9ygAwIBAgIUSTXTLsMPxg4n9YY6GASBcJsgcaEwDQYJKoZIhvcNAQEL\n" + + "BQAwSzELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxITAf\n" + + "BgNVBAMTGFF1b1ZhZGlzIElzc3VpbmcgQ0EgMyBHMzAeFw0xMjExMTQxMzQ4MTda\n" + + "Fw0xNDExMTQxMzQ4MTdaMHYxCzAJBgNVBAYTAkJNMREwDwYDVQQIEwhQZW1icm9r\n" + + "ZTERMA8GA1UEBxMISGFtaWx0b24xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQx\n" + + "JjAkBgNVBAMTHXF2aWNhM2czLXIucXVvdmFkaXNnbG9iYWwuY29tMIIBIjANBgkq\n" + + "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtaZUVAvasDtoFhZqL2fH+rI/IKeY0zj7\n" + + "hGuYpLlT32JZX8cmkWUywZt6VxA8A5o82Ay0xT9vHy4MPnmmZExEvmkaECBmOh6+\n" + + "WzWydYGKeeheUERJ1hLj2T7MKz/CCFY6NxD9XzvYOyhDpCUQKCOx4LMn0nMFrXrS\n" + + "6IVirDUmH26dpl3IfsdVXyn6N3wLSNf+UX7in/PXsfD/A6RVtqYsfx4fxFJIPIhv\n" + + "XG/cDOVIyfq6Oo1hthzGm8cnOSjvK/UfQV5iVBK68rqoGG+r9uBG9BfZtd7o0wrf\n" + + "SSJkJAPJVpWTLvnD8RYpJIBz01vNgEOCEgF54bvjhBOjx15mrH7roQIDAQABo4IB\n" + + "ozCCAZ8wdAYIKwYBBQUHAQEEaDBmMCoGCCsGAQUFBzABhh5odHRwOi8vb2NzcC5x\n" + + "dW92YWRpc2dsb2JhbC5jb20wOAYIKwYBBQUHMAKGLGh0dHA6Ly90cnVzdC5xdW92\n" + + "YWRpc2dsb2JhbC5jb20vcXZpY2EzZzMuY3J0MCgGA1UdEQQhMB+CHXF2aWNhM2cz\n" + + "LXIucXVvdmFkaXNnbG9iYWwuY29tMFEGA1UdIARKMEgwRgYMKwYBBAG+WAACZAEB\n" + + "MDYwNAYIKwYBBQUHAgEWKGh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL3Jl\n" + + "cG9zaXRvcnkwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggr\n" + + "BgEFBQcDAjAfBgNVHSMEGDAWgBQT8kH0jTlERwWd+6vGWjUMHpbvXjA7BgNVHR8E\n" + + "NDAyMDCgLqAshipodHRwOi8vY3JsLnF1b3ZhZGlzZ2xvYmFsLmNvbS9xdmljYTNn\n" + + "My5jcmwwHQYDVR0OBBYEFLnaKDrPemoRtOZaUReSV5rWp3OoMA0GCSqGSIb3DQEB\n" + + "CwUAA4ICAQA+B+R1TDmE4jC6itHBMPgqRoETJxtTdKyp6/egk5My4MATXRCSrStA\n" + + "gp1c86hljmlN2gq05HKlAz9cC4W80pypJGfEbhYIi9B4Jxdo6zJNJqcFz3zj/otx\n" + + "hvZ2nOO5qqEupAP8aHju0LhUlkcFQlbqaA+IiuQUh0VFQxk8LwkKEA8oIib7wLie\n" + + "P1zBMXeRyDM5CnFWQmIFKXR4+9f51Dfv40Gy2RKQT7I8oXuADhrG9iXFJPXz4yYK\n" + + "LazlDjnn0wv4vB9BmlcVdM2HPYqIPdvWBtPxT9vpNYHnB9Dq/zGqKJNUh8I4jB9k\n" + + "8iQYJgoj62mQW2o1fObkVwrGgglAyzUzUzJfJyy9OEECjLY5o/9TJAKBAnewJ5B9\n" + + "PagYo+klH937s2MOLqzl/uvbjXUBBvql1UU/lb8tSK9xCaXMEDhgiVricr13k32y\n" + + "XmUcA/im96CI5cF5i4xHMnqprzPehFB/Mmi6g2tpiE0bmLkYj7MMJcmtUowa3FqA\n" + + "QHtqKrK8wOfHep6qPx6VMD6Ypaf6yq66/kkSg05i6VO7V371UTibHeVLTr7LPRQJ\n" + + "Emp8k/6qCXOtf5OdXwHBIDqvszf8ry85Rl3q813TntF0pPRvqLEYadC4Bwq7Snf+\n" + + "PR0MPNhuwZBCmxZcyZqhVG2PyvvEmhPxhEdbO5DWUFwUP17WHNlgeQ==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + if (ocspEnabled) { + // Revoked certificates are expired in Nov 2014 + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("Jan 01, 2014"); + } + + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Thu Jan 03 23:47:02 PST 2013", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ValidatePathWithParams.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ValidatePathWithParams.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,354 @@ +/* + * Copyright (c) 2017, 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.ByteArrayInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.Security; +import java.security.cert.CertPath; +import java.security.cert.CertPathValidator; +import java.security.cert.CertPathValidatorException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateExpiredException; +import java.security.cert.CertificateFactory; +import java.security.cert.CertificateRevokedException; +import java.security.cert.PKIXParameters; +import java.security.cert.PKIXRevocationChecker; +import java.security.cert.X509Certificate; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.EnumSet; +import java.util.Locale; + +/** + * Utility class to validate certificate path. It supports OCSP and/or CRL + * validation. + */ +public class ValidatePathWithParams { + + private static final String FS = System.getProperty("file.separator"); + private static final String CACERTS_STORE = System.getProperty("test.jdk") + + FS + "lib" + FS + "security" + FS + "cacerts"; + + private final String[] trustedRootCerts; + + // use this for expired cert validation + private Date validationDate = null; + + // expected certificate status + private Status expectedStatus = Status.UNKNOWN; + private Date expectedRevDate = null; + + private final CertPathValidator certPathValidator; + private final PKIXRevocationChecker certPathChecker; + private final CertificateFactory cf; + + /** + * Possible status values supported for EE certificate + */ + public static enum Status { + UNKNOWN, GOOD, REVOKED, EXPIRED; + } + + /** + * Constructor + * + * @param additionalTrustRoots trusted root certificates + * @throws IOException + * @throws CertificateException + * @throws NoSuchAlgorithmException + */ + public ValidatePathWithParams(String[] additionalTrustRoots) + throws IOException, CertificateException, NoSuchAlgorithmException { + + cf = CertificateFactory.getInstance("X509"); + certPathValidator = CertPathValidator.getInstance("PKIX"); + certPathChecker + = (PKIXRevocationChecker) certPathValidator.getRevocationChecker(); + + if ((additionalTrustRoots == null) || (additionalTrustRoots[0] == null)) { + trustedRootCerts = null; + } else { + trustedRootCerts = additionalTrustRoots.clone(); + } + } + + /** + * Validate certificates + * + * @param certsToValidate Certificates to validate + * @param st expected certificate status + * @param revDate if revoked, expected revocation date + * @param out PrintStream to log messages + * @throws IOException + * @throws CertificateException + * @throws InvalidAlgorithmParameterException + * @throws ParseException + * @throws NoSuchAlgorithmException + * @throws KeyStoreException + */ + public void validate(String[] certsToValidate, + Status st, + String revDate, + PrintStream out) + throws IOException, CertificateException, + InvalidAlgorithmParameterException, ParseException, + NoSuchAlgorithmException, KeyStoreException { + + expectedStatus = st; + if (expectedStatus == Status.REVOKED) { + if (revDate != null) { + expectedRevDate = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", + Locale.US).parse(revDate); + } + } + + Status certStatus = null; + Date revocationDate = null; + + logSettings(out); + + try { + doCertPathValidate(certsToValidate, out); + certStatus = Status.GOOD; + } catch (IOException ioe) { + // Some machines don't have network setup correctly to be able to + // reach outside world, skip such failures + out.println("WARNING: Network setup issue, skip this test"); + ioe.printStackTrace(System.err); + return; + } catch (CertPathValidatorException cpve) { + out.println("Received exception: " + cpve); + + if (cpve.getCause() instanceof IOException) { + out.println("WARNING: CertPathValidatorException caused by IO" + + " error, skip this test"); + return; + } + + if (cpve.getReason() == CertPathValidatorException.BasicReason.ALGORITHM_CONSTRAINED) { + out.println("WARNING: CertPathValidatorException caused by" + + " restricted algorithm, skip this test"); + return; + } + + if (cpve.getReason() == CertPathValidatorException.BasicReason.REVOKED + || cpve.getCause() instanceof CertificateRevokedException) { + certStatus = Status.REVOKED; + if (cpve.getCause() instanceof CertificateRevokedException) { + CertificateRevokedException cre + = (CertificateRevokedException) cpve.getCause(); + revocationDate = cre.getRevocationDate(); + } + } else if (cpve.getReason() == CertPathValidatorException.BasicReason.EXPIRED + || cpve.getCause() instanceof CertificateExpiredException) { + certStatus = Status.EXPIRED; + } else { + throw new RuntimeException( + "TEST FAILED: couldn't determine EE certificate status"); + } + } + + out.println("Expected Certificate status: " + expectedStatus); + out.println("Certificate status after validation: " + certStatus.name()); + + // Don't want test to fail in case certificate is expired when not expected + // Simply skip the test. + if (expectedStatus != Status.EXPIRED && certStatus == Status.EXPIRED) { + out.println("WARNING: Certificate expired, skip the test"); + return; + } + + if (certStatus != expectedStatus) { + throw new RuntimeException( + "TEST FAILED: unexpected status of EE certificate"); + } + + if (certStatus == Status.REVOKED) { + // Check revocation date + if (revocationDate != null) { + out.println( + "Certificate revocation date:" + revocationDate.toString()); + if (expectedRevDate != null) { + out.println( + "Expected revocation date:" + expectedRevDate.toString()); + if (!expectedRevDate.equals(revocationDate)) { + throw new RuntimeException( + "TEST FAILED: unexpected revocation date"); + } + } + } else { + throw new RuntimeException("TEST FAILED: no revocation date"); + } + } + } + + private void logSettings(PrintStream out) { + out.println(); + out.println("====================================================="); + out.println("CONFIGURATION"); + out.println("====================================================="); + out.println("http.proxyHost :" + System.getProperty("http.proxyHost")); + out.println("http.proxyPort :" + System.getProperty("http.proxyPort")); + out.println("https.proxyHost :" + System.getProperty("https.proxyHost")); + out.println("https.proxyPort :" + System.getProperty("https.proxyPort")); + out.println("https.socksProxyHost :" + + System.getProperty("https.socksProxyHost")); + out.println("https.socksProxyPort :" + + System.getProperty("https.socksProxyPort")); + out.println("jdk.certpath.disabledAlgorithms :" + + Security.getProperty("jdk.certpath.disabledAlgorithms")); + out.println("Revocation options :" + certPathChecker.getOptions()); + out.println("OCSP responder set :" + certPathChecker.getOcspResponder()); + out.println("Trusted root set: " + (trustedRootCerts != null)); + + if (validationDate != null) { + out.println("Validation Date:" + validationDate.toString()); + } + out.println("Expected EE Status:" + expectedStatus.name()); + if (expectedStatus == Status.REVOKED && expectedRevDate != null) { + out.println( + "Expected EE Revocation Date:" + expectedRevDate.toString()); + } + out.println("====================================================="); + } + + private void doCertPathValidate(String[] certsToValidate, PrintStream out) + throws IOException, CertificateException, + InvalidAlgorithmParameterException, ParseException, + NoSuchAlgorithmException, CertPathValidatorException, KeyStoreException { + + if (certsToValidate == null) { + throw new RuntimeException("Require atleast one cert to validate"); + } + + // Generate CertPath with certsToValidate + ArrayList certs = new ArrayList(); + for (String cert : certsToValidate) { + if (cert != null) { + certs.add(getCertificate(cert)); + } + } + CertPath certPath = (CertPath) cf.generateCertPath(certs); + + // Set cacerts as anchor + KeyStore cacerts = KeyStore.getInstance("JKS"); + try (FileInputStream fis = new FileInputStream(CACERTS_STORE)) { + cacerts.load(fis, "changeit".toCharArray()); + } catch (IOException | NoSuchAlgorithmException | CertificateException ex) { + throw new RuntimeException(ex); + } + + // Set additional trust certificates + if (trustedRootCerts != null) { + for (int i = 0; i < trustedRootCerts.length; i++) { + X509Certificate rootCACert = getCertificate(trustedRootCerts[i]); + cacerts.setCertificateEntry("tempca" + i, rootCACert); + } + } + + PKIXParameters params; + params = new PKIXParameters(cacerts); + params.addCertPathChecker(certPathChecker); + + // Set backdated validation if requested, if null, current date is set + params.setDate(validationDate); + + // Validate + certPathValidator.validate(certPath, params); + out.println("Successful CertPath validation"); + } + + private X509Certificate getCertificate(String encodedCert) + throws IOException, CertificateException { + ByteArrayInputStream is + = new ByteArrayInputStream(encodedCert.getBytes()); + X509Certificate cert = (X509Certificate) cf.generateCertificate(is); + return cert; + } + + /** + * Set list of disabled algorithms + * + * @param algos algorithms to disable + */ + public static void setDisabledAlgorithms(String algos) { + Security.setProperty("jdk.certpath.disabledAlgorithms", algos); + } + + /** + * Enable OCSP only revocation checks, treat network error as success + */ + public void enableOCSPCheck() { + // OCSP is by default, disable fallback to CRL + certPathChecker.setOptions(EnumSet.of( + PKIXRevocationChecker.Option.NO_FALLBACK)); + } + + /** + * Enable CRL only revocation check, treat network error as success + */ + public void enableCRLCheck() { + certPathChecker.setOptions(EnumSet.of( + PKIXRevocationChecker.Option.PREFER_CRLS, + PKIXRevocationChecker.Option.NO_FALLBACK)); + } + + /** + * Overrides OCSP responder URL in AIA extension of certificate + * + * @param url OCSP responder + * @throws URISyntaxException + */ + public void setOCSPResponderURL(String url) throws URISyntaxException { + certPathChecker.setOcspResponder(new URI(url)); + } + + /** + * Set validation date for EE certificate + * + * @param vDate string formatted date + * @throws ParseException if vDate is incorrect + */ + public void setValidationDate(String vDate) throws ParseException { + validationDate = DateFormat.getDateInstance(DateFormat.MEDIUM, + Locale.US).parse(vDate); + } + + /** + * Reset validation date for EE certificate to current date + */ + public void resetValidationDate() { + validationDate = null; + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/sun/security/pkcs11/PKCS11Test.java --- a/test/jdk/sun/security/pkcs11/PKCS11Test.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/sun/security/pkcs11/PKCS11Test.java Wed Dec 13 10:25:38 2017 -0800 @@ -741,13 +741,18 @@ } private static String distro() { - try (BufferedReader in = - new BufferedReader(new InputStreamReader( - Runtime.getRuntime().exec("uname -v").getInputStream()))) { + if (props.getProperty("os.name").equals("SunOS")) { + try (BufferedReader in = + new BufferedReader(new InputStreamReader( + Runtime.getRuntime().exec("uname -v").getInputStream()))) { - return in.readLine(); - } catch (Exception e) { - throw new RuntimeException("Failed to determine distro.", e); + return in.readLine(); + } catch (Exception e) { + throw new RuntimeException("Failed to determine distro.", e); + } + } else { + // Not used outside Solaris + return null; } } diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/sun/security/pkcs11/Secmod/README-SQLITE --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/sun/security/pkcs11/Secmod/README-SQLITE Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,8 @@ +// How to create key4.db and cert9.db +cd +echo "" > 1 +echo "test12" > 2 +modutil -create -force -dbdir sql:/$(pwd) +modutil -list "NSS Internal PKCS #11 Module" -dbdir sql:/$(pwd) +modutil -changepw "NSS Certificate DB" -force -dbdir sql:/$(pwd) -pwfile $(pwd)/1 -newpwfile $(pwd)/2 + diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/sun/security/pkcs11/Secmod/TestNssDbSqlite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/sun/security/pkcs11/Secmod/TestNssDbSqlite.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * + * 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 8165996 + * @summary Test NSS DB Sqlite + * @library ../ + * @modules java.base/sun.security.rsa + * java.base/sun.security.provider + * java.base/sun.security.jca + * java.base/sun.security.tools.keytool + * java.base/sun.security.x509 + * java.base/com.sun.crypto.provider + * jdk.crypto.cryptoki/sun.security.pkcs11:+open + * @run main/othervm/timeout=120 TestNssDbSqlite + * @author Martin Balao (mbalao@redhat.com) + */ + +import java.security.PrivateKey; +import java.security.cert.Certificate; +import java.security.KeyStore; +import java.security.Provider; +import java.security.Signature; + +import sun.security.rsa.SunRsaSign; +import sun.security.jca.ProviderList; +import sun.security.jca.Providers; +import sun.security.tools.keytool.CertAndKeyGen; +import sun.security.x509.X500Name; + +public final class TestNssDbSqlite extends SecmodTest { + + private static final boolean enableDebug = true; + + private static Provider sunPKCS11NSSProvider; + private static Provider sunRsaSignProvider; + private static Provider sunJCEProvider; + private static KeyStore ks; + private static char[] passphrase = "test12".toCharArray(); + private static PrivateKey privateKey; + private static Certificate certificate; + + public static void main(String[] args) throws Exception { + + initialize(); + + if (enableDebug) { + System.out.println("SunPKCS11 provider: " + + sunPKCS11NSSProvider); + } + + testRetrieveKeysFromKeystore(); + + System.out.println("Test PASS - OK"); + } + + private static void testRetrieveKeysFromKeystore() throws Exception { + + String plainText = "known plain text"; + + ks.setKeyEntry("root_ca_1", privateKey, passphrase, + new Certificate[]{certificate}); + PrivateKey k1 = (PrivateKey) ks.getKey("root_ca_1", passphrase); + + Signature sS = Signature.getInstance( + "SHA256withRSA", sunPKCS11NSSProvider); + sS.initSign(k1); + sS.update(plainText.getBytes()); + byte[] generatedSignature = sS.sign(); + + if (enableDebug) { + System.out.println("Generated signature: "); + for (byte b : generatedSignature) { + System.out.printf("0x%02x, ", (int)(b) & 0xFF); + } + System.out.println(""); + } + + Signature sV = Signature.getInstance("SHA256withRSA", sunRsaSignProvider); + sV.initVerify(certificate); + sV.update(plainText.getBytes()); + if(!sV.verify(generatedSignature)){ + throw new Exception("Couldn't verify signature"); + } + } + + private static void initialize() throws Exception { + initializeProvider(); + } + + private static void initializeProvider () throws Exception { + useSqlite(true); + if (!initSecmod()) { + return; + } + + sunPKCS11NSSProvider = getSunPKCS11(BASE + SEP + "nss-sqlite.cfg"); + sunJCEProvider = new com.sun.crypto.provider.SunJCE(); + sunRsaSignProvider = new SunRsaSign(); + Providers.setProviderList(ProviderList.newList( + sunJCEProvider, sunPKCS11NSSProvider, + new sun.security.provider.Sun(), sunRsaSignProvider)); + + ks = KeyStore.getInstance("PKCS11-NSS-Sqlite", sunPKCS11NSSProvider); + ks.load(null, passphrase); + + CertAndKeyGen gen = new CertAndKeyGen("RSA", "SHA256withRSA"); + gen.generate(2048); + privateKey = gen.getPrivateKey(); + certificate = gen.getSelfCertificate(new X500Name("CN=Me"), 365); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/sun/security/pkcs11/Secmod/cert9.db Binary file test/jdk/sun/security/pkcs11/Secmod/cert9.db has changed diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/sun/security/pkcs11/Secmod/key4.db Binary file test/jdk/sun/security/pkcs11/Secmod/key4.db has changed diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/sun/security/pkcs11/Secmod/nss-sqlite.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/sun/security/pkcs11/Secmod/nss-sqlite.cfg Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,13 @@ +# config file for secmod KeyStore access using sqlite backend + +name = NSS-Sqlite + +nssLibraryDirectory = ${pkcs11test.nss.libdir} + +nssDbMode = readWrite + +nssModule = keystore + +nssSecmodDirectory = ${pkcs11test.nss.db} + +attributes = compatibility diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/sun/security/pkcs11/SecmodTest.java --- a/test/jdk/sun/security/pkcs11/SecmodTest.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/sun/security/pkcs11/SecmodTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -34,6 +34,11 @@ static String DBDIR; static char[] password = "test12".toCharArray(); static String keyAlias = "mykey"; + static boolean useSqlite = false; + + static void useSqlite(boolean b) { + useSqlite = b; + } static boolean initSecmod() throws Exception { useNSS(); @@ -49,14 +54,24 @@ safeReload(LIBPATH + System.mapLibraryName("nssckbi")); DBDIR = System.getProperty("test.classes", ".") + SEP + "tmpdb"; - System.setProperty("pkcs11test.nss.db", DBDIR); + if (useSqlite) { + System.setProperty("pkcs11test.nss.db", "sql:/" + DBDIR); + } else { + System.setProperty("pkcs11test.nss.db", DBDIR); + } File dbdirFile = new File(DBDIR); if (dbdirFile.exists() == false) { dbdirFile.mkdir(); } - copyFile("secmod.db", BASE, DBDIR); - copyFile("key3.db", BASE, DBDIR); - copyFile("cert8.db", BASE, DBDIR); + + if (useSqlite) { + copyFile("key4.db", BASE, DBDIR); + copyFile("cert9.db", BASE, DBDIR); + } else { + copyFile("secmod.db", BASE, DBDIR); + copyFile("key3.db", BASE, DBDIR); + copyFile("cert8.db", BASE, DBDIR); + } return true; } diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/sun/text/resources/LocaleData.cldr --- a/test/jdk/sun/text/resources/LocaleData.cldr Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/sun/text/resources/LocaleData.cldr Wed Dec 13 10:25:38 2017 -0800 @@ -34,8 +34,8 @@ FormatData/pt_BR/DayNames/0=domingo FormatData/pt_BR/DayNames/1=segunda-feira FormatData/pt_BR/DayNames/2=ter\u00e7a-feira -CalendarData/pt_BR/firstDayOfWeek=1 -CalendarData/pt_BR/minimalDaysInFirstWeek=1 +CalendarData/pt_BR/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pt_BR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/pt_BR/MonthNames/0=janeiro FormatData/pt_BR/MonthNames/1=fevereiro FormatData/pt_BR/MonthNames/2=mar\u00e7o @@ -189,8 +189,8 @@ FormatData/pl_PL/MonthAbbreviations/10=lis FormatData/pl_PL/MonthAbbreviations/11=gru FormatData/pl_PL/MonthAbbreviations/12= -CalendarData/pl_PL/firstDayOfWeek=2 -CalendarData/pl_PL/minimalDaysInFirstWeek=4 +CalendarData/pl_PL/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pl_PL/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/pl_PL/AmPmMarkers/0=AM FormatData/pl_PL/AmPmMarkers/1=PM @@ -320,8 +320,8 @@ FormatData/ru_RU/DayAbbreviations/6=\u0441\u0431 FormatData/ru_RU/AmPmMarkers/0=\u0414\u041f FormatData/ru_RU/AmPmMarkers/1=\u041f\u041f -CalendarData/ru_RU/firstDayOfWeek=2 -CalendarData/ru_RU/minimalDaysInFirstWeek=1 +CalendarData/ru_RU/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ru_RU/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA # bug #4094371, 4098518, 4290801, 6558863 FormatData/en_AU/TimePatterns/0=h:mm:ss a zzzz @@ -745,8 +745,8 @@ FormatData/ar_AE/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_AE/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_AE/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_AE/firstDayOfWeek=7 -CalendarData/ar_AE/minimalDaysInFirstWeek=1 +CalendarData/ar_AE/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_AE/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_AE/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_AE/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_AE/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -833,8 +833,8 @@ FormatData/ar_BH/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_BH/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_BH/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_BH/firstDayOfWeek=7 -CalendarData/ar_BH/minimalDaysInFirstWeek=1 +CalendarData/ar_BH/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_BH/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_BH/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_BH/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_BH/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -921,8 +921,8 @@ FormatData/ar_DZ/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_DZ/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_DZ/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_DZ/firstDayOfWeek=7 -CalendarData/ar_DZ/minimalDaysInFirstWeek=1 +CalendarData/ar_DZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_DZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_DZ/MonthAbbreviations/0=\u062c\u0627\u0646\u0641\u064a FormatData/ar_DZ/MonthAbbreviations/1=\u0641\u064a\u0641\u0631\u064a FormatData/ar_DZ/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1009,8 +1009,8 @@ FormatData/ar_EG/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_EG/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_EG/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_EG/firstDayOfWeek=7 -CalendarData/ar_EG/minimalDaysInFirstWeek=1 +CalendarData/ar_EG/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_EG/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_EG/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_EG/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_EG/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1097,8 +1097,8 @@ FormatData/ar_IQ/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_IQ/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_IQ/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_IQ/firstDayOfWeek=7 -CalendarData/ar_IQ/minimalDaysInFirstWeek=1 +CalendarData/ar_IQ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_IQ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_IQ/MonthAbbreviations/0=\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a FormatData/ar_IQ/MonthAbbreviations/1=\u0634\u0628\u0627\u0637 FormatData/ar_IQ/MonthAbbreviations/2=\u0622\u0630\u0627\u0631 @@ -1218,8 +1218,8 @@ FormatData/ar_JO/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_JO/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_JO/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_JO/firstDayOfWeek=7 -CalendarData/ar_JO/minimalDaysInFirstWeek=1 +CalendarData/ar_JO/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_JO/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_JO/Eras/0=\u0642.\u0645 FormatData/ar_JO/Eras/1=\u0645 LocaleNames/ar_JO/ar=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 @@ -1273,8 +1273,8 @@ FormatData/ar_KW/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_KW/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_KW/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_KW/firstDayOfWeek=7 -CalendarData/ar_KW/minimalDaysInFirstWeek=1 +CalendarData/ar_KW/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_KW/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_KW/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_KW/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_KW/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1394,8 +1394,8 @@ FormatData/ar_LB/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_LB/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_LB/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_LB/firstDayOfWeek=2 -CalendarData/ar_LB/minimalDaysInFirstWeek=1 +CalendarData/ar_LB/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_LB/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_LB/Eras/0=\u0642.\u0645 FormatData/ar_LB/Eras/1=\u0645 LocaleNames/ar_LB/ar=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 @@ -1449,8 +1449,8 @@ FormatData/ar_LY/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_LY/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_LY/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_LY/firstDayOfWeek=7 -CalendarData/ar_LY/minimalDaysInFirstWeek=1 +CalendarData/ar_LY/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_LY/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_LY/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_LY/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_LY/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1537,8 +1537,8 @@ FormatData/ar_MA/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_MA/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_MA/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_MA/firstDayOfWeek=7 -CalendarData/ar_MA/minimalDaysInFirstWeek=1 +CalendarData/ar_MA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_MA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_MA/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_MA/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_MA/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1625,8 +1625,8 @@ FormatData/ar_OM/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_OM/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_OM/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_OM/firstDayOfWeek=7 -CalendarData/ar_OM/minimalDaysInFirstWeek=1 +CalendarData/ar_OM/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_OM/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_OM/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_OM/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_OM/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1713,8 +1713,8 @@ FormatData/ar_QA/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_QA/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_QA/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_QA/firstDayOfWeek=7 -CalendarData/ar_QA/minimalDaysInFirstWeek=1 +CalendarData/ar_QA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_QA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_QA/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_QA/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_QA/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1801,8 +1801,8 @@ FormatData/ar_SA/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_SA/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_SA/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_SA/firstDayOfWeek=1 -CalendarData/ar_SA/minimalDaysInFirstWeek=1 +CalendarData/ar_SA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_SA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_SA/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_SA/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_SA/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1890,8 +1890,8 @@ FormatData/ar_SD/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_SD/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_SD/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_SD/firstDayOfWeek=7 -CalendarData/ar_SD/minimalDaysInFirstWeek=1 +CalendarData/ar_SD/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_SD/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_SD/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_SD/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_SD/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -2011,8 +2011,8 @@ FormatData/ar_SY/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_SY/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_SY/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_SY/firstDayOfWeek=7 -CalendarData/ar_SY/minimalDaysInFirstWeek=1 +CalendarData/ar_SY/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_SY/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_SY/Eras/0=\u0642.\u0645 FormatData/ar_SY/Eras/1=\u0645 LocaleNames/ar_SY/ar=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 @@ -2066,8 +2066,8 @@ FormatData/ar_TN/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_TN/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_TN/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_TN/firstDayOfWeek=1 -CalendarData/ar_TN/minimalDaysInFirstWeek=1 +CalendarData/ar_TN/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_TN/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_TN/MonthAbbreviations/0=\u062c\u0627\u0646\u0641\u064a FormatData/ar_TN/MonthAbbreviations/1=\u0641\u064a\u0641\u0631\u064a FormatData/ar_TN/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -2154,8 +2154,8 @@ FormatData/ar_YE/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_YE/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_YE/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_YE/firstDayOfWeek=1 -CalendarData/ar_YE/minimalDaysInFirstWeek=1 +CalendarData/ar_YE/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_YE/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_YE/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_YE/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_YE/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -2341,9 +2341,9 @@ FormatData/fr_FR/MonthAbbreviations/10=nov. FormatData/fr_FR/MonthAbbreviations/11=d\u00e9c. FormatData/fr_FR/MonthAbbreviations/12= -CalendarData/fr_FR/firstDayOfWeek=2 +CalendarData/fr_FR/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY # next line changed according the 4518811 bug -CalendarData/fr_FR/minimalDaysInFirstWeek=4 +CalendarData/fr_FR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/fr_FR/AmPmMarkers/0=AM FormatData/fr_FR/AmPmMarkers/1=PM @@ -2488,19 +2488,19 @@ LocaleNames/ru_RU/MM=\u041c\u044c\u044f\u043d\u043c\u0430 (\u0411\u0438\u0440\u043c\u0430) #bug 4518811 -CalendarData/ca_ES/minimalDaysInFirstWeek=4 -CalendarData/cs_CZ/minimalDaysInFirstWeek=4 -CalendarData/da_DK/minimalDaysInFirstWeek=4 -CalendarData/de_AT/minimalDaysInFirstWeek=4 -CalendarData/el_GR/minimalDaysInFirstWeek=4 -CalendarData/en_IE/minimalDaysInFirstWeek=4 -CalendarData/es_ES/minimalDaysInFirstWeek=4 -CalendarData/et_EE/minimalDaysInFirstWeek=4 -CalendarData/fi_FI/minimalDaysInFirstWeek=4 -CalendarData/is_IS/minimalDaysInFirstWeek=4 -CalendarData/lt_LT/minimalDaysInFirstWeek=4 -CalendarData/pl_PL/minimalDaysInFirstWeek=4 -CalendarData/pt_PT/minimalDaysInFirstWeek=4 +CalendarData/ca_ES/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/cs_CZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/da_DK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/de_AT/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/el_GR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/en_IE/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/es_ES/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/et_EE/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/fi_FI/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/is_IS/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/lt_LT/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pl_PL/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pt_PT/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA #bug 4945388 CurrencyNames/be_BY/BYR=\u0440. @@ -2523,7 +2523,7 @@ LocaleNames/zh/tw=\u7279\u5a01\u6587 #bug 6277020 -CalendarData/ca_ES/firstDayOfWeek=2 +CalendarData/ca_ES/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY #bug 6277696 #zh_SG, id, id_ID, en_MT, mt_MT, en_PH, el, el_CY, ms, ms_MY @@ -3324,7 +3324,7 @@ LocaleNames/el_CY/ZW=\u0396\u03b9\u03bc\u03c0\u03ac\u03bc\u03c0\u03bf\u03c5\u03b5 #CurrencyNames/el_CY/CYP= CurrencyNames/el_CY/EUR=\u20ac -CalendarData/el_CY/minimalDaysInFirstWeek=1 +CalendarData/el_CY/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA #ms_MY and ms FormatData/ms_MY/NumberPatterns/0=#,##0.### @@ -3538,7 +3538,7 @@ LocaleNames/es_US/TT=Trinidad y Tobago LocaleNames/es_US/VI=Islas V\u00edrgenes de EE. UU. CurrencyNames/es_US/USD=$ -CalendarData/es_US/firstDayOfWeek=1 +CalendarData/es_US/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY #bug 4400849 LocaleNames/pt/aa=afar LocaleNames/pt/ab=abc\u00e1zio @@ -5389,13 +5389,13 @@ FormatData/mt/AmPmMarkers/1=PM FormatData/mt/DatePatterns/0=EEEE, d 'ta'\u2019 MMMM y # bug# 6483191 -CalendarData/ga_IE/firstDayOfWeek=1 -CalendarData/en_PH/firstDayOfWeek=1 -CalendarData/en_SG/firstDayOfWeek=1 -CalendarData/zh_SG/firstDayOfWeek=1 -CalendarData/mt_MT/firstDayOfWeek=1 -CalendarData/en_MT/firstDayOfWeek=1 -CalendarData/es_US/firstDayOfWeek=1 +CalendarData/ga_IE/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/en_PH/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/en_SG/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_SG/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/mt_MT/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/en_MT/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/es_US/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY #CalendarData/es_CY/firstDayOfWeek= #CalendarData/in_ID/firstDayOfWeek= #CalendarData/ms_MY/firstDayOfWeek= @@ -6122,14 +6122,14 @@ # bug 6998391 #CalendarData/sr-Latn/firstDayOfWeek= -CalendarData/sr-Latn-BA/firstDayOfWeek=2 -CalendarData/sr-Latn-ME/firstDayOfWeek=2 -CalendarData/sr-Latn-RS/firstDayOfWeek=2 +CalendarData/sr-Latn-BA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Latn-ME/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Latn-RS/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY # #CalendarData/sr-Latn/minimalDaysInFirstWeek= -CalendarData/sr-Latn-BA/minimalDaysInFirstWeek=1 -CalendarData/sr-Latn-ME/minimalDaysInFirstWeek=1 -CalendarData/sr-Latn-RS/minimalDaysInFirstWeek=1 +CalendarData/sr-Latn-BA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Latn-ME/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Latn-RS/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA # LocaleNames/sr-Latn/SR=Surinam LocaleNames/sr-Latn-BA/SR=Surinam @@ -8303,79 +8303,79 @@ # bug #8185841 -CalendarData/az-Latn-AZ/firstDayOfWeek=2 -CalendarData/az-Latn-AZ/minimalDaysInFirstWeek=1 -CalendarData/az-Cyrl-AZ/firstDayOfWeek=2 -CalendarData/az-Cyrl-AZ/minimalDaysInFirstWeek=1 -CalendarData/az_AZ/firstDayOfWeek=2 -CalendarData/az-AZ/minimalDaysInFirstWeek=1 -CalendarData/bs-Cyrl-BA/firstDayOfWeek=2 -CalendarData/bs-Cyrl-BA/minimalDaysInFirstWeek=1 -CalendarData/bs_BA/firstDayOfWeek=2 -CalendarData/bs_BA/minimalDaysInFirstWeek=1 -CalendarData/pa-Arab-PK/firstDayOfWeek=1 -CalendarData/pa-Arab-PK/minimalDaysInFirstWeek=1 -CalendarData/pa_PK/firstDayOfWeek=1 -CalendarData/pa_PK/minimalDaysInFirstWeek=1 -CalendarData/pa-Guru-IN/firstDayOfWeek=1 -CalendarData/pa-Guru-IN/minimalDaysInFirstWeek=1 -CalendarData/pa_IN/firstDayOfWeek=1 -CalendarData/pa_IN/minimalDaysInFirstWeek=1 -CalendarData/shi-Latn-MA/firstDayOfWeek=7 -CalendarData/shi-Latn-MA/minimalDaysInFirstWeek=1 -CalendarData/shi-Tfng-MA/firstDayOfWeek=7 -CalendarData/shi-Tfng-MA/minimalDaysInFirstWeek=1 -CalendarData/shi_MA/firstDayOfWeek=7 -CalendarData/shi_MA/minimalDaysInFirstWeek=1 -CalendarData/sr-Cyrl-BA/firstDayOfWeek=2 -CalendarData/sr-Cyrl-BA/minimalDaysInFirstWeek=1 -CalendarData/sr-Cyrl-ME/firstDayOfWeek=2 -CalendarData/sr-Cyrl-ME/minimalDaysInFirstWeek=1 -CalendarData/sr-Cyrl-RS/firstDayOfWeek=2 -CalendarData/sr-Cyrl-RS/minimalDaysInFirstWeek=1 -CalendarData/sr-Cyrl-XK/firstDayOfWeek=2 -CalendarData/sr-Cyrl-XK/minimalDaysInFirstWeek=1 -CalendarData/sr_RS/firstDayOfWeek=2 -CalendarData/sr_RS/minimalDaysInFirstWeek=1 -CalendarData/sr_BA/firstDayOfWeek=2 -CalendarData/sr_BA/minimalDaysInFirstWeek=1 -CalendarData/sr_ME/firstDayOfWeek=2 -CalendarData/sr_ME/minimalDaysInFirstWeek=1 -CalendarData/sr_XK/firstDayOfWeek=2 -CalendarData/sr_XK/minimalDaysInFirstWeek=1 -CalendarData/uz-Arab-AF/firstDayOfWeek=7 -CalendarData/uz-Arab-AF/minimalDaysInFirstWeek=1 -CalendarData/uz-Cyrl-UZ/firstDayOfWeek=2 -CalendarData/uz-Cyrl-UZ/minimalDaysInFirstWeek=1 -CalendarData/uz-Latn-UZ/firstDayOfWeek=2 -CalendarData/uz-Latn-UZ/minimalDaysInFirstWeek=1 -CalendarData/vai-Latn-LR/firstDayOfWeek=2 -CalendarData/vai-Latn-LR/minimalDaysInFirstWeek=1 -CalendarData/vai-Vaii-LR/firstDayOfWeek=2 -CalendarData/vai-Vaii-LR/minimalDaysInFirstWeek=1 -CalendarData/vai_LR/firstDayOfWeek=2 -CalendarData/vai_LR/minimalDaysInFirstWeek=1 -CalendarData/uz_UZ/firstDayOfWeek=2 -CalendarData/uz_UZ/minimalDaysInFirstWeek=1 -CalendarData/zh_CN/firstDayOfWeek=1 -CalendarData/zh_CN/minimalDaysInFirstWeek=1 -CalendarData/zh-Hans-CN/minimalDaysInFirstWeek=1 -CalendarData/zh-Hans-CN/firstDayOfWeek=1 -CalendarData/zh-Hans-HK/firstDayOfWeek=1 -CalendarData/zh-Hans-HK/minimalDaysInFirstWeek=1 -CalendarData/zh-Hans-MO/minimalDaysInFirstWeek=1 -CalendarData/zh-Hans-MO/firstDayOfWeek=1 -CalendarData/zh-Hans-SG/firstDayOfWeek=1 -CalendarData/zh-Hans-SG/minimalDaysInFirstWeek=1 -CalendarData/zh-Hant-HK/minimalDaysInFirstWeek=1 -CalendarData/zh-Hant-HK/firstDayOfWeek=1 -CalendarData/zh-Hant-TW/minimalDaysInFirstWeek=1 -CalendarData/zh-Hant-TW/firstDayOfWeek=1 -CalendarData/zh_HK/minimalDaysInFirstWeek=1 -CalendarData/zh_HK/firstDayOfWeek=1 -CalendarData/zh_MO/minimalDaysInFirstWeek=1 -CalendarData/zh_MO/firstDayOfWeek=1 -CalendarData/zh_SG/minimalDaysInFirstWeek=1 -CalendarData/zh_SG/firstDayOfWeek=1 -CalendarData/zh_TW/firstDayOfWeek=1 -CalendarData/zh_TW/minimalDaysInFirstWeek=1 +CalendarData/az-Latn-AZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/az-Latn-AZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/az-Cyrl-AZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/az-Cyrl-AZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/az_AZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/az-AZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/bs-Cyrl-BA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/bs-Cyrl-BA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/bs_BA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/bs_BA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pa-Arab-PK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pa-Arab-PK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pa_PK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pa_PK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pa-Guru-IN/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pa-Guru-IN/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pa_IN/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pa_IN/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/shi-Latn-MA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/shi-Latn-MA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/shi-Tfng-MA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/shi-Tfng-MA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/shi_MA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/shi_MA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Cyrl-BA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Cyrl-BA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Cyrl-ME/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Cyrl-ME/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Cyrl-RS/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Cyrl-RS/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Cyrl-XK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Cyrl-XK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr_RS/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr_RS/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr_BA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr_BA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr_ME/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr_ME/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr_XK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr_XK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/uz-Arab-AF/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/uz-Arab-AF/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/uz-Cyrl-UZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/uz-Cyrl-UZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/uz-Latn-UZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/uz-Latn-UZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/vai-Latn-LR/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/vai-Latn-LR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/vai-Vaii-LR/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/vai-Vaii-LR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/vai_LR/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/vai_LR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/uz_UZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/uz_UZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh_CN/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_CN/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hans-CN/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hans-CN/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh-Hans-HK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh-Hans-HK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hans-MO/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hans-MO/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh-Hans-SG/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh-Hans-SG/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hant-HK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hant-HK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh-Hant-TW/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hant-TW/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_HK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh_HK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_MO/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh_MO/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_SG/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh_SG/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_TW/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_TW/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/sun/text/resources/LocaleDataTest.java --- a/test/jdk/sun/text/resources/LocaleDataTest.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/sun/text/resources/LocaleDataTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -37,7 +37,7 @@ * 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509 * 7114053 7074882 7040556 8008577 8013836 8021121 6192407 6931564 8027695 * 8017142 8037343 8055222 8042126 8074791 8075173 8080774 8129361 8134916 - * 8145136 8145952 8164784 8037111 8081643 7037368 8178872 8185841 + * 8145136 8145952 8164784 8037111 8081643 7037368 8178872 8185841 8190918 * @summary Verify locale data * @modules java.base/sun.util.resources * @modules jdk.localedata diff -r 093027a037cf -r 191ae61bd1e9 test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java --- a/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -40,7 +40,7 @@ /* * @test - * @bug 8152143 8152704 8155649 8165804 8185841 + * @bug 8152143 8152704 8155649 8165804 8185841 8176841 8190918 * @summary IncludeLocalesPlugin tests * @author Naoto Sato * @library ../../lib @@ -70,6 +70,14 @@ private static int errors; private final static Object[][] testData = { + // Test data should include: + // - --include-locales command line option + // - --add-modules command line option values + // - List of required resources in the result image + // - List of resources that should not exist in the result image + // - List of available locales in the result image + // - Error message + // without --include-locales option: should include all locales { "", @@ -227,11 +235,8 @@ List.of( "/jdk.localedata/sun/text/resources/ext/FormatData_en_IN.class", "/jdk.localedata/sun/text/resources/ext/FormatData_hi_IN.class", - "/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_as_IN.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class", - "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_IN.class", - "/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_kok_IN.class", - "/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_pa_IN.class"), + "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_IN.class"), List.of( "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/thai_dict", @@ -242,6 +247,7 @@ "/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_zh.class", + "/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_as_IN.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"), @@ -327,7 +333,7 @@ "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"), List.of( "(root)", "en", "en_US", "en_US_POSIX", "zh", "zh__#Hans", "zh_CN", - "zh_HK", "zh_MO", "zh_CN_#Hans", "zh_HK_#Hans", "zh_MO_#Hans", "zh_SG", "zh_SG_#Hans"), + "zh_CN_#Hans", "zh_HK_#Hans", "zh_MO_#Hans", "zh_SG", "zh_SG_#Hans"), "", }, @@ -387,6 +393,34 @@ "", }, + // Langtag including extensions. Should be ignored. + { + "--include-locales=en,ja-u-nu-thai", + "jdk.localedata", + List.of( + "/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", + "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class"), + List.of( + "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", + "/jdk.localedata/sun/text/resources/ext/FormatData_th.class"), + List.of( + "(root)", "en", "en_001", "en_150", "en_AG", "en_AI", "en_AS", "en_AT", + "en_AU", "en_BB", "en_BE", "en_BI", "en_BM", "en_BS", "en_BW", "en_BZ", + "en_CA", "en_CC", "en_CH", "en_CK", "en_CM", "en_CX", "en_CY", "en_DE", + "en_DG", "en_DK", "en_DM", "en_ER", "en_FI", "en_FJ", "en_FK", "en_FM", + "en_GB", "en_GD", "en_GG", "en_GH", "en_GI", "en_GM", "en_GU", "en_GY", + "en_HK", "en_IE", "en_IL", "en_IM", "en_IN", "en_IO", "en_JE", "en_JM", + "en_KE", "en_KI", "en_KN", "en_KY", "en_LC", "en_LR", "en_LS", "en_MG", + "en_MH", "en_MO", "en_MP", "en_MS", "en_MT", "en_MU", "en_MW", "en_MY", + "en_NA", "en_NF", "en_NG", "en_NL", "en_NR", "en_NU", "en_NZ", "en_PG", + "en_PH", "en_PK", "en_PN", "en_PR", "en_PW", "en_RW", "en_SB", "en_SC", + "en_SD", "en_SE", "en_SG", "en_SH", "en_SI", "en_SL", "en_SS", "en_SX", + "en_SZ", "en_TC", "en_TK", "en_TO", "en_TT", "en_TV", "en_TZ", "en_UG", + "en_UM", "en_US", "en_US_POSIX", "en_VC", "en_VG", "en_VI", "en_VU", + "en_WS", "en_ZA", "en_ZM", "en_ZW"), + "", + }, + // Error case: No matching locales { "--include-locales=xyz", diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/TestMemberInheritance.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/TestMemberInheritance.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2002, 2017, 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 4638588 4635809 6256068 6270645 8025633 8026567 8162363 8175200 + * 8192850 + * @summary Test to make sure that members are inherited properly in the Javadoc. + * Verify that inheritance labels are correct. + * @author jamieh + * @library ../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build JavadocTester + * @run main TestMemberInheritance + */ + +public class TestMemberInheritance extends JavadocTester { + + public static void main(String... args) throws Exception { + TestMemberInheritance tester = new TestMemberInheritance(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg", "diamond", "inheritDist", "pkg1"); + checkExit(Exit.OK); + + checkOutput("pkg/SubClass.html", true, + // Public field should be inherited + "", + // Public method should be inherited + "", + // Public inner class should be inherited. + "", + // Protected field should be inherited + "", + // Protected method should be inherited + "", + // Protected inner class should be inherited. + "", + // New labels as of 1.5.0 + "Nested classes/interfaces inherited from class pkg." + + "BaseClass", + "Nested classes/interfaces inherited from interface pkg." + + "BaseInterface"); + + checkOutput("pkg/BaseClass.html", true, + // Test overriding/implementing methods with generic parameters. + "
    \n" + + "
    Specified by:
    \n" + + "
    " + + "getAnnotation in interface " + + "" + + "BaseInterface
    \n" + + "
    "); + + checkOutput("diamond/Z.html", true, + // Test diamond inheritance member summary (6256068) + "aMethod"); + + checkOutput("inheritDist/C.html", true, + // Test that doc is inherited from closed parent (6270645) + "
    m1-B
    "); + + checkOutput("pkg/SubClass.html", false, + "staticMethod"); + + checkOutput("pkg1/Implementer.html", true, + // ensure the method makes it + "static java.time.Period\n" + + "" + + "" + + "between​(java.time.LocalDate startDateInclusive,\n" + + " java.time.LocalDate endDateExclusive)"); + + checkOutput("pkg1/Implementer.html", false, + "

    Methods inherited from interface pkg1.Interface

    \n" + + "between" + ); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/diamond/A.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/diamond/A.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2005, 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 diamond; + +//6256068 +public interface A { + /** + * aDoc. + */ + void aMethod(); +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/diamond/B.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/diamond/B.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2005, 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 diamond; + +public interface B extends A { + /** + * bDoc. + */ + void bMethod(); +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/diamond/C.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/diamond/C.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2005, 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 diamond; + +public interface C extends B { + /** + * cDoc. + */ + void cMethod(); +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/diamond/X.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/diamond/X.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2005, 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 diamond; + +public interface X extends A { + /** + * xDoc. + */ + void xMethod(); +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/diamond/Z.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/diamond/Z.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2005, 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 diamond; + +public interface Z extends X, C { + /** + * zDoc. + */ + void zMethod(); +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/inheritDist/A.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/inheritDist/A.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2005, 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 inheritDist; + +//6270645 +public interface A { + /** + * m1-A + */ + void m1(); +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/inheritDist/B.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/inheritDist/B.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2005, 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 inheritDist; + +public interface B extends A { + /** + * m1-B + */ + void m1(); +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/inheritDist/C.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/inheritDist/C.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2005, 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 inheritDist; + +public class C implements B { + public void m1() {} +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg/BaseClass.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg/BaseClass.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2002, 2004, 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 pkg; + +import java.lang.annotation.*; + +public class BaseClass implements BaseInterface { + + public int pubField = 1; + + public class pubInnerClass{} + + public void pubMethod() {} + + protected int proField = 1; + + protected class proInnerClass{} + + protected void proMethod() {} + + public B getAnnotation(Class annotationClass) { + return null; + } + + public static void staticMethod(){} +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg/BaseInterface.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg/BaseInterface.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2004, 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 pkg; + +import java.lang.annotation.*; + +public interface BaseInterface { + + public class NestedClassFromInterface{} + + public A getAnnotation(Class annotationClass); +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg/SubClass.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg/SubClass.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2002, 2004, 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 pkg; + +import java.lang.annotation.*; + +public class SubClass extends BaseClass { + + public C getAnnotation(Class annotationClass) { + return null; + } + + public static void staticMethod(){} +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg1/Implementer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg1/Implementer.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,33 @@ +/* + * 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 + * 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 pkg1; + +import java.time.LocalDate; +import java.time.Period; + +public class Implementer implements Interface { + public static Period between(LocalDate startDateInclusive, LocalDate endDateExclusive) { + return null; + } + +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg1/Interface.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg1/Interface.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,32 @@ +/* + * 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 + * 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 pkg1; + +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.ChronoPeriod; + +public interface Interface { + public static ChronoPeriod between(ChronoLocalDate startDateInclusive, ChronoLocalDate endDateExclusive) { + return null; + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/TestMemberInheritence.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/TestMemberInheritence.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2002, 2017, 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 4638588 4635809 6256068 6270645 8025633 8026567 8162363 8175200 - * @summary Test to make sure that members are inherited properly in the Javadoc. - * Verify that inheritence labels are correct. - * @author jamieh - * @library ../lib - * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build JavadocTester - * @run main TestMemberInheritence - */ - -public class TestMemberInheritence extends JavadocTester { - - public static void main(String... args) throws Exception { - TestMemberInheritence tester = new TestMemberInheritence(); - tester.runTests(); - } - - @Test - void test() { - javadoc("-d", "out", - "-sourcepath", testSrc, - "pkg", "diamond", "inheritDist", "pkg1"); - checkExit(Exit.OK); - - checkOutput("pkg/SubClass.html", true, - // Public field should be inherited - "", - // Public method should be inherited - "", - // Public inner class should be inherited. - "", - // Protected field should be inherited - "", - // Protected method should be inherited - "", - // Protected inner class should be inherited. - "", - // New labels as of 1.5.0 - "Nested classes/interfaces inherited from class pkg." - + "BaseClass", - "Nested classes/interfaces inherited from interface pkg." - + "BaseInterface"); - - checkOutput("pkg/BaseClass.html", true, - // Test overriding/implementing methods with generic parameters. - "
    \n" - + "
    Specified by:
    \n" - + "
    " - + "getAnnotation in interface " - + "" - + "BaseInterface
    \n" - + "
    "); - - checkOutput("diamond/Z.html", true, - // Test diamond inheritence member summary (6256068) - "aMethod"); - - checkOutput("inheritDist/C.html", true, - // Test that doc is inherited from closed parent (6270645) - "
    m1-B
    "); - - checkOutput("pkg/SubClass.html", false, - "staticMethod"); - - checkOutput("pkg1/Implementer.html", true, - // ensure the method makes it - "static java.time.Period\n" - + "" - + "" - + "between​(java.time.LocalDate startDateInclusive,\n" - + " java.time.LocalDate endDateExclusive)", - // check the inherited from interfaces - "

    Methods inherited from interface pkg1.Interface

    \n" - + "between" - ); - } -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/A.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/A.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2005, 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 diamond; - -//6256068 -public interface A { - /** - * aDoc. - */ - void aMethod(); -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/B.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/B.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2005, 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 diamond; - -public interface B extends A { - /** - * bDoc. - */ - void bMethod(); -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/C.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/C.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2005, 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 diamond; - -public interface C extends B { - /** - * cDoc. - */ - void cMethod(); -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/X.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/X.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2005, 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 diamond; - -public interface X extends A { - /** - * xDoc. - */ - void xMethod(); -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/Z.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/Z.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2005, 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 diamond; - -public interface Z extends X, C { - /** - * zDoc. - */ - void zMethod(); -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/inheritDist/A.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/inheritDist/A.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2005, 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 inheritDist; - -//6270645 -public interface A { - /** - * m1-A - */ - void m1(); -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/inheritDist/B.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/inheritDist/B.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2005, 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 inheritDist; - -public interface B extends A { - /** - * m1-B - */ - void m1(); -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/inheritDist/C.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/inheritDist/C.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2005, 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 inheritDist; - -public class C implements B { - public void m1() {} -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg/BaseClass.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg/BaseClass.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2002, 2004, 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 pkg; - -import java.lang.annotation.*; - -public class BaseClass implements BaseInterface { - - public int pubField = 1; - - public class pubInnerClass{} - - public void pubMethod() {} - - protected int proField = 1; - - protected class proInnerClass{} - - protected void proMethod() {} - - public B getAnnotation(Class annotationClass) { - return null; - } - - public static void staticMethod(){} -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg/BaseInterface.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg/BaseInterface.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2004, 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 pkg; - -import java.lang.annotation.*; - -public interface BaseInterface { - - public class NestedClassFromInterface{} - - public A getAnnotation(Class annotationClass); -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg/SubClass.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg/SubClass.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2002, 2004, 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 pkg; - -import java.lang.annotation.*; - -public class SubClass extends BaseClass { - - public C getAnnotation(Class annotationClass) { - return null; - } - - public static void staticMethod(){} -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg1/Implementer.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg1/Implementer.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * 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 - * 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 pkg1; - -import java.time.LocalDate; -import java.time.Period; - -public class Implementer implements Interface { - public static Period between(LocalDate startDateInclusive, LocalDate endDateExclusive) { - return null; - } - -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg1/Interface.java --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg1/Interface.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * 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 - * 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 pkg1; - -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoPeriod; - -public interface Interface { - public static ChronoPeriod between(ChronoLocalDate startDateInclusive, ChronoLocalDate endDateExclusive) { - return null; - } -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testModules/TestEmptyModule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestEmptyModule.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017, 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 8193107 + * @summary test an empty module + * @modules jdk.javadoc/jdk.javadoc.internal.api + * jdk.javadoc/jdk.javadoc.internal.tool + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @library ../lib /tools/lib + * @build toolbox.ToolBox toolbox.ModuleBuilder JavadocTester + * @run main TestEmptyModule + */ + +import toolbox.ModuleBuilder; +import toolbox.ToolBox; + +import java.nio.file.Path; +import java.nio.file.Paths; + +public class TestEmptyModule extends JavadocTester { + + public final ToolBox tb; + public static void main(String... args) throws Exception { + TestEmptyModule tester = new TestEmptyModule(); + tester.runTests(m -> new Object[] { Paths.get(m.getName()) }); + } + + public TestEmptyModule() { + tb = new ToolBox(); + } + + @Test + public void checkEmptyModule(Path base) throws Exception { + ModuleBuilder mb = new ModuleBuilder(tb, "empty") + .comment("module empty."); + mb.write(base); + + javadoc("-d", base.resolve("out").toString(), + "-quiet", + "--module-source-path", base.toString(), + "--module", "empty"); + checkExit(Exit.OK); + + checkOutput("empty-summary.html", true, + "module empty."); + } + +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 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 8174839 8175200 8186332 + * @summary Bad overriding method should not crash + * @library ../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build JavadocTester + * @run main TestBadOverride + */ + +public class TestBadOverride extends JavadocTester { + + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String... args) throws Exception { + TestBadOverride tester = new TestBadOverride(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg4"); + checkExit(Exit.OK); + + checkOutput("pkg4/Foo.html", true, + "
  • \n" + + "

    toString

    \n" + + "
    public void toString()
    \n" + + "
    Why can't I do this ?
    \n" + + "
  • "); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestMultiInheritance.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestMultiInheritance.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2003, 2016, 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 4933335 + * @summary Make sure that all inherited methods from multiple extended + * interfaces are documented + * @author jamieh + * @library ../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build JavadocTester + * @run main TestMultiInheritance + */ + +public class TestMultiInheritance extends JavadocTester { + + public static void main(String... args) throws Exception { + TestMultiInheritance tester = new TestMultiInheritance(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg3"); + checkExit(Exit.OK); + + // Method foo() is inherited from BOTH I2 and I3 + + checkOutput("pkg3/I1.html", true, + "Methods inherited from interface pkg3." + + "
    " + + "I2", + "Methods inherited from interface pkg3." + + "" + + "I3"); + + checkOutput("pkg3/I0.html", true, + "Methods inherited from interface pkg3." + + "" + + "I2", + "Methods inherited from interface pkg3." + + "" + + "I3"); + + // Method foo() is NOT inherited from I4 because it is overriden by I3. + + checkOutput("pkg3/I1.html", false, + "Methods inherited from interface pkg3." + + "" + + "I4"); + + checkOutput("pkg3/I0.html", false, + "Methods inherited from interface pkg3." + + "" + + "I4"); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverriddenMethodDocCopy.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverriddenMethodDocCopy.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2003, 2016, 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 4368820 8025633 8026567 + * @summary Inherited comment should link directly to member, not just + * class + * @author jamieh + * @library ../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build JavadocTester + * @run main TestOverriddenMethodDocCopy + */ + +public class TestOverriddenMethodDocCopy extends JavadocTester { + + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String... args) throws Exception { + TestOverriddenMethodDocCopy tester = new TestOverriddenMethodDocCopy(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg1", "pkg2"); + checkExit(Exit.OK); + + checkOutput("pkg1/SubClass.html", true, + "Description copied from class: " + + "" + + "BaseClass"); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverriddenPrivateMethods.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverriddenPrivateMethods.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2002, 2016, 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 4634891 8026567 + * @summary Determine if overridden methods are properly documented when + * -protected (default) visibility flag is used. + * @author jamieh + * @library ../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build JavadocTester + * @run main TestOverriddenPrivateMethods + */ + +public class TestOverriddenPrivateMethods extends JavadocTester { + + public static void main(String... args) throws Exception { + TestOverriddenPrivateMethods tester = new TestOverriddenPrivateMethods(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg1", "pkg2"); + checkExit(Exit.OK); + + // The public method should be overridden + checkOutput("pkg1/SubClass.html", true, + "
    Overrides:
    \n" + + "
    Overrides:\n" + + "
    Overrides:\n" + + "
    Overrides:\n" + + "
    Overrides:\n" + + "
    Overrides:\n" + + "
    " + + "publicMethod in class " + + "BaseClass
    "); + + // The public method in different package should be overridden + checkOutput("pkg2/SubClass.html", true, + "
    Overrides:
    \n" + + "
    " + + "publicMethod in class " + + "BaseClass
    "); + + // The package private method should be overridden since the base and sub class are in the same + // package. + checkOutput("pkg1/SubClass.html", true, + "
    Overrides:
    \n" + + "
    " + + "packagePrivateMethod in class " + + "BaseClass
    "); + + // The private method in should not be overridden + checkOutput("pkg1/SubClass.html", false, + "
    Overrides:
    \n" + + "
    "); + + // The private method in different package should not be overridden + checkOutput("pkg2/SubClass.html", false, + "
    Overrides:
    \n" + + "
    "); + + // The package private method should not be overridden since the base and sub class are in + // different packages. + checkOutput("pkg2/SubClass.html", false, + "
    Overrides:
    \n" + + "
    "); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverriddenPrivateMethodsWithPrivateFlag.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverriddenPrivateMethodsWithPrivateFlag.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2002, 2016, 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 4634891 8026567 + * @summary Determine if overridden methods are properly documented when + * -protected (default) visibility flag is used. + * @author jamieh + * @library ../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build JavadocTester + * @run main TestOverriddenPrivateMethodsWithPrivateFlag + */ + +public class TestOverriddenPrivateMethodsWithPrivateFlag extends JavadocTester { + + public static void main(String... args) throws Exception { + TestOverriddenPrivateMethodsWithPrivateFlag tester = new TestOverriddenPrivateMethodsWithPrivateFlag(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-private", + "pkg1", "pkg2"); + checkExit(Exit.OK); + + // The public method should be overridden + checkOutput("pkg1/SubClass.html", true, + "
    Overrides:
    \n" + + "
    Overrides:\n" + + "
    Overrides:\n" + + "
    Overrides:\n" + + "
    Overrides:\n" + + "
    Overrides:\n" + + "
    rate", + + // Check nested classes + "Nested classes/interfaces declared in class pkg5.", + "Classes.P", + "./pkg5/Classes.P.PN.html", + "Classes.P.PN.html", + "type parameter in Classes.P.PN\">K", + "type parameter in Classes.P.PN", + "V", + + // Check fields + "Fields declared in class pkg5.field0", + + // Check method summary + "Method Summary", + "void", + "../pkg5/Classes.C.html#m1--\">m1", + "A modified method", + + "void", + "../pkg5/Classes.C.html#m4-java.lang.String-java.lang.String-\">m4", + "java.lang.String k,", + "java.lang.String", + " v)", + + // Check footnotes + "Methods declared in class pkg5.m0", + + // Check method details for override + "overrideSpecifyLabel", + "Overrides:", + "../pkg5/Classes.GP.html#m7--\">m7", + "in class", + "../pkg5/Classes.GP.html", + "Classes.GP" + ); + + checkOrder("pkg5/Classes.C.html", + // Check footnotes 2 + "Methods declared in class pkg5.", + "../pkg5/Classes.P.html#getRate--\">getRate", + "../pkg5/Classes.P.html#m2--\">m2", + "../pkg5/Classes.P.html#m3--\">m3", + "../pkg5/Classes.P.html#m4-K-V-\">m4", + "../pkg5/Classes.P.html#rateProperty--\">rateProperty", + "../pkg5/Classes.P.html#setRate-double-\">setRate", + + // Check @link + "A test of links to the methods in this class.

    \n", + "../pkg5/Classes.GP.html#m0--", + "Classes.GP.m0()", + "../pkg5/Classes.C.html#m1--", + "m1()", + "../pkg5/Classes.P.html#m2--", + "Classes.P.m2()", + "../pkg5/Classes.P.html#m3--", + "Classes.P.m3()", + "m4(java.lang.String,java.lang.String)", + "../pkg5/Classes.P.html#m5--", + "Classes.P.m5()", + "../pkg5/Classes.C.html#m6--", + "m6()", + "../pkg5/Classes.C.html#m7--", + "m7()", + "End of links", + + // Check @see + "See Also:", + "../pkg5/Classes.GP.html#m0--", + "Classes.GP.m0()", + "../pkg5/Classes.C.html#m1--", + "m1()", + "../pkg5/Classes.P.html#m2--", + "Classes.P.m2()", + "../pkg5/Classes.P.html#m3--", + "Classes.P.m3()", + "../pkg5/Classes.C.html#m4-java.lang.String-java.lang.String-", + "m4(String k, String v)", + "../pkg5/Classes.P.html#m5--\">Classes.P.m5()", + "../pkg5/Classes.C.html#m6--\">m6()", + "../pkg5/Classes.C.html#m7--\">m7()" + ); + + // Tests for interfaces + + // Make sure the static methods in the super interface + // do not make it to this interface + checkOutput("pkg5/Interfaces.D.html", false, + "msd", "msn"); + + checkOrder("pkg5/Interfaces.D.html", + "Start of links

    ", + "../pkg5/Interfaces.A.html#m0--\">Interfaces.A.m0()", + "../pkg5/Interfaces.A.html#m1--\">Interfaces.A.m1()", + "../pkg5/Interfaces.A.html#m2--\">Interfaces.A.m2()", + "../pkg5/Interfaces.A.html#m3--\">Interfaces.A.m3()", + "../pkg5/Interfaces.D.html#m--\">m()", + "../pkg5/Interfaces.D.html#n--\">n()", + "../pkg5/Interfaces.C.html#o--\">Interfaces.C.o()", + "End of links", + + // Check @see links + "See Also:", + "../pkg5/Interfaces.A.html#m0--\">Interfaces.A.m0()", + "../pkg5/Interfaces.A.html#m1--\">Interfaces.A.m1()", + "../pkg5/Interfaces.A.html#m2--\">Interfaces.A.m2()", + "../pkg5/Interfaces.A.html#m3--\">Interfaces.A.m3()", + "../pkg5/Interfaces.D.html#m--\">m()", + "../pkg5/Interfaces.D.html#n--\">n()", + "../pkg5/Interfaces.C.html#o--\">Interfaces.C.o()", + + // Check properties + "Properties declared in interface pkg5.Interfaces.A", + + // Check nested classes + "Nested classes/interfaces declared in interface pkg5.", + "Interfaces.A", + "../pkg5/Interfaces.A.AA.html", + "Interfaces.A.AA", + + // Check Fields + "Fields declared in interface pkg5.QUOTE", + "../pkg5/Interfaces.A.html#rate\">rate", + + // Check Method Summary + "Method Summary", + "../pkg5/Interfaces.D.html#m--\">m", + "../pkg5/Interfaces.D.html#n--\">n", + + // Check footnotes + "Methods declared in interface pkg5.getRate", + "../pkg5/Interfaces.A.html#rateProperty--\">rateProperty", + "../pkg5/Interfaces.A.html#setRate-double-", + "Methods declared in interface pkg5.m1", + "../pkg5/Interfaces.B.html#m3--\">m3", + "Methods declared in interface pkg5.o" + ); + + // Test synthetic values and valuesof of an enum. + checkOrder("index-all.html", + "

    M

    ", + "m()", + "m()", + "m0()", + "m0()", + "m1()", + "m1()", + "m1()", + "m1()", + "m2()", + "m2()", + "m3()", + "m3()", + "m3()", + "m4(String, String)", + "m4(K, V)", + "m5()", + "m6()", + "m6()", + "m7()", + "m7()", + "Returns the enum constant of this type with the specified name.", + "Returns an array containing the constants of this enum type, in\n" + + "the order they are declared." + ); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg1/BaseClass.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg1/BaseClass.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2002, 2003, 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 pkg1; + +public class BaseClass { + + /************************************************* + * A public method that can be overriden. + * + */ + public void publicMethod() {} + + + /************************************************* + * A package private method that can only + * be overriden by sub classes in the same package. + * + */ + void packagePrivateMethod() {} + + /************************************************* + * A private that cannot be overriden. + * + */ + private void privateMethod() {} + + /** + * These comments will be copied to the overriden method. + */ + public void overridenMethodWithDocsToCopy() {} + +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg1/SubClass.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg1/SubClass.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2002, 2003, 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 pkg1; + +public class SubClass extends BaseClass { + + /************************************************* + * This method should override the same public + * method in the base class. + * + */ + public void publicMethod() {} + + + /************************************************* + * This method should override the same package + * private method in the base class because they + * are in the same package. + */ + public void packagePrivateMethod() {} + + /************************************************* + * This method should not override anything because + * the same method in the base class is private. + * + */ + public void privateMethod() {} + + public void overridenMethodWithDocsToCopy() {} +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg2/SubClass.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg2/SubClass.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2002, 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 pkg2; + +import pkg1.*; + +public class SubClass extends BaseClass { + + /************************************************* + * This method should override the same public + * method in the base class. + * + */ + public void publicMethod() {} + + + /************************************************* + * This method should not override the same package + * private method in the base class because they + * are in different packages. + */ + public void packagePrivateMethod() {} + + /************************************************* + * This method should not override anything because + * the same method in the base class is private. + * + */ + public void privateMethod() {} + +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I0.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I0.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2003, 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 pkg3; + +public interface I0 extends I2, I3, I4 {} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I1.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2003, 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 pkg3; + +public interface I1 extends I2, I4, I3 {} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I2.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2003, 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 pkg3; + +public interface I2 { + + public void foo(); + +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I3.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I3.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2003, 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 pkg3; + +public interface I3 extends I4 { + + public void foo(); + +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I4.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I4.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2003, 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 pkg3; + +public interface I4 { + + public void foo(); + +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg4/Foo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg4/Foo.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, 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 pkg4; + +public class Foo { + /** + * Why can't I do this ? + */ + public void toString() {} +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/Classes.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/Classes.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2017, 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 pkg5; + +public class Classes { + + public static class GP { + /** m0 in grand parent */ + public void m0() {} + + /** m7 in grand parent */ + public void m7() {} + } + + public static class P extends GP { + + /** A nested class in parent */ + public class PN{} + + /** A property in parent */ + private DoubleProperty rate; + public final void setRate(double l){} + public final double getRate(){return 1;} + public DoubleProperty rateProperty() {return null;} + + /** A ctor in parent */ + public P() {} + + /** + * A ctor in parent. + * @param s string + */ + public P(String s) {} + + /** field0 in parent */ + public int field0; + + /** field1 in parent */ + public int field1; + + + // m0 in parent + public void m0() {} + + /** m1 in parent */ + public void m1() {} + + /** m2 in parent */ + public void m2() {} + + /** m3 in parent */ + public void m3() {} + + /** m4 in parent + @param k a key + @param v a value + */ + public void m4(K k, V v) {} + + // No comment + public void m5() {} + + // No comment + public void m6() {} + + /** {@inheritDoc} */ + public void m7() {} + + } + + public static class C extends P { + + public C(String s) {} + + public int field1; + + /** A modified method */ + public void m1() {} + + /** {@inheritDoc} */ + public void m2() {} + + // No comment method + public void m3() {} + + public void m4(String k, String v) {} + + // Do something else than the parent + public void m5() {} + + /** A test of links to the methods in this class.

    + * {@link m0}, + * {@link m1}, + * {@link m2}, + * {@link m3}, + * {@link m4}, + * {@link m5}, + * {@link m6}, + * {@link m7}, + * End of links + * + * @see #m0() + * @see #m1() + * @see #m2() + * @see #m3() + * @see #m4(String k, String v) + * @see #m5() + * @see #m6() + * @see #m7() + */ + public void m6() {} + + /** m7 in Child. */ + public void m7() {} + } + + /** Tickle this {@link TestEnum#doSomething()} */ + public class DoubleProperty {} +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/Interfaces.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/Interfaces.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2017, 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 pkg5; + +public class Interfaces { + public interface A { + + /** field f in A */ + public int f = 0; + + public static String QUOTE = "Winter is coming"; + + /** a documented static method */ + public static void msd() {} + + /* An undocumented static method */ + public static void msn() {} + + /** A property in parent */ + DoubleProperty rate = null; + public void setRate(double l); + public double getRate(); + public DoubleProperty rateProperty(); + // A support class + public interface DoubleProperty {} + + /** AA in A */ + public interface AA {} + + /** m0 in A */ + public void m0(); + + /** m1 in A */ + public void m1(); + + /** m2 in A */ + public void m2(); + + /** m3 in A */ + public void m3(); + } + + public interface B extends A { + // No comment + public void m0(); + + /** m1 in B */ + public void m1(); + + /** {@inheritDoc} */ + public void m2(); + + /** @throws Exception e */ + public void m3() throws Exception; + + /** n in B */ + public void n(); + } + + public interface C extends A, B { + /** m in C */ + public void m(); + + /** o in C */ + public void o(); + } + + /** + * The child of all children. + * + * Start of links

    + * {@link m0}, + * {@link m1}, + * {@link m2}, + * {@link m3}, + * {@link m}, + * {@link n}, + * {@link o}, + * End of links + * + * @see #m0() + * @see #m1() + * @see #m2() + * @see #m3() + * @see #m + * @see #n + * @see #o + */ + public interface D extends A, B, C { + /** m in D */ + public void m(); + + /** n in D */ + public void n(); + + // no comment + public void o(); + } + } diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/TestEnum.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/TestEnum.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 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 pkg5; + +/** Test Enum */ +public enum TestEnum { + A, B, C, D; + /** A useful method. */ + public void doSomething(){} +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestBadOverride.java --- a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestBadOverride.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2017, 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 8174839 8175200 8186332 - * @summary Bad overriding method should not crash - * @library ../lib - * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build JavadocTester - * @run main TestBadOverride - */ - -public class TestBadOverride extends JavadocTester { - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String... args) throws Exception { - TestBadOverride tester = new TestBadOverride(); - tester.runTests(); - } - - @Test - void test() { - javadoc("-d", "out", - "-sourcepath", testSrc, - "pkg4"); - checkExit(Exit.OK); - - checkOutput("pkg4/Foo.html", true, - "

  • \n" - + "

    toString

    \n" - + "
    public void toString()
    \n" - + "
    Why can't I do this ?
    \n" - + "
  • "); - } -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestMultiInheritence.java --- a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestMultiInheritence.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2003, 2016, 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 4933335 - * @summary Make sure that all inherited methods from multiple extended - * interfaces are documented - * @author jamieh - * @library ../lib - * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build JavadocTester - * @run main TestMultiInheritence - */ - -// TODO: should be TestMultiInheritance -public class TestMultiInheritence extends JavadocTester { - - public static void main(String... args) throws Exception { - TestMultiInheritence tester = new TestMultiInheritence(); - tester.runTests(); - } - - @Test - void test() { - javadoc("-d", "out", - "-sourcepath", testSrc, - "pkg3"); - checkExit(Exit.OK); - - // Method foo() is inherited from BOTH I2 and I3 - - checkOutput("pkg3/I1.html", true, - "Methods inherited from interface pkg3." - + "" - + "I2", - "Methods inherited from interface pkg3." - + "" - + "I3"); - - checkOutput("pkg3/I0.html", true, - "Methods inherited from interface pkg3." - + "" - + "I2", - "Methods inherited from interface pkg3." - + "" - + "I3"); - - // Method foo() is NOT inherited from I4 because it is overriden by I3. - - checkOutput("pkg3/I1.html", false, - "Methods inherited from interface pkg3." - + "" - + "I4"); - - checkOutput("pkg3/I0.html", false, - "Methods inherited from interface pkg3." - + "" - + "I4"); - } -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverrideMethods.java --- a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverrideMethods.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2017, 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 8157000 - * @summary test the behavior of --override-methods option - * @library ../lib - * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build JavadocTester - * @run main TestOverrideMethods - */ - -public class TestOverrideMethods extends JavadocTester { - public static void main(String... args) throws Exception { - TestOverrideMethods tester = new TestOverrideMethods(); - tester.runTests(); - } - - @Test - void testInvalidOption() { - // Make sure an invalid argument fails - javadoc("-d", "out-bad-option", - "-sourcepath", testSrc, - "-javafx", - "--override-methods=nonsense", - "pkg5"); - - checkExit(Exit.CMDERR); - } - - @Test - void testDetail() { - // Make sure the option works - javadoc("-d", "out-detail", - "-sourcepath", testSrc, - "-javafx", - "--override-methods=detail", - "pkg5"); - - checkExit(Exit.OK); - } - - @Test - void testSummary() { - javadoc("-d", "out-summary", - "-sourcepath", testSrc, - "-javafx", - "--override-methods=summary", - "pkg5"); - - checkExit(Exit.OK); - - checkOutput("pkg5/Classes.C.html", true, - // Check properties - "

    Properties declared in class pkg5.Classes.P

    \n" - + "rate", - - // Check nested classes - "

    Nested classes/interfaces declared in class pkg5." - + "Classes.P

    \n" - + "" - + "Classes.P.PN<K," - + "" - + "V>\n", - - // Check fields - "

    Fields declared in class pkg5.Classes.P

    \n" - + "field0\n", - - // Check method summary - "void\n" - + "" - + "m1()\n" - + "\n" - + "
    A modified method
    \n", - - "void\n" - + "" - + "m4" - + "​(java.lang.String k,\n" - + " java.lang.String v)\n", - - // Check footnotes - "

    Methods declared in class pkg5.Classes.GP

    \n" - + "m0", - - // Check method details for override - "
    Overrides:
    \n" - + "
    m7" - + " in class Classes.GP
    \n" - ); - - // Check footnotes 2 - checkOrder("pkg5/Classes.C.html", - "Methods declared in class pkg5.", - "getRate, ", - "m2, ", - "m3, ", - "m4, ", - "rateProperty, ", - "setRate" - ); - - // Check @link - checkOrder("pkg5/Classes.C.html", - "A test of links to the methods in this class.

    \n", - "Classes.GP.m0()", - "m1()", - "Classes.P.m2()", - "Classes.P.m3()", - "m4(java.lang.String,java.lang.String)", - "Classes.P.m5()", - "m6()", - "m7()", - "End of links" - ); - - // Check @see - checkOrder("pkg5/Classes.C.html", - "See Also:", - "Classes.GP.m0()", - "m1()", - "Classes.P.m2()", - "Classes.P.m3()", - "" - + "m4(String k, String v)", - "Classes.P.m5()", - "m6()", - "m7()" - ); - - checkOutput("pkg5/Interfaces.D.html", true, - // Check properties - "

    Properties declared in interface pkg5.Interfaces.A", - - // Check nested classes - "

    Nested classes/interfaces declared in interface pkg5." - + "" - + "Interfaces.A

    \n" - + "Interfaces.A.AA", - - // Check fields - "

    Fields declared in interface pkg5.Interfaces.A

    \n" - + "f", - - // Check method summary - "void\n" - + "" - + "m()\n" - + "\n" - + "
    m in D
    \n", - - "void\n" - + "" - + "n()\n" - + "\n" - + "
    n in D
    \n", - - // Check footnote - "

    Methods declared in interface pkg5.Interfaces.A

    \n" - + "getRate, " - + "rateProperty, " - + "setRate", - - "

    Methods declared in interface pkg5.Interfaces.B

    \n" - + "m1, " - + "m3", - - "

    Methods declared in interface pkg5.Interfaces.C

    \n" - + "o" - ); - - checkOrder("pkg5/Interfaces.D.html", - "Start of links

    ", - "Interfaces.A.m0()", - "Interfaces.A.m1()", - "Interfaces.A.m2()", - "Interfaces.A.m3()", - "m()", - "n()", - "Interfaces.C.o()", - "End of links"); - - checkOrder("pkg5/Interfaces.D.html", - "See Also:", - "Interfaces.A.m0()", - "Interfaces.A.m1()", - "Interfaces.A.m2()", - "Interfaces.A.m3()", - "m()", - "n()", - "Interfaces.C.o()"); - - // Test synthetic values and valuesof of an enum. - checkOrder("index-all.html", - "

    M

    ", - "m()", - "m()", - "m0()", - "m0()", - "m1()", - "m1()", - "m1()", - "m1()", - "m2()", - "m2()", - "m3()", - "m3()", - "m3()", - "m4(String, String)", - "m4(K, V)", - "m5()", - "m6()", - "m6()", - "m7()", - "m7()", - "Returns the enum constant of this type with the specified name.", - "Returns an array containing the constants of this enum type, in\n" + - "the order they are declared." - ); - } -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverridenMethodDocCopy.java --- a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverridenMethodDocCopy.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2003, 2016, 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 4368820 8025633 8026567 - * @summary Inherited comment should link directly to member, not just - * class - * @author jamieh - * @library ../lib - * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build JavadocTester - * @run main TestOverridenMethodDocCopy - */ - -public class TestOverridenMethodDocCopy extends JavadocTester { - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String... args) throws Exception { - TestOverridenMethodDocCopy tester = new TestOverridenMethodDocCopy(); - tester.runTests(); - } - - @Test - void test() { - javadoc("-d", "out", - "-sourcepath", testSrc, - "pkg1", "pkg2"); - checkExit(Exit.OK); - - checkOutput("pkg1/SubClass.html", true, - "Description copied from class: " - + "" - + "BaseClass"); - } -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverridenPrivateMethods.java --- a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverridenPrivateMethods.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2002, 2016, 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 4634891 8026567 - * @summary Determine if overriden methods are properly documented when - * -protected (default) visibility flag is used. - * @author jamieh - * @library ../lib - * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build JavadocTester - * @run main TestOverridenPrivateMethods - */ - -public class TestOverridenPrivateMethods extends JavadocTester { - - public static void main(String... args) throws Exception { - TestOverridenPrivateMethods tester = new TestOverridenPrivateMethods(); - tester.runTests(); - } - - @Test - void test() { - javadoc("-d", "out", - "-sourcepath", testSrc, - "pkg1", "pkg2"); - checkExit(Exit.OK); - - // The public method should be overridden - checkOutput("pkg1/SubClass.html", true, - "
    Overrides:
    \n" - + "
    Overrides:\n" - + "
    Overrides:\n" - + "
    Overrides:\n" - + "
    Overrides:\n" - + "
    Overrides:\n" - + "
    " - + "publicMethod in class " - + "BaseClass
    "); - - // The public method in different package should be overridden - checkOutput("pkg2/SubClass.html", true, - "
    Overrides:
    \n" - + "
    " - + "publicMethod in class " - + "BaseClass
    "); - - // The package private method should be overridden since the base and sub class are in the same - // package. - checkOutput("pkg1/SubClass.html", true, - "
    Overrides:
    \n" - + "
    " - + "packagePrivateMethod in class " - + "BaseClass
    "); - - // The private method in should not be overridden - checkOutput("pkg1/SubClass.html", false, - "
    Overrides:
    \n" - + "
    "); - - // The private method in different package should not be overridden - checkOutput("pkg2/SubClass.html", false, - "
    Overrides:
    \n" - + "
    "); - - // The package private method should not be overridden since the base and sub class are in - // different packages. - checkOutput("pkg2/SubClass.html", false, - "
    Overrides:
    \n" - + "
    "); - } -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java --- a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2002, 2016, 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 4634891 8026567 - * @summary Determine if overridden methods are properly documented when - * -protected (default) visibility flag is used. - * @author jamieh - * @library ../lib - * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build JavadocTester - * @run main TestOverridenPrivateMethodsWithPrivateFlag - */ - -public class TestOverridenPrivateMethodsWithPrivateFlag extends JavadocTester { - - public static void main(String... args) throws Exception { - TestOverridenPrivateMethodsWithPrivateFlag tester = new TestOverridenPrivateMethodsWithPrivateFlag(); - tester.runTests(); - } - - @Test - void test() { - javadoc("-d", "out", - "-sourcepath", testSrc, - "-private", - "pkg1", "pkg2"); - checkExit(Exit.OK); - - // The public method should be overridden - checkOutput("pkg1/SubClass.html", true, - "
    Overrides:
    \n" + - "
    Overrides:\n" + - "
    Overrides:\n" + - "
    Overrides:\n" + - "
    Overrides:\n" + - "
    Overrides:\n" + - "
    extends GP { - - /** A nested class in parent */ - public class PN{} - - /** A property in parent */ - private DoubleProperty rate; - public final void setRate(double l){} - public final double getRate(){return 1;} - public DoubleProperty rateProperty() {return null;} - - /** A ctor in parent */ - public P() {} - - /** - * A ctor in parent. - * @param s string - */ - public P(String s) {} - - /** field0 in parent */ - public int field0; - - /** field1 in parent */ - public int field1; - - - // m0 in parent - public void m0() {} - - /** m1 in parent */ - public void m1() {} - - /** m2 in parent */ - public void m2() {} - - /** m3 in parent */ - public void m3() {} - - /** m4 in parent - @param k a key - @param v a value - */ - public void m4(K k, V v) {} - - // No comment - public void m5() {} - - // No comment - public void m6() {} - - /** {@inheritDoc} */ - public void m7() {} - - } - - public static class C extends P { - - public C(String s) {} - - public int field1; - - /** A modified method */ - public void m1() {} - - /** {@inheritDoc} */ - public void m2() {} - - // No comment method - public void m3() {} - - public void m4(String k, String v) {} - - // Do something else than the parent - public void m5() {} - - /** A test of links to the methods in this class.

    - * {@link m0}, - * {@link m1}, - * {@link m2}, - * {@link m3}, - * {@link m4}, - * {@link m5}, - * {@link m6}, - * {@link m7}, - * End of links - * - * @see #m0() - * @see #m1() - * @see #m2() - * @see #m3() - * @see #m4(String k, String v) - * @see #m5() - * @see #m6() - * @see #m7() - */ - public void m6() {} - - /** m7 in Child. */ - public void m7() {} - } - - /** Tickle this {@link TestEnum#doSomething()} */ - public class DoubleProperty {} -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/Interfaces.java --- a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/Interfaces.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2017, 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 pkg5; - -public class Interfaces { - public interface A { - - /** field f in A */ - public int f = 0; - - /** A property in parent */ - DoubleProperty rate = null; - public void setRate(double l); - public double getRate(); - public DoubleProperty rateProperty(); - // A support class - public interface DoubleProperty {} - - /** AA in A */ - public interface AA {} - - /** m0 in A */ - public void m0(); - - /** m1 in A */ - public void m1(); - - /** m2 in A */ - public void m2(); - - /** m3 in A */ - public void m3(); - } - - public interface B extends A { - // No comment - public void m0(); - - /** m1 in B */ - public void m1(); - - /** {@inheritDoc} */ - public void m2(); - - /** @throws Exception e */ - public void m3() throws Exception; - - /** n in B */ - public void n(); - } - - public interface C extends A, B { - /** m in C */ - public void m(); - - /** o in C */ - public void o(); - } - - /** - * The child of all children. - * - * Start of links

    - * {@link m0}, - * {@link m1}, - * {@link m2}, - * {@link m3}, - * {@link m}, - * {@link n}, - * {@link o}, - * End of links - * - * @see #m0() - * @see #m1() - * @see #m2() - * @see #m3() - * @see #m - * @see #n - * @see #o - */ - public interface D extends A, B, C { - /** m in D */ - public void m(); - - /** n in D */ - public void n(); - - // no comment - public void o(); - } - } diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/TestEnum.java --- a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/TestEnum.java Wed Dec 13 13:27:45 2017 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2017, 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 pkg5; - -/** Test Enum */ -public enum TestEnum { - A, B, C, D; - /** A useful method. */ - public void doSomething(){} -} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/jdk/jshell/ToolSimpleTest.java --- a/test/langtools/jdk/jshell/ToolSimpleTest.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/langtools/jdk/jshell/ToolSimpleTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -216,7 +216,9 @@ public void testInvalidClassPath() { test( a -> assertCommand(a, "/env --class-path snurgefusal", - "| File 'snurgefusal' for '--class-path' is not found.") + "| File 'snurgefusal' for '--class-path' is not found."), + a -> assertCommand(a, "/env --class-path ?", + "| File '?' for '--class-path' is not found.") ); } diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/tools/javac/varargs/ElementTypeMissingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/javac/varargs/ElementTypeMissingTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,8 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8193142 + * @summary Regression: ClassCastException: Type$ErrorType cannot be cast to Type$ArrayType + * @compile/fail/ref=ElementTypeMissingTest.out -XDrawDiagnostics -XDdev ElementTypeMissingTest.java + */ + +public class ElementTypeMissingTest { void m(Unkn... own) { } } \ No newline at end of file diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/tools/javac/varargs/ElementTypeMissingTest.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/javac/varargs/ElementTypeMissingTest.out Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,2 @@ +ElementTypeMissingTest.java:8:46: compiler.err.cant.resolve.location: kindname.class, Unkn, , , (compiler.misc.location: kindname.class, ElementTypeMissingTest, null) +1 error \ No newline at end of file diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/tools/jdeps/lib/JdepsUtil.java --- a/test/langtools/tools/jdeps/lib/JdepsUtil.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/langtools/tools/jdeps/lib/JdepsUtil.java Wed Dec 13 10:25:38 2017 -0800 @@ -175,7 +175,7 @@ public ModuleAnalyzer getModuleAnalyzer(Set mods) throws IOException { // if --check is set, add to the root set and all modules are observable addmods(mods); - builder.allModules(); + builder.addmods(Set.of("ALL-SYSTEM", "ALL-MODULE-PATH")); return new ModuleAnalyzer(configuration(), pw, mods); } diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/tools/jdeps/modules/GenModuleInfo.java --- a/test/langtools/tools/jdeps/modules/GenModuleInfo.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/langtools/tools/jdeps/modules/GenModuleInfo.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 - * @summary Tests jdeps --generate-module-info option + * @bug 8193192 * @library ../lib * @build CompilerUtils JdepsUtil JdepsRunner * @modules jdk.jdeps/com.sun.tools.jdeps * @run testng GenModuleInfo + * @summary Tests jdeps --generate-module-info option */ import java.io.File; @@ -58,15 +59,21 @@ private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); private static final Path MODS_DIR = Paths.get("mods"); private static final Path LIBS_DIR = Paths.get("libs"); + private static final Path MLIBS_DIR = Paths.get("mlibs"); private static final Path DEST_DIR = Paths.get("moduleinfosrc"); private static final Path NEW_MODS_DIR = Paths.get("new_mods"); // the names of the modules in this test public static final String UNSUPPORTED = "unsupported"; public static final Set MODULES = Set.of( - "mI", "mII", "mIII", "provider", UNSUPPORTED + "mI", "mII", "mIII", "provider", "test", UNSUPPORTED ); + @BeforeTest + public void setup() throws Exception { + compileAndCreateJars(); + } + /** * Compile modules */ @@ -81,6 +88,21 @@ /** * Create JAR files with no module-info.class */ + public static void createModularJARs(Path mods, Path dest, String... modules) throws IOException { + Files.createDirectory(dest); + // create modular JAR + for (String mn : modules) { + Path root = mods.resolve(mn); + try (Stream stream = Files.find(root, Integer.MAX_VALUE, + (p, attr) -> { return attr.isRegularFile(); })) { + JdepsUtil.createJar(dest.resolve(mn + ".jar"), root, stream); + } + } + } + + /** + * Create JAR files with no module-info.class + */ public static List createJARFiles(Path mods, Path libs) throws IOException { Files.createDirectory(libs); @@ -141,18 +163,16 @@ } - /** - * Compiles all modules used by the test - */ - @BeforeTest - public void compileAll() throws Exception { + public static void compileAndCreateJars() throws Exception { CompilerUtils.cleanDir(MODS_DIR); CompilerUtils.cleanDir(LIBS_DIR); - CompilerUtils.cleanDir(DEST_DIR); - CompilerUtils.cleanDir(NEW_MODS_DIR); compileModules(MODS_DIR); + // create modular JARs except test + createModularJARs(MODS_DIR, MLIBS_DIR, MODULES.stream().filter(mn -> !mn.equals("test")) + .toArray(String[]::new)); + // create non-modular JARs createJARFiles(MODS_DIR, LIBS_DIR); } @@ -166,35 +186,67 @@ @Test public void test() throws IOException { - Files.createDirectory(DEST_DIR); + Path dest = DEST_DIR.resolve("case1"); + Path classes = NEW_MODS_DIR.resolve("case1"); + Files.createDirectories(dest); + Files.createDirectories(classes); Stream files = MODULES.stream() .map(mn -> LIBS_DIR.resolve(mn + ".jar")) .map(Path::toString); Stream options = Stream.concat( - Stream.of("--generate-module-info", DEST_DIR.toString()), files); + Stream.of("--generate-module-info", dest.toString()), files); JdepsRunner.run(options.toArray(String[]::new)); // check file exists MODULES.stream() - .map(mn -> DEST_DIR.resolve(mn).resolve("module-info.java")) + .map(mn -> dest.resolve(mn).resolve("module-info.java")) .forEach(f -> assertTrue(Files.exists(f))); // copy classes to a temporary directory // and then compile new module-info.java - copyClasses(MODS_DIR, NEW_MODS_DIR); - compileNewGenModuleInfo(DEST_DIR, NEW_MODS_DIR); + copyClasses(MODS_DIR, classes); + compileNewGenModuleInfo(dest, classes); for (String mn : MODULES) { - Path p1 = NEW_MODS_DIR.resolve(mn).resolve(MODULE_INFO); - Path p2 = MODS_DIR.resolve(mn).resolve(MODULE_INFO); + verify(mn, classes, MODS_DIR); + } + } + + @Test + public void withModulePath() throws IOException { + Path dest = DEST_DIR.resolve("case2"); + Path classes = NEW_MODS_DIR.resolve("case2"); + Files.createDirectories(dest); + Files.createDirectories(classes); + + JdepsRunner.run("--module-path", MLIBS_DIR.toString(), + "--generate-module-info", dest.toString(), + LIBS_DIR.resolve("test.jar").toString()); + + String name = "test"; + Path gensrc = dest.resolve(name).resolve("module-info.java"); + assertTrue(Files.exists(gensrc)); - try (InputStream in1 = Files.newInputStream(p1); - InputStream in2 = Files.newInputStream(p2)) { - verify(ModuleDescriptor.read(in1), - ModuleDescriptor.read(in2, () -> packages(MODS_DIR.resolve(mn)))); - } + // copy classes to a temporary directory + // and then compile new module-info.java + copyClasses(MODS_DIR.resolve(name), classes.resolve(name)); + assertTrue(CompilerUtils.compileModule(dest, classes, name, "-p", MLIBS_DIR.toString())); + + verify(name, classes, MODS_DIR); + } + + /** + * Verify the dependences from the given module-info.class files + */ + public void verify(String mn, Path mdir1, Path mdir2) throws IOException { + Path p1 = mdir1.resolve(mn).resolve(MODULE_INFO); + Path p2 = mdir2.resolve(mn).resolve(MODULE_INFO); + try (InputStream in1 = Files.newInputStream(p1); + InputStream in2 = Files.newInputStream(p2)) { + verify(ModuleDescriptor.read(in1), + ModuleDescriptor.read(in2, () -> packages(mdir2.resolve(mn)))); } } diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/tools/jdeps/modules/GenOpenModule.java --- a/test/langtools/tools/jdeps/modules/GenOpenModule.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/langtools/tools/jdeps/modules/GenOpenModule.java Wed Dec 13 10:25:38 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -54,41 +54,39 @@ private static final Path DEST_DIR = Paths.get("moduleinfosrc"); private static final Path NEW_MODS_DIR = Paths.get("new_mods"); - /** - * Compiles all modules used by the test - */ @BeforeTest - public void compileAll() throws Exception { - - compileModules(MODS_DIR); - - createJARFiles(MODS_DIR, LIBS_DIR); + public void setup() throws Exception { + compileAndCreateJars(); } @Test public void test() throws IOException { + Path dest = DEST_DIR.resolve("open"); + Path classes = NEW_MODS_DIR.resolve("open"); + Files.createDirectories(dest); + Files.createDirectories(classes); + Stream files = MODULES.stream() .map(mn -> LIBS_DIR.resolve(mn + ".jar")) .map(Path::toString); Stream options = Stream.concat( - Stream.of("--generate-open-module", DEST_DIR.toString()), files); + Stream.of("--generate-open-module", dest.toString()), files); JdepsRunner.run(options.toArray(String[]::new)); // check file exists MODULES.stream() - .map(mn -> DEST_DIR.resolve(mn).resolve("module-info.java")) + .map(mn -> dest.resolve(mn).resolve("module-info.java")) .forEach(f -> assertTrue(Files.exists(f))); // copy classes to a temporary directory // and then compile new module-info.java - copyClasses(MODS_DIR, NEW_MODS_DIR); - compileNewGenModuleInfo(DEST_DIR, NEW_MODS_DIR); + copyClasses(MODS_DIR, classes); + compileNewGenModuleInfo(dest, classes); for (String mn : MODULES) { - Path p1 = NEW_MODS_DIR.resolve(mn).resolve(MODULE_INFO); + Path p1 = classes.resolve(mn).resolve(MODULE_INFO); Path p2 = MODS_DIR.resolve(mn).resolve(MODULE_INFO); - try (InputStream in1 = Files.newInputStream(p1); InputStream in2 = Files.newInputStream(p2)) { verify(ModuleDescriptor.read(in1), diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/tools/jdeps/modules/src/test/jdk/test/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/jdeps/modules/src/test/jdk/test/Main.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 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 jdk.test; + +import java.sql.Driver; + +import p1.Goo; +import p2.Bar; +import p3.Foo; + +public class Main { + public static void main(String... args) { + Goo goo = toGoo(new Bar()); + Driver driver = new Foo().getDriver(); + } + + public static Goo toGoo(Bar bar) { + return bar.toGoo(); + } +} diff -r 093027a037cf -r 191ae61bd1e9 test/langtools/tools/jdeps/modules/src/test/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/jdeps/modules/src/test/module-info.java Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017, 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. + */ + +module test { + requires java.sql; + requires transitive mI; + requires transitive mII; + requires mIII; +} diff -r 093027a037cf -r 191ae61bd1e9 test/nashorn/script/basic/JDK-8069338.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/nashorn/script/basic/JDK-8069338.js Wed Dec 13 10:25:38 2017 -0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2017, 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. + */ + +/** + * JDK-8069338: Implement sharedScopeCall for optimistic types + * + * @test + * @run + */ + +var c = 0; +var n = 1; + +function f() { + return c++ > 10 ? 'f' : 1; +} + +function h() { + var x = 0; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + n = 'b'; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + return x; +} + +function g() { + var x = 0; + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + return x; +} + +Assert.assertEquals(h(), '11bbbbbb'); +Assert.assertEquals(g(), '11ffffff'); + diff -r 093027a037cf -r 191ae61bd1e9 test/nashorn/src/jdk/dynalink/beans/test/BeanLinkerTest.java --- a/test/nashorn/src/jdk/dynalink/beans/test/BeanLinkerTest.java Wed Dec 13 13:27:45 2017 +0530 +++ b/test/nashorn/src/jdk/dynalink/beans/test/BeanLinkerTest.java Wed Dec 13 10:25:38 2017 -0800 @@ -30,6 +30,7 @@ import static jdk.dynalink.StandardOperation.CALL; import static jdk.dynalink.StandardOperation.GET; import static jdk.dynalink.StandardOperation.NEW; +import static jdk.dynalink.StandardOperation.REMOVE; import static jdk.dynalink.StandardOperation.SET; import java.lang.invoke.CallSite; @@ -39,7 +40,9 @@ import java.security.AccessControlException; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.DynamicLinker; import jdk.dynalink.DynamicLinkerFactory; @@ -90,6 +93,7 @@ private static final Operation GET_ELEMENT = GET.withNamespace(ELEMENT); private static final Operation GET_METHOD = GET.withNamespace(METHOD); private static final Operation SET_ELEMENT = SET.withNamespace(ELEMENT); + private static final Operation REMOVE_ELEMENT = REMOVE.withNamespace(ELEMENT); private static final MethodHandle findThrower(final String name) { try { @@ -121,8 +125,8 @@ final CallSiteDescriptor desc = req.getCallSiteDescriptor(); final Operation op = desc.getOperation(); final Operation baseOp = NamedOperation.getBaseOperation(op); - if (baseOp != GET_ELEMENT && baseOp != SET_ELEMENT) { - // We only handle GET_ELEMENT and SET_ELEMENT. + if (baseOp != GET_ELEMENT && baseOp != SET_ELEMENT && baseOp != REMOVE_ELEMENT) { + // We only handle GET_ELEMENT, SET_ELEMENT and REMOVE_ELEMENT. return null; } @@ -538,4 +542,85 @@ } } } + + @Test(dataProvider = "flags") + public void removeElementFromListTest(final boolean publicLookup) throws Throwable { + final MethodType mt = MethodType.methodType(void.class, Object.class, int.class); + final CallSite cs = createCallSite(publicLookup, REMOVE_ELEMENT, mt); + + final List list = new ArrayList<>(List.of(23, 430, -4354)); + + cs.getTarget().invoke(list, 1); + Assert.assertEquals(list, List.of(23, -4354)); + cs.getTarget().invoke(list, 1); + Assert.assertEquals(list, List.of(23)); + cs.getTarget().invoke(list, 0); + Assert.assertEquals(list, List.of()); + try { + cs.getTarget().invoke(list, -1); + throw new RuntimeException("expected IndexOutOfBoundsException"); + } catch (final IndexOutOfBoundsException ex) { + } + + try { + cs.getTarget().invoke(list, list.size()); + throw new RuntimeException("expected IndexOutOfBoundsException"); + } catch (final IndexOutOfBoundsException ex) { + } + } + + @Test(dataProvider = "flags") + public void removeElementFromListWithFixedKeyTest(final boolean publicLookup) throws Throwable { + final MethodType mt = MethodType.methodType(void.class, Object.class); + + final List list = new ArrayList<>(List.of(23, 430, -4354)); + + createCallSite(publicLookup, REMOVE_ELEMENT.named(1), mt).getTarget().invoke(list); + Assert.assertEquals(list, List.of(23, -4354)); + createCallSite(publicLookup, REMOVE_ELEMENT.named(1), mt).getTarget().invoke(list); + Assert.assertEquals(list, List.of(23)); + createCallSite(publicLookup, REMOVE_ELEMENT.named(0), mt).getTarget().invoke(list); + Assert.assertEquals(list, List.of()); + try { + createCallSite(publicLookup, REMOVE_ELEMENT.named(-1), mt).getTarget().invoke(list); + throw new RuntimeException("expected IndexOutOfBoundsException"); + } catch (final IndexOutOfBoundsException ex) { + } + + try { + createCallSite(publicLookup, REMOVE_ELEMENT.named(list.size()), mt).getTarget().invoke(list); + throw new RuntimeException("expected IndexOutOfBoundsException"); + } catch (final IndexOutOfBoundsException ex) { + } + } + + @Test(dataProvider = "flags") + public void removeElementFromMapTest(final boolean publicLookup) throws Throwable { + final MethodType mt = MethodType.methodType(void.class, Object.class, Object.class); + final CallSite cs = createCallSite(publicLookup, REMOVE_ELEMENT, mt); + + final Map map = new HashMap<>(Map.of("k1", "v1", "k2", "v2", "k3", "v3")); + + cs.getTarget().invoke(map, "k2"); + Assert.assertEquals(map, Map.of("k1", "v1", "k3", "v3")); + cs.getTarget().invoke(map, "k4"); + Assert.assertEquals(map, Map.of("k1", "v1", "k3", "v3")); + cs.getTarget().invoke(map, "k1"); + Assert.assertEquals(map, Map.of("k3", "v3")); + } + + + @Test(dataProvider = "flags") + public void removeElementFromMapWithFixedKeyTest(final boolean publicLookup) throws Throwable { + final MethodType mt = MethodType.methodType(void.class, Object.class); + + final Map map = new HashMap<>(Map.of("k1", "v1", "k2", "v2", "k3", "v3")); + + createCallSite(publicLookup, REMOVE_ELEMENT.named("k2"), mt).getTarget().invoke(map); + Assert.assertEquals(map, Map.of("k1", "v1", "k3", "v3")); + createCallSite(publicLookup, REMOVE_ELEMENT.named("k4"), mt).getTarget().invoke(map); + Assert.assertEquals(map, Map.of("k1", "v1", "k3", "v3")); + createCallSite(publicLookup, REMOVE_ELEMENT.named("k1"), mt).getTarget().invoke(map); + Assert.assertEquals(map, Map.of("k3", "v3")); + } }