diff --git a/jdk/make/data/currency/CurrencyData.properties b/jdk/make/data/currency/CurrencyData.properties index 2b5a5704959..4123814c849 100644 --- a/jdk/make/data/currency/CurrencyData.properties +++ b/jdk/make/data/currency/CurrencyData.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,10 @@ # questions. # -formatVersion=1 +# Version of the currency data format. +# 1: initial +# 2: Change in minor unit (allowing 4-9 digits) +formatVersion=2 # Version of the currency code information in this class. # It is a serial number that accompanies with each amendment. @@ -36,7 +39,7 @@ dataVersion=159 all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036-\ AWG533-AYM945-AZM031-AZN944-BAM977-BBD052-BDT050-BEF056-BGL100-BGN975-BHD048-BIF108-\ BMD060-BND096-BOB068-BOV984-BRL986-BSD044-BTN064-BWP072-BYB112-BYR974-\ - BZD084-CAD124-CDF976-CHF756-CLF990-CLP152-CNY156-COP170-CRC188-CSD891-CUP192-CUC931-\ + BZD084-CAD124-CDF976-CHE947-CHF756-CHW948-CLF990-CLP152-CNY156-COP170-COU970-CRC188-CSD891-CUP192-CUC931-\ CVE132-CYP196-CZK203-DEM276-DJF262-DKK208-DOP214-DZD012-EEK233-EGP818-\ ERN232-ESP724-ETB230-EUR978-FIM246-FJD242-FKP238-FRF250-GBP826-GEL981-\ GHC288-GHS936-GIP292-GMD270-GNF324-GRD300-GTQ320-GWP624-GYD328-HKD344-HNL340-\ @@ -49,7 +52,7 @@ all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036 PKR586-PLN985-PTE620-PYG600-QAR634-ROL946-RON946-RSD941-RUB643-RUR810-RWF646-SAR682-\ SBD090-SCR690-SDD736-SDG938-SEK752-SGD702-SHP654-SIT705-SKK703-SLL694-SOS706-\ SRD968-SRG740-SSP728-STD678-SVC222-SYP760-SZL748-THB764-TJS972-TMM795-TMT934-TND788-TOP776-\ - TPE626-TRL792-TRY949-TTD780-TWD901-TZS834-UAH980-UGX800-USD840-USN997-USS998-\ + TPE626-TRL792-TRY949-TTD780-TWD901-TZS834-UAH980-UGX800-USD840-USN997-USS998-UYI940-\ UYU858-UZS860-VEB862-VEF937-VND704-VUV548-WST882-XAF950-XAG961-XAU959-XBA955-\ XBB956-XBC957-XBD958-XCD951-XDR960-XFO000-XFU000-XOF952-XPD964-XPF953-\ XPT962-XSU994-XTS963-XUA965-XXX999-YER886-YUM891-ZAR710-ZMK894-ZMW967-ZWD716-ZWL932-\ @@ -579,16 +582,17 @@ ZM=ZMW ZW=ZWL -# List of currencies with 0, 1, OR 3 decimals for minor units, or where there -# are no minor units defined. All others use 2 decimals. +# List of currencies with non-2digit decimals for minor units, +# or where there are no minor units defined. All others use 2 decimals. minor0=\ - ADP-BEF-BIF-BYB-BYR-CLF-CLP-DJF-ESP-GNF-\ + ADP-BEF-BIF-BYB-BYR-CLP-DJF-ESP-GNF-\ GRD-ISK-ITL-JPY-KMF-KRW-LUF-MGF-PYG-PTE-RWF-\ - TPE-TRL-UGX-VND-VUV-XAF-XOF-XPF -minor1= + TPE-TRL-UGX-UYI-VND-VUV-XAF-XOF-XPF minor3=\ BHD-IQD-JOD-KWD-LYD-OMR-TND +minor4=\ + CLF minorUndefined=\ XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-\ XPT-XSU-XTS-XUA-XXX diff --git a/jdk/make/gensrc/Gensrc-jdk.jconsole.gmk b/jdk/make/gensrc/Gensrc-jdk.jconsole.gmk deleted file mode 100644 index 2885540dfb4..00000000000 --- a/jdk/make/gensrc/Gensrc-jdk.jconsole.gmk +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -include GensrcCommon.gmk - -########################################################################################## -# Version file for jconsole - -$(SUPPORT_OUTPUTDIR)/gensrc/jdk.jconsole/sun/tools/jconsole/Version.java: \ - $(JDK_TOPDIR)/src/jdk.jconsole/share/classes/sun/tools/jconsole/Version.java.template - $(MKDIR) -p $(@D) - $(RM) $@ $@.tmp - $(ECHO) $(LOG_INFO) Generating sun/tools/jconsole/Version.java - $(SED) -e 's/@@jconsole_version@@/$(FULL_VERSION)/g' $< > $@.tmp - $(MV) $@.tmp $@ - -GENSRC_JDK_JCONSOLE += $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jconsole/sun/tools/jconsole/Version.java - -jdk.jconsole: $(GENSRC_JDK_JCONSOLE) - -all: jdk.jconsole - -.PHONY: all jdk.jconsole diff --git a/jdk/make/lib/Lib-java.security.jgss.gmk b/jdk/make/lib/Lib-java.security.jgss.gmk index a92212f4b0e..c2cee4e109b 100644 --- a/jdk/make/lib/Lib-java.security.jgss.gmk +++ b/jdk/make/lib/Lib-java.security.jgss.gmk @@ -41,7 +41,6 @@ ifneq ($(OPENJDK_TARGET_OS), windows) CFLAGS := $(CFLAGS_JDKLIB) $(addprefix -I, $(LIBJ2GSS_SRC)) \ $(LIBJAVA_HEADER_FLAGS) \ -I$(SUPPORT_OUTPUTDIR)/headers/java.security.jgss, \ - DISABLED_WARNINGS_gcc := pointer-to-int-cast, \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libj2gss/mapfile-vers, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ @@ -74,6 +73,8 @@ ifneq ($(BUILD_CRYPTO), no) endif ifneq ($(BUILD_LIBKRB5_NAME), ) + # libosxkrb5 needs to call deprecated krb5 APIs so that java + # can use the native credentials cache. $(eval $(call SetupNativeCompilation,BUILD_LIBKRB5, \ LIBRARY := $(BUILD_LIBKRB5_NAME), \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ @@ -83,7 +84,7 @@ ifneq ($(BUILD_CRYPTO), no) CFLAGS := $(CFLAGS_JDKLIB) \ $(addprefix -I, $(BUILD_LIBKRB5_SRC)) \ -I$(SUPPORT_OUTPUTDIR)/headers/java.security.jgss, \ - DISABLED_WARNINGS_clang := implicit-function-declaration, \ + DISABLED_WARNINGS_clang := deprecated-declarations, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX := $(BUILD_LIBKRB5_LIBS), \ diff --git a/jdk/make/lib/Lib-jdk.pack200.gmk b/jdk/make/lib/Lib-jdk.pack200.gmk index b8bab611310..37e32d0a725 100644 --- a/jdk/make/lib/Lib-jdk.pack200.gmk +++ b/jdk/make/lib/Lib-jdk.pack200.gmk @@ -42,6 +42,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK, \ CFLAGS_release := -DPRODUCT, \ DISABLED_WARNINGS_gcc := conversion-null sign-compare format-security \ format-nonliteral parentheses, \ + DISABLED_WARNINGS_clang := bool-conversion format-security, \ DISABLED_WARNINGS_solstudio := truncwarn, \ DISABLED_WARNINGS_microsoft := 4267 4018, \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers, \ diff --git a/jdk/make/mapfiles/libawt/mapfile-mawt-vers b/jdk/make/mapfiles/libawt/mapfile-mawt-vers index 06d3ff802e1..195ba1cbc50 100644 --- a/jdk/make/mapfiles/libawt/mapfile-mawt-vers +++ b/jdk/make/mapfiles/libawt/mapfile-mawt-vers @@ -243,7 +243,7 @@ SUNWprivate_1.1 { getDefaultConfig; Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_X11FontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_font_SunFontManager_populateFontFileNameMap; # CDE private entry point diff --git a/jdk/make/mapfiles/libawt/mapfile-vers-linux b/jdk/make/mapfiles/libawt/mapfile-vers-linux index 922b015c68c..5624693fcca 100644 --- a/jdk/make/mapfiles/libawt/mapfile-vers-linux +++ b/jdk/make/mapfiles/libawt/mapfile-vers-linux @@ -270,7 +270,7 @@ SUNWprivate_1.1 { getDefaultConfig; Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_X11FontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_font_SunFontManager_populateFontFileNameMap; # CDE private entry point diff --git a/jdk/make/mapfiles/libawt_headless/mapfile-vers b/jdk/make/mapfiles/libawt_headless/mapfile-vers index df24e4505db..5ea1745e296 100644 --- a/jdk/make/mapfiles/libawt_headless/mapfile-vers +++ b/jdk/make/mapfiles/libawt_headless/mapfile-vers @@ -65,7 +65,7 @@ SUNWprivate_1.1 { Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_X11FontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_awt_FontDescriptor_initIDs; Java_sun_awt_PlatformFont_initIDs; diff --git a/jdk/make/mapfiles/libawt_xawt/mapfile-vers b/jdk/make/mapfiles/libawt_xawt/mapfile-vers index 4a891077b76..a2f75efcd0b 100644 --- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers @@ -188,7 +188,7 @@ SUNWprivate_1.1 { Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_X11FontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_awt_X11GraphicsEnvironment_initDisplay; Java_sun_awt_X11GraphicsEnvironment_initGLX; Java_sun_awt_X11GraphicsEnvironment_initXRender; diff --git a/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java b/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java index ca1271e6851..cc125638c96 100644 --- a/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java +++ b/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Locale; +import java.util.Objects; import java.util.Properties; import java.util.TimeZone; @@ -72,10 +73,6 @@ public class GenerateCurrencyData { private static String formatVersion; private static String dataVersion; private static String validCurrencyCodes; - private static String currenciesWith0MinorUnitDecimals; - private static String currenciesWith1MinorUnitDecimal; - private static String currenciesWith3MinorUnitDecimal; - private static String currenciesWithMinorUnitsUndefined; // handy constants - must match definitions in java.util.Currency // magic number @@ -83,29 +80,31 @@ public class GenerateCurrencyData { // number of characters from A to Z private static final int A_TO_Z = ('Z' - 'A') + 1; // entry for invalid country codes - private static final int INVALID_COUNTRY_ENTRY = 0x007F; + private static final int INVALID_COUNTRY_ENTRY = 0x0000007F; // entry for countries without currency - private static final int COUNTRY_WITHOUT_CURRENCY_ENTRY = 0x0080; + private static final int COUNTRY_WITHOUT_CURRENCY_ENTRY = 0x00000200; // mask for simple case country entries - private static final int SIMPLE_CASE_COUNTRY_MASK = 0x0000; + private static final int SIMPLE_CASE_COUNTRY_MASK = 0x00000000; // mask for simple case country entry final character - private static final int SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK = 0x001F; + private static final int SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK = 0x0000001F; // mask for simple case country entry default currency digits - private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK = 0x0060; + private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK = 0x000001E0; // shift count for simple case country entry default currency digits private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT = 5; + // maximum number for simple case country entry default currency digits + private static final int SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS = 9; // mask for special case country entries - private static final int SPECIAL_CASE_COUNTRY_MASK = 0x0080; + private static final int SPECIAL_CASE_COUNTRY_MASK = 0x00000200; // mask for special case country index - private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 0x001F; + private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 0x0000001F; // delta from entry index component in main table to index into special case tables private static final int SPECIAL_CASE_COUNTRY_INDEX_DELTA = 1; // mask for distinguishing simple and special case countries private static final int COUNTRY_TYPE_MASK = SIMPLE_CASE_COUNTRY_MASK | SPECIAL_CASE_COUNTRY_MASK; // mask for the numeric code of the currency - private static final int NUMERIC_CODE_MASK = 0x0003FF00; + private static final int NUMERIC_CODE_MASK = 0x000FFC00; // shift count for the numeric code of the currency - private static final int NUMERIC_CODE_SHIFT = 8; + private static final int NUMERIC_CODE_SHIFT = 10; // generated data private static int[] mainTable = new int[A_TO_Z * A_TO_Z]; @@ -120,7 +119,7 @@ public class GenerateCurrencyData { private static int[] specialCaseOldCurrenciesNumericCode = new int[maxSpecialCases]; private static int[] specialCaseNewCurrenciesNumericCode = new int[maxSpecialCases]; - private static final int maxOtherCurrencies = 70; + private static final int maxOtherCurrencies = 128; private static int otherCurrenciesCount = 0; private static StringBuffer otherCurrencies = new StringBuffer(); private static int[] otherCurrenciesDefaultFractionDigits = new int[maxOtherCurrencies]; @@ -129,6 +128,11 @@ public class GenerateCurrencyData { // date format for parsing cut-over times private static SimpleDateFormat format; + // Minor Units + private static String[] currenciesWithDefinedMinorUnitDecimals = + new String[SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS + 1]; + private static String currenciesWithMinorUnitsUndefined; + public static void main(String[] args) { // Look for "-o outputfilename" option @@ -171,16 +175,14 @@ public class GenerateCurrencyData { formatVersion = (String) currencyData.get("formatVersion"); dataVersion = (String) currencyData.get("dataVersion"); validCurrencyCodes = (String) currencyData.get("all"); - currenciesWith0MinorUnitDecimals = (String) currencyData.get("minor0"); - currenciesWith1MinorUnitDecimal = (String) currencyData.get("minor1"); - currenciesWith3MinorUnitDecimal = (String) currencyData.get("minor3"); + for (int i = 0; i <= SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS; i++) { + currenciesWithDefinedMinorUnitDecimals[i] + = (String) currencyData.get("minor"+i); + } currenciesWithMinorUnitsUndefined = (String) currencyData.get("minorUndefined"); if (formatVersion == null || dataVersion == null || validCurrencyCodes == null || - currenciesWith0MinorUnitDecimals == null || - currenciesWith1MinorUnitDecimal == null || - currenciesWith3MinorUnitDecimal == null || currenciesWithMinorUnitsUndefined == null) { throw new NullPointerException("not all required data is defined in input"); } @@ -207,7 +209,7 @@ public class GenerateCurrencyData { if (currencyInfo.charAt(0) == firstChar && currencyInfo.charAt(1) == secondChar) { checkCurrencyCode(currencyInfo); int digits = getDefaultFractionDigits(currencyInfo); - if (digits < 0 || digits > 3) { + if (digits < 0 || digits > SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS) { throw new RuntimeException("fraction digits out of range for " + currencyInfo); } int numericCode= getNumericCode(currencyInfo); @@ -231,13 +233,14 @@ public class GenerateCurrencyData { } private static int getDefaultFractionDigits(String currencyCode) { - if (currenciesWith0MinorUnitDecimals.indexOf(currencyCode) != -1) { - return 0; - } else if (currenciesWith1MinorUnitDecimal.indexOf(currencyCode) != -1) { - return 1; - } else if (currenciesWith3MinorUnitDecimal.indexOf(currencyCode) != -1) { - return 3; - } else if (currenciesWithMinorUnitsUndefined.indexOf(currencyCode) != -1) { + for (int i = 0; i <= SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS; i++) { + if (Objects.nonNull(currenciesWithDefinedMinorUnitDecimals[i]) && + currenciesWithDefinedMinorUnitDecimals[i].indexOf(currencyCode) != -1) { + return i; + } + } + + if (currenciesWithMinorUnitsUndefined.indexOf(currencyCode) != -1) { return -1; } else { return 2; diff --git a/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/J2DBench.java b/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/J2DBench.java index 2294e7f01be..053908ca8d8 100644 --- a/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/J2DBench.java +++ b/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/J2DBench.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -61,6 +61,7 @@ import javax.swing.BoxLayout; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; import java.text.SimpleDateFormat; import java.util.Date; @@ -698,7 +699,7 @@ public class J2DBench { } }; guiFrame = f; - f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add(Group.root.getJComponent(), BorderLayout.CENTER); JPanel p = new JPanel(); diff --git a/jdk/src/demo/share/jfc/SampleTree/SampleTree.java b/jdk/src/demo/share/jfc/SampleTree/SampleTree.java index efde28fd6f0..c7093a157ae 100644 --- a/jdk/src/demo/share/jfc/SampleTree/SampleTree.java +++ b/jdk/src/demo/share/jfc/SampleTree/SampleTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -135,7 +135,7 @@ public final class SampleTree { panel.add("Center", sp); panel.add("South", constructOptionsPanel()); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } diff --git a/jdk/src/demo/share/management/JTop/JTop.java b/jdk/src/demo/share/management/JTop/JTop.java index ab0cd94e33d..c1d48cc3716 100644 --- a/jdk/src/demo/share/management/JTop/JTop.java +++ b/jdk/src/demo/share/management/JTop/JTop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -410,7 +410,7 @@ public class JTop extends JPanel { private static void createAndShowGUI(JPanel jtop) { // Create and set up the window. JFrame frame = new JFrame("JTop"); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // Create and set up the content pane. JComponent contentPane = (JComponent) frame.getContentPane(); diff --git a/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java b/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java index ef5e76aea76..34f32f69421 100644 --- a/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java +++ b/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java @@ -276,7 +276,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * @since 1.4 * @spec JSR-51 */ - public FileChannel getChannel() { + public final FileChannel getChannel() { FileChannel fc = this.channel; if (fc == null) { synchronized (this) { diff --git a/jdk/src/java.base/share/classes/java/security/AccessControlContext.java b/jdk/src/java.base/share/classes/java/security/AccessControlContext.java index 22cb1005ed7..feed0cf11e1 100644 --- a/jdk/src/java.base/share/classes/java/security/AccessControlContext.java +++ b/jdk/src/java.base/share/classes/java/security/AccessControlContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -153,8 +153,6 @@ public final class AccessControlContext { * {@code DomainCombiner} with the provided * {@code AccessControlContext}. * - *

- * * @param acc the {@code AccessControlContext} associated * with the provided {@code DomainCombiner}. * @@ -338,8 +336,6 @@ public final class AccessControlContext { * Get the {@code DomainCombiner} associated with this * {@code AccessControlContext}. * - *

- * * @return the {@code DomainCombiner} associated with this * {@code AccessControlContext}, or {@code null} * if there is none. @@ -738,12 +734,12 @@ public final class AccessControlContext { /** * Checks two AccessControlContext objects for equality. - * Checks that obj is + * Checks that {@code obj} is * an AccessControlContext and has the same set of ProtectionDomains * as this context. - *

+ * * @param obj the object we are testing for equality with this object. - * @return true if obj is an AccessControlContext, and has the + * @return true if {@code obj} is an AccessControlContext, and has the * same set of ProtectionDomains as this context, false otherwise. */ public boolean equals(Object obj) { diff --git a/jdk/src/java.base/share/classes/java/security/AllPermission.java b/jdk/src/java.base/share/classes/java/security/AllPermission.java index c01b134f074..b830b884c59 100644 --- a/jdk/src/java.base/share/classes/java/security/AllPermission.java +++ b/jdk/src/java.base/share/classes/java/security/AllPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,7 +96,7 @@ public final class AllPermission extends Permission { * objects are always equal. * * @param obj the object we are testing for equality with this object. - * @return true if obj is an AllPermission, false otherwise. + * @return true if {@code obj} is an AllPermission, false otherwise. */ public boolean equals(Object obj) { return (obj instanceof AllPermission); @@ -124,7 +124,6 @@ public final class AllPermission extends Permission { /** * Returns a new PermissionCollection object for storing AllPermission * objects. - *

* * @return a new PermissionCollection object suitable for * storing AllPermissions. diff --git a/jdk/src/java.base/share/classes/java/security/BasicPermission.java b/jdk/src/java.base/share/classes/java/security/BasicPermission.java index 0abbfa7c047..7e0f4fb85b4 100644 --- a/jdk/src/java.base/share/classes/java/security/BasicPermission.java +++ b/jdk/src/java.base/share/classes/java/security/BasicPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ import java.io.IOException; * named permission or you don't.) * Subclasses may implement actions on top of BasicPermission, * if desired. - *

+ * * @see java.security.Permission * @see java.security.Permissions * @see java.security.PermissionCollection @@ -154,8 +154,8 @@ public abstract class BasicPermission extends Permission *

* More specifically, this method returns true if: *

@@ -193,11 +193,11 @@ public abstract class BasicPermission extends Permission /** * Checks two BasicPermission objects for equality. - * Checks that obj's class is the same as this object's class + * Checks that {@code obj}'s class is the same as this object's class * and has the same name as this object. - *

+ * * @param obj the object we are testing for equality with this object. - * @return true if obj's class is the same as this object's class + * @return true if {@code obj}'s class is the same as this object's class * and has the same name as this BasicPermission object, false otherwise. */ public boolean equals(Object obj) { diff --git a/jdk/src/java.base/share/classes/java/security/DomainCombiner.java b/jdk/src/java.base/share/classes/java/security/DomainCombiner.java index 4785df4cd80..0e1ccf9112f 100644 --- a/jdk/src/java.base/share/classes/java/security/DomainCombiner.java +++ b/jdk/src/java.base/share/classes/java/security/DomainCombiner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,8 +87,6 @@ public interface DomainCombiner { * Individual ProtectionDomains may be modified (with a new * set of Permissions, for example). * - *

- * * @param currentDomains the ProtectionDomains associated with the * current execution Thread, up to the most recent * privileged {@code ProtectionDomain}. @@ -96,7 +94,7 @@ public interface DomainCombiner { * with the most recently executing {@code ProtectionDomain} * residing at the beginning of the array. This parameter may * be {@code null} if the current execution Thread - * has no associated ProtectionDomains.

+ * has no associated ProtectionDomains. * * @param assignedDomains an array of inherited ProtectionDomains. * ProtectionDomains may be inherited from a parent Thread, diff --git a/jdk/src/java.base/share/classes/java/security/KeyRep.java b/jdk/src/java.base/share/classes/java/security/KeyRep.java index 0b1412c1563..f97208f1083 100644 --- a/jdk/src/java.base/share/classes/java/security/KeyRep.java +++ b/jdk/src/java.base/share/classes/java/security/KeyRep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -112,8 +112,6 @@ public class KeyRep implements Serializable { /** * Construct the alternate Key class. * - *

- * * @param type either one of Type.SECRET, Type.PUBLIC, or Type.PRIVATE * @param algorithm the algorithm returned from * {@code Key.getAlgorithm()} @@ -157,8 +155,6 @@ public class KeyRep implements Serializable { * encoded key bytes, and generates a private key from the spec * * - *

- * * @return the resolved Key object * * @exception ObjectStreamException if the Type/format diff --git a/jdk/src/java.base/share/classes/java/security/KeyStore.java b/jdk/src/java.base/share/classes/java/security/KeyStore.java index 71df7dbd5a2..8fde796e041 100644 --- a/jdk/src/java.base/share/classes/java/security/KeyStore.java +++ b/jdk/src/java.base/share/classes/java/security/KeyStore.java @@ -120,7 +120,7 @@ import sun.security.util.Debug; * KeyStore ks = KeyStore.getInstance("JKS"); * * The system will return the most preferred implementation of the - * specified keystore type available in the environment.

+ * specified keystore type available in the environment. * * *

Before a keystore can be accessed, it must be @@ -617,7 +617,6 @@ public class KeyStore { /** * Retrieves the attributes associated with an entry. - *

* * @return an unmodifiable {@code Set} of attributes, possibly empty * @@ -708,7 +707,6 @@ public class KeyStore { /** * Retrieves the attributes associated with an entry. - *

* * @return an unmodifiable {@code Set} of attributes, possibly empty * @@ -792,7 +790,6 @@ public class KeyStore { /** * Retrieves the attributes associated with an entry. - *

* * @return an unmodifiable {@code Set} of attributes, possibly empty * diff --git a/jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java b/jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java index ceb41d87063..ea11dab2e9a 100644 --- a/jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java +++ b/jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -595,7 +595,6 @@ public abstract class KeyStoreSpi { * Probes the specified input stream to determine whether it contains a * keystore that is supported by this implementation, or not. * - *

* @implSpec * This method returns false by default. Keystore implementations should * override this method to peek at the data stream directly or to use other diff --git a/jdk/src/java.base/share/classes/java/security/Permissions.java b/jdk/src/java.base/share/classes/java/security/Permissions.java index cce9f5f56f3..cc9c69358ee 100644 --- a/jdk/src/java.base/share/classes/java/security/Permissions.java +++ b/jdk/src/java.base/share/classes/java/security/Permissions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -111,7 +111,7 @@ implements Serializable * * This method creates * a new PermissionCollection object (and adds the permission to it) - * if an appropriate collection does not yet exist.

+ * if an appropriate collection does not yet exist. * * @param permission the Permission object to add. * @@ -162,7 +162,7 @@ implements Serializable * *

Additionally, if this PermissionCollection contains the * AllPermission, this method will always return true. - *

+ * * @param permission the Permission object to check. * * @return true if "permission" is implied by the permissions in the diff --git a/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java b/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java index 2e505d74554..6e7056ddc92 100644 --- a/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java +++ b/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java @@ -51,7 +51,6 @@ import sun.misc.SharedSecrets; * ProtectionDomain can also be constructed such that it is dynamically * mapped to a set of permissions by the current Policy whenever a permission * is checked. - *

* * @author Li Gong * @author Roland Schemers @@ -168,7 +167,6 @@ public class ProtectionDomain { * this domain. This constructor affords the * Policy provider the opportunity to augment the supplied * PermissionCollection to reflect policy changes. - *

* * @param codesource the CodeSource associated with this domain * @param permissions the permissions granted to this domain @@ -263,7 +261,6 @@ public class ProtectionDomain { * permissions, then the permission will be checked against the * combination of the PermissionCollection supplied at construction and * the current Policy binding. - *

* * @param permission the Permission object to check. * diff --git a/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java b/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java index 145f4fc482b..41b84dbe683 100644 --- a/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java +++ b/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,7 +65,7 @@ public class SecureClassLoader extends ClassLoader { *

If there is a security manager, this method first * calls the security manager's {@code checkCreateClassLoader} * method to ensure creation of a class loader is allowed. - *

+ * * @param parent the parent ClassLoader * @exception SecurityException if a security manager exists and its * {@code checkCreateClassLoader} method doesn't allow @@ -112,7 +112,7 @@ public class SecureClassLoader extends ClassLoader { *

* If a non-null CodeSource is supplied a ProtectionDomain is * constructed and associated with the class being defined. - *

+ * * @param name the expected name of the class, or {@code null} * if not known, using '.' and not '/' as the separator * and without a trailing ".class" suffix. @@ -149,7 +149,7 @@ public class SecureClassLoader extends ClassLoader { *

* If a non-null CodeSource is supplied a ProtectionDomain is * constructed and associated with the class being defined. - *

+ * * @param name the expected name of the class, or {@code null} * if not known, using '.' and not '/' as the separator * and without a trailing ".class" suffix. @@ -180,7 +180,7 @@ public class SecureClassLoader extends ClassLoader { * This method is invoked by the defineClass method which takes * a CodeSource as an argument when it is constructing the * ProtectionDomain for the class being defined. - *

+ * * @param codesource the codesource. * * @return the permissions granted to the codesource. diff --git a/jdk/src/java.base/share/classes/java/security/UnresolvedPermission.java b/jdk/src/java.base/share/classes/java/security/UnresolvedPermission.java index 98ab2d13f9f..9dff324920e 100644 --- a/jdk/src/java.base/share/classes/java/security/UnresolvedPermission.java +++ b/jdk/src/java.base/share/classes/java/security/UnresolvedPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -310,7 +310,7 @@ implements java.io.Serializable /** * Checks two UnresolvedPermission objects for equality. - * Checks that obj is an UnresolvedPermission, and has + * Checks that {@code obj} is an UnresolvedPermission, and has * the same type (class) name, permission name, actions, and * certificates as this object. * @@ -491,7 +491,7 @@ implements java.io.Serializable /** * Returns a new PermissionCollection object for storing * UnresolvedPermission objects. - *

+ * * @return a new PermissionCollection object suitable for * storing UnresolvedPermissions. */ diff --git a/jdk/src/java.base/share/classes/java/security/cert/Certificate.java b/jdk/src/java.base/share/classes/java/security/cert/Certificate.java index 10544983d2c..6923627ce7b 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/Certificate.java +++ b/jdk/src/java.base/share/classes/java/security/cert/Certificate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ import sun.security.x509.X509CertImpl; * An identity certificate is a binding of a principal to a public key which * is vouched for by another principal. (A principal represents * an entity such as an individual user, a group, or a corporation.) - *

+ *

* This class is an abstraction for certificates that have different * formats but important common uses. For example, different types of * certificates, such as X.509 and PGP, share general certificate @@ -248,9 +248,7 @@ public abstract class Certificate implements java.io.Serializable { * Construct the alternate Certificate class with the Certificate * type and Certificate encoding bytes. * - *

- * - * @param type the standard name of the Certificate type.

+ * @param type the standard name of the Certificate type. * * @param data the Certificate data. */ @@ -262,8 +260,6 @@ public abstract class Certificate implements java.io.Serializable { /** * Resolve the Certificate Object. * - *

- * * @return the resolved Certificate Object * * @throws java.io.ObjectStreamException if the Certificate diff --git a/jdk/src/java.base/share/classes/java/util/Currency.java b/jdk/src/java.base/share/classes/java/util/Currency.java index f5f67b2e58d..1ba8cc93e07 100644 --- a/jdk/src/java.base/share/classes/java/util/Currency.java +++ b/jdk/src/java.base/share/classes/java/util/Currency.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -140,11 +140,11 @@ public final class Currency implements Serializable { // - maps country code to 32-bit int // - 26*26 entries, corresponding to [A-Z]*[A-Z] // - \u007F -> not valid country - // - bits 18-31: unused - // - bits 8-17: numeric code (0 to 1023) - // - bit 7: 1 - special case, bits 0-4 indicate which one + // - bits 20-31: unused + // - bits 10-19: numeric code (0 to 1023) + // - bit 9: 1 - special case, bits 0-4 indicate which one // 0 - simple country, bits 0-4 indicate final char of currency code - // - bits 5-6: fraction digits for simple countries, 0 for special cases + // - bits 5-8: fraction digits for simple countries, 0 for special cases // - bits 0-4: final char for currency code for simple country, or ID of special case // - special case IDs: // - 0: country has no currency @@ -182,32 +182,34 @@ public final class Currency implements Serializable { // number of characters from A to Z private static final int A_TO_Z = ('Z' - 'A') + 1; // entry for invalid country codes - private static final int INVALID_COUNTRY_ENTRY = 0x007F; + private static final int INVALID_COUNTRY_ENTRY = 0x0000007F; // entry for countries without currency - private static final int COUNTRY_WITHOUT_CURRENCY_ENTRY = 0x0080; + private static final int COUNTRY_WITHOUT_CURRENCY_ENTRY = 0x00000200; // mask for simple case country entries - private static final int SIMPLE_CASE_COUNTRY_MASK = 0x0000; + private static final int SIMPLE_CASE_COUNTRY_MASK = 0x00000000; // mask for simple case country entry final character - private static final int SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK = 0x001F; + private static final int SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK = 0x0000001F; // mask for simple case country entry default currency digits - private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK = 0x0060; + private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK = 0x000001E0; // shift count for simple case country entry default currency digits private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT = 5; + // maximum number for simple case country entry default currency digits + private static final int SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS = 9; // mask for special case country entries - private static final int SPECIAL_CASE_COUNTRY_MASK = 0x0080; + private static final int SPECIAL_CASE_COUNTRY_MASK = 0x00000200; // mask for special case country index - private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 0x001F; + private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 0x0000001F; // delta from entry index component in main table to index into special case tables private static final int SPECIAL_CASE_COUNTRY_INDEX_DELTA = 1; // mask for distinguishing simple and special case countries private static final int COUNTRY_TYPE_MASK = SIMPLE_CASE_COUNTRY_MASK | SPECIAL_CASE_COUNTRY_MASK; // mask for the numeric code of the currency - private static final int NUMERIC_CODE_MASK = 0x0003FF00; + private static final int NUMERIC_CODE_MASK = 0x000FFC00; // shift count for the numeric code of the currency - private static final int NUMERIC_CODE_SHIFT = 8; + private static final int NUMERIC_CODE_SHIFT = 10; // Currency data format version - private static final int VALID_FORMAT_VERSION = 1; + private static final int VALID_FORMAT_VERSION = 2; static { AccessController.doPrivileged(new PrivilegedAction() { @@ -261,7 +263,7 @@ public final class Currency implements Serializable { Set keys = props.stringPropertyNames(); Pattern propertiesPattern = Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*" + - "([0-3])\\s*,?\\s*(\\d{4}-\\d{2}-\\d{2}T\\d{2}:" + + "(\\d+)\\s*,?\\s*(\\d{4}-\\d{2}-\\d{2}T\\d{2}:" + "\\d{2}:\\d{2})?"); for (String key : keys) { replaceCurrencyData(propertiesPattern, @@ -682,7 +684,7 @@ public final class Currency implements Serializable { * @param ctry country code * @param curdata currency data. This is a comma separated string that * consists of "three-letter alphabet code", "three-digit numeric code", - * and "one-digit (0,1,2, or 3) default fraction digit". + * and "one-digit (0-9) default fraction digit". * For example, "JPZ,392,0". * An optional UTC date can be appended to the string (comma separated) * to allow a currency change take effect after date specified. @@ -721,8 +723,14 @@ public final class Currency implements Serializable { String code = m.group(1); int numeric = Integer.parseInt(m.group(2)); - int fraction = Integer.parseInt(m.group(3)); int entry = numeric << NUMERIC_CODE_SHIFT; + int fraction = Integer.parseInt(m.group(3)); + if (fraction > SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS) { + info("currency.properties entry for " + ctry + + " ignored since the fraction is more than " + + SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS + ":" + curdata, null); + return; + } int index; for (index = 0; index < scOldCurrencies.length; index++) { diff --git a/jdk/src/java.base/share/classes/java/util/Properties.java b/jdk/src/java.base/share/classes/java/util/Properties.java index e313c9716d0..04397c3f9f2 100644 --- a/jdk/src/java.base/share/classes/java/util/Properties.java +++ b/jdk/src/java.base/share/classes/java/util/Properties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,8 +34,6 @@ import java.io.Reader; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.BufferedWriter; -import java.security.AccessController; -import java.security.PrivilegedAction; import jdk.internal.util.xml.PropertiesDefaultHandler; @@ -311,9 +309,11 @@ class Properties extends Hashtable { * input stream. * @throws IllegalArgumentException if a malformed Unicode escape * appears in the input. + * @throws NullPointerException if {@code reader} is null. * @since 1.6 */ public synchronized void load(Reader reader) throws IOException { + Objects.requireNonNull(reader, "reader parameter is null"); load0(new LineReader(reader)); } @@ -335,9 +335,11 @@ class Properties extends Hashtable { * input stream. * @throws IllegalArgumentException if the input stream contains a * malformed Unicode escape sequence. + * @throws NullPointerException if {@code inStream} is null. * @since 1.2 */ public synchronized void load(InputStream inStream) throws IOException { + Objects.requireNonNull(inStream, "inStream parameter is null"); load0(new LineReader(inStream)); } diff --git a/jdk/src/java.base/share/classes/java/util/regex/Matcher.java b/jdk/src/java.base/share/classes/java/util/regex/Matcher.java index 96cf39a6338..ded7215005d 100644 --- a/jdk/src/java.base/share/classes/java/util/regex/Matcher.java +++ b/jdk/src/java.base/share/classes/java/util/regex/Matcher.java @@ -292,11 +292,13 @@ public final class Matcher implements MatchResult { @Override public int start() { + checkMatch(); return first; } @Override public int start(int group) { + checkMatch(); if (group < 0 || group > groupCount) throw new IndexOutOfBoundsException("No group " + group); return groups[group * 2]; @@ -304,11 +306,13 @@ public final class Matcher implements MatchResult { @Override public int end() { + checkMatch(); return last; } @Override public int end(int group) { + checkMatch(); if (group < 0 || group > groupCount) throw new IndexOutOfBoundsException("No group " + group); return groups[group * 2 + 1]; @@ -321,17 +325,25 @@ public final class Matcher implements MatchResult { @Override public String group() { + checkMatch(); return group(0); } @Override public String group(int group) { + checkMatch(); if (group < 0 || group > groupCount) throw new IndexOutOfBoundsException("No group " + group); if ((groups[group*2] == -1) || (groups[group*2+1] == -1)) return null; return text.subSequence(groups[group * 2], groups[group * 2 + 1]).toString(); } + + private void checkMatch() { + if (first < 0) + throw new IllegalStateException("No match found"); + + } } /** diff --git a/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java b/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java index 3e9cddbd324..eb1d97195e5 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java +++ b/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -447,7 +447,7 @@ abstract class DoublePipeline @Override public final long count() { - return mapToLong(e -> 1L).sum(); + return evaluate(ReduceOps.makeDoubleCounting()); } @Override diff --git a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java index be6cc98aa60..8f272bf4b1d 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java @@ -581,6 +581,24 @@ public interface DoubleStream extends BaseStream { * *

This is a terminal operation. * + * @apiNote + * An implementation may choose to not execute the stream pipeline (either + * sequentially or in parallel) if it is capable of computing the count + * directly from the stream source. In such cases no source elements will + * be traversed and no intermediate operations will be evaluated. + * Behavioral parameters with side-effects, which are strongly discouraged + * except for harmless cases such as debugging, may be affected. For + * example, consider the following stream: + *

{@code
+     *     DoubleStream s = DoubleStream.of(1, 2, 3, 4);
+     *     long count = s.peek(System.out::println).count();
+     * }
+ * The number of elements covered by the stream source is known and the + * intermediate operation, {@code peek}, does not inject into or remove + * elements from the stream (as may be the case for {@code flatMap} or + * {@code filter} operations). Thus the count is 4 and there is no need to + * execute the pipeline and, as a side-effect, print out the elements. + * * @return the count of elements in this stream */ long count(); diff --git a/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java b/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java index 313045f96c7..9c0162f1ce3 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java +++ b/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -427,7 +427,7 @@ abstract class IntPipeline @Override public final long count() { - return mapToLong(e -> 1L).sum(); + return evaluate(ReduceOps.makeIntCounting()); } @Override diff --git a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java index b68084b5d40..4bb1ab5b97e 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java @@ -504,6 +504,24 @@ public interface IntStream extends BaseStream { * *

This is a terminal operation. * + * @apiNote + * An implementation may choose to not execute the stream pipeline (either + * sequentially or in parallel) if it is capable of computing the count + * directly from the stream source. In such cases no source elements will + * be traversed and no intermediate operations will be evaluated. + * Behavioral parameters with side-effects, which are strongly discouraged + * except for harmless cases such as debugging, may be affected. For + * example, consider the following stream: + *

{@code
+     *     IntStream s = IntStream.of(1, 2, 3, 4);
+     *     long count = s.peek(System.out::println).count();
+     * }
+ * The number of elements covered by the stream source is known and the + * intermediate operation, {@code peek}, does not inject into or remove + * elements from the stream (as may be the case for {@code flatMap} or + * {@code filter} operations). Thus the count is 4 and there is no need to + * execute the pipeline and, as a side-effect, print out the elements. + * * @return the count of elements in this stream */ long count(); diff --git a/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java b/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java index fab01a21118..7a84ff997e7 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java +++ b/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -425,7 +425,7 @@ abstract class LongPipeline @Override public final long count() { - return map(e -> 1L).sum(); + return evaluate(ReduceOps.makeLongCounting()); } @Override diff --git a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java index 14d6d0b5eb9..4f9c72bef42 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java @@ -509,6 +509,24 @@ public interface LongStream extends BaseStream { * *

This is a terminal operation. * + * @apiNote + * An implementation may choose to not execute the stream pipeline (either + * sequentially or in parallel) if it is capable of computing the count + * directly from the stream source. In such cases no source elements will + * be traversed and no intermediate operations will be evaluated. + * Behavioral parameters with side-effects, which are strongly discouraged + * except for harmless cases such as debugging, may be affected. For + * example, consider the following stream: + *

{@code
+     *     LongStream s = LongStream.of(1, 2, 3, 4);
+     *     long count = s.peek(System.out::println).count();
+     * }
+ * The number of elements covered by the stream source is known and the + * intermediate operation, {@code peek}, does not inject into or remove + * elements from the stream (as may be the case for {@code flatMap} or + * {@code filter} operations). Thus the count is 4 and there is no need to + * execute the pipeline and, as a side-effect, print out the elements. + * * @return the count of elements in this stream */ long count(); diff --git a/jdk/src/java.base/share/classes/java/util/stream/ReduceOps.java b/jdk/src/java.base/share/classes/java/util/stream/ReduceOps.java index 3a0f81a0f72..e3cf2979f45 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/ReduceOps.java +++ b/jdk/src/java.base/share/classes/java/util/stream/ReduceOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -233,6 +233,40 @@ final class ReduceOps { }; } + /** + * Constructs a {@code TerminalOp} that counts the number of stream + * elements. If the size of the pipeline is known then count is the size + * and there is no need to evaluate the pipeline. If the size of the + * pipeline is non known then count is produced, via reduction, using a + * {@link CountingSink}. + * + * @param the type of the input elements + * @return a {@code TerminalOp} implementing the counting + */ + public static TerminalOp + makeRefCounting() { + return new ReduceOp>(StreamShape.REFERENCE) { + @Override + public CountingSink makeSink() { return new CountingSink.OfRef<>(); } + + @Override + public Long evaluateSequential(PipelineHelper helper, + Spliterator spliterator) { + if (StreamOpFlag.SIZED.isKnown(helper.getStreamAndOpFlags())) + return spliterator.getExactSizeIfKnown(); + return super.evaluateSequential(helper, spliterator); + } + + @Override + public Long evaluateParallel(PipelineHelper helper, + Spliterator spliterator) { + if (StreamOpFlag.SIZED.isKnown(helper.getStreamAndOpFlags())) + return spliterator.getExactSizeIfKnown(); + return super.evaluateParallel(helper, spliterator); + } + }; + } + /** * Constructs a {@code TerminalOp} that implements a functional reduce on * {@code int} values. @@ -369,6 +403,39 @@ final class ReduceOps { }; } + /** + * Constructs a {@code TerminalOp} that counts the number of stream + * elements. If the size of the pipeline is known then count is the size + * and there is no need to evaluate the pipeline. If the size of the + * pipeline is non known then count is produced, via reduction, using a + * {@link CountingSink}. + * + * @return a {@code TerminalOp} implementing the counting + */ + public static TerminalOp + makeIntCounting() { + return new ReduceOp>(StreamShape.INT_VALUE) { + @Override + public CountingSink makeSink() { return new CountingSink.OfInt(); } + + @Override + public Long evaluateSequential(PipelineHelper helper, + Spliterator spliterator) { + if (StreamOpFlag.SIZED.isKnown(helper.getStreamAndOpFlags())) + return spliterator.getExactSizeIfKnown(); + return super.evaluateSequential(helper, spliterator); + } + + @Override + public Long evaluateParallel(PipelineHelper helper, + Spliterator spliterator) { + if (StreamOpFlag.SIZED.isKnown(helper.getStreamAndOpFlags())) + return spliterator.getExactSizeIfKnown(); + return super.evaluateParallel(helper, spliterator); + } + }; + } + /** * Constructs a {@code TerminalOp} that implements a functional reduce on * {@code long} values. @@ -505,6 +572,39 @@ final class ReduceOps { }; } + /** + * Constructs a {@code TerminalOp} that counts the number of stream + * elements. If the size of the pipeline is known then count is the size + * and there is no need to evaluate the pipeline. If the size of the + * pipeline is non known then count is produced, via reduction, using a + * {@link CountingSink}. + * + * @return a {@code TerminalOp} implementing the counting + */ + public static TerminalOp + makeLongCounting() { + return new ReduceOp>(StreamShape.LONG_VALUE) { + @Override + public CountingSink makeSink() { return new CountingSink.OfLong(); } + + @Override + public Long evaluateSequential(PipelineHelper helper, + Spliterator spliterator) { + if (StreamOpFlag.SIZED.isKnown(helper.getStreamAndOpFlags())) + return spliterator.getExactSizeIfKnown(); + return super.evaluateSequential(helper, spliterator); + } + + @Override + public Long evaluateParallel(PipelineHelper helper, + Spliterator spliterator) { + if (StreamOpFlag.SIZED.isKnown(helper.getStreamAndOpFlags())) + return spliterator.getExactSizeIfKnown(); + return super.evaluateParallel(helper, spliterator); + } + }; + } + /** * Constructs a {@code TerminalOp} that implements a functional reduce on * {@code double} values. @@ -641,6 +741,91 @@ final class ReduceOps { }; } + /** + * Constructs a {@code TerminalOp} that counts the number of stream + * elements. If the size of the pipeline is known then count is the size + * and there is no need to evaluate the pipeline. If the size of the + * pipeline is non known then count is produced, via reduction, using a + * {@link CountingSink}. + * + * @return a {@code TerminalOp} implementing the counting + */ + public static TerminalOp + makeDoubleCounting() { + return new ReduceOp>(StreamShape.DOUBLE_VALUE) { + @Override + public CountingSink makeSink() { return new CountingSink.OfDouble(); } + + @Override + public Long evaluateSequential(PipelineHelper helper, + Spliterator spliterator) { + if (StreamOpFlag.SIZED.isKnown(helper.getStreamAndOpFlags())) + return spliterator.getExactSizeIfKnown(); + return super.evaluateSequential(helper, spliterator); + } + + @Override + public Long evaluateParallel(PipelineHelper helper, + Spliterator spliterator) { + if (StreamOpFlag.SIZED.isKnown(helper.getStreamAndOpFlags())) + return spliterator.getExactSizeIfKnown(); + return super.evaluateParallel(helper, spliterator); + } + }; + } + + /** + * A sink that counts elements + */ + static abstract class CountingSink + extends Box + implements AccumulatingSink> { + long count; + + @Override + public void begin(long size) { + count = 0L; + } + + @Override + public Long get() { + return count; + } + + @Override + public void combine(CountingSink other) { + count += other.count; + } + + static final class OfRef extends CountingSink { + @Override + public void accept(T t) { + count++; + } + } + + static final class OfInt extends CountingSink implements Sink.OfInt { + @Override + public void accept(int t) { + count++; + } + } + + static final class OfLong extends CountingSink implements Sink.OfLong { + @Override + public void accept(long t) { + count++; + } + } + + static final class OfDouble extends CountingSink implements Sink.OfDouble { + @Override + public void accept(double t) { + count++; + } + } + } + /** * A type of {@code TerminalSink} that implements an associative reducing * operation on elements of type {@code T} and producing a result of type @@ -652,7 +837,7 @@ final class ReduceOps { */ private interface AccumulatingSink> extends TerminalSink { - public void combine(K other); + void combine(K other); } /** diff --git a/jdk/src/java.base/share/classes/java/util/stream/ReferencePipeline.java b/jdk/src/java.base/share/classes/java/util/stream/ReferencePipeline.java index 8f5da0e55e7..4402997958b 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/ReferencePipeline.java +++ b/jdk/src/java.base/share/classes/java/util/stream/ReferencePipeline.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -523,10 +523,9 @@ abstract class ReferencePipeline @Override public final long count() { - return mapToLong(e -> 1L).sum(); + return evaluate(ReduceOps.makeRefCounting()); } - // /** diff --git a/jdk/src/java.base/share/classes/java/util/stream/Stream.java b/jdk/src/java.base/share/classes/java/util/stream/Stream.java index b5eb2c9f566..e0e26ff385f 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/Stream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/Stream.java @@ -851,6 +851,25 @@ public interface Stream extends BaseStream> { * *

This is a terminal operation. * + * @apiNote + * An implementation may choose to not execute the stream pipeline (either + * sequentially or in parallel) if it is capable of computing the count + * directly from the stream source. In such cases no source elements will + * be traversed and no intermediate operations will be evaluated. + * Behavioral parameters with side-effects, which are strongly discouraged + * except for harmless cases such as debugging, may be affected. For + * example, consider the following stream: + *

{@code
+     *     List l = Arrays.asList("A", "B", "C", "D");
+     *     long count = l.stream().peek(System.out::println).count();
+     * }
+ * The number of elements covered by the stream source, a {@code List}, is + * known and the intermediate operation, {@code peek}, does not inject into + * or remove elements from the stream (as may be the case for + * {@code flatMap} or {@code filter} operations). Thus the count is the + * size of the {@code List} and there is no need to execute the pipeline + * and, as a side-effect, print out the list elements. + * * @return the count of elements in this stream */ long count(); diff --git a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java index 37520a1b5ec..691ce46078f 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java +++ b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -172,7 +172,6 @@ public class CipherInputStream extends FilterInputStream { * -1 is returned. This method blocks until input data * is available, the end of the stream is detected, or an exception * is thrown. - *

* * @return the next byte of data, or -1 if the end of the * stream is reached. diff --git a/jdk/src/java.base/share/classes/javax/crypto/package.html b/jdk/src/java.base/share/classes/javax/crypto/package.html index 15185738e59..c1d46ff528c 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/package.html +++ b/jdk/src/java.base/share/classes/javax/crypto/package.html @@ -1,5 +1,5 @@