diff --git a/.hgtags b/.hgtags
index d6a20f73fdb..b65c43f255c 100644
--- a/.hgtags
+++ b/.hgtags
@@ -313,3 +313,5 @@ ff3fc75f3214ad7e03595be1b0d0f38d887b6f0e jdk9-b66
5b500c93ce4822d47061cd518ff3f72d9d8cb5b5 jdk9-b68
d69c968463f0ae5d0b45de3fc14fe65171b23948 jdk9-b69
43d0179ee9de3bfffae3417f09e07eb6d8efc963 jdk9-b70
+f66c185284727f6e6ffd27e9c45ed2dd9da0a691 jdk9-b71
+61d2d0629b6dbf4c091dc86151ade1b3ef34fffe jdk9-b72
diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index 7dbc36fa276..aace44e73fd 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -313,3 +313,5 @@ f546760134eb861fcfecd4ce611b0040b0d25a6a jdk9-b67
70e4272790b6199e9ca89df2758ff9cb58ec4125 jdk9-b68
1bcfd6b8726582cff5a42dbfc75903e36f9dd4fe jdk9-b69
eed77fcd77711fcdba05f18fc22f37d86efb243c jdk9-b70
+c706ef5ea5da00078dc5e4334660315f7d99c15b jdk9-b71
+8582c35016fb6211b373810b6b172feccf9c483b jdk9-b72
diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh
index 446fadaba6a..68446dae10c 100644
--- a/common/autoconf/generated-configure.sh
+++ b/common/autoconf/generated-configure.sh
@@ -4364,7 +4364,7 @@ VS_SDK_PLATFORM_NAME_2013=
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1434614912
+DATE_WHEN_GENERATED=1435822080
###############################################################################
#
@@ -42961,7 +42961,7 @@ $as_echo "$as_me: WARNING: X11 is not used, so --with-x is ignored" >&2;}
if test "x$x_libraries" = xNONE; then
if test -f "$SYSROOT/usr/X11R6/lib/libX11.so"; then
x_libraries="$SYSROOT/usr/X11R6/lib"
- elif test "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+ elif test -f "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
x_libraries="$SYSROOT/usr/lib64"
elif test -f "$SYSROOT/usr/lib/libX11.so"; then
x_libraries="$SYSROOT/usr/lib"
diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4
index 6e963b280de..6b651132851 100644
--- a/common/autoconf/libraries.m4
+++ b/common/autoconf/libraries.m4
@@ -113,7 +113,7 @@ AC_DEFUN_ONCE([LIB_SETUP_X11],
if test "x$x_libraries" = xNONE; then
if test -f "$SYSROOT/usr/X11R6/lib/libX11.so"; then
x_libraries="$SYSROOT/usr/X11R6/lib"
- elif test "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+ elif test -f "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
x_libraries="$SYSROOT/usr/lib64"
elif test -f "$SYSROOT/usr/lib/libX11.so"; then
x_libraries="$SYSROOT/usr/lib"
diff --git a/common/bin/compare.sh b/common/bin/compare.sh
index 8c7095296bb..ce527af478d 100644
--- a/common/bin/compare.sh
+++ b/common/bin/compare.sh
@@ -1188,28 +1188,11 @@ if [ "$SKIP_DEFAULT" != "true" ]; then
OTHER_JDK="$OTHER/install/jdk"
OTHER_JRE="$OTHER/install/jre"
echo "Selecting install images for compare"
- elif [ -d "$THIS/deploy/jdk" -o -d "$THIS/deploy/images/jdk" ] \
- && [ -d "$OTHER/deploy/jdk" -o -d "$OTHER/deploy/images/jdk" ]; then
- if [ -d "$THIS/deploy/images/jdk" ]; then
- THIS_JDK="$THIS/deploy/images/jdk"
- THIS_JRE="$THIS/deploy/images/jre"
- else
- THIS_JDK="$THIS/deploy/jdk"
- THIS_JRE="$THIS/deploy/jre"
- fi
- if [ -d "$OTHER/deploy/images/jdk" ]; then
- OTHER_JDK="$OTHER/deploy/images/jdk"
- OTHER_JRE="$OTHER/deploy/images/jre"
- else
- OTHER_JDK="$OTHER/deploy/jdk"
- OTHER_JRE="$OTHER/deploy/jre"
- fi
- echo "Selecting deploy images for compare"
- elif [ -d "$THIS/deploy/images/jdk" ] && [ -d "$OTHER/deploy/jdk" ]; then
- THIS_JDK="$THIS/deploy/jdk"
- THIS_JRE="$THIS/deploy/jre"
- OTHER_JDK="$OTHER/deploy/jdk"
- OTHER_JRE="$OTHER/deploy/jre"
+ elif [ -d "$THIS/images/jdk" ] && [ -d "$OTHER/deploy/images/jdk" ]; then
+ THIS_JDK="$THIS/images/jdk"
+ THIS_JRE="$THIS/images/jre"
+ OTHER_JDK="$OTHER/deploy/images/jdk"
+ OTHER_JRE="$OTHER/deploy/images/jre"
echo "Selecting deploy images for compare"
elif [ -d "$THIS/images/jdk" ] && [ -d "$OTHER/images/jdk" ]; then
THIS_JDK="$THIS/images/jdk"
@@ -1221,30 +1204,28 @@ if [ "$SKIP_DEFAULT" != "true" ]; then
echo "No common images found."
exit 1
fi
+ echo " $THIS_JDK"
+ echo " $OTHER_JDK"
- if [ -d "$THIS/deploy/jdk-bundle" -o -d "$THIS/deploy/images/jdk-bundle" ] \
- && [ -d "$OTHER/deploy/jdk-bundle" -o -d "$OTHER/deploy/images/jdk-bundle" ]; then
+ if [ -d "$THIS/images/jdk-bundle" -o -d "$THIS/deploy/images/jdk-bundle" ] \
+ && [ -d "$OTHER/images/jdk-bundle" -o -d "$OTHER/deploy/images/jdk-bundle" ]; then
if [ -d "$THIS/deploy/images/jdk-bundle" ]; then
THIS_JDK_BUNDLE="$THIS/deploy/images/jdk-bundle"
THIS_JRE_BUNDLE="$THIS/deploy/images/jre-bundle"
else
- THIS_JDK_BUNDLE="$THIS/deploy/jdk-bundle"
- THIS_JRE_BUNDLE="$THIS/deploy/jre-bundle"
+ THIS_JDK_BUNDLE="$THIS/images/jdk-bundle"
+ THIS_JRE_BUNDLE="$THIS/images/jre-bundle"
fi
if [ -d "$OTHER/deploy/images/jdk-bundle" ]; then
OTHER_JDK_BUNDLE="$OTHER/deploy/images/jdk-bundle"
OTHER_JRE_BUNDLE="$OTHER/deploy/images/jre-bundle"
else
- OTHER_JDK_BUNDLE="$OTHER/deploy/jdk-bundle"
- OTHER_JRE_BUNDLE="$OTHER/deploy/jre-bundle"
+ OTHER_JDK_BUNDLE="$OTHER/images/jdk-bundle"
+ OTHER_JRE_BUNDLE="$OTHER/images/jre-bundle"
fi
- echo "Also comparing deploy macosx bundles"
- elif [ -d "$THIS/images/jdk-bundle" ] && [ -d "$OTHER/images/jdk-bundle" ]; then
- THIS_JDK_BUNDLE="$THIS/images/jdk-bundle"
- THIS_JRE_BUNDLE="$THIS/images/jre-bundle"
- OTHER_JDK_BUNDLE="$OTHER/images/jdk-bundle"
- OTHER_JRE_BUNDLE="$OTHER/images/jre-bundle"
echo "Also comparing macosx bundles"
+ echo " $THIS_JDK_BUNDLE"
+ echo " $OTHER_JDK_BUNDLE"
fi
if [ -d "$THIS/deploy/bundles" -o -d "$THIS/deploy/images/bundles" ] \
@@ -1262,19 +1243,21 @@ if [ "$SKIP_DEFAULT" != "true" ]; then
echo "Also comparing deploy javadoc bundles"
fi
- if [ -d "$THIS/deploy/JavaAppletPlugin.plugin" -o -d "$THIS/deploy/images/JavaAppletPlugin.plugin" ] \
- && [ -d "$OTHER/deploy/JavaAppletPlugin.plugin" -o -d "$OTHER/deploy/images/JavaAppletPlugin.plugin" ]; then
- if [ -d "$THIS/deploy/images/bundles" ]; then
+ if [ -d "$THIS/images/JavaAppletPlugin.plugin" ] \
+ && [ -d "$OTHER/images/JavaAppletPlugin.plugin" -o -d "$OTHER/deploy/images/JavaAppletPlugin.plugin" ]; then
+ if [ -d "$THIS/images/JavaAppletPlugin.plugin" ]; then
+ THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/images/JavaAppletPlugin.plugin"
+ else
THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/deploy/images/JavaAppletPlugin.plugin"
- else
- THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/deploy/JavaAppletPlugin.plugin"
fi
- if [ -d "$OTHER/deploy/images/bundles" ]; then
- OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/deploy/images/JavaAppletPlugin.plugin"
+ if [ -d "$OTHER/images/JavaAppletPlugin.plugin" ]; then
+ OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/images/JavaAppletPlugin.plugin"
else
- OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/deploy/JavaAppletPlugin.plugin"
+ OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/deploy/images/JavaAppletPlugin.plugin"
fi
echo "Also comparing deploy applet image"
+ echo " $THIS_DEPLOY_APPLET_PLUGIN_DIR"
+ echo " $OTHER_DEPLOY_APPLET_PLUGIN_DIR"
fi
if [ -d "$OTHER/images" ]; then
diff --git a/corba/.hgtags b/corba/.hgtags
index a2d2d57f9c1..e323b55a76c 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -313,3 +313,5 @@ afc1e295c4bf83f9a5dd539c29914edd4a754a3f jdk9-b65
8efad64f40eb8cd4df376c0a5275892eeb396bbd jdk9-b68
de8acedcb5b5870f1dc54cba575aaa5d33897ea2 jdk9-b69
e7cf01990ed366bd493080663259281e91ce223b jdk9-b70
+cd39ed501fb0504554a7f58ac6cf3dd2b64afec0 jdk9-b71
+f9f3706bd24c42c07cb260fe05730a749b8e52f4 jdk9-b72
diff --git a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java
index 185f40cf012..5e6bba759e3 100644
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java
@@ -65,7 +65,7 @@ import org.omg.CORBA.ValueMember;
import sun.corba.Bridge;
/**
- * A ObjectStreamClass describes a class that can be serialized to a stream
+ * An ObjectStreamClass describes a class that can be serialized to a stream
* or a class that was serialized to a stream. It contains the name
* and the serialVersionUID of the class.
*
@@ -788,9 +788,9 @@ public class ObjectStreamClass implements java.io.Serializable {
/* Compare the base class names of streamName and localName.
*
* @return Return true iff the base class name compare.
- * @parameter streamName Fully qualified class name.
- * @parameter localName Fully qualified class name.
- * @parameter pkgSeparator class names use either '.' or '/'.
+ * @param streamName Fully qualified class name.
+ * @param localName Fully qualified class name.
+ * @param pkgSeparator class names use either '.' or '/'.
*
* Only compare base class name to allow package renaming.
*/
diff --git a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClass_1_3_1.java b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClass_1_3_1.java
index 3e06edc2550..5188975ff76 100644
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClass_1_3_1.java
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClass_1_3_1.java
@@ -656,9 +656,9 @@ public class ObjectStreamClass_1_3_1 implements java.io.Serializable {
/* Compare the base class names of streamName and localName.
*
* @return Return true iff the base class name compare.
- * @parameter streamName Fully qualified class name.
- * @parameter localName Fully qualified class name.
- * @parameter pkgSeparator class names use either '.' or '/'.
+ * @param streamName Fully qualified class name.
+ * @param localName Fully qualified class name.
+ * @param pkgSeparator class names use either '.' or '/'.
*
* Only compare base class name to allow package renaming.
*/
diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/BoundsHelper.java b/corba/src/java.corba/share/classes/org/omg/CORBA/BoundsHelper.java
index 54aae7c1df0..52f2128c51e 100644
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/BoundsHelper.java
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/BoundsHelper.java
@@ -27,10 +27,10 @@ package org.omg.CORBA;
/**
- * This Helper class is used to facilitate the marshalling of Bounds.
+ * This Helper class is used to facilitate the marshalling of {@code Bounds}.
* For more information on Helper files, see
*
- * "Generated Files: Helper Files".
+ * "Generated Files: Helper Files".
*/
abstract public class BoundsHelper
diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/ORBPackage/InvalidNameHelper.java b/corba/src/java.corba/share/classes/org/omg/CORBA/ORBPackage/InvalidNameHelper.java
index 044e2b17eb4..150f6374e80 100644
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/ORBPackage/InvalidNameHelper.java
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/ORBPackage/InvalidNameHelper.java
@@ -28,10 +28,10 @@ package org.omg.CORBA.ORBPackage;
/**
* This Helper class is used to facilitate the marshalling of
- * ORBPackage/InvalidName.
+ * {@code ORBPackage/InvalidName}.
* For more information on Helper files, see
*
- * "Generated Files: Helper Files".
+ * "Generated Files: Helper Files".
*/
abstract public class InvalidNameHelper
diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BadKindHelper.java b/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BadKindHelper.java
index 755935698dd..3db1ad89f54 100644
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BadKindHelper.java
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BadKindHelper.java
@@ -28,10 +28,10 @@ package org.omg.CORBA.TypeCodePackage;
/**
* This Helper class is used to facilitate the marshalling of
- * TypeCodePackage/BadKind.
+ * {@code TypeCodePackage/BadKind}.
* For more information on Helper files, see
*
- * "Generated Files: Helper Files".
+ * "Generated Files: Helper Files".
*/
abstract public class BadKindHelper
diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BoundsHelper.java b/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BoundsHelper.java
index c234c595b17..1a9aeb71e2b 100644
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BoundsHelper.java
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BoundsHelper.java
@@ -28,10 +28,10 @@ package org.omg.CORBA.TypeCodePackage;
/**
* This Helper class is used to facilitate the marshalling of
- * TypeCodePackage/Bounds.
+ * {@code TypeCodePackage/Bounds}.
* For more information on Helper files, see
*
- * "Generated Files: Helper Files".
+ * "Generated Files: Helper Files".
*/
abstract public class BoundsHelper
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index fc4a736f8e4..439df02dbb9 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -473,3 +473,5 @@ d47dfabd16d48eb96a451edd1b61194a39ee0eb5 jdk9-b67
11af3990d56c97b40318bc1f20608e86f051a3f7 jdk9-b68
ff0929a59ced0e144201aa05819ae2e47d6f2c61 jdk9-b69
8672e9264db30c21504063932dbc374eabc287a1 jdk9-b70
+07c6b035d68b0c41b1dcd442157b50b41a2551e9 jdk9-b71
+c1b2825ef47e75cb34dd18450d1c4280b7c5853c jdk9-b72
diff --git a/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp
index 85752e738c2..26d3c46e72b 100644
--- a/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp
@@ -2270,17 +2270,21 @@ public:
}
// CRC32 instructions
-#define INSN(NAME, sf, sz) \
+#define INSN(NAME, c, sf, sz) \
void NAME(Register Rd, Register Rn, Register Rm) { \
starti; \
- f(sf, 31), f(0b0011010110, 30, 21), f(0b0100, 15, 12), f(sz, 11, 10); \
- rf(Rm, 16), rf(Rn, 5), rf(Rd, 0); \
+ f(sf, 31), f(0b0011010110, 30, 21), f(0b010, 15, 13), f(c, 12); \
+ f(sz, 11, 10), rf(Rm, 16), rf(Rn, 5), rf(Rd, 0); \
}
- INSN(crc32b, 0, 0b00);
- INSN(crc32h, 0, 0b01);
- INSN(crc32w, 0, 0b10);
- INSN(crc32x, 1, 0b11);
+ INSN(crc32b, 0, 0, 0b00);
+ INSN(crc32h, 0, 0, 0b01);
+ INSN(crc32w, 0, 0, 0b10);
+ INSN(crc32x, 0, 1, 0b11);
+ INSN(crc32cb, 1, 0, 0b00);
+ INSN(crc32ch, 1, 0, 0b01);
+ INSN(crc32cw, 1, 0, 0b10);
+ INSN(crc32cx, 1, 1, 0b11);
#undef INSN
diff --git a/hotspot/src/cpu/aarch64/vm/globalDefinitions_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/globalDefinitions_aarch64.hpp
index 7ec6bf58f65..d392ccf5e48 100644
--- a/hotspot/src/cpu/aarch64/vm/globalDefinitions_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/globalDefinitions_aarch64.hpp
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014, Red Hat Inc. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
* 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,12 +28,6 @@
const int StackAlignmentInBytes = 16;
-// Indicates whether the C calling conventions require that
-// 32-bit integer argument values are properly extended to 64 bits.
-// If set, SharedRuntime::c_calling_convention() must adapt
-// signatures accordingly.
-const bool CCallingConventionRequiresIntsAsLongs = true;
-
#define SUPPORTS_NATIVE_CX8
// The maximum B/BL offset range on AArch64 is 128MB.
diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
index 61283353b35..b47d57f1cdb 100644
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
@@ -2914,6 +2914,65 @@ void MacroAssembler::kernel_crc32(Register crc, Register buf, Register len,
ornw(crc, zr, crc);
}
+/**
+ * @param crc register containing existing CRC (32-bit)
+ * @param buf register pointing to input byte buffer (byte*)
+ * @param len register containing number of bytes
+ * @param table register that will contain address of CRC table
+ * @param tmp scratch register
+ */
+void MacroAssembler::kernel_crc32c(Register crc, Register buf, Register len,
+ Register table0, Register table1, Register table2, Register table3,
+ Register tmp, Register tmp2, Register tmp3) {
+ Label L_exit;
+ Label CRC_by64_loop, CRC_by4_loop, CRC_by1_loop;
+
+ subs(len, len, 64);
+ br(Assembler::GE, CRC_by64_loop);
+ adds(len, len, 64-4);
+ br(Assembler::GE, CRC_by4_loop);
+ adds(len, len, 4);
+ br(Assembler::GT, CRC_by1_loop);
+ b(L_exit);
+
+ BIND(CRC_by4_loop);
+ ldrw(tmp, Address(post(buf, 4)));
+ subs(len, len, 4);
+ crc32cw(crc, crc, tmp);
+ br(Assembler::GE, CRC_by4_loop);
+ adds(len, len, 4);
+ br(Assembler::LE, L_exit);
+ BIND(CRC_by1_loop);
+ ldrb(tmp, Address(post(buf, 1)));
+ subs(len, len, 1);
+ crc32cb(crc, crc, tmp);
+ br(Assembler::GT, CRC_by1_loop);
+ b(L_exit);
+
+ align(CodeEntryAlignment);
+ BIND(CRC_by64_loop);
+ subs(len, len, 64);
+ ldp(tmp, tmp3, Address(post(buf, 16)));
+ crc32cx(crc, crc, tmp);
+ crc32cx(crc, crc, tmp3);
+ ldp(tmp, tmp3, Address(post(buf, 16)));
+ crc32cx(crc, crc, tmp);
+ crc32cx(crc, crc, tmp3);
+ ldp(tmp, tmp3, Address(post(buf, 16)));
+ crc32cx(crc, crc, tmp);
+ crc32cx(crc, crc, tmp3);
+ ldp(tmp, tmp3, Address(post(buf, 16)));
+ crc32cx(crc, crc, tmp);
+ crc32cx(crc, crc, tmp3);
+ br(Assembler::GE, CRC_by64_loop);
+ adds(len, len, 64-4);
+ br(Assembler::GE, CRC_by4_loop);
+ adds(len, len, 4);
+ br(Assembler::GT, CRC_by1_loop);
+ BIND(L_exit);
+ return;
+}
+
SkipIfEqual::SkipIfEqual(
MacroAssembler* masm, const bool* flag_addr, bool value) {
_masm = masm;
diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
index 8a8c58e3955..b3544ee625d 100644
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
@@ -967,6 +967,10 @@ public:
void kernel_crc32(Register crc, Register buf, Register len,
Register table0, Register table1, Register table2, Register table3,
Register tmp, Register tmp2, Register tmp3);
+ // CRC32 code for java.util.zip.CRC32C::updateBytes() instrinsic.
+ void kernel_crc32c(Register crc, Register buf, Register len,
+ Register table0, Register table1, Register table2, Register table3,
+ Register tmp, Register tmp2, Register tmp3);
#undef VIRTUAL
diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
index af461db8b61..a7fcaca9788 100644
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
@@ -2356,6 +2356,47 @@ class StubGenerator: public StubCodeGenerator {
return start;
}
+ /**
+ * Arguments:
+ *
+ * Inputs:
+ * c_rarg0 - int crc
+ * c_rarg1 - byte* buf
+ * c_rarg2 - int length
+ * c_rarg3 - int* table
+ *
+ * Ouput:
+ * rax - int crc result
+ */
+ address generate_updateBytesCRC32C() {
+ assert(UseCRC32CIntrinsics, "what are we doing here?");
+
+ __ align(CodeEntryAlignment);
+ StubCodeMark mark(this, "StubRoutines", "updateBytesCRC32C");
+
+ address start = __ pc();
+
+ const Register crc = c_rarg0; // crc
+ const Register buf = c_rarg1; // source java byte array address
+ const Register len = c_rarg2; // length
+ const Register table0 = c_rarg3; // crc_table address
+ const Register table1 = c_rarg4;
+ const Register table2 = c_rarg5;
+ const Register table3 = c_rarg6;
+ const Register tmp3 = c_rarg7;
+
+ BLOCK_COMMENT("Entry:");
+ __ enter(); // required for proper stackwalking of RuntimeStub frame
+
+ __ kernel_crc32c(crc, buf, len,
+ table0, table1, table2, table3, rscratch1, rscratch2, tmp3);
+
+ __ leave(); // required for proper stackwalking of RuntimeStub frame
+ __ ret(lr);
+
+ return start;
+ }
+
/**
* Arguments:
*
@@ -2579,6 +2620,10 @@ class StubGenerator: public StubCodeGenerator {
StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB");
}
+ if (UseCRC32CIntrinsics) {
+ StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C();
+ }
+
// Safefetch stubs.
generate_safefetch("SafeFetch32", sizeof(int), &StubRoutines::_safefetch32_entry,
&StubRoutines::_safefetch32_fault_pc,
diff --git a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
index cf76c0d1f07..02591e639ed 100644
--- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
@@ -199,9 +199,12 @@ void VM_Version::get_processor_features() {
UseCRC32Intrinsics = true;
}
- if (UseCRC32CIntrinsics) {
- if (!FLAG_IS_DEFAULT(UseCRC32CIntrinsics))
- warning("CRC32C intrinsics are not available on this CPU");
+ if (auxv & HWCAP_CRC32) {
+ if (FLAG_IS_DEFAULT(UseCRC32CIntrinsics)) {
+ FLAG_SET_DEFAULT(UseCRC32CIntrinsics, true);
+ }
+ } else if (UseCRC32CIntrinsics) {
+ warning("CRC32C is not available on the CPU");
FLAG_SET_DEFAULT(UseCRC32CIntrinsics, false);
}
@@ -214,34 +217,31 @@ void VM_Version::get_processor_features() {
FLAG_SET_DEFAULT(UseSHA, false);
}
- if (!UseSHA) {
+ if (UseSHA && (auxv & HWCAP_SHA1)) {
+ if (FLAG_IS_DEFAULT(UseSHA1Intrinsics)) {
+ FLAG_SET_DEFAULT(UseSHA1Intrinsics, true);
+ }
+ } else if (UseSHA1Intrinsics) {
+ warning("Intrinsics for SHA-1 crypto hash functions not available on this CPU.");
FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
- FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
+ }
+
+ if (UseSHA && (auxv & HWCAP_SHA2)) {
+ if (FLAG_IS_DEFAULT(UseSHA256Intrinsics)) {
+ FLAG_SET_DEFAULT(UseSHA256Intrinsics, true);
+ }
+ } else if (UseSHA256Intrinsics) {
+ warning("Intrinsics for SHA-224 and SHA-256 crypto hash functions not available on this CPU.");
+ FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
+ }
+
+ if (UseSHA512Intrinsics) {
+ warning("Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU.");
FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
- } else {
- if (auxv & HWCAP_SHA1) {
- if (FLAG_IS_DEFAULT(UseSHA1Intrinsics)) {
- FLAG_SET_DEFAULT(UseSHA1Intrinsics, true);
- }
- } else if (UseSHA1Intrinsics) {
- warning("SHA1 instruction is not available on this CPU.");
- FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
- }
- if (auxv & HWCAP_SHA2) {
- if (FLAG_IS_DEFAULT(UseSHA256Intrinsics)) {
- FLAG_SET_DEFAULT(UseSHA256Intrinsics, true);
- }
- } else if (UseSHA256Intrinsics) {
- warning("SHA256 instruction (for SHA-224 and SHA-256) is not available on this CPU.");
- FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
- }
- if (UseSHA512Intrinsics) {
- warning("SHA512 instruction (for SHA-384 and SHA-512) is not available on this CPU.");
- FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
- }
- if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) {
- FLAG_SET_DEFAULT(UseSHA, false);
- }
+ }
+
+ if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) {
+ FLAG_SET_DEFAULT(UseSHA, false);
}
// This machine allows unaligned memory accesses
diff --git a/hotspot/src/cpu/ppc/vm/globalDefinitions_ppc.hpp b/hotspot/src/cpu/ppc/vm/globalDefinitions_ppc.hpp
index bd8bef477da..da5c8b008c5 100644
--- a/hotspot/src/cpu/ppc/vm/globalDefinitions_ppc.hpp
+++ b/hotspot/src/cpu/ppc/vm/globalDefinitions_ppc.hpp
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012, 2013 SAP AG. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012, 2015 SAP AG. All rights reserved.
* 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,12 +31,6 @@ const int BytesPerInstWord = 4;
const int StackAlignmentInBytes = 16;
-// Indicates whether the C calling conventions require that
-// 32-bit integer argument values are properly extended to 64 bits.
-// If set, SharedRuntime::c_calling_convention() must adapt
-// signatures accordingly.
-const bool CCallingConventionRequiresIntsAsLongs = true;
-
#define SUPPORTS_NATIVE_CX8
// The PPC CPUs are NOT multiple-copy-atomic.
diff --git a/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp b/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp
index 5d8ca9769e9..f3b02e0bf9f 100644
--- a/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp
+++ b/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp
@@ -731,23 +731,8 @@ int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
case T_SHORT:
case T_INT:
// We must cast ints to longs and use full 64 bit stack slots
- // here. We do the cast in GraphKit::gen_stub() and just guard
- // here against loosing that change.
- assert(CCallingConventionRequiresIntsAsLongs,
- "argument of type int should be promoted to type long");
- guarantee(i > 0 && sig_bt[i-1] == T_LONG,
- "argument of type (bt) should have been promoted to type (T_LONG,bt) for bt in "
- "{T_BOOLEAN, T_CHAR, T_BYTE, T_SHORT, T_INT}");
- // Do not count halves.
- regs[i].set_bad();
- --arg;
- break;
+ // here. Thus fall through, handle as long.
case T_LONG:
- guarantee(sig_bt[i+1] == T_VOID ||
- sig_bt[i+1] == T_BOOLEAN || sig_bt[i+1] == T_CHAR ||
- sig_bt[i+1] == T_BYTE || sig_bt[i+1] == T_SHORT ||
- sig_bt[i+1] == T_INT,
- "expecting type (T_LONG,half) or type (T_LONG,bt) with bt in {T_BOOLEAN, T_CHAR, T_BYTE, T_SHORT, T_INT}");
case T_OBJECT:
case T_ARRAY:
case T_ADDRESS:
@@ -1273,7 +1258,7 @@ static void object_move(MacroAssembler* masm,
static void int_move(MacroAssembler*masm,
VMRegPair src, VMRegPair dst,
Register r_caller_sp, Register r_temp) {
- assert(src.first()->is_valid() && src.second() == src.first()->next(), "incoming must be long-int");
+ assert(src.first()->is_valid(), "incoming must be int");
assert(dst.first()->is_valid() && dst.second() == dst.first()->next(), "outgoing must be long");
if (src.first()->is_stack()) {
@@ -1762,13 +1747,6 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
// the jni function will expect them. To figure out where they go
// we convert the java signature to a C signature by inserting
// the hidden arguments as arg[0] and possibly arg[1] (static method)
- //
- // Additionally, on ppc64 we must convert integers to longs in the C
- // signature. We do this in advance in order to have no trouble with
- // indexes into the bt-arrays.
- // So convert the signature and registers now, and adjust the total number
- // of in-arguments accordingly.
- int i2l_argcnt = convert_ints_to_longints_argcnt(total_in_args, in_sig_bt); // PPC64: pass ints as longs.
// Calculate the total number of C arguments and create arrays for the
// signature and the outgoing registers.
@@ -1776,7 +1754,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
// some floating-point arguments must be passed in registers _and_
// in stack locations.
bool method_is_static = method->is_static();
- int total_c_args = i2l_argcnt;
+ int total_c_args = total_in_args;
if (!is_critical_native) {
int n_hidden_args = method_is_static ? 2 : 1;
@@ -1785,7 +1763,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
// No JNIEnv*, no this*, but unpacked arrays (base+length).
for (int i = 0; i < total_in_args; i++) {
if (in_sig_bt[i] == T_ARRAY) {
- total_c_args += 2; // PPC64: T_LONG, T_INT, T_ADDRESS (see convert_ints_to_longints and c_calling_convention)
+ total_c_args++;
}
}
}
@@ -1803,8 +1781,6 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
int argc = 0;
if (!is_critical_native) {
- convert_ints_to_longints(i2l_argcnt, total_in_args, in_sig_bt, in_regs); // PPC64: pass ints as longs.
-
out_sig_bt[argc++] = T_ADDRESS;
if (method->is_static()) {
out_sig_bt[argc++] = T_OBJECT;
@@ -1815,7 +1791,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
}
} else {
Thread* THREAD = Thread::current();
- in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, i2l_argcnt);
+ in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
SignatureStream ss(method->signature());
int o = 0;
for (int i = 0; i < total_in_args ; i++, o++) {
@@ -1839,28 +1815,16 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
}
} else {
in_elem_bt[o] = T_VOID;
- switch(in_sig_bt[i]) { // PPC64: pass ints as longs.
- case T_BOOLEAN:
- case T_CHAR:
- case T_BYTE:
- case T_SHORT:
- case T_INT: in_elem_bt[++o] = T_VOID; break;
- default: break;
- }
}
if (in_sig_bt[i] != T_VOID) {
assert(in_sig_bt[i] == ss.type(), "must match");
ss.next();
}
}
- assert(i2l_argcnt==o, "must match");
-
- convert_ints_to_longints(i2l_argcnt, total_in_args, in_sig_bt, in_regs); // PPC64: pass ints as longs.
for (int i = 0; i < total_in_args ; i++ ) {
if (in_sig_bt[i] == T_ARRAY) {
// Arrays are passed as int, elem* pair.
- out_sig_bt[argc++] = T_LONG; // PPC64: pass ints as longs.
out_sig_bt[argc++] = T_INT;
out_sig_bt[argc++] = T_ADDRESS;
} else {
@@ -1921,7 +1885,8 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
case T_BYTE:
case T_SHORT:
case T_CHAR:
- case T_INT: /*single_slots++;*/ break; // PPC64: pass ints as longs.
+ case T_INT:
+ // Fall through.
case T_ARRAY:
case T_LONG: double_slots++; break;
default: ShouldNotReachHere();
@@ -2019,7 +1984,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
__ save_LR_CR(r_temp_1);
__ generate_stack_overflow_check(frame_size_in_bytes); // Check before creating frame.
- __ mr(r_callers_sp, R1_SP); // Remember frame pointer.
+ __ mr(r_callers_sp, R1_SP); // Remember frame pointer.
__ push_frame(frame_size_in_bytes, r_temp_1); // Push the c2n adapter's frame.
frame_done_pc = (intptr_t)__ pc();
@@ -2098,24 +2063,16 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
case T_BYTE:
case T_SHORT:
case T_INT:
- guarantee(in > 0 && in_sig_bt[in-1] == T_LONG,
- "expecting type (T_LONG,bt) for bt in {T_BOOLEAN, T_CHAR, T_BYTE, T_SHORT, T_INT}");
+ // Move int and do sign extension.
+ int_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
break;
case T_LONG:
- if (in_sig_bt[in+1] == T_VOID) {
- long_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
- } else {
- guarantee(in_sig_bt[in+1] == T_BOOLEAN || in_sig_bt[in+1] == T_CHAR ||
- in_sig_bt[in+1] == T_BYTE || in_sig_bt[in+1] == T_SHORT ||
- in_sig_bt[in+1] == T_INT,
- "expecting type (T_LONG,bt) for bt in {T_BOOLEAN, T_CHAR, T_BYTE, T_SHORT, T_INT}");
- int_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
- }
+ long_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
break;
case T_ARRAY:
if (is_critical_native) {
int body_arg = out;
- out -= 2; // Point to length arg. PPC64: pass ints as longs.
+ out -= 1; // Point to length arg.
unpack_array_argument(masm, in_regs[in], in_elem_bt[in], out_regs[body_arg], out_regs[out],
r_callers_sp, r_temp_1, r_temp_2);
break;
@@ -2187,7 +2144,6 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
// Make sure that thread is non-volatile; it crosses a bunch of VM calls below.
assert(R16_thread->is_nonvolatile(), "thread must be in non-volatile register");
-
# if 0
// DTrace method entry
# endif
diff --git a/hotspot/src/cpu/sparc/vm/globalDefinitions_sparc.hpp b/hotspot/src/cpu/sparc/vm/globalDefinitions_sparc.hpp
index a63c64658a5..93432223e8d 100644
--- a/hotspot/src/cpu/sparc/vm/globalDefinitions_sparc.hpp
+++ b/hotspot/src/cpu/sparc/vm/globalDefinitions_sparc.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,12 +30,6 @@ const int BytesPerInstWord = 4;
const int StackAlignmentInBytes = (2*wordSize);
-// Indicates whether the C calling conventions require that
-// 32-bit integer argument values are properly extended to 64 bits.
-// If set, SharedRuntime::c_calling_convention() must adapt
-// signatures accordingly.
-const bool CCallingConventionRequiresIntsAsLongs = false;
-
#define SUPPORTS_NATIVE_CX8
// The expected size in bytes of a cache line, used to pad data structures.
diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
index 441b9e4eff6..163a12acaa9 100644
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
@@ -329,39 +329,35 @@ void VM_Version::initialize() {
FLAG_SET_DEFAULT(UseSHA, false);
}
- if (!UseSHA) {
+ if (UseSHA && has_sha1()) {
+ if (FLAG_IS_DEFAULT(UseSHA1Intrinsics)) {
+ FLAG_SET_DEFAULT(UseSHA1Intrinsics, true);
+ }
+ } else if (UseSHA1Intrinsics) {
+ warning("Intrinsics for SHA-1 crypto hash functions not available on this CPU.");
FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
- FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
- FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
- } else {
- if (has_sha1()) {
- if (FLAG_IS_DEFAULT(UseSHA1Intrinsics)) {
- FLAG_SET_DEFAULT(UseSHA1Intrinsics, true);
- }
- } else if (UseSHA1Intrinsics) {
- warning("SHA1 instruction is not available on this CPU.");
- FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
- }
- if (has_sha256()) {
- if (FLAG_IS_DEFAULT(UseSHA256Intrinsics)) {
- FLAG_SET_DEFAULT(UseSHA256Intrinsics, true);
- }
- } else if (UseSHA256Intrinsics) {
- warning("SHA256 instruction (for SHA-224 and SHA-256) is not available on this CPU.");
- FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
- }
+ }
- if (has_sha512()) {
- if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) {
- FLAG_SET_DEFAULT(UseSHA512Intrinsics, true);
- }
- } else if (UseSHA512Intrinsics) {
- warning("SHA512 instruction (for SHA-384 and SHA-512) is not available on this CPU.");
- FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
+ if (UseSHA && has_sha256()) {
+ if (FLAG_IS_DEFAULT(UseSHA256Intrinsics)) {
+ FLAG_SET_DEFAULT(UseSHA256Intrinsics, true);
}
- if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) {
- FLAG_SET_DEFAULT(UseSHA, false);
+ } else if (UseSHA256Intrinsics) {
+ warning("Intrinsics for SHA-224 and SHA-256 crypto hash functions not available on this CPU.");
+ FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
+ }
+
+ if (UseSHA && has_sha512()) {
+ if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) {
+ FLAG_SET_DEFAULT(UseSHA512Intrinsics, true);
}
+ } else if (UseSHA512Intrinsics) {
+ warning("Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU.");
+ FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
+ }
+
+ if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) {
+ FLAG_SET_DEFAULT(UseSHA, false);
}
// SPARC T4 and above should have support for CRC32C instruction
diff --git a/hotspot/src/cpu/x86/vm/globalDefinitions_x86.hpp b/hotspot/src/cpu/x86/vm/globalDefinitions_x86.hpp
index 758593ab77d..8ddbdf82ca4 100644
--- a/hotspot/src/cpu/x86/vm/globalDefinitions_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/globalDefinitions_x86.hpp
@@ -27,12 +27,6 @@
const int StackAlignmentInBytes = 16;
-// Indicates whether the C calling conventions require that
-// 32-bit integer argument values are properly extended to 64 bits.
-// If set, SharedRuntime::c_calling_convention() must adapt
-// signatures accordingly.
-const bool CCallingConventionRequiresIntsAsLongs = false;
-
#define SUPPORTS_NATIVE_CX8
// The expected size in bytes of a cache line, used to pad data structures.
diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
index af84af2a681..d63f1469796 100644
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
@@ -23,6 +23,9 @@
*/
#include "precompiled.hpp"
+#ifndef _WINDOWS
+#include "alloca.h"
+#endif
#include "asm/macroAssembler.hpp"
#include "asm/macroAssembler.inline.hpp"
#include "code/debugInfoRec.hpp"
@@ -3511,6 +3514,250 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha
}
+//------------------------------Montgomery multiplication------------------------
+//
+
+#ifndef _WINDOWS
+
+#define ASM_SUBTRACT
+
+#ifdef ASM_SUBTRACT
+// Subtract 0:b from carry:a. Return carry.
+static unsigned long
+sub(unsigned long a[], unsigned long b[], unsigned long carry, long len) {
+ long i = 0, cnt = len;
+ unsigned long tmp;
+ asm volatile("clc; "
+ "0: ; "
+ "mov (%[b], %[i], 8), %[tmp]; "
+ "sbb %[tmp], (%[a], %[i], 8); "
+ "inc %[i]; dec %[cnt]; "
+ "jne 0b; "
+ "mov %[carry], %[tmp]; sbb $0, %[tmp]; "
+ : [i]"+r"(i), [cnt]"+r"(cnt), [tmp]"=&r"(tmp)
+ : [a]"r"(a), [b]"r"(b), [carry]"r"(carry)
+ : "memory");
+ return tmp;
+}
+#else // ASM_SUBTRACT
+typedef int __attribute__((mode(TI))) int128;
+
+// Subtract 0:b from carry:a. Return carry.
+static unsigned long
+sub(unsigned long a[], unsigned long b[], unsigned long carry, int len) {
+ int128 tmp = 0;
+ int i;
+ for (i = 0; i < len; i++) {
+ tmp += a[i];
+ tmp -= b[i];
+ a[i] = tmp;
+ tmp >>= 64;
+ assert(-1 <= tmp && tmp <= 0, "invariant");
+ }
+ return tmp + carry;
+}
+#endif // ! ASM_SUBTRACT
+
+// Multiply (unsigned) Long A by Long B, accumulating the double-
+// length result into the accumulator formed of T0, T1, and T2.
+#define MACC(A, B, T0, T1, T2) \
+do { \
+ unsigned long hi, lo; \
+ __asm__ ("mul %5; add %%rax, %2; adc %%rdx, %3; adc $0, %4" \
+ : "=&d"(hi), "=a"(lo), "+r"(T0), "+r"(T1), "+g"(T2) \
+ : "r"(A), "a"(B) : "cc"); \
+ } while(0)
+
+// As above, but add twice the double-length result into the
+// accumulator.
+#define MACC2(A, B, T0, T1, T2) \
+do { \
+ unsigned long hi, lo; \
+ __asm__ ("mul %5; add %%rax, %2; adc %%rdx, %3; adc $0, %4; " \
+ "add %%rax, %2; adc %%rdx, %3; adc $0, %4" \
+ : "=&d"(hi), "=a"(lo), "+r"(T0), "+r"(T1), "+g"(T2) \
+ : "r"(A), "a"(B) : "cc"); \
+ } while(0)
+
+// Fast Montgomery multiplication. The derivation of the algorithm is
+// in A Cryptographic Library for the Motorola DSP56000,
+// Dusse and Kaliski, Proc. EUROCRYPT 90, pp. 230-237.
+
+static void __attribute__((noinline))
+montgomery_multiply(unsigned long a[], unsigned long b[], unsigned long n[],
+ unsigned long m[], unsigned long inv, int len) {
+ unsigned long t0 = 0, t1 = 0, t2 = 0; // Triple-precision accumulator
+ int i;
+
+ assert(inv * n[0] == -1UL, "broken inverse in Montgomery multiply");
+
+ for (i = 0; i < len; i++) {
+ int j;
+ for (j = 0; j < i; j++) {
+ MACC(a[j], b[i-j], t0, t1, t2);
+ MACC(m[j], n[i-j], t0, t1, t2);
+ }
+ MACC(a[i], b[0], t0, t1, t2);
+ m[i] = t0 * inv;
+ MACC(m[i], n[0], t0, t1, t2);
+
+ assert(t0 == 0, "broken Montgomery multiply");
+
+ t0 = t1; t1 = t2; t2 = 0;
+ }
+
+ for (i = len; i < 2*len; i++) {
+ int j;
+ for (j = i-len+1; j < len; j++) {
+ MACC(a[j], b[i-j], t0, t1, t2);
+ MACC(m[j], n[i-j], t0, t1, t2);
+ }
+ m[i-len] = t0;
+ t0 = t1; t1 = t2; t2 = 0;
+ }
+
+ while (t0)
+ t0 = sub(m, n, t0, len);
+}
+
+// Fast Montgomery squaring. This uses asymptotically 25% fewer
+// multiplies so it should be up to 25% faster than Montgomery
+// multiplication. However, its loop control is more complex and it
+// may actually run slower on some machines.
+
+static void __attribute__((noinline))
+montgomery_square(unsigned long a[], unsigned long n[],
+ unsigned long m[], unsigned long inv, int len) {
+ unsigned long t0 = 0, t1 = 0, t2 = 0; // Triple-precision accumulator
+ int i;
+
+ assert(inv * n[0] == -1UL, "broken inverse in Montgomery multiply");
+
+ for (i = 0; i < len; i++) {
+ int j;
+ int end = (i+1)/2;
+ for (j = 0; j < end; j++) {
+ MACC2(a[j], a[i-j], t0, t1, t2);
+ MACC(m[j], n[i-j], t0, t1, t2);
+ }
+ if ((i & 1) == 0) {
+ MACC(a[j], a[j], t0, t1, t2);
+ }
+ for (; j < i; j++) {
+ MACC(m[j], n[i-j], t0, t1, t2);
+ }
+ m[i] = t0 * inv;
+ MACC(m[i], n[0], t0, t1, t2);
+
+ assert(t0 == 0, "broken Montgomery square");
+
+ t0 = t1; t1 = t2; t2 = 0;
+ }
+
+ for (i = len; i < 2*len; i++) {
+ int start = i-len+1;
+ int end = start + (len - start)/2;
+ int j;
+ for (j = start; j < end; j++) {
+ MACC2(a[j], a[i-j], t0, t1, t2);
+ MACC(m[j], n[i-j], t0, t1, t2);
+ }
+ if ((i & 1) == 0) {
+ MACC(a[j], a[j], t0, t1, t2);
+ }
+ for (; j < len; j++) {
+ MACC(m[j], n[i-j], t0, t1, t2);
+ }
+ m[i-len] = t0;
+ t0 = t1; t1 = t2; t2 = 0;
+ }
+
+ while (t0)
+ t0 = sub(m, n, t0, len);
+}
+
+// Swap words in a longword.
+static unsigned long swap(unsigned long x) {
+ return (x << 32) | (x >> 32);
+}
+
+// Copy len longwords from s to d, word-swapping as we go. The
+// destination array is reversed.
+static void reverse_words(unsigned long *s, unsigned long *d, int len) {
+ d += len;
+ while(len-- > 0) {
+ d--;
+ *d = swap(*s);
+ s++;
+ }
+}
+
+// The threshold at which squaring is advantageous was determined
+// experimentally on an i7-3930K (Ivy Bridge) CPU @ 3.5GHz.
+#define MONTGOMERY_SQUARING_THRESHOLD 64
+
+void SharedRuntime::montgomery_multiply(jint *a_ints, jint *b_ints, jint *n_ints,
+ jint len, jlong inv,
+ jint *m_ints) {
+ assert(len % 2 == 0, "array length in montgomery_multiply must be even");
+ int longwords = len/2;
+
+ // Make very sure we don't use so much space that the stack might
+ // overflow. 512 jints corresponds to an 16384-bit integer and
+ // will use here a total of 8k bytes of stack space.
+ int total_allocation = longwords * sizeof (unsigned long) * 4;
+ guarantee(total_allocation <= 8192, "must be");
+ unsigned long *scratch = (unsigned long *)alloca(total_allocation);
+
+ // Local scratch arrays
+ unsigned long
+ *a = scratch + 0 * longwords,
+ *b = scratch + 1 * longwords,
+ *n = scratch + 2 * longwords,
+ *m = scratch + 3 * longwords;
+
+ reverse_words((unsigned long *)a_ints, a, longwords);
+ reverse_words((unsigned long *)b_ints, b, longwords);
+ reverse_words((unsigned long *)n_ints, n, longwords);
+
+ ::montgomery_multiply(a, b, n, m, (unsigned long)inv, longwords);
+
+ reverse_words(m, (unsigned long *)m_ints, longwords);
+}
+
+void SharedRuntime::montgomery_square(jint *a_ints, jint *n_ints,
+ jint len, jlong inv,
+ jint *m_ints) {
+ assert(len % 2 == 0, "array length in montgomery_square must be even");
+ int longwords = len/2;
+
+ // Make very sure we don't use so much space that the stack might
+ // overflow. 512 jints corresponds to an 16384-bit integer and
+ // will use here a total of 6k bytes of stack space.
+ int total_allocation = longwords * sizeof (unsigned long) * 3;
+ guarantee(total_allocation <= 8192, "must be");
+ unsigned long *scratch = (unsigned long *)alloca(total_allocation);
+
+ // Local scratch arrays
+ unsigned long
+ *a = scratch + 0 * longwords,
+ *n = scratch + 1 * longwords,
+ *m = scratch + 2 * longwords;
+
+ reverse_words((unsigned long *)a_ints, a, longwords);
+ reverse_words((unsigned long *)n_ints, n, longwords);
+
+ if (len >= MONTGOMERY_SQUARING_THRESHOLD) {
+ ::montgomery_square(a, n, m, (unsigned long)inv, longwords);
+ } else {
+ ::montgomery_multiply(a, a, n, m, (unsigned long)inv, longwords);
+ }
+
+ reverse_words(m, (unsigned long *)m_ints, longwords);
+}
+
+#endif // WINDOWS
+
#ifdef COMPILER2
// This is here instead of runtime_x86_64.cpp because it uses SimpleRuntimeFrame
//
diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp
index dc73f58b7b2..764290e9686 100644
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp
@@ -4318,7 +4318,18 @@ class StubGenerator: public StubCodeGenerator {
if (UseMulAddIntrinsic) {
StubRoutines::_mulAdd = generate_mulAdd();
}
-#endif
+
+#ifndef _WINDOWS
+ if (UseMontgomeryMultiplyIntrinsic) {
+ StubRoutines::_montgomeryMultiply
+ = CAST_FROM_FN_PTR(address, SharedRuntime::montgomery_multiply);
+ }
+ if (UseMontgomerySquareIntrinsic) {
+ StubRoutines::_montgomerySquare
+ = CAST_FROM_FN_PTR(address, SharedRuntime::montgomery_square);
+ }
+#endif // WINDOWS
+#endif // COMPILER2
}
public:
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
index 10a6a0c448d..79e31c0de3b 100644
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
@@ -692,10 +692,19 @@ void VM_Version::get_processor_features() {
warning("SHA instructions are not available on this CPU");
FLAG_SET_DEFAULT(UseSHA, false);
}
- if (UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics) {
- warning("SHA intrinsics are not available on this CPU");
+
+ if (UseSHA1Intrinsics) {
+ warning("Intrinsics for SHA-1 crypto hash functions not available on this CPU.");
FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
+ }
+
+ if (UseSHA256Intrinsics) {
+ warning("Intrinsics for SHA-224 and SHA-256 crypto hash functions not available on this CPU.");
FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
+ }
+
+ if (UseSHA512Intrinsics) {
+ warning("Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU.");
FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
}
@@ -813,6 +822,12 @@ void VM_Version::get_processor_features() {
if (FLAG_IS_DEFAULT(UseMulAddIntrinsic)) {
UseMulAddIntrinsic = true;
}
+ if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) {
+ UseMontgomeryMultiplyIntrinsic = true;
+ }
+ if (FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) {
+ UseMontgomerySquareIntrinsic = true;
+ }
#else
if (UseMultiplyToLenIntrinsic) {
if (!FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) {
@@ -820,6 +835,18 @@ void VM_Version::get_processor_features() {
}
FLAG_SET_DEFAULT(UseMultiplyToLenIntrinsic, false);
}
+ if (UseMontgomeryMultiplyIntrinsic) {
+ if (!FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) {
+ warning("montgomeryMultiply intrinsic is not available in 32-bit VM");
+ }
+ FLAG_SET_DEFAULT(UseMontgomeryMultiplyIntrinsic, false);
+ }
+ if (UseMontgomerySquareIntrinsic) {
+ if (!FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) {
+ warning("montgomerySquare intrinsic is not available in 32-bit VM");
+ }
+ FLAG_SET_DEFAULT(UseMontgomerySquareIntrinsic, false);
+ }
if (UseSquareToLenIntrinsic) {
if (!FLAG_IS_DEFAULT(UseSquareToLenIntrinsic)) {
warning("squareToLen intrinsic is not available in 32-bit VM");
diff --git a/hotspot/src/cpu/zero/vm/globalDefinitions_zero.hpp b/hotspot/src/cpu/zero/vm/globalDefinitions_zero.hpp
index 5777b8ff98f..5956fe1cfcc 100644
--- a/hotspot/src/cpu/zero/vm/globalDefinitions_zero.hpp
+++ b/hotspot/src/cpu/zero/vm/globalDefinitions_zero.hpp
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2009 Red Hat, Inc.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2009, 2015, Red Hat, Inc.
* 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,10 +28,4 @@
#include
-// Indicates whether the C calling conventions require that
-// 32-bit integer argument values are properly extended to 64 bits.
-// If set, SharedRuntime::c_calling_convention() must adapt
-// signatures accordingly.
-const bool CCallingConventionRequiresIntsAsLongs = false;
-
#endif // CPU_ZERO_VM_GLOBALDEFINITIONS_ZERO_HPP
diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
index b7cafd4c618..b7e73a804c6 100644
--- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
@@ -191,7 +191,7 @@ public:
return CPUVisitor::visit(nodeh, state);
}
- PICL(bool is_fujitsu) : _L1_data_cache_line_size(0), _L2_data_cache_line_size(0), _dl_handle(NULL) {
+ PICL(bool is_fujitsu, bool is_sun4v) : _L1_data_cache_line_size(0), _L2_data_cache_line_size(0), _dl_handle(NULL) {
if (!open_library()) {
return;
}
@@ -203,7 +203,7 @@ public:
if (is_fujitsu) {
cpu_class = "core";
}
- CPUVisitor cpu_visitor(this, os::processor_count());
+ CPUVisitor cpu_visitor(this, (is_sun4v && !is_fujitsu) ? 1 : os::processor_count());
_picl_walk_tree_by_class(rooth, cpu_class, &cpu_visitor, PICL_visit_cpu_helper);
if (cpu_visitor.l1_visitor()->is_assigned()) { // Is there a value?
_L1_data_cache_line_size = cpu_visitor.l1_visitor()->value();
@@ -447,7 +447,7 @@ int VM_Version::platform_features(int features) {
}
// Figure out cache line sizes using PICL
- PICL picl((features & sparc64_family_m) != 0);
+ PICL picl((features & sparc64_family_m) != 0, (features & sun4v_m) != 0);
_L1_data_cache_line_size = picl.L1_data_cache_line_size();
_L2_data_cache_line_size = picl.L2_data_cache_line_size();
diff --git a/hotspot/src/share/tools/hsdis/Makefile b/hotspot/src/share/tools/hsdis/Makefile
index 2fb08210ab2..cc8f26a3036 100644
--- a/hotspot/src/share/tools/hsdis/Makefile
+++ b/hotspot/src/share/tools/hsdis/Makefile
@@ -70,7 +70,8 @@ CONFIGURE_ARGS= --host=$(MINGW) --target=$(MINGW)
else #linux
CPU = $(shell uname -m)
ARCH1=$(CPU:x86_64=amd64)
-ARCH=$(ARCH1:i686=i386)
+ARCH2=$(ARCH1:i686=i386)
+ARCH=$(ARCH2:ppc64le=ppc64)
ifdef LP64
CFLAGS/sparcv9 += -m64
CFLAGS/amd64 += -m64
diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
index 9a7c291b886..ec90e425c30 100644
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
@@ -3157,6 +3157,9 @@ GraphBuilder::GraphBuilder(Compilation* compilation, IRScope* scope)
// code for the inlined version will be different than the root
// compiled version which could lead to monotonicity problems on
// intel.
+ if (CheckIntrinsics && !scope->method()->intrinsic_candidate()) {
+ BAILOUT("failed to inline intrinsic, method not annotated");
+ }
// Set up a stream so that appending instructions works properly.
ciBytecodeStream s(scope->method());
@@ -3197,6 +3200,9 @@ GraphBuilder::GraphBuilder(Compilation* compilation, IRScope* scope)
// result in the referent being marked live and the reference
// object removed from the list of discovered references during
// reference processing.
+ if (CheckIntrinsics && !scope->method()->intrinsic_candidate()) {
+ BAILOUT("failed to inline intrinsic, method not annotated");
+ }
// Also we need intrinsic to prevent commoning reads from this field
// across safepoint since GC can change its value.
@@ -3317,7 +3323,8 @@ bool GraphBuilder::try_inline(ciMethod* callee, bool holder_known, Bytecodes::Co
}
// handle intrinsics
- if (callee->intrinsic_id() != vmIntrinsics::_none) {
+ if (callee->intrinsic_id() != vmIntrinsics::_none &&
+ (CheckIntrinsics ? callee->intrinsic_candidate() : true)) {
if (try_inline_intrinsics(callee)) {
print_inlining(callee, "intrinsic");
return true;
@@ -4278,7 +4285,7 @@ void GraphBuilder::append_unsafe_CAS(ciMethod* callee) {
assert(result_type->is_int(), "int result");
Values* args = state()->pop_arguments(callee->arg_size());
- // Pop off some args to speically handle, then push back
+ // Pop off some args to specially handle, then push back
Value newval = args->pop();
Value cmpval = args->pop();
Value offset = args->pop();
diff --git a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp
index a647d8553c9..70c2a596d2c 100644
--- a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp
+++ b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp
@@ -1185,7 +1185,6 @@ vmIntrinsics::ID BCEscapeAnalyzer::known_intrinsic() {
vmIntrinsics::ID iid = method()->intrinsic_id();
if (iid == vmIntrinsics::_getClass ||
- iid == vmIntrinsics::_fillInStackTrace ||
iid == vmIntrinsics::_hashCode)
return iid;
else
@@ -1199,10 +1198,6 @@ bool BCEscapeAnalyzer::compute_escape_for_intrinsic(vmIntrinsics::ID iid) {
case vmIntrinsics::_getClass:
_return_local = false;
break;
- case vmIntrinsics::_fillInStackTrace:
- arg.set(0); // 'this'
- set_returned(arg);
- break;
case vmIntrinsics::_hashCode:
// initialized state is correct
break;
diff --git a/hotspot/src/share/vm/ci/ciMethod.hpp b/hotspot/src/share/vm/ci/ciMethod.hpp
index c394ea29310..7ce61952341 100644
--- a/hotspot/src/share/vm/ci/ciMethod.hpp
+++ b/hotspot/src/share/vm/ci/ciMethod.hpp
@@ -178,9 +178,10 @@ class ciMethod : public ciMetadata {
// Code size for inlining decisions.
int code_size_for_inlining();
- bool caller_sensitive() const { return get_Method()->caller_sensitive(); }
- bool force_inline() const { return get_Method()->force_inline(); }
- bool dont_inline() const { return get_Method()->dont_inline(); }
+ bool caller_sensitive() const { return get_Method()->caller_sensitive(); }
+ bool force_inline() const { return get_Method()->force_inline(); }
+ bool dont_inline() const { return get_Method()->dont_inline(); }
+ bool intrinsic_candidate() const { return get_Method()->intrinsic_candidate(); }
int comp_level();
int highest_osr_comp_level();
diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp
index e60c3a61d90..0d1f3274277 100644
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp
@@ -1751,6 +1751,10 @@ ClassFileParser::AnnotationCollector::annotation_index(ClassLoaderData* loader_d
if (_location != _in_method) break; // only allow for methods
if (!privileged) break; // only allow in privileged code
return _method_LambdaForm_Hidden;
+ case vmSymbols::VM_SYMBOL_ENUM_NAME(jdk_internal_HotSpotIntrinsicCandidate_signature):
+ if (_location != _in_method) break; // only allow for methods
+ if (!privileged) break; // only allow in privileged code
+ return _method_HotSpotIntrinsicCandidate;
case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_Stable_signature):
if (_location != _in_field) break; // only allow for fields
if (!privileged) break; // only allow in privileged code
@@ -1790,6 +1794,8 @@ void ClassFileParser::MethodAnnotationCollector::apply_to(methodHandle m) {
m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm);
if (has_annotation(_method_LambdaForm_Hidden))
m->set_hidden(true);
+ if (has_annotation(_method_HotSpotIntrinsicCandidate) && !m->is_synthetic())
+ m->set_intrinsic_candidate(true);
}
void ClassFileParser::ClassAnnotationCollector::apply_to(instanceKlassHandle k) {
@@ -4131,9 +4137,78 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
// (We used to do this lazily, but now we query it in Rewriter,
// which is eagerly done for every method, so we might as well do it now,
// when everything is fresh in memory.)
- if (Method::klass_id_for_intrinsics(this_klass()) != vmSymbols::NO_SID) {
+ vmSymbols::SID klass_id = Method::klass_id_for_intrinsics(this_klass());
+ if (klass_id != vmSymbols::NO_SID) {
for (int j = 0; j < methods->length(); j++) {
- methods->at(j)->init_intrinsic_id();
+ Method* method = methods->at(j);
+ method->init_intrinsic_id();
+
+ if (CheckIntrinsics) {
+ // Check if an intrinsic is defined for method 'method',
+ // but the method is not annotated with @HotSpotIntrinsicCandidate.
+ if (method->intrinsic_id() != vmIntrinsics::_none &&
+ !method->intrinsic_candidate()) {
+ tty->print("Compiler intrinsic is defined for method [%s], "
+ "but the method is not annotated with @HotSpotIntrinsicCandidate.%s",
+ method->name_and_sig_as_C_string(),
+ NOT_DEBUG(" Method will not be inlined.") DEBUG_ONLY(" Exiting.")
+ );
+ tty->cr();
+ DEBUG_ONLY(vm_exit(1));
+ }
+ // Check is the method 'method' is annotated with @HotSpotIntrinsicCandidate,
+ // but there is no intrinsic available for it.
+ if (method->intrinsic_candidate() &&
+ method->intrinsic_id() == vmIntrinsics::_none) {
+ tty->print("Method [%s] is annotated with @HotSpotIntrinsicCandidate, "
+ "but no compiler intrinsic is defined for the method.%s",
+ method->name_and_sig_as_C_string(),
+ NOT_DEBUG("") DEBUG_ONLY(" Exiting.")
+ );
+ tty->cr();
+ DEBUG_ONLY(vm_exit(1));
+ }
+ }
+ }
+
+ if (CheckIntrinsics) {
+ // Check for orphan methods in the current class. A method m
+ // of a class C is orphan if an intrinsic is defined for method m,
+ // but class C does not declare m.
+
+ for (int id = vmIntrinsics::FIRST_ID; id < (int)vmIntrinsics::ID_LIMIT; id++) {
+ if (id == vmIntrinsics::_compiledLambdaForm) {
+ // The _compiledLamdbdaForm intrinsic is a special marker for bytecode
+ // generated for the JVM from a LambdaForm and therefore no method
+ // is defined for it.
+ continue;
+ }
+
+ if (vmIntrinsics::class_for(vmIntrinsics::ID_from(id)) == klass_id) {
+ // Check if the current class contains a method with the same
+ // name, flags, signature.
+ bool match = false;
+ for (int j = 0; j < methods->length(); j++) {
+ Method* method = methods->at(j);
+ if (id == method->intrinsic_id()) {
+ match = true;
+ break;
+ }
+ }
+
+ if (!match) {
+ char buf[1000];
+ tty->print("Compiler intrinsic is defined for method [%s], "
+ "but the method is not available in class [%s].%s",
+ vmIntrinsics::short_name_as_C_string(vmIntrinsics::ID_from(id), buf, sizeof(buf)),
+ this_klass->name()->as_C_string(),
+ NOT_DEBUG("") DEBUG_ONLY(" Exiting.")
+ );
+ tty->cr();
+ DEBUG_ONLY(vm_exit(1));
+ }
+ }
+ }
}
}
diff --git a/hotspot/src/share/vm/classfile/classFileParser.hpp b/hotspot/src/share/vm/classfile/classFileParser.hpp
index 6d8c180954c..10d331fa641 100644
--- a/hotspot/src/share/vm/classfile/classFileParser.hpp
+++ b/hotspot/src/share/vm/classfile/classFileParser.hpp
@@ -130,6 +130,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC {
_method_InjectedProfile,
_method_LambdaForm_Compiled,
_method_LambdaForm_Hidden,
+ _method_HotSpotIntrinsicCandidate,
_sun_misc_Contended,
_field_Stable,
_annotation_LIMIT
diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp
index a50e6762164..1e4c97bae23 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp
@@ -1707,8 +1707,7 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, methodHandle met
// - rest of the stack
if (!skip_fillInStackTrace_check) {
- if ((method->name() == vmSymbols::fillInStackTrace_name() ||
- method->name() == vmSymbols::fillInStackTrace0_name()) &&
+ if (method->name() == vmSymbols::fillInStackTrace_name() &&
throwable->is_a(method->method_holder())) {
continue;
}
diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp
index 0844489c00f..3da5ef430a7 100644
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp
@@ -258,6 +258,8 @@
/* Type Annotations (JDK 8 and above) */ \
template(type_annotations_name, "typeAnnotations") \
\
+ /* Intrinsic Annotation (JDK 9 and above) */ \
+ template(jdk_internal_HotSpotIntrinsicCandidate_signature, "Ljdk/internal/HotSpotIntrinsicCandidate;") \
\
/* Support for JSR 292 & invokedynamic (JDK 1.7 and above) */ \
template(java_lang_invoke_CallSite, "java/lang/invoke/CallSite") \
@@ -345,7 +347,6 @@
template(dispatch_name, "dispatch") \
template(getSystemClassLoader_name, "getSystemClassLoader") \
template(fillInStackTrace_name, "fillInStackTrace") \
- template(fillInStackTrace0_name, "fillInStackTrace0") \
template(getCause_name, "getCause") \
template(initCause_name, "initCause") \
template(setProperty_name, "setProperty") \
@@ -635,7 +636,43 @@
// The F_xx is one of the Flags enum; see below.
//
// for Emacs: (let ((c-backslash-column 120) (c-backslash-max-column 120)) (c-backslash-region (point) (point-max) nil t))
+//
+//
+// There are two types of intrinsic methods: (1) Library intrinsics and (2) bytecode intrinsics.
+//
+// (1) A library intrinsic method may be replaced with hand-crafted assembly code,
+// with hand-crafted compiler IR, or with a combination of the two. The semantics
+// of the replacement code may differ from the semantics of the replaced code.
+//
+// (2) Bytecode intrinsic methods are not replaced by special code, but they are
+// treated in some other special way by the compiler. For example, the compiler
+// may delay inlining for some String-related intrinsic methods (e.g., some methods
+// defined in the StringBuilder and StringBuffer classes, see
+// Compile::should_delay_string_inlining() for more details).
+//
+// Due to the difference between the semantics of an intrinsic method as defined
+// in the (Java) source code and the semantics of the method as defined
+// by the code in the VM, intrinsic methods must be explicitly marked.
+//
+// Intrinsic methods are marked by the jdk.internal.HotSpotIntrinsicCandidate
+// annotation. If CheckIntrinsics is enabled, the VM performs the following
+// checks when a class C is loaded: (1) all intrinsics defined by the VM for
+// class C are present in the loaded class file and are marked;
+// (2) an intrinsic is defined by the VM for all marked methods of class C.
+//
+// If a mismatch is detected for a method, the VM behaves differently depending
+// on the type of build. A fastdebug build exits and reports an error on a mismatch.
+// A product build will not replace an unmarked library intrinsic method with
+// hand-crafted code, that is, unmarked library intrinsics are treated as ordinary
+// methods in a product build. The special treatment of a bytecode intrinsic method
+// persists even if the method not marked.
+//
+// When adding an intrinsic for a method, please make sure to appropriately
+// annotate the method in the source code. The list below contains all
+// library intrinsics followed by bytecode intrinsics. Please also make sure to
+// add the declaration of the intrinsic to the approriate section of the list.
#define VM_INTRINSICS_DO(do_intrinsic, do_class, do_name, do_signature, do_alias) \
+ /* (1) Library intrinsics */ \
do_intrinsic(_hashCode, java_lang_Object, hashCode_name, void_int_signature, F_R) \
do_name( hashCode_name, "hashCode") \
do_intrinsic(_getClass, java_lang_Object, getClass_name, void_class_signature, F_R) \
@@ -792,12 +829,12 @@
\
do_class(sun_nio_cs_iso8859_1_Encoder, "sun/nio/cs/ISO_8859_1$Encoder") \
do_intrinsic(_encodeISOArray, sun_nio_cs_iso8859_1_Encoder, encodeISOArray_name, encodeISOArray_signature, F_S) \
- do_name( encodeISOArray_name, "encodeISOArray") \
+ do_name( encodeISOArray_name, "implEncodeISOArray") \
do_signature(encodeISOArray_signature, "([CI[BII)I") \
\
do_class(java_math_BigInteger, "java/math/BigInteger") \
- do_intrinsic(_multiplyToLen, java_math_BigInteger, multiplyToLen_name, multiplyToLen_signature, F_R) \
- do_name( multiplyToLen_name, "multiplyToLen") \
+ do_intrinsic(_multiplyToLen, java_math_BigInteger, multiplyToLen_name, multiplyToLen_signature, F_S) \
+ do_name( multiplyToLen_name, "implMultiplyToLen") \
do_signature(multiplyToLen_signature, "([II[II[I)[I") \
\
do_intrinsic(_squareToLen, java_math_BigInteger, squareToLen_name, squareToLen_signature, F_S) \
@@ -808,6 +845,14 @@
do_name( mulAdd_name, "implMulAdd") \
do_signature(mulAdd_signature, "([I[IIII)I") \
\
+ do_intrinsic(_montgomeryMultiply, java_math_BigInteger, montgomeryMultiply_name, montgomeryMultiply_signature, F_S) \
+ do_name( montgomeryMultiply_name, "implMontgomeryMultiply") \
+ do_signature(montgomeryMultiply_signature, "([I[I[IIJ[I)[I") \
+ \
+ do_intrinsic(_montgomerySquare, java_math_BigInteger, montgomerySquare_name, montgomerySquare_signature, F_S) \
+ do_name( montgomerySquare_name, "implMontgomerySquare") \
+ do_signature(montgomerySquare_signature, "([I[IIJ[I)[I") \
+ \
/* java/lang/ref/Reference */ \
do_intrinsic(_Reference_get, java_lang_ref_Reference, get_name, void_object_signature, F_R) \
\
@@ -815,21 +860,21 @@
do_class(com_sun_crypto_provider_aescrypt, "com/sun/crypto/provider/AESCrypt") \
do_intrinsic(_aescrypt_encryptBlock, com_sun_crypto_provider_aescrypt, encryptBlock_name, byteArray_int_byteArray_int_signature, F_R) \
do_intrinsic(_aescrypt_decryptBlock, com_sun_crypto_provider_aescrypt, decryptBlock_name, byteArray_int_byteArray_int_signature, F_R) \
- do_name( encryptBlock_name, "encryptBlock") \
- do_name( decryptBlock_name, "decryptBlock") \
+ do_name( encryptBlock_name, "implEncryptBlock") \
+ do_name( decryptBlock_name, "implDecryptBlock") \
do_signature(byteArray_int_byteArray_int_signature, "([BI[BI)V") \
\
do_class(com_sun_crypto_provider_cipherBlockChaining, "com/sun/crypto/provider/CipherBlockChaining") \
do_intrinsic(_cipherBlockChaining_encryptAESCrypt, com_sun_crypto_provider_cipherBlockChaining, encrypt_name, byteArray_int_int_byteArray_int_signature, F_R) \
do_intrinsic(_cipherBlockChaining_decryptAESCrypt, com_sun_crypto_provider_cipherBlockChaining, decrypt_name, byteArray_int_int_byteArray_int_signature, F_R) \
- do_name( encrypt_name, "encrypt") \
- do_name( decrypt_name, "decrypt") \
+ do_name( encrypt_name, "implEncrypt") \
+ do_name( decrypt_name, "implDecrypt") \
do_signature(byteArray_int_int_byteArray_int_signature, "([BII[BI)I") \
\
/* support for sun.security.provider.SHA */ \
do_class(sun_security_provider_sha, "sun/security/provider/SHA") \
do_intrinsic(_sha_implCompress, sun_security_provider_sha, implCompress_name, implCompress_signature, F_R) \
- do_name( implCompress_name, "implCompress") \
+ do_name( implCompress_name, "implCompress0") \
do_signature(implCompress_signature, "([BI)V") \
\
/* support for sun.security.provider.SHA2 */ \
@@ -843,7 +888,7 @@
/* support for sun.security.provider.DigestBase */ \
do_class(sun_security_provider_digestbase, "sun/security/provider/DigestBase") \
do_intrinsic(_digestBase_implCompressMB, sun_security_provider_digestbase, implCompressMB_name, implCompressMB_signature, F_R) \
- do_name( implCompressMB_name, "implCompressMultiBlock") \
+ do_name( implCompressMB_name, "implCompressMultiBlock0") \
do_signature(implCompressMB_signature, "([BII)I") \
\
/* support for com.sun.crypto.provider.GHASH */ \
@@ -857,17 +902,18 @@
do_intrinsic(_updateCRC32, java_util_zip_CRC32, update_name, int2_int_signature, F_SN) \
do_name( update_name, "update") \
do_intrinsic(_updateBytesCRC32, java_util_zip_CRC32, updateBytes_name, updateBytes_signature, F_SN) \
- do_name( updateBytes_name, "updateBytes") \
+ do_name( updateBytes_name, "updateBytes0") \
do_signature(updateBytes_signature, "(I[BII)I") \
do_intrinsic(_updateByteBufferCRC32, java_util_zip_CRC32, updateByteBuffer_name, updateByteBuffer_signature, F_SN) \
- do_name( updateByteBuffer_name, "updateByteBuffer") \
+ do_name( updateByteBuffer_name, "updateByteBuffer0") \
do_signature(updateByteBuffer_signature, "(IJII)I") \
\
/* support for java.util.zip.CRC32C */ \
do_class(java_util_zip_CRC32C, "java/util/zip/CRC32C") \
- do_intrinsic(_updateBytesCRC32C, java_util_zip_CRC32C, updateBytes_name, updateBytes_signature, F_S) \
- do_intrinsic(_updateDirectByteBufferCRC32C, java_util_zip_CRC32C, updateDirectByteBuffer_name, updateByteBuffer_signature, F_S) \
- do_name( updateDirectByteBuffer_name, "updateDirectByteBuffer") \
+ do_intrinsic(_updateBytesCRC32C, java_util_zip_CRC32C, updateBytes_C_name, updateBytes_signature, F_S) \
+ do_name( updateBytes_C_name, "updateBytes") \
+ do_intrinsic(_updateDirectByteBufferCRC32C, java_util_zip_CRC32C, updateDirectByteBuffer_C_name, updateByteBuffer_signature, F_S) \
+ do_name( updateDirectByteBuffer_C_name, "updateDirectByteBuffer") \
\
/* support for sun.misc.Unsafe */ \
do_class(sun_misc_Unsafe, "sun/misc/Unsafe") \
@@ -878,12 +924,6 @@
do_intrinsic(_copyMemory, sun_misc_Unsafe, copyMemory_name, copyMemory_signature, F_RN) \
do_name( copyMemory_name, "copyMemory") \
do_signature(copyMemory_signature, "(Ljava/lang/Object;JLjava/lang/Object;JJ)V") \
- do_intrinsic(_park, sun_misc_Unsafe, park_name, park_signature, F_RN) \
- do_name( park_name, "park") \
- do_signature(park_signature, "(ZJ)V") \
- do_intrinsic(_unpark, sun_misc_Unsafe, unpark_name, unpark_signature, F_RN) \
- do_name( unpark_name, "unpark") \
- do_alias( unpark_signature, /*(LObject;)V*/ object_void_signature) \
do_intrinsic(_loadFence, sun_misc_Unsafe, loadFence_name, loadFence_signature, F_RN) \
do_name( loadFence_name, "loadFence") \
do_alias( loadFence_signature, void_method_signature) \
@@ -1066,11 +1106,15 @@
do_intrinsic(_getAndSetObject, sun_misc_Unsafe, getAndSetObject_name, getAndSetObject_signature, F_R)\
do_name( getAndSetObject_name, "getAndSetObject") \
do_signature(getAndSetObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;)Ljava/lang/Object;" ) \
- /*== LAST_COMPILER_INLINE*/ \
- /*the compiler does have special inlining code for these; bytecode inline is just fine */ \
\
- do_intrinsic(_fillInStackTrace, java_lang_Throwable, fillInStackTrace_name, void_throwable_signature, F_RNY) \
- \
+ /* (2) Bytecode intrinsics */ \
+ \
+ do_intrinsic(_park, sun_misc_Unsafe, park_name, park_signature, F_RN) \
+ do_name( park_name, "park") \
+ do_signature(park_signature, "(ZJ)V") \
+ do_intrinsic(_unpark, sun_misc_Unsafe, unpark_name, unpark_signature, F_RN) \
+ do_name( unpark_name, "unpark") \
+ do_alias( unpark_signature, /*(LObject;)V*/ object_void_signature) \
do_intrinsic(_StringBuilder_void, java_lang_StringBuilder, object_initializer_name, void_method_signature, F_R) \
do_intrinsic(_StringBuilder_int, java_lang_StringBuilder, object_initializer_name, int_void_signature, F_R) \
do_intrinsic(_StringBuilder_String, java_lang_StringBuilder, object_initializer_name, string_void_signature, F_R) \
diff --git a/hotspot/src/share/vm/interpreter/rewriter.cpp b/hotspot/src/share/vm/interpreter/rewriter.cpp
index 20ddee9a478..01122e7ecf7 100644
--- a/hotspot/src/share/vm/interpreter/rewriter.cpp
+++ b/hotspot/src/share/vm/interpreter/rewriter.cpp
@@ -107,7 +107,7 @@ void Rewriter::make_constant_pool_cache(TRAPS) {
// more complicated solution is required. A special return bytecode
// is used only by Object. to signal the finalization
// registration point. Additionally local 0 must be preserved so it's
-// available to pass to the registration function. For simplicty we
+// available to pass to the registration function. For simplicity we
// require that local 0 is never overwritten so it's available as an
// argument for registration.
diff --git a/hotspot/src/share/vm/oops/method.hpp b/hotspot/src/share/vm/oops/method.hpp
index cf2bc9214b5..8700052a953 100644
--- a/hotspot/src/share/vm/oops/method.hpp
+++ b/hotspot/src/share/vm/oops/method.hpp
@@ -82,7 +82,8 @@ class Method : public Metadata {
_dont_inline = 1 << 3,
_hidden = 1 << 4,
_has_injected_profile = 1 << 5,
- _running_emcp = 1 << 6
+ _running_emcp = 1 << 6,
+ _intrinsic_candidate = 1 << 7
};
u1 _flags;
@@ -815,6 +816,13 @@ class Method : public Metadata {
_flags = x ? (_flags | _hidden) : (_flags & ~_hidden);
}
+ bool intrinsic_candidate() {
+ return (_flags & _intrinsic_candidate) != 0;
+ }
+ void set_intrinsic_candidate(bool x) {
+ _flags = x ? (_flags | _intrinsic_candidate) : (_flags & ~_intrinsic_candidate);
+ }
+
bool has_injected_profile() {
return (_flags & _has_injected_profile) != 0;
}
diff --git a/hotspot/src/share/vm/opto/c2_globals.hpp b/hotspot/src/share/vm/opto/c2_globals.hpp
index 289d9e50880..4c6824cf3f9 100644
--- a/hotspot/src/share/vm/opto/c2_globals.hpp
+++ b/hotspot/src/share/vm/opto/c2_globals.hpp
@@ -688,6 +688,12 @@
product(bool, UseMulAddIntrinsic, false, \
"Enables intrinsification of BigInteger.mulAdd()") \
\
+ product(bool, UseMontgomeryMultiplyIntrinsic, false, \
+ "Enables intrinsification of BigInteger.montgomeryMultiply()") \
+ \
+ product(bool, UseMontgomerySquareIntrinsic, false, \
+ "Enables intrinsification of BigInteger.montgomerySquare()") \
+ \
product(bool, UseTypeSpeculation, true, \
"Speculatively propagate types from profiles") \
\
diff --git a/hotspot/src/share/vm/opto/escape.cpp b/hotspot/src/share/vm/opto/escape.cpp
index 744952a1c10..9bbaf9c1f37 100644
--- a/hotspot/src/share/vm/opto/escape.cpp
+++ b/hotspot/src/share/vm/opto/escape.cpp
@@ -976,8 +976,10 @@ void ConnectionGraph::process_call_arguments(CallNode *call) {
strcmp(call->as_CallLeaf()->_name, "sha512_implCompressMB") == 0 ||
strcmp(call->as_CallLeaf()->_name, "multiplyToLen") == 0 ||
strcmp(call->as_CallLeaf()->_name, "squareToLen") == 0 ||
- strcmp(call->as_CallLeaf()->_name, "mulAdd") == 0)
- ))) {
+ strcmp(call->as_CallLeaf()->_name, "mulAdd") == 0 ||
+ strcmp(call->as_CallLeaf()->_name, "montgomery_multiply") == 0 ||
+ strcmp(call->as_CallLeaf()->_name, "montgomery_square") == 0)
+ ))) {
call->dump();
fatal(err_msg_res("EA unexpected CallLeaf %s", call->as_CallLeaf()->_name));
}
diff --git a/hotspot/src/share/vm/opto/generateOptoStub.cpp b/hotspot/src/share/vm/opto/generateOptoStub.cpp
index 0472f45adeb..5603ffbbd27 100644
--- a/hotspot/src/share/vm/opto/generateOptoStub.cpp
+++ b/hotspot/src/share/vm/opto/generateOptoStub.cpp
@@ -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
@@ -118,19 +118,14 @@ void GraphKit::gen_stub(address C_function,
// The C routines gets the base of thread-local storage passed in as an
// extra argument. Not all calls need it, but its cheap to add here.
for (uint pcnt = cnt; pcnt < parm_cnt; pcnt++, cnt++) {
- // Convert ints to longs if required.
- if (CCallingConventionRequiresIntsAsLongs && jdomain->field_at(pcnt)->isa_int()) {
- fields[cnt++] = TypeLong::LONG;
- fields[cnt] = Type::HALF; // must add an additional half for a long
- } else {
- fields[cnt] = jdomain->field_at(pcnt);
- }
+ fields[cnt] = jdomain->field_at(pcnt);
}
fields[cnt++] = TypeRawPtr::BOTTOM; // Thread-local storage
// Also pass in the caller's PC, if asked for.
- if( return_pc )
+ if (return_pc) {
fields[cnt++] = TypeRawPtr::BOTTOM; // Return PC
+ }
const TypeTuple* domain = TypeTuple::make(cnt,fields);
// The C routine we are about to call cannot return an oop; it can block on
@@ -143,21 +138,22 @@ void GraphKit::gen_stub(address C_function,
const Type **rfields = TypeTuple::fields(jrange->cnt() - TypeFunc::Parms);
// Fixup oop returns
int retval_ptr = retval->isa_oop_ptr();
- if( retval_ptr ) {
+ if (retval_ptr) {
assert( pass_tls, "Oop must be returned thru TLS" );
// Fancy-jumps return address; others return void
rfields[TypeFunc::Parms] = is_fancy_jump ? TypeRawPtr::BOTTOM : Type::TOP;
- } else if( retval->isa_int() ) { // Returning any integer subtype?
+ } else if (retval->isa_int()) { // Returning any integer subtype?
// "Fatten" byte, char & short return types to 'int' to show that
// the native C code can return values with junk high order bits.
// We'll sign-extend it below later.
rfields[TypeFunc::Parms] = TypeInt::INT; // It's "dirty" and needs sign-ext
- } else if( jrange->cnt() >= TypeFunc::Parms+1 ) { // Else copy other types
+ } else if (jrange->cnt() >= TypeFunc::Parms+1) { // Else copy other types
rfields[TypeFunc::Parms] = jrange->field_at(TypeFunc::Parms);
- if( jrange->cnt() == TypeFunc::Parms+2 )
+ if (jrange->cnt() == TypeFunc::Parms+2) {
rfields[TypeFunc::Parms+1] = jrange->field_at(TypeFunc::Parms+1);
+ }
}
const TypeTuple* range = TypeTuple::make(jrange->cnt(),rfields);
@@ -181,14 +177,7 @@ void GraphKit::gen_stub(address C_function,
// A little too aggressive on the parm copy; return address is not an input
call->set_req(TypeFunc::ReturnAdr, top());
for (; i < parm_cnt; i++) { // Regular input arguments
- // Convert ints to longs if required.
- if (CCallingConventionRequiresIntsAsLongs && jdomain->field_at(i)->isa_int()) {
- Node* int_as_long = _gvn.transform(new ConvI2LNode(map()->in(i)));
- call->init_req(cnt++, int_as_long); // long
- call->init_req(cnt++, top()); // half
- } else {
- call->init_req(cnt++, map()->in(i));
- }
+ call->init_req(cnt++, map()->in(i));
}
call->init_req( cnt++, thread );
diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp
index f87f52cfc29..3a4e43432c8 100644
--- a/hotspot/src/share/vm/opto/library_call.cpp
+++ b/hotspot/src/share/vm/opto/library_call.cpp
@@ -297,6 +297,8 @@ class LibraryCallKit : public GraphKit {
bool inline_multiplyToLen();
bool inline_squareToLen();
bool inline_mulAdd();
+ bool inline_montgomeryMultiply();
+ bool inline_montgomerySquare();
bool inline_profileBoolean();
bool inline_isCompileConstant();
@@ -508,6 +510,13 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) {
if (!UseMulAddIntrinsic) return NULL;
break;
+ case vmIntrinsics::_montgomeryMultiply:
+ if (!UseMontgomeryMultiplyIntrinsic) return NULL;
+ break;
+ case vmIntrinsics::_montgomerySquare:
+ if (!UseMontgomerySquareIntrinsic) return NULL;
+ break;
+
case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
if (!UseAESIntrinsics) return NULL;
@@ -642,7 +651,8 @@ JVMState* LibraryIntrinsic::generate(JVMState* jvms) {
const int bci = kit.bci();
// Try to inline the intrinsic.
- if (kit.try_to_inline(_last_predicate)) {
+ if ((CheckIntrinsics ? callee->intrinsic_candidate() : true) &&
+ kit.try_to_inline(_last_predicate)) {
if (C->print_intrinsics() || C->print_inlining()) {
C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)");
}
@@ -663,7 +673,13 @@ JVMState* LibraryIntrinsic::generate(JVMState* jvms) {
if (C->print_intrinsics() || C->print_inlining()) {
if (jvms->has_method()) {
// Not a root compile.
- const char* msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)";
+ const char* msg;
+ if (callee->intrinsic_candidate()) {
+ msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)";
+ } else {
+ msg = is_virtual() ? "failed to inline (intrinsic, virtual), method not annotated"
+ : "failed to inline (intrinsic), method not annotated";
+ }
C->print_inlining(callee, jvms->depth() - 1, bci, msg);
} else {
// Root compile
@@ -942,6 +958,11 @@ bool LibraryCallKit::try_to_inline(int predicate) {
case vmIntrinsics::_mulAdd:
return inline_mulAdd();
+ case vmIntrinsics::_montgomeryMultiply:
+ return inline_montgomeryMultiply();
+ case vmIntrinsics::_montgomerySquare:
+ return inline_montgomerySquare();
+
case vmIntrinsics::_ghash_processBlocks:
return inline_ghash_processBlocks();
@@ -5244,7 +5265,7 @@ bool LibraryCallKit::inline_encodeISOArray() {
//-------------inline_multiplyToLen-----------------------------------
bool LibraryCallKit::inline_multiplyToLen() {
- assert(UseMultiplyToLenIntrinsic, "not implementated on this platform");
+ assert(UseMultiplyToLenIntrinsic, "not implemented on this platform");
address stubAddr = StubRoutines::multiplyToLen();
if (stubAddr == NULL) {
@@ -5254,11 +5275,12 @@ bool LibraryCallKit::inline_multiplyToLen() {
assert(callee()->signature()->size() == 5, "multiplyToLen has 5 parameters");
- Node* x = argument(1);
- Node* xlen = argument(2);
- Node* y = argument(3);
- Node* ylen = argument(4);
- Node* z = argument(5);
+ // no receiver because it is a static method
+ Node* x = argument(0);
+ Node* xlen = argument(1);
+ Node* y = argument(2);
+ Node* ylen = argument(3);
+ Node* z = argument(4);
const Type* x_type = x->Value(&_gvn);
const Type* y_type = y->Value(&_gvn);
@@ -5437,6 +5459,121 @@ bool LibraryCallKit::inline_mulAdd() {
return true;
}
+//-------------inline_montgomeryMultiply-----------------------------------
+bool LibraryCallKit::inline_montgomeryMultiply() {
+ address stubAddr = StubRoutines::montgomeryMultiply();
+ if (stubAddr == NULL) {
+ return false; // Intrinsic's stub is not implemented on this platform
+ }
+
+ assert(UseMontgomeryMultiplyIntrinsic, "not implemented on this platform");
+ const char* stubName = "montgomery_square";
+
+ assert(callee()->signature()->size() == 7, "montgomeryMultiply has 7 parameters");
+
+ Node* a = argument(0);
+ Node* b = argument(1);
+ Node* n = argument(2);
+ Node* len = argument(3);
+ Node* inv = argument(4);
+ Node* m = argument(6);
+
+ const Type* a_type = a->Value(&_gvn);
+ const TypeAryPtr* top_a = a_type->isa_aryptr();
+ const Type* b_type = b->Value(&_gvn);
+ const TypeAryPtr* top_b = b_type->isa_aryptr();
+ const Type* n_type = a->Value(&_gvn);
+ const TypeAryPtr* top_n = n_type->isa_aryptr();
+ const Type* m_type = a->Value(&_gvn);
+ const TypeAryPtr* top_m = m_type->isa_aryptr();
+ if (top_a == NULL || top_a->klass() == NULL ||
+ top_b == NULL || top_b->klass() == NULL ||
+ top_n == NULL || top_n->klass() == NULL ||
+ top_m == NULL || top_m->klass() == NULL) {
+ // failed array check
+ return false;
+ }
+
+ BasicType a_elem = a_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ BasicType b_elem = b_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ BasicType n_elem = n_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ BasicType m_elem = m_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ if (a_elem != T_INT || b_elem != T_INT || n_elem != T_INT || m_elem != T_INT) {
+ return false;
+ }
+
+ // Make the call
+ {
+ Node* a_start = array_element_address(a, intcon(0), a_elem);
+ Node* b_start = array_element_address(b, intcon(0), b_elem);
+ Node* n_start = array_element_address(n, intcon(0), n_elem);
+ Node* m_start = array_element_address(m, intcon(0), m_elem);
+
+ Node* call = make_runtime_call(RC_LEAF,
+ OptoRuntime::montgomeryMultiply_Type(),
+ stubAddr, stubName, TypePtr::BOTTOM,
+ a_start, b_start, n_start, len, inv, top(),
+ m_start);
+ set_result(m);
+ }
+
+ return true;
+}
+
+bool LibraryCallKit::inline_montgomerySquare() {
+ address stubAddr = StubRoutines::montgomerySquare();
+ if (stubAddr == NULL) {
+ return false; // Intrinsic's stub is not implemented on this platform
+ }
+
+ assert(UseMontgomerySquareIntrinsic, "not implemented on this platform");
+ const char* stubName = "montgomery_square";
+
+ assert(callee()->signature()->size() == 6, "montgomerySquare has 6 parameters");
+
+ Node* a = argument(0);
+ Node* n = argument(1);
+ Node* len = argument(2);
+ Node* inv = argument(3);
+ Node* m = argument(5);
+
+ const Type* a_type = a->Value(&_gvn);
+ const TypeAryPtr* top_a = a_type->isa_aryptr();
+ const Type* n_type = a->Value(&_gvn);
+ const TypeAryPtr* top_n = n_type->isa_aryptr();
+ const Type* m_type = a->Value(&_gvn);
+ const TypeAryPtr* top_m = m_type->isa_aryptr();
+ if (top_a == NULL || top_a->klass() == NULL ||
+ top_n == NULL || top_n->klass() == NULL ||
+ top_m == NULL || top_m->klass() == NULL) {
+ // failed array check
+ return false;
+ }
+
+ BasicType a_elem = a_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ BasicType n_elem = n_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ BasicType m_elem = m_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ if (a_elem != T_INT || n_elem != T_INT || m_elem != T_INT) {
+ return false;
+ }
+
+ // Make the call
+ {
+ Node* a_start = array_element_address(a, intcon(0), a_elem);
+ Node* n_start = array_element_address(n, intcon(0), n_elem);
+ Node* m_start = array_element_address(m, intcon(0), m_elem);
+
+ Node* call = make_runtime_call(RC_LEAF,
+ OptoRuntime::montgomerySquare_Type(),
+ stubAddr, stubName, TypePtr::BOTTOM,
+ a_start, n_start, len, inv, top(),
+ m_start);
+ set_result(m);
+ }
+
+ return true;
+}
+
/**
* Calculate CRC32 for byte.
diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp
index 431b2bb0f96..e87cc4a1ade 100644
--- a/hotspot/src/share/vm/opto/loopTransform.cpp
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp
@@ -2941,13 +2941,6 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) {
_igvn.register_new_node_with_optimizer(store_value);
}
- if (CCallingConventionRequiresIntsAsLongs &&
- // See StubRoutines::select_fill_function for types. FLOAT has been converted to INT.
- (t == T_FLOAT || t == T_INT || is_subword_type(t))) {
- store_value = new ConvI2LNode(store_value);
- _igvn.register_new_node_with_optimizer(store_value);
- }
-
Node* mem_phi = store->in(MemNode::Memory);
Node* result_ctrl;
Node* result_mem;
@@ -2957,9 +2950,6 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) {
uint cnt = 0;
call->init_req(TypeFunc::Parms + cnt++, from);
call->init_req(TypeFunc::Parms + cnt++, store_value);
- if (CCallingConventionRequiresIntsAsLongs) {
- call->init_req(TypeFunc::Parms + cnt++, C->top());
- }
#ifdef _LP64
len = new ConvI2LNode(len);
_igvn.register_new_node_with_optimizer(len);
diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp
index 56bf22b964a..32a589d6122 100644
--- a/hotspot/src/share/vm/opto/runtime.cpp
+++ b/hotspot/src/share/vm/opto/runtime.cpp
@@ -779,18 +779,10 @@ const TypeFunc* OptoRuntime::generic_arraycopy_Type() {
const TypeFunc* OptoRuntime::array_fill_Type() {
const Type** fields;
int argp = TypeFunc::Parms;
- if (CCallingConventionRequiresIntsAsLongs) {
// create input type (domain): pointer, int, size_t
- fields = TypeTuple::fields(3 LP64_ONLY( + 2));
- fields[argp++] = TypePtr::NOTNULL;
- fields[argp++] = TypeLong::LONG;
- fields[argp++] = Type::HALF;
- } else {
- // create input type (domain): pointer, int, size_t
- fields = TypeTuple::fields(3 LP64_ONLY( + 1));
- fields[argp++] = TypePtr::NOTNULL;
- fields[argp++] = TypeInt::INT;
- }
+ fields = TypeTuple::fields(3 LP64_ONLY( + 1));
+ fields[argp++] = TypePtr::NOTNULL;
+ fields[argp++] = TypeInt::INT;
fields[argp++] = TypeX_X; // size in whatevers (size_t)
LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length
const TypeTuple *domain = TypeTuple::make(argp, fields);
@@ -1010,6 +1002,53 @@ const TypeFunc* OptoRuntime::mulAdd_Type() {
return TypeFunc::make(domain, range);
}
+const TypeFunc* OptoRuntime::montgomeryMultiply_Type() {
+ // create input type (domain)
+ int num_args = 7;
+ int argcnt = num_args;
+ const Type** fields = TypeTuple::fields(argcnt);
+ int argp = TypeFunc::Parms;
+ fields[argp++] = TypePtr::NOTNULL; // a
+ fields[argp++] = TypePtr::NOTNULL; // b
+ fields[argp++] = TypePtr::NOTNULL; // n
+ fields[argp++] = TypeInt::INT; // len
+ fields[argp++] = TypeLong::LONG; // inv
+ fields[argp++] = Type::HALF;
+ fields[argp++] = TypePtr::NOTNULL; // result
+ assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
+ const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
+
+ // result type needed
+ fields = TypeTuple::fields(1);
+ fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
+
+ const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
+ return TypeFunc::make(domain, range);
+}
+
+const TypeFunc* OptoRuntime::montgomerySquare_Type() {
+ // create input type (domain)
+ int num_args = 6;
+ int argcnt = num_args;
+ const Type** fields = TypeTuple::fields(argcnt);
+ int argp = TypeFunc::Parms;
+ fields[argp++] = TypePtr::NOTNULL; // a
+ fields[argp++] = TypePtr::NOTNULL; // n
+ fields[argp++] = TypeInt::INT; // len
+ fields[argp++] = TypeLong::LONG; // inv
+ fields[argp++] = Type::HALF;
+ fields[argp++] = TypePtr::NOTNULL; // result
+ assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
+ const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
+
+ // result type needed
+ fields = TypeTuple::fields(1);
+ fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
+
+ const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
+ return TypeFunc::make(domain, range);
+}
+
// GHASH block processing
const TypeFunc* OptoRuntime::ghash_processBlocks_Type() {
int argcnt = 4;
diff --git a/hotspot/src/share/vm/opto/runtime.hpp b/hotspot/src/share/vm/opto/runtime.hpp
index 424bf822b0d..c2fc15db3d0 100644
--- a/hotspot/src/share/vm/opto/runtime.hpp
+++ b/hotspot/src/share/vm/opto/runtime.hpp
@@ -311,6 +311,8 @@ private:
static const TypeFunc* digestBase_implCompressMB_Type();
static const TypeFunc* multiplyToLen_Type();
+ static const TypeFunc* montgomeryMultiply_Type();
+ static const TypeFunc* montgomerySquare_Type();
static const TypeFunc* squareToLen_Type();
diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp
index aae5ccc5971..3afc32a0b30 100644
--- a/hotspot/src/share/vm/runtime/globals.hpp
+++ b/hotspot/src/share/vm/runtime/globals.hpp
@@ -728,7 +728,8 @@ public:
"Control whether AES instructions can be used on x86/x64") \
\
product(bool, UseSHA, false, \
- "Control whether SHA instructions can be used on SPARC") \
+ "Control whether SHA instructions can be used " \
+ "on SPARC and on ARM") \
\
product(bool, UseGHASHIntrinsics, false, \
"Use intrinsics for GHASH versions of crypto") \
@@ -837,13 +838,16 @@ public:
"Use intrinsics for AES versions of crypto") \
\
product(bool, UseSHA1Intrinsics, false, \
- "Use intrinsics for SHA-1 crypto hash function") \
+ "Use intrinsics for SHA-1 crypto hash function. " \
+ "Requires that UseSHA is enabled.") \
\
product(bool, UseSHA256Intrinsics, false, \
- "Use intrinsics for SHA-224 and SHA-256 crypto hash functions") \
+ "Use intrinsics for SHA-224 and SHA-256 crypto hash functions. " \
+ "Requires that UseSHA is enabled.") \
\
product(bool, UseSHA512Intrinsics, false, \
- "Use intrinsics for SHA-384 and SHA-512 crypto hash functions") \
+ "Use intrinsics for SHA-384 and SHA-512 crypto hash functions. " \
+ "Requires that UseSHA is enabled.") \
\
product(bool, UseCRC32Intrinsics, false, \
"use intrinsics for java.util.zip.CRC32") \
@@ -4124,7 +4128,16 @@ public:
\
product_pd(bool, PreserveFramePointer, \
"Use the FP register for holding the frame pointer " \
- "and not as a general purpose register.")
+ "and not as a general purpose register.") \
+ \
+ diagnostic(bool, CheckIntrinsics, trueInDebug, \
+ "When a class C is loaded, check that " \
+ "(1) all intrinsics defined by the VM for class C are present "\
+ "in the loaded class file and are marked with the " \
+ "@HotSpotIntrinsicCandidate annotation and also that " \
+ "(2) there is an intrinsic registered for all loaded methods " \
+ "that are annotated with the @HotSpotIntrinsicCandidate " \
+ "annotation.")
/*
* Macros for factoring of globals
diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp
index d226fe9b76b..98bcd2ef8df 100644
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp
@@ -2642,71 +2642,6 @@ JRT_ENTRY_NO_ASYNC(void, SharedRuntime::block_for_jni_critical(JavaThread* threa
GC_locker::unlock_critical(thread);
JRT_END
-int SharedRuntime::convert_ints_to_longints_argcnt(int in_args_count, BasicType* in_sig_bt) {
- int argcnt = in_args_count;
- if (CCallingConventionRequiresIntsAsLongs) {
- for (int in = 0; in < in_args_count; in++) {
- BasicType bt = in_sig_bt[in];
- switch (bt) {
- case T_BOOLEAN:
- case T_CHAR:
- case T_BYTE:
- case T_SHORT:
- case T_INT:
- argcnt++;
- break;
- default:
- break;
- }
- }
- } else {
- assert(0, "This should not be needed on this platform");
- }
-
- return argcnt;
-}
-
-void SharedRuntime::convert_ints_to_longints(int i2l_argcnt, int& in_args_count,
- BasicType*& in_sig_bt, VMRegPair*& in_regs) {
- if (CCallingConventionRequiresIntsAsLongs) {
- VMRegPair *new_in_regs = NEW_RESOURCE_ARRAY(VMRegPair, i2l_argcnt);
- BasicType *new_in_sig_bt = NEW_RESOURCE_ARRAY(BasicType, i2l_argcnt);
-
- int argcnt = 0;
- for (int in = 0; in < in_args_count; in++, argcnt++) {
- BasicType bt = in_sig_bt[in];
- VMRegPair reg = in_regs[in];
- switch (bt) {
- case T_BOOLEAN:
- case T_CHAR:
- case T_BYTE:
- case T_SHORT:
- case T_INT:
- // Convert (bt) to (T_LONG,bt).
- new_in_sig_bt[argcnt] = T_LONG;
- new_in_sig_bt[argcnt+1] = bt;
- assert(reg.first()->is_valid() && !reg.second()->is_valid(), "");
- new_in_regs[argcnt].set2(reg.first());
- new_in_regs[argcnt+1].set_bad();
- argcnt++;
- break;
- default:
- // No conversion needed.
- new_in_sig_bt[argcnt] = bt;
- new_in_regs[argcnt] = reg;
- break;
- }
- }
- assert(argcnt == i2l_argcnt, "must match");
-
- in_regs = new_in_regs;
- in_sig_bt = new_in_sig_bt;
- in_args_count = i2l_argcnt;
- } else {
- assert(0, "This should not be needed on this platform");
- }
-}
-
// -------------------------------------------------------------------------
// Java-Java calling convention
// (what you use when Java calls Java)
diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.hpp b/hotspot/src/share/vm/runtime/sharedRuntime.hpp
index 93ca5b2fa94..f94a8693572 100644
--- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp
@@ -145,6 +145,12 @@ class SharedRuntime: AllStatic {
static double dsqrt(double f);
#endif
+ // Montgomery multiplication
+ static void montgomery_multiply(jint *a_ints, jint *b_ints, jint *n_ints,
+ jint len, jlong inv, jint *m_ints);
+ static void montgomery_square(jint *a_ints, jint *n_ints,
+ jint len, jlong inv, jint *m_ints);
+
#ifdef __SOFTFP__
// C++ compiler generates soft float instructions as well as passing
// float and double in registers.
diff --git a/hotspot/src/share/vm/runtime/stubRoutines.cpp b/hotspot/src/share/vm/runtime/stubRoutines.cpp
index fd10d6f4cdc..7a453f8b2ae 100644
--- a/hotspot/src/share/vm/runtime/stubRoutines.cpp
+++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp
@@ -143,6 +143,8 @@ address StubRoutines::_updateBytesCRC32C = NULL;
address StubRoutines::_multiplyToLen = NULL;
address StubRoutines::_squareToLen = NULL;
address StubRoutines::_mulAdd = NULL;
+address StubRoutines::_montgomeryMultiply = NULL;
+address StubRoutines::_montgomerySquare = NULL;
double (* StubRoutines::_intrinsic_log )(double) = NULL;
double (* StubRoutines::_intrinsic_log10 )(double) = NULL;
diff --git a/hotspot/src/share/vm/runtime/stubRoutines.hpp b/hotspot/src/share/vm/runtime/stubRoutines.hpp
index 22ad6c04d29..b702a29adaa 100644
--- a/hotspot/src/share/vm/runtime/stubRoutines.hpp
+++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp
@@ -202,6 +202,8 @@ class StubRoutines: AllStatic {
static address _multiplyToLen;
static address _squareToLen;
static address _mulAdd;
+ static address _montgomeryMultiply;
+ static address _montgomerySquare;
// These are versions of the java.lang.Math methods which perform
// the same operations as the intrinsic version. They are used for
@@ -366,6 +368,8 @@ class StubRoutines: AllStatic {
static address multiplyToLen() {return _multiplyToLen; }
static address squareToLen() {return _squareToLen; }
static address mulAdd() {return _mulAdd; }
+ static address montgomeryMultiply() { return _montgomeryMultiply; }
+ static address montgomerySquare() { return _montgomerySquare; }
static address select_fill_function(BasicType t, bool aligned, const char* &name);
diff --git a/hotspot/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java b/hotspot/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java
index 2aecaaa4903..f4109d65810 100644
--- a/hotspot/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java
+++ b/hotspot/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java
@@ -34,6 +34,7 @@ import jdk.test.lib.*;
* @library /testlibrary
* @modules java.base/sun.misc
* java.management
+ * java.base/jdk.internal
* @compile -XDignore.symbol.file java/lang/Object.java TestMonomorphicObjectCall.java
* @run main TestMonomorphicObjectCall
*/
diff --git a/hotspot/test/compiler/dependencies/MonomorphicObjectCall/java/lang/Object.java b/hotspot/test/compiler/dependencies/MonomorphicObjectCall/java/lang/Object.java
index aa983bcbd68..d311352e10b 100644
--- a/hotspot/test/compiler/dependencies/MonomorphicObjectCall/java/lang/Object.java
+++ b/hotspot/test/compiler/dependencies/MonomorphicObjectCall/java/lang/Object.java
@@ -25,25 +25,33 @@
package java.lang;
+import jdk.internal.HotSpotIntrinsicCandidate;
+
/**
* Slightly modified version of java.lang.Object that replaces
* finalize() by finalizeObject() to avoid overriding in subclasses.
*/
public class Object {
+ @HotSpotIntrinsicCandidate
+ public Object() {}
+
private static native void registerNatives();
static {
registerNatives();
}
+ @HotSpotIntrinsicCandidate
public final native Class> getClass();
+ @HotSpotIntrinsicCandidate
public native int hashCode();
public boolean equals(Object obj) {
return (this == obj);
}
+ @HotSpotIntrinsicCandidate
protected native Object clone() throws CloneNotSupportedException;
public String toString() {
diff --git a/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java b/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java
new file mode 100644
index 00000000000..41662b4e82b
--- /dev/null
+++ b/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java
@@ -0,0 +1,277 @@
+//
+// Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+// Copyright (c) 2015, Red Hat Inc. All rights reserved.
+// 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.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Random;
+
+/**
+ * @test
+ * @bug 8130150
+ * @library /testlibrary
+ * @summary Verify that the Montgomery multiply intrinsic works and correctly checks its arguments.
+ */
+
+public class MontgomeryMultiplyTest {
+
+ static final MethodHandles.Lookup lookup = MethodHandles.lookup();
+
+ static final MethodHandle montgomeryMultiplyHandle, montgomerySquareHandle;
+ static final MethodHandle bigIntegerConstructorHandle;
+ static final Field bigIntegerMagField;
+
+ static {
+ // Use reflection to gain access to the methods we want to test.
+ try {
+ Method m = BigInteger.class.getDeclaredMethod("montgomeryMultiply",
+ /*a*/int[].class, /*b*/int[].class, /*n*/int[].class, /*len*/int.class,
+ /*inv*/long.class, /*product*/int[].class);
+ m.setAccessible(true);
+ montgomeryMultiplyHandle = lookup.unreflect(m);
+
+ m = BigInteger.class.getDeclaredMethod("montgomerySquare",
+ /*a*/int[].class, /*n*/int[].class, /*len*/int.class,
+ /*inv*/long.class, /*product*/int[].class);
+ m.setAccessible(true);
+ montgomerySquareHandle = lookup.unreflect(m);
+
+ Constructor c
+ = BigInteger.class.getDeclaredConstructor(int.class, int[].class);
+ c.setAccessible(true);
+ bigIntegerConstructorHandle = lookup.unreflectConstructor(c);
+
+ bigIntegerMagField = BigInteger.class.getDeclaredField("mag");
+ bigIntegerMagField.setAccessible(true);
+
+ } catch (Throwable ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ // Invoke either BigInteger.montgomeryMultiply or BigInteger.montgomerySquare.
+ int[] montgomeryMultiply(int[] a, int[] b, int[] n, int len, long inv,
+ int[] product) throws Throwable {
+ int[] result =
+ (a == b) ? (int[]) montgomerySquareHandle.invokeExact(a, n, len, inv, product)
+ : (int[]) montgomeryMultiplyHandle.invokeExact(a, b, n, len, inv, product);
+ return Arrays.copyOf(result, len);
+ }
+
+ // Invoke the private constructor BigInteger(int[]).
+ BigInteger newBigInteger(int[] val) throws Throwable {
+ return (BigInteger) bigIntegerConstructorHandle.invokeExact(1, val);
+ }
+
+ // Get the private field BigInteger.mag
+ int[] mag(BigInteger n) {
+ try {
+ return (int[]) bigIntegerMagField.get(n);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ // Montgomery multiplication
+ // Calculate a * b * r^-1 mod n)
+ //
+ // R is a power of the word size
+ // N' = R^-1 mod N
+ //
+ // T := ab
+ // m := (T mod R)N' mod R [so 0 <= m < R]
+ // t := (T + mN)/R
+ // if t >= N then return t - N else return t
+ //
+ BigInteger montgomeryMultiply(BigInteger a, BigInteger b, BigInteger N,
+ int len, BigInteger n_prime)
+ throws Throwable {
+ BigInteger T = a.multiply(b);
+ BigInteger R = BigInteger.ONE.shiftLeft(len*32);
+ BigInteger mask = R.subtract(BigInteger.ONE);
+ BigInteger m = (T.and(mask)).multiply(n_prime);
+ m = m.and(mask); // i.e. m.mod(R)
+ T = T.add(m.multiply(N));
+ T = T.shiftRight(len*32); // i.e. T.divide(R)
+ if (T.compareTo(N) > 0) {
+ T = T.subtract(N);
+ }
+ return T;
+ }
+
+ // Call the Montgomery multiply intrinsic.
+ BigInteger montgomeryMultiply(int[] a_words, int[] b_words, int[] n_words,
+ int len, BigInteger inv)
+ throws Throwable {
+ BigInteger t = montgomeryMultiply(
+ newBigInteger(a_words),
+ newBigInteger(b_words),
+ newBigInteger(n_words),
+ len, inv);
+ return t;
+ }
+
+ // Check that the Montgomery multiply intrinsic returns the same
+ // result as the longhand calculation.
+ void check(int[] a_words, int[] b_words, int[] n_words, int len, BigInteger inv)
+ throws Throwable {
+ BigInteger n = newBigInteger(n_words);
+ BigInteger slow = montgomeryMultiply(a_words, b_words, n_words, len, inv);
+ BigInteger fast
+ = newBigInteger(montgomeryMultiply
+ (a_words, b_words, n_words, len, inv.longValue(), null));
+ // The intrinsic may not return the same value as the longhand
+ // calculation but they must have the same residue mod N.
+ if (!slow.mod(n).equals(fast.mod(n))) {
+ throw new RuntimeException();
+ }
+ }
+
+ Random rnd = new Random(0);
+
+ // Return a random value of length <= bits in an array of even length
+ int[] random_val(int bits) {
+ int len = (bits+63)/64; // i.e. length in longs
+ int[] val = new int[len*2];
+ for (int i = 0; i < val.length; i++)
+ val[i] = rnd.nextInt();
+ int leadingZeros = 64 - (bits & 64);
+ if (leadingZeros >= 32) {
+ val[0] = 0;
+ val[1] &= ~(-1l << (leadingZeros & 31));
+ } else {
+ val[0] &= ~(-1l << leadingZeros);
+ }
+ return val;
+ }
+
+ void testOneLength(int lenInBits, int lenInInts) throws Throwable {
+ BigInteger mod = new BigInteger(lenInBits, 2, rnd);
+ BigInteger r = BigInteger.ONE.shiftLeft(lenInInts * 32);
+ BigInteger n_prime = mod.modInverse(r).negate();
+
+ // Make n.length even, padding with a zero if necessary
+ int[] n = mag(mod);
+ if (n.length < lenInInts) {
+ int[] x = new int[lenInInts];
+ System.arraycopy(n, 0, x, lenInInts-n.length, n.length);
+ n = x;
+ }
+
+ for (int i = 0; i < 10000; i++) {
+ // multiply
+ check(random_val(lenInBits), random_val(lenInBits), n, lenInInts, n_prime);
+ // square
+ int[] tmp = random_val(lenInBits);
+ check(tmp, tmp, n, lenInInts, n_prime);
+ }
+ }
+
+ // Test the Montgomery multiply intrinsic with a bunch of random
+ // values of varying lengths. Do this for long enough that the
+ // caller of the intrinsic is C2-compiled.
+ void testResultValues() throws Throwable {
+ // Test a couple of interesting edge cases.
+ testOneLength(1024, 32);
+ testOneLength(1025, 34);
+ for (int j = 10; j > 0; j--) {
+ // Construct a random prime whose length in words is even
+ int lenInBits = rnd.nextInt(2048) + 64;
+ int lenInInts = (lenInBits + 63)/64*2;
+ testOneLength(lenInBits, lenInInts);
+ }
+ }
+
+ // Range checks
+ void testOneMontgomeryMultiplyCheck(int[] a, int[] b, int[] n, int len, long inv,
+ int[] product, Class klass) {
+ try {
+ montgomeryMultiply(a, b, n, len, inv, product);
+ } catch (Throwable ex) {
+ if (klass.isAssignableFrom(ex.getClass()))
+ return;
+ throw new RuntimeException(klass + " expected, " + ex + " was thrown");
+ }
+ throw new RuntimeException(klass + " expected, was not thrown");
+ }
+
+ void testOneMontgomeryMultiplyCheck(int[] a, int[] b, BigInteger n, int len, BigInteger inv,
+ Class klass) {
+ testOneMontgomeryMultiplyCheck(a, b, mag(n), len, inv.longValue(), null, klass);
+ }
+
+ void testOneMontgomeryMultiplyCheck(int[] a, int[] b, BigInteger n, int len, BigInteger inv,
+ int[] product, Class klass) {
+ testOneMontgomeryMultiplyCheck(a, b, mag(n), len, inv.longValue(), product, klass);
+ }
+
+ void testMontgomeryMultiplyChecks() {
+ int[] blah = random_val(40);
+ int[] small = random_val(39);
+ BigInteger mod = new BigInteger(40*32 , 2, rnd);
+ BigInteger r = BigInteger.ONE.shiftLeft(40*32);
+ BigInteger n_prime = mod.modInverse(r).negate();
+
+ // Length out of range: square
+ testOneMontgomeryMultiplyCheck(blah, blah, mod, 41, n_prime, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(blah, blah, mod, 0, n_prime, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(blah, blah, mod, -1, n_prime, IllegalArgumentException.class);
+ // As above, but for multiply
+ testOneMontgomeryMultiplyCheck(blah, blah.clone(), mod, 41, n_prime, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(blah, blah.clone(), mod, 0, n_prime, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(blah, blah.clone(), mod, 0, n_prime, IllegalArgumentException.class);
+
+ // Length odd
+ testOneMontgomeryMultiplyCheck(small, small, mod, 39, n_prime, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(small, small, mod, 0, n_prime, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(small, small, mod, -1, n_prime, IllegalArgumentException.class);
+ // As above, but for multiply
+ testOneMontgomeryMultiplyCheck(small, small.clone(), mod, 39, n_prime, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(small, small.clone(), mod, 0, n_prime, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(small, small.clone(), mod, -1, n_prime, IllegalArgumentException.class);
+
+ // array too small
+ testOneMontgomeryMultiplyCheck(blah, blah, mod, 40, n_prime, small, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(blah, blah.clone(), mod, 40, n_prime, small, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(small, blah, mod, 40, n_prime, blah, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(blah, small, mod, 40, n_prime, blah, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(blah, blah, mod, 40, n_prime, small, IllegalArgumentException.class);
+ testOneMontgomeryMultiplyCheck(small, small, mod, 40, n_prime, blah, IllegalArgumentException.class);
+ }
+
+ public static void main(String args[]) {
+ try {
+ new MontgomeryMultiplyTest().testMontgomeryMultiplyChecks();
+ new MontgomeryMultiplyTest().testResultValues();
+ } catch (Throwable ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java b/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java
index c58299601fa..5c801cb6d1e 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java
@@ -47,16 +47,12 @@ public class SHAOptionsBase extends CommandLineOptionTest {
// expressions, not just a plain strings.
protected static final String SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE
= "SHA instructions are not available on this CPU";
- protected static final String SHA1_INSTRUCTION_IS_NOT_AVAILABLE
- = "SHA1 instruction is not available on this CPU\\.";
- protected static final String SHA256_INSTRUCTION_IS_NOT_AVAILABLE
- = "SHA256 instruction \\(for SHA-224 and SHA-256\\) "
- + "is not available on this CPU\\.";
- protected static final String SHA512_INSTRUCTION_IS_NOT_AVAILABLE
- = "SHA512 instruction \\(for SHA-384 and SHA-512\\) "
- + "is not available on this CPU\\.";
- protected static final String SHA_INTRINSICS_ARE_NOT_AVAILABLE
- = "SHA intrinsics are not available on this CPU";
+ protected static final String SHA1_INTRINSICS_ARE_NOT_AVAILABLE
+ = "Intrinsics for SHA-1 crypto hash functions not available on this CPU.";
+ protected static final String SHA256_INTRINSICS_ARE_NOT_AVAILABLE
+ = "Intrinsics for SHA-224 and SHA-256 crypto hash functions not available on this CPU.";
+ protected static final String SHA512_INTRINSICS_ARE_NOT_AVAILABLE
+ = "Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU.";
private final TestCase[] testCases;
@@ -71,33 +67,23 @@ public class SHAOptionsBase extends CommandLineOptionTest {
* instructions required by the option are not supported.
*/
protected static String getWarningForUnsupportedCPU(String optionName) {
- if (Platform.isSparc() || Platform.isAArch64()) {
+ if (Platform.isSparc() || Platform.isAArch64() ||
+ Platform.isX64() || Platform.isX86()) {
switch (optionName) {
- case SHAOptionsBase.USE_SHA_OPTION:
- return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE;
- case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
- return SHAOptionsBase.SHA1_INSTRUCTION_IS_NOT_AVAILABLE;
- case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
- return SHAOptionsBase.SHA256_INSTRUCTION_IS_NOT_AVAILABLE;
- case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION:
- return SHAOptionsBase.SHA512_INSTRUCTION_IS_NOT_AVAILABLE;
- default:
- throw new Error("Unexpected option " + optionName);
- }
- } else if (Platform.isX64() || Platform.isX86()) {
- switch (optionName) {
- case SHAOptionsBase.USE_SHA_OPTION:
- return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE;
- case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
- case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
- case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION:
- return SHAOptionsBase.SHA_INTRINSICS_ARE_NOT_AVAILABLE;
- default:
- throw new Error("Unexpected option " + optionName);
+ case SHAOptionsBase.USE_SHA_OPTION:
+ return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE;
+ case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION:
+ return SHAOptionsBase.SHA1_INTRINSICS_ARE_NOT_AVAILABLE;
+ case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION:
+ return SHAOptionsBase.SHA256_INTRINSICS_ARE_NOT_AVAILABLE;
+ case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION:
+ return SHAOptionsBase.SHA512_INTRINSICS_ARE_NOT_AVAILABLE;
+ default:
+ throw new Error("Unexpected option " + optionName);
}
} else {
- throw new Error("Support for CPUs other then X86 or SPARC is not "
- + "implemented.");
+ throw new Error("Support for CPUs different fromn X86, SPARC, and AARCH64 "
+ + "is not implemented");
}
}
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java
index 8a59d6392f7..69be4343825 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java
@@ -64,18 +64,20 @@ public class GenericTestCaseForSupportedCPU extends
SHAOptionsBase.USE_SHA_OPTION, true),
CommandLineOptionTest.prepareBooleanFlag(optionName, false));
- // Verify that it is possible to enable the tested option and disable
- // all SHA intrinsics via -UseSHA without any warnings.
- CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
- SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
- }, shouldPassMessage, String.format("It should be able to "
- + "enable option '%s' even if %s was passed to JVM",
- optionName, CommandLineOptionTest.prepareBooleanFlag(
- SHAOptionsBase.USE_SHA_OPTION, false)),
- ExitCode.OK,
- CommandLineOptionTest.prepareBooleanFlag(
- SHAOptionsBase.USE_SHA_OPTION, false),
- CommandLineOptionTest.prepareBooleanFlag(optionName, true));
+ if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
+ // Verify that if -XX:-UseSHA is passed to the JVM, it is not possible
+ // to enable the tested option and a warning is printed.
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) },
+ null,
+ shouldPassMessage,
+ String.format("Enabling option '%s' should not be possible and should result in a warning if %s was passed to JVM",
+ optionName,
+ CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false)),
+ ExitCode.OK,
+ CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
+ CommandLineOptionTest.prepareBooleanFlag(optionName, true));
+ }
}
@Override
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java
index 47bf312bfb2..6730b9e9594 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java
@@ -49,14 +49,22 @@ public class GenericTestCaseForUnsupportedAArch64CPU extends
}, shouldPassMessage, shouldPassMessage, ExitCode.OK,
CommandLineOptionTest.prepareBooleanFlag(optionName, false));
- shouldPassMessage = String.format("JVM should start with '-XX:+"
- + "%s' flag, but output should contain warning.", optionName);
- // Verify that when the tested option is explicitly enabled, then
- // a warning will occur in VM output.
- CommandLineOptionTest.verifySameJVMStartup(new String[] {
- SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
- }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK,
- CommandLineOptionTest.prepareBooleanFlag(optionName, true));
+ shouldPassMessage = String.format("If JVM is started with '-XX:-"
+ + "%s' '-XX:+%s', output should contain warning.",
+ SHAOptionsBase.USE_SHA_OPTION, optionName);
+
+ // Verify that when the tested option is enabled, then
+ // a warning will occur in VM output if UseSHA is disabled.
+ if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) },
+ null,
+ shouldPassMessage,
+ shouldPassMessage,
+ ExitCode.OK,
+ CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
+ CommandLineOptionTest.prepareBooleanFlag(optionName, true));
+ }
}
@Override
diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java
index 34d17dbf301..58dde555551 100644
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java
@@ -48,6 +48,19 @@ public class GenericTestCaseForUnsupportedSparcCPU extends
SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
}, shouldPassMessage, shouldPassMessage, ExitCode.OK,
CommandLineOptionTest.prepareBooleanFlag(optionName, false));
+
+ // Verify that when the tested option is enabled, then
+ // a warning will occur in VM output if UseSHA is disabled.
+ if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) },
+ null,
+ shouldPassMessage,
+ shouldPassMessage,
+ ExitCode.OK,
+ CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
+ CommandLineOptionTest.prepareBooleanFlag(optionName, true));
+ }
}
@Override
diff --git a/jaxp/.hgtags b/jaxp/.hgtags
index 3f37a93d347..3912f8ef4e5 100644
--- a/jaxp/.hgtags
+++ b/jaxp/.hgtags
@@ -313,3 +313,5 @@ d5963ccce28d7a3e96ee3e2dc8a8676e61699b70 jdk9-b66
82aae947938ec9b0119fdd78a616d0b7263072ee jdk9-b68
f844a908d3308f47d73cf64e87c98d37d5d76ce8 jdk9-b69
42180703e0a362c1de7cdbf61d2cbc6609e678c4 jdk9-b70
+a3200b88f259f904876b9ab13fd4c4ec2726f8ba jdk9-b71
+81e85f3b6174314155991048767452a9931e12e2 jdk9-b72
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/JavaWrapper.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/JavaWrapper.java
deleted file mode 100644
index d264b047ba1..00000000000
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/JavaWrapper.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-package com.sun.org.apache.bcel.internal.util;
-
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache BCEL" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
- * written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * "Apache BCEL", nor may "Apache" appear in their name, without
- * prior written permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- */
-
-import java.lang.reflect.*;
-
-/**
- * Java interpreter replacement, i.e., wrapper that uses its own ClassLoader
- * to modify/generate classes as they're requested. You can take this as a template
- * for your own applications.
- * Call this wrapper with
- *
- * To use your own class loader you can set the "bcel.classloader" system property
- * which defaults to "com.sun.org.apache.bcel.internal.util.ClassLoader", e.g., with
- *
- *
- * @author M. Dahm
- * @see ClassLoader
- */
-public class JavaWrapper {
- private java.lang.ClassLoader loader;
-
- private static java.lang.ClassLoader getClassLoader() {
- String s = SecuritySupport.getSystemProperty("bcel.classloader");
-
- if((s == null) || "".equals(s))
- s = "com.sun.org.apache.bcel.internal.util.ClassLoader";
-
- try {
- return (java.lang.ClassLoader)Class.forName(s).newInstance();
- } catch(Exception e) {
- throw new RuntimeException(e.toString());
- }
- }
-
- public JavaWrapper(java.lang.ClassLoader loader) {
- this.loader = loader;
- }
-
- public JavaWrapper() {
- this(getClassLoader());
- }
-
- /** Runs the _main method of the given class with the arguments passed in argv
- *
- * @param class_name the fully qualified class name
- * @param argv the arguments just as you would pass them directly
- */
- public void runMain(String class_name, String[] argv) throws ClassNotFoundException
- {
- Class cl = loader.loadClass(class_name);
- Method method = null;
-
- try {
- method = cl.getMethod("_main", new Class[] { argv.getClass() });
-
- /* Method _main is sane ?
- */
- int m = method.getModifiers();
- Class r = method.getReturnType();
-
- if(!(Modifier.isPublic(m) && Modifier.isStatic(m)) ||
- Modifier.isAbstract(m) || (r != Void.TYPE))
- throw new NoSuchMethodException();
- } catch(NoSuchMethodException no) {
- System.out.println("In class " + class_name +
- ": public static void _main(String[] argv) is not defined");
- return;
- }
-
- try {
- method.invoke(null, new Object[] { argv });
- } catch(Exception ex) {
- ex.printStackTrace();
- }
- }
-
- /** Default _main method used as wrapper, expects the fully qualified class name
- * of the real class as the first argument.
- */
- public static void _main(String[] argv) throws Exception {
- /* Expects class name as first argument, other arguments are by-passed.
- */
- if(argv.length == 0) {
- System.out.println("Missing class name.");
- return;
- }
-
- String class_name = argv[0];
- String[] new_argv = new String[argv.length - 1];
- System.arraycopy(argv, 1, new_argv, 0, new_argv.length);
-
- JavaWrapper wrapper = new JavaWrapper();
- wrapper.runMain(class_name, new_argv);
- }
-}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/Extensions.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/Extensions.java
index 23082e87aa4..17ff0567cd6 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/Extensions.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/Extensions.java
@@ -22,20 +22,16 @@
*/
package com.sun.org.apache.xalan.internal.lib;
-import java.util.Hashtable;
import java.util.StringTokenizer;
-import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import com.sun.org.apache.xalan.internal.extensions.ExpressionContext;
-import com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck;
import com.sun.org.apache.xpath.internal.NodeSet;
import com.sun.org.apache.xpath.internal.objects.XBoolean;
import com.sun.org.apache.xpath.internal.objects.XNumber;
import com.sun.org.apache.xpath.internal.objects.XObject;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
@@ -275,102 +271,6 @@ public class Extensions
return tokenize(toTokenize, " \t\n\r");
}
- /**
- * Return a Node of basic debugging information from the
- * EnvironmentCheck utility about the Java environment.
- *
- *
Simply calls the {@link com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck}
- * utility to grab info about the Java environment and CLASSPATH,
- * etc., and then returns the resulting Node. Stylesheets can
- * then maniuplate this data or simply xsl:copy-of the Node. Note
- * that we first attempt to load the more advanced
- * org.apache.env.Which utility by reflection; only if that fails
- * to we still use the internal version. Which is available from
- * http://xml.apache.org/commons/.
- *
- *
We throw a WrappedRuntimeException in the unlikely case
- * that reading information from the environment throws us an
- * exception. (Is this really the best thing to do?)
- *
- * @param myContext an ExpressionContext passed in by the
- * extension mechanism. This must be an XPathContext.
- * @return a Node as described above.
- */
- public static Node checkEnvironment(ExpressionContext myContext)
- {
-
- Document factoryDocument = getDocument();
-
- Node resultNode = null;
- try
- {
- // First use reflection to try to load Which, which is a
- // better version of EnvironmentCheck
- resultNode = checkEnvironmentUsingWhich(myContext, factoryDocument);
-
- if (null != resultNode)
- return resultNode;
-
- // If reflection failed, fallback to our internal EnvironmentCheck
- EnvironmentCheck envChecker = new EnvironmentCheck();
- Hashtable h = envChecker.getEnvironmentHash();
- resultNode = factoryDocument.createElement("checkEnvironmentExtension");
- envChecker.appendEnvironmentReport(resultNode, factoryDocument, h);
- envChecker = null;
- }
- catch(Exception e)
- {
- throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e);
- }
-
- return resultNode;
- }
-
- /**
- * Private worker method to attempt to use org.apache.env.Which.
- *
- * @param myContext an ExpressionContext passed in by the
- * extension mechanism. This must be an XPathContext.
- * @param factoryDocument providing createElement services, etc.
- * @return a Node with environment info; null if any error
- */
- private static Node checkEnvironmentUsingWhich(ExpressionContext myContext,
- Document factoryDocument)
- {
- final String WHICH_CLASSNAME = "org.apache.env.Which";
- final String WHICH_METHODNAME = "which";
- final Class WHICH_METHOD_ARGS[] = { java.util.Hashtable.class,
- java.lang.String.class,
- java.lang.String.class };
- try
- {
- // Use reflection to try to find xml-commons utility 'Which'
- Class clazz = ObjectFactory.findProviderClass(WHICH_CLASSNAME, true);
- if (null == clazz)
- return null;
-
- // Fully qualify names since this is the only method they're used in
- java.lang.reflect.Method method = clazz.getMethod(WHICH_METHODNAME, WHICH_METHOD_ARGS);
- Hashtable report = new Hashtable();
-
- // Call the method with our Hashtable, common options, and ignore return value
- Object[] methodArgs = { report, "XmlCommons;Xalan;Xerces;Crimson;Ant", "" };
- Object returnValue = method.invoke(null, methodArgs);
-
- // Create a parent to hold the report and append hash to it
- Node resultNode = factoryDocument.createElement("checkEnvironmentExtension");
- com.sun.org.apache.xml.internal.utils.Hashtree2Node.appendHashToNode(report, "whichReport",
- resultNode, factoryDocument);
-
- return resultNode;
- }
- catch (Throwable t)
- {
- // Simply return null; no need to report error
- return null;
- }
- }
-
/**
* @return an instance of DOM Document
*/
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java
index f030ea4442e..e23c00390b6 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java
@@ -121,22 +121,7 @@ public class ObjectFactory {
public static Object newInstance(String className, boolean doFallback)
throws ConfigurationError
{
- if (System.getSecurityManager()!=null) {
- return newInstance(className, null, doFallback);
- } else {
- return newInstance(className,
- findClassLoader (), doFallback);
- }
- }
-
- /**
- * Create an instance of a class using the specified ClassLoader
- */
- static Object newInstance(String className, ClassLoader cl,
- boolean doFallback)
- throws ConfigurationError
- {
- // assert(className != null);
+ ClassLoader cl = System.getSecurityManager()!=null ? null : findClassLoader();
try{
Class providerClass = findProviderClass(className, cl, doFallback);
Object instance = providerClass.newInstance();
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java
deleted file mode 100644
index 9ab7e30bec6..00000000000
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * $Id: Compile.java,v 1.2.4.1 2005/08/31 11:24:13 pvedula Exp $
- */
-
-package com.sun.org.apache.xalan.internal.xsltc.cmdline;
-
-import com.sun.org.apache.xalan.internal.utils.FeatureManager;
-import java.io.File;
-import java.net.URL;
-import java.util.Vector;
-
-import com.sun.org.apache.xalan.internal.xsltc.cmdline.getopt.GetOpt;
-import com.sun.org.apache.xalan.internal.xsltc.cmdline.getopt.GetOptsException;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
-
-/**
- * @author Jacek Ambroziak
- * @author Santiago Pericas-Geertsen
- * @author G. Todd Miller
- * @author Morten Jorgensen
- */
-public final class Compile {
-
- // Versioning numbers for the compiler -v option output
- private static int VERSION_MAJOR = 1;
- private static int VERSION_MINOR = 4;
- private static int VERSION_DELTA = 0;
-
-
-
- // This variable should be set to false to prevent any methods in this
- // class from calling System.exit(). As this is a command-line tool,
- // calling System.exit() is normally OK, but we also want to allow for
- // this class being used in other ways as well.
- private static boolean _allowExit = true;
-
-
- public static void printUsage() {
- System.err.println("XSLTC version " +
- VERSION_MAJOR + "." + VERSION_MINOR +
- ((VERSION_DELTA > 0) ? ("." + VERSION_DELTA) : ("")) + "\n" +
- new ErrorMsg(ErrorMsg.COMPILE_USAGE_STR));
- if (_allowExit) System.exit(-1);
- }
-
- /**
- * This method implements the command line compiler. See the USAGE_STRING
- * constant for a description. It may make sense to move the command-line
- * handling to a separate package (ie. make one xsltc.cmdline.Compiler
- * class that contains this main() method and one xsltc.cmdline.Transform
- * class that contains the DefaultRun stuff).
- */
- public static void main(String[] args) {
- try {
- boolean inputIsURL = false;
- boolean useStdIn = false;
- boolean classNameSet = false;
- final GetOpt getopt = new GetOpt(args, "o:d:j:p:uxhsinv");
- if (args.length < 1) printUsage();
-
- final XSLTC xsltc = new XSLTC(true, new FeatureManager());
- xsltc.init();
-
- int c;
- while ((c = getopt.getNextOption()) != -1) {
- switch(c) {
- case 'i':
- useStdIn = true;
- break;
- case 'o':
- xsltc.setClassName(getopt.getOptionArg());
- classNameSet = true;
- break;
- case 'd':
- xsltc.setDestDirectory(getopt.getOptionArg());
- break;
- case 'p':
- xsltc.setPackageName(getopt.getOptionArg());
- break;
- case 'j':
- xsltc.setJarFileName(getopt.getOptionArg());
- break;
- case 'x':
- xsltc.setDebug(true);
- break;
- case 'u':
- inputIsURL = true;
- break;
- case 's':
- _allowExit = false;
- break;
- case 'n':
- xsltc.setTemplateInlining(true); // used to be 'false'
- break;
- case 'v':
- // fall through to case h
- case 'h':
- default:
- printUsage();
- break;
- }
- }
-
- boolean compileOK;
-
- if (useStdIn) {
- if (!classNameSet) {
- System.err.println(new ErrorMsg(ErrorMsg.COMPILE_STDIN_ERR));
- if (_allowExit) System.exit(-1);
- }
- compileOK = xsltc.compile(System.in, xsltc.getClassName());
- }
- else {
- // Generate a vector containg URLs for all stylesheets specified
- final String[] stylesheetNames = getopt.getCmdArgs();
- final Vector stylesheetVector = new Vector();
- for (int i = 0; i < stylesheetNames.length; i++) {
- final String name = stylesheetNames[i];
- URL url;
- if (inputIsURL)
- url = new URL(name);
- else
- url = (new File(name)).toURI().toURL();
- stylesheetVector.addElement(url);
- }
- compileOK = xsltc.compile(stylesheetVector);
- }
-
- // Compile the stylesheet and output class/jar file(s)
- if (compileOK) {
- xsltc.printWarnings();
- if (xsltc.getJarFileName() != null) xsltc.outputToJar();
- if (_allowExit) System.exit(0);
- }
- else {
- xsltc.printWarnings();
- xsltc.printErrors();
- if (_allowExit) System.exit(-1);
- }
- }
- catch (GetOptsException ex) {
- System.err.println(ex);
- printUsage(); // exits with code '-1'
- }
- catch (Exception e) {
- e.printStackTrace();
- if (_allowExit) System.exit(-1);
- }
- }
-
-}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/Transform.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/Transform.java
deleted file mode 100644
index a81cd779594..00000000000
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/Transform.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * $Id: Transform.java,v 1.2.4.1 2005/09/12 09:07:33 pvedula Exp $
- */
-
-package com.sun.org.apache.xalan.internal.xsltc.cmdline;
-
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
-import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
-import com.sun.org.apache.xalan.internal.xsltc.TransletException;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
-import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter;
-import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Constants;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.Parameter;
-import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
-import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
-import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
-import java.io.FileNotFoundException;
-import java.net.MalformedURLException;
-import java.net.UnknownHostException;
-import java.util.Vector;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.sax.SAXSource;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-
-/**
- * @author Jacek Ambroziak
- * @author Santiago Pericas-Geertsen
- * @author G. Todd Miller
- * @author Morten Jorgensen
- */
-final public class Transform {
-
- private SerializationHandler _handler;
-
- private String _fileName;
- private String _className;
- private String _jarFileSrc;
- private boolean _isJarFileSpecified = false;
- private Vector _params = null;
- private boolean _uri, _debug;
- private int _iterations;
-
- public Transform(String className, String fileName,
- boolean uri, boolean debug, int iterations) {
- _fileName = fileName;
- _className = className;
- _uri = uri;
- _debug = debug;
- _iterations = iterations;
- }
-
- public String getFileName(){return _fileName;}
- public String getClassName(){return _className;}
-
- public void setParameters(Vector params) {
- _params = params;
- }
-
- private void setJarFileInputSrc(boolean flag, String jarFile) {
- // TODO: at this time we do not do anything with this
- // information, attempts to add the jarfile to the CLASSPATH
- // were successful via System.setProperty, but the effects
- // were not visible to the running JVM. For now we add jarfile
- // to CLASSPATH in the wrapper script that calls this program.
- _isJarFileSpecified = flag;
- // TODO verify jarFile exists...
- _jarFileSrc = jarFile;
- }
-
- private void doTransform() {
- try {
- final Class clazz = ObjectFactory.findProviderClass(_className, true);
- final AbstractTranslet translet = (AbstractTranslet)clazz.newInstance();
- translet.postInitialization();
-
- // Create a SAX parser and get the XMLReader object it uses
- final SAXParserFactory factory = SAXParserFactory.newInstance();
- try {
- factory.setFeature(Constants.NAMESPACE_FEATURE,true);
- }
- catch (Exception e) {
- factory.setNamespaceAware(true);
- }
- final SAXParser parser = factory.newSAXParser();
- final XMLReader reader = parser.getXMLReader();
-
- // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
- XSLTCDTMManager dtmManager =
- XSLTCDTMManager.createNewDTMManagerInstance();
-
- DTMWSFilter wsfilter;
- if (translet != null && translet instanceof StripFilter) {
- wsfilter = new DOMWSFilter(translet);
- } else {
- wsfilter = null;
- }
-
- final DOMEnhancedForDTM dom =
- (DOMEnhancedForDTM)dtmManager.getDTM(
- new SAXSource(reader, new InputSource(_fileName)),
- false, wsfilter, true, false, translet.hasIdCall());
-
- dom.setDocumentURI(_fileName);
- translet.prepassDocument(dom);
-
- // Pass global parameters
- int n = _params.size();
- for (int i = 0; i < n; i++) {
- Parameter param = (Parameter) _params.elementAt(i);
- translet.addParameter(param._name, param._value);
- }
-
- // Transform the document
- TransletOutputHandlerFactory tohFactory =
- TransletOutputHandlerFactory.newInstance();
- tohFactory.setOutputType(TransletOutputHandlerFactory.STREAM);
- tohFactory.setEncoding(translet._encoding);
- tohFactory.setOutputMethod(translet._method);
-
- if (_iterations == -1) {
- translet.transform(dom, tohFactory.getSerializationHandler());
- }
- else if (_iterations > 0) {
- long mm = System.currentTimeMillis();
- for (int i = 0; i < _iterations; i++) {
- translet.transform(dom,
- tohFactory.getSerializationHandler());
- }
- mm = System.currentTimeMillis() - mm;
-
- System.err.println("\n");
- }
- }
- catch (TransletException e) {
- if (_debug) e.printStackTrace();
- System.err.println(new ErrorMsg(ErrorMsg.RUNTIME_ERROR_KEY)+
- e.getMessage());
- }
- catch (RuntimeException e) {
- if (_debug) e.printStackTrace();
- System.err.println(new ErrorMsg(ErrorMsg.RUNTIME_ERROR_KEY)+
- e.getMessage());
- }
- catch (FileNotFoundException e) {
- if (_debug) e.printStackTrace();
- ErrorMsg err = new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, _fileName);
- System.err.println(new ErrorMsg(ErrorMsg.RUNTIME_ERROR_KEY)+
- err.toString());
- }
- catch (MalformedURLException e) {
- if (_debug) e.printStackTrace();
- ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, _fileName);
- System.err.println(new ErrorMsg(ErrorMsg.RUNTIME_ERROR_KEY)+
- err.toString());
- }
- catch (ClassNotFoundException e) {
- if (_debug) e.printStackTrace();
- ErrorMsg err= new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR,_className);
- System.err.println(new ErrorMsg(ErrorMsg.RUNTIME_ERROR_KEY)+
- err.toString());
- }
- catch (UnknownHostException e) {
- if (_debug) e.printStackTrace();
- ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, _fileName);
- System.err.println(new ErrorMsg(ErrorMsg.RUNTIME_ERROR_KEY)+
- err.toString());
- }
- catch (SAXException e) {
- Exception ex = e.getException();
- if (_debug) {
- if (ex != null) ex.printStackTrace();
- e.printStackTrace();
- }
- System.err.print(new ErrorMsg(ErrorMsg.RUNTIME_ERROR_KEY));
- if (ex != null)
- System.err.println(ex.getMessage());
- else
- System.err.println(e.getMessage());
- }
- catch (Exception e) {
- if (_debug) e.printStackTrace();
- System.err.println(new ErrorMsg(ErrorMsg.RUNTIME_ERROR_KEY)+
- e.getMessage());
- }
- }
-
- public static void printUsage() {
- System.err.println(new ErrorMsg(ErrorMsg.TRANSFORM_USAGE_STR));
- }
-
- public static void main(String[] args) {
- try {
- if (args.length > 0) {
- int i;
- int iterations = -1;
- boolean uri = false, debug = false;
- boolean isJarFileSpecified = false;
- String jarFile = null;
-
- // Parse options starting with '-'
- for (i = 0; i < args.length && args[i].charAt(0) == '-'; i++) {
- if (args[i].equals("-u")) {
- uri = true;
- }
- else if (args[i].equals("-x")) {
- debug = true;
- }
- else if (args[i].equals("-j")) {
- isJarFileSpecified = true;
- jarFile = args[++i];
- }
- else if (args[i].equals("-n")) {
- try {
- iterations = Integer.parseInt(args[++i]);
- }
- catch (NumberFormatException e) {
- // ignore
- }
- }
- else {
- printUsage();
- }
- }
-
- // Enough arguments left ?
- if (args.length - i < 2) printUsage();
-
- // Get document file and class name
- Transform handler = new Transform(args[i+1], args[i], uri,
- debug, iterations);
- handler.setJarFileInputSrc(isJarFileSpecified, jarFile);
-
- // Parse stylesheet parameters
- Vector params = new Vector();
- for (i += 2; i < args.length; i++) {
- final int equal = args[i].indexOf('=');
- if (equal > 0) {
- final String name = args[i].substring(0, equal);
- final String value = args[i].substring(equal+1);
- params.addElement(new Parameter(name, value));
- }
- else {
- printUsage();
- }
- }
-
- if (i == args.length) {
- handler.setParameters(params);
- handler.doTransform();
- }
- } else {
- printUsage();
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/GetOpt.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/GetOpt.java
deleted file mode 100644
index 3e537c9a86a..00000000000
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/GetOpt.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * $Id: GetOpt.java,v 1.2.4.1 2005/08/31 11:46:04 pvedula Exp $
- */
-
-package com.sun.org.apache.xalan.internal.xsltc.cmdline.getopt;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
-
-
-/**
-* GetOpt is a Java equivalent to the C getopt() library function
-* discussed in man page getopt(3C). It provides command line
-* parsing for Java applications. It supports the most rules of the
-* command line standard (see man page intro(1)) including stacked
-* options such as '-sxm' (which is equivalent to -s -x -m); it
-* handles special '--' option that signifies the end of options.
-* Additionally this implementation of getopt will check for
-* mandatory arguments to options such as in the case of
-* '-d ' it will throw a MissingOptArgException if the
-* option argument '' is not included on the commandline.
-* getopt(3C) does not check for this.
- * @author G Todd Miller
-*/
-public class GetOpt{
- public GetOpt(String[] args, String optString){
- theOptions = new ArrayList();
- int currOptIndex = 0;
- theCmdArgs = new ArrayList();
- theOptionMatcher = new OptionMatcher(optString);
- // fill in the options list
- for(int i=0; i 2){
- // stacked options found, such as '-shm'
- // iterate thru the tokens after the dash and
- // add them to theOptions list
- for(int j=1; j', if current option parsed is 'd' then
- * getOptionArg() would return ''.
- * @return String - argument for current parsed option.
- * @param none
- */
- public String getOptionArg(){
- String retval = null;
- String tmp = theCurrentOption.getArgument();
- char c = theCurrentOption.getArgLetter();
- if(theOptionMatcher.hasArg(c)){
- retval = tmp;
- }
- return retval;
- }
-
- /**
- * gets list of the commandline arguments. For example, in command
- * such as 'cmd -s -d file file2 file3 file4' with the usage
- * 'cmd [-s] [-d ] ...', getCmdArgs() would return
- * the list {file2, file3, file4}.
- * @return String[] - list of command arguments that may appear
- * after options and option arguments.
- * @params none
- */
- public String[] getCmdArgs(){
- String[] retval = new String[theCmdArgs.size()];
- int i=0;
- for(ListIterator it=theCmdArgs.listIterator(); it.hasNext();){
- retval[i++] = (String)it.next();
- }
- return retval;
- }
-
-
- private Option theCurrentOption = null;
- private ListIterator theOptionsIterator;
- private List theOptions = null;
- private List theCmdArgs = null;
- private OptionMatcher theOptionMatcher = null;
-
- ///////////////////////////////////////////////////////////
- //
- // Inner Classes
- //
- ///////////////////////////////////////////////////////////
-
- // inner class to model an option
- class Option{
- private char theArgLetter;
- private String theArgument = null;
- public Option(char argLetter) { theArgLetter = argLetter; }
- public void setArg(String arg) {
- theArgument = arg;
- }
- public boolean hasArg() { return (theArgument != null); }
- public char getArgLetter() { return theArgLetter; }
- public String getArgument() { return theArgument; }
- } // end class Option
-
-
- // inner class to query optString for a possible option match,
- // and whether or not a given legal option takes an argument.
- //
- class OptionMatcher{
- public OptionMatcher(String optString){
- theOptString = optString;
- }
- public boolean match(char c){
- boolean retval = false;
- if(theOptString.indexOf(c) != -1){
- retval = true;
- }
- return retval;
- }
- public boolean hasArg(char c){
- boolean retval = false;
- int index = theOptString.indexOf(c)+1;
- if (index == theOptString.length()){
- // reached end of theOptString
- retval = false;
- }
- else if(theOptString.charAt(index) == ':'){
- retval = true;
- }
- return retval;
- }
- private String theOptString = null;
- } // end class OptionMatcher
-}// end class GetOpt
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/GetOptsException.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/GetOptsException.java
deleted file mode 100644
index fac6089576a..00000000000
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/GetOptsException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * $Id: GetOptsException.java,v 1.2.4.1 2005/08/31 11:47:06 pvedula Exp $
- */
-
-package com.sun.org.apache.xalan.internal.xsltc.cmdline.getopt;
-
-/**
- * @author G Todd Miller
- */
-public class GetOptsException extends Exception{
- static final long serialVersionUID = 8736874967183039804L;
- public GetOptsException(String msg){
- super(msg);
- }
-}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/IllegalArgumentException.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/IllegalArgumentException.java
deleted file mode 100644
index 932f61e53f6..00000000000
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/IllegalArgumentException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * $Id: IllegalArgumentException.java,v 1.2.4.1 2005/08/31 11:47:56 pvedula Exp $
- */
-
-package com.sun.org.apache.xalan.internal.xsltc.cmdline.getopt;
-
-
-class IllegalArgumentException extends GetOptsException{
- static final long serialVersionUID = 8642122427294793651L;
- public IllegalArgumentException(String msg){
- super(msg);
- }
-}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/MissingOptArgException.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/MissingOptArgException.java
deleted file mode 100644
index c5e99b6b60a..00000000000
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt/MissingOptArgException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * $Id: MissingOptArgException.java,v 1.2.4.1 2005/08/31 11:49:21 pvedula Exp $
- */
-
-package com.sun.org.apache.xalan.internal.xsltc.cmdline.getopt;
-
-
-/**
- * @author G Todd Miller
- */
-class MissingOptArgException extends GetOptsException{
- static final long serialVersionUID = -1972471465394544822L;
- public MissingOptArgException(String msg){
- super(msg);
- }
-}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SmartTransformerFactoryImpl.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SmartTransformerFactoryImpl.java
deleted file mode 100644
index 4637dce2035..00000000000
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SmartTransformerFactoryImpl.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * $Id: SmartTransformerFactoryImpl.java,v 1.2.4.1 2005/09/14 09:57:13 pvedula Exp $
- */
-
-
-package com.sun.org.apache.xalan.internal.xsltc.trax;
-
-import javax.xml.XMLConstants;
-import javax.xml.transform.ErrorListener;
-import javax.xml.transform.Source;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TemplatesHandler;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-import org.xml.sax.XMLFilter;
-
-/**
- * Implementation of a transformer factory that uses an XSLTC
- * transformer factory for the creation of Templates objects
- * and uses the Xalan processor transformer factory for the
- * creation of Transformer objects.
- * @author G. Todd Miller
- */
-public class SmartTransformerFactoryImpl extends SAXTransformerFactory
-{
- /**
- *
Set a feature for this SmartTransformerFactory and Transformers
- * or Templates created by this factory.
- *
- *
- * Feature names are fully qualified {@link java.net.URI}s.
- * Implementations may define their own features.
- * An {@link TransformerConfigurationException} is thrown if this TransformerFactory or the
- * Transformers or Templates it creates cannot support the feature.
- * It is possible for an TransformerFactory to expose a feature value but be unable to change its state.
- *
- *
- *
See {@link javax.xml.transform.TransformerFactory} for full documentation of specific features.
- *
- * @param name Feature name.
- * @param value Is feature state true or false.
- *
- * @throws TransformerConfigurationException if this TransformerFactory
- * or the Transformers or Templates it creates cannot support this feature.
- * @throws NullPointerException If the name parameter is null.
- */
- public void setFeature(String name, boolean value)
- throws TransformerConfigurationException {
-
- // feature name cannot be null
- if (name == null) {
- ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_SET_FEATURE_NULL_NAME);
- throw new NullPointerException(err.toString());
- }
- // secure processing?
- else if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
- featureSecureProcessing = value;
- // all done processing feature
- return;
- }
- else {
- // unknown feature
- ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNSUPPORTED_FEATURE, name);
- throw new TransformerConfigurationException(err.toString());
- }
- }
-
- /**
- * javax.xml.transform.sax.TransformerFactory implementation.
- * Look up the value of a feature (to see if it is supported).
- * This method must be updated as the various methods and features of this
- * class are implemented.
- *
- * @param name The feature name
- * @return 'true' if feature is supported, 'false' if not
- */
- public boolean getFeature(String name) {
- // All supported features should be listed here
- String[] features = {
- DOMSource.FEATURE,
- DOMResult.FEATURE,
- SAXSource.FEATURE,
- SAXResult.FEATURE,
- StreamSource.FEATURE,
- StreamResult.FEATURE
- };
-
- // feature name cannot be null
- if (name == null) {
- ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_GET_FEATURE_NULL_NAME);
- throw new NullPointerException(err.toString());
- }
-
- // Inefficient, but it really does not matter in a function like this
- for (int i = 0; i < features.length; i++) {
- if (name.equals(features[i]))
- return true;
- }
-
- // secure processing?
- if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
- return featureSecureProcessing;
- }
-
- // unknown feature
- return false;
- }
-
- public URIResolver getURIResolver() {
- return _uriresolver;
- }
-
- public void setURIResolver(URIResolver resolver) {
- _uriresolver = resolver;
- }
-
- public Source getAssociatedStylesheet(Source source, String media,
- String title, String charset)
- throws TransformerConfigurationException
- {
- if (_currFactory == null) {
- createXSLTCTransformerFactory();
- }
- return _currFactory.getAssociatedStylesheet(source, media,
- title, charset);
- }
-
- /**
- * Create a Transformer object that copies the input document to the
- * result. Uses the com.sun.org.apache.xalan.internal.processor.TransformerFactory.
- * @return A Transformer object.
- */
- public Transformer newTransformer()
- throws TransformerConfigurationException
- {
- if (_xalanFactory == null) {
- createXalanTransformerFactory();
- }
- if (_errorlistener != null) {
- _xalanFactory.setErrorListener(_errorlistener);
- }
- if (_uriresolver != null) {
- _xalanFactory.setURIResolver(_uriresolver);
- }
- _currFactory = _xalanFactory;
- return _currFactory.newTransformer();
- }
-
- /**
- * Create a Transformer object that from the input stylesheet
- * Uses the com.sun.org.apache.xalan.internal.processor.TransformerFactory.
- * @param source the stylesheet.
- * @return A Transformer object.
- */
- public Transformer newTransformer(Source source) throws
- TransformerConfigurationException
- {
- if (_xalanFactory == null) {
- createXalanTransformerFactory();
- }
- if (_errorlistener != null) {
- _xalanFactory.setErrorListener(_errorlistener);
- }
- if (_uriresolver != null) {
- _xalanFactory.setURIResolver(_uriresolver);
- }
- _currFactory = _xalanFactory;
- return _currFactory.newTransformer(source);
- }
-
- /**
- * Create a Templates object that from the input stylesheet
- * Uses the com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
- * @param source the stylesheet.
- * @return A Templates object.
- */
- public Templates newTemplates(Source source)
- throws TransformerConfigurationException
- {
- if (_xsltcFactory == null) {
- createXSLTCTransformerFactory();
- }
- if (_errorlistener != null) {
- _xsltcFactory.setErrorListener(_errorlistener);
- }
- if (_uriresolver != null) {
- _xsltcFactory.setURIResolver(_uriresolver);
- }
- _currFactory = _xsltcFactory;
- return _currFactory.newTemplates(source);
- }
-
- /**
- * Get a TemplatesHandler object that can process SAX ContentHandler
- * events into a Templates object. Uses the
- * com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
- */
- public TemplatesHandler newTemplatesHandler()
- throws TransformerConfigurationException
- {
- if (_xsltcFactory == null) {
- createXSLTCTransformerFactory();
- }
- if (_errorlistener != null) {
- _xsltcFactory.setErrorListener(_errorlistener);
- }
- if (_uriresolver != null) {
- _xsltcFactory.setURIResolver(_uriresolver);
- }
- return _xsltcFactory.newTemplatesHandler();
- }
-
- /**
- * Get a TransformerHandler object that can process SAX ContentHandler
- * events based on a copy transformer.
- * Uses com.sun.org.apache.xalan.internal.processor.TransformerFactory.
- */
- public TransformerHandler newTransformerHandler()
- throws TransformerConfigurationException
- {
- if (_xalanFactory == null) {
- createXalanTransformerFactory();
- }
- if (_errorlistener != null) {
- _xalanFactory.setErrorListener(_errorlistener);
- }
- if (_uriresolver != null) {
- _xalanFactory.setURIResolver(_uriresolver);
- }
- return _xalanFactory.newTransformerHandler();
- }
-
- /**
- * Get a TransformerHandler object that can process SAX ContentHandler
- * events based on a transformer specified by the stylesheet Source.
- * Uses com.sun.org.apache.xalan.internal.processor.TransformerFactory.
- */
- public TransformerHandler newTransformerHandler(Source src)
- throws TransformerConfigurationException
- {
- if (_xalanFactory == null) {
- createXalanTransformerFactory();
- }
- if (_errorlistener != null) {
- _xalanFactory.setErrorListener(_errorlistener);
- }
- if (_uriresolver != null) {
- _xalanFactory.setURIResolver(_uriresolver);
- }
- return _xalanFactory.newTransformerHandler(src);
- }
-
-
- /**
- * Get a TransformerHandler object that can process SAX ContentHandler
- * events based on a transformer specified by the stylesheet Source.
- * Uses com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
- */
- public TransformerHandler newTransformerHandler(Templates templates)
- throws TransformerConfigurationException
- {
- if (_xsltcFactory == null) {
- createXSLTCTransformerFactory();
- }
- if (_errorlistener != null) {
- _xsltcFactory.setErrorListener(_errorlistener);
- }
- if (_uriresolver != null) {
- _xsltcFactory.setURIResolver(_uriresolver);
- }
- return _xsltcFactory.newTransformerHandler(templates);
- }
-
-
- /**
- * Create an XMLFilter that uses the given source as the
- * transformation instructions. Uses
- * com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
- */
- public XMLFilter newXMLFilter(Source src)
- throws TransformerConfigurationException {
- if (_xsltcFactory == null) {
- createXSLTCTransformerFactory();
- }
- if (_errorlistener != null) {
- _xsltcFactory.setErrorListener(_errorlistener);
- }
- if (_uriresolver != null) {
- _xsltcFactory.setURIResolver(_uriresolver);
- }
- Templates templates = _xsltcFactory.newTemplates(src);
- if (templates == null ) return null;
- return newXMLFilter(templates);
- }
-
- /*
- * Create an XMLFilter that uses the given source as the
- * transformation instructions. Uses
- * com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory.
- */
- public XMLFilter newXMLFilter(Templates templates)
- throws TransformerConfigurationException {
- try {
- return new com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter(templates);
- }
- catch(TransformerConfigurationException e1) {
- if (_xsltcFactory == null) {
- createXSLTCTransformerFactory();
- }
- ErrorListener errorListener = _xsltcFactory.getErrorListener();
- if(errorListener != null) {
- try {
- errorListener.fatalError(e1);
- return null;
- }
- catch( TransformerException e2) {
- new TransformerConfigurationException(e2);
- }
- }
- throw e1;
- }
- }
-}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java
index 4c5ba830907..360bbb3786f 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java
@@ -371,11 +371,7 @@ public class CoreDOMImplementationImpl
// to restrict the number of validation handlers being
// requested
if(freeValidatorIndex < 0) {
- return (RevalidationHandler) (ObjectFactory
- .newInstance(
- "com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator",
- ObjectFactory.findClassLoader(),
- true));
+ return new com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator();
}
// return first available validator
RevalidationHandler val = validators[freeValidatorIndex];
@@ -384,11 +380,7 @@ public class CoreDOMImplementationImpl
}
else if(schemaType == XMLGrammarDescription.XML_DTD) {
if(freeDTDValidatorIndex < 0) {
- return (RevalidationHandler) (ObjectFactory
- .newInstance(
- "com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator",
- ObjectFactory.findClassLoader(),
- true));
+ return new com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator();
}
// return first available validator
RevalidationHandler val = dtdValidators[freeDTDValidatorIndex];
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
index 7d2e50580ba..cb490f3287e 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
@@ -638,7 +638,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
// set preference for redirection
followRedirects = httpInputSource.getFollowHTTPRedirects();
if (!followRedirects) {
- setInstanceFollowRedirects(urlConnection, followRedirects);
+ urlConnection.setInstanceFollowRedirects(followRedirects);
}
}
@@ -2192,20 +2192,6 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
} // expandSystemIdStrictOn(String,String):String
- /**
- * Attempt to set whether redirects will be followed for an HttpURLConnection.
- * This may fail on earlier JDKs which do not support setting this preference.
- */
- public static void setInstanceFollowRedirects(HttpURLConnection urlCon, boolean followRedirects) {
- try {
- Method method = HttpURLConnection.class.getMethod("setInstanceFollowRedirects", new Class[] {Boolean.TYPE});
- method.invoke(urlCon, new Object[] {followRedirects ? Boolean.TRUE : Boolean.FALSE});
- }
- // setInstanceFollowRedirects doesn't exist.
- catch (Exception exc) {}
- }
-
-
/**
* Helper method for expandSystemId(String,String,boolean):String
*/
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMUtil.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMUtil.java
index 4a00810f106..e684ea66288 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMUtil.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMUtil.java
@@ -845,13 +845,7 @@ public class DOMUtil {
*/
public static DOMException createDOMException(short code, Throwable cause) {
DOMException de = new DOMException(code, cause != null ? cause.getMessage() : null);
- if (cause != null && ThrowableMethods.fgThrowableMethodsAvailable) {
- try {
- ThrowableMethods.fgThrowableInitCauseMethod.invoke(de, new Object [] {cause});
- }
- // Something went wrong. There's not much we can do about it.
- catch (Exception e) {}
- }
+ if (cause != null) de.initCause(cause);
return de;
}
@@ -860,42 +854,8 @@ public class DOMUtil {
*/
public static LSException createLSException(short code, Throwable cause) {
LSException lse = new LSException(code, cause != null ? cause.getMessage() : null);
- if (cause != null && ThrowableMethods.fgThrowableMethodsAvailable) {
- try {
- ThrowableMethods.fgThrowableInitCauseMethod.invoke(lse, new Object [] {cause});
- }
- // Something went wrong. There's not much we can do about it.
- catch (Exception e) {}
- }
+ if (cause != null) lse.initCause(cause);
return lse;
}
- /**
- * Holder of methods from java.lang.Throwable.
- */
- static class ThrowableMethods {
-
- // Method: java.lang.Throwable.initCause(java.lang.Throwable)
- private static java.lang.reflect.Method fgThrowableInitCauseMethod = null;
-
- // Flag indicating whether or not Throwable methods available.
- private static boolean fgThrowableMethodsAvailable = false;
-
- private ThrowableMethods() {}
-
- // Attempt to get methods for java.lang.Throwable on class initialization.
- static {
- try {
- fgThrowableInitCauseMethod = Throwable.class.getMethod("initCause", new Class [] {Throwable.class});
- fgThrowableMethodsAvailable = true;
- }
- // ClassNotFoundException, NoSuchMethodException or SecurityException
- // Whatever the case, we cannot use java.lang.Throwable.initCause(java.lang.Throwable).
- catch (Exception exc) {
- fgThrowableInitCauseMethod = null;
- fgThrowableMethodsAvailable = false;
- }
- }
- }
-
} // class DOMUtil
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java
index f6673b5d005..1ddc1b185f5 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java
@@ -140,7 +140,7 @@ public class XIncludeTextReader {
// set preference for redirection
boolean followRedirects = httpInputSource.getFollowHTTPRedirects();
if (!followRedirects) {
- XMLEntityManager.setInstanceFollowRedirects(urlConnection, followRedirects);
+ urlConnection.setInstanceFollowRedirects(followRedirects);
}
}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/DTMException.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/DTMException.java
index b5677fc441f..7711ce73f88 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/DTMException.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/DTMException.java
@@ -323,63 +323,5 @@ public class DTMException extends RuntimeException {
super.printStackTrace(s);
} catch (Throwable e) {}
- boolean isJdk14OrHigher = false;
- try {
- Throwable.class.getMethod("getCause", (Class[]) null);
- isJdk14OrHigher = true;
- } catch (NoSuchMethodException nsme) {
- // do nothing
- }
-
- // The printStackTrace method of the Throwable class in jdk 1.4
- // and higher will include the cause when printing the backtrace.
- // The following code is only required when using jdk 1.3 or lower
- if (!isJdk14OrHigher) {
- Throwable exception = getException();
-
- for (int i = 0; (i < 10) && (null != exception); i++) {
- s.println("---------");
-
- try {
- if (exception instanceof DTMException) {
- String locInfo =
- ((DTMException) exception)
- .getLocationAsString();
-
- if (null != locInfo) {
- s.println(locInfo);
- }
- }
-
- exception.printStackTrace(s);
- } catch (Throwable e) {
- s.println("Could not print stack trace...");
- }
-
- try {
- Method meth =
- ((Object) exception).getClass().getMethod("getException",
- (Class[]) null);
-
- if (null != meth) {
- Throwable prev = exception;
-
- exception = (Throwable) meth.invoke(exception, (Object[]) null);
-
- if (prev == exception) {
- break;
- }
- } else {
- exception = null;
- }
- } catch (InvocationTargetException ite) {
- exception = null;
- } catch (IllegalAccessException iae) {
- exception = null;
- } catch (NoSuchMethodException nsme) {
- exception = null;
- }
- }
- }
}
}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMManagerDefault.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMManagerDefault.java
index 9f93f802ae5..1eadf3a5950 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMManagerDefault.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMManagerDefault.java
@@ -348,8 +348,7 @@ public class DTMManagerDefault extends DTMManager
if (haveXercesParser) {
// IncrementalSAXSource_Xerces to avoid threading.
try {
- coParser =(IncrementalSAXSource)
- Class.forName("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Xerces").newInstance();
+ coParser = new com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Xerces();
} catch( Exception ex ) {
ex.printStackTrace();
coParser=null;
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/IncrementalSAXSource_Xerces.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/IncrementalSAXSource_Xerces.java
index 29881ebabcc..963ccf02c5a 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/IncrementalSAXSource_Xerces.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/IncrementalSAXSource_Xerces.java
@@ -87,6 +87,9 @@ public class IncrementalSAXSource_Xerces
{
try
{
+ // This should be cleaned up and the use of reflection
+ // removed - see JDK-8129880
+
// Xerces-2 incremental parsing support (as of Beta 3)
// ContentHandlers still get set on fIncrementalParser (to get
// conversion from XNI events to SAX events), but
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java
index d5d5d2aca27..6cfe327bcd6 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java
@@ -233,7 +233,13 @@ public class SAXCatalogReader implements CatalogReader, ContentHandler, Document
}
parser.parse(new InputSource(is), spHandler);
} else {
- Parser parser = (Parser) ReflectUtil.forName(parserClass).newInstance();
+ Class> c = ReflectUtil.forName(parserClass);
+ if (!Parser.class.isAssignableFrom(c)) {
+ throw new ClassCastException(parserClass
+ + " cannot be cast to "
+ + Parser.class.getName());
+ }
+ Parser parser = (Parser) c.newInstance();
parser.setDocumentHandler(this);
if (bResolver != null) {
parser.setEntityResolver(bResolver);
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java
index 2c9a4988fca..878616905b7 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java
@@ -1220,37 +1220,13 @@ public abstract class BaseMarkupSerializer
if ( internal != null && internal.length() > 0 )
_printer.printText( internal );
endDTD();
- }
- // DOM Level 1 -- does implementation have methods?
- catch (NoSuchMethodError nsme) {
- Class docTypeClass = docType.getClass();
-
- String docTypePublicId = null;
- String docTypeSystemId = null;
- try {
- java.lang.reflect.Method getPublicId = docTypeClass.getMethod("getPublicId", (Class[]) null);
- if (getPublicId.getReturnType().equals(String.class)) {
- docTypePublicId = (String)getPublicId.invoke(docType, (Object[]) null);
- }
- }
- catch (Exception e) {
- // ignore
- }
- try {
- java.lang.reflect.Method getSystemId = docTypeClass.getMethod("getSystemId", (Class[]) null);
- if (getSystemId.getReturnType().equals(String.class)) {
- docTypeSystemId = (String)getSystemId.invoke(docType, (Object[]) null);
- }
- }
- catch (Exception e) {
- // ignore
- }
+ } catch (Exception e) {
+ // ignore
_printer.enterDTD();
- _docTypePublicId = docTypePublicId;
- _docTypeSystemId = docTypeSystemId;
+ _docTypePublicId = null;
+ _docTypeSystemId = null;
endDTD();
}
-
serializeDTD(docType.getName());
}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java
index dc9378b39e5..d53d1b6649d 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java
@@ -54,7 +54,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
import org.w3c.dom.ls.LSException;
import org.w3c.dom.ls.LSOutput;
import org.w3c.dom.ls.LSSerializer;
@@ -1030,15 +1029,12 @@ public class DOMSerializerImpl implements LSSerializer, DOMConfiguration {
private String _getXmlVersion(Node node) {
Document doc = (node.getNodeType() == Node.DOCUMENT_NODE)
? (Document) node : node.getOwnerDocument();
- if (doc != null && DocumentMethods.fgDocumentMethodsAvailable) {
+ if (doc != null) {
try {
- return (String) DocumentMethods.fgDocumentGetXmlVersionMethod.invoke(doc, (Object[]) null);
+ return doc.getXmlVersion();
} // The VM ran out of memory or there was some other serious problem. Re-throw.
- catch (VirtualMachineError vme) {
+ catch (VirtualMachineError | ThreadDeath vme) {
throw vme;
- } // ThreadDeath should always be re-thrown
- catch (ThreadDeath td) {
- throw td;
} // Ignore all other exceptions and errors
catch (Throwable t) {
}
@@ -1049,15 +1045,12 @@ public class DOMSerializerImpl implements LSSerializer, DOMConfiguration {
private String _getInputEncoding(Node node) {
Document doc = (node.getNodeType() == Node.DOCUMENT_NODE)
? (Document) node : node.getOwnerDocument();
- if (doc != null && DocumentMethods.fgDocumentMethodsAvailable) {
+ if (doc != null) {
try {
- return (String) DocumentMethods.fgDocumentGetInputEncodingMethod.invoke(doc, (Object[]) null);
+ return doc.getInputEncoding();
} // The VM ran out of memory or there was some other serious problem. Re-throw.
- catch (VirtualMachineError vme) {
+ catch (VirtualMachineError | ThreadDeath vme) {
throw vme;
- } // ThreadDeath should always be re-thrown
- catch (ThreadDeath td) {
- throw td;
} // Ignore all other exceptions and errors
catch (Throwable t) {
}
@@ -1068,15 +1061,12 @@ public class DOMSerializerImpl implements LSSerializer, DOMConfiguration {
private String _getXmlEncoding(Node node) {
Document doc = (node.getNodeType() == Node.DOCUMENT_NODE)
? (Document) node : node.getOwnerDocument();
- if (doc != null && DocumentMethods.fgDocumentMethodsAvailable) {
+ if (doc != null) {
try {
- return (String) DocumentMethods.fgDocumentGetXmlEncodingMethod.invoke(doc, (Object[]) null);
+ return doc.getXmlEncoding();
} // The VM ran out of memory or there was some other serious problem. Re-throw.
- catch (VirtualMachineError vme) {
+ catch (VirtualMachineError | ThreadDeath vme) {
throw vme;
- } // ThreadDeath should always be re-thrown
- catch (ThreadDeath td) {
- throw td;
} // Ignore all other exceptions and errors
catch (Throwable t) {
}
@@ -1084,42 +1074,4 @@ public class DOMSerializerImpl implements LSSerializer, DOMConfiguration {
return null;
}
- /**
- * Holder of DOM Level 3 methods from org.w3c.dom.Document.
- */
- static class DocumentMethods {
-
- // Method: org.w3c.dom.Document.getXmlVersion()
- private static java.lang.reflect.Method fgDocumentGetXmlVersionMethod = null;
-
- // Method: org.w3c.dom.Document.getInputEncoding()
- private static java.lang.reflect.Method fgDocumentGetInputEncodingMethod = null;
-
- // Method: org.w3c.dom.Document.getXmlEncoding()
- private static java.lang.reflect.Method fgDocumentGetXmlEncodingMethod = null;
-
- // Flag indicating whether or not Document methods are available.
- private static boolean fgDocumentMethodsAvailable = false;
-
- private DocumentMethods() {
- }
-
- // Attempt to get methods for org.w3c.dom.Document on class initialization.
- static {
- try {
- fgDocumentGetXmlVersionMethod = Document.class.getMethod("getXmlVersion", new Class[]{});
- fgDocumentGetInputEncodingMethod = Document.class.getMethod("getInputEncoding", new Class[]{});
- fgDocumentGetXmlEncodingMethod = Document.class.getMethod("getXmlEncoding", new Class[]{});
- fgDocumentMethodsAvailable = true;
- } // ClassNotFoundException, NoSuchMethodException or SecurityException
- // Whatever the case, we cannot retrieve the methods.
- catch (Exception exc) {
- fgDocumentGetXmlVersionMethod = null;
- fgDocumentGetInputEncodingMethod = null;
- fgDocumentGetXmlEncodingMethod = null;
- fgDocumentMethodsAvailable = false;
- }
- }
- }
-
} //DOMSerializerImpl
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java
index 6756daf410b..8b3d1261b00 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java
@@ -26,6 +26,8 @@ import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import com.sun.org.apache.xerces.internal.util.EncodingMap;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
/**
* This class represents an encoding.
@@ -37,9 +39,6 @@ import com.sun.org.apache.xerces.internal.util.EncodingMap;
*/
public class EncodingInfo {
- // An array to hold the argument for a method of Charset, CharsetEncoder or CharToByteConverter.
- private Object [] fArgsForMethod = null;
-
// name of encoding as registered with IANA;
// preferably a MIME name, but aliases are fine too.
String ianaName;
@@ -47,15 +46,7 @@ public class EncodingInfo {
int lastPrintable;
// The CharsetEncoder with which we test unusual characters.
- Object fCharsetEncoder = null;
-
- // The CharToByteConverter with which we test unusual characters.
- Object fCharToByteConverter = null;
-
- // Is the converter null because it can't be instantiated
- // for some reason (perhaps we're running with insufficient authority as
- // an applet?
- boolean fHaveTriedCToB = false;
+ CharsetEncoder fCharsetEncoder = null;
// Is the charset encoder usable or available.
boolean fHaveTriedCharsetEncoder = false;
@@ -118,16 +109,12 @@ public class EncodingInfo {
private boolean isPrintable0(char ch) {
// Attempt to get a CharsetEncoder for this encoding.
- if (fCharsetEncoder == null && CharsetMethods.fgNIOCharsetAvailable && !fHaveTriedCharsetEncoder) {
- if (fArgsForMethod == null) {
- fArgsForMethod = new Object [1];
- }
+ if (fCharsetEncoder == null && !fHaveTriedCharsetEncoder) {
// try and create the CharsetEncoder
try {
- fArgsForMethod[0] = javaName;
- Object charset = CharsetMethods.fgCharsetForNameMethod.invoke(null, fArgsForMethod);
- if (((Boolean) CharsetMethods.fgCharsetCanEncodeMethod.invoke(charset, (Object[]) null)).booleanValue()) {
- fCharsetEncoder = CharsetMethods.fgCharsetNewEncoderMethod.invoke(charset, (Object[]) null);
+ Charset charset = java.nio.charset.Charset.forName(javaName);
+ if (charset.canEncode()) {
+ fCharsetEncoder = charset.newEncoder();
}
// This charset cannot be used for encoding, don't try it again...
else {
@@ -142,8 +129,7 @@ public class EncodingInfo {
// Attempt to use the CharsetEncoder to determine whether the character is printable.
if (fCharsetEncoder != null) {
try {
- fArgsForMethod[0] = new Character(ch);
- return ((Boolean) CharsetMethods.fgCharsetEncoderCanEncodeMethod.invoke(fCharsetEncoder, fArgsForMethod)).booleanValue();
+ return fCharsetEncoder.canEncode(ch);
}
catch (Exception e) {
// obviously can't use this charset encoder; possibly a JDK bug
@@ -152,39 +138,7 @@ public class EncodingInfo {
}
}
- // As a last resort try to use a sun.io.CharToByteConverter to
- // determine whether this character is printable. We will always
- // reach here on JDK 1.3 or below.
- if (fCharToByteConverter == null) {
- if (fHaveTriedCToB || !CharToByteConverterMethods.fgConvertersAvailable) {
- // forget it; nothing we can do...
- return false;
- }
- if (fArgsForMethod == null) {
- fArgsForMethod = new Object [1];
- }
- // try and create the CharToByteConverter
- try {
- fArgsForMethod[0] = javaName;
- fCharToByteConverter = CharToByteConverterMethods.fgGetConverterMethod.invoke(null, fArgsForMethod);
- }
- catch (Exception e) {
- // don't try it again...
- fHaveTriedCToB = true;
- return false;
- }
- }
- try {
- fArgsForMethod[0] = new Character(ch);
- return ((Boolean) CharToByteConverterMethods.fgCanConvertMethod.invoke(fCharToByteConverter, fArgsForMethod)).booleanValue();
- }
- catch (Exception e) {
- // obviously can't use this converter; probably some kind of
- // security restriction
- fCharToByteConverter = null;
- fHaveTriedCToB = false;
- return false;
- }
+ return false;
}
// is this an encoding name recognized by this JDK?
@@ -194,82 +148,4 @@ public class EncodingInfo {
String s = new String(bTest, name);
}
- /**
- * Holder of methods from java.nio.charset.Charset and java.nio.charset.CharsetEncoder.
- */
- static class CharsetMethods {
-
- // Method: java.nio.charset.Charset.forName(java.lang.String)
- private static java.lang.reflect.Method fgCharsetForNameMethod = null;
-
- // Method: java.nio.charset.Charset.canEncode()
- private static java.lang.reflect.Method fgCharsetCanEncodeMethod = null;
-
- // Method: java.nio.charset.Charset.newEncoder()
- private static java.lang.reflect.Method fgCharsetNewEncoderMethod = null;
-
- // Method: java.nio.charset.CharsetEncoder.canEncode(char)
- private static java.lang.reflect.Method fgCharsetEncoderCanEncodeMethod = null;
-
- // Flag indicating whether or not java.nio.charset.* is available.
- private static boolean fgNIOCharsetAvailable = false;
-
- private CharsetMethods() {}
-
- // Attempt to get methods for Charset and CharsetEncoder on class initialization.
- static {
- try {
- Class charsetClass = Class.forName("java.nio.charset.Charset");
- Class charsetEncoderClass = Class.forName("java.nio.charset.CharsetEncoder");
- fgCharsetForNameMethod = charsetClass.getMethod("forName", new Class [] {String.class});
- fgCharsetCanEncodeMethod = charsetClass.getMethod("canEncode", new Class [] {});
- fgCharsetNewEncoderMethod = charsetClass.getMethod("newEncoder", new Class [] {});
- fgCharsetEncoderCanEncodeMethod = charsetEncoderClass.getMethod("canEncode", new Class [] {Character.TYPE});
- fgNIOCharsetAvailable = true;
- }
- // ClassNotFoundException, NoSuchMethodException or SecurityException
- // Whatever the case, we cannot use java.nio.charset.*.
- catch (Exception exc) {
- fgCharsetForNameMethod = null;
- fgCharsetCanEncodeMethod = null;
- fgCharsetEncoderCanEncodeMethod = null;
- fgCharsetNewEncoderMethod = null;
- fgNIOCharsetAvailable = false;
- }
- }
- }
-
- /**
- * Holder of methods from sun.io.CharToByteConverter.
- */
- static class CharToByteConverterMethods {
-
- // Method: sun.io.CharToByteConverter.getConverter(java.lang.String)
- private static java.lang.reflect.Method fgGetConverterMethod = null;
-
- // Method: sun.io.CharToByteConverter.canConvert(char)
- private static java.lang.reflect.Method fgCanConvertMethod = null;
-
- // Flag indicating whether or not sun.io.CharToByteConverter is available.
- private static boolean fgConvertersAvailable = false;
-
- private CharToByteConverterMethods() {}
-
- // Attempt to get methods for char to byte converter on class initialization.
- static {
- try {
- Class clazz = Class.forName("sun.io.CharToByteConverter");
- fgGetConverterMethod = clazz.getMethod("getConverter", new Class [] {String.class});
- fgCanConvertMethod = clazz.getMethod("canConvert", new Class [] {Character.TYPE});
- fgConvertersAvailable = true;
- }
- // ClassNotFoundException, NoSuchMethodException or SecurityException
- // Whatever the case, we cannot use sun.io.CharToByteConverter.
- catch (Exception exc) {
- fgGetConverterMethod = null;
- fgCanConvertMethod = null;
- fgConvertersAvailable = false;
- }
- }
- }
}
diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/FunctionTable.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/FunctionTable.java
index 6d5b7ff3394..f216fc91a8b 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/FunctionTable.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/FunctionTable.java
@@ -378,6 +378,12 @@ public class FunctionTable
int funcIndex;
Object funcIndexObj = getFunctionID(name);
+ if (func != null && !Function.class.isAssignableFrom(func)) {
+ throw new ClassCastException(func.getName()
+ + " cannot be cast to "
+ + Function.class.getName());
+ }
+
if (null != funcIndexObj)
{
funcIndex = ((Integer) funcIndexObj).intValue();
diff --git a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java
index 6ab58d44349..c24e9cfcafe 100644
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java
@@ -64,7 +64,6 @@ public class XMLDOMWriterImpl implements XMLStreamWriter {
private Node currentNode = null;
private Node node = null;
private NamespaceSupport namespaceContext = null;
- private Method mXmlVersion = null;
private boolean [] needContextPop = null;
private StringBuffer stringBuffer = null;
private int resizeValue = 20;
@@ -83,25 +82,11 @@ public class XMLDOMWriterImpl implements XMLStreamWriter {
ownerDoc = node.getOwnerDocument();
currentNode = node;
}
- getDLThreeMethods();
stringBuffer = new StringBuffer();
needContextPop = new boolean[resizeValue];
namespaceContext = new NamespaceSupport();
}
- private void getDLThreeMethods(){
- try{
- mXmlVersion = ownerDoc.getClass().getMethod("setXmlVersion",new Class[] {String.class});
- }catch(NoSuchMethodException mex){
- //log these errors at fine level.
- mXmlVersion = null;
- }catch(SecurityException se){
- //log these errors at fine level.
- mXmlVersion = null;
- }
- }
-
-
/**
* This method has no effect when called.
* @throws javax.xml.stream.XMLStreamException {@inheritDoc}
@@ -557,15 +542,7 @@ public class XMLDOMWriterImpl implements XMLStreamWriter {
* @throws javax.xml.stream.XMLStreamException {@inheritDoc}
*/
public void writeStartDocument() throws XMLStreamException {
- try{
- if(mXmlVersion != null){
- mXmlVersion.invoke(ownerDoc, new Object[] {"1.0"});
- }
- }catch(IllegalAccessException iae){
- throw new XMLStreamException(iae);
- }catch(InvocationTargetException ite){
- throw new XMLStreamException(ite);
- }
+ ownerDoc.setXmlVersion("1.0");
}
/**
@@ -575,15 +552,7 @@ public class XMLDOMWriterImpl implements XMLStreamWriter {
* @throws javax.xml.stream.XMLStreamException {@inheritDoc}
*/
public void writeStartDocument(String version) throws XMLStreamException {
- try{
- if(mXmlVersion != null){
- mXmlVersion.invoke(ownerDoc, new Object[] {version});
- }
- }catch(IllegalAccessException iae){
- throw new XMLStreamException(iae);
- }catch(InvocationTargetException ite){
- throw new XMLStreamException(ite);
- }
+ ownerDoc.setXmlVersion(version);
}
/**
@@ -594,15 +563,7 @@ public class XMLDOMWriterImpl implements XMLStreamWriter {
* @throws javax.xml.stream.XMLStreamException {@inheritDoc}
*/
public void writeStartDocument(String encoding, String version) throws XMLStreamException {
- try{
- if(mXmlVersion != null){
- mXmlVersion.invoke(ownerDoc, new Object[] {version});
- }
- }catch(IllegalAccessException iae){
- throw new XMLStreamException(iae);
- }catch(InvocationTargetException ite){
- throw new XMLStreamException(ite);
- }
+ ownerDoc.setXmlVersion(version);
//TODO: What to do with encoding.-Venu
}
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventReader.java b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventReader.java
index 97d20767055..3788fad0227 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventReader.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventReader.java
@@ -49,7 +49,7 @@ public interface XMLEventReader extends Iterator {
* Get the next XMLEvent
* @see XMLEvent
* @throws XMLStreamException if there is an error with the underlying XML.
- * @throws NoSuchElementException iteration has no more elements.
+ * @throws java.util.NoSuchElementException iteration has no more elements.
*/
public XMLEvent nextEvent() throws XMLStreamException;
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/stream/events/XMLEvent.java b/jaxp/src/java.xml/share/classes/javax/xml/stream/events/XMLEvent.java
index 4f980121988..338b5cbff72 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/stream/events/XMLEvent.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/events/XMLEvent.java
@@ -170,7 +170,7 @@ public interface XMLEvent extends javax.xml.stream.XMLStreamConstants {
* infoset expressed.
*
* @param writer The writer that will output the data
- * @throws XMLStreamException if there is a fatal error writing the event
+ * @throws javax.xml.stream.XMLStreamException if there is a fatal error writing the event
*/
public void writeAsEncodedUnicode(Writer writer)
throws javax.xml.stream.XMLStreamException;
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/transform/TransformerException.java b/jaxp/src/java.xml/share/classes/javax/xml/transform/TransformerException.java
index dfd48246e27..78a058c322d 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/transform/TransformerException.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/transform/TransformerException.java
@@ -110,6 +110,12 @@ public class TransformerException extends Exception {
*/
public synchronized Throwable initCause(Throwable cause) {
+ // TransformerException doesn't set its cause (probably
+ // because it predates initCause()) - and we may not want
+ // to change this since Exceptions are serializable...
+ // But this also leads to the broken code in printStackTrace
+ // below...
+
if (this.containedException != null) {
throw new IllegalStateException("Can't overwrite cause");
}
@@ -312,61 +318,57 @@ public class TransformerException extends Exception {
}
try {
- String locInfo = getLocationAsString();
-
- if (null != locInfo) {
- s.println(locInfo);
- }
-
- super.printStackTrace(s);
- } catch (Throwable e) {}
-
- Throwable exception = getException();
-
- for (int i = 0; (i < 10) && (null != exception); i++) {
- s.println("---------");
-
try {
- if (exception instanceof TransformerException) {
- String locInfo =
- ((TransformerException) exception)
- .getLocationAsString();
+ String locInfo = getLocationAsString();
- if (null != locInfo) {
- s.println(locInfo);
- }
+ if (null != locInfo) {
+ s.println(locInfo);
}
- exception.printStackTrace(s);
- } catch (Throwable e) {
- s.println("Could not print stack trace...");
- }
+ super.printStackTrace(s);
+ } catch (Throwable e) {}
- try {
- Method meth =
- ((Object) exception).getClass().getMethod("getException",
- (Class[]) null);
+ Throwable exception = getException();
- if (null != meth) {
- Throwable prev = exception;
+ for (int i = 0; (i < 10) && (null != exception); i++) {
+ s.println("---------");
- exception = (Throwable) meth.invoke(exception, (Object[]) null);
+ try {
+ exception.printStackTrace(s);
+ // if exception is a TransformerException it will print
+ // its contained exception, so we don't need to redo it here,
+ // and we can exit the loop now.
+ if (exception instanceof TransformerException) break;
+ } catch (Throwable e) {
+ s.println("Could not print stack trace...");
+ }
- if (prev == exception) {
- break;
+ try {
+ // Is this still needed?
+ Method meth = exception.getClass().getMethod("getException");
+
+ if (null != meth) {
+ Throwable prev = exception;
+
+ exception = (Throwable) meth.invoke(exception, (Object[]) null);
+
+ if (prev == exception) {
+ break;
+ }
+ } else {
+ exception = null;
}
- } else {
+ } catch (InvocationTargetException ite) {
+ exception = null;
+ } catch (IllegalAccessException iae) {
+ exception = null;
+ } catch (NoSuchMethodException nsme) {
exception = null;
}
- } catch (InvocationTargetException ite) {
- exception = null;
- } catch (IllegalAccessException iae) {
- exception = null;
- } catch (NoSuchMethodException nsme) {
- exception = null;
}
+ } finally {
+ // ensure output is written
+ s.flush();
}
- // insure output is written
- s.flush();
}
}
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java b/jaxp/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java
index 4d384a418a7..b0ae3a4cb40 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java
@@ -28,7 +28,6 @@ package javax.xml.validation;
import java.io.File;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.net.URL;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java b/jaxp/src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java
index 1f1741e83b2..0416527be15 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java
@@ -41,13 +41,10 @@ class SecuritySupport {
ClassLoader getContextClassLoader() {
return
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public ClassLoader run() {
- ClassLoader cl = null;
- //try {
- cl = Thread.currentThread().getContextClassLoader();
- //} catch (SecurityException ex) { }
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null)
cl = ClassLoader.getSystemClassLoader();
return cl;
@@ -56,7 +53,7 @@ class SecuritySupport {
}
String getSystemProperty(final String propName) {
- return AccessController.doPrivileged(new PrivilegedAction() {
+ return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public String run() {
return System.getProperty(propName);
@@ -69,7 +66,7 @@ class SecuritySupport {
{
try {
return AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
+ new PrivilegedExceptionAction<>() {
@Override
public FileInputStream run() throws FileNotFoundException {
return new FileInputStream(file);
@@ -82,7 +79,7 @@ class SecuritySupport {
// Used for debugging purposes
String getClassSource(Class> cls) {
- return AccessController.doPrivileged(new PrivilegedAction() {
+ return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public String run() {
CodeSource cs = cls.getProtectionDomain().getCodeSource();
@@ -97,7 +94,7 @@ class SecuritySupport {
}
boolean doesFileExist(final File f) {
- return AccessController.doPrivileged(new PrivilegedAction() {
+ return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Boolean run() {
return f.exists();
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/xpath/SecuritySupport.java b/jaxp/src/java.xml/share/classes/javax/xml/xpath/SecuritySupport.java
index 9df3ec2c99a..f7b5cc41d97 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/xpath/SecuritySupport.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/xpath/SecuritySupport.java
@@ -40,7 +40,7 @@ class SecuritySupport {
ClassLoader getContextClassLoader() {
- return AccessController.doPrivileged(new PrivilegedAction() {
+ return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public ClassLoader run() {
ClassLoader cl = null;
@@ -53,7 +53,7 @@ class SecuritySupport {
}
String getSystemProperty(final String propName) {
- return AccessController.doPrivileged(new PrivilegedAction() {
+ return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public String run() {
return System.getProperty(propName);
@@ -66,7 +66,7 @@ class SecuritySupport {
{
try {
return AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
+ new PrivilegedExceptionAction<>() {
@Override
public FileInputStream run() throws FileNotFoundException {
return new FileInputStream(file);
@@ -79,7 +79,7 @@ class SecuritySupport {
// Used for debugging purposes
String getClassSource(Class> cls) {
- return AccessController.doPrivileged(new PrivilegedAction() {
+ return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public String run() {
CodeSource cs = cls.getProtectionDomain().getCodeSource();
@@ -94,7 +94,7 @@ class SecuritySupport {
}
boolean doesFileExist(final File f) {
- return AccessController.doPrivileged(new PrivilegedAction() {
+ return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Boolean run() {
return f.exists();
diff --git a/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java b/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java
index 6263959a9a6..dc950cbc896 100644
--- a/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java
+++ b/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java
@@ -28,7 +28,6 @@ package javax.xml.xpath;
import java.io.File;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.net.URL;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
diff --git a/jaxp/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java b/jaxp/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java
index 48fda761e1e..6099cf3cb32 100644
--- a/jaxp/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java
+++ b/jaxp/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java
@@ -333,59 +333,36 @@ public final class DOMImplementationRegistry {
}
/**
- * A simple JRE (Java Runtime Environment) 1.1 test
- *
- * @return true if JRE 1.1
- */
- private static boolean isJRE11() {
- try {
- Class c = Class.forName("java.security.AccessController");
- // java.security.AccessController existed since 1.2 so, if no
- // exception was thrown, the DOM application is running in a JRE
- // 1.2 or higher
- return false;
- } catch (Exception ex) {
- // ignore
- }
- return true;
- }
-
- /**
- * This method returns the ContextClassLoader or null if
- * running in a JRE 1.1
+ * This method returns the ContextClassLoader.
*
* @return The Context Classloader
*/
private static ClassLoader getContextClassLoader() {
- return isJRE11()
- ? null
- : (ClassLoader)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- ClassLoader classLoader = null;
- try {
- classLoader =
- Thread.currentThread().getContextClassLoader();
- } catch (SecurityException ex) {
- }
- return classLoader;
+ return AccessController.doPrivileged(new PrivilegedAction<>() {
+ @Override
+ public ClassLoader run() {
+ ClassLoader classLoader = null;
+ try {
+ classLoader =
+ Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
}
- });
+ return classLoader;
+ }
+ });
}
/**
* This method returns the system property indicated by the specified name
- * after checking access control privileges. For a JRE 1.1, this check is
- * not done.
+ * after checking access control privileges.
*
* @param name the name of the system property
* @return the system property
*/
private static String getSystemProperty(final String name) {
- return isJRE11()
- ? (String) System.getProperty(name)
- : (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ return AccessController.doPrivileged(new PrivilegedAction<>() {
+ @Override
+ public String run() {
return System.getProperty(name);
}
});
@@ -394,7 +371,7 @@ public final class DOMImplementationRegistry {
/**
* This method returns an Inputstream for the reading resource
* META_INF/services/org.w3c.dom.DOMImplementationSourceList after checking
- * access control privileges. For a JRE 1.1, this check is not done.
+ * access control privileges.
*
* @param classLoader classLoader
* @param name the resource
@@ -402,28 +379,18 @@ public final class DOMImplementationRegistry {
*/
private static InputStream getResourceAsStream(final ClassLoader classLoader,
final String name) {
- if (isJRE11()) {
- InputStream ris;
- if (classLoader == null) {
- ris = ClassLoader.getSystemResourceAsStream(name);
- } else {
- ris = classLoader.getResourceAsStream(name);
- }
- return ris;
- } else {
- return (InputStream)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- InputStream ris;
- if (classLoader == null) {
- ris =
- ClassLoader.getSystemResourceAsStream(name);
- } else {
- ris = classLoader.getResourceAsStream(name);
- }
- return ris;
- }
- });
- }
+ return AccessController.doPrivileged(new PrivilegedAction<>() {
+ @Override
+ public InputStream run() {
+ InputStream ris;
+ if (classLoader == null) {
+ ris =
+ ClassLoader.getSystemResourceAsStream(name);
+ } else {
+ ris = classLoader.getResourceAsStream(name);
+ }
+ return ris;
+ }
+ });
}
}
diff --git a/jaxws/.hgtags b/jaxws/.hgtags
index 9808e797b01..b00513266ab 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -316,3 +316,5 @@ c9785bc8ade98a16a050d7520b70c68363857e00 jdk9-b67
b5878b03d1b2e105917d959fbfa3c57c22495803 jdk9-b68
f5911c6155c29ac24b6f9068273207e5ebd3a3df jdk9-b69
94084caa27a3c8a09a7510aef596ebd64e97c569 jdk9-b70
+61caeb7061bbf8cc74a767997e5d17cc00712629 jdk9-b71
+1d87054e2d2f405c114f0061b97cbf8214bddf0a jdk9-b72
diff --git a/jaxws/src/java.activation/share/classes/com/sun/activation/registries/MailcapTokenizer.java b/jaxws/src/java.activation/share/classes/com/sun/activation/registries/MailcapTokenizer.java
index 225d7e15a8e..9ece7dc645d 100644
--- a/jaxws/src/java.activation/share/classes/com/sun/activation/registries/MailcapTokenizer.java
+++ b/jaxws/src/java.activation/share/classes/com/sun/activation/registries/MailcapTokenizer.java
@@ -42,7 +42,7 @@ public class MailcapTokenizer {
/**
* Constructor
*
- * @parameter inputString the string to tokenize
+ * @param inputString the string to tokenize
*/
public MailcapTokenizer(String inputString) {
data = inputString;
@@ -73,7 +73,7 @@ public class MailcapTokenizer {
/**
* Retrieve current token.
*
- * @returns The current token value
+ * @return The current token value
*/
public int getCurrentToken() {
return currentToken;
@@ -115,7 +115,7 @@ public class MailcapTokenizer {
/*
* Retrieve current token value.
*
- * @returns A String containing the current token value
+ * @return A String containing the current token value
*/
public String getCurrentTokenValue() {
return currentTokenValue;
@@ -123,7 +123,7 @@ public class MailcapTokenizer {
/*
* Process the next token.
*
- * @returns the next token
+ * @return the next token
*/
public int nextToken() {
if (dataIndex < dataLength) {
diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java
index 376b6738cb5..c5185236400 100644
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java
@@ -34,8 +34,7 @@ import java.io.IOException;
import java.io.InputStream;
/**
- *
- * The JAXBContext class provides the client's entry point to the
+ * The {@code JAXBContext} class provides the client's entry point to the
* JAXB API. It provides an abstraction for managing the XML/Java binding
* information necessary to implement the JAXB binding framework operations:
* unmarshal, marshal and validate.
@@ -62,16 +61,16 @@ import java.io.InputStream;
*
* The following JAXB 1.0 requirement is only required for schema to
* java interface/implementation binding. It does not apply to JAXB annotated
- * classes. JAXB Providers must generate a jaxb.properties file in
+ * classes. JAXB Providers must generate a {@code jaxb.properties} file in
* each package containing schema derived classes. The property file must
- * contain a property named javax.xml.bind.context.factory whose
- * value is the name of the class that implements the createContext
+ * contain a property named {@code javax.xml.bind.context.factory} whose
+ * value is the name of the class that implements the {@code createContext}
* APIs.
*
*
* The class supplied by the provider does not have to be assignable to
- * javax.xml.bind.JAXBContext, it simply has to provide a class that
- * implements the createContext APIs.
+ * {@code javax.xml.bind.JAXBContext}, it simply has to provide a class that
+ * implements the {@code createContext} APIs.
*
*
* In addition, the provider must call the
@@ -91,13 +90,13 @@ import java.io.InputStream;
* Additionally, the unmarshal method allows for an unrecognized root element that
* has an xsi:type attribute's value that references a type definition declared in
* the schema to be unmarshalled as the root of an instance document.
- * The JAXBContext object
+ * The {@code JAXBContext} object
* allows the merging of global elements and type definitions across a set of schemas (listed
- * in the contextPath). Since each schema in the schema set can belong
+ * in the {@code contextPath}). Since each schema in the schema set can belong
* to distinct namespaces, the unification of schemas to an unmarshalling
* context should be namespace independent. This means that a client
* application is able to unmarshal XML documents that are instances of
- * any of the schemas listed in the contextPath. For example:
+ * any of the schemas listed in the {@code contextPath}. For example:
*
*
* JAXBContext jc = JAXBContext.newInstance( "com.acme.foo:com.acme.bar" );
@@ -114,12 +113,12 @@ import java.io.InputStream;
* For schema-derived interface/implementation classes and for the
* creation of elements that are not bound to a JAXB-annotated
* class, an application needs to have access and knowledge about each of
- * the schema derived ObjectFactory classes that exist in each of
- * java packages contained in the contextPath. For each schema
+ * the schema derived {@code ObjectFactory} classes that exist in each of
+ * java packages contained in the {@code contextPath}. For each schema
* derived java class, there is a static factory method that produces objects
* of that type. For example,
- * assume that after compiling a schema, you have a package com.acme.foo
- * that contains a schema derived interface named PurchaseOrder. In
+ * assume that after compiling a schema, you have a package {@code com.acme.foo}
+ * that contains a schema derived interface named {@code PurchaseOrder}. In
* order to create objects of that type, the client application would use the
* factory method like this:
*
@@ -133,25 +132,25 @@ import java.io.InputStream;
* it can use the mutator methods to set content on it.
*
*
- * For more information on the generated ObjectFactory classes, see
+ * For more information on the generated {@code ObjectFactory} classes, see
* Section 4.2 Java Package of the specification.
*
*
* The provider must generate a class in each
* package that contains all of the necessary object factory methods for that
* package named ObjectFactory as well as the static
- * newInstance( javaContentInterface ) method
+ * {@code newInstance( javaContentInterface )} method
*
*
Marshalling
*
* The {@link Marshaller} class provides the client application the ability
* to convert a Java content tree back into XML data. There is no difference
* between marshalling a content tree that is created manually using the factory
- * methods and marshalling a content tree that is the result an unmarshal
- * operation. Clients can marshal a java content tree back to XML data
- * to a java.io.OutputStream or a java.io.Writer. The
+ * methods and marshalling a content tree that is the result an {@code unmarshal}
+ * operation. Clients can marshal a java content tree back to XML data
+ * to a {@code java.io.OutputStream} or a {@code java.io.Writer}. The
* marshalling process can alternatively produce SAX2 event streams to a
- * registered ContentHandler or produce a DOM Node object.
+ * registered {@code ContentHandler} or produce a DOM Node object.
* Client applications have control over the output encoding as well as
* whether or not to marshal the XML data as a complete document or
* as a fragment.
@@ -178,7 +177,7 @@ import java.io.InputStream;
* Validation has been changed significantly since JAXB 1.0. The {@link Validator}
* class has been deprecated and made optional. This means that you are advised
* not to use this class and, in fact, it may not even be available depending on
- * your JAXB provider. JAXB 1.0 client applications that rely on Validator
+ * your JAXB provider. JAXB 1.0 client applications that rely on {@code Validator}
* will still work properly when deployed with the JAXB 1.0 runtime system.
*
* In JAXB 2.0, the {@link Unmarshaller} has included convenince methods that expose
@@ -192,8 +191,8 @@ import java.io.InputStream;
* The following JAXB 1.0 restriction only applies to binding schema to
* interfaces/implementation classes.
* Since this binding does not require a common runtime system, a JAXB
- * client application must not attempt to mix runtime objects (JAXBContext,
- * Marshaller, etc. ) from different providers. This does not
+ * client application must not attempt to mix runtime objects ({@code JAXBContext,
+ * Marshaller}, etc. ) from different providers. This does not
* mean that the client application isn't portable, it simply means that a
* client has to use a runtime system provided by the same provider that was
* used to compile the schema.
@@ -201,14 +200,14 @@ import java.io.InputStream;
*
*
Discovery of JAXB implementation
*
- * When one of the newInstance methods is called, a JAXB implementation is discovered
+ * When one of the {@code newInstance} methods is called, a JAXB implementation is discovered
* by the following steps.
*
*
*
*
* For each package/class explicitly passed in to the {@link #newInstance} method, in the order they are specified,
- * jaxb.properties file is looked up in its package, by using the associated classloader —
+ * {@code jaxb.properties} file is looked up in its package, by using the associated classloader —
* this is {@link Class#getClassLoader() the owner class loader} for a {@link Class} argument, and for a package
* the specified {@link ClassLoader}.
*
@@ -269,8 +268,6 @@ import java.io.InputStream;
* {@link javax.xml.bind.JAXBContextFactory#createContext(Class[], java.util.Map)} is invoked
* to create a {@link JAXBContext}.
*
- *
- *
* @apiNote
*
Service discovery method using file /META-INF/services/javax.xml.bind.JAXBContext (described in step 4)
* and leveraging provider's static methods is supported only to allow backwards compatibility, but it is strongly
@@ -294,7 +291,7 @@ public abstract class JAXBContext {
/**
* The name of the property that contains the name of the class capable
- * of creating new JAXBContext objects.
+ * of creating new {@code JAXBContext} objects.
*/
public static final String JAXB_CONTEXT_FACTORY = "javax.xml.bind.JAXBContextFactory";
@@ -303,8 +300,7 @@ public abstract class JAXBContext {
/**
- *
- * Create a new instance of a JAXBContext class.
+ * Create a new instance of a {@code JAXBContext} class.
*
*
* This is a convenience method to invoke the
@@ -312,7 +308,7 @@ public abstract class JAXBContext {
* the context class loader of the current thread.
*
* @throws JAXBException if an error was encountered while creating the
- * JAXBContext such as
+ * {@code JAXBContext} such as
*
*
failure to locate either ObjectFactory.class or jaxb.index in the packages
*
an ambiguity among global elements contained in the contextPath
@@ -328,8 +324,7 @@ public abstract class JAXBContext {
}
/**
- *
- * Create a new instance of a JAXBContext class.
+ * Create a new instance of a {@code JAXBContext} class.
*
*
* The client application must supply a context path which is a list of
@@ -340,7 +335,7 @@ public abstract class JAXBContext {
* ObjectFactory.class generated per package.
* Alternatively than being listed in the context path, programmer
* annotated JAXB mapped classes can be listed in a
- * jaxb.index resource file, format described below.
+ * {@code jaxb.index} resource file, format described below.
* Note that a java package can contain both schema-derived classes and
* user annotated JAXB classes. Additionally, the java package may
* contain JAXB package annotations that must be processed. (see JLS,
@@ -349,7 +344,7 @@ public abstract class JAXBContext {
*
*
* Every package listed on the contextPath must meet one or both of the
- * following conditions otherwise a JAXBException will be thrown:
+ * following conditions otherwise a {@code JAXBException} will be thrown:
*
*
*
it must contain ObjectFactory.class
@@ -367,12 +362,12 @@ public abstract class JAXBContext {
* are reachable, as defined in {@link #newInstance(Class...)}, from the
* listed classes are also registered with JAXBContext.
*
- * Constraints on class name occuring in a jaxb.index file are:
+ * Constraints on class name occuring in a {@code jaxb.index} file are:
*
*
Must not end with ".class".
*
Class names are resolved relative to package containing
- * jaxb.index file. Only classes occuring directly in package
- * containing jaxb.index file are allowed.
+ * {@code jaxb.index} file. Only classes occuring directly in package
+ * containing {@code jaxb.index} file are allowed.
*
Fully qualified class names are not allowed.
* A qualified class name,relative to current package,
* is only allowed to specify a nested or inner class.
@@ -381,21 +376,21 @@ public abstract class JAXBContext {
*
* To maintain compatibility with JAXB 1.0 schema to java
* interface/implementation binding, enabled by schema customization
- * {@literal },
+ * {@code },
* the JAXB provider will ensure that each package on the context path
- * has a jaxb.properties file which contains a value for the
- * javax.xml.bind.context.factory property and that all values
+ * has a {@code jaxb.properties} file which contains a value for the
+ * {@code javax.xml.bind.context.factory} property and that all values
* resolve to the same provider. This requirement does not apply to
* JAXB annotated classes.
*
*
* If there are any global XML element name collisions across the various
- * packages listed on the contextPath, a JAXBException
+ * packages listed on the {@code contextPath}, a {@code JAXBException}
* will be thrown.
*
*
* Mixing generated interface/impl bindings from multiple JAXB Providers
- * in the same context path may result in a JAXBException
+ * in the same context path may result in a {@code JAXBException}
* being thrown.
*
*
@@ -408,9 +403,9 @@ public abstract class JAXBContext {
* This class loader will be used to locate the implementation
* classes.
*
- * @return a new instance of a JAXBContext
+ * @return a new instance of a {@code JAXBContext}
* @throws JAXBException if an error was encountered while creating the
- * JAXBContext such as
+ * {@code JAXBContext} such as
*
*
failure to locate either ObjectFactory.class or jaxb.index in the packages
*
an ambiguity among global elements contained in the contextPath
@@ -424,8 +419,7 @@ public abstract class JAXBContext {
}
/**
- *
- * Create a new instance of a JAXBContext class.
+ * Create a new instance of a {@code JAXBContext} class.
*
*
* This is mostly the same as {@link JAXBContext#newInstance(String, ClassLoader)},
@@ -434,7 +428,7 @@ public abstract class JAXBContext {
*
*
* The interpretation of properties is up to implementations. Implementations should
- * throw JAXBException if it finds properties that it doesn't understand.
+ * throw {@code JAXBException} if it finds properties that it doesn't understand.
*
* @param contextPath list of java package names that contain schema derived classes
* @param classLoader
@@ -443,9 +437,9 @@ public abstract class JAXBContext {
* provider-specific properties. Can be null, which means the same thing as passing
* in an empty map.
*
- * @return a new instance of a JAXBContext
+ * @return a new instance of a {@code JAXBContext}
* @throws JAXBException if an error was encountered while creating the
- * JAXBContext such as
+ * {@code JAXBContext} such as
*
*
failure to locate either ObjectFactory.class or jaxb.index in the packages
*
an ambiguity among global elements contained in the contextPath
@@ -472,8 +466,7 @@ public abstract class JAXBContext {
// TODO: resurrect this once we introduce external annotations
// /**
-// *
-// * Create a new instance of a JAXBContext class.
+// * Create a new instance of a {@code JAXBContext} class.
// *
// *
// * The client application must supply a list of classes that the new
@@ -484,8 +477,8 @@ public abstract class JAXBContext {
// * referenced statically from the specified classes.
// *
// * For example, in the following Java code, if you do
-// * newInstance(Foo.class), the newly created {@link JAXBContext}
-// * will recognize both Foo and Bar, but not Zot:
+// * {@code newInstance(Foo.class)}, the newly created {@link JAXBContext}
+// * will recognize both {@code Foo} and {@code Bar}, but not {@code Zot}:
// *
// * class Foo {
// * Bar b;
@@ -509,11 +502,11 @@ public abstract class JAXBContext {
// * spec-defined classes will be returned.
// *
// * @return
-// * A new instance of a JAXBContext.
+// * A new instance of a {@code JAXBContext}.
// *
// * @throws JAXBException
// * if an error was encountered while creating the
-// * JAXBContext, such as (but not limited to):
+// * {@code JAXBContext}, such as (but not limited to):
// *
// *
No JAXB implementation was discovered
// *
Classes use JAXB annotations incorrectly
@@ -546,8 +539,7 @@ public abstract class JAXBContext {
// }
/**
- *
- * Create a new instance of a JAXBContext class.
+ * Create a new instance of a {@code JAXBContext} class.
*
*
* The client application must supply a list of classes that the new
@@ -556,12 +548,12 @@ public abstract class JAXBContext {
* Not only the new context will recognize all the classes specified,
* but it will also recognize any classes that are directly/indirectly
* referenced statically from the specified classes. Subclasses of
- * referenced classes nor @XmlTransient referenced classes
+ * referenced classes nor {@code @XmlTransient} referenced classes
* are not registered with JAXBContext.
*
* For example, in the following Java code, if you do
- * newInstance(Foo.class), the newly created {@link JAXBContext}
- * will recognize both Foo and Bar, but not Zot or FooBar:
+ * {@code newInstance(Foo.class)}, the newly created {@link JAXBContext}
+ * will recognize both {@code Foo} and {@code Bar}, but not {@code Zot} or {@code FooBar}:
*
* class Foo {
* @XmlTransient FooBar c;
@@ -589,11 +581,11 @@ public abstract class JAXBContext {
* spec-defined classes will be returned.
*
* @return
- * A new instance of a JAXBContext.
+ * A new instance of a {@code JAXBContext}.
*
* @throws JAXBException
* if an error was encountered while creating the
- * JAXBContext, such as (but not limited to):
+ * {@code JAXBContext}, such as (but not limited to):
*
*
No JAXB implementation was discovered
*
Classes use JAXB annotations incorrectly
@@ -615,8 +607,7 @@ public abstract class JAXBContext {
}
/**
- *
- * Create a new instance of a JAXBContext class.
+ * Create a new instance of a {@code JAXBContext} class.
*
*
* An overloading of {@link JAXBContext#newInstance(Class...)}
@@ -624,7 +615,7 @@ public abstract class JAXBContext {
*
*
* The interpretation of properties is up to implementations. Implementations should
- * throw JAXBException if it finds properties that it doesn't understand.
+ * throw {@code JAXBException} if it finds properties that it doesn't understand.
*
* @param classesToBeBound
* list of java classes to be recognized by the new {@link JAXBContext}.
@@ -635,11 +626,11 @@ public abstract class JAXBContext {
* in an empty map.
*
* @return
- * A new instance of a JAXBContext.
+ * A new instance of a {@code JAXBContext}.
*
* @throws JAXBException
* if an error was encountered while creating the
- * JAXBContext, such as (but not limited to):
+ * {@code JAXBContext}, such as (but not limited to):
*
*
No JAXB implementation was discovered
*
Classes use JAXB annotations incorrectly
@@ -672,25 +663,25 @@ public abstract class JAXBContext {
}
/**
- * Create an Unmarshaller object that can be used to convert XML
+ * Create an {@code Unmarshaller} object that can be used to convert XML
* data into a java content tree.
*
- * @return an Unmarshaller object
+ * @return an {@code Unmarshaller} object
*
* @throws JAXBException if an error was encountered while creating the
- * Unmarshaller object
+ * {@code Unmarshaller} object
*/
public abstract Unmarshaller createUnmarshaller() throws JAXBException;
/**
- * Create a Marshaller object that can be used to convert a
+ * Create a {@code Marshaller} object that can be used to convert a
* java content tree into XML data.
*
- * @return a Marshaller object
+ * @return a {@code Marshaller} object
*
* @throws JAXBException if an error was encountered while creating the
- * Marshaller object
+ * {@code Marshaller} object
*/
public abstract Marshaller createMarshaller() throws JAXBException;
@@ -699,27 +690,27 @@ public abstract class JAXBContext {
* {@link Validator} has been made optional and deprecated in JAXB 2.0. Please
* refer to the javadoc for {@link Validator} for more detail.
*
- * Create a Validator object that can be used to validate a
+ * Create a {@code Validator} object that can be used to validate a
* java content tree against its source schema.
*
- * @return a Validator object
+ * @return a {@code Validator} object
*
* @throws JAXBException if an error was encountered while creating the
- * Validator object
+ * {@code Validator} object
* @deprecated since JAXB2.0
*/
public abstract Validator createValidator() throws JAXBException;
/**
- * Creates a Binder object that can be used for
+ * Creates a {@code Binder} object that can be used for
* associative/in-place unmarshalling/marshalling.
*
* @param domType select the DOM API to use by passing in its DOM Node class.
*
- * @return always a new valid Binder object.
+ * @return always a new valid {@code Binder} object.
*
* @throws UnsupportedOperationException
- * if DOM API corresponding to domType is not supported by
+ * if DOM API corresponding to {@code domType} is not supported by
* the implementation.
*
* @since 1.6, JAXB 2.0
@@ -731,9 +722,9 @@ public abstract class JAXBContext {
}
/**
- * Creates a Binder for W3C DOM.
+ * Creates a {@code Binder} for W3C DOM.
*
- * @return always a new valid Binder object.
+ * @return always a new valid {@code Binder} object.
*
* @since 1.6, JAXB 2.0
*/
@@ -742,11 +733,11 @@ public abstract class JAXBContext {
}
/**
- * Creates a JAXBIntrospector object that can be used to
+ * Creates a {@code JAXBIntrospector} object that can be used to
* introspect JAXB objects.
*
* @return
- * always return a non-null valid JAXBIntrospector object.
+ * always return a non-null valid {@code JAXBIntrospector} object.
*
* @throws UnsupportedOperationException
* Calling this method on JAXB 1.0 implementations will throw
diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html
index 57f80e44acd..4fc54e34dc4 100644
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html
@@ -239,7 +239,7 @@
For a property, a given annotation can be applied to
either read or write property but not both.
-
+
A property name must be different from any other
property name in any of the super classes of the
class being mapped.
@@ -250,8 +250,8 @@
Notations
Namespace prefixes
The following namespace prefixes are used in the XML Schema
- fragments in this package.
* If there is a security manager, its {@code checkConnect}
* method is called for each InetAddress. Only InetAddresses where
@@ -104,53 +108,56 @@ public final class NetworkInterface {
* will be returned in the Enumeration. However, if the caller has the
* {@link NetPermission}("getNetworkInformation") permission, then all
* InetAddresses are returned.
+ *
* @return an Enumeration object with all or a subset of the InetAddresses
* bound to this network interface
+ * @see #inetAddresses()
*/
public Enumeration getInetAddresses() {
+ return enumerationFromArray(getCheckedInetAddresses());
+ }
- class checkedAddresses implements Enumeration {
+ /**
+ * Get a Stream of all or a subset of the InetAddresses bound to this
+ * network interface.
+ *
+ * If there is a security manager, its {@code checkConnect}
+ * method is called for each InetAddress. Only InetAddresses where
+ * the {@code checkConnect} doesn't throw a SecurityException will be
+ * returned in the Stream. However, if the caller has the
+ * {@link NetPermission}("getNetworkInformation") permission, then all
+ * InetAddresses are returned.
+ *
+ * @return a Stream object with all or a subset of the InetAddresses
+ * bound to this network interface
+ * @since 1.9
+ */
+ public Stream inetAddresses() {
+ return streamFromArray(getCheckedInetAddresses());
+ }
- private int i=0, count=0;
- private InetAddress local_addrs[];
+ private InetAddress[] getCheckedInetAddresses() {
+ InetAddress[] local_addrs = new InetAddress[addrs.length];
+ boolean trusted = true;
- checkedAddresses() {
- local_addrs = new InetAddress[addrs.length];
- boolean trusted = true;
-
- SecurityManager sec = System.getSecurityManager();
- if (sec != null) {
- try {
- sec.checkPermission(new NetPermission("getNetworkInformation"));
- } catch (SecurityException e) {
- trusted = false;
- }
- }
- for (int j=0; j getSubInterfaces() {
- class subIFs implements Enumeration {
-
- private int i=0;
-
- subIFs() {
- }
-
- public NetworkInterface nextElement() {
- if (i < childs.length) {
- return childs[i++];
- } else {
- throw new NoSuchElementException();
- }
- }
-
- public boolean hasMoreElements() {
- return (i < childs.length);
- }
- }
- return new subIFs();
+ return enumerationFromArray(childs);
+ }
+ /**
+ * Get a Stream of all subinterfaces (also known as virtual
+ * interfaces) attached to this network interface.
+ *
+ * @return a Stream object with all of the subinterfaces
+ * of this network interface
+ * @since 1.9
+ */
+ public Stream subInterfaces() {
+ return streamFromArray(childs);
}
/**
@@ -326,43 +326,80 @@ public final class NetworkInterface {
}
/**
- * Returns all the interfaces on this machine. The {@code Enumeration}
- * contains at least one element, possibly representing a loopback
- * interface that only supports communication between entities on
+ * Returns an {@code Enumeration} of all the interfaces on this machine. The
+ * {@code Enumeration} contains at least one element, possibly representing
+ * a loopback interface that only supports communication between entities on
* this machine.
*
- * NOTE: can use getNetworkInterfaces()+getInetAddresses()
- * to obtain all IP addresses for this node
+ * @apiNote this method can be used in combination with
+ * {@link #getInetAddresses()} to obtain all IP addresses for this node
*
* @return an Enumeration of NetworkInterfaces found on this machine
* @exception SocketException if an I/O error occurs.
+ * @see #networkInterfaces()
*/
-
public static Enumeration getNetworkInterfaces()
throws SocketException {
- final NetworkInterface[] netifs = getAll();
+ NetworkInterface[] netifs = getAll();
+ assert netifs != null && netifs.length > 0;
- // specified to return null if no network interfaces
- if (netifs == null)
- return null;
+ return enumerationFromArray(netifs);
+ }
+ /**
+ * Returns a {@code Stream} of all the interfaces on this machine. The
+ * {@code Stream} contains at least one interface, possibly representing a
+ * loopback interface that only supports communication between entities on
+ * this machine.
+ *
+ * @apiNote this method can be used in combination with
+ * {@link #inetAddresses()}} to obtain a stream of all IP addresses for
+ * this node, for example:
+ *
+ *
+ * @return a Stream of NetworkInterfaces found on this machine
+ * @exception SocketException if an I/O error occurs.
+ * @since 1.9
+ */
+ public static Stream networkInterfaces()
+ throws SocketException {
+ NetworkInterface[] netifs = getAll();
+ assert netifs != null && netifs.length > 0;
+
+ return streamFromArray(netifs);
+ }
+
+ private static Enumeration enumerationFromArray(T[] a) {
return new Enumeration<>() {
- private int i = 0;
- public NetworkInterface nextElement() {
- if (netifs != null && i < netifs.length) {
- NetworkInterface netif = netifs[i++];
- return netif;
+ int i = 0;
+
+ @Override
+ public T nextElement() {
+ if (i < a.length) {
+ return a[i++];
} else {
throw new NoSuchElementException();
}
}
+ @Override
public boolean hasMoreElements() {
- return (netifs != null && i < netifs.length);
+ return i < a.length;
}
};
}
+ private static Stream streamFromArray(T[] a) {
+ return StreamSupport.stream(
+ Spliterators.spliterator(
+ a,
+ Spliterator.DISTINCT | Spliterator.IMMUTABLE | Spliterator.NONNULL),
+ false);
+ }
+
private native static NetworkInterface[] getAll()
throws SocketException;
diff --git a/jdk/src/java.base/share/classes/java/net/SocksSocketImpl.java b/jdk/src/java.base/share/classes/java/net/SocksSocketImpl.java
index 573945b9632..f7974d0d705 100644
--- a/jdk/src/java.base/share/classes/java/net/SocksSocketImpl.java
+++ b/jdk/src/java.base/share/classes/java/net/SocksSocketImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import sun.net.SocksProxy;
+import sun.net.spi.DefaultProxySelector;
import sun.net.www.ParseUtil;
/* import org.ietf.jgss.*; */
@@ -69,12 +70,21 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
server = ad.getHostString();
serverPort = ad.getPort();
}
+ useV4 = useV4(proxy);
}
void setV4() {
useV4 = true;
}
+ private static boolean useV4(Proxy proxy) {
+ if (proxy instanceof SocksProxy
+ && ((SocksProxy)proxy).protocolVersion() == 4) {
+ return true;
+ }
+ return DefaultProxySelector.socksProxyVersion() == 4;
+ }
+
private synchronized void privilegedConnect(final String host,
final int port,
final int timeout)
@@ -398,11 +408,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
// Use getHostString() to avoid reverse lookups
server = ((InetSocketAddress) p.address()).getHostString();
serverPort = ((InetSocketAddress) p.address()).getPort();
- if (p instanceof SocksProxy) {
- if (((SocksProxy)p).protocolVersion() == 4) {
- useV4 = true;
- }
- }
+ useV4 = useV4(p);
// Connects to the SOCKS server
try {
@@ -715,11 +721,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
// Use getHostString() to avoid reverse lookups
server = ((InetSocketAddress) p.address()).getHostString();
serverPort = ((InetSocketAddress) p.address()).getPort();
- if (p instanceof SocksProxy) {
- if (((SocksProxy)p).protocolVersion() == 4) {
- useV4 = true;
- }
- }
+ useV4 = useV4(p);
// Connects to the SOCKS server
try {
diff --git a/jdk/src/java.base/share/classes/java/net/URI.java b/jdk/src/java.base/share/classes/java/net/URI.java
index 89a9d50e52a..2896cf222e6 100644
--- a/jdk/src/java.base/share/classes/java/net/URI.java
+++ b/jdk/src/java.base/share/classes/java/net/URI.java
@@ -2018,7 +2018,7 @@ public final class URI
StringBuilder sb = new StringBuilder(base.length() + cn);
// 5.2 (6a)
if (i >= 0)
- sb.append(base.substring(0, i + 1));
+ sb.append(base, 0, i + 1);
// 5.2 (6b)
sb.append(child);
path = sb.toString();
@@ -2686,7 +2686,7 @@ public final class URI
if (!match(c, lowMask, highMask)) {
if (sb == null) {
sb = new StringBuffer();
- sb.append(s.substring(0, i));
+ sb.append(s, 0, i);
}
appendEscape(sb, (byte)c);
} else {
@@ -2698,7 +2698,7 @@ public final class URI
|| Character.isISOControl(c))) {
if (sb == null) {
sb = new StringBuffer();
- sb.append(s.substring(0, i));
+ sb.append(s, 0, i);
}
appendEncoded(sb, c);
} else {
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 5e588602c97..f2ca4129309 100644
--- a/jdk/src/java.base/share/classes/java/security/AccessControlContext.java
+++ b/jdk/src/java.base/share/classes/java/security/AccessControlContext.java
@@ -76,7 +76,7 @@ import sun.security.util.SecurityConstants;
public final class AccessControlContext {
- private ProtectionDomain context[];
+ private ProtectionDomain[] context;
// isPrivileged and isAuthorized are referenced by the VM - do not remove
// or change their names
private boolean isPrivileged;
@@ -89,13 +89,13 @@ public final class AccessControlContext {
private DomainCombiner combiner = null;
// limited privilege scope
- private Permission permissions[];
+ private Permission[] permissions;
private AccessControlContext parent;
private boolean isWrapped;
// is constrained by limited privilege scope?
private boolean isLimited;
- private ProtectionDomain limitedContext[];
+ private ProtectionDomain[] limitedContext;
private static boolean debugInit = false;
private static Debug debug = null;
@@ -123,7 +123,7 @@ public final class AccessControlContext {
* changes to the array will not affect this AccessControlContext.
* @throws NullPointerException if {@code context} is {@code null}
*/
- public AccessControlContext(ProtectionDomain context[])
+ public AccessControlContext(ProtectionDomain[] context)
{
if (context.length == 0) {
this.context = null;
@@ -282,7 +282,7 @@ public final class AccessControlContext {
* package private constructor for AccessController.getContext()
*/
- AccessControlContext(ProtectionDomain context[],
+ AccessControlContext(ProtectionDomain[] context,
boolean isPrivileged)
{
this.context = context;
@@ -643,7 +643,7 @@ public final class AccessControlContext {
/*
* Combine the current (stack) and assigned domains.
*/
- private static ProtectionDomain[] combine(ProtectionDomain[]current,
+ private static ProtectionDomain[] combine(ProtectionDomain[] current,
ProtectionDomain[] assigned) {
// current could be null if only system code is on the stack;
@@ -666,7 +666,7 @@ public final class AccessControlContext {
int n = (skipAssigned) ? 0 : assigned.length;
// now we combine both of them, and create a new context
- ProtectionDomain pd[] = new ProtectionDomain[slen + n];
+ ProtectionDomain[] pd = new ProtectionDomain[slen + n];
// first copy in the assigned context domains, no need to compress
if (!skipAssigned) {
@@ -695,7 +695,7 @@ public final class AccessControlContext {
} else if (skipAssigned && n == slen) {
return current;
}
- ProtectionDomain tmp[] = new ProtectionDomain[n];
+ ProtectionDomain[] tmp = new ProtectionDomain[n];
System.arraycopy(pd, 0, tmp, 0, n);
pd = tmp;
}
diff --git a/jdk/src/java.base/share/classes/java/security/CodeSource.java b/jdk/src/java.base/share/classes/java/security/CodeSource.java
index afd3fffd05f..c08050a9f03 100644
--- a/jdk/src/java.base/share/classes/java/security/CodeSource.java
+++ b/jdk/src/java.base/share/classes/java/security/CodeSource.java
@@ -65,7 +65,7 @@ public class CodeSource implements java.io.Serializable {
/*
* The code signers. Certificate chains are concatenated.
*/
- private transient java.security.cert.Certificate certs[] = null;
+ private transient java.security.cert.Certificate[] certs = null;
// cached SocketPermission used for matchLocation
private transient SocketPermission sp;
@@ -91,7 +91,7 @@ public class CodeSource implements java.io.Serializable {
* @param certs the certificate(s). It may be null. The contents of the
* array are copied to protect against subsequent modification.
*/
- public CodeSource(URL url, java.security.cert.Certificate certs[]) {
+ public CodeSource(URL url, java.security.cert.Certificate[] certs) {
this.location = url;
if (url != null) {
this.locationNoFragString = URLUtil.urlNoFragString(url);
diff --git a/jdk/src/java.base/share/classes/java/security/PermissionCollection.java b/jdk/src/java.base/share/classes/java/security/PermissionCollection.java
index 3f13b9f93d5..0aa6ce74bc4 100644
--- a/jdk/src/java.base/share/classes/java/security/PermissionCollection.java
+++ b/jdk/src/java.base/share/classes/java/security/PermissionCollection.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
@@ -26,6 +26,8 @@
package java.security;
import java.util.*;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
/**
* Abstract class representing a collection of Permission objects.
@@ -126,9 +128,34 @@ public abstract class PermissionCollection implements java.io.Serializable {
* Returns an enumeration of all the Permission objects in the collection.
*
* @return an enumeration of all the Permissions.
+ * @see #elementsAsStream()
*/
public abstract Enumeration elements();
+ /**
+ * Returns a stream of all the Permission objects in the collection.
+ *
+ *
The collection should not be modified (see {@link #add}) during the
+ * execution of the terminal stream operation. Otherwise, the result of the
+ * terminal stream operation is undefined.
+ *
+ * @implSpec
+ * The default implementation creates a stream whose source is derived from
+ * the enumeration returned from a call to {@link #elements()}.
+ *
+ * @return a stream of all the Permissions.
+ * @since 1.9
+ */
+ public Stream elementsAsStream() {
+ int characteristics = isReadOnly()
+ ? Spliterator.NONNULL | Spliterator.IMMUTABLE
+ : Spliterator.NONNULL;
+ return StreamSupport.stream(
+ Spliterators.spliteratorUnknownSize(
+ elements().asIterator(), characteristics),
+ false);
+ }
+
/**
* Marks this PermissionCollection object as "readonly". After
* a PermissionCollection object
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 b9a834a40da..6bb5fa1a445 100644
--- a/jdk/src/java.base/share/classes/java/security/Permissions.java
+++ b/jdk/src/java.base/share/classes/java/security/Permissions.java
@@ -289,9 +289,9 @@ implements Serializable
if (unresolvedPerms == null)
return null;
- java.security.cert.Certificate certs[] = null;
+ java.security.cert.Certificate[] certs = null;
- Object signers[] = p.getClass().getSigners();
+ Object[] signers = p.getClass().getSigners();
int n = 0;
if (signers != null) {
diff --git a/jdk/src/java.base/share/classes/java/security/SecureRandom.java b/jdk/src/java.base/share/classes/java/security/SecureRandom.java
index f1531de25f7..09b5a008f9c 100644
--- a/jdk/src/java.base/share/classes/java/security/SecureRandom.java
+++ b/jdk/src/java.base/share/classes/java/security/SecureRandom.java
@@ -69,7 +69,7 @@ import sun.security.util.Debug;
*
*
* SecureRandom random = new SecureRandom();
- * byte bytes[] = new byte[20];
+ * byte[] bytes = new byte[20];
* random.nextBytes(bytes);
*
*
@@ -77,7 +77,7 @@ import sun.security.util.Debug;
* to generate a given number of seed bytes (to seed other random number
* generators, for example):
*
*
* Note: Depending on the implementation, the {@code generateSeed} and
@@ -186,7 +186,7 @@ public class SecureRandom extends java.util.Random {
*
* @param seed the seed.
*/
- public SecureRandom(byte seed[]) {
+ public SecureRandom(byte[] seed) {
super(0);
getDefaultPRNG(true, seed);
}
@@ -486,7 +486,7 @@ public class SecureRandom extends java.util.Random {
@Override
final protected int next(int numBits) {
int numBytes = (numBits+7)/8;
- byte b[] = new byte[numBytes];
+ byte[] b = new byte[numBytes];
int next = 0;
nextBytes(b);
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 e5b0d3047aa..9827788806a 100644
--- a/jdk/src/java.base/share/classes/java/security/UnresolvedPermission.java
+++ b/jdk/src/java.base/share/classes/java/security/UnresolvedPermission.java
@@ -130,7 +130,7 @@ implements java.io.Serializable
*/
private String actions;
- private transient java.security.cert.Certificate certs[];
+ private transient java.security.cert.Certificate[] certs;
/**
* Creates a new UnresolvedPermission containing the permission
@@ -152,7 +152,7 @@ implements java.io.Serializable
public UnresolvedPermission(String type,
String name,
String actions,
- java.security.cert.Certificate certs[])
+ java.security.cert.Certificate[] certs)
{
super(type);
@@ -224,7 +224,7 @@ implements java.io.Serializable
* try and resolve this permission using the class loader of the permission
* that was passed in.
*/
- Permission resolve(Permission p, java.security.cert.Certificate certs[]) {
+ Permission resolve(Permission p, java.security.cert.Certificate[] certs) {
if (this.certs != null) {
// if p wasn't signed, we don't have a match
if (certs == null) {
diff --git a/jdk/src/java.base/share/classes/java/security/cert/X509CertSelector.java b/jdk/src/java.base/share/classes/java/security/cert/X509CertSelector.java
index a498bbefc5f..ba13f3cdb2a 100644
--- a/jdk/src/java.base/share/classes/java/security/cert/X509CertSelector.java
+++ b/jdk/src/java.base/share/classes/java/security/cert/X509CertSelector.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
@@ -2238,7 +2238,7 @@ public class X509CertSelector implements CertSelector {
+ subjectPublicKeyAlgID + ", xcert subjectPublicKeyAlgID = "
+ algID.getOID());
}
- if (!subjectPublicKeyAlgID.equals((Object)algID.getOID())) {
+ if (!subjectPublicKeyAlgID.equals(algID.getOID())) {
if (debug != null) {
debug.println("X509CertSelector.match: "
+ "subject public key alg IDs don't match");
diff --git a/jdk/src/java.base/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java b/jdk/src/java.base/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java
index a198e43a2e1..268d2550b67 100644
--- a/jdk/src/java.base/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java
+++ b/jdk/src/java.base/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java
@@ -54,7 +54,7 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec {
private final BigInteger primeExponentP;
private final BigInteger primeExponentQ;
private final BigInteger crtCoefficient;
- private final RSAOtherPrimeInfo otherPrimeInfo[];
+ private final RSAOtherPrimeInfo[] otherPrimeInfo;
/**
* Creates a new {@code RSAMultiPrimePrivateCrtKeySpec}
diff --git a/jdk/src/java.base/share/classes/java/text/MergeCollation.java b/jdk/src/java.base/share/classes/java/text/MergeCollation.java
index bd541a58afb..4e5e5a53ae0 100644
--- a/jdk/src/java.base/share/classes/java/text/MergeCollation.java
+++ b/jdk/src/java.base/share/classes/java/text/MergeCollation.java
@@ -329,8 +329,8 @@ final class MergeCollation {
PatternEntry e = patterns.get(i);
if (e.chars.regionMatches(0,entry.chars,0,
e.chars.length())) {
- excessChars.append(entry.chars.substring(e.chars.length(),
- entry.chars.length()));
+ excessChars.append(entry.chars, e.chars.length(),
+ entry.chars.length());
break;
}
}
diff --git a/jdk/src/java.base/share/classes/java/text/MessageFormat.java b/jdk/src/java.base/share/classes/java/text/MessageFormat.java
index 2497a490eb0..5239db0c119 100644
--- a/jdk/src/java.base/share/classes/java/text/MessageFormat.java
+++ b/jdk/src/java.base/share/classes/java/text/MessageFormat.java
@@ -1239,7 +1239,7 @@ public class MessageFormat extends Format {
int lastOffset = 0;
int last = result.length();
for (int i = 0; i <= maxOffset; ++i) {
- result.append(pattern.substring(lastOffset, offsets[i]));
+ result.append(pattern, lastOffset, offsets[i]);
lastOffset = offsets[i];
int argumentNumber = argumentNumbers[i];
if (arguments == null || argumentNumber >= arguments.length) {
@@ -1332,7 +1332,7 @@ public class MessageFormat extends Format {
}
}
}
- result.append(pattern.substring(lastOffset, pattern.length()));
+ result.append(pattern, lastOffset, pattern.length());
if (characterIterators != null && last != result.length()) {
characterIterators.add(createAttributedCharacterIterator(
result.substring(last)));
diff --git a/jdk/src/java.base/share/classes/java/util/ArrayList.java b/jdk/src/java.base/share/classes/java/util/ArrayList.java
index 9caec34ec64..7a3ad72fb46 100644
--- a/jdk/src/java.base/share/classes/java/util/ArrayList.java
+++ b/jdk/src/java.base/share/classes/java/util/ArrayList.java
@@ -178,7 +178,8 @@ public class ArrayList extends AbstractList
public ArrayList(Collection extends E> c) {
elementData = c.toArray();
if ((size = elementData.length) != 0) {
- // c.toArray might (incorrectly) not return Object[] (see 6260652)
+ // defend against c.toArray (incorrectly) not returning Object[]
+ // (see e.g. https://bugs.openjdk.java.net/browse/JDK-6260652)
if (elementData.getClass() != Object[].class)
elementData = Arrays.copyOf(elementData, size, Object[].class);
} else {
diff --git a/jdk/src/java.base/share/classes/java/util/Arrays.java b/jdk/src/java.base/share/classes/java/util/Arrays.java
index ae321498dc4..8c34de5e41f 100644
--- a/jdk/src/java.base/share/classes/java/util/Arrays.java
+++ b/jdk/src/java.base/share/classes/java/util/Arrays.java
@@ -3820,7 +3820,7 @@ public class Arrays {
@Override
public Object[] toArray() {
- return a.clone();
+ return Arrays.copyOf(a, a.length, Object[].class);
}
@Override
diff --git a/jdk/src/java.base/share/classes/java/util/Collections.java b/jdk/src/java.base/share/classes/java/util/Collections.java
index ce4ae7d1b97..6ae9a2feb16 100644
--- a/jdk/src/java.base/share/classes/java/util/Collections.java
+++ b/jdk/src/java.base/share/classes/java/util/Collections.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
@@ -4268,6 +4268,7 @@ public class Collections {
public boolean hasMoreElements() { return false; }
public E nextElement() { throw new NoSuchElementException(); }
+ public Iterator asIterator() { return emptyIterator(); }
}
/**
@@ -5199,6 +5200,11 @@ public class Collections {
* interoperability with legacy APIs that require an enumeration
* as input.
*
+ *
The iterator returned from a call to {@link Enumeration#asIterator()}
+ * does not support removal of elements from the specified collection. This
+ * is necessary to avoid unintentionally increasing the capabilities of the
+ * returned enumeration.
+ *
* @param the class of the objects in the collection
* @param c the collection for which an enumeration is to be returned.
* @return an enumeration over the specified collection.
diff --git a/jdk/src/java.base/share/classes/java/util/LinkedList.java b/jdk/src/java.base/share/classes/java/util/LinkedList.java
index 343ded84d07..e2e57e8d5a2 100644
--- a/jdk/src/java.base/share/classes/java/util/LinkedList.java
+++ b/jdk/src/java.base/share/classes/java/util/LinkedList.java
@@ -88,18 +88,22 @@ public class LinkedList
/**
* Pointer to first node.
- * Invariant: (first == null && last == null) ||
- * (first.prev == null && first.item != null)
*/
transient Node first;
/**
* Pointer to last node.
- * Invariant: (first == null && last == null) ||
- * (last.next == null && last.item != null)
*/
transient Node last;
+ /*
+ void dataStructureInvariants() {
+ assert (size == 0)
+ ? (first == null && last == null)
+ : (first.prev == null && last.next == null);
+ }
+ */
+
/**
* Constructs an empty list.
*/
diff --git a/jdk/src/java.base/share/classes/java/util/Vector.java b/jdk/src/java.base/share/classes/java/util/Vector.java
index d89f0cd0497..815a6469e73 100644
--- a/jdk/src/java.base/share/classes/java/util/Vector.java
+++ b/jdk/src/java.base/share/classes/java/util/Vector.java
@@ -174,7 +174,8 @@ public class Vector
public Vector(Collection extends E> c) {
elementData = c.toArray();
elementCount = elementData.length;
- // c.toArray might (incorrectly) not return Object[] (see 6260652)
+ // defend against c.toArray (incorrectly) not returning Object[]
+ // (see e.g. https://bugs.openjdk.java.net/browse/JDK-6260652)
if (elementData.getClass() != Object[].class)
elementData = Arrays.copyOf(elementData, elementCount, Object[].class);
}
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java b/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
index 162ad3b51d1..3e328ec351e 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
@@ -134,7 +134,8 @@ public class CopyOnWriteArrayList
elements = ((CopyOnWriteArrayList>)c).getArray();
else {
elements = c.toArray();
- // c.toArray might (incorrectly) not return Object[] (see 6260652)
+ // defend against c.toArray (incorrectly) not returning Object[]
+ // (see e.g. https://bugs.openjdk.java.net/browse/JDK-6260652)
if (elements.getClass() != Object[].class)
elements = Arrays.copyOf(elements, elements.length, Object[].class);
}
diff --git a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
index f565bc02361..bc8c24c453e 100644
--- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
+++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.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
@@ -265,6 +265,10 @@ class JarFile extends ZipFile {
public JarEntry nextElement() {
return next();
}
+
+ public Iterator asIterator() {
+ return this;
+ }
}
/**
diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
index 8669158bbc9..a4aa9b39d70 100644
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
@@ -526,6 +526,10 @@ class ZipFile implements ZipConstants, Closeable {
return ze;
}
}
+
+ public Iterator asIterator() {
+ return this;
+ }
}
/**
diff --git a/jdk/src/java.base/share/classes/sun/invoke/util/BytecodeName.java b/jdk/src/java.base/share/classes/sun/invoke/util/BytecodeName.java
index fa34d2bbb6f..9bebac8f64b 100644
--- a/jdk/src/java.base/share/classes/sun/invoke/util/BytecodeName.java
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/BytecodeName.java
@@ -511,7 +511,7 @@ public class BytecodeName {
if (s.charAt(0) != ESCAPE_C && i > 0)
sb.append(NULL_ESCAPE);
// append the string so far, which is unremarkable:
- sb.append(s.substring(0, i));
+ sb.append(s, 0, i);
}
// rewrite \ to \-, / to \|, etc.
@@ -544,7 +544,7 @@ public class BytecodeName {
if (sb == null) {
sb = new StringBuilder(s.length());
// append the string so far, which is unremarkable:
- sb.append(s.substring(stringStart, i));
+ sb.append(s, stringStart, i);
}
++i; // skip both characters
c = oc;
diff --git a/jdk/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java b/jdk/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java
index 36db753365a..c753f6888ab 100644
--- a/jdk/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java
+++ b/jdk/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.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
@@ -106,6 +106,15 @@ public class DefaultProxySelector extends ProxySelector {
}
}
+ public static int socksProxyVersion() {
+ return AccessController.doPrivileged(
+ new PrivilegedAction() {
+ @Override public Integer run() {
+ return NetProperties.getInteger(SOCKS_PROXY_VERSION, 5);
+ }
+ });
+ }
+
/**
* How to deal with "non proxy hosts":
* since we do have to generate a pattern we don't want to do that if
@@ -302,8 +311,7 @@ public class DefaultProxySelector extends ProxySelector {
saddr = InetSocketAddress.createUnresolved(phost, pport);
// Socks is *always* the last on the list.
if (j == (props[i].length - 1)) {
- int version = NetProperties.getInteger(SOCKS_PROXY_VERSION, 5).intValue();
- return SocksProxy.create(saddr, version);
+ return SocksProxy.create(saddr, socksProxyVersion());
} else {
return new Proxy(Proxy.Type.HTTP, saddr);
}
diff --git a/jdk/src/java.base/share/classes/sun/net/www/ParseUtil.java b/jdk/src/java.base/share/classes/sun/net/www/ParseUtil.java
index 1c9abf9d1f4..52af2cb6510 100644
--- a/jdk/src/java.base/share/classes/sun/net/www/ParseUtil.java
+++ b/jdk/src/java.base/share/classes/sun/net/www/ParseUtil.java
@@ -451,7 +451,7 @@ public class ParseUtil {
if (!match(c, lowMask, highMask) && !isEscaped(s, i)) {
if (sb == null) {
sb = new StringBuffer();
- sb.append(s.substring(0, i));
+ sb.append(s, 0, i);
}
appendEscape(sb, (byte)c);
} else {
@@ -463,7 +463,7 @@ public class ParseUtil {
|| Character.isISOControl(c))) {
if (sb == null) {
sb = new StringBuffer();
- sb.append(s.substring(0, i));
+ sb.append(s, 0, i);
}
appendEncoded(sb, c);
} else {
diff --git a/jdk/src/java.base/share/classes/sun/nio/fs/AbstractFileTypeDetector.java b/jdk/src/java.base/share/classes/sun/nio/fs/AbstractFileTypeDetector.java
index 0e43486e215..4b4e623275c 100644
--- a/jdk/src/java.base/share/classes/sun/nio/fs/AbstractFileTypeDetector.java
+++ b/jdk/src/java.base/share/classes/sun/nio/fs/AbstractFileTypeDetector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,27 @@ public abstract class AbstractFileTypeDetector
super();
}
+ /**
+ * Returns the extension of a file name, specifically the portion of the
+ * parameter string after the first dot. If the parameter is {@code null},
+ * empty, does not contain a dot, or the dot is the last character, then an
+ * empty string is returned, otherwise the characters after the dot are
+ * returned.
+ *
+ * @param name A file name
+ * @return The characters after the first dot or an empty string.
+ */
+ protected final String getExtension(String name) {
+ String ext = "";
+ if (name != null && !name.isEmpty()) {
+ int dot = name.indexOf('.');
+ if ((dot >= 0) && (dot < name.length() - 1)) {
+ ext = name.substring(dot + 1);
+ }
+ }
+ return ext;
+ }
+
/**
* Invokes the appropriate probe method to guess a file's content type,
* and checks that the content type's syntax is valid.
diff --git a/jdk/src/java.base/share/classes/sun/security/pkcs/ContentInfo.java b/jdk/src/java.base/share/classes/sun/security/pkcs/ContentInfo.java
index bc78d0f1c0d..47a64dbfb79 100644
--- a/jdk/src/java.base/share/classes/sun/security/pkcs/ContentInfo.java
+++ b/jdk/src/java.base/share/classes/sun/security/pkcs/ContentInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -163,9 +163,9 @@ public class ContentInfo {
}
public byte[] getData() throws IOException {
- if (contentType.equals((Object)DATA_OID) ||
- contentType.equals((Object)OLD_DATA_OID) ||
- contentType.equals((Object)TIMESTAMP_TOKEN_INFO_OID)) {
+ if (contentType.equals(DATA_OID) ||
+ contentType.equals(OLD_DATA_OID) ||
+ contentType.equals(TIMESTAMP_TOKEN_INFO_OID)) {
if (content == null)
return null;
else
diff --git a/jdk/src/java.base/share/classes/sun/security/pkcs/PKCS7.java b/jdk/src/java.base/share/classes/sun/security/pkcs/PKCS7.java
index 52d7b18bcc4..5c6c625aa0a 100644
--- a/jdk/src/java.base/share/classes/sun/security/pkcs/PKCS7.java
+++ b/jdk/src/java.base/share/classes/sun/security/pkcs/PKCS7.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -182,13 +182,12 @@ public class PKCS7 {
contentType = contentInfo.contentType;
DerValue content = contentInfo.getContent();
- if (contentType.equals((Object)ContentInfo.SIGNED_DATA_OID)) {
+ if (contentType.equals(ContentInfo.SIGNED_DATA_OID)) {
parseSignedData(content);
- } else if (contentType.equals((Object)ContentInfo.OLD_SIGNED_DATA_OID)) {
+ } else if (contentType.equals(ContentInfo.OLD_SIGNED_DATA_OID)) {
// This is for backwards compatibility with JDK 1.1.x
parseOldSignedData(content);
- } else if (contentType.equals((Object)
- ContentInfo.NETSCAPE_CERT_SEQUENCE_OID)){
+ } else if (contentType.equals(ContentInfo.NETSCAPE_CERT_SEQUENCE_OID)){
parseNetscapeCertChain(content);
} else {
throw new ParsingException("content type " + contentType +
@@ -508,7 +507,7 @@ public class PKCS7 {
// certificates (optional)
if (certificates != null && certificates.length != 0) {
// cast to X509CertImpl[] since X509CertImpl implements DerEncoder
- X509CertImpl implCerts[] = new X509CertImpl[certificates.length];
+ X509CertImpl[] implCerts = new X509CertImpl[certificates.length];
for (int i = 0; i < certificates.length; i++) {
if (certificates[i] instanceof X509CertImpl)
implCerts[i] = (X509CertImpl) certificates[i];
diff --git a/jdk/src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java b/jdk/src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java
index 59512f11b6e..88742d37668 100644
--- a/jdk/src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java
+++ b/jdk/src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java
@@ -78,7 +78,7 @@ public class PKCS8Key implements PrivateKey {
* data is stored and transmitted losslessly, but no knowledge
* about this particular algorithm is available.
*/
- private PKCS8Key (AlgorithmId algid, byte key [])
+ private PKCS8Key (AlgorithmId algid, byte[] key)
throws InvalidKeyException {
this.algid = algid;
this.key = key;
diff --git a/jdk/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java b/jdk/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java
index 1f310a2d32f..12b72de51e5 100644
--- a/jdk/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java
+++ b/jdk/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -307,7 +307,7 @@ public class SignerInfo implements DerEncoder {
authenticatedAttributes.getAttributeValue(
PKCS9Attribute.CONTENT_TYPE_OID);
if (contentType == null ||
- !contentType.equals((Object)content.contentType))
+ !contentType.equals(content.contentType))
return null; // contentType does not match, bad SignerInfo
// now, check message digest
diff --git a/jdk/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/jdk/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
index 625d31115a9..a8c5fa709ba 100644
--- a/jdk/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
+++ b/jdk/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
@@ -154,28 +154,28 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
private static final Debug debug = Debug.getInstance("pkcs12");
- private static final int keyBag[] = {1, 2, 840, 113549, 1, 12, 10, 1, 2};
- private static final int certBag[] = {1, 2, 840, 113549, 1, 12, 10, 1, 3};
- private static final int secretBag[] = {1, 2, 840, 113549, 1, 12, 10, 1, 5};
+ private static final int[] keyBag = {1, 2, 840, 113549, 1, 12, 10, 1, 2};
+ private static final int[] certBag = {1, 2, 840, 113549, 1, 12, 10, 1, 3};
+ private static final int[] secretBag = {1, 2, 840, 113549, 1, 12, 10, 1, 5};
- private static final int pkcs9Name[] = {1, 2, 840, 113549, 1, 9, 20};
- private static final int pkcs9KeyId[] = {1, 2, 840, 113549, 1, 9, 21};
+ private static final int[] pkcs9Name = {1, 2, 840, 113549, 1, 9, 20};
+ private static final int[] pkcs9KeyId = {1, 2, 840, 113549, 1, 9, 21};
- private static final int pkcs9certType[] = {1, 2, 840, 113549, 1, 9, 22, 1};
+ private static final int[] pkcs9certType = {1, 2, 840, 113549, 1, 9, 22, 1};
- private static final int pbeWithSHAAnd40BitRC2CBC[] =
+ private static final int[] pbeWithSHAAnd40BitRC2CBC =
{1, 2, 840, 113549, 1, 12, 1, 6};
- private static final int pbeWithSHAAnd3KeyTripleDESCBC[] =
+ private static final int[] pbeWithSHAAnd3KeyTripleDESCBC =
{1, 2, 840, 113549, 1, 12, 1, 3};
- private static final int pbes2[] = {1, 2, 840, 113549, 1, 5, 13};
+ private static final int[] pbes2 = {1, 2, 840, 113549, 1, 5, 13};
// TODO: temporary Oracle OID
/*
* { joint-iso-itu-t(2) country(16) us(840) organization(1) oracle(113894)
* jdk(746875) crypto(1) id-at-trustedKeyUsage(1) }
*/
- private static final int TrustedKeyUsage[] =
+ private static final int[] TrustedKeyUsage =
{2, 16, 840, 1, 113894, 746875, 1, 1};
- private static final int AnyExtendedKeyUsage[] = {2, 5, 29, 37, 0};
+ private static final int[] AnyExtendedKeyUsage = {2, 5, 29, 37, 0};
private static ObjectIdentifier PKCS8ShroudedKeyBag_OID;
private static ObjectIdentifier CertBag_OID;
@@ -243,7 +243,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
// A private key entry and its supporting certificate chain
private static class PrivateKeyEntry extends KeyEntry {
byte[] protectedPrivKey;
- Certificate chain[];
+ Certificate[] chain;
};
// A secret key
@@ -789,7 +789,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
}
}
if (params != null) {
- if (algorithm.equals((Object)pbes2_OID)) {
+ if (algorithm.equals(pbes2_OID)) {
algParams = AlgorithmParameters.getInstance("PBES2");
} else {
algParams = AlgorithmParameters.getInstance("PBE");
@@ -926,7 +926,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
private static String mapPBEParamsToAlgorithm(ObjectIdentifier algorithm,
AlgorithmParameters algParams) throws NoSuchAlgorithmException {
// Check for PBES2 algorithms
- if (algorithm.equals((Object)pbes2_OID) && algParams != null) {
+ if (algorithm.equals(pbes2_OID) && algParams != null) {
return algParams.toString();
}
return algorithm.toString();
@@ -1937,7 +1937,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
ContentInfo authSafe = new ContentInfo(s);
ObjectIdentifier contentType = authSafe.getContentType();
- if (contentType.equals((Object)ContentInfo.DATA_OID)) {
+ if (contentType.equals(ContentInfo.DATA_OID)) {
authSafeData = authSafe.getData();
} else /* signed data */ {
throw new IOException("public key protected PKCS12 not supported");
@@ -1965,14 +1965,14 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
safeContents = new ContentInfo(sci);
contentType = safeContents.getContentType();
safeContentsData = null;
- if (contentType.equals((Object)ContentInfo.DATA_OID)) {
+ if (contentType.equals(ContentInfo.DATA_OID)) {
if (debug != null) {
debug.println("Loading PKCS#7 data content-type");
}
safeContentsData = safeContents.getData();
- } else if (contentType.equals((Object)ContentInfo.ENCRYPTED_DATA_OID)) {
+ } else if (contentType.equals(ContentInfo.ENCRYPTED_DATA_OID)) {
if (password == null) {
if (debug != null) {
@@ -2178,12 +2178,12 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
+ bagValue.tag);
}
bagValue = bagValue.data.getDerValue();
- if (bagId.equals((Object)PKCS8ShroudedKeyBag_OID)) {
+ if (bagId.equals(PKCS8ShroudedKeyBag_OID)) {
PrivateKeyEntry kEntry = new PrivateKeyEntry();
kEntry.protectedPrivKey = bagValue.toByteArray();
bagItem = kEntry;
privateKeyCount++;
- } else if (bagId.equals((Object)CertBag_OID)) {
+ } else if (bagId.equals(CertBag_OID)) {
DerInputStream cs = new DerInputStream(bagValue.toByteArray());
DerValue[] certValues = cs.getSequence(2);
ObjectIdentifier certId = certValues[0].getOID();
@@ -2198,7 +2198,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
(new ByteArrayInputStream(certValue.getOctetString()));
bagItem = cert;
certificateCount++;
- } else if (bagId.equals((Object)SecretBag_OID)) {
+ } else if (bagId.equals(SecretBag_OID)) {
DerInputStream ss = new DerInputStream(bagValue.toByteArray());
DerValue[] secretValues = ss.getSequence(2);
ObjectIdentifier secretId = secretValues[0].getOID();
@@ -2249,12 +2249,12 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
throw new IOException("Attribute " + attrId +
" should have a value " + e.getMessage());
}
- if (attrId.equals((Object)PKCS9FriendlyName_OID)) {
+ if (attrId.equals(PKCS9FriendlyName_OID)) {
alias = valSet[0].getBMPString();
- } else if (attrId.equals((Object)PKCS9LocalKeyId_OID)) {
+ } else if (attrId.equals(PKCS9LocalKeyId_OID)) {
keyId = valSet[0].getOctetString();
} else if
- (attrId.equals((Object)TrustedKeyUsage_OID)) {
+ (attrId.equals(TrustedKeyUsage_OID)) {
trustedKeyUsage = new ObjectIdentifier[valSet.length];
for (int k = 0; k < valSet.length; k++) {
trustedKeyUsage[k] = valSet[k].getOID();
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/AuthPolicyFile.java b/jdk/src/java.base/share/classes/sun/security/provider/AuthPolicyFile.java
index b93c4d863f6..05150c95145 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/AuthPolicyFile.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/AuthPolicyFile.java
@@ -403,7 +403,7 @@ public class AuthPolicyFile extends javax.security.auth.Policy {
debug.println(" "+perm);
}
} catch (ClassNotFoundException cnfe) {
- Certificate certs[];
+ Certificate[] certs;
if (pe.signedBy != null) {
certs = getCertificates(keyStore, pe.signedBy);
} else {
@@ -623,7 +623,7 @@ public class AuthPolicyFile extends javax.security.auth.Policy {
init();
}
- final CodeSource codesource[] = {null};
+ final CodeSource[] codesource = {null};
codesource[0] = canonicalizeCodebase(cs, true);
@@ -666,7 +666,7 @@ public class AuthPolicyFile extends javax.security.auth.Policy {
// now see if any of the keys are trusted ids.
if (!ignoreIdentityScope) {
- Certificate certs[] = codesource[0].getCertificates();
+ Certificate[] certs = codesource[0].getCertificates();
if (certs != null) {
for (int k=0; k < certs.length; k++) {
if (aliasMapping.get(certs[k]) == null &&
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/DSAParameterGenerator.java b/jdk/src/java.base/share/classes/sun/security/provider/DSAParameterGenerator.java
index ac50e96f268..a8d4803dcbb 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/DSAParameterGenerator.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/DSAParameterGenerator.java
@@ -237,7 +237,7 @@ public class DSAParameterGenerator extends AlgorithmParameterGeneratorSpi {
BigInteger offset = ONE;
/* Step 11 */
for (counter = 0; counter < 4*valueL; counter++) {
- BigInteger V[] = new BigInteger[n + 1];
+ BigInteger[] V = new BigInteger[n + 1];
/* Step 11.1 */
for (int j = 0; j <= n; j++) {
BigInteger J = BigInteger.valueOf(j);
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java b/jdk/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java
index 59b759bd3c8..49d645b863f 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java
@@ -82,7 +82,7 @@ public abstract class JavaKeyStore extends KeyStoreSpi {
private static class KeyEntry {
Date date; // the creation date of this entry
byte[] protectedPrivKey;
- Certificate chain[];
+ Certificate[] chain;
};
// Trusted certificates
@@ -604,7 +604,7 @@ public abstract class JavaKeyStore extends KeyStoreSpi {
* the keystore (such as deleting or modifying key or
* certificate entries).
*/
- byte digest[] = md.digest();
+ byte[] digest = md.digest();
dos.write(digest);
dos.flush();
@@ -770,9 +770,8 @@ public abstract class JavaKeyStore extends KeyStoreSpi {
* with
*/
if (password != null) {
- byte computed[], actual[];
- computed = md.digest();
- actual = new byte[computed.length];
+ byte[] computed = md.digest();
+ byte[] actual = new byte[computed.length];
dis.readFully(actual);
for (int i = 0; i < computed.length; i++) {
if (computed[i] != actual[i]) {
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java b/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java
index 33605436f82..58d483e4293 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java
@@ -795,7 +795,7 @@ public class PolicyFile extends java.security.Policy {
// an unresolved permission which will be resolved
// when implies is called
// Add it to entry
- Certificate certs[];
+ Certificate[] certs;
if (pe.signedBy != null) {
certs = getCertificates(keyStore,
pe.signedBy,
@@ -817,7 +817,7 @@ public class PolicyFile extends java.security.Policy {
debug.println(" "+perm);
}
} catch (ClassNotFoundException cnfe) {
- Certificate certs[];
+ Certificate[] certs;
if (pe.signedBy != null) {
certs = getCertificates(keyStore,
pe.signedBy,
@@ -2032,7 +2032,7 @@ public class PolicyFile extends java.security.Policy {
*
* @serial
*/
- private Certificate certs[];
+ private Certificate[] certs;
/**
* Creates a new SelfPermission containing the permission
@@ -2048,7 +2048,7 @@ public class PolicyFile extends java.security.Policy {
* certificate first and the (root) certificate authority last).
*/
public SelfPermission(String type, String name, String actions,
- Certificate certs[])
+ Certificate[] certs)
{
super(type);
if (type == null) {
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java b/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java
index 2658a9e03ba..ba8ed750254 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java
@@ -1353,7 +1353,7 @@ public class PolicyParser {
}
}
- public static void main(String arg[]) throws Exception {
+ public static void main(String[] arg) throws Exception {
try (FileReader fr = new FileReader(arg[0]);
FileWriter fw = new FileWriter(arg[1])) {
PolicyParser pp = new PolicyParser(true);
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/SecureRandom.java b/jdk/src/java.base/share/classes/sun/security/provider/SecureRandom.java
index 99edb6a89d2..167558bd8f8 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/SecureRandom.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/SecureRandom.java
@@ -85,7 +85,7 @@ implements java.io.Serializable {
*
* @param seed the seed.
*/
- private SecureRandom(byte seed[]) {
+ private SecureRandom(byte[] seed) {
init(seed);
}
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java
index dce8fd6b934..55186949e48 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -322,7 +322,7 @@ public final class OCSP {
List descriptions = aia.getAccessDescriptions();
for (AccessDescription description : descriptions) {
- if (description.getAccessMethod().equals((Object)
+ if (description.getAccessMethod().equals(
AccessDescription.Ad_OCSP_Id)) {
GeneralName generalName = description.getAccessLocation();
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java
index f8e72abebc0..02c669e63c4 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java
@@ -239,7 +239,7 @@ public final class OCSPResponse {
// responseType
derIn = tmp.data;
ObjectIdentifier responseType = derIn.getOID();
- if (responseType.equals((Object)OCSP_BASIC_RESPONSE_OID)) {
+ if (responseType.equals(OCSP_BASIC_RESPONSE_OID)) {
if (debug != null) {
debug.println("OCSP response type: basic");
}
@@ -338,8 +338,7 @@ public final class OCSPResponse {
debug.println("OCSP extension: " + ext);
}
// Only the NONCE extension is recognized
- if (ext.getExtensionId().equals((Object)
- OCSP.NONCE_EXTENSION_OID))
+ if (ext.getExtensionId().equals(OCSP.NONCE_EXTENSION_OID))
{
nonce = ext.getExtensionValue();
} else if (ext.isCritical()) {
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java
index 0477b2b751e..f1900f8824b 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java
@@ -202,7 +202,7 @@ class URICertStore extends CertStoreSpi {
* object of a certificate's Authority Information Access Extension.
*/
static CertStore getInstance(AccessDescription ad) {
- if (!ad.getAccessMethod().equals((Object)
+ if (!ad.getAccessMethod().equals(
AccessDescription.Ad_CAISSUERS_Id)) {
return null;
}
diff --git a/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java b/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java
index d5ba1f82621..6d43d1e32a3 100644
--- a/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java
+++ b/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java
@@ -232,7 +232,7 @@ public abstract class RSASignature extends SignatureSpi {
throw new IOException("SEQUENCE length error");
}
AlgorithmId algId = AlgorithmId.parse(values[0]);
- if (algId.getOID().equals((Object)oid) == false) {
+ if (algId.getOID().equals(oid) == false) {
throw new IOException("ObjectIdentifier mismatch: "
+ algId.getOID());
}
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ByteBufferInputStream.java b/jdk/src/java.base/share/classes/sun/security/ssl/ByteBufferInputStream.java
index 05107988a53..753a728a1b8 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ByteBufferInputStream.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ByteBufferInputStream.java
@@ -70,7 +70,7 @@ class ByteBufferInputStream extends InputStream {
* Increments position().
*/
@Override
- public int read(byte b[]) throws IOException {
+ public int read(byte[] b) throws IOException {
if (bb == null) {
throw new IOException("read on a closed InputStream");
@@ -85,7 +85,7 @@ class ByteBufferInputStream extends InputStream {
* Increments position().
*/
@Override
- public int read(byte b[], int off, int len) throws IOException {
+ public int read(byte[] b, int off, int len) throws IOException {
if (bb == null) {
throw new IOException("read on a closed InputStream");
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java
index 1561fc5b893..16384007238 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java
@@ -810,7 +810,7 @@ final class ClientHandshaker extends Handshaker {
String alias = null;
int keytypesTmpSize = keytypesTmp.size();
if (keytypesTmpSize != 0) {
- String keytypes[] =
+ String[] keytypes =
keytypesTmp.toArray(new String[keytypesTmpSize]);
if (conn != null) {
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java b/jdk/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java
index 94426f47d70..878a8fd0203 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java
@@ -48,7 +48,7 @@ final class DHClientKeyExchange extends HandshakeMessage {
* This value may be empty if it was included in the
* client's certificate ...
*/
- private byte dh_Yc[]; // 1 to 2^16 -1 bytes
+ private byte[] dh_Yc; // 1 to 2^16 -1 bytes
BigInteger getClientPublicKey() {
return dh_Yc == null ? null : new BigInteger(1, dh_Yc);
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeInStream.java b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeInStream.java
index 2111f344609..f61d1beb6f3 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeInStream.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeInStream.java
@@ -146,7 +146,7 @@ public final class HandshakeInStream extends ByteArrayInputStream {
byte[] getBytes8() throws IOException {
int len = getInt8();
verifyLength(len);
- byte b[] = new byte[len];
+ byte[] b = new byte[len];
read(b);
return b;
@@ -155,7 +155,7 @@ public final class HandshakeInStream extends ByteArrayInputStream {
public byte[] getBytes16() throws IOException {
int len = getInt16();
verifyLength(len);
- byte b[] = new byte[len];
+ byte[] b = new byte[len];
read(b);
return b;
@@ -164,7 +164,7 @@ public final class HandshakeInStream extends ByteArrayInputStream {
byte[] getBytes24() throws IOException {
int len = getInt24();
verifyLength(len);
- byte b[] = new byte[len];
+ byte[] b = new byte[len];
read(b);
return b;
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java
index 00b84262e09..f4452faaa2c 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java
@@ -689,8 +689,8 @@ static abstract class ServerKeyExchange extends HandshakeMessage
static final
class RSA_ServerKeyExchange extends ServerKeyExchange
{
- private byte rsa_modulus[]; // 1 to 2^16 - 1 bytes
- private byte rsa_exponent[]; // 1 to 2^16 - 1 bytes
+ private byte[] rsa_modulus; // 1 to 2^16 - 1 bytes
+ private byte[] rsa_exponent; // 1 to 2^16 - 1 bytes
private Signature signature;
private byte[] signatureBytes;
@@ -698,7 +698,7 @@ class RSA_ServerKeyExchange extends ServerKeyExchange
/*
* Hash the nonces and the ephemeral RSA public key.
*/
- private void updateSignature(byte clntNonce[], byte svrNonce[])
+ private void updateSignature(byte[] clntNonce, byte[] svrNonce)
throws SignatureException {
int tmp;
@@ -827,11 +827,11 @@ class DH_ServerKeyExchange extends ServerKeyExchange
private final static boolean dhKeyExchangeFix =
Debug.getBooleanProperty("com.sun.net.ssl.dhKeyExchangeFix", true);
- private byte dh_p []; // 1 to 2^16 - 1 bytes
- private byte dh_g []; // 1 to 2^16 - 1 bytes
- private byte dh_Ys []; // 1 to 2^16 - 1 bytes
+ private byte[] dh_p; // 1 to 2^16 - 1 bytes
+ private byte[] dh_g; // 1 to 2^16 - 1 bytes
+ private byte[] dh_Ys; // 1 to 2^16 - 1 bytes
- private byte signature [];
+ private byte[] signature;
// protocol version being established using this ServerKeyExchange message
ProtocolVersion protocolVersion;
@@ -857,8 +857,8 @@ class DH_ServerKeyExchange extends ServerKeyExchange
* with the cert chain which was sent ... for DHE_DSS and DHE_RSA
* key exchange. (Constructor called by server.)
*/
- DH_ServerKeyExchange(DHCrypt obj, PrivateKey key, byte clntNonce[],
- byte svrNonce[], SecureRandom sr,
+ DH_ServerKeyExchange(DHCrypt obj, PrivateKey key, byte[] clntNonce,
+ byte[] svrNonce, SecureRandom sr,
SignatureAndHashAlgorithm signAlgorithm,
ProtocolVersion protocolVersion) throws GeneralSecurityException {
@@ -913,7 +913,7 @@ class DH_ServerKeyExchange extends ServerKeyExchange
* DHE_DSS or DHE_RSA key exchange. (Called by client.)
*/
DH_ServerKeyExchange(HandshakeInStream input, PublicKey publicKey,
- byte clntNonce[], byte svrNonce[], int messageSize,
+ byte[] clntNonce, byte[] svrNonce, int messageSize,
Collection localSupportedSignAlgs,
ProtocolVersion protocolVersion)
throws IOException, GeneralSecurityException {
@@ -948,7 +948,7 @@ class DH_ServerKeyExchange extends ServerKeyExchange
}
// read the signature
- byte signature[];
+ byte[] signature;
if (dhKeyExchangeFix) {
signature = input.getBytes16();
} else {
@@ -1004,8 +1004,8 @@ class DH_ServerKeyExchange extends ServerKeyExchange
/*
* Update sig with nonces and Diffie-Hellman public key.
*/
- private void updateSignature(Signature sig, byte clntNonce[],
- byte svrNonce[]) throws SignatureException {
+ private void updateSignature(Signature sig, byte[] clntNonce,
+ byte[] svrNonce) throws SignatureException {
int tmp;
sig.update(clntNonce);
@@ -1268,8 +1268,8 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange {
}
}
- private void updateSignature(Signature sig, byte clntNonce[],
- byte svrNonce[]) throws SignatureException {
+ private void updateSignature(Signature sig, byte[] clntNonce,
+ byte[] svrNonce) throws SignatureException {
sig.update(clntNonce);
sig.update(svrNonce);
@@ -1334,7 +1334,7 @@ static final class DistinguishedName {
* DER encoded distinguished name.
* TLS requires that its not longer than 65535 bytes.
*/
- byte name[];
+ byte[] name;
DistinguishedName(HandshakeInStream input) throws IOException {
name = input.getBytes16();
@@ -1411,8 +1411,8 @@ class CertificateRequest extends HandshakeMessage
private final static byte[] TYPES_ECC =
{ cct_rsa_sign, cct_dss_sign, cct_ecdsa_sign };
- byte types []; // 1 to 255 types
- DistinguishedName authorities []; // 3 to 2^16 - 1
+ byte[] types; // 1 to 255 types
+ DistinguishedName[] authorities; // 3 to 2^16 - 1
// ... "3" because that's the smallest DER-encoded X500 DN
// protocol version being established using this CertificateRequest message
@@ -1424,7 +1424,7 @@ class CertificateRequest extends HandshakeMessage
// length of supported_signature_algorithms
private int algorithmsLen;
- CertificateRequest(X509Certificate ca[], KeyExchange keyExchange,
+ CertificateRequest(X509Certificate[] ca, KeyExchange keyExchange,
Collection signAlgs,
ProtocolVersion protocolVersion) throws IOException {
@@ -2063,7 +2063,7 @@ static final class Finished extends HandshakeMessage {
if (protocolVersion.useTLS10PlusSpec()) {
// TLS 1.0+
try {
- byte [] seed;
+ byte[] seed;
String prfAlg;
PRF prf;
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java
index 99ab971ed86..049da437a32 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java
@@ -119,7 +119,7 @@ public class HandshakeOutStream extends ByteArrayOutputStream {
}
}
- public void putBytes16(byte b[]) throws IOException {
+ public void putBytes16(byte[] b) throws IOException {
if (b == null) {
putInt16(0);
} else {
@@ -128,7 +128,7 @@ public class HandshakeOutStream extends ByteArrayOutputStream {
}
}
- void putBytes24(byte b[]) throws IOException {
+ void putBytes24(byte[] b) throws IOException {
if (b == null) {
putInt24(0);
} else {
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/MAC.java b/jdk/src/java.base/share/classes/sun/security/ssl/MAC.java
index d78c8282794..c41b1bb8962 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/MAC.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/MAC.java
@@ -52,7 +52,7 @@ final class MAC extends Authenticator {
final static MAC TLS_NULL = new MAC(false);
// Value of the null MAC is fixed
- private static final byte nullMAC[] = new byte[0];
+ private static final byte[] nullMAC = new byte[0];
// internal identifier for the MAC algorithm
private final MacAlg macAlg;
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/RandomCookie.java b/jdk/src/java.base/share/classes/sun/security/ssl/RandomCookie.java
index 22e50eb7c0e..5ba6b47da3e 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/RandomCookie.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/RandomCookie.java
@@ -38,7 +38,7 @@ import java.security.SecureRandom;
*/
final class RandomCookie {
- byte random_bytes[]; // exactly 32 bytes
+ byte[] random_bytes; // exactly 32 bytes
RandomCookie(SecureRandom generator) {
long temp = System.currentTimeMillis() / 1000;
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java
index deea7949d9e..993ab27496d 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java
@@ -986,7 +986,7 @@ final class ServerHandshaker extends Handshaker {
ClientKeyExchangeService.find(keyExchange.name) == null) {
CertificateRequest m4;
- X509Certificate caCerts[];
+ X509Certificate[] caCerts;
Collection localSignAlgs = null;
if (protocolVersion.useTLS12PlusSpec()) {
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SessionId.java b/jdk/src/java.base/share/classes/sun/security/ssl/SessionId.java
index 31a4ab9f2f8..d716eb08e90 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/SessionId.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SessionId.java
@@ -43,7 +43,7 @@ final
class SessionId
{
static int MAX_LENGTH = 32;
- private byte sessionId []; // max 32 bytes
+ private byte[] sessionId; // max 32 bytes
/** Constructs a new session ID ... perhaps for a rejoinable session */
SessionId (boolean isRejoinable, SecureRandom generator)
@@ -56,7 +56,7 @@ class SessionId
}
/** Constructs a session ID from a byte array (max size 32 bytes) */
- SessionId (byte sessionId [])
+ SessionId (byte[] sessionId)
{ this.sessionId = sessionId; }
/** Returns the length of the ID, in bytes */
@@ -64,7 +64,7 @@ class SessionId
{ return sessionId.length; }
/** Returns the bytes in the ID. May be an empty array. */
- byte [] getId ()
+ byte[] getId ()
{
return sessionId.clone ();
}
@@ -106,7 +106,7 @@ class SessionId
return false;
SessionId s = (SessionId) obj;
- byte b [] = s.getId ();
+ byte[] b = s.getId ();
if (b.length != sessionId.length)
return false;
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java
index bff87c8f7e2..066b5c013ea 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java
@@ -94,13 +94,13 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
}
@Override
- public void checkClientTrusted(X509Certificate chain[], String authType)
+ public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
checkTrusted(chain, authType, (Socket)null, true);
}
@Override
- public void checkServerTrusted(X509Certificate chain[], String authType)
+ public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
checkTrusted(chain, authType, (Socket)null, false);
}
diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
index 0ce7ef42ae0..dcf276bf60e 100644
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
@@ -1280,7 +1280,7 @@ public final class Main {
Iterator attrs = req.getAttributes().getAttributes().iterator();
while (attrs.hasNext()) {
PKCS10Attribute attr = attrs.next();
- if (attr.getAttributeId().equals((Object)PKCS9Attribute.EXTENSION_REQUEST_OID)) {
+ if (attr.getAttributeId().equals(PKCS9Attribute.EXTENSION_REQUEST_OID)) {
reqex = (CertificateExtensions)attr.getAttributeValue();
}
}
@@ -2338,7 +2338,7 @@ public final class Main {
req.getSubjectName(), pkey.getFormat(), pkey.getAlgorithm());
for (PKCS10Attribute attr: req.getAttributes().getAttributes()) {
ObjectIdentifier oid = attr.getAttributeId();
- if (oid.equals((Object)PKCS9Attribute.EXTENSION_REQUEST_OID)) {
+ if (oid.equals(PKCS9Attribute.EXTENSION_REQUEST_OID)) {
CertificateExtensions exts = (CertificateExtensions)attr.getAttributeValue();
if (exts != null) {
printExtensions(rb.getString("Extension.Request."), exts, out);
diff --git a/jdk/src/java.base/share/classes/sun/security/util/ManifestDigester.java b/jdk/src/java.base/share/classes/sun/security/util/ManifestDigester.java
index 568e296f719..820ec18e0b1 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/ManifestDigester.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/ManifestDigester.java
@@ -37,7 +37,7 @@ public class ManifestDigester {
public static final String MF_MAIN_ATTRS = "Manifest-Main-Attributes";
/** the raw bytes of the manifest */
- private byte rawBytes[];
+ private byte[] rawBytes;
/** the offset/length pair for a section */
private HashMap entries; // key is a UTF-8 string
@@ -107,7 +107,7 @@ public class ManifestDigester {
return false;
}
- public ManifestDigester(byte bytes[])
+ public ManifestDigester(byte[] bytes)
{
rawBytes = bytes;
entries = new HashMap<>();
@@ -181,7 +181,7 @@ public class ManifestDigester {
}
}
- private boolean isNameAttr(byte bytes[], int start)
+ private boolean isNameAttr(byte[] bytes, int start)
{
return ((bytes[start] == 'N') || (bytes[start] == 'n')) &&
((bytes[start+1] == 'a') || (bytes[start+1] == 'A')) &&
@@ -261,11 +261,10 @@ public class ManifestDigester {
return e;
}
- public byte[] manifestDigest(MessageDigest md)
- {
- md.reset();
- md.update(rawBytes, 0, rawBytes.length);
- return md.digest();
- }
+ public byte[] manifestDigest(MessageDigest md) {
+ md.reset();
+ md.update(rawBytes, 0, rawBytes.length);
+ return md.digest();
+ }
}
diff --git a/jdk/src/java.base/share/classes/sun/security/util/ManifestEntryVerifier.java b/jdk/src/java.base/share/classes/sun/security/util/ManifestEntryVerifier.java
index 6fcc26143e2..19cc730ce6f 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/ManifestEntryVerifier.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/ManifestEntryVerifier.java
@@ -165,7 +165,7 @@ public class ManifestEntryVerifier {
/**
* update the digests for the digests we are interested in
*/
- public void update(byte buffer[], int off, int len) {
+ public void update(byte[] buffer, int off, int len) {
if (skip) return;
for (int i=0; i < digests.size(); i++) {
diff --git a/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java b/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java
index 9d02a42101f..ab92d1cdc40 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -212,7 +212,7 @@ class ObjectIdentifier implements Serializable
* Constructor, from an array of integers.
* Validity check included.
*/
- public ObjectIdentifier (int values []) throws IOException
+ public ObjectIdentifier(int[] values) throws IOException
{
checkCount(values.length);
checkFirstComponent(values[0]);
@@ -318,14 +318,6 @@ class ObjectIdentifier implements Serializable
out.write (DerValue.tag_ObjectId, encoding);
}
- /**
- * @deprecated Use equals((Object)oid)
- */
- @Deprecated
- public boolean equals(ObjectIdentifier other) {
- return equals((Object)other);
- }
-
/**
* Compares this identifier with another, for equality.
*
diff --git a/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
index 88d0ccb00e4..841aa0adabc 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
@@ -55,7 +55,7 @@ public class SignatureFileVerifier {
private PKCS7 block;
/** the raw bytes of the .SF file */
- private byte sfBytes[];
+ private byte[] sfBytes;
/** the name of the signature block file, uppercased and without
* the extension (.DSA/.RSA/.EC)
@@ -84,7 +84,7 @@ public class SignatureFileVerifier {
public SignatureFileVerifier(ArrayList signerCache,
ManifestDigester md,
String name,
- byte rawBytes[])
+ byte[] rawBytes)
throws IOException, CertificateException
{
// new PKCS7() calls CertificateFactory.getInstance()
@@ -129,7 +129,7 @@ public class SignatureFileVerifier {
* used to set the raw bytes of the .SF file when it
* is external to the signature block file.
*/
- public void setSignatureFile(byte sfBytes[])
+ public void setSignatureFile(byte[] sfBytes)
{
this.sfBytes = sfBytes;
}
@@ -511,7 +511,7 @@ public class SignatureFileVerifier {
* CodeSigner objects. We do this only *once* for a given
* signature block file.
*/
- private CodeSigner[] getSigners(SignerInfo infos[], PKCS7 block)
+ private CodeSigner[] getSigners(SignerInfo[] infos, PKCS7 block)
throws IOException, NoSuchAlgorithmException, SignatureException,
CertificateException {
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/AVA.java b/jdk/src/java.base/share/classes/sun/security/x509/AVA.java
index c75030a21a7..1b7d297b233 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/AVA.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/AVA.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -364,8 +364,8 @@ public class AVA implements DerEncoder {
// encode as PrintableString unless value contains
// non-PrintableString chars
- if (this.oid.equals((Object)PKCS9Attribute.EMAIL_ADDRESS_OID) ||
- (this.oid.equals((Object)X500Name.DOMAIN_COMPONENT_OID) &&
+ if (this.oid.equals(PKCS9Attribute.EMAIL_ADDRESS_OID) ||
+ (this.oid.equals(X500Name.DOMAIN_COMPONENT_OID) &&
PRESERVE_OLD_DC_ENCODING == false)) {
// EmailAddress and DomainComponent must be IA5String
return new DerValue(DerValue.tag_IA5String,
@@ -495,8 +495,8 @@ public class AVA implements DerEncoder {
// encode as PrintableString unless value contains
// non-PrintableString chars
- if (this.oid.equals((Object)PKCS9Attribute.EMAIL_ADDRESS_OID) ||
- (this.oid.equals((Object)X500Name.DOMAIN_COMPONENT_OID) &&
+ if (this.oid.equals(PKCS9Attribute.EMAIL_ADDRESS_OID) ||
+ (this.oid.equals(X500Name.DOMAIN_COMPONENT_OID) &&
PRESERVE_OLD_DC_ENCODING == false)) {
// EmailAddress and DomainComponent must be IA5String
return new DerValue(DerValue.tag_IA5String, temp.toString());
@@ -967,7 +967,7 @@ public class AVA implements DerEncoder {
previousWhite = false;
- byte valueBytes[] = null;
+ byte[] valueBytes = null;
try {
valueBytes = Character.toString(c).getBytes("UTF8");
} catch (IOException ie) {
@@ -1051,7 +1051,7 @@ public class AVA implements DerEncoder {
// using the hex format below. This will be used only
// when the value is not a string type
- byte data [] = value.toByteArray();
+ byte[] data = value.toByteArray();
retval.append('#');
for (int i = 0; i < data.length; i++) {
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/AccessDescription.java b/jdk/src/java.base/share/classes/sun/security/x509/AccessDescription.java
index fbf4bed3a37..45fa695e88c 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/AccessDescription.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/AccessDescription.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -95,19 +95,19 @@ public final class AccessDescription {
if (this == that) {
return true;
}
- return (accessMethod.equals((Object)that.getAccessMethod()) &&
+ return (accessMethod.equals(that.getAccessMethod()) &&
accessLocation.equals(that.getAccessLocation()));
}
public String toString() {
String method = null;
- if (accessMethod.equals((Object)Ad_CAISSUERS_Id)) {
+ if (accessMethod.equals(Ad_CAISSUERS_Id)) {
method = "caIssuers";
- } else if (accessMethod.equals((Object)Ad_CAREPOSITORY_Id)) {
+ } else if (accessMethod.equals(Ad_CAREPOSITORY_Id)) {
method = "caRepository";
- } else if (accessMethod.equals((Object)Ad_TIMESTAMPING_Id)) {
+ } else if (accessMethod.equals(Ad_TIMESTAMPING_Id)) {
method = "timeStamping";
- } else if (accessMethod.equals((Object)Ad_OCSP_Id)) {
+ } else if (accessMethod.equals(Ad_OCSP_Id)) {
method = "ocsp";
} else {
method = accessMethod.toString();
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/AlgIdDSA.java b/jdk/src/java.base/share/classes/sun/security/x509/AlgIdDSA.java
index c4d2f896b5d..2e08c0509e7 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/AlgIdDSA.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/AlgIdDSA.java
@@ -117,7 +117,7 @@ class AlgIdDSA extends AlgorithmId implements DSAParams
* @param q the DSS/DSA parameter "Q"
* @param g the DSS/DSA parameter "G"
*/
- public AlgIdDSA (byte p [], byte q [], byte g [])
+ public AlgIdDSA (byte[] p, byte[] q, byte[] g)
throws IOException
{
this (new BigInteger (1, p),
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/AlgorithmId.java b/jdk/src/java.base/share/classes/sun/security/x509/AlgorithmId.java
index 294888bfaf4..530dc167c00 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/AlgorithmId.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/AlgorithmId.java
@@ -648,12 +648,12 @@ public class AlgorithmId implements Serializable, DerEncoder {
/*
* COMMON PUBLIC KEY TYPES
*/
- private static final int DH_data[] = { 1, 2, 840, 113549, 1, 3, 1 };
- private static final int DH_PKIX_data[] = { 1, 2, 840, 10046, 2, 1 };
- private static final int DSA_OIW_data[] = { 1, 3, 14, 3, 2, 12 };
- private static final int DSA_PKIX_data[] = { 1, 2, 840, 10040, 4, 1 };
- private static final int RSA_data[] = { 2, 5, 8, 1, 1 };
- private static final int RSAEncryption_data[] =
+ private static final int[] DH_data = { 1, 2, 840, 113549, 1, 3, 1 };
+ private static final int[] DH_PKIX_data = { 1, 2, 840, 10046, 2, 1 };
+ private static final int[] DSA_OIW_data = { 1, 3, 14, 3, 2, 12 };
+ private static final int[] DSA_PKIX_data = { 1, 2, 840, 10040, 4, 1 };
+ private static final int[] RSA_data = { 2, 5, 8, 1, 1 };
+ private static final int[] RSAEncryption_data =
{ 1, 2, 840, 113549, 1, 1, 1 };
public static final ObjectIdentifier DH_oid;
@@ -674,27 +674,27 @@ public class AlgorithmId implements Serializable, DerEncoder {
/*
* COMMON SIGNATURE ALGORITHMS
*/
- private static final int md2WithRSAEncryption_data[] =
+ private static final int[] md2WithRSAEncryption_data =
{ 1, 2, 840, 113549, 1, 1, 2 };
- private static final int md5WithRSAEncryption_data[] =
+ private static final int[] md5WithRSAEncryption_data =
{ 1, 2, 840, 113549, 1, 1, 4 };
- private static final int sha1WithRSAEncryption_data[] =
+ private static final int[] sha1WithRSAEncryption_data =
{ 1, 2, 840, 113549, 1, 1, 5 };
- private static final int sha1WithRSAEncryption_OIW_data[] =
+ private static final int[] sha1WithRSAEncryption_OIW_data =
{ 1, 3, 14, 3, 2, 29 };
- private static final int sha224WithRSAEncryption_data[] =
+ private static final int[] sha224WithRSAEncryption_data =
{ 1, 2, 840, 113549, 1, 1, 14 };
- private static final int sha256WithRSAEncryption_data[] =
+ private static final int[] sha256WithRSAEncryption_data =
{ 1, 2, 840, 113549, 1, 1, 11 };
- private static final int sha384WithRSAEncryption_data[] =
+ private static final int[] sha384WithRSAEncryption_data =
{ 1, 2, 840, 113549, 1, 1, 12 };
- private static final int sha512WithRSAEncryption_data[] =
+ private static final int[] sha512WithRSAEncryption_data =
{ 1, 2, 840, 113549, 1, 1, 13 };
- private static final int shaWithDSA_OIW_data[] =
+ private static final int[] shaWithDSA_OIW_data =
{ 1, 3, 14, 3, 2, 13 };
- private static final int sha1WithDSA_OIW_data[] =
+ private static final int[] sha1WithDSA_OIW_data =
{ 1, 3, 14, 3, 2, 27 };
- private static final int dsaWithSHA1_PKIX_data[] =
+ private static final int[] dsaWithSHA1_PKIX_data =
{ 1, 2, 840, 10040, 4, 3 };
public static final ObjectIdentifier md2WithRSAEncryption_oid;
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/CertificateExtensions.java b/jdk/src/java.base/share/classes/sun/security/x509/CertificateExtensions.java
index 8471be38ae1..a3a0fe187bb 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/CertificateExtensions.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/CertificateExtensions.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
@@ -241,7 +241,7 @@ public class CertificateExtensions implements CertAttrSet {
public String getNameByOid(ObjectIdentifier oid) throws IOException {
for (String name: map.keySet()) {
- if (map.get(name).getExtensionId().equals((Object)oid)) {
+ if (map.get(name).getExtensionId().equals(oid)) {
return name;
}
}
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/CertificatePolicyId.java b/jdk/src/java.base/share/classes/sun/security/x509/CertificatePolicyId.java
index 5f281bfc8f5..8a2f625dda3 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/CertificatePolicyId.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/CertificatePolicyId.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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -93,8 +93,7 @@ public class CertificatePolicyId {
*/
public boolean equals(Object other) {
if (other instanceof CertificatePolicyId)
- return id.equals((Object)
- ((CertificatePolicyId) other).getIdentifier());
+ return id.equals(((CertificatePolicyId) other).getIdentifier());
else
return false;
}
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/Extension.java b/jdk/src/java.base/share/classes/sun/security/x509/Extension.java
index d3a711e4b5e..5649d2a1206 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/Extension.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/Extension.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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -264,7 +264,7 @@ public class Extension implements java.security.cert.Extension {
Extension otherExt = (Extension) other;
if (critical != otherExt.critical)
return false;
- if (!extensionId.equals((Object)otherExt.extensionId))
+ if (!extensionId.equals(otherExt.extensionId))
return false;
return Arrays.equals(extensionValue, otherExt.extensionValue);
}
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/NameConstraintsExtension.java b/jdk/src/java.base/share/classes/sun/security/x509/NameConstraintsExtension.java
index 4d1e4cdd126..eafe3eefe78 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/NameConstraintsExtension.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/NameConstraintsExtension.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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -579,7 +579,7 @@ implements CertAttrSet, Cloneable {
public boolean verifyRFC822SpecialCase(X500Name subject) throws IOException {
for (AVA ava : subject.allAvas()) {
ObjectIdentifier attrOID = ava.getObjectIdentifier();
- if (attrOID.equals((Object)PKCS9Attribute.EMAIL_ADDRESS_OID)) {
+ if (attrOID.equals(PKCS9Attribute.EMAIL_ADDRESS_OID)) {
String attrValue = ava.getValueString();
if (attrValue != null) {
RFC822Name emailName;
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/NetscapeCertTypeExtension.java b/jdk/src/java.base/share/classes/sun/security/x509/NetscapeCertTypeExtension.java
index 735efddfc3a..ca4dc3c53c3 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/NetscapeCertTypeExtension.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/NetscapeCertTypeExtension.java
@@ -69,7 +69,7 @@ implements CertAttrSet {
public static final String S_MIME_CA = "s_mime_ca";
public static final String OBJECT_SIGNING_CA = "object_signing_ca";
- private static final int CertType_data[] = { 2, 16, 840, 1, 113730, 1, 1 };
+ private static final int[] CertType_data = { 2, 16, 840, 1, 113730, 1, 1 };
/**
* Object identifier for the Netscape-Cert-Type extension.
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/OIDMap.java b/jdk/src/java.base/share/classes/sun/security/x509/OIDMap.java
index c8f0da3a671..b6d1b25e51d 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/OIDMap.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/OIDMap.java
@@ -102,7 +102,7 @@ public class OIDMap {
private static final String OCSPNOCHECK = ROOT + "." +
OCSPNoCheckExtension.NAME;
- private static final int NetscapeCertType_data[] =
+ private static final int[] NetscapeCertType_data =
{ 2, 16, 840, 1, 113730, 1, 1 };
/** Map ObjectIdentifier(oid) -> OIDInfo(info) */
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/OIDName.java b/jdk/src/java.base/share/classes/sun/security/x509/OIDName.java
index b5435eb0653..6db9d11e2d3 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/OIDName.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/OIDName.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.
* 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,7 +120,7 @@ public class OIDName implements GeneralNameInterface {
OIDName other = (OIDName)obj;
- return oid.equals((Object)other.oid);
+ return oid.equals(other.oid);
}
/**
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/OtherName.java b/jdk/src/java.base/share/classes/sun/security/x509/OtherName.java
index 5b73fb1a176..0a2842a00be 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/OtherName.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/OtherName.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -176,7 +176,7 @@ public class OtherName implements GeneralNameInterface {
return false;
}
OtherName otherOther = (OtherName)other;
- if (!(otherOther.oid.equals((Object)oid))) {
+ if (!(otherOther.oid.equals(oid))) {
return false;
}
GeneralNameInterface otherGNI = null;
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/PKIXExtensions.java b/jdk/src/java.base/share/classes/sun/security/x509/PKIXExtensions.java
index 3c7696327af..37ac3fbb963 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/PKIXExtensions.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/PKIXExtensions.java
@@ -49,32 +49,32 @@ import sun.security.util.*;
*/
public class PKIXExtensions {
// The object identifiers
- private static final int AuthorityKey_data [] = { 2, 5, 29, 35 };
- private static final int SubjectKey_data [] = { 2, 5, 29, 14 };
- private static final int KeyUsage_data [] = { 2, 5, 29, 15 };
- private static final int PrivateKeyUsage_data [] = { 2, 5, 29, 16 };
- private static final int CertificatePolicies_data [] = { 2, 5, 29, 32 };
- private static final int PolicyMappings_data [] = { 2, 5, 29, 33 };
- private static final int SubjectAlternativeName_data [] = { 2, 5, 29, 17 };
- private static final int IssuerAlternativeName_data [] = { 2, 5, 29, 18 };
- private static final int SubjectDirectoryAttributes_data [] = { 2, 5, 29, 9 };
- private static final int BasicConstraints_data [] = { 2, 5, 29, 19 };
- private static final int NameConstraints_data [] = { 2, 5, 29, 30 };
- private static final int PolicyConstraints_data [] = { 2, 5, 29, 36 };
- private static final int CRLDistributionPoints_data [] = { 2, 5, 29, 31 };
- private static final int CRLNumber_data [] = { 2, 5, 29, 20 };
- private static final int IssuingDistributionPoint_data [] = { 2, 5, 29, 28 };
- private static final int DeltaCRLIndicator_data [] = { 2, 5, 29, 27 };
- private static final int ReasonCode_data [] = { 2, 5, 29, 21 };
- private static final int HoldInstructionCode_data [] = { 2, 5, 29, 23 };
- private static final int InvalidityDate_data [] = { 2, 5, 29, 24 };
- private static final int ExtendedKeyUsage_data [] = { 2, 5, 29, 37 };
- private static final int InhibitAnyPolicy_data [] = { 2, 5, 29, 54 };
- private static final int CertificateIssuer_data [] = { 2, 5, 29, 29 };
- private static final int AuthInfoAccess_data [] = { 1, 3, 6, 1, 5, 5, 7, 1, 1};
- private static final int SubjectInfoAccess_data [] = { 1, 3, 6, 1, 5, 5, 7, 1, 11};
- private static final int FreshestCRL_data [] = { 2, 5, 29, 46 };
- private static final int OCSPNoCheck_data [] = { 1, 3, 6, 1, 5, 5, 7,
+ private static final int[] AuthorityKey_data = { 2, 5, 29, 35 };
+ private static final int[] SubjectKey_data = { 2, 5, 29, 14 };
+ private static final int[] KeyUsage_data = { 2, 5, 29, 15 };
+ private static final int[] PrivateKeyUsage_data = { 2, 5, 29, 16 };
+ private static final int[] CertificatePolicies_data = { 2, 5, 29, 32 };
+ private static final int[] PolicyMappings_data = { 2, 5, 29, 33 };
+ private static final int[] SubjectAlternativeName_data = { 2, 5, 29, 17 };
+ private static final int[] IssuerAlternativeName_data = { 2, 5, 29, 18 };
+ private static final int[] SubjectDirectoryAttributes_data = { 2, 5, 29, 9 };
+ private static final int[] BasicConstraints_data = { 2, 5, 29, 19 };
+ private static final int[] NameConstraints_data = { 2, 5, 29, 30 };
+ private static final int[] PolicyConstraints_data = { 2, 5, 29, 36 };
+ private static final int[] CRLDistributionPoints_data = { 2, 5, 29, 31 };
+ private static final int[] CRLNumber_data = { 2, 5, 29, 20 };
+ private static final int[] IssuingDistributionPoint_data = { 2, 5, 29, 28 };
+ private static final int[] DeltaCRLIndicator_data = { 2, 5, 29, 27 };
+ private static final int[] ReasonCode_data = { 2, 5, 29, 21 };
+ private static final int[] HoldInstructionCode_data = { 2, 5, 29, 23 };
+ private static final int[] InvalidityDate_data = { 2, 5, 29, 24 };
+ private static final int[] ExtendedKeyUsage_data = { 2, 5, 29, 37 };
+ private static final int[] InhibitAnyPolicy_data = { 2, 5, 29, 54 };
+ private static final int[] CertificateIssuer_data = { 2, 5, 29, 29 };
+ private static final int[] AuthInfoAccess_data = { 1, 3, 6, 1, 5, 5, 7, 1, 1};
+ private static final int[] SubjectInfoAccess_data = { 1, 3, 6, 1, 5, 5, 7, 1, 11};
+ private static final int[] FreshestCRL_data = { 2, 5, 29, 46 };
+ private static final int[] OCSPNoCheck_data = { 1, 3, 6, 1, 5, 5, 7,
48, 1, 5};
/**
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/RDN.java b/jdk/src/java.base/share/classes/sun/security/x509/RDN.java
index 6ba421d3b27..6e927c4a340 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/RDN.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/RDN.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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -321,7 +321,7 @@ public class RDN {
*/
DerValue findAttribute(ObjectIdentifier oid) {
for (int i = 0; i < assertion.length; i++) {
- if (assertion[i].oid.equals((Object)oid)) {
+ if (assertion[i].oid.equals(oid)) {
return assertion[i].value;
}
}
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X500Name.java b/jdk/src/java.base/share/classes/sun/security/x509/X500Name.java
index 79d64e84555..740b7fed538 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/X500Name.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X500Name.java
@@ -1119,25 +1119,25 @@ public class X500Name implements GeneralNameInterface, Principal {
* Includes all those specified in RFC 5280 as MUST or SHOULD
* be recognized
*/
- private static final int commonName_data[] = { 2, 5, 4, 3 };
- private static final int SURNAME_DATA[] = { 2, 5, 4, 4 };
- private static final int SERIALNUMBER_DATA[] = { 2, 5, 4, 5 };
- private static final int countryName_data[] = { 2, 5, 4, 6 };
- private static final int localityName_data[] = { 2, 5, 4, 7 };
- private static final int stateName_data[] = { 2, 5, 4, 8 };
- private static final int streetAddress_data[] = { 2, 5, 4, 9 };
- private static final int orgName_data[] = { 2, 5, 4, 10 };
- private static final int orgUnitName_data[] = { 2, 5, 4, 11 };
- private static final int title_data[] = { 2, 5, 4, 12 };
- private static final int GIVENNAME_DATA[] = { 2, 5, 4, 42 };
- private static final int INITIALS_DATA[] = { 2, 5, 4, 43 };
- private static final int GENERATIONQUALIFIER_DATA[] = { 2, 5, 4, 44 };
- private static final int DNQUALIFIER_DATA[] = { 2, 5, 4, 46 };
+ private static final int[] commonName_data = { 2, 5, 4, 3 };
+ private static final int[] SURNAME_DATA = { 2, 5, 4, 4 };
+ private static final int[] SERIALNUMBER_DATA = { 2, 5, 4, 5 };
+ private static final int[] countryName_data = { 2, 5, 4, 6 };
+ private static final int[] localityName_data = { 2, 5, 4, 7 };
+ private static final int[] stateName_data = { 2, 5, 4, 8 };
+ private static final int[] streetAddress_data = { 2, 5, 4, 9 };
+ private static final int[] orgName_data = { 2, 5, 4, 10 };
+ private static final int[] orgUnitName_data = { 2, 5, 4, 11 };
+ private static final int[] title_data = { 2, 5, 4, 12 };
+ private static final int[] GIVENNAME_DATA = { 2, 5, 4, 42 };
+ private static final int[] INITIALS_DATA = { 2, 5, 4, 43 };
+ private static final int[] GENERATIONQUALIFIER_DATA = { 2, 5, 4, 44 };
+ private static final int[] DNQUALIFIER_DATA = { 2, 5, 4, 46 };
- private static final int ipAddress_data[] = { 1, 3, 6, 1, 4, 1, 42, 2, 11, 2, 1 };
- private static final int DOMAIN_COMPONENT_DATA[] =
+ private static final int[] ipAddress_data = { 1, 3, 6, 1, 4, 1, 42, 2, 11, 2, 1 };
+ private static final int[] DOMAIN_COMPONENT_DATA =
{ 0, 9, 2342, 19200300, 100, 1, 25 };
- private static final int userid_data[] =
+ private static final int[] userid_data =
{ 0, 9, 2342, 19200300, 100, 1, 1 };
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLEntryImpl.java b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLEntryImpl.java
index 8646b43841a..d92da97e1db 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLEntryImpl.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLEntryImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, 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
@@ -414,7 +414,7 @@ public class X509CRLEntryImpl extends X509CRLEntry
e.hasMoreElements();) {
ex = e.nextElement();
inCertOID = ex.getExtensionId();
- if (inCertOID.equals((Object)findOID)) {
+ if (inCertOID.equals(findOID)) {
crlExt = ex;
break;
}
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java
index 7a68cebdabb..d248121fd97 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.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
@@ -1039,7 +1039,7 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
e.hasMoreElements();) {
ex = e.nextElement();
inCertOID = ex.getExtensionId();
- if (inCertOID.equals((Object)findOID)) {
+ if (inCertOID.equals(findOID)) {
crlExt = ex;
break;
}
@@ -1086,7 +1086,7 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
throw new CRLException("Invalid DER-encoded CRL data");
signedCRL = val.toByteArray();
- DerValue seq[] = new DerValue[3];
+ DerValue[] seq = new DerValue[3];
seq[0] = val.data.getDerValue();
seq[1] = val.data.getDerValue();
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
index b74de5a5dfe..955f7793a86 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1339,7 +1339,7 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
return ex;
}
for (Extension ex2: extensions.getAllExtensions()) {
- if (ex2.getExtensionId().equals((Object)oid)) {
+ if (ex2.getExtensionId().equals(oid)) {
//XXXX May want to consider cloning this
return ex2;
}
@@ -1395,7 +1395,7 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
for (Extension ex : exts.getAllExtensions()) {
ObjectIdentifier inCertOID = ex.getExtensionId();
- if (inCertOID.equals((Object)findOID)) {
+ if (inCertOID.equals(findOID)) {
certExt = ex;
break;
}
diff --git a/jdk/src/java.base/share/classes/sun/text/normalizer/UnicodeSet.java b/jdk/src/java.base/share/classes/sun/text/normalizer/UnicodeSet.java
index f3ee71aa969..3fcd67466b7 100644
--- a/jdk/src/java.base/share/classes/sun/text/normalizer/UnicodeSet.java
+++ b/jdk/src/java.base/share/classes/sun/text/normalizer/UnicodeSet.java
@@ -1850,7 +1850,7 @@ public class UnicodeSet implements UnicodeMatcher {
syntaxError(chars, "Invalid property pattern");
}
chars.jumpahead(pos.getIndex());
- rebuiltPat.append(patStr.substring(0, pos.getIndex()));
+ rebuiltPat.append(patStr, 0, pos.getIndex());
}
//----------------------------------------------------------------
diff --git a/jdk/src/java.base/share/classes/sun/util/BuddhistCalendar.java b/jdk/src/java.base/share/classes/sun/util/BuddhistCalendar.java
index adb4163fe8e..7c4a843239d 100644
--- a/jdk/src/java.base/share/classes/sun/util/BuddhistCalendar.java
+++ b/jdk/src/java.base/share/classes/sun/util/BuddhistCalendar.java
@@ -242,12 +242,13 @@ public class BuddhistCalendar extends GregorianCalendar {
return s;
}
p += yearField.length();
- StringBuilder sb = new StringBuilder(s.substring(0, p));
+ StringBuilder sb = new StringBuilder(s.length() + 10);
+ sb.append(s, 0, p);
// Skip the year number
while (Character.isDigit(s.charAt(p++)))
;
int year = internalGet(YEAR) + BUDDHIST_YEAR_OFFSET;
- sb.append(year).append(s.substring(p - 1));
+ sb.append(year).append(s, p - 1, s.length());
return sb.toString();
}
diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c
index fa4c1c9ca99..64deecadec4 100644
--- a/jdk/src/java.base/share/native/libjli/java.c
+++ b/jdk/src/java.base/share/native/libjli/java.c
@@ -145,7 +145,7 @@ static struct vmdesc *knownVMs = NULL;
static int knownVMsCount = 0;
static int knownVMsLimit = 0;
-static void GrowKnownVMs();
+static void GrowKnownVMs(int minimum);
static int KnownVMIndex(const char* name);
static void FreeKnownVMs();
static jboolean IsWildCardEnabled();
diff --git a/jdk/src/java.base/unix/classes/java/io/UnixFileSystem.java b/jdk/src/java.base/unix/classes/java/io/UnixFileSystem.java
index fb0fef63646..c0ca02dd4ad 100644
--- a/jdk/src/java.base/unix/classes/java/io/UnixFileSystem.java
+++ b/jdk/src/java.base/unix/classes/java/io/UnixFileSystem.java
@@ -65,8 +65,8 @@ class UnixFileSystem extends FileSystem {
int n = len;
while ((n > 0) && (pathname.charAt(n - 1) == '/')) n--;
if (n == 0) return "/";
- StringBuffer sb = new StringBuffer(pathname.length());
- if (off > 0) sb.append(pathname.substring(0, off));
+ StringBuilder sb = new StringBuilder(pathname.length());
+ if (off > 0) sb.append(pathname, 0, off);
char prevChar = 0;
for (int i = off; i < n; i++) {
char c = pathname.charAt(i);
diff --git a/jdk/src/java.base/unix/classes/sun/nio/fs/MimeTypesFileTypeDetector.java b/jdk/src/java.base/unix/classes/sun/nio/fs/MimeTypesFileTypeDetector.java
index b742b3f626f..20e077cbdc3 100644
--- a/jdk/src/java.base/unix/classes/sun/nio/fs/MimeTypesFileTypeDetector.java
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/MimeTypesFileTypeDetector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -83,18 +83,6 @@ class MimeTypesFileTypeDetector extends AbstractFileTypeDetector {
return mimeType;
}
- // Get the extension of a file name.
- private static String getExtension(String name) {
- String ext = "";
- if (name != null && !name.isEmpty()) {
- int dot = name.indexOf('.');
- if ((dot >= 0) && (dot < name.length() - 1)) {
- ext = name.substring(dot + 1);
- }
- }
- return ext;
- }
-
/**
* Parse the mime types file, and store the type-extension mappings into
* mimeTypeMap. The mime types file is not loaded until the first probe
diff --git a/jdk/src/java.base/windows/classes/java/io/WinNTFileSystem.java b/jdk/src/java.base/windows/classes/java/io/WinNTFileSystem.java
index caa47f80c08..9ee66bf4169 100644
--- a/jdk/src/java.base/windows/classes/java/io/WinNTFileSystem.java
+++ b/jdk/src/java.base/windows/classes/java/io/WinNTFileSystem.java
@@ -104,7 +104,7 @@ class WinNTFileSystem extends FileSystem {
if (off < 3) off = 0; /* Avoid fencepost cases with UNC pathnames */
int src;
char slash = this.slash;
- StringBuffer sb = new StringBuffer(len);
+ StringBuilder sb = new StringBuilder(len);
if (off == 0) {
/* Complete normalization, including prefix */
@@ -112,7 +112,7 @@ class WinNTFileSystem extends FileSystem {
} else {
/* Partial normalization */
src = off;
- sb.append(path.substring(0, off));
+ sb.append(path, 0, off);
}
/* Remove redundant slashes from the remainder of the path, forcing all
@@ -156,8 +156,7 @@ class WinNTFileSystem extends FileSystem {
}
}
- String rv = sb.toString();
- return rv;
+ return sb.toString();
}
/* A normal Win32 pathname contains no duplicate slashes, except possibly
@@ -172,7 +171,7 @@ class WinNTFileSystem extends FileSystem {
else directory-relative (has form "z:foo")
3 absolute local pathname (begins with "z:\\")
*/
- private int normalizePrefix(String path, int len, StringBuffer sb) {
+ private int normalizePrefix(String path, int len, StringBuilder sb) {
int src = 0;
while ((src < len) && isSlash(path.charAt(src))) src++;
char c;
diff --git a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java
index eeed61d3798..115002b5825 100644
--- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java
+++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java
@@ -275,7 +275,7 @@ public final class JRSUIControl {
}
- Hit getHitForPoint(final double x, final double y, final double w, final double h, final double hitX, final double hitY) {
+ Hit getHitForPoint(final int x, final int y, final int w, final int h, final int hitX, final int hitY) {
sync();
// reflect hitY about the midline of the control before sending to native
final Hit hit = JRSUIConstants.getHit(getNativeHitPart(cfDictionaryPtr, priorEncodedProperties, currentEncodedProperties, x, y, w, h, hitX, 2 * y + h - hitY));
@@ -283,7 +283,7 @@ public final class JRSUIControl {
return hit;
}
- void getPartBounds(final double[] rect, final double x, final double y, final double w, final double h, final int part) {
+ void getPartBounds(final double[] rect, final int x, final int y, final int w, final int h, final int part) {
if (rect == null) throw new NullPointerException("Cannot load null rect");
if (rect.length != 4) throw new IllegalArgumentException("Rect must have four elements");
@@ -292,7 +292,7 @@ public final class JRSUIControl {
priorEncodedProperties = currentEncodedProperties;
}
- double getScrollBarOffsetChange(final double x, final double y, final double w, final double h, final int offset, final int visibleAmount, final int extent) {
+ double getScrollBarOffsetChange(final int x, final int y, final int w, final int h, final int offset, final int visibleAmount, final int extent) {
sync();
final double offsetChange = getNativeScrollBarOffsetChange(cfDictionaryPtr, priorEncodedProperties, currentEncodedProperties, x, y, w, h, offset, visibleAmount, extent);
priorEncodedProperties = currentEncodedProperties;
diff --git a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java
index 94ef685714e..69fdf688013 100644
--- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java
+++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,15 @@
package apple.laf;
-import com.apple.laf.AquaImageFactory.NineSliceMetrics;
-
-import apple.laf.JRSUIConstants.*;
-import sun.security.action.GetPropertyAction;
-
import java.security.AccessController;
-public class JRSUIUtils {
+import apple.laf.JRSUIConstants.Hit;
+import apple.laf.JRSUIConstants.ScrollBarPart;
+import com.apple.laf.AquaImageFactory.NineSliceMetrics;
+import sun.security.action.GetPropertyAction;
+
+public final class JRSUIUtils {
+
static boolean isLeopard = isMacOSXLeopard();
static boolean isSnowLeopardOrBelow = isMacOSXSnowLeopardOrBelow();
@@ -48,7 +49,9 @@ public class JRSUIUtils {
return currentMacOSXVersionMatchesGivenVersionRange(version, true, false, false);
}
- static boolean currentMacOSXVersionMatchesGivenVersionRange(final int version, final boolean inclusive, final boolean matchBelow, final boolean matchAbove) {
+ static boolean currentMacOSXVersionMatchesGivenVersionRange(
+ final int version, final boolean inclusive,
+ final boolean matchBelow, final boolean matchAbove) {
// split the "10.x.y" version number
String osVersion = AccessController.doPrivileged(new GetPropertyAction("os.version"));
String[] fragments = osVersion.split("\\.");
@@ -99,12 +102,22 @@ public class JRSUIUtils {
return shouldUseScrollToClick();
}
- public static void getPartBounds(final double[] rect, final JRSUIControl control, final double x, final double y, final double w, final double h, final ScrollBarPart part) {
+ public static void getPartBounds(final double[] rect,
+ final JRSUIControl control,
+ final int x, final int y, final int w,
+ final int h,
+ final ScrollBarPart part) {
control.getPartBounds(rect, x, y, w, h, part.ordinal);
}
- public static double getNativeOffsetChange(final JRSUIControl control, final double x, final double y, final double w, final double h, final int offset, final int visibleAmount, final int extent) {
- return control.getScrollBarOffsetChange(x, y, w, h, offset, visibleAmount, extent);
+ public static double getNativeOffsetChange(final JRSUIControl control,
+ final int x, final int y,
+ final int w, final int h,
+ final int offset,
+ final int visibleAmount,
+ final int extent) {
+ return control.getScrollBarOffsetChange(x, y, w, h, offset,
+ visibleAmount, extent);
}
}
@@ -115,7 +128,10 @@ public class JRSUIUtils {
}
public static class HitDetection {
- public static Hit getHitForPoint(final JRSUIControl control, final double x, final double y, final double w, final double h, final double hitX, final double hitY) {
+ public static Hit getHitForPoint(final JRSUIControl control,
+ final int x, final int y, final int w,
+ final int h, final int hitX,
+ final int hitY) {
return control.getHitForPoint(x, y, w, h, hitX, hitY);
}
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Cursor.java b/jdk/src/java.desktop/share/classes/java/awt/Cursor.java
index 5c7cce45230..3e6d9410476 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Cursor.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Cursor.java
@@ -26,8 +26,8 @@ package java.awt;
import java.beans.ConstructorProperties;
import java.io.InputStream;
-import java.net.URL;
import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.util.Hashtable;
import java.util.Properties;
@@ -261,7 +261,7 @@ public class Cursor implements java.io.Serializable {
* @throws IllegalArgumentException if the specified cursor type is
* invalid
*/
- static public Cursor getPredefinedCursor(int type) {
+ public static Cursor getPredefinedCursor(int type) {
if (type < Cursor.DEFAULT_CURSOR || type > Cursor.MOVE_CURSOR) {
throw new IllegalArgumentException("illegal cursor type");
}
@@ -286,7 +286,7 @@ public class Cursor implements java.io.Serializable {
* GraphicsEnvironment.isHeadless returns true
* @exception AWTException in case of erroneous retrieving of the cursor
*/
- static public Cursor getSystemCustomCursor(final String name)
+ public static Cursor getSystemCustomCursor(final String name)
throws AWTException, HeadlessException {
GraphicsEnvironment.checkHeadless();
Cursor cursor = systemCustomCursors.get(name);
@@ -330,18 +330,15 @@ public class Cursor implements java.io.Serializable {
} catch (NumberFormatException nfe) {
throw new AWTException("failed to parse hotspot property for cursor: " + name);
}
-
- try {
- final Toolkit toolkit = Toolkit.getDefaultToolkit();
- final String file = RESOURCE_PREFIX + fileName;
-
- cursor = AccessController.doPrivileged(
- (PrivilegedExceptionAction) () -> {
- URL url = Cursor.class.getResource(file);
- Image image = toolkit.getImage(url);
- return toolkit.createCustomCursor(image, hotPoint,
- localized);
- });
+ final Toolkit toolkit = Toolkit.getDefaultToolkit();
+ final String file = RESOURCE_PREFIX + fileName;
+ final InputStream in = AccessController.doPrivileged(
+ (PrivilegedAction) () -> {
+ return Cursor.class.getResourceAsStream(file);
+ });
+ try (in) {
+ Image image = toolkit.createImage(in.readAllBytes());
+ cursor = toolkit.createCustomCursor(image, hotPoint, localized);
} catch (Exception e) {
throw new AWTException(
"Exception: " + e.getClass() + " " + e.getMessage() +
@@ -365,7 +362,7 @@ public class Cursor implements java.io.Serializable {
*
* @return the default cursor
*/
- static public Cursor getDefaultCursor() {
+ public static Cursor getDefaultCursor() {
return getPredefinedCursor(Cursor.DEFAULT_CURSOR);
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
index 31107cbc637..e48d28eacf8 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
@@ -58,6 +58,14 @@ import sun.awt.PeerEvent;
import sun.awt.SunToolkit;
import sun.util.CoreResourceBundleControl;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Arrays;
+import java.util.ServiceLoader;
+import java.util.Set;
+import java.util.stream.Collectors;
+import javax.accessibility.AccessibilityProvider;
+
/**
* This class is the abstract superclass of all actual
* implementations of the Abstract Window Toolkit. Subclasses of
@@ -420,7 +428,7 @@ public abstract class Toolkit {
}
}
- // Get the names of any assistive technolgies to load. First
+ // Get the names of any assistive technologies to load. First
// check the system property and then check the properties
// file.
String classNames = System.getProperty("javax.accessibility.assistive_technologies");
@@ -436,85 +444,125 @@ public abstract class Toolkit {
}
/**
- * Loads additional classes into the VM, using the property
- * 'assistive_technologies' specified in the Sun reference
- * implementation by a line in the 'accessibility.properties'
- * file. The form is "assistive_technologies=..." where
- * the "..." is a comma-separated list of assistive technology
- * classes to load. Each class is loaded in the order given
- * and a single instance of each is created using
- * Class.forName(class).newInstance(). All errors are handled
- * via an AWTError exception.
+ * Rethrow the AWTError but include the cause.
*
- *
The assumption is made that assistive technology classes are supplied
- * as part of INSTALLED (as opposed to: BUNDLED) extensions or specified
- * on the class path
- * (and therefore can be loaded using the class loader returned by
- * a call to ClassLoader.getSystemClassLoader, whose
- * delegation parent is the extension class loader for installed
- * extensions).
+ * @param s the error message
+ * @param e the original exception
+ * @throw the new AWTError including the cause (the original exception)
+ */
+ private static void newAWTError(Throwable e, String s) {
+ AWTError newAWTError = new AWTError(s);
+ newAWTError.initCause(e);
+ throw newAWTError;
+ }
+
+ /**
+ * When a service provider for Assistive Technology is not found look for a
+ * supporting class on the class path and instantiate it.
+ *
+ * @param atName the name of the class to be loaded
+ */
+ private static void fallbackToLoadClassForAT(String atName) {
+ try {
+ Class.forName(atName, false, ClassLoader.getSystemClassLoader()).newInstance();
+ } catch (ClassNotFoundException e) {
+ newAWTError(e, "Assistive Technology not found: " + atName);
+ } catch (InstantiationException e) {
+ newAWTError(e, "Could not instantiate Assistive Technology: " + atName);
+ } catch (IllegalAccessException e) {
+ newAWTError(e, "Could not access Assistive Technology: " + atName);
+ } catch (Exception e) {
+ newAWTError(e, "Error trying to install Assistive Technology: " + atName);
+ }
+ }
+
+ /**
+ * Loads accessibility support using the property assistive_technologies.
+ * The form is assistive_technologies= followed by a comma-separated list of
+ * assistive technology providers to load. The order in which providers are
+ * loaded is determined by the order in which the ServiceLoader discovers
+ * implementations of the AccessibilityProvider interface, not by the order
+ * of provider names in the property list. When a provider is found its
+ * accessibility implementation will be started by calling the provider's
+ * activate method. All errors are handled via an AWTError exception.
*/
private static void loadAssistiveTechnologies() {
// Load any assistive technologies
if (atNames != null) {
ClassLoader cl = ClassLoader.getSystemClassLoader();
- StringTokenizer parser = new StringTokenizer(atNames," ,");
- String atName;
- while (parser.hasMoreTokens()) {
- atName = parser.nextToken();
+ Set names = Arrays.stream(atNames.split(","))
+ .map(String::trim)
+ .collect(Collectors.toSet());
+ final Map providers = new HashMap<>();
+ AccessController.doPrivileged((PrivilegedAction) () -> {
try {
- Class> clazz;
- if (cl != null) {
- clazz = cl.loadClass(atName);
- } else {
- clazz = Class.forName(atName);
+ for (AccessibilityProvider p : ServiceLoader.load(AccessibilityProvider.class, cl)) {
+ String name = p.getName();
+ if (names.contains(name) && !providers.containsKey(name)) {
+ p.activate();
+ providers.put(name, p);
+ }
}
- clazz.newInstance();
- } catch (ClassNotFoundException e) {
- throw new AWTError("Assistive Technology not found: "
- + atName);
- } catch (InstantiationException e) {
- throw new AWTError("Could not instantiate Assistive"
- + " Technology: " + atName);
- } catch (IllegalAccessException e) {
- throw new AWTError("Could not access Assistive"
- + " Technology: " + atName);
- } catch (Exception e) {
- throw new AWTError("Error trying to install Assistive"
- + " Technology: " + atName + " " + e);
+ } catch (java.util.ServiceConfigurationError | Exception e) {
+ newAWTError(e, "Could not load or activate service provider");
}
- }
+ return null;
+ });
+ names.stream()
+ .filter(n -> !providers.containsKey(n))
+ .forEach(Toolkit::fallbackToLoadClassForAT);
}
}
/**
* Gets the default toolkit.
*
- * If a system property named "java.awt.headless" is set
- * to true then the headless implementation
- * of Toolkit is used.
+ * If a system property named {@code "java.awt.headless"} is set
+ * to {@code true} then the headless implementation
+ * of {@code Toolkit} is used.
*
- * If there is no "java.awt.headless" or it is set to
- * false and there is a system property named
- * "awt.toolkit",
+ * If there is no {@code "java.awt.headless"} or it is set to
+ * {@code false} and there is a system property named
+ * {@code "awt.toolkit"},
* that property is treated as the name of a class that is a subclass
- * of Toolkit;
+ * of {@code Toolkit};
* otherwise the default platform-specific implementation of
- * Toolkit is used.
+ * {@code Toolkit} is used.
*
- * Also loads additional classes into the VM, using the property
- * 'assistive_technologies' specified in the Sun reference
- * implementation by a line in the 'accessibility.properties'
- * file. The form is "assistive_technologies=..." where
- * the "..." is a comma-separated list of assistive technology
- * classes to load. Each class is loaded in the order given
- * and a single instance of each is created using
- * Class.forName(class).newInstance(). This is done just after
- * the AWT toolkit is created. All errors are handled via an
- * AWTError exception.
- * @return the default toolkit.
+ * If this Toolkit is not a headless implementation and if they exist, service
+ * providers of {@link javax.accessibility.AccessibilityProvider} will be loaded
+ * if specified by the system property
+ * {@code javax.accessibility.assistive_technologies}.
+ *
+ * An example of setting this property is to invoke Java with
+ * {@code -Djavax.accessibility.assistive_technologies=MyServiceProvider}.
+ * In addition to MyServiceProvider other service providers can be specified
+ * using a comma separated list. Service providers are loaded after the AWT
+ * toolkit is created. All errors are handled via an AWTError exception.
+ *
+ * The names specified in the assistive_technologies property are used to query
+ * each service provider implementation. If the requested name matches the
+ * {@linkplain AccessibilityProvider#getName name} of the service provider, the
+ * {@link AccessibilityProvider#activate} method will be invoked to activate the
+ * matching service provider.
+ *
+ * @implSpec
+ * If assistive technology service providers are not specified with a system
+ * property this implementation will look in a properties file located as follows:
+ *
+ * Only the first of these files to be located will be consulted. The requested
+ * service providers are specified by setting the {@code assistive_technologies=}
+ * property. A single provider or a comma separated list of providers can be
+ * specified.
+ *
+ * @return the default toolkit.
* @exception AWTError if a toolkit could not be found, or
* if one could not be accessed or instantiated.
+ * @see java.util.ServiceLoader
+ * @see javax.accessibility.AccessibilityProvider
*/
public static synchronized Toolkit getDefaultToolkit() {
if (toolkit == null) {
@@ -550,7 +598,9 @@ public abstract class Toolkit {
return null;
}
});
- loadAssistiveTechnologies();
+ if (!GraphicsEnvironment.isHeadless()) {
+ loadAssistiveTechnologies();
+ }
}
return toolkit;
}
diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibilityProvider.java b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibilityProvider.java
new file mode 100644
index 00000000000..001b42f15d6
--- /dev/null
+++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibilityProvider.java
@@ -0,0 +1,93 @@
+/*
+ * 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 javax.accessibility;
+
+/**
+ * Service Provider Interface (SPI) for Assistive Technology.
+ *
+ * This service provider class provides mappings from the platform
+ * specific accessibility APIs to the Java Accessibility API.
+ *
+ * Each service provider implementation is named and can be activated via the
+ * {@link #activate} method. Service providers can be loaded when the default
+ * {@link java.awt.Toolkit toolkit} is initialized.
+ *
+ * @apiNote There will typically be one provider per platform, such as Windows
+ * or Linux, to support accessibility for screen readers and magnifiers. However,
+ * more than one service provider can be activated. For example, a test tool
+ * which provides visual results obtained by interrogating the Java Accessibility
+ * API can be activated along with the activation of the support for screen readers
+ * and screen magnifiers.
+ *
+ * @see java.awt.Toolkit#getDefaultToolkit
+ * @see java.util.ServiceLoader
+ * @since 1.9
+ */
+public abstract class AccessibilityProvider {
+
+ /**
+ * Initializes a new accessibility provider.
+ *
+ * @throws SecurityException
+ * If a security manager has been installed and it denies
+ * {@link RuntimePermission} {@code "accessibilityProvider"}
+ */
+ protected AccessibilityProvider() {
+ // Use a permission check when calling a private constructor to check that
+ // the proper security permission has been granted before the Object superclass
+ // is called. If an exception is thrown before the Object superclass is
+ // constructed a finalizer in a subclass of this class will not be run.
+ // This protects against a finalizer vulnerability.
+ this(checkPermission());
+ }
+
+ private AccessibilityProvider(Void ignore) { }
+
+ /**
+ * If this code is running with a security manager and if the permission
+ * "accessibilityProvider" has not been granted SecurityException will be thrown.
+ *
+ */
+ private static Void checkPermission() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new RuntimePermission("accessibilityProvider"));
+ return null;
+ }
+
+ /**
+ * Returns the name of this service provider. This name is used to locate a
+ * requested service provider.
+ *
+ * @return the name of this service provider
+ */
+ public abstract String getName();
+
+ /**
+ * Activates the support provided by this service provider.
+ */
+ public abstract void activate();
+
+}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java
index 76451154127..f22fd8e86dd 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.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
@@ -896,11 +896,12 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI {
// Paint the background for the tab area
if ( tabPane.isOpaque() ) {
- if (!c.isBackgroundSet() && (tabAreaBackground != null)) {
+ Color background = c.getBackground();
+ if (background instanceof UIResource && tabAreaBackground != null) {
g.setColor(tabAreaBackground);
}
else {
- g.setColor( c.getBackground() );
+ g.setColor(background);
}
switch ( tabPlacement ) {
case LEFT:
diff --git a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java
index 80b58f37e1c..847c0884b6a 100644
--- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java
@@ -291,7 +291,7 @@ public abstract class SunToolkit extends Toolkit
// Maps from non-Component/MenuComponent to AppContext.
// WeakHashMap
private static final Map