--- a/.hgtags Wed Dec 12 08:38:45 2018 -0500
+++ b/.hgtags Tue Dec 18 15:08:56 2018 -0500
@@ -526,3 +526,4 @@
f8fb0c86f2b3d24294d39c5685a628e1beb14ba7 jdk-12+21
732bec44c89e8b93a38296bf690f97b7230c5b6d jdk-12+22
eef755718cb24813031a842bbfc716a6cea18e9a jdk-12+23
+cc4098b3bc10d1c390384289025fea7b0d4b9e93 jdk-13+0
--- a/make/Docs.gmk Wed Dec 12 08:38:45 2018 -0500
+++ b/make/Docs.gmk Tue Dec 18 15:08:56 2018 -0500
@@ -168,14 +168,6 @@
font-family: DejaVu Sans, Arial, Helvetica, sans-serif; \
font-weight: normal;">$(DRAFT_TEXT)</div>
-JDK_INDEX_CONTENT := \
- <!DOCTYPE html> \
- <html lang="en"> \
- <head> \
- <meta http-equiv="refresh" content="0;url=api/index.html"> \
- </head> \
- </html>
-
################################################################################
# JDK javadoc titles/text snippets
@@ -485,14 +477,7 @@
################################################################################
-JDK_INDEX_HTML := $(DOCS_OUTPUTDIR)/index.html
-
-$(JDK_INDEX_HTML):
- $(ECHO) '$(JDK_INDEX_CONTENT)' > $@
-
-JDK_INDEX_TARGETS += $(JDK_INDEX_HTML)
-
-# Copy the global resources
+# Copy the global resources, including the top-level redirect index.html
GLOBAL_SPECS_RESOURCES_DIR := $(TOPDIR)/make/data/docs-resources/
$(eval $(call SetupCopyFiles, COPY_GLOBAL_RESOURCES, \
SRC := $(GLOBAL_SPECS_RESOURCES_DIR), \
@@ -532,9 +517,9 @@
) \
)
-ifeq ($(ENABLE_FULL_DOCS), true)
+ifneq ($(PANDOC), )
# For all markdown files in $module/share/specs directories, convert them to
- # html.
+ # html, if we have pandoc (otherwise we'll just skip this).
GLOBAL_SPECS_DEFAULT_CSS_FILE := $(DOCS_OUTPUTDIR)/resources/jdk-default.css
--- a/make/Images.gmk Wed Dec 12 08:38:45 2018 -0500
+++ b/make/Images.gmk Tue Dec 18 15:08:56 2018 -0500
@@ -36,7 +36,7 @@
# Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, Images-pre.gmk))
-############################################################################
+################################################################################
# All modules for the current target platform.
ALL_MODULES := $(call FindAllModules)
@@ -57,7 +57,7 @@
JMODS := $(wildcard $(IMAGES_OUTPUTDIR)/jmods/*.jmod)
# Use this file inside the image as target for make rule
-JIMAGE_TARGET_FILE := bin/java$(EXE_SUFFIX)
+JIMAGE_TARGET_FILE := release
JLINK_ORDER_RESOURCES := **module-info.class
JLINK_JLI_CLASSES :=
--- a/make/Main.gmk Wed Dec 12 08:38:45 2018 -0500
+++ b/make/Main.gmk Tue Dec 18 15:08:56 2018 -0500
@@ -862,8 +862,6 @@
docs-jdk-specs: $(JVM_DOCS_TARGETS) jdk.jdi-gensrc \
docs-jdk-index
- docs-jdk-index: exploded-image buildtools-modules
-
docs-zip: docs-jdk
# Tests
--- a/make/autoconf/hotspot.m4 Wed Dec 12 08:38:45 2018 -0500
+++ b/make/autoconf/hotspot.m4 Tue Dec 18 15:08:56 2018 -0500
@@ -327,7 +327,7 @@
# Only enable Shenandoah on supported arches
AC_MSG_CHECKING([if shenandoah can be built])
- if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86" || test "x$OPENJDK_TARGET_CPU" = "xaarch64" ; then
+ if test "x$OPENJDK_TARGET_CPU" = "xx86_64" || test "x$OPENJDK_TARGET_CPU" = "xaarch64" ; then
AC_MSG_RESULT([yes])
else
DISABLED_JVM_FEATURES="$DISABLED_JVM_FEATURES shenandoahgc"
--- a/make/autoconf/version-numbers Wed Dec 12 08:38:45 2018 -0500
+++ b/make/autoconf/version-numbers Tue Dec 18 15:08:56 2018 -0500
@@ -25,17 +25,17 @@
# Default version numbers to use unless overridden by configure
-DEFAULT_VERSION_FEATURE=12
+DEFAULT_VERSION_FEATURE=13
DEFAULT_VERSION_INTERIM=0
DEFAULT_VERSION_UPDATE=0
DEFAULT_VERSION_PATCH=0
DEFAULT_VERSION_EXTRA1=0
DEFAULT_VERSION_EXTRA2=0
DEFAULT_VERSION_EXTRA3=0
-DEFAULT_VERSION_DATE=2019-03-19
-DEFAULT_VERSION_CLASSFILE_MAJOR=56 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
+DEFAULT_VERSION_DATE=2019-09-17
+DEFAULT_VERSION_CLASSFILE_MAJOR=57 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
DEFAULT_VERSION_CLASSFILE_MINOR=0
-DEFAULT_ACCEPTABLE_BOOT_VERSIONS="11 12"
+DEFAULT_ACCEPTABLE_BOOT_VERSIONS="11 12 13"
LAUNCHER_NAME=openjdk
PRODUCT_NAME=OpenJDK
--- a/make/common/SetupJavaCompilers.gmk Wed Dec 12 08:38:45 2018 -0500
+++ b/make/common/SetupJavaCompilers.gmk Tue Dec 18 15:08:56 2018 -0500
@@ -72,7 +72,7 @@
$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
JVM := $(JAVA_JAVAC), \
JAVAC := $(NEW_JAVAC), \
- FLAGS := -source 12 -target 12 --doclint-format html5 \
+ FLAGS := -source 13 -target 13 --doclint-format html5 \
-encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
@@ -82,7 +82,7 @@
$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
JVM := $(JAVA_JAVAC), \
JAVAC := $(NEW_JAVAC), \
- FLAGS := -source 12 -target 12 \
+ FLAGS := -source 13 -target 13 \
-encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS), \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make/data/docs-resources/index.html Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<!--
+ Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ 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.
+-->
+<html lang="en">
+<head>
+<meta http-equiv="refresh" content="0;url=api/index.html">
+<title>Java API Documentation redirect</title>
+</head>
+<body>
+</body>
+</html>
--- a/make/jdk/src/classes/build/tools/jigsaw/ModuleSummary.java Wed Dec 12 08:38:45 2018 -0500
+++ b/make/jdk/src/classes/build/tools/jigsaw/ModuleSummary.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,11 +36,13 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
+import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@@ -552,6 +554,21 @@
return sb.toString();
}
+ private String providesEntry(Provides p) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(String.format("provides %s<br>\n", p.service()));
+ List<String> pvs = new ArrayList<>(p.providers());
+ pvs.sort(Comparator.naturalOrder());
+ for (int i = 0; i < pvs.size(); i++) { // My kingdom for Stream::zip ...
+ String fmt = ((i == 0)
+ ? " with %s"
+ : ",<br> %s");
+ sb.append(String.format(fmt, pvs.get(i)));
+ }
+ sb.append("\n");
+ return sb.toString();
+ }
+
public String servicesColumn() {
StringBuilder sb = new StringBuilder();
sb.append(String.format(" <td class=\"%s\">", CODE));
@@ -560,8 +577,7 @@
.forEach(s -> sb.append("uses ").append(s).append("<br>").append("\n"));
ms.descriptor().provides().stream()
.sorted(Comparator.comparing(Provides::service))
- .map(p -> String.format("provides %s<br> with %s",
- p.service(), p.providers()))
+ .map(this::providesEntry)
.forEach(p -> sb.append(p).append("<br>").append("\n"));
sb.append("</td>");
return sb.toString();
--- a/src/hotspot/cpu/ppc/assembler_ppc.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/ppc/assembler_ppc.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -539,6 +539,12 @@
XVSUBDP_OPCODE = (60u << OPCODE_SHIFT | 104u << 3),
XVMULSP_OPCODE = (60u << OPCODE_SHIFT | 80u << 3),
XVMULDP_OPCODE = (60u << OPCODE_SHIFT | 112u << 3),
+ XVMADDASP_OPCODE=(60u << OPCODE_SHIFT | 65u << 3),
+ XVMADDADP_OPCODE=(60u << OPCODE_SHIFT | 97u << 3),
+ XVMSUBASP_OPCODE=(60u << OPCODE_SHIFT | 81u << 3),
+ XVMSUBADP_OPCODE=(60u << OPCODE_SHIFT | 113u << 3),
+ XVNMSUBASP_OPCODE=(60u<< OPCODE_SHIFT | 209u << 3),
+ XVNMSUBADP_OPCODE=(60u<< OPCODE_SHIFT | 241u << 3),
// Deliver A Random Number (introduced with POWER9)
DARN_OPCODE = (31u << OPCODE_SHIFT | 755u << 1),
@@ -2227,6 +2233,12 @@
inline void xvsubdp( VectorSRegister d, VectorSRegister a, VectorSRegister b);
inline void xvmulsp( VectorSRegister d, VectorSRegister a, VectorSRegister b);
inline void xvmuldp( VectorSRegister d, VectorSRegister a, VectorSRegister b);
+ inline void xvmaddasp(VectorSRegister d, VectorSRegister a, VectorSRegister b);
+ inline void xvmaddadp(VectorSRegister d, VectorSRegister a, VectorSRegister b);
+ inline void xvmsubasp(VectorSRegister d, VectorSRegister a, VectorSRegister b);
+ inline void xvmsubadp(VectorSRegister d, VectorSRegister a, VectorSRegister b);
+ inline void xvnmsubasp(VectorSRegister d, VectorSRegister a, VectorSRegister b);
+ inline void xvnmsubadp(VectorSRegister d, VectorSRegister a, VectorSRegister b);
// VSX Extended Mnemonics
inline void xxspltd( VectorSRegister d, VectorSRegister a, int x);
--- a/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -790,6 +790,12 @@
inline void Assembler::xvsubdp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVSUBDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
inline void Assembler::xvmulsp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMULSP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
inline void Assembler::xvmuldp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMULDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvmaddasp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMADDASP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvmaddadp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMADDADP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvmsubasp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMSUBASP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvmsubadp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMSUBADP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvnmsubasp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVNMSUBASP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvnmsubadp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVNMSUBADP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
inline void Assembler::mtvrd( VectorRegister d, Register a) { emit_int32( MTVSRD_OPCODE | vsrt(d->to_vsr()) | ra(a)); }
inline void Assembler::mfvrd( Register a, VectorRegister d) { emit_int32( MFVSRD_OPCODE | vsrt(d->to_vsr()) | ra(a)); }
inline void Assembler::mtvrwz( VectorRegister d, Register a) { emit_int32( MTVSRWZ_OPCODE | vsrt(d->to_vsr()) | ra(a)); }
--- a/src/hotspot/cpu/ppc/ppc.ad Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/ppc/ppc.ad Tue Dec 18 15:08:56 2018 -0500
@@ -2257,6 +2257,9 @@
return SuperwordUseVSX;
case Op_PopCountVI:
return (SuperwordUseVSX && UsePopCountInstruction);
+ case Op_FmaVF:
+ case Op_FmaVD:
+ return (SuperwordUseVSX && UseFMA);
case Op_Digit:
case Op_LowerCase:
case Op_UpperCase:
@@ -14475,6 +14478,92 @@
ins_pipe(pipe_class_default);
%}
+// --------------------------------- FMA --------------------------------------
+// dst + src1 * src2
+instruct vfma4F(vecX dst, vecX src1, vecX src2) %{
+ match(Set dst (FmaVF dst (Binary src1 src2)));
+ predicate(n->as_Vector()->length() == 4);
+
+ format %{ "XVMADDASP $dst, $src1, $src2" %}
+
+ size(4);
+ ins_encode %{
+ __ xvmaddasp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+ %}
+ ins_pipe(pipe_class_default);
+%}
+
+// dst - src1 * src2
+instruct vfma4F_neg1(vecX dst, vecX src1, vecX src2) %{
+ match(Set dst (FmaVF dst (Binary (NegVF src1) src2)));
+ match(Set dst (FmaVF dst (Binary src1 (NegVF src2))));
+ predicate(n->as_Vector()->length() == 4);
+
+ format %{ "XVNMSUBASP $dst, $src1, $src2" %}
+
+ size(4);
+ ins_encode %{
+ __ xvnmsubasp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+ %}
+ ins_pipe(pipe_class_default);
+%}
+
+// - dst + src1 * src2
+instruct vfma4F_neg2(vecX dst, vecX src1, vecX src2) %{
+ match(Set dst (FmaVF (NegVF dst) (Binary src1 src2)));
+ predicate(n->as_Vector()->length() == 4);
+
+ format %{ "XVMSUBASP $dst, $src1, $src2" %}
+
+ size(4);
+ ins_encode %{
+ __ xvmsubasp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+ %}
+ ins_pipe(pipe_class_default);
+%}
+
+// dst + src1 * src2
+instruct vfma2D(vecX dst, vecX src1, vecX src2) %{
+ match(Set dst (FmaVD dst (Binary src1 src2)));
+ predicate(n->as_Vector()->length() == 2);
+
+ format %{ "XVMADDADP $dst, $src1, $src2" %}
+
+ size(4);
+ ins_encode %{
+ __ xvmaddadp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+ %}
+ ins_pipe(pipe_class_default);
+%}
+
+// dst - src1 * src2
+instruct vfma2D_neg1(vecX dst, vecX src1, vecX src2) %{
+ match(Set dst (FmaVD dst (Binary (NegVD src1) src2)));
+ match(Set dst (FmaVD dst (Binary src1 (NegVD src2))));
+ predicate(n->as_Vector()->length() == 2);
+
+ format %{ "XVNMSUBADP $dst, $src1, $src2" %}
+
+ size(4);
+ ins_encode %{
+ __ xvnmsubadp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+ %}
+ ins_pipe(pipe_class_default);
+%}
+
+// - dst + src1 * src2
+instruct vfma2D_neg2(vecX dst, vecX src1, vecX src2) %{
+ match(Set dst (FmaVD (NegVD dst) (Binary src1 src2)));
+ predicate(n->as_Vector()->length() == 2);
+
+ format %{ "XVMSUBADP $dst, $src1, $src2" %}
+
+ size(4);
+ ins_encode %{
+ __ xvmsubadp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+ %}
+ ins_pipe(pipe_class_default);
+%}
//----------Overflow Math Instructions-----------------------------------------
--- a/src/hotspot/cpu/x86/assembler_x86.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/assembler_x86.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -3966,6 +3966,34 @@
emit_int8((unsigned char)(0xC0 | encode));
}
+void Assembler::pmaddwd(XMMRegister dst, XMMRegister src) {
+ NOT_LP64(assert(VM_Version::supports_sse2(), ""));
+ InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
+ int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+ emit_int8((unsigned char)0xF5);
+ emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::vpmaddwd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
+ assert(vector_len == AVX_128bit ? VM_Version::supports_avx() :
+ (vector_len == AVX_256bit ? VM_Version::supports_avx2() :
+ (vector_len == AVX_512bit ? VM_Version::supports_evex() : 0)), "");
+ InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
+ int encode = simd_prefix_and_encode(dst, nds, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+ emit_int8((unsigned char)0xF5);
+ emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::evpdpwssd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
+ assert(VM_Version::supports_evex(), "");
+ assert(VM_Version::supports_vnni(), "must support vnni");
+ InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true);
+ attributes.set_is_evex_instruction();
+ int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
+ emit_int8(0x52);
+ emit_int8((unsigned char)(0xC0 | encode));
+}
+
// generic
void Assembler::pop(Register dst) {
int encode = prefix_and_encode(dst->encoding());
@@ -4178,6 +4206,17 @@
emit_int8(shift);
}
+void Assembler::vpsrldq(XMMRegister dst, XMMRegister src, int shift, int vector_len) {
+ assert(vector_len == AVX_128bit ? VM_Version::supports_avx() :
+ vector_len == AVX_256bit ? VM_Version::supports_avx2() :
+ vector_len == AVX_512bit ? VM_Version::supports_avx512bw() : 0, "");
+ InstructionAttr attributes(vector_len, /*vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
+ int encode = vex_prefix_and_encode(xmm3->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+ emit_int8(0x73);
+ emit_int8((unsigned char)(0xC0 | encode));
+ emit_int8(shift & 0xFF);
+}
+
void Assembler::pslldq(XMMRegister dst, int shift) {
// Shift left 128 bit value in dst XMMRegister by shift number of bytes.
NOT_LP64(assert(VM_Version::supports_sse2(), ""));
@@ -4189,6 +4228,17 @@
emit_int8(shift);
}
+void Assembler::vpslldq(XMMRegister dst, XMMRegister src, int shift, int vector_len) {
+ assert(vector_len == AVX_128bit ? VM_Version::supports_avx() :
+ vector_len == AVX_256bit ? VM_Version::supports_avx2() :
+ vector_len == AVX_512bit ? VM_Version::supports_avx512bw() : 0, "");
+ InstructionAttr attributes(vector_len, /*vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
+ int encode = vex_prefix_and_encode(xmm7->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+ emit_int8(0x73);
+ emit_int8((unsigned char)(0xC0 | encode));
+ emit_int8(shift & 0xFF);
+}
+
void Assembler::ptest(XMMRegister dst, Address src) {
assert(VM_Version::supports_sse4_1(), "");
assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
@@ -4200,7 +4250,7 @@
}
void Assembler::ptest(XMMRegister dst, XMMRegister src) {
- assert(VM_Version::supports_sse4_1(), "");
+ assert(VM_Version::supports_sse4_1() || VM_Version::supports_avx(), "");
InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
emit_int8(0x17);
--- a/src/hotspot/cpu/x86/assembler_x86.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/assembler_x86.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -1668,6 +1668,12 @@
void evpmovdb(Address dst, XMMRegister src, int vector_len);
+ // Multiply add
+ void pmaddwd(XMMRegister dst, XMMRegister src);
+ void vpmaddwd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
+ // Multiply add accumulate
+ void evpdpwssd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
+
#ifndef _LP64 // no 32bit push/pop on amd64
void popl(Address dst);
#endif
@@ -2055,6 +2061,7 @@
void vpsllw(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len);
void vpslld(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len);
void vpsllq(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len);
+ void vpslldq(XMMRegister dst, XMMRegister src, int shift, int vector_len);
// Logical shift right packed integers
void psrlw(XMMRegister dst, int shift);
@@ -2069,6 +2076,7 @@
void vpsrlw(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len);
void vpsrld(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len);
void vpsrlq(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len);
+ void vpsrldq(XMMRegister dst, XMMRegister src, int shift, int vector_len);
void evpsrlvw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
void evpsllvw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
--- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -943,12 +943,17 @@
int iter);
void addm(int disp, Register r1, Register r2);
-
+ void gfmul(XMMRegister tmp0, XMMRegister t);
+ void schoolbookAAD(int i, Register subkeyH, XMMRegister data, XMMRegister tmp0,
+ XMMRegister tmp1, XMMRegister tmp2, XMMRegister tmp3);
+ void generateHtbl_one_block(Register htbl);
+ void generateHtbl_eight_blocks(Register htbl);
public:
void sha256_AVX2(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0,
XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4,
Register buf, Register state, Register ofs, Register limit, Register rsp,
bool multi_block, XMMRegister shuf_mask);
+ void avx_ghash(Register state, Register htbl, Register data, Register blocks);
#endif
#ifdef _LP64
@@ -1498,6 +1503,15 @@
// 0x11 - multiply upper 64 bits [64:127]
Assembler::vpclmulqdq(dst, nds, src, 0x11);
}
+ void vpclmullqhqdq(XMMRegister dst, XMMRegister nds, XMMRegister src) {
+ // 0x10 - multiply nds[0:63] and src[64:127]
+ Assembler::vpclmulqdq(dst, nds, src, 0x10);
+ }
+ void vpclmulhqlqdq(XMMRegister dst, XMMRegister nds, XMMRegister src) {
+ //0x01 - multiply nds[64:127] and src[0:63]
+ Assembler::vpclmulqdq(dst, nds, src, 0x01);
+ }
+
void evpclmulldq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
// 0x00 - multiply lower 64 bits [0:63]
Assembler::evpclmulqdq(dst, nds, src, 0x00, vector_len);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/cpu/x86/macroAssembler_x86_aes.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,324 @@
+/*
+* Copyright (c) 2018, Intel Corporation.
+*
+* 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.
+*
+*/
+
+#include "precompiled.hpp"
+#include "asm/assembler.hpp"
+#include "asm/assembler.inline.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "macroAssembler_x86.hpp"
+
+#ifdef _LP64
+// Multiply 128 x 128 bits, using 4 pclmulqdq operations
+void MacroAssembler::schoolbookAAD(int i, Register htbl, XMMRegister data,
+ XMMRegister tmp0, XMMRegister tmp1, XMMRegister tmp2, XMMRegister tmp3) {
+ movdqu(xmm15, Address(htbl, i * 16));
+ vpclmulhqlqdq(tmp3, data, xmm15); // 0x01
+ vpxor(tmp2, tmp2, tmp3, Assembler::AVX_128bit);
+ vpclmulldq(tmp3, data, xmm15); // 0x00
+ vpxor(tmp0, tmp0, tmp3, Assembler::AVX_128bit);
+ vpclmulhdq(tmp3, data, xmm15); // 0x11
+ vpxor(tmp1, tmp1, tmp3, Assembler::AVX_128bit);
+ vpclmullqhqdq(tmp3, data, xmm15); // 0x10
+ vpxor(tmp2, tmp2, tmp3, Assembler::AVX_128bit);
+}
+
+// Multiply two 128 bit numbers resulting in a 256 bit value
+// Result of the multiplication followed by reduction stored in state
+void MacroAssembler::gfmul(XMMRegister tmp0, XMMRegister state) {
+ const XMMRegister tmp1 = xmm4;
+ const XMMRegister tmp2 = xmm5;
+ const XMMRegister tmp3 = xmm6;
+ const XMMRegister tmp4 = xmm7;
+
+ vpclmulldq(tmp1, state, tmp0); //0x00 (a0 * b0)
+ vpclmulhdq(tmp4, state, tmp0);//0x11 (a1 * b1)
+ vpclmullqhqdq(tmp2, state, tmp0);//0x10 (a1 * b0)
+ vpclmulhqlqdq(tmp3, state, tmp0); //0x01 (a0 * b1)
+
+ vpxor(tmp2, tmp2, tmp3, Assembler::AVX_128bit); // (a0 * b1) + (a1 * b0)
+
+ vpslldq(tmp3, tmp2, 8, Assembler::AVX_128bit);
+ vpsrldq(tmp2, tmp2, 8, Assembler::AVX_128bit);
+ vpxor(tmp1, tmp1, tmp3, Assembler::AVX_128bit); // tmp1 and tmp4 hold the result
+ vpxor(tmp4, tmp4, tmp2, Assembler::AVX_128bit); // of carryless multiplication
+ // Follows the reduction technique mentioned in
+ // Shift-XOR reduction described in Gueron-Kounavis May 2010
+ // First phase of reduction
+ //
+ vpslld(xmm8, tmp1, 31, Assembler::AVX_128bit); // packed right shift shifting << 31
+ vpslld(xmm9, tmp1, 30, Assembler::AVX_128bit); // packed right shift shifting << 30
+ vpslld(xmm10, tmp1, 25, Assembler::AVX_128bit);// packed right shift shifting << 25
+ // xor the shifted versions
+ vpxor(xmm8, xmm8, xmm9, Assembler::AVX_128bit);
+ vpxor(xmm8, xmm8, xmm10, Assembler::AVX_128bit);
+ vpslldq(xmm9, xmm8, 12, Assembler::AVX_128bit);
+ vpsrldq(xmm8, xmm8, 4, Assembler::AVX_128bit);
+ vpxor(tmp1, tmp1, xmm9, Assembler::AVX_128bit);// first phase of the reduction complete
+ //
+ // Second phase of the reduction
+ //
+ vpsrld(xmm9, tmp1, 1, Assembler::AVX_128bit);// packed left shifting >> 1
+ vpsrld(xmm10, tmp1, 2, Assembler::AVX_128bit);// packed left shifting >> 2
+ vpsrld(xmm11, tmp1, 7, Assembler::AVX_128bit);// packed left shifting >> 7
+ vpxor(xmm9, xmm9, xmm10, Assembler::AVX_128bit);// xor the shifted versions
+ vpxor(xmm9, xmm9, xmm11, Assembler::AVX_128bit);
+ vpxor(xmm9, xmm9, xmm8, Assembler::AVX_128bit);
+ vpxor(tmp1, tmp1, xmm9, Assembler::AVX_128bit);
+ vpxor(state, tmp4, tmp1, Assembler::AVX_128bit);// the result is in state
+ ret(0);
+}
+
+// This method takes the subkey after expansion as input and generates 1 * 16 power of subkey H.
+// The power of H is used in reduction process for one block ghash
+void MacroAssembler::generateHtbl_one_block(Register htbl) {
+ const XMMRegister t = xmm13;
+
+ // load the original subkey hash
+ movdqu(t, Address(htbl, 0));
+ // shuffle using long swap mask
+ movdqu(xmm10, ExternalAddress(StubRoutines::x86::ghash_long_swap_mask_addr()));
+ vpshufb(t, t, xmm10, Assembler::AVX_128bit);
+
+ // Compute H' = GFMUL(H, 2)
+ vpsrld(xmm3, t, 7, Assembler::AVX_128bit);
+ movdqu(xmm4, ExternalAddress(StubRoutines::x86::ghash_shufflemask_addr()));
+ vpshufb(xmm3, xmm3, xmm4, Assembler::AVX_128bit);
+ movl(rax, 0xff00);
+ movdl(xmm4, rax);
+ vpshufb(xmm4, xmm4, xmm3, Assembler::AVX_128bit);
+ movdqu(xmm5, ExternalAddress(StubRoutines::x86::ghash_polynomial_addr()));
+ vpand(xmm5, xmm5, xmm4, Assembler::AVX_128bit);
+ vpsrld(xmm3, t, 31, Assembler::AVX_128bit);
+ vpslld(xmm4, t, 1, Assembler::AVX_128bit);
+ vpslldq(xmm3, xmm3, 4, Assembler::AVX_128bit);
+ vpxor(t, xmm4, xmm3, Assembler::AVX_128bit);// t holds p(x) <<1 or H * 2
+
+ //Adding p(x)<<1 to xmm5 which holds the reduction polynomial
+ vpxor(t, t, xmm5, Assembler::AVX_128bit);
+ movdqu(Address(htbl, 1 * 16), t); // H * 2
+
+ ret(0);
+}
+
+// This method takes the subkey after expansion as input and generates the remaining powers of subkey H.
+// The power of H is used in reduction process for eight block ghash
+void MacroAssembler::generateHtbl_eight_blocks(Register htbl) {
+ const XMMRegister t = xmm13;
+ const XMMRegister tmp0 = xmm1;
+ Label GFMUL;
+
+ movdqu(t, Address(htbl, 1 * 16));
+ movdqu(tmp0, t);
+
+ // tmp0 and t hold H. Now we compute powers of H by using GFMUL(H, H)
+ call(GFMUL, relocInfo::none);
+ movdqu(Address(htbl, 2 * 16), t); //H ^ 2 * 2
+ call(GFMUL, relocInfo::none);
+ movdqu(Address(htbl, 3 * 16), t); //H ^ 3 * 2
+ call(GFMUL, relocInfo::none);
+ movdqu(Address(htbl, 4 * 16), t); //H ^ 4 * 2
+ call(GFMUL, relocInfo::none);
+ movdqu(Address(htbl, 5 * 16), t); //H ^ 5 * 2
+ call(GFMUL, relocInfo::none);
+ movdqu(Address(htbl, 6 * 16), t); //H ^ 6 * 2
+ call(GFMUL, relocInfo::none);
+ movdqu(Address(htbl, 7 * 16), t); //H ^ 7 * 2
+ call(GFMUL, relocInfo::none);
+ movdqu(Address(htbl, 8 * 16), t); //H ^ 8 * 2
+ ret(0);
+
+ bind(GFMUL);
+ gfmul(tmp0, t);
+}
+
+// Multiblock and single block GHASH computation using Shift XOR reduction technique
+void MacroAssembler::avx_ghash(Register input_state, Register htbl,
+ Register input_data, Register blocks) {
+
+ // temporary variables to hold input data and input state
+ const XMMRegister data = xmm1;
+ const XMMRegister state = xmm0;
+ // temporary variables to hold intermediate results
+ const XMMRegister tmp0 = xmm3;
+ const XMMRegister tmp1 = xmm4;
+ const XMMRegister tmp2 = xmm5;
+ const XMMRegister tmp3 = xmm6;
+ // temporary variables to hold byte and long swap masks
+ const XMMRegister bswap_mask = xmm2;
+ const XMMRegister lswap_mask = xmm14;
+
+ Label GENERATE_HTBL_1_BLK, GENERATE_HTBL_8_BLKS, BEGIN_PROCESS, GFMUL, BLOCK8_REDUCTION,
+ ONE_BLK_INIT, PROCESS_1_BLOCK, PROCESS_8_BLOCKS, SAVE_STATE, EXIT_GHASH;
+
+ testptr(blocks, blocks);
+ jcc(Assembler::zero, EXIT_GHASH);
+
+ // Check if Hashtable (1*16) has been already generated
+ // For anything less than 8 blocks, we generate only the first power of H.
+ movdqu(tmp2, Address(htbl, 1 * 16));
+ ptest(tmp2, tmp2);
+ jcc(Assembler::notZero, BEGIN_PROCESS);
+ call(GENERATE_HTBL_1_BLK, relocInfo::none);
+
+ // Shuffle the input state
+ bind(BEGIN_PROCESS);
+ movdqu(lswap_mask, ExternalAddress(StubRoutines::x86::ghash_long_swap_mask_addr()));
+ movdqu(state, Address(input_state, 0));
+ vpshufb(state, state, lswap_mask, Assembler::AVX_128bit);
+
+ cmpl(blocks, 8);
+ jcc(Assembler::below, ONE_BLK_INIT);
+ // If we have 8 blocks or more data, then generate remaining powers of H
+ movdqu(tmp2, Address(htbl, 8 * 16));
+ ptest(tmp2, tmp2);
+ jcc(Assembler::notZero, PROCESS_8_BLOCKS);
+ call(GENERATE_HTBL_8_BLKS, relocInfo::none);
+
+ //Do 8 multiplies followed by a reduction processing 8 blocks of data at a time
+ //Each block = 16 bytes.
+ bind(PROCESS_8_BLOCKS);
+ subl(blocks, 8);
+ movdqu(bswap_mask, ExternalAddress(StubRoutines::x86::ghash_byte_swap_mask_addr()));
+ movdqu(data, Address(input_data, 16 * 7));
+ vpshufb(data, data, bswap_mask, Assembler::AVX_128bit);
+ //Loading 1*16 as calculated powers of H required starts at that location.
+ movdqu(xmm15, Address(htbl, 1 * 16));
+ //Perform carryless multiplication of (H*2, data block #7)
+ vpclmulhqlqdq(tmp2, data, xmm15);//a0 * b1
+ vpclmulldq(tmp0, data, xmm15);//a0 * b0
+ vpclmulhdq(tmp1, data, xmm15);//a1 * b1
+ vpclmullqhqdq(tmp3, data, xmm15);//a1* b0
+ vpxor(tmp2, tmp2, tmp3, Assembler::AVX_128bit);// (a0 * b1) + (a1 * b0)
+
+ movdqu(data, Address(input_data, 16 * 6));
+ vpshufb(data, data, bswap_mask, Assembler::AVX_128bit);
+ // Perform carryless multiplication of (H^2 * 2, data block #6)
+ schoolbookAAD(2, htbl, data, tmp0, tmp1, tmp2, tmp3);
+
+ movdqu(data, Address(input_data, 16 * 5));
+ vpshufb(data, data, bswap_mask, Assembler::AVX_128bit);
+ // Perform carryless multiplication of (H^3 * 2, data block #5)
+ schoolbookAAD(3, htbl, data, tmp0, tmp1, tmp2, tmp3);
+ movdqu(data, Address(input_data, 16 * 4));
+ vpshufb(data, data, bswap_mask, Assembler::AVX_128bit);
+ // Perform carryless multiplication of (H^4 * 2, data block #4)
+ schoolbookAAD(4, htbl, data, tmp0, tmp1, tmp2, tmp3);
+ movdqu(data, Address(input_data, 16 * 3));
+ vpshufb(data, data, bswap_mask, Assembler::AVX_128bit);
+ // Perform carryless multiplication of (H^5 * 2, data block #3)
+ schoolbookAAD(5, htbl, data, tmp0, tmp1, tmp2, tmp3);
+ movdqu(data, Address(input_data, 16 * 2));
+ vpshufb(data, data, bswap_mask, Assembler::AVX_128bit);
+ // Perform carryless multiplication of (H^6 * 2, data block #2)
+ schoolbookAAD(6, htbl, data, tmp0, tmp1, tmp2, tmp3);
+ movdqu(data, Address(input_data, 16 * 1));
+ vpshufb(data, data, bswap_mask, Assembler::AVX_128bit);
+ // Perform carryless multiplication of (H^7 * 2, data block #1)
+ schoolbookAAD(7, htbl, data, tmp0, tmp1, tmp2, tmp3);
+ movdqu(data, Address(input_data, 16 * 0));
+ // xor data block#0 with input state before perfoming carry-less multiplication
+ vpshufb(data, data, bswap_mask, Assembler::AVX_128bit);
+ vpxor(data, data, state, Assembler::AVX_128bit);
+ // Perform carryless multiplication of (H^8 * 2, data block #0)
+ schoolbookAAD(8, htbl, data, tmp0, tmp1, tmp2, tmp3);
+ vpslldq(tmp3, tmp2, 8, Assembler::AVX_128bit);
+ vpsrldq(tmp2, tmp2, 8, Assembler::AVX_128bit);
+ vpxor(tmp0, tmp0, tmp3, Assembler::AVX_128bit);// tmp0, tmp1 contains aggregated results of
+ vpxor(tmp1, tmp1, tmp2, Assembler::AVX_128bit);// the multiplication operation
+
+ // we have the 2 128-bit partially accumulated multiplication results in tmp0:tmp1
+ // with higher 128-bit in tmp1 and lower 128-bit in corresponding tmp0
+ // Follows the reduction technique mentioned in
+ // Shift-XOR reduction described in Gueron-Kounavis May 2010
+ bind(BLOCK8_REDUCTION);
+ // First Phase of the reduction
+ vpslld(xmm8, tmp0, 31, Assembler::AVX_128bit); // packed right shifting << 31
+ vpslld(xmm9, tmp0, 30, Assembler::AVX_128bit); // packed right shifting << 30
+ vpslld(xmm10, tmp0, 25, Assembler::AVX_128bit); // packed right shifting << 25
+ // xor the shifted versions
+ vpxor(xmm8, xmm8, xmm10, Assembler::AVX_128bit);
+ vpxor(xmm8, xmm8, xmm9, Assembler::AVX_128bit);
+
+ vpslldq(xmm9, xmm8, 12, Assembler::AVX_128bit);
+ vpsrldq(xmm8, xmm8, 4, Assembler::AVX_128bit);
+
+ vpxor(tmp0, tmp0, xmm9, Assembler::AVX_128bit); // first phase of reduction is complete
+ // second phase of the reduction
+ vpsrld(xmm9, tmp0, 1, Assembler::AVX_128bit); // packed left shifting >> 1
+ vpsrld(xmm10, tmp0, 2, Assembler::AVX_128bit); // packed left shifting >> 2
+ vpsrld(tmp2, tmp0, 7, Assembler::AVX_128bit); // packed left shifting >> 7
+ // xor the shifted versions
+ vpxor(xmm9, xmm9, xmm10, Assembler::AVX_128bit);
+ vpxor(xmm9, xmm9, tmp2, Assembler::AVX_128bit);
+ vpxor(xmm9, xmm9, xmm8, Assembler::AVX_128bit);
+ vpxor(tmp0, xmm9, tmp0, Assembler::AVX_128bit);
+ // Final result is in state
+ vpxor(state, tmp0, tmp1, Assembler::AVX_128bit);
+
+ lea(input_data, Address(input_data, 16 * 8));
+ cmpl(blocks, 8);
+ jcc(Assembler::below, ONE_BLK_INIT);
+ jmp(PROCESS_8_BLOCKS);
+
+ // Since this is one block operation we will only use H * 2 i.e. the first power of H
+ bind(ONE_BLK_INIT);
+ movdqu(tmp0, Address(htbl, 1 * 16));
+ movdqu(bswap_mask, ExternalAddress(StubRoutines::x86::ghash_byte_swap_mask_addr()));
+
+ //Do one (128 bit x 128 bit) carry-less multiplication at a time followed by a reduction.
+ bind(PROCESS_1_BLOCK);
+ cmpl(blocks, 0);
+ jcc(Assembler::equal, SAVE_STATE);
+ subl(blocks, 1);
+ movdqu(data, Address(input_data, 0));
+ vpshufb(data, data, bswap_mask, Assembler::AVX_128bit);
+ vpxor(state, state, data, Assembler::AVX_128bit);
+ // gfmul(H*2, state)
+ call(GFMUL, relocInfo::none);
+ addptr(input_data, 16);
+ jmp(PROCESS_1_BLOCK);
+
+ bind(SAVE_STATE);
+ vpshufb(state, state, lswap_mask, Assembler::AVX_128bit);
+ movdqu(Address(input_state, 0), state);
+ jmp(EXIT_GHASH);
+
+ bind(GFMUL);
+ gfmul(tmp0, state);
+
+ bind(GENERATE_HTBL_1_BLK);
+ generateHtbl_one_block(htbl);
+
+ bind(GENERATE_HTBL_8_BLKS);
+ generateHtbl_eight_blocks(htbl);
+
+ bind(EXIT_GHASH);
+ // zero out xmm registers used for Htbl storage
+ vpxor(xmm0, xmm0, xmm0, Assembler::AVX_128bit);
+ vpxor(xmm1, xmm1, xmm1, Assembler::AVX_128bit);
+ vpxor(xmm3, xmm3, xmm3, Assembler::AVX_128bit);
+ vpxor(xmm15, xmm15, xmm15, Assembler::AVX_128bit);
+}
+#endif // _LP64
--- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -4388,6 +4388,45 @@
return start;
}
+// Polynomial x^128+x^127+x^126+x^121+1
+address ghash_polynomial_addr() {
+ __ align(CodeEntryAlignment);
+ StubCodeMark mark(this, "StubRoutines", "_ghash_poly_addr");
+ address start = __ pc();
+ __ emit_data64(0x0000000000000001, relocInfo::none);
+ __ emit_data64(0xc200000000000000, relocInfo::none);
+ return start;
+}
+
+address ghash_shufflemask_addr() {
+ __ align(CodeEntryAlignment);
+ StubCodeMark mark(this, "StubRoutines", "_ghash_shuffmask_addr");
+ address start = __ pc();
+ __ emit_data64(0x0f0f0f0f0f0f0f0f, relocInfo::none);
+ __ emit_data64(0x0f0f0f0f0f0f0f0f, relocInfo::none);
+ return start;
+}
+
+// Ghash single and multi block operations using AVX instructions
+address generate_avx_ghash_processBlocks() {
+ __ align(CodeEntryAlignment);
+
+ StubCodeMark mark(this, "StubRoutines", "ghash_processBlocks");
+ address start = __ pc();
+
+ // arguments
+ const Register state = c_rarg0;
+ const Register htbl = c_rarg1;
+ const Register data = c_rarg2;
+ const Register blocks = c_rarg3;
+ __ enter();
+ // Save state before entering routine
+ __ avx_ghash(state, htbl, data, blocks);
+ __ leave(); // required for proper stackwalking of RuntimeStub frame
+ __ ret(0);
+ return start;
+}
+
// byte swap x86 long
address generate_ghash_long_swap_mask() {
__ align(CodeEntryAlignment);
@@ -5886,9 +5925,15 @@
// Generate GHASH intrinsics code
if (UseGHASHIntrinsics) {
- StubRoutines::x86::_ghash_long_swap_mask_addr = generate_ghash_long_swap_mask();
- StubRoutines::x86::_ghash_byte_swap_mask_addr = generate_ghash_byte_swap_mask();
- StubRoutines::_ghash_processBlocks = generate_ghash_processBlocks();
+ StubRoutines::x86::_ghash_long_swap_mask_addr = generate_ghash_long_swap_mask();
+ StubRoutines::x86::_ghash_byte_swap_mask_addr = generate_ghash_byte_swap_mask();
+ if (VM_Version::supports_avx()) {
+ StubRoutines::x86::_ghash_shuffmask_addr = ghash_shufflemask_addr();
+ StubRoutines::x86::_ghash_poly_addr = ghash_polynomial_addr();
+ StubRoutines::_ghash_processBlocks = generate_avx_ghash_processBlocks();
+ } else {
+ StubRoutines::_ghash_processBlocks = generate_ghash_processBlocks();
+ }
}
if (UseBASE64Intrinsics) {
--- a/src/hotspot/cpu/x86/stubRoutines_x86.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/stubRoutines_x86.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -38,6 +38,8 @@
address StubRoutines::x86::_counter_shuffle_mask_addr = NULL;
address StubRoutines::x86::_ghash_long_swap_mask_addr = NULL;
address StubRoutines::x86::_ghash_byte_swap_mask_addr = NULL;
+address StubRoutines::x86::_ghash_poly_addr = NULL;
+address StubRoutines::x86::_ghash_shuffmask_addr = NULL;
address StubRoutines::x86::_upper_word_mask_addr = NULL;
address StubRoutines::x86::_shuffle_byte_flip_mask_addr = NULL;
address StubRoutines::x86::_k256_adr = NULL;
--- a/src/hotspot/cpu/x86/stubRoutines_x86.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/stubRoutines_x86.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -128,6 +128,8 @@
// swap mask for ghash
static address _ghash_long_swap_mask_addr;
static address _ghash_byte_swap_mask_addr;
+ static address _ghash_poly_addr;
+ static address _ghash_shuffmask_addr;
// upper word mask for sha1
static address _upper_word_mask_addr;
@@ -205,6 +207,8 @@
static address crc_by128_masks_addr() { return (address)_crc_by128_masks; }
static address ghash_long_swap_mask_addr() { return _ghash_long_swap_mask_addr; }
static address ghash_byte_swap_mask_addr() { return _ghash_byte_swap_mask_addr; }
+ static address ghash_shufflemask_addr() { return _ghash_shuffmask_addr; }
+ static address ghash_polynomial_addr() { return _ghash_poly_addr; }
static address upper_word_mask_addr() { return _upper_word_mask_addr; }
static address shuffle_byte_flip_mask_addr() { return _shuffle_byte_flip_mask_addr; }
static address k256_addr() { return _k256_adr; }
--- a/src/hotspot/cpu/x86/vm_version_x86.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/vm_version_x86.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -1289,7 +1289,7 @@
if (FLAG_IS_DEFAULT(UseXMMForArrayCopy)) {
UseXMMForArrayCopy = true; // use SSE2 movq on new Intel cpus
}
- if (supports_sse4_2() && supports_ht()) { // Newest Intel cpus
+ if ((supports_sse4_2() && supports_ht()) || supports_avx()) { // Newest Intel cpus
if (FLAG_IS_DEFAULT(UseUnalignedLoadStores)) {
UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus
}
--- a/src/hotspot/cpu/x86/vm_version_x86.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/vm_version_x86.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -336,6 +336,7 @@
#define CPU_AVX512_VPOPCNTDQ ((uint64_t)UCONST64(0x2000000000)) // Vector popcount
#define CPU_VPCLMULQDQ ((uint64_t)UCONST64(0x4000000000)) //Vector carryless multiplication
#define CPU_VAES ((uint64_t)UCONST64(0x8000000000)) // Vector AES instructions
+#define CPU_VNNI ((uint64_t)UCONST64(0x16000000000)) // Vector Neural Network Instructions
enum Extended_Family {
// AMD
@@ -548,6 +549,8 @@
result |= CPU_VPCLMULQDQ;
if (_cpuid_info.sef_cpuid7_ecx.bits.vaes != 0)
result |= CPU_VAES;
+ if (_cpuid_info.sef_cpuid7_ecx.bits.avx512_vnni != 0)
+ result |= CPU_VNNI;
}
}
if(_cpuid_info.sef_cpuid7_ebx.bits.bmi1 != 0)
@@ -828,6 +831,7 @@
static bool supports_vpopcntdq() { return (_features & CPU_AVX512_VPOPCNTDQ) != 0; }
static bool supports_vpclmulqdq() { return (_features & CPU_VPCLMULQDQ) != 0; }
static bool supports_vaes() { return (_features & CPU_VAES) != 0; }
+ static bool supports_vnni() { return (_features & CPU_VNNI) != 0; }
// Intel features
static bool is_intel_family_core() { return is_intel() &&
--- a/src/hotspot/cpu/x86/x86.ad Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/x86.ad Tue Dec 18 15:08:56 2018 -0500
@@ -1446,6 +1446,10 @@
if (VM_Version::supports_on_spin_wait() == false)
ret_value = false;
break;
+ case Op_MulAddVS2VI:
+ if (UseSSE < 2)
+ ret_value = false;
+ break;
}
return ret_value; // Per default match rules are supported.
@@ -9855,6 +9859,118 @@
ins_pipe( pipe_slow );
%}
+// --------------------------------- Vector Multiply Add --------------------------------------
+
+instruct smuladd4S2I_reg(vecD dst, vecD src1) %{
+ predicate(UseSSE >= 2 && UseAVX == 0 && n->as_Vector()->length() == 2);
+ match(Set dst (MulAddVS2VI dst src1));
+ format %{ "pmaddwd $dst,$dst,$src1\t! muladd packed4Sto2I" %}
+ ins_encode %{
+ __ pmaddwd($dst$$XMMRegister, $src1$$XMMRegister);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct vmuladd4S2I_reg(vecD dst, vecD src1, vecD src2) %{
+ predicate(UseAVX > 0 && n->as_Vector()->length() == 2);
+ match(Set dst (MulAddVS2VI src1 src2));
+ format %{ "vpmaddwd $dst,$src1,$src2\t! muladd packed4Sto2I" %}
+ ins_encode %{
+ int vector_len = 0;
+ __ vpmaddwd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct smuladd8S4I_reg(vecX dst, vecX src1) %{
+ predicate(UseSSE >= 2 && UseAVX == 0 && n->as_Vector()->length() == 4);
+ match(Set dst (MulAddVS2VI dst src1));
+ format %{ "pmaddwd $dst,$dst,$src1\t! muladd packed8Sto4I" %}
+ ins_encode %{
+ __ pmaddwd($dst$$XMMRegister, $src1$$XMMRegister);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct vmuladd8S4I_reg(vecX dst, vecX src1, vecX src2) %{
+ predicate(UseAVX > 0 && n->as_Vector()->length() == 4);
+ match(Set dst (MulAddVS2VI src1 src2));
+ format %{ "vpmaddwd $dst,$src1,$src2\t! muladd packed8Sto4I" %}
+ ins_encode %{
+ int vector_len = 0;
+ __ vpmaddwd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct vmuladd16S8I_reg(vecY dst, vecY src1, vecY src2) %{
+ predicate(UseAVX > 1 && n->as_Vector()->length() == 8);
+ match(Set dst (MulAddVS2VI src1 src2));
+ format %{ "vpmaddwd $dst,$src1,$src2\t! muladd packed16Sto8I" %}
+ ins_encode %{
+ int vector_len = 1;
+ __ vpmaddwd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct vmuladd32S16I_reg(vecZ dst, vecZ src1, vecZ src2) %{
+ predicate(UseAVX > 2 && n->as_Vector()->length() == 16);
+ match(Set dst (MulAddVS2VI src1 src2));
+ format %{ "vpmaddwd $dst,$src1,$src2\t! muladd packed32Sto16I" %}
+ ins_encode %{
+ int vector_len = 2;
+ __ vpmaddwd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+// --------------------------------- Vector Multiply Add Add ----------------------------------
+
+instruct vmuladdadd4S2I_reg(vecD dst, vecD src1, vecD src2) %{
+ predicate(VM_Version::supports_vnni() && UseAVX > 2 && n->as_Vector()->length() == 2);
+ match(Set dst (AddVI (MulAddVS2VI src1 src2) dst));
+ format %{ "evpdpwssd $dst,$src1,$src2\t! muladdadd packed4Sto2I" %}
+ ins_encode %{
+ int vector_len = 0;
+ __ evpdpwssd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct vmuladdadd8S4I_reg(vecX dst, vecX src1, vecX src2) %{
+ predicate(VM_Version::supports_vnni() && UseAVX > 2 && n->as_Vector()->length() == 4);
+ match(Set dst (AddVI (MulAddVS2VI src1 src2) dst));
+ format %{ "evpdpwssd $dst,$src1,$src2\t! muladdadd packed8Sto4I" %}
+ ins_encode %{
+ int vector_len = 0;
+ __ evpdpwssd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct vmuladdadd16S8I_reg(vecY dst, vecY src1, vecY src2) %{
+ predicate(VM_Version::supports_vnni() && UseAVX > 2 && n->as_Vector()->length() == 8);
+ match(Set dst (AddVI (MulAddVS2VI src1 src2) dst));
+ format %{ "evpdpwssd $dst,$src1,$src2\t! muladdadd packed16Sto8I" %}
+ ins_encode %{
+ int vector_len = 1;
+ __ evpdpwssd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct vmuladdadd32S16I_reg(vecZ dst, vecZ src1, vecZ src2) %{
+ predicate(VM_Version::supports_vnni() && UseAVX > 2 && n->as_Vector()->length() == 16);
+ match(Set dst (AddVI (MulAddVS2VI src1 src2) dst));
+ format %{ "evpdpwssd $dst,$src1,$src2\t! muladdadd packed32Sto16I" %}
+ ins_encode %{
+ int vector_len = 2;
+ __ evpdpwssd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
// --------------------------------- PopCount --------------------------------------
instruct vpopcount2I(vecD dst, vecD src) %{
--- a/src/hotspot/cpu/x86/x86_32.ad Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/x86_32.ad Tue Dec 18 15:08:56 2018 -0500
@@ -7755,6 +7755,16 @@
ins_pipe( ialu_reg_mem_alu0 );
%}
+instruct mulAddS2I_rReg(rRegI dst, rRegI src1, rRegI src2, rRegI src3, eFlagsReg cr)
+%{
+ match(Set dst (MulAddS2I (Binary dst src1) (Binary src2 src3)));
+ effect(KILL cr, KILL src2);
+
+ expand %{ mulI_rReg(dst, src1, cr);
+ mulI_rReg(src2, src3, cr);
+ addI_rReg(dst, src2, cr); %}
+%}
+
// Multiply Register Int to Long
instruct mulI2L(eADXRegL dst, eAXRegI src, nadxRegI src1, eFlagsReg flags) %{
// Basic Idea: long = (long)int * (long)int
--- a/src/hotspot/cpu/x86/x86_64.ad Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/cpu/x86/x86_64.ad Tue Dec 18 15:08:56 2018 -0500
@@ -8175,6 +8175,16 @@
ins_pipe(ialu_reg_mem_alu0);
%}
+instruct mulAddS2I_rReg(rRegI dst, rRegI src1, rRegI src2, rRegI src3, rFlagsReg cr)
+%{
+ match(Set dst (MulAddS2I (Binary dst src1) (Binary src2 src3)));
+ effect(KILL cr, KILL src2);
+
+ expand %{ mulI_rReg(dst, src1, cr);
+ mulI_rReg(src2, src3, cr);
+ addI_rReg(dst, src2, cr); %}
+%}
+
instruct mulL_rReg(rRegL dst, rRegL src, rFlagsReg cr)
%{
match(Set dst (MulL dst src));
--- a/src/hotspot/os/linux/os_linux.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/os/linux/os_linux.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -1354,9 +1354,11 @@
void os::abort(bool dump_core, void* siginfo, const void* context) {
os::shutdown();
if (dump_core) {
+#if INCLUDE_CDS
if (UseSharedSpaces && DumpPrivateMappingsInCore) {
ClassLoader::close_jrt_image();
}
+#endif
#ifndef PRODUCT
fdStream out(defaultStream::output_fd());
out.print_raw("Current thread is ");
@@ -5075,9 +5077,11 @@
set_coredump_filter(DAX_SHARED_BIT);
}
+#if INCLUDE_CDS
if (UseSharedSpaces && DumpPrivateMappingsInCore) {
set_coredump_filter(FILE_BACKED_PVT_BIT);
}
+#endif
return JNI_OK;
}
--- a/src/hotspot/share/adlc/formssel.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/adlc/formssel.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -4181,6 +4181,7 @@
"AddReductionVF", "AddReductionVD",
"MulReductionVI", "MulReductionVL",
"MulReductionVF", "MulReductionVD",
+ "MulAddVS2VI",
"LShiftCntV","RShiftCntV",
"LShiftVB","LShiftVS","LShiftVI","LShiftVL",
"RShiftVB","RShiftVS","RShiftVI","RShiftVL",
--- a/src/hotspot/share/c1/c1_Instruction.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/c1/c1_Instruction.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -827,9 +827,16 @@
for_each_local_value(existing_state, index, existing_value) {
Value new_value = new_state->local_at(index);
if (new_value == NULL || new_value->type()->tag() != existing_value->type()->tag()) {
- // The old code invalidated the phi function here
- // Because dead locals are replaced with NULL, this is a very rare case now, so simply bail out
- return false; // BAILOUT in caller
+ Phi* existing_phi = existing_value->as_Phi();
+ if (existing_phi == NULL) {
+ return false; // BAILOUT in caller
+ }
+ // Invalidate the phi function here. This case is very rare except for
+ // JVMTI capability "can_access_local_variables".
+ // In really rare cases we will bail out in LIRGenerator::move_to_phi.
+ existing_phi->make_illegal();
+ existing_state->invalidate_local(index);
+ TRACE_PHI(tty->print_cr("invalidating local %d because of type mismatch", index));
}
}
--- a/src/hotspot/share/c1/c1_LIRGenerator.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -1113,7 +1113,7 @@
// no moves are created for phi functions at the begin of exception
// handlers, so assign operands manually here
for_each_phi_fun(block(), phi,
- operand_for_instruction(phi));
+ if (!phi->is_illegal()) { operand_for_instruction(phi); });
LIR_Opr thread_reg = getThreadPointer();
__ move_wide(new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT),
--- a/src/hotspot/share/c1/c1_LinearScan.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/c1/c1_LinearScan.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -574,7 +574,7 @@
// Phi functions at the begin of an exception handler are
// implicitly defined (= killed) at the beginning of the block.
for_each_phi_fun(block, phi,
- live_kill.set_bit(phi->operand()->vreg_number())
+ if (!phi->is_illegal()) { live_kill.set_bit(phi->operand()->vreg_number()); }
);
}
@@ -1904,7 +1904,7 @@
// the live_in bits are not set for phi functions of the xhandler entry, so iterate them separately
for_each_phi_fun(block, phi,
- resolve_exception_entry(block, phi->operand()->vreg_number(), move_resolver)
+ if (!phi->is_illegal()) { resolve_exception_entry(block, phi->operand()->vreg_number(), move_resolver); }
);
if (move_resolver.has_mappings()) {
@@ -1978,7 +1978,7 @@
// the live_in bits are not set for phi functions of the xhandler entry, so iterate them separately
for_each_phi_fun(block, phi,
- resolve_exception_edge(handler, throwing_op_id, phi->operand()->vreg_number(), phi, move_resolver)
+ if (!phi->is_illegal()) { resolve_exception_edge(handler, throwing_op_id, phi->operand()->vreg_number(), phi, move_resolver); }
);
if (move_resolver.has_mappings()) {
--- a/src/hotspot/share/c1/c1_ValueStack.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/c1/c1_ValueStack.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -299,7 +299,7 @@
}
-// Macro definition for simple iteration of all phif functions of a block, i.e all
+// Macro definition for simple iteration of all phi functions of a block, i.e all
// phi functions of the ValueStack where the block matches.
// Use the following code pattern to iterate all phi functions of a block:
//
@@ -315,7 +315,7 @@
Value value; \
{ \
for_each_stack_value(cur_state, cur_index, value) { \
- Phi* v_phi = value->as_Phi(); \
+ Phi* v_phi = value->as_Phi(); \
if (v_phi != NULL && v_phi->block() == v_block) { \
v_code; \
} \
@@ -323,7 +323,7 @@
} \
{ \
for_each_local_value(cur_state, cur_index, value) { \
- Phi* v_phi = value->as_Phi(); \
+ Phi* v_phi = value->as_Phi(); \
if (v_phi != NULL && v_phi->block() == v_block) { \
v_code; \
} \
--- a/src/hotspot/share/classfile/classFileParser.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/classfile/classFileParser.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -119,6 +119,8 @@
#define JAVA_12_VERSION 56
+#define JAVA_13_VERSION 57
+
void ClassFileParser::set_class_bad_constant_seen(short bad_constant) {
assert((bad_constant == 19 || bad_constant == 20) && _major_version >= JAVA_9_VERSION,
"Unexpected bad constant pool entry");
--- a/src/hotspot/share/code/vtableStubs.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/code/vtableStubs.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -51,6 +51,7 @@
void* VtableStub::operator new(size_t size, int code_size) throw() {
+ assert_lock_strong(VtableStubs_lock);
assert(size == sizeof(VtableStub), "mismatched size");
// compute real VtableStub size (rounded to nearest word)
const int real_size = align_up(code_size + (int)sizeof(VtableStub), wordSize);
@@ -208,31 +209,35 @@
address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) {
assert(vtable_index >= 0, "must be positive");
- VtableStub* s = ShareVtableStubs ? lookup(is_vtable_stub, vtable_index) : NULL;
- if (s == NULL) {
- if (is_vtable_stub) {
- s = create_vtable_stub(vtable_index);
- } else {
- s = create_itable_stub(vtable_index);
- }
-
- // Creation of vtable or itable can fail if there is not enough free space in the code cache.
+ VtableStub* s;
+ {
+ MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
+ s = ShareVtableStubs ? lookup(is_vtable_stub, vtable_index) : NULL;
if (s == NULL) {
- return NULL;
- }
+ if (is_vtable_stub) {
+ s = create_vtable_stub(vtable_index);
+ } else {
+ s = create_itable_stub(vtable_index);
+ }
- enter(is_vtable_stub, vtable_index, s);
- if (PrintAdapterHandlers) {
- tty->print_cr("Decoding VtableStub %s[%d]@" INTX_FORMAT,
- is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location()));
- Disassembler::decode(s->code_begin(), s->code_end());
- }
- // Notify JVMTI about this stub. The event will be recorded by the enclosing
- // JvmtiDynamicCodeEventCollector and posted when this thread has released
- // all locks.
- if (JvmtiExport::should_post_dynamic_code_generated()) {
- JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub",
- s->code_begin(), s->code_end());
+ // Creation of vtable or itable can fail if there is not enough free space in the code cache.
+ if (s == NULL) {
+ return NULL;
+ }
+
+ enter(is_vtable_stub, vtable_index, s);
+ if (PrintAdapterHandlers) {
+ tty->print_cr("Decoding VtableStub %s[%d]@" INTX_FORMAT,
+ is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location()));
+ Disassembler::decode(s->code_begin(), s->code_end());
+ }
+ // Notify JVMTI about this stub. The event will be recorded by the enclosing
+ // JvmtiDynamicCodeEventCollector and posted when this thread has released
+ // all locks.
+ if (JvmtiExport::should_post_dynamic_code_generated()) {
+ JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub",
+ s->code_begin(), s->code_end());
+ }
}
}
return s->entry_point();
@@ -247,7 +252,7 @@
VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
- MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
+ assert_lock_strong(VtableStubs_lock);
unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);
VtableStub* s = _table[hash];
while( s && !s->matches(is_vtable_stub, vtable_index)) s = s->next();
@@ -256,7 +261,7 @@
void VtableStubs::enter(bool is_vtable_stub, int vtable_index, VtableStub* s) {
- MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
+ assert_lock_strong(VtableStubs_lock);
assert(s->matches(is_vtable_stub, vtable_index), "bad vtable stub");
unsigned int h = VtableStubs::hash(is_vtable_stub, vtable_index);
// enter s at the beginning of the corresponding list
--- a/src/hotspot/share/gc/g1/dirtyCardQueue.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/gc/g1/dirtyCardQueue.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -137,7 +137,9 @@
PtrQueueSet(notify_when_complete),
_shared_dirty_card_queue(this, true /* permanent */),
_free_ids(NULL),
- _processed_buffers_mut(0), _processed_buffers_rs_thread(0)
+ _processed_buffers_mut(0),
+ _processed_buffers_rs_thread(0),
+ _cur_par_buffer_node(NULL)
{
_all_active = true;
}
--- a/src/hotspot/share/gc/g1/g1CardCounts.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/gc/g1/g1CardCounts.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -58,7 +58,7 @@
}
G1CardCounts::G1CardCounts(G1CollectedHeap *g1h):
- _listener(), _g1h(g1h), _card_counts(NULL), _reserved_max_card_num(0) {
+ _listener(), _g1h(g1h), _ct(NULL), _card_counts(NULL), _reserved_max_card_num(0), _ct_bot(NULL) {
_listener.set_cardcounts(this);
}
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -4287,7 +4287,7 @@
public:
G1FreeHumongousRegionClosure(FreeRegionList* free_region_list) :
- _free_region_list(free_region_list), _humongous_objects_reclaimed(0), _humongous_regions_reclaimed(0), _freed_bytes(0) {
+ _free_region_list(free_region_list), _proxy_set(NULL), _humongous_objects_reclaimed(0), _humongous_regions_reclaimed(0), _freed_bytes(0) {
}
virtual bool do_heap_region(HeapRegion* r) {
--- a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -337,10 +337,6 @@
}
class VerifyArchivePointerRegionClosure: public HeapRegionClosure {
-private:
- G1CollectedHeap* _g1h;
-public:
- VerifyArchivePointerRegionClosure(G1CollectedHeap* g1h) { }
virtual bool do_heap_region(HeapRegion* r) {
if (r->is_archive()) {
VerifyObjectInArchiveRegionClosure verify_oop_pointers(r, false);
@@ -352,7 +348,7 @@
void G1HeapVerifier::verify_archive_regions() {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
- VerifyArchivePointerRegionClosure cl(NULL);
+ VerifyArchivePointerRegionClosure cl;
g1h->heap_region_iterate(&cl);
}
--- a/src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,8 @@
"G1YoungRemSetSamplingThread monitor",
true,
Monitor::_safepoint_check_never),
- _last_periodic_gc_attempt_s(os::elapsedTime()) {
+ _last_periodic_gc_attempt_s(os::elapsedTime()),
+ _vtime_accum(0) {
set_name("G1 Young RemSet Sampling");
create_and_start();
}
--- a/src/hotspot/share/gc/g1/heapRegion.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/gc/g1/heapRegion.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -877,8 +877,10 @@
}
G1ContiguousSpace::G1ContiguousSpace(G1BlockOffsetTable* bot) :
+ _top(NULL),
_bot_part(bot, this),
- _par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true)
+ _par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true),
+ _pre_dummy_top(NULL)
{
}
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -939,9 +939,6 @@
q = queues->claim_next();
while (q != NULL) {
if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
- ShenandoahCancelledTerminatorTerminator tt;
- ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers);
- while (!terminator->offer_termination(&tt));
return;
}
@@ -965,9 +962,6 @@
*/
while (true) {
if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
- ShenandoahCancelledTerminatorTerminator tt;
- ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers);
- while (!terminator->offer_termination(&tt));
return;
}
@@ -991,7 +985,8 @@
// Need to leave the STS here otherwise it might block safepoints.
ShenandoahSuspendibleThreadSetLeaver stsl(CANCELLABLE && ShenandoahSuspendibleWorkers);
ShenandoahTerminationTimingsTracker term_tracker(worker_id);
- if (terminator->offer_termination()) return;
+ ShenandoahTerminatorTerminator tt(heap);
+ if (terminator->offer_termination(&tt)) return;
}
}
}
--- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -49,28 +49,8 @@
return true;
}
-class ShenandoahOWSTTerminator: public OWSTTaskTerminator {
-public:
- ShenandoahOWSTTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
- OWSTTaskTerminator(n_threads, queue_set){ }
-
-protected:
- bool exit_termination(size_t tasks, TerminatorTerminator* terminator);
-};
-
-bool ShenandoahOWSTTerminator::exit_termination(size_t tasks, TerminatorTerminator* terminator) {
- ShenandoahTerminatorTerminator* t = (ShenandoahTerminatorTerminator*)terminator;
- bool force = (t != NULL) && t->should_force_termination();
- if (force) {
- // Force termination : continue termination, even there are remaining tasks.
- return false;
- } else {
- return OWSTTaskTerminator::exit_termination(tasks, terminator);
- }
-}
-
ShenandoahTaskTerminator::ShenandoahTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
- _terminator(new ShenandoahOWSTTerminator(n_threads, queue_set)) { }
+ _terminator(new OWSTTaskTerminator(n_threads, queue_set)) { }
ShenandoahTaskTerminator::~ShenandoahTaskTerminator() {
assert(_terminator != NULL, "Invariant");
--- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -306,18 +306,12 @@
};
class ShenandoahTerminatorTerminator : public TerminatorTerminator {
+private:
+ ShenandoahHeap* _heap;
public:
+ ShenandoahTerminatorTerminator(ShenandoahHeap* const heap) : _heap(heap) { }
// return true, terminates immediately, even if there's remaining work left
- virtual bool should_force_termination() { return false; }
-};
-
-class ShenandoahCancelledTerminatorTerminator : public ShenandoahTerminatorTerminator {
- virtual bool should_exit_termination() {
- return false;
- }
- virtual bool should_force_termination() {
- return true;
- }
+ virtual bool should_exit_termination() { return _heap->cancelled_gc(); }
};
class ShenandoahTaskTerminator : public StackObj {
--- a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -498,10 +498,6 @@
q = queues->claim_next();
while (q != NULL) {
if (_heap->check_cancelled_gc_and_yield(sts_yield)) {
- ShenandoahCancelledTerminatorTerminator tt;
- ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
- ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
- while (!terminator->offer_termination(&tt));
return;
}
@@ -547,17 +543,15 @@
ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
ShenandoahTerminationTimingsTracker term_tracker(worker_id);
- if (terminator->offer_termination()) return;
+ ShenandoahTerminatorTerminator tt(_heap);
+
+ if (terminator->offer_termination(&tt)) return;
}
}
}
bool ShenandoahTraversalGC::check_and_handle_cancelled_gc(ShenandoahTaskTerminator* terminator, bool sts_yield) {
if (_heap->cancelled_gc()) {
- ShenandoahCancelledTerminatorTerminator tt;
- ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
- ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
- while (! terminator->offer_termination(&tt));
return true;
}
return false;
--- a/src/hotspot/share/interpreter/invocationCounter.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/interpreter/invocationCounter.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -153,9 +153,9 @@
// don't need the shift by number_of_noncount_bits, but we do need to adjust
// the factor by which we scale the threshold.
if (ProfileInterpreter) {
- InterpreterBackwardBranchLimit = (CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
+ InterpreterBackwardBranchLimit = (int)((int64_t)CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage) / 100);
} else {
- InterpreterBackwardBranchLimit = ((CompileThreshold * OnStackReplacePercentage) / 100) << number_of_noncount_bits;
+ InterpreterBackwardBranchLimit = (int)(((int64_t)CompileThreshold * OnStackReplacePercentage / 100) << number_of_noncount_bits);
}
assert(0 <= InterpreterBackwardBranchLimit,
--- a/src/hotspot/share/jfr/jni/jfrJniMethod.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/jfr/jni/jfrJniMethod.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -33,7 +33,7 @@
#include "jfr/recorder/checkpoint/jfrMetadataEvent.hpp"
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp"
#include "jfr/recorder/repository/jfrRepository.hpp"
-#include "jfr/recorder/repository/jfrChunkSizeNotifier.hpp"
+#include "jfr/recorder/repository/jfrChunkRotation.hpp"
#include "jfr/recorder/repository/jfrChunkWriter.hpp"
#include "jfr/recorder/service/jfrOptionSet.hpp"
#include "jfr/recorder/stacktrace/jfrStackTraceRepository.hpp"
@@ -114,7 +114,7 @@
NO_TRANSITION_END
NO_TRANSITION(void, jfr_set_file_notification(JNIEnv* env, jobject jvm, jlong threshold))
- JfrChunkSizeNotifier::set_chunk_size_threshold((size_t)threshold);
+ JfrChunkRotation::set_threshold((intptr_t)threshold);
NO_TRANSITION_END
NO_TRANSITION(void, jfr_set_sample_threads(JNIEnv* env, jobject jvm, jboolean sampleThreads))
@@ -173,6 +173,9 @@
return JfrEventSetting::set_cutoff(event_type_id, cutoff_ticks) ? JNI_TRUE : JNI_FALSE;
NO_TRANSITION_END
+NO_TRANSITION(jboolean, jfr_should_rotate_disk(JNIEnv* env, jobject jvm))
+ return JfrChunkRotation::should_rotate() ? JNI_TRUE : JNI_FALSE;
+NO_TRANSITION_END
/*
* JVM_ENTRY_NO_ENV entries
--- a/src/hotspot/share/jfr/jni/jfrJniMethod.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/jfr/jni/jfrJniMethod.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -129,6 +129,9 @@
void JNICALL jfr_emit_old_object_samples(JNIEnv* env, jobject jvm, jlong cutoff_ticks, jboolean);
+jboolean JNICALL jfr_should_rotate_disk(JNIEnv* env, jobject jvm);
+
+
#ifdef __cplusplus
}
#endif
--- a/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -78,7 +78,8 @@
(char*)"setForceInstrumentation", (char*)"(Z)V", (void*)jfr_set_force_instrumentation,
(char*)"getUnloadedEventClassCount", (char*)"()J", (void*)jfr_get_unloaded_event_classes_count,
(char*)"setCutoff", (char*)"(JJ)Z", (void*)jfr_set_cutoff,
- (char*)"emitOldObjectSamples", (char*)"(JZ)V", (void*)jfr_emit_old_object_samples
+ (char*)"emitOldObjectSamples", (char*)"(JZ)V", (void*)jfr_emit_old_object_samples,
+ (char*)"shouldRotateDisk", (char*)"()Z", (void*)jfr_should_rotate_disk
};
const size_t method_array_length = sizeof(method) / sizeof(JNINativeMethod);
--- a/src/hotspot/share/jfr/leakprofiler/emitEventOperation.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/jfr/leakprofiler/emitEventOperation.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -185,7 +185,7 @@
if (object->is_array()) {
return arrayOop(object)->length();
}
- return -1;
+ return min_jint;
}
void EmitEventOperation::write_event(const ObjectSample* sample, EdgeStore* edge_store) {
--- a/src/hotspot/share/jfr/metadata/metadata.xml Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/jfr/metadata/metadata.xml Tue Dec 18 15:08:56 2018 -0500
@@ -40,7 +40,8 @@
<Event name="ThreadPark" category="Java Application" label="Java Thread Park" thread="true" stackTrace="true">
<Field type="Class" name="parkedClass" label="Class Parked On" />
- <Field type="long" contentType="millis" name="timeout" label="Park Timeout" />
+ <Field type="long" contentType="nanos" name="timeout" label="Park Timeout" />
+ <Field type="long" contentType="epochmillis" name="until" label="Park Until" />
<Field type="ulong" contentType="address" name="address" label="Address of Object Parked" relation="JavaMonitorAddress" />
</Event>
@@ -64,19 +65,19 @@
<Field type="InflateCause" name="cause" label="Monitor Inflation Cause" description="Cause of inflation" />
</Event>
- <Event name="BiasedLockRevocation" category="Java Application" label="Biased Lock Revocation" description="Revoked bias of object" thread="true"
+ <Event name="BiasedLockRevocation" category="Java Virtual Machine, Runtime" label="Biased Lock Revocation" description="Revoked bias of object" thread="true"
stackTrace="true">
<Field type="Class" name="lockClass" label="Lock Class" description="Class of object whose biased lock was revoked" />
<Field type="ulong" name="safepointId" label="Safepoint Identifier" relation="SafepointId" />
<Field type="Thread" name="previousOwner" label="Previous Owner" description="Thread owning the bias before revocation" />
</Event>
- <Event name="BiasedLockSelfRevocation" category="Java Application" label="Biased Lock Self Revocation" description="Revoked bias of object biased towards own thread"
+ <Event name="BiasedLockSelfRevocation" category="Java Virtual Machine, Runtime" label="Biased Lock Self Revocation" description="Revoked bias of object biased towards own thread"
thread="true" stackTrace="true">
<Field type="Class" name="lockClass" label="Lock Class" description="Class of object whose biased lock was revoked" />
</Event>
- <Event name="BiasedLockClassRevocation" category="Java Application" label="Biased Lock Class Revocation" description="Revoked biases for all instances of a class"
+ <Event name="BiasedLockClassRevocation" category="Java Virtual Machine, Runtime" label="Biased Lock Class Revocation" description="Revoked biases for all instances of a class"
thread="true" stackTrace="true">
<Field type="Class" name="revokedClass" label="Revoked Class" description="Class whose biased locks were revoked" />
<Field type="boolean" name="disableBiasing" label="Disable Further Biasing" description="Whether further biasing for instances of this class will be allowed" />
@@ -349,7 +350,7 @@
<Field type="ulong" contentType="bytes" name="recentMutatorAllocationSize" label="Recent Mutator Allocation Size"
description="Mutator allocation during mutator operation in the most recent interval" />
<Field type="long" contentType="millis" name="recentMutatorDuration" label="Recent Mutator Duration" description="Time the mutator ran in the most recent interval" />
- <Field type="double" name="recentAllocationRate" label="Recent Allocation Rate" description="Allocation rate of the mutator in the most recent interval in bytes/second" />
+ <Field type="double" contentType="bytes-per-second" name="recentAllocationRate" label="Recent Allocation Rate" description="Allocation rate of the mutator in the most recent interval in bytes/second" />
<Field type="long" contentType="millis" name="lastMarkingDuration" label="Last Marking Duration" description="Last time from the end of the last initial mark to the first mixed GC" />
</Event>
@@ -361,7 +362,7 @@
<Field type="ulong" contentType="bytes" name="ihopTargetOccupancy" label="IHOP Target Occupancy" description="Internal target old generation occupancy to reach at the start of mixed GC" />
<Field type="ulong" contentType="bytes" name="currentOccupancy" label="Current Occupancy" description="Current old generation occupancy" />
<Field type="ulong" contentType="bytes" name="additionalBufferSize" label="Additional Buffer" description="Additional buffer size" experimental="true" />
- <Field type="double" name="predictedAllocationRate" label="Predicted Allocation Rate" description="Current predicted allocation rate for the mutator in bytes/second" />
+ <Field type="double" contentType="bytes-per-second" name="predictedAllocationRate" label="Predicted Allocation Rate" description="Current predicted allocation rate for the mutator in bytes/second" />
<Field type="long" contentType="millis" name="predictedMarkingDuration" label="Predicted Marking Duration"
description="Current predicted time from the end of the last initial mark to the first mixed GC" />
<Field type="boolean" name="predictionActive" label="Prediction Active" description="Indicates whether the adaptive IHOP prediction is active" />
@@ -563,9 +564,9 @@
relation="SafepointId" />
</Event>
- <Event name="Shutdown" category="Java Virtual Machine, Runtime" label="VM Shutdown" description="VM shutting down" thread="true" stackTrace="true"
+ <Event name="Shutdown" category="Java Virtual Machine, Runtime" label="JVM Shutdown" description="JVM shutting down" thread="true" stackTrace="true"
startTime="false">
- <Field type="string" name="reason" label="Reason" description="Reason for VM shutdown" />
+ <Field type="string" name="reason" label="Reason" description="Reason for JVM shutdown" />
</Event>
<Event name="ObjectAllocationInNewTLAB" category="Java Application" label="Allocation in new TLAB" description="Allocation in new Thread Local Allocation Buffer"
@@ -581,7 +582,7 @@
<Field type="ulong" contentType="bytes" name="allocationSize" label="Allocation Size" />
</Event>
- <Event name="OldObjectSample" category="Java Application" label="Old Object Sample" description="A potential memory leak" stackTrace="true" thread="true"
+ <Event name="OldObjectSample" category="Java Virtual Machine, Profiling" label="Old Object Sample" description="A potential memory leak" stackTrace="true" thread="true"
startTime="false" cutoff="true">
<Field type="Ticks" name="allocationTime" label="Allocation Time" />
<Field type="ulong" contentType="bytes" name="lastKnownHeapUsage" label="Last Known Heap Usage" />
@@ -646,8 +647,8 @@
<Event name="CPUTimeStampCounter" category="Operating System, Processor" label="CPU Time Stamp Counter" period="endChunk">
<Field type="boolean" name="fastTimeEnabled" label="Fast Time" />
<Field type="boolean" name="fastTimeAutoEnabled" label="Trusted Platform" />
- <Field type="long" name="osFrequency" label="OS Frequency Per Second" />
- <Field type="long" name="fastTimeFrequency" label="Fast Time Frequency per Second" />
+ <Field type="long" contentType="hertz" name="osFrequency" label="OS Frequency" />
+ <Field type="long" contentType="hertz" name="fastTimeFrequency" label="Fast Time Frequency" />
</Event>
<Event name="CPULoad" category="Operating System, Processor" label="CPU Load" description="OS CPU Load" period="everyChunk">
@@ -662,13 +663,13 @@
</Event>
<Event name="ThreadContextSwitchRate" category="Operating System, Processor" label="Thread Context Switch Rate" period="everyChunk">
- <Field type="float" name="switchRate" label="Switch Rate" description="Number of context switches per second" />
+ <Field type="float" contentType="hertz" name="switchRate" label="Switch Rate" description="Number of context switches per second" />
</Event>
<Event name="NetworkUtilization" category="Operating System, Network" label="Network Utilization" period="everyChunk">
<Field type="NetworkInterfaceName" name="networkInterface" label="Network Interface" description="Network Interface Name"/>
- <Field type="long" contentType="bytes" name="readRate" label="Read Rate" description="Number of incoming bytes per second"/>
- <Field type="long" contentType="bytes" name="writeRate" label="Write Rate" description="Number of outgoing bytes per second"/>
+ <Field type="long" contentType="bits-per-second" name="readRate" label="Read Rate" description="Number of incoming bits per second"/>
+ <Field type="long" contentType="bits-per-second" name="writeRate" label="Write Rate" description="Number of outgoing bits per second"/>
</Event>
<Event name="JavaThreadStatistics" category="Java Application, Statistics" label="Java Thread Statistics" period="everyChunk">
@@ -686,7 +687,7 @@
<Event name="ClassLoaderStatistics" category="Java Application, Statistics" label="Class Loader Statistics" period="everyChunk">
<Field type="ClassLoader" name="classLoader" label="Class Loader" />
<Field type="ClassLoader" name="parentClassLoader" label="Parent Class Loader" />
- <Field type="ulong" contentType="address" name="classLoaderData" label="ClassLoaderData pointer" description="Pointer to the ClassLoaderData structure in the JVM" />
+ <Field type="ulong" contentType="address" name="classLoaderData" label="ClassLoaderData Pointer" description="Pointer to the ClassLoaderData structure in the JVM" />
<Field type="long" name="classCount" label="Classes" description="Number of loaded classes" />
<Field type="ulong" contentType="bytes" name="chunkSize" label="Total Chunk Size" description="Total size of all allocated metaspace chunks (each chunk has several blocks)" />
<Field type="ulong" contentType="bytes" name="blockSize" label="Total Block Size" description="Total size of all allocated metaspace blocks (each chunk has several blocks)" />
@@ -740,8 +741,7 @@
<Event name="ModuleExport" category="Java Virtual Machine, Runtime, Modules" label="Module Export" thread="false" period="everyChunk">
<Field type="Package" name="exportedPackage" label="Exported Package" />
<Field type="Module" name="targetModule" label="Target Module"
- description="Module to which the package is qualifiedly exported.
- If null, the package is unqualifiedly exported" />
+ description="Module to which the package is qualifiedly exported. If null or N/A, the package is unqualifiedly exported" />
</Event>
<Event name="CompilerStatistics" category="Java Virtual Machine, Compiler" label="Compiler Statistics" thread="false" period="everyChunk" startTime="false">
@@ -1095,7 +1095,7 @@
<Field type="OldObjectArray" name="array" label="Array Information" description="Array or null if it is not an array" />
<Field type="OldObjectField" name="field" label="Field Information" description="Field or null if it is an array" />
<Field type="OldObject" name="object" label="Object" description="Object holder for this reference" />
- <Field type="int" name="skip" label="Skip value" description="The object is this many hops away" />
+ <Field type="int" name="skip" label="Skip Value" description="The object is this many hops away" />
</Type>
<Type name="StackFrame">
@@ -1133,12 +1133,16 @@
<XmlType name="char" javaType="char" parameterType="char" fieldType="char"/>
<XmlType name="string" javaType="java.lang.String" parameterType="const char*" fieldType="const char*"/>
- <XmlContentType name="bytes" annotationType="jdk.jfr.DataAmount" annotationValue="BYTES" />
- <XmlContentType name="tickstamp" annotationType="jdk.jfr.Timestamp" annotationValue="TICKS" />
- <XmlContentType name="epochmillis" annotationType="jdk.jfr.Timestamp" annotationValue="MILLISECONDS_SINCE_EPOCH" />
- <XmlContentType name="tickspan" annotationType="jdk.jfr.Timespan" annotationValue="TICKS" />
- <XmlContentType name="address" annotationType="jdk.jfr.MemoryAddress" />
- <XmlContentType name="percentage" annotationType="jdk.jfr.Percentage" />
- <XmlContentType name="millis" annotationType="jdk.jfr.Timespan" annotationValue="MILLISECONDS" />
-
+ <XmlContentType name="bytes" annotation="jdk.jfr.DataAmount(BYTES)" />
+ <XmlContentType name="tickstamp" annotation="jdk.jfr.Timestamp(TICKS)" />
+ <XmlContentType name="epochmillis" annotation="jdk.jfr.Timestamp(MILLISECONDS_SINCE_EPOCH)" />
+ <XmlContentType name="tickspan" annotation="jdk.jfr.Timespan(TICKS)" />
+ <XmlContentType name="address" annotation="jdk.jfr.MemoryAddress" />
+ <XmlContentType name="percentage" annotation="jdk.jfr.Percentage" />
+ <XmlContentType name="millis" annotation="jdk.jfr.Timespan(MILLISECONDS)" />
+ <XmlContentType name="nanos" annotation="jdk.jfr.Timespan(NANOSECONDS)" />
+ <XmlContentType name="hertz" annotation="jdk.jfr.Frequency" />
+ <XmlContentType name="bytes-per-second" annotation="jdk.jfr.DataAmount(BYTES), jdk.jfr.Frequency" />
+ <XmlContentType name="bits-per-second" annotation="jdk.jfr.DataAmount(BITS), jdk.jfr.Frequency" />
+
</Metadata>
--- a/src/hotspot/share/jfr/metadata/metadata.xsd Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/jfr/metadata/metadata.xsd Tue Dec 18 15:08:56 2018 -0500
@@ -107,8 +107,7 @@
<xs:element name="XmlContentType">
<xs:complexType>
<xs:attribute name="name" type="xs:NMTOKEN" use="required" />
- <xs:attribute name="annotationType" type="xs:NMTOKEN" use="required" />
- <xs:attribute name="annotationValue" type="xs:string" use="optional" />
+ <xs:attribute name="annotation" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="Relation">
--- a/src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -174,8 +174,8 @@
event.set_starttime(cur_time);
event.set_endtime(cur_time);
event.set_networkInterface(entry.id);
- event.set_readRate(read_rate);
- event.set_writeRate(write_rate);
+ event.set_readRate(8 * read_rate);
+ event.set_writeRate(8 * write_rate);
event.commit();
}
// update existing entry with new values
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/jfr/recorder/repository/jfrChunkRotation.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "jfr/jni/jfrJavaSupport.hpp"
+#include "jfr/recorder/repository/jfrChunkRotation.hpp"
+#include "jfr/recorder/repository/jfrChunkWriter.hpp"
+
+static jobject chunk_monitor = NULL;
+static intptr_t threshold = 0;
+static bool rotate = false;
+
+static jobject install_chunk_monitor(Thread* thread) {
+ assert(chunk_monitor == NULL, "invariant");
+ // read static field
+ HandleMark hm(thread);
+ static const char klass[] = "jdk/jfr/internal/JVM";
+ static const char field[] = "FILE_DELTA_CHANGE";
+ static const char signature[] = "Ljava/lang/Object;";
+ JavaValue result(T_OBJECT);
+ JfrJavaArguments field_args(&result, klass, field, signature, thread);
+ JfrJavaSupport::get_field_global_ref(&field_args, thread);
+ chunk_monitor = result.get_jobject();
+ return chunk_monitor;
+}
+
+// lazy install
+static jobject get_chunk_monitor(Thread* thread) {
+ return chunk_monitor != NULL ? chunk_monitor : install_chunk_monitor(thread);
+}
+
+static void notify() {
+ Thread* const thread = Thread::current();
+ JfrJavaSupport::notify_all(get_chunk_monitor(thread), thread);
+}
+
+void JfrChunkRotation::evaluate(const JfrChunkWriter& writer) {
+ assert(threshold > 0, "invariant");
+ if (rotate) {
+ // already in progress
+ return;
+ }
+ assert(!rotate, "invariant");
+ if (writer.size_written() > threshold) {
+ rotate = true;
+ notify();
+ }
+}
+
+bool JfrChunkRotation::should_rotate() {
+ return rotate;
+}
+
+void JfrChunkRotation::on_rotation() {
+ rotate = false;
+}
+
+void JfrChunkRotation::set_threshold(intptr_t bytes) {
+ threshold = bytes;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/jfr/recorder/repository/jfrChunkRotation.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ *
+ */
+
+#ifndef SHARE_VM_JFR_RECORDER_REPOSITORY_JFRCHUNKROTATION_HPP
+#define SHARE_VM_JFR_RECORDER_REPOSITORY_JFRCHUNKROTATION_HPP
+
+#include "memory/allocation.hpp"
+
+class JfrChunkWriter;
+
+//
+// Responsible for notifications about current chunk size now exceeding threshold.
+// This is a means to initiate a chunk rotation on the basis of the size written.
+//
+class JfrChunkRotation : AllStatic {
+ public:
+ static void evaluate(const JfrChunkWriter& writer);
+ static void set_threshold(intptr_t bytes);
+ static bool should_rotate();
+ static void on_rotation();
+};
+
+#endif // SHARE_VM_JFR_RECORDER_REPOSITORY_JFRCHUNKROTATION_HPP
--- a/src/hotspot/share/jfr/recorder/repository/jfrChunkSizeNotifier.cpp Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
- * 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.
- *
- */
-
-#include "precompiled.hpp"
-#include "jfr/jni/jfrJavaSupport.hpp"
-#include "jfr/recorder/repository/jfrChunkWriter.hpp"
-#include "jfr/recorder/repository/jfrChunkSizeNotifier.hpp"
-
-size_t JfrChunkSizeNotifier::_chunk_size_threshold = 0;
-
-void JfrChunkSizeNotifier::set_chunk_size_threshold(size_t bytes) {
- _chunk_size_threshold = bytes;
-}
-
-size_t JfrChunkSizeNotifier::chunk_size_threshold() {
- return _chunk_size_threshold;
-}
-
-static jobject new_chunk_monitor = NULL;
-
-// lazy install
-static jobject get_new_chunk_monitor(Thread* thread) {
- static bool initialized = false;
- if (initialized) {
- assert(new_chunk_monitor != NULL, "invariant");
- return new_chunk_monitor;
- }
- assert(new_chunk_monitor == NULL, "invariant");
- // read static field
- HandleMark hm(thread);
- static const char klass[] = "jdk/jfr/internal/JVM";
- static const char field[] = "FILE_DELTA_CHANGE";
- static const char signature[] = "Ljava/lang/Object;";
- JavaValue result(T_OBJECT);
- JfrJavaArguments field_args(&result, klass, field, signature, thread);
- JfrJavaSupport::get_field_global_ref(&field_args, thread);
- new_chunk_monitor = result.get_jobject();
- initialized = new_chunk_monitor != NULL;
- return new_chunk_monitor;
-}
-
-void JfrChunkSizeNotifier::notify() {
- Thread* const thread = Thread::current();
- JfrJavaSupport::notify_all(get_new_chunk_monitor(thread), thread);
-}
-
-void JfrChunkSizeNotifier::release_monitor() {
- if (new_chunk_monitor != NULL) {
- JfrJavaSupport::destroy_global_jni_handle(new_chunk_monitor);
- new_chunk_monitor = NULL;
- }
-}
--- a/src/hotspot/share/jfr/recorder/repository/jfrChunkSizeNotifier.hpp Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
- * 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.
- *
- */
-
-#ifndef SHARE_VM_JFR_RECORDER_REPOSITORY_JFRRCHUNKSIZENOTIFIER_HPP
-#define SHARE_VM_JFR_RECORDER_REPOSITORY_JFRRCHUNKSIZENOTIFIER_HPP
-
-#include "memory/allocation.hpp"
-
-//
-// Responsible for notifications about current chunk size now exceeding threshold.
-// This is a means to initiate a chunk rotation on the basis of size written.
-//
-class JfrChunkSizeNotifier : AllStatic {
- friend class JfrRecorder;
- private:
- static size_t _chunk_size_threshold;
- static void release_monitor();
- public:
- static void set_chunk_size_threshold(size_t bytes);
- static size_t chunk_size_threshold();
- static void notify();
-};
-
-#endif // SHARE_VM_JFR_RECORDER_REPOSITORY_JFRRCHUNKSIZENOTIFIER_HPP
--- a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -28,7 +28,7 @@
#include "jfr/recorder/jfrRecorder.hpp"
#include "jfr/recorder/checkpoint/jfrCheckpointManager.hpp"
#include "jfr/recorder/checkpoint/jfrMetadataEvent.hpp"
-#include "jfr/recorder/repository/jfrChunkSizeNotifier.hpp"
+#include "jfr/recorder/repository/jfrChunkRotation.hpp"
#include "jfr/recorder/repository/jfrChunkWriter.hpp"
#include "jfr/recorder/repository/jfrRepository.hpp"
#include "jfr/recorder/service/jfrPostBox.hpp"
@@ -340,6 +340,7 @@
void JfrRecorderService::open_new_chunk(bool vm_error) {
assert(!_chunkwriter.is_valid(), "invariant");
assert(!JfrStream_lock->owned_by_self(), "invariant");
+ JfrChunkRotation::on_rotation();
MutexLockerEx stream_lock(JfrStream_lock, Mutex::_no_safepoint_check_flag);
if (!_repository.open_chunk(vm_error)) {
assert(!_chunkwriter.is_valid(), "invariant");
@@ -535,8 +536,5 @@
}
void JfrRecorderService::evaluate_chunk_size_for_rotation() {
- const size_t size_written = _chunkwriter.size_written();
- if (size_written > JfrChunkSizeNotifier::chunk_size_threshold()) {
- JfrChunkSizeNotifier::notify();
- }
+ JfrChunkRotation::evaluate(_chunkwriter);
}
--- a/src/hotspot/share/memory/heapInspection.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/memory/heapInspection.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -168,14 +168,12 @@
KlassInfoTable::KlassInfoTable(bool add_all_classes) {
_size_of_instances_in_words = 0;
- _size = 0;
_ref = (HeapWord*) Universe::boolArrayKlassObj();
_buckets =
(KlassInfoBucket*) AllocateHeap(sizeof(KlassInfoBucket) * _num_buckets,
mtInternal, CURRENT_PC, AllocFailStrategy::RETURN_NULL);
if (_buckets != NULL) {
- _size = _num_buckets;
- for (int index = 0; index < _size; index++) {
+ for (int index = 0; index < _num_buckets; index++) {
_buckets[index].initialize();
}
if (add_all_classes) {
@@ -187,11 +185,11 @@
KlassInfoTable::~KlassInfoTable() {
if (_buckets != NULL) {
- for (int index = 0; index < _size; index++) {
+ for (int index = 0; index < _num_buckets; index++) {
_buckets[index].empty();
}
FREE_C_HEAP_ARRAY(KlassInfoBucket, _buckets);
- _size = 0;
+ _buckets = NULL;
}
}
@@ -200,7 +198,7 @@
}
KlassInfoEntry* KlassInfoTable::lookup(Klass* k) {
- uint idx = hash(k) % _size;
+ uint idx = hash(k) % _num_buckets;
assert(_buckets != NULL, "Allocation failure should have been caught");
KlassInfoEntry* e = _buckets[idx].lookup(k);
// Lookup may fail if this is a new klass for which we
@@ -227,8 +225,8 @@
}
void KlassInfoTable::iterate(KlassInfoClosure* cic) {
- assert(_size == 0 || _buckets != NULL, "Allocation failure should have been caught");
- for (int index = 0; index < _size; index++) {
+ assert(_buckets != NULL, "Allocation failure should have been caught");
+ for (int index = 0; index < _num_buckets; index++) {
_buckets[index].iterate(cic);
}
}
--- a/src/hotspot/share/memory/heapInspection.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/memory/heapInspection.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -234,7 +234,6 @@
class KlassInfoTable: public StackObj {
private:
- int _size;
static const int _num_buckets = 20011;
size_t _size_of_instances_in_words;
--- a/src/hotspot/share/oops/methodCounters.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/oops/methodCounters.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -103,9 +103,9 @@
// If interpreter profiling is enabled, the backward branch limit
// is compared against the method data counter rather than an invocation
// counter, therefore no shifting of bits is required.
- _interpreter_backward_branch_limit = (compile_threshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
+ _interpreter_backward_branch_limit = (int)((int64_t)compile_threshold * (OnStackReplacePercentage - InterpreterProfilePercentage) / 100);
} else {
- _interpreter_backward_branch_limit = ((compile_threshold * OnStackReplacePercentage) / 100) << InvocationCounter::count_shift;
+ _interpreter_backward_branch_limit = (int)(((int64_t)compile_threshold * OnStackReplacePercentage / 100) << InvocationCounter::count_shift);
}
_interpreter_profile_limit = ((compile_threshold * InterpreterProfilePercentage) / 100) << InvocationCounter::count_shift;
_invoke_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
--- a/src/hotspot/share/opto/classes.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/opto/classes.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -201,6 +201,7 @@
macro(LoopLimit)
macro(Mach)
macro(MachProj)
+macro(MulAddS2I)
macro(MaxI)
macro(MemBarAcquire)
macro(LoadFence)
@@ -341,6 +342,7 @@
macro(MulReductionVF)
macro(MulVD)
macro(MulReductionVD)
+macro(MulAddVS2VI)
macro(FmaVD)
macro(FmaVF)
macro(DivVF)
--- a/src/hotspot/share/opto/loopnode.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/opto/loopnode.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -1249,6 +1249,9 @@
// important (common) to do address expressions.
Node *remix_address_expressions( Node *n );
+ // Convert add to muladd to generate MuladdS2I under certain criteria
+ Node * convert_add_to_muladd(Node * n);
+
// Attempt to use a conditional move instead of a phi/branch
Node *conditional_move( Node *n );
--- a/src/hotspot/share/opto/loopopts.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/opto/loopopts.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -493,6 +493,54 @@
return NULL;
}
+// Optimize ((in1[2*i] * in2[2*i]) + (in1[2*i+1] * in2[2*i+1]))
+Node *PhaseIdealLoop::convert_add_to_muladd(Node* n) {
+ assert(n->Opcode() == Op_AddI, "sanity");
+ Node * nn = NULL;
+ Node * in1 = n->in(1);
+ Node * in2 = n->in(2);
+ if (in1->Opcode() == Op_MulI && in2->Opcode() == Op_MulI) {
+ IdealLoopTree* loop_n = get_loop(get_ctrl(n));
+ if (loop_n->_head->as_Loop()->is_valid_counted_loop() &&
+ Matcher::match_rule_supported(Op_MulAddS2I) &&
+ Matcher::match_rule_supported(Op_MulAddVS2VI)) {
+ Node* mul_in1 = in1->in(1);
+ Node* mul_in2 = in1->in(2);
+ Node* mul_in3 = in2->in(1);
+ Node* mul_in4 = in2->in(2);
+ if (mul_in1->Opcode() == Op_LoadS &&
+ mul_in2->Opcode() == Op_LoadS &&
+ mul_in3->Opcode() == Op_LoadS &&
+ mul_in4->Opcode() == Op_LoadS) {
+ IdealLoopTree* loop1 = get_loop(get_ctrl(mul_in1));
+ IdealLoopTree* loop2 = get_loop(get_ctrl(mul_in2));
+ IdealLoopTree* loop3 = get_loop(get_ctrl(mul_in3));
+ IdealLoopTree* loop4 = get_loop(get_ctrl(mul_in4));
+ IdealLoopTree* loop5 = get_loop(get_ctrl(in1));
+ IdealLoopTree* loop6 = get_loop(get_ctrl(in2));
+ // All nodes should be in the same counted loop.
+ if (loop_n == loop1 && loop_n == loop2 && loop_n == loop3 &&
+ loop_n == loop4 && loop_n == loop5 && loop_n == loop6) {
+ Node* adr1 = mul_in1->in(MemNode::Address);
+ Node* adr2 = mul_in2->in(MemNode::Address);
+ Node* adr3 = mul_in3->in(MemNode::Address);
+ Node* adr4 = mul_in4->in(MemNode::Address);
+ if (adr1->is_AddP() && adr2->is_AddP() && adr3->is_AddP() && adr4->is_AddP()) {
+ if ((adr1->in(AddPNode::Base) == adr3->in(AddPNode::Base)) &&
+ (adr2->in(AddPNode::Base) == adr4->in(AddPNode::Base))) {
+ nn = new MulAddS2INode(mul_in1, mul_in2, mul_in3, mul_in4);
+ register_new_node(nn, get_ctrl(n));
+ _igvn.replace_node(n, nn);
+ return nn;
+ }
+ }
+ }
+ }
+ }
+ }
+ return nn;
+}
+
//------------------------------conditional_move-------------------------------
// Attempt to replace a Phi with a conditional move. We have some pretty
// strict profitability requirements. All Phis at the merge point must
@@ -927,6 +975,11 @@
Node *m = remix_address_expressions( n );
if( m ) return m;
+ if (n_op == Op_AddI) {
+ Node *nn = convert_add_to_muladd( n );
+ if ( nn ) return nn;
+ }
+
if (n->is_ConstraintCast()) {
Node* dom_cast = n->as_ConstraintCast()->dominating_cast(&_igvn, this);
// ConstraintCastNode::dominating_cast() uses node control input to determine domination.
--- a/src/hotspot/share/opto/matcher.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/opto/matcher.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -2352,6 +2352,15 @@
n->del_req(3);
break;
}
+ case Op_MulAddS2I: {
+ Node* pair1 = new BinaryNode(n->in(1), n->in(2));
+ Node* pair2 = new BinaryNode(n->in(3), n->in(4));
+ n->set_req(1, pair1);
+ n->set_req(2, pair2);
+ n->del_req(4);
+ n->del_req(3);
+ break;
+ }
default:
break;
}
--- a/src/hotspot/share/opto/mulnode.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/opto/mulnode.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -285,4 +285,15 @@
virtual const Type* Value(PhaseGVN* phase) const;
};
+//------------------------------MulAddS2INode----------------------------------
+// Multiply shorts into integers and add them.
+// Semantics: I_OUT = S1 * S2 + S3 * S4
+class MulAddS2INode : public Node {
+public:
+ MulAddS2INode(Node* in1, Node *in2, Node *in3, Node* in4) : Node(0, in1, in2, in3, in4) {}
+ virtual int Opcode() const;
+ const Type *bottom_type() const { return TypeInt::INT; }
+ virtual uint ideal_reg() const { return Op_RegI; }
+};
+
#endif // SHARE_VM_OPTO_MULNODE_HPP
--- a/src/hotspot/share/opto/parseHelper.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/opto/parseHelper.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -471,15 +471,15 @@
if (osr_site) {
ciProfileData* data = md->bci_to_data(cur_bci);
assert(data != NULL && data->is_JumpData(), "need JumpData for taken branch");
- int limit = (CompileThreshold
- * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
+ int limit = (int)((int64_t)CompileThreshold
+ * (OnStackReplacePercentage - InterpreterProfilePercentage) / 100);
test_for_osr_md_counter_at(md, data, JumpData::taken_offset(), limit);
}
} else {
// With method data update off, use the invocation counter to trigger an
// OSR compilation, as done in the interpreter.
if (osr_site) {
- int limit = (CompileThreshold * OnStackReplacePercentage) / 100;
+ int limit = (int)((int64_t)CompileThreshold * OnStackReplacePercentage / 100);
increment_and_test_invocation_counter(limit);
}
}
--- a/src/hotspot/share/opto/superword.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/opto/superword.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -645,6 +645,10 @@
// with a different alignment were created before.
for (uint i = 0; i < align_to_refs.size(); i++) {
MemNode* mr = align_to_refs.at(i)->as_Mem();
+ if (mr == mem_ref) {
+ // Skip when we are looking at same memory operation.
+ continue;
+ }
if (same_velt_type(mr, mem_ref) &&
memory_alignment(mr, iv_adjustment) != 0)
create_pack = false;
@@ -846,6 +850,27 @@
return NULL;
}
+//------------------span_works_for_memory_size-----------------------------
+static bool span_works_for_memory_size(MemNode* mem, int span, int mem_size, int offset) {
+ bool span_matches_memory = false;
+ if ((mem_size == type2aelembytes(T_BYTE) || mem_size == type2aelembytes(T_SHORT))
+ && ABS(span) == type2aelembytes(T_INT)) {
+ // There is a mismatch on span size compared to memory.
+ for (DUIterator_Fast jmax, j = mem->fast_outs(jmax); j < jmax; j++) {
+ Node* use = mem->fast_out(j);
+ if (!VectorNode::is_type_transition_to_int(use)) {
+ return false;
+ }
+ }
+ // If all uses transition to integer, it means that we can successfully align even on mismatch.
+ return true;
+ }
+ else {
+ span_matches_memory = ABS(span) == mem_size;
+ }
+ return span_matches_memory && (ABS(offset) % mem_size) == 0;
+}
+
//------------------------------ref_is_alignable---------------------------
// Can the preloop align the reference to position zero in the vector?
bool SuperWord::ref_is_alignable(SWPointer& p) {
@@ -862,7 +887,7 @@
int offset = p.offset_in_bytes();
// Stride one accesses are alignable if offset is aligned to memory operation size.
// Offset can be unaligned when UseUnalignedAccesses is used.
- if (ABS(span) == mem_size && (ABS(offset) % mem_size) == 0) {
+ if (span_works_for_memory_size(p.mem(), span, mem_size, offset)) {
return true;
}
// If the initial offset from start of the object is computable,
@@ -915,6 +940,28 @@
}
return false;
}
+//---------------------------get_vw_bytes_special------------------------
+int SuperWord::get_vw_bytes_special(MemNode* s) {
+ // Get the vector width in bytes.
+ int vw = vector_width_in_bytes(s);
+
+ // Check for special case where there is an MulAddS2I usage where short vectors are going to need combined.
+ BasicType btype = velt_basic_type(s);
+ if (type2aelembytes(btype) == 2) {
+ bool should_combine_adjacent = true;
+ for (DUIterator_Fast imax, i = s->fast_outs(imax); i < imax; i++) {
+ Node* user = s->fast_out(i);
+ if (!VectorNode::is_muladds2i(user)) {
+ should_combine_adjacent = false;
+ }
+ }
+ if (should_combine_adjacent) {
+ vw = MIN2(Matcher::max_vector_size(btype)*type2aelembytes(btype), vw * 2);
+ }
+ }
+
+ return vw;
+}
//---------------------------get_iv_adjustment---------------------------
// Calculate loop's iv adjustment for this memory ops.
@@ -923,7 +970,7 @@
int offset = align_to_ref_p.offset_in_bytes();
int scale = align_to_ref_p.scale_in_bytes();
int elt_size = align_to_ref_p.memory_size();
- int vw = vector_width_in_bytes(mem_ref);
+ int vw = get_vw_bytes_special(mem_ref);
assert(vw > 1, "sanity");
int iv_adjustment;
if (scale != 0) {
@@ -2303,6 +2350,12 @@
const TypePtr* atyp = n->adr_type();
vn = StoreVectorNode::make(opc, ctl, mem, adr, atyp, val, vlen);
vlen_in_bytes = vn->as_StoreVector()->memory_size();
+ } else if (VectorNode::is_muladds2i(n)) {
+ assert(n->req() == 5u, "MulAddS2I should have 4 operands.");
+ Node* in1 = vector_opd(p, 1);
+ Node* in2 = vector_opd(p, 2);
+ vn = VectorNode::make(opc, in1, in2, vlen, velt_basic_type(n));
+ vlen_in_bytes = vn->as_Vector()->length_in_bytes();
} else if (n->req() == 3 && !is_cmov_pack(p)) {
// Promote operands to vector
Node* in1 = NULL;
@@ -2615,6 +2668,16 @@
}
assert(opd_bt == in->bottom_type()->basic_type(), "all same type");
pk->add_opd(in);
+ if (VectorNode::is_muladds2i(pi)) {
+ Node* in2 = pi->in(opd_idx + 2);
+ assert(my_pack(in2) == NULL, "Should already have been unpacked");
+ if (my_pack(in2) != NULL) {
+ NOT_PRODUCT(if (is_trace_loop_reverse() || TraceLoopOpts) { tty->print_cr("Should already have been unpacked"); })
+ return NULL;
+ }
+ assert(opd_bt == in2->bottom_type()->basic_type(), "all same type");
+ pk->add_opd(in2);
+ }
}
_igvn.register_new_node_with_optimizer(pk);
_phase->set_ctrl(pk, _phase->get_ctrl(opd));
@@ -2692,6 +2755,21 @@
}
return true;
}
+ if (VectorNode::is_muladds2i(use)) {
+ // MulAddS2I takes shorts and produces ints - hence the special checks
+ // on alignment and size.
+ if (u_pk->size() * 2 != d_pk->size()) {
+ return false;
+ }
+ for (uint i = 0; i < MIN2(d_pk->size(), u_pk->size()); i++) {
+ Node* ui = u_pk->at(i);
+ Node* di = d_pk->at(i);
+ if (alignment(ui) != alignment(di) * 2) {
+ return false;
+ }
+ }
+ return true;
+ }
if (u_pk->size() != d_pk->size())
return false;
for (uint i = 0; i < u_pk->size(); i++) {
@@ -3017,7 +3095,7 @@
NOT_PRODUCT(if(is_trace_alignment()) tty->print("SWPointer::memory_alignment: SWPointer p invalid, return bottom_align");)
return bottom_align;
}
- int vw = vector_width_in_bytes(s);
+ int vw = get_vw_bytes_special(s);
if (vw < 2) {
NOT_PRODUCT(if(is_trace_alignment()) tty->print_cr("SWPointer::memory_alignment: vector_width_in_bytes < 2, return bottom_align");)
return bottom_align; // No vectors for this type
--- a/src/hotspot/share/opto/superword.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/opto/superword.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -347,6 +347,7 @@
BasicType bt = velt_basic_type(n);
return vector_width(n)*type2aelembytes(bt);
}
+ int get_vw_bytes_special(MemNode* s);
MemNode* align_to_ref() { return _align_to_ref; }
void set_align_to_ref(MemNode* m) { _align_to_ref = m; }
--- a/src/hotspot/share/opto/vectornode.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/opto/vectornode.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -196,6 +196,8 @@
case Op_StoreF:
case Op_StoreD:
return Op_StoreVector;
+ case Op_MulAddS2I:
+ return Op_MulAddVS2VI;
default:
return 0; // Unimplemented
@@ -214,6 +216,25 @@
return false;
}
+bool VectorNode::is_type_transition_short_to_int(Node* n) {
+ switch (n->Opcode()) {
+ case Op_MulAddS2I:
+ return true;
+ }
+ return false;
+}
+
+bool VectorNode::is_type_transition_to_int(Node* n) {
+ return is_type_transition_short_to_int(n);
+}
+
+bool VectorNode::is_muladds2i(Node* n) {
+ if (n->Opcode() == Op_MulAddS2I) {
+ return true;
+ }
+ return false;
+}
+
bool VectorNode::is_shift(Node* n) {
switch (n->Opcode()) {
case Op_LShiftI:
@@ -277,6 +298,7 @@
case Op_AndI: case Op_AndL:
case Op_OrI: case Op_OrL:
case Op_XorI: case Op_XorL:
+ case Op_MulAddS2I:
*start = 1;
*end = 3; // 2 vector operands
break;
@@ -354,6 +376,8 @@
case Op_AndV: return new AndVNode(n1, n2, vt);
case Op_OrV: return new OrVNode (n1, n2, vt);
case Op_XorV: return new XorVNode(n1, n2, vt);
+
+ case Op_MulAddVS2VI: return new MulAddVS2VINode(n1, n2, vt);
default:
fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
return NULL;
--- a/src/hotspot/share/opto/vectornode.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/opto/vectornode.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -67,6 +67,9 @@
static int opcode(int opc, BasicType bt);
static bool implemented(int opc, uint vlen, BasicType bt);
static bool is_shift(Node* n);
+ static bool is_type_transition_short_to_int(Node* n);
+ static bool is_type_transition_to_int(Node* n);
+ static bool is_muladds2i(Node* n);
static bool is_invariant_vector(Node* n);
// [Start, end) half-open range defining which operands are vectors
static void vector_operands(Node* n, uint* start, uint* end);
@@ -261,6 +264,14 @@
virtual int Opcode() const;
};
+//------------------------------MulAddVS2VINode--------------------------------
+// Vector multiply shorts to int and add adjacent ints.
+class MulAddVS2VINode : public VectorNode {
+ public:
+ MulAddVS2VINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {}
+ virtual int Opcode() const;
+};
+
//------------------------------FmaVDNode--------------------------------------
// Vector multiply double
class FmaVDNode : public VectorNode {
--- a/src/hotspot/share/prims/jvmti.xml Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/prims/jvmti.xml Tue Dec 18 15:08:56 2018 -0500
@@ -13595,7 +13595,7 @@
</event>
<event label="Sampled Object Allocation"
- id="SampledObjectAlloc" const="JVMTI_EVENT_SAMPLED_OBJECT_ALLOC" num="86" since="11">
+ id="SampledObjectAlloc" const="JVMTI_EVENT_SAMPLED_OBJECT_ALLOC" filtered="thread" num="86" since="11">
<description>
Sent when an allocated object is sampled.
By default, the sampling interval is set to 512KB. The sampling is semi-random to avoid
--- a/src/hotspot/share/prims/jvmtiEventController.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/prims/jvmtiEventController.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -96,7 +96,8 @@
static const jlong INTERP_EVENT_BITS = SINGLE_STEP_BIT | METHOD_ENTRY_BIT | METHOD_EXIT_BIT |
FRAME_POP_BIT | FIELD_ACCESS_BIT | FIELD_MODIFICATION_BIT;
static const jlong THREAD_FILTERED_EVENT_BITS = INTERP_EVENT_BITS | EXCEPTION_BITS | MONITOR_BITS |
- BREAKPOINT_BIT | CLASS_LOAD_BIT | CLASS_PREPARE_BIT | THREAD_END_BIT;
+ BREAKPOINT_BIT | CLASS_LOAD_BIT | CLASS_PREPARE_BIT | THREAD_END_BIT |
+ SAMPLED_OBJECT_ALLOC_BIT;
static const jlong NEED_THREAD_LIFE_EVENTS = THREAD_FILTERED_EVENT_BITS | THREAD_START_BIT;
static const jlong EARLY_EVENT_BITS = CLASS_FILE_LOAD_HOOK_BIT | CLASS_LOAD_BIT | CLASS_PREPARE_BIT |
VM_START_BIT | VM_INIT_BIT | VM_DEATH_BIT | NATIVE_METHOD_BIND_BIT |
--- a/src/hotspot/share/prims/jvmtiExport.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/prims/jvmtiExport.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -2567,6 +2567,11 @@
}
void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) {
+ JvmtiThreadState *state = thread->jvmti_thread_state();
+ if (state == NULL) {
+ return;
+ }
+
EVT_TRIG_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
("[%s] Trg sampled object alloc triggered",
JvmtiTrace::safe_get_thread_name(thread)));
@@ -2575,14 +2580,16 @@
}
HandleMark hm(thread);
Handle h(thread, object);
- JvmtiEnvIterator it;
- for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
- if (env->is_enabled(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC)) {
+
+ JvmtiEnvThreadStateIterator it(state);
+ for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
+ if (ets->is_enabled(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC)) {
EVT_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
("[%s] Evt sampled object alloc sent %s",
JvmtiTrace::safe_get_thread_name(thread),
object == NULL ? "NULL" : object->klass()->external_name()));
+ JvmtiEnv *env = ets->get_env();
JvmtiObjectAllocEventMark jem(thread, h());
JvmtiJavaThreadEventTransition jet(thread);
jvmtiEventSampledObjectAlloc callback = env->callbacks()->SampledObjectAlloc;
--- a/src/hotspot/share/prims/unsafe.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/prims/unsafe.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -926,11 +926,12 @@
}
} UNSAFE_END
-static void post_thread_park_event(EventThreadPark* event, const oop obj, jlong timeout) {
+static void post_thread_park_event(EventThreadPark* event, const oop obj, jlong timeout_nanos, jlong until_epoch_millis) {
assert(event != NULL, "invariant");
assert(event->should_commit(), "invariant");
event->set_parkedClass((obj != NULL) ? obj->klass() : NULL);
- event->set_timeout(timeout);
+ event->set_timeout(timeout_nanos);
+ event->set_until(until_epoch_millis);
event->set_address((obj != NULL) ? (u8)cast_from_oop<uintptr_t>(obj) : 0);
event->commit();
}
@@ -942,7 +943,16 @@
JavaThreadParkedState jtps(thread, time != 0);
thread->parker()->park(isAbsolute != 0, time);
if (event.should_commit()) {
- post_thread_park_event(&event, thread->current_park_blocker(), time);
+ const oop obj = thread->current_park_blocker();
+ if (time == 0) {
+ post_thread_park_event(&event, obj, min_jlong, min_jlong);
+ } else {
+ if (isAbsolute != 0) {
+ post_thread_park_event(&event, obj, min_jlong, time);
+ } else {
+ post_thread_park_event(&event, obj, time, min_jlong);
+ }
+ }
}
HOTSPOT_THREAD_PARK_END((uintptr_t) thread->parker());
} UNSAFE_END
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -145,47 +145,42 @@
}
JVMFlag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) {
- int backward_branch_limit;
+ int64_t max_percentage_limit = INT_MAX;
+ if (!ProfileInterpreter) {
+ max_percentage_limit = (max_percentage_limit>>InvocationCounter::count_shift);
+ }
+ max_percentage_limit = CompileThreshold == 0 ? max_percentage_limit*100 : max_percentage_limit*100/CompileThreshold;
+
if (ProfileInterpreter) {
- if (OnStackReplacePercentage < InterpreterProfilePercentage) {
+ if (value < InterpreterProfilePercentage) {
JVMFlag::printError(verbose,
"OnStackReplacePercentage (" INTX_FORMAT ") must be "
"larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n",
- OnStackReplacePercentage, InterpreterProfilePercentage);
+ value, InterpreterProfilePercentage);
return JVMFlag::VIOLATES_CONSTRAINT;
}
- backward_branch_limit = ((CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100)
- << InvocationCounter::count_shift;
-
- if (backward_branch_limit < 0) {
+ max_percentage_limit += InterpreterProfilePercentage;
+ if (value > max_percentage_limit) {
JVMFlag::printError(verbose,
- "CompileThreshold * (InterpreterProfilePercentage - OnStackReplacePercentage) / 100 = "
- INTX_FORMAT " "
- "must be between 0 and %d, try changing "
- "CompileThreshold, InterpreterProfilePercentage, and/or OnStackReplacePercentage\n",
- (CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100,
- INT_MAX >> InvocationCounter::count_shift);
+ "OnStackReplacePercentage (" INTX_FORMAT ") must be between 0 and " INT64_FORMAT "\n",
+ value,
+ max_percentage_limit);
return JVMFlag::VIOLATES_CONSTRAINT;
}
} else {
- if (OnStackReplacePercentage < 0 ) {
+ if (value < 0) {
JVMFlag::printError(verbose,
"OnStackReplacePercentage (" INTX_FORMAT ") must be "
- "non-negative\n", OnStackReplacePercentage);
+ "non-negative\n", value);
return JVMFlag::VIOLATES_CONSTRAINT;
}
- backward_branch_limit = ((CompileThreshold * OnStackReplacePercentage) / 100)
- << InvocationCounter::count_shift;
-
- if (backward_branch_limit < 0) {
+ if (value > max_percentage_limit) {
JVMFlag::printError(verbose,
- "CompileThreshold * OnStackReplacePercentage / 100 = " INTX_FORMAT " "
- "must be between 0 and %d, try changing "
- "CompileThreshold and/or OnStackReplacePercentage\n",
- (CompileThreshold * OnStackReplacePercentage) / 100,
- INT_MAX >> InvocationCounter::count_shift);
+ "OnStackReplacePercentage (" INTX_FORMAT ") must be between 0 and " INT64_FORMAT "\n",
+ value,
+ max_percentage_limit);
return JVMFlag::VIOLATES_CONSTRAINT;
}
}
--- a/src/hotspot/share/runtime/globals.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/runtime/globals.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -501,6 +501,13 @@
diagnostic(bool, AbortVMOnSafepointTimeout, false, \
"Abort upon failure to reach safepoint (see SafepointTimeout)") \
\
+ diagnostic(bool, AbortVMOnVMOperationTimeout, false, \
+ "Abort upon failure to complete VM operation promptly") \
+ \
+ diagnostic(intx, AbortVMOnVMOperationTimeoutDelay, 1000, \
+ "Delay in milliseconds for option AbortVMOnVMOperationTimeout") \
+ range(0, max_intx) \
+ \
/* 50 retries * (5 * current_retry_count) millis = ~6.375 seconds */ \
/* typically, at most a few retries are needed */ \
product(intx, SuspendRetryCount, 50, \
--- a/src/hotspot/share/runtime/vmThread.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/runtime/vmThread.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -28,6 +28,7 @@
#include "jfr/jfrEvents.hpp"
#include "jfr/support/jfrThreadId.hpp"
#include "logging/log.hpp"
+#include "logging/logStream.hpp"
#include "logging/logConfiguration.hpp"
#include "memory/resourceArea.hpp"
#include "oops/method.hpp"
@@ -197,6 +198,32 @@
drain_list_oops_do(f);
}
+//------------------------------------------------------------------------------------------------------------------
+// Timeout machinery
+
+void VMOperationTimeoutTask::task() {
+ assert(AbortVMOnVMOperationTimeout, "only if enabled");
+ if (is_armed()) {
+ jlong delay = (os::javaTimeMillis() - _arm_time);
+ if (delay > AbortVMOnVMOperationTimeoutDelay) {
+ fatal("VM operation took too long: " SIZE_FORMAT " ms (timeout: " SIZE_FORMAT " ms)",
+ delay, AbortVMOnVMOperationTimeoutDelay);
+ }
+ }
+}
+
+bool VMOperationTimeoutTask::is_armed() {
+ return OrderAccess::load_acquire(&_armed) != 0;
+}
+
+void VMOperationTimeoutTask::arm() {
+ _arm_time = os::javaTimeMillis();
+ OrderAccess::release_store_fence(&_armed, 1);
+}
+
+void VMOperationTimeoutTask::disarm() {
+ OrderAccess::release_store_fence(&_armed, 0);
+}
//------------------------------------------------------------------------------------------------------------------
// Implementation of VMThread stuff
@@ -209,12 +236,28 @@
VMOperationQueue* VMThread::_vm_queue = NULL;
PerfCounter* VMThread::_perf_accumulated_vm_operation_time = NULL;
const char* VMThread::_no_op_reason = NULL;
+VMOperationTimeoutTask* VMThread::_timeout_task = NULL;
void VMThread::create() {
assert(vm_thread() == NULL, "we can only allocate one VMThread");
_vm_thread = new VMThread();
+ if (AbortVMOnVMOperationTimeout) {
+ // Make sure we call the timeout task frequently enough, but not too frequent.
+ // Try to make the interval 10% of the timeout delay, so that we miss the timeout
+ // by those 10% at max. Periodic task also expects it to fit min/max intervals.
+ size_t interval = (size_t)AbortVMOnVMOperationTimeoutDelay / 10;
+ interval = interval / PeriodicTask::interval_gran * PeriodicTask::interval_gran;
+ interval = MAX2<size_t>(interval, PeriodicTask::min_interval);
+ interval = MIN2<size_t>(interval, PeriodicTask::max_interval);
+
+ _timeout_task = new VMOperationTimeoutTask(interval);
+ _timeout_task->enroll();
+ } else {
+ assert(_timeout_task == NULL, "sanity");
+ }
+
// Create VM operation queue
_vm_queue = new VMOperationQueue();
guarantee(_vm_queue != NULL, "just checking");
@@ -492,6 +535,11 @@
_vm_queue->set_drain_list(safepoint_ops); // ensure ops can be scanned
SafepointSynchronize::begin();
+
+ if (_timeout_task != NULL) {
+ _timeout_task->arm();
+ }
+
evaluate_operation(_cur_vm_operation);
// now process all queued safepoint ops, iteratively draining
// the queue until there are none left
@@ -533,6 +581,10 @@
_vm_queue->set_drain_list(NULL);
+ if (_timeout_task != NULL) {
+ _timeout_task->disarm();
+ }
+
// Complete safepoint synchronization
SafepointSynchronize::end();
--- a/src/hotspot/share/runtime/vmThread.hpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/hotspot/share/runtime/vmThread.hpp Tue Dec 18 15:08:56 2018 -0500
@@ -27,6 +27,7 @@
#include "runtime/perfData.hpp"
#include "runtime/thread.hpp"
+#include "runtime/task.hpp"
#include "runtime/vmOperations.hpp"
//
@@ -84,6 +85,26 @@
};
+// VM operation timeout handling: warn or abort the VM when VM operation takes
+// too long. Periodic tasks do not participate in safepoint protocol, and therefore
+// can fire when application threads are stopped.
+
+class VMOperationTimeoutTask : public PeriodicTask {
+private:
+ volatile int _armed;
+ jlong _arm_time;
+
+public:
+ VMOperationTimeoutTask(size_t interval_time) :
+ PeriodicTask(interval_time), _armed(0), _arm_time(0) {}
+
+ virtual void task();
+
+ bool is_armed();
+ void arm();
+ void disarm();
+};
+
//
// A single VMThread (the primordial thread) spawns all other threads
// and is itself used by other threads to offload heavy vm operations
@@ -101,6 +122,8 @@
static const char* _no_op_reason;
+ static VMOperationTimeoutTask* _timeout_task;
+
static bool no_op_safepoint_needed(bool check_time);
void evaluate_operation(VM_Operation* op);
--- a/src/java.base/linux/native/libjava/ProcessHandleImpl_linux.c Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/linux/native/libjava/ProcessHandleImpl_linux.c Tue Dec 18 15:08:56 2018 -0500
@@ -138,13 +138,13 @@
char *args = NULL;
jstring cmdexe = NULL;
char fn[32];
- struct stat stat_buf;
+ struct stat64 stat_buf;
/*
* Stat /proc/<pid> to get the user id
*/
snprintf(fn, sizeof fn, "/proc/%d", pid);
- if (stat(fn, &stat_buf) == 0) {
+ if (stat64(fn, &stat_buf) == 0) {
unix_getUserInfo(env, jinfo, stat_buf.st_uid);
JNU_CHECK_EXCEPTION(env);
}
--- a/src/java.base/share/classes/com/sun/crypto/provider/GHASH.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/com/sun/crypto/provider/GHASH.java Tue Dec 18 15:08:56 2018 -0500
@@ -124,10 +124,10 @@
}
- /* subkeyH and state are stored in long[] for GHASH intrinsic use */
+ /* subkeyHtbl and state are stored in long[] for GHASH intrinsic use */
- // hash subkey H; should not change after the object has been constructed
- private final long[] subkeyH;
+ // hashtable subkeyHtbl; holds 2*9 powers of subkeyH computed using carry-less multiplication
+ private long[] subkeyHtbl;
// buffer for storing hash
private final long[] state;
@@ -149,9 +149,9 @@
throw new ProviderException("Internal error");
}
state = new long[2];
- this.subkeyH = new long[2];
- this.subkeyH[0] = getLong(subkeyH, 0);
- this.subkeyH[1] = getLong(subkeyH, 8);
+ subkeyHtbl = new long[2*9];
+ subkeyHtbl[0] = getLong(subkeyH, 0);
+ subkeyHtbl[1] = getLong(subkeyH, 8);
}
/**
@@ -194,8 +194,8 @@
if (inLen == 0) {
return;
}
- ghashRangeCheck(in, inOfs, inLen, state, subkeyH);
- processBlocks(in, inOfs, inLen/AES_BLOCK_SIZE, state, subkeyH);
+ ghashRangeCheck(in, inOfs, inLen, state, subkeyHtbl);
+ processBlocks(in, inOfs, inLen/AES_BLOCK_SIZE, state, subkeyHtbl);
}
private static void ghashRangeCheck(byte[] in, int inOfs, int inLen, long[] st, long[] subH) {
@@ -219,8 +219,8 @@
throw new RuntimeException("internal state has invalid length: " +
st.length);
}
- if (subH.length != 2) {
- throw new RuntimeException("internal subkeyH has invalid length: " +
+ if (subH.length != 18) {
+ throw new RuntimeException("internal subkeyHtbl has invalid length: " +
subH.length);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/com/sun/crypto/provider/HmacPKCS12PBECore.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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 com.sun.crypto.provider;
+
+import java.util.Arrays;
+
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+import java.security.*;
+import java.security.spec.*;
+
+/**
+ * This is an implementation of the HMAC algorithms as defined
+ * in PKCS#12 v1.1 standard (see RFC 7292 Appendix B.4).
+ *
+ * @author Valerie Peng
+ */
+abstract class HmacPKCS12PBECore extends HmacCore {
+
+ public static final class HmacPKCS12PBE_SHA1 extends HmacPKCS12PBECore {
+ public HmacPKCS12PBE_SHA1() throws NoSuchAlgorithmException {
+ super("SHA1", 64);
+ }
+ }
+
+ public static final class HmacPKCS12PBE_SHA224 extends HmacPKCS12PBECore {
+ public HmacPKCS12PBE_SHA224() throws NoSuchAlgorithmException {
+ super("SHA-224", 64);
+ }
+ }
+
+ public static final class HmacPKCS12PBE_SHA256 extends HmacPKCS12PBECore {
+ public HmacPKCS12PBE_SHA256() throws NoSuchAlgorithmException {
+ super("SHA-256", 64);
+ }
+ }
+
+ public static final class HmacPKCS12PBE_SHA384 extends HmacPKCS12PBECore {
+ public HmacPKCS12PBE_SHA384() throws NoSuchAlgorithmException {
+ super("SHA-384", 128);
+ }
+ }
+
+ public static final class HmacPKCS12PBE_SHA512 extends HmacPKCS12PBECore {
+ public HmacPKCS12PBE_SHA512() throws NoSuchAlgorithmException {
+ super("SHA-512", 128);
+ }
+ }
+
+ public static final class HmacPKCS12PBE_SHA512_224 extends HmacPKCS12PBECore {
+ public HmacPKCS12PBE_SHA512_224() throws NoSuchAlgorithmException {
+ super("SHA-512/224", 128);
+ }
+ }
+
+ public static final class HmacPKCS12PBE_SHA512_256 extends HmacPKCS12PBECore {
+ public HmacPKCS12PBE_SHA512_256() throws NoSuchAlgorithmException {
+ super("SHA-512/256", 128);
+ }
+ }
+
+ private final String algorithm;
+ private final int bl;
+
+ /**
+ * Standard constructor, creates a new HmacSHA1 instance.
+ */
+ public HmacPKCS12PBECore(String algorithm, int bl) throws NoSuchAlgorithmException {
+ super(algorithm, bl);
+ this.algorithm = algorithm;
+ this.bl = bl;
+ }
+
+ /**
+ * Initializes the HMAC with the given secret key and algorithm parameters.
+ *
+ * @param key the secret key.
+ * @param params the algorithm parameters.
+ *
+ * @exception InvalidKeyException if the given key is inappropriate for
+ * initializing this MAC.
+ * @exception InvalidAlgorithmParameterException if the given algorithm
+ * parameters are inappropriate for this MAC.
+ */
+ protected void engineInit(Key key, AlgorithmParameterSpec params)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+ char[] passwdChars;
+ byte[] salt = null;
+ int iCount = 0;
+ if (key instanceof javax.crypto.interfaces.PBEKey) {
+ javax.crypto.interfaces.PBEKey pbeKey =
+ (javax.crypto.interfaces.PBEKey) key;
+ passwdChars = pbeKey.getPassword();
+ salt = pbeKey.getSalt(); // maybe null if unspecified
+ iCount = pbeKey.getIterationCount(); // maybe 0 if unspecified
+ } else if (key instanceof SecretKey) {
+ byte[] passwdBytes;
+ if (!(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3)) ||
+ (passwdBytes = key.getEncoded()) == null) {
+ throw new InvalidKeyException("Missing password");
+ }
+ passwdChars = new char[passwdBytes.length];
+ for (int i=0; i<passwdChars.length; i++) {
+ passwdChars[i] = (char) (passwdBytes[i] & 0x7f);
+ }
+ Arrays.fill(passwdBytes, (byte)0x00);
+ } else {
+ throw new InvalidKeyException("SecretKey of PBE type required");
+ }
+
+ byte[] derivedKey;
+ try {
+ if (params == null) {
+ // should not auto-generate default values since current
+ // javax.crypto.Mac api does not have any method for caller to
+ // retrieve the generated defaults.
+ if ((salt == null) || (iCount == 0)) {
+ throw new InvalidAlgorithmParameterException
+ ("PBEParameterSpec required for salt and iteration count");
+ }
+ } else if (!(params instanceof PBEParameterSpec)) {
+ throw new InvalidAlgorithmParameterException
+ ("PBEParameterSpec type required");
+ } else {
+ PBEParameterSpec pbeParams = (PBEParameterSpec) params;
+ // make sure the parameter values are consistent
+ if (salt != null) {
+ if (!Arrays.equals(salt, pbeParams.getSalt())) {
+ throw new InvalidAlgorithmParameterException
+ ("Inconsistent value of salt between key and params");
+ }
+ } else {
+ salt = pbeParams.getSalt();
+ }
+ if (iCount != 0) {
+ if (iCount != pbeParams.getIterationCount()) {
+ throw new InvalidAlgorithmParameterException
+ ("Different iteration count between key and params");
+ }
+ } else {
+ iCount = pbeParams.getIterationCount();
+ }
+ }
+ // For security purpose, we need to enforce a minimum length
+ // for salt; just require the minimum salt length to be 8-byte
+ // which is what PKCS#5 recommends and openssl does.
+ if (salt.length < 8) {
+ throw new InvalidAlgorithmParameterException
+ ("Salt must be at least 8 bytes long");
+ }
+ if (iCount <= 0) {
+ throw new InvalidAlgorithmParameterException
+ ("IterationCount must be a positive number");
+ }
+ derivedKey = PKCS12PBECipherCore.derive(passwdChars, salt,
+ iCount, engineGetMacLength(), PKCS12PBECipherCore.MAC_KEY,
+ algorithm, bl);
+ } finally {
+ Arrays.fill(passwdChars, '\0');
+ }
+ SecretKey cipherKey = new SecretKeySpec(derivedKey, "HmacSHA1");
+ super.engineInit(cipherKey, null);
+ }
+}
--- a/src/java.base/share/classes/com/sun/crypto/provider/HmacPKCS12PBESHA1.java Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.crypto.provider;
-
-import java.util.Arrays;
-import java.nio.ByteBuffer;
-
-import javax.crypto.MacSpi;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-import javax.crypto.spec.PBEParameterSpec;
-import java.security.*;
-import java.security.spec.*;
-
-/**
- * This is an implementation of the HMAC-PBESHA1 algorithm as defined
- * in PKCS#12 v1.0 standard.
- *
- * @author Valerie Peng
- */
-public final class HmacPKCS12PBESHA1 extends HmacCore {
-
- /**
- * Standard constructor, creates a new HmacSHA1 instance.
- */
- public HmacPKCS12PBESHA1() throws NoSuchAlgorithmException {
- super("SHA1", 64);
- }
-
- /**
- * Initializes the HMAC with the given secret key and algorithm parameters.
- *
- * @param key the secret key.
- * @param params the algorithm parameters.
- *
- * @exception InvalidKeyException if the given key is inappropriate for
- * initializing this MAC.
- * @exception InvalidAlgorithmParameterException if the given algorithm
- * parameters are inappropriate for this MAC.
- */
- protected void engineInit(Key key, AlgorithmParameterSpec params)
- throws InvalidKeyException, InvalidAlgorithmParameterException {
- char[] passwdChars;
- byte[] salt = null;
- int iCount = 0;
- if (key instanceof javax.crypto.interfaces.PBEKey) {
- javax.crypto.interfaces.PBEKey pbeKey =
- (javax.crypto.interfaces.PBEKey) key;
- passwdChars = pbeKey.getPassword();
- salt = pbeKey.getSalt(); // maybe null if unspecified
- iCount = pbeKey.getIterationCount(); // maybe 0 if unspecified
- } else if (key instanceof SecretKey) {
- byte[] passwdBytes;
- if (!(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3)) ||
- (passwdBytes = key.getEncoded()) == null) {
- throw new InvalidKeyException("Missing password");
- }
- passwdChars = new char[passwdBytes.length];
- for (int i=0; i<passwdChars.length; i++) {
- passwdChars[i] = (char) (passwdBytes[i] & 0x7f);
- }
- Arrays.fill(passwdBytes, (byte)0x00);
- } else {
- throw new InvalidKeyException("SecretKey of PBE type required");
- }
-
- byte[] derivedKey;
- try {
- if (params == null) {
- // should not auto-generate default values since current
- // javax.crypto.Mac api does not have any method for caller to
- // retrieve the generated defaults.
- if ((salt == null) || (iCount == 0)) {
- throw new InvalidAlgorithmParameterException
- ("PBEParameterSpec required for salt and iteration count");
- }
- } else if (!(params instanceof PBEParameterSpec)) {
- throw new InvalidAlgorithmParameterException
- ("PBEParameterSpec type required");
- } else {
- PBEParameterSpec pbeParams = (PBEParameterSpec) params;
- // make sure the parameter values are consistent
- if (salt != null) {
- if (!Arrays.equals(salt, pbeParams.getSalt())) {
- throw new InvalidAlgorithmParameterException
- ("Inconsistent value of salt between key and params");
- }
- } else {
- salt = pbeParams.getSalt();
- }
- if (iCount != 0) {
- if (iCount != pbeParams.getIterationCount()) {
- throw new InvalidAlgorithmParameterException
- ("Different iteration count between key and params");
- }
- } else {
- iCount = pbeParams.getIterationCount();
- }
- }
- // For security purpose, we need to enforce a minimum length
- // for salt; just require the minimum salt length to be 8-byte
- // which is what PKCS#5 recommends and openssl does.
- if (salt.length < 8) {
- throw new InvalidAlgorithmParameterException
- ("Salt must be at least 8 bytes long");
- }
- if (iCount <= 0) {
- throw new InvalidAlgorithmParameterException
- ("IterationCount must be a positive number");
- }
- derivedKey = PKCS12PBECipherCore.derive(passwdChars, salt,
- iCount, engineGetMacLength(), PKCS12PBECipherCore.MAC_KEY);
- } finally {
- Arrays.fill(passwdChars, '\0');
- }
- SecretKey cipherKey = new SecretKeySpec(derivedKey, "HmacSHA1");
- super.engineInit(cipherKey, null);
- }
-}
--- a/src/java.base/share/classes/com/sun/crypto/provider/PBES2Parameters.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/com/sun/crypto/provider/PBES2Parameters.java Tue Dec 18 15:08:56 2018 -0500
@@ -314,41 +314,48 @@
+ "not an ASN.1 OCTET STRING tag");
}
iCount = pBKDF2_params.data.getInteger();
+
+ DerValue prf = null;
// keyLength INTEGER (1..MAX) OPTIONAL,
if (pBKDF2_params.data.available() > 0) {
DerValue keyLength = pBKDF2_params.data.getDerValue();
if (keyLength.tag == DerValue.tag_Integer) {
keysize = keyLength.getInteger() * 8; // keysize (in bits)
+ } else {
+ // Should be the prf
+ prf = keyLength;
}
}
// prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT algid-hmacWithSHA1
String kdfAlgo = "HmacSHA1";
- if (pBKDF2_params.data.available() > 0) {
- if (pBKDF2_params.tag == DerValue.tag_Sequence) {
- DerValue prf = pBKDF2_params.data.getDerValue();
- kdfAlgo_OID = prf.data.getOID();
- if (hmacWithSHA1_OID.equals(kdfAlgo_OID)) {
- kdfAlgo = "HmacSHA1";
- } else if (hmacWithSHA224_OID.equals(kdfAlgo_OID)) {
- kdfAlgo = "HmacSHA224";
- } else if (hmacWithSHA256_OID.equals(kdfAlgo_OID)) {
- kdfAlgo = "HmacSHA256";
- } else if (hmacWithSHA384_OID.equals(kdfAlgo_OID)) {
- kdfAlgo = "HmacSHA384";
- } else if (hmacWithSHA512_OID.equals(kdfAlgo_OID)) {
- kdfAlgo = "HmacSHA512";
- } else {
+ if (prf == null) {
+ if (pBKDF2_params.data.available() > 0) {
+ prf = pBKDF2_params.data.getDerValue();
+ }
+ }
+ if (prf != null) {
+ kdfAlgo_OID = prf.data.getOID();
+ if (hmacWithSHA1_OID.equals(kdfAlgo_OID)) {
+ kdfAlgo = "HmacSHA1";
+ } else if (hmacWithSHA224_OID.equals(kdfAlgo_OID)) {
+ kdfAlgo = "HmacSHA224";
+ } else if (hmacWithSHA256_OID.equals(kdfAlgo_OID)) {
+ kdfAlgo = "HmacSHA256";
+ } else if (hmacWithSHA384_OID.equals(kdfAlgo_OID)) {
+ kdfAlgo = "HmacSHA384";
+ } else if (hmacWithSHA512_OID.equals(kdfAlgo_OID)) {
+ kdfAlgo = "HmacSHA512";
+ } else {
+ throw new IOException("PBE parameter parsing error: "
+ + "expecting the object identifier for a HmacSHA key "
+ + "derivation function");
+ }
+ if (prf.data.available() != 0) {
+ // parameter is 'NULL' for all HmacSHA KDFs
+ DerValue parameter = prf.data.getDerValue();
+ if (parameter.tag != DerValue.tag_Null) {
throw new IOException("PBE parameter parsing error: "
- + "expecting the object identifier for a HmacSHA key "
- + "derivation function");
- }
- if (prf.data.available() != 0) {
- // parameter is 'NULL' for all HmacSHA KDFs
- DerValue parameter = prf.data.getDerValue();
- if (parameter.tag != DerValue.tag_Null) {
- throw new IOException("PBE parameter parsing error: "
- + "not an ASN.1 NULL tag");
- }
+ + "not an ASN.1 NULL tag");
}
}
}
--- a/src/java.base/share/classes/com/sun/crypto/provider/SunJCE.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/com/sun/crypto/provider/SunJCE.java Tue Dec 18 15:08:56 2018 -0500
@@ -28,8 +28,12 @@
import java.security.AccessController;
import java.security.Provider;
import java.security.SecureRandom;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.List;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
-
+import static sun.security.provider.SunEntries.createAliases;
+import static sun.security.provider.SunEntries.createAliasesWithOid;
/**
* The "SunJCE" Cryptographic Service Provider.
@@ -81,16 +85,6 @@
"(implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, "
+ "Diffie-Hellman, HMAC, ChaCha20)";
- private static final String OID_PKCS12_RC4_128 = "1.2.840.113549.1.12.1.1";
- private static final String OID_PKCS12_RC4_40 = "1.2.840.113549.1.12.1.2";
- private static final String OID_PKCS12_DESede = "1.2.840.113549.1.12.1.3";
- private static final String OID_PKCS12_RC2_128 = "1.2.840.113549.1.12.1.5";
- private static final String OID_PKCS12_RC2_40 = "1.2.840.113549.1.12.1.6";
- private static final String OID_PKCS5_MD5_DES = "1.2.840.113549.1.5.3";
- private static final String OID_PKCS5_PBKDF2 = "1.2.840.113549.1.5.12";
- private static final String OID_PKCS5_PBES2 = "1.2.840.113549.1.5.13";
- private static final String OID_PKCS3 = "1.2.840.113549.1.3.1";
-
/* Are we debugging? -- for developers */
static final boolean debug = false;
@@ -105,10 +99,105 @@
}
static SecureRandom getRandom() { return SecureRandomHolder.RANDOM; }
+ private void ps(String type, String algo, String cn,
+ List<String> aliases, HashMap<String, String> attrs) {
+ putService(new Provider.Service(this, type, algo, cn, aliases, attrs));
+ }
+
public SunJCE() {
/* We are the "SunJCE" provider */
super("SunJCE", PROVIDER_VER, info);
+ // if there is no security manager installed, put directly into
+ // the provider
+ if (System.getSecurityManager() == null) {
+ putEntries();
+ } else {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ @Override
+ public Void run() {
+ putEntries();
+ return null;
+ }
+ });
+ }
+ if (instance == null) {
+ instance = this;
+ }
+ }
+
+ void putEntries() {
+ // common aliases and oids
+ List<String> aesAliases = createAliases("Rijndael");
+ List<String> desEdeAliases = createAliases("TripleDES");
+ List<String> arcFourAliases = createAliases("RC4");
+ List<String> sunTlsMSAliases = createAliases(
+ "SunTls12MasterSecret", "SunTlsExtendedMasterSecret"
+ );
+ List<String> sunTlsKMAliases = createAliases("SunTls12KeyMaterial");
+ List<String> sunTlsRsaPMSAliases = createAliases("SunTls12RsaPremasterSecret");
+
+ String aes128Oid = "2.16.840.1.101.3.4.1.";
+ String aes192Oid = "2.16.840.1.101.3.4.1.2";
+ String aes256Oid = "2.16.840.1.101.3.4.1.4";
+
+ List<String> pkcs12RC4_128Aliases =
+ createAliasesWithOid("1.2.840.113549.1.12.1.1");
+
+ List<String> pkcs12RC4_40Aliases =
+ createAliasesWithOid("1.2.840.113549.1.12.1.2");
+
+ List<String> pkcs12DESedeAliases =
+ createAliasesWithOid("1.2.840.113549.1.12.1.3");
+
+ List<String> pkcs12RC2_128Aliases =
+ createAliasesWithOid("1.2.840.113549.1.12.1.5");
+
+ List<String> pkcs12RC2_40Aliases =
+ createAliasesWithOid("1.2.840.113549.1.12.1.6");
+
+ List<String> pkcs5MD5_DESAliases =
+ createAliasesWithOid("1.2.840.113549.1.5.3", "PBE");
+
+ List<String> pkcs5PBKDF2Aliases =
+ createAliasesWithOid("1.2.840.113549.1.5.12");
+
+ List<String> pkcs5PBES2Aliases =
+ createAliasesWithOid("1.2.840.113549.1.5.13");
+
+ List<String> diffieHellmanAliases =
+ createAliasesWithOid("1.2.840.113549.1.3.1", "DH");
+
+ List<String> chachaPolyAliases =
+ createAliasesWithOid("1.2.840.113549.1.9.16.3.18");
+
+ String macOidBase = "1.2.840.113549.2.";
+ List<String> macSHA1Aliases = createAliasesWithOid(macOidBase + "7");
+ List<String> macSHA224Aliases = createAliasesWithOid(macOidBase + "8");
+ List<String> macSHA256Aliases = createAliasesWithOid(macOidBase + "9");
+ List<String> macSHA384Aliases = createAliasesWithOid(macOidBase + "10");
+ List<String> macSHA512Aliases = createAliasesWithOid(macOidBase + "11");
+
+ // reuse attribute map and reset before each reuse
+ HashMap<String, String> attrs = new HashMap<>(3);
+ attrs.put("SupportedModes", "ECB");
+ attrs.put("SupportedPaddings", "NOPADDING|PKCS1PADDING|OAEPPADDING"
+ + "|OAEPWITHMD5ANDMGF1PADDING"
+ + "|OAEPWITHSHA1ANDMGF1PADDING"
+ + "|OAEPWITHSHA-1ANDMGF1PADDING"
+ + "|OAEPWITHSHA-224ANDMGF1PADDING"
+ + "|OAEPWITHSHA-256ANDMGF1PADDING"
+ + "|OAEPWITHSHA-384ANDMGF1PADDING"
+ + "|OAEPWITHSHA-512ANDMGF1PADDING"
+ + "|OAEPWITHSHA-512/224ANDMGF1PADDING"
+ + "|OAEPWITHSHA-512/256ANDMGF1PADDING");
+ attrs.put("SupportedKeyClasses",
+ "java.security.interfaces.RSAPublicKey" +
+ "|java.security.interfaces.RSAPrivateKey");
+ ps("Cipher", "RSA",
+ "com.sun.crypto.provider.RSACipher", null, attrs);
+
+ // common block cipher modes, pads
final String BLOCK_MODES = "ECB|CBC|PCBC|CTR|CTS|CFB|OFB" +
"|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64" +
"|OFB8|OFB16|OFB24|OFB32|OFB40|OFB48|OFB56|OFB64";
@@ -117,699 +206,557 @@
"|OFB72|OFB80|OFB88|OFB96|OFB104|OFB112|OFB120|OFB128";
final String BLOCK_PADS = "NOPADDING|PKCS5PADDING|ISO10126PADDING";
- AccessController.doPrivileged(
- new java.security.PrivilegedAction<Object>() {
- @Override
- public Object run() {
+ attrs.clear();
+ attrs.put("SupportedModes", BLOCK_MODES);
+ attrs.put("SupportedPaddings", BLOCK_PADS);
+ attrs.put("SupportedKeyFormats", "RAW");
+ ps("Cipher", "DES",
+ "com.sun.crypto.provider.DESCipher", null, attrs);
+ ps("Cipher", "DESede", "com.sun.crypto.provider.DESedeCipher",
+ desEdeAliases, attrs);
+ ps("Cipher", "Blowfish",
+ "com.sun.crypto.provider.BlowfishCipher", null, attrs);
- /*
- * Cipher engines
- */
- put("Cipher.RSA", "com.sun.crypto.provider.RSACipher");
- put("Cipher.RSA SupportedModes", "ECB");
- put("Cipher.RSA SupportedPaddings",
- "NOPADDING|PKCS1PADDING|OAEPPADDING"
- + "|OAEPWITHMD5ANDMGF1PADDING"
- + "|OAEPWITHSHA1ANDMGF1PADDING"
- + "|OAEPWITHSHA-1ANDMGF1PADDING"
- + "|OAEPWITHSHA-224ANDMGF1PADDING"
- + "|OAEPWITHSHA-256ANDMGF1PADDING"
- + "|OAEPWITHSHA-384ANDMGF1PADDING"
- + "|OAEPWITHSHA-512ANDMGF1PADDING"
- + "|OAEPWITHSHA-512/224ANDMGF1PADDING"
- + "|OAEPWITHSHA-512/256ANDMGF1PADDING");
- put("Cipher.RSA SupportedKeyClasses",
- "java.security.interfaces.RSAPublicKey" +
- "|java.security.interfaces.RSAPrivateKey");
+ ps("Cipher", "RC2",
+ "com.sun.crypto.provider.RC2Cipher", null, attrs);
+
+ attrs.clear();
+ attrs.put("SupportedModes", BLOCK_MODES128);
+ attrs.put("SupportedPaddings", BLOCK_PADS);
+ attrs.put("SupportedKeyFormats", "RAW");
+ ps("Cipher", "AES", "com.sun.crypto.provider.AESCipher$General",
+ aesAliases, attrs);
- put("Cipher.DES", "com.sun.crypto.provider.DESCipher");
- put("Cipher.DES SupportedModes", BLOCK_MODES);
- put("Cipher.DES SupportedPaddings", BLOCK_PADS);
- put("Cipher.DES SupportedKeyFormats", "RAW");
-
- put("Cipher.DESede", "com.sun.crypto.provider.DESedeCipher");
- put("Alg.Alias.Cipher.TripleDES", "DESede");
- put("Cipher.DESede SupportedModes", BLOCK_MODES);
- put("Cipher.DESede SupportedPaddings", BLOCK_PADS);
- put("Cipher.DESede SupportedKeyFormats", "RAW");
+ attrs.clear();
+ attrs.put("SupportedKeyFormats", "RAW");
+ ps("Cipher", "AES_128/ECB/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES128_ECB_NoPadding",
+ createAliasesWithOid(aes128Oid+"1"), attrs);
+ ps("Cipher", "AES_128/CBC/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES128_CBC_NoPadding",
+ createAliasesWithOid(aes128Oid+"2"), attrs);
+ ps("Cipher", "AES_128/OFB/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES128_OFB_NoPadding",
+ createAliasesWithOid(aes128Oid+"3"), attrs);
+ ps("Cipher", "AES_128/CFB/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES128_CFB_NoPadding",
+ createAliasesWithOid(aes128Oid+"4"), attrs);
+ ps("Cipher", "AES_128/GCM/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES128_GCM_NoPadding",
+ createAliasesWithOid(aes128Oid+"6"), attrs);
- put("Cipher.DESedeWrap",
- "com.sun.crypto.provider.DESedeWrapCipher");
- put("Cipher.DESedeWrap SupportedModes", "CBC");
- put("Cipher.DESedeWrap SupportedPaddings", "NOPADDING");
- put("Cipher.DESedeWrap SupportedKeyFormats", "RAW");
-
- // PBES1
-
- put("Cipher.PBEWithMD5AndDES",
- "com.sun.crypto.provider.PBEWithMD5AndDESCipher");
- put("Alg.Alias.Cipher.OID."+OID_PKCS5_MD5_DES,
- "PBEWithMD5AndDES");
- put("Alg.Alias.Cipher."+OID_PKCS5_MD5_DES,
- "PBEWithMD5AndDES");
+ ps("Cipher", "AES_192/ECB/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES192_ECB_NoPadding",
+ createAliasesWithOid(aes192Oid+"1"), attrs);
+ ps("Cipher", "AES_192/CBC/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES192_CBC_NoPadding",
+ createAliasesWithOid(aes192Oid+"2"), attrs);
+ ps("Cipher", "AES_192/OFB/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES192_OFB_NoPadding",
+ createAliasesWithOid(aes192Oid+"3"), attrs);
+ ps("Cipher", "AES_192/CFB/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES192_CFB_NoPadding",
+ createAliasesWithOid(aes192Oid+"4"), attrs);
+ ps("Cipher", "AES_192/GCM/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES192_GCM_NoPadding",
+ createAliasesWithOid(aes192Oid+"6"), attrs);
- put("Cipher.PBEWithMD5AndTripleDES",
- "com.sun.crypto.provider.PBEWithMD5AndTripleDESCipher");
-
- put("Cipher.PBEWithSHA1AndDESede",
- "com.sun.crypto.provider.PKCS12PBECipherCore$" +
- "PBEWithSHA1AndDESede");
- put("Alg.Alias.Cipher.OID." + OID_PKCS12_DESede,
- "PBEWithSHA1AndDESede");
- put("Alg.Alias.Cipher." + OID_PKCS12_DESede,
- "PBEWithSHA1AndDESede");
+ ps("Cipher", "AES_256/ECB/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES256_ECB_NoPadding",
+ createAliasesWithOid(aes256Oid+"1"), attrs);
+ ps("Cipher", "AES_256/CBC/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES256_CBC_NoPadding",
+ createAliasesWithOid(aes256Oid+"2"), attrs);
+ ps("Cipher", "AES_256/OFB/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES256_OFB_NoPadding",
+ createAliasesWithOid(aes256Oid+"3"), attrs);
+ ps("Cipher", "AES_256/CFB/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES256_CFB_NoPadding",
+ createAliasesWithOid(aes256Oid+"4"), attrs);
+ ps("Cipher", "AES_256/GCM/NoPadding",
+ "com.sun.crypto.provider.AESCipher$AES256_GCM_NoPadding",
+ createAliasesWithOid(aes256Oid+"6"), attrs);
- put("Cipher.PBEWithSHA1AndRC2_40",
- "com.sun.crypto.provider.PKCS12PBECipherCore$" +
- "PBEWithSHA1AndRC2_40");
- put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC2_40,
- "PBEWithSHA1AndRC2_40");
- put("Alg.Alias.Cipher." + OID_PKCS12_RC2_40,
- "PBEWithSHA1AndRC2_40");
-
- put("Cipher.PBEWithSHA1AndRC2_128",
- "com.sun.crypto.provider.PKCS12PBECipherCore$" +
- "PBEWithSHA1AndRC2_128");
- put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC2_128,
- "PBEWithSHA1AndRC2_128");
- put("Alg.Alias.Cipher." + OID_PKCS12_RC2_128,
- "PBEWithSHA1AndRC2_128");
+ attrs.clear();
+ attrs.put("SupportedModes", "CBC");
+ attrs.put("SupportedPaddings", "NOPADDING");
+ attrs.put("SupportedKeyFormats", "RAW");
+ ps("Cipher", "DESedeWrap",
+ "com.sun.crypto.provider.DESedeWrapCipher", null, attrs);
- put("Cipher.PBEWithSHA1AndRC4_40",
- "com.sun.crypto.provider.PKCS12PBECipherCore$" +
- "PBEWithSHA1AndRC4_40");
- put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC4_40,
- "PBEWithSHA1AndRC4_40");
- put("Alg.Alias.Cipher." + OID_PKCS12_RC4_40,
- "PBEWithSHA1AndRC4_40");
+ attrs.clear();
+ attrs.put("SupportedModes", "ECB");
+ attrs.put("SupportedPaddings", "NOPADDING");
+ attrs.put("SupportedKeyFormats", "RAW");
+ ps("Cipher", "ARCFOUR", "com.sun.crypto.provider.ARCFOURCipher",
+ arcFourAliases, attrs);
+ ps("Cipher", "AESWrap", "com.sun.crypto.provider.AESWrapCipher$General",
+ null, attrs);
+ ps("Cipher", "AESWrap_128",
+ "com.sun.crypto.provider.AESWrapCipher$AES128",
+ createAliasesWithOid(aes128Oid+"5"), attrs);
+ ps("Cipher", "AESWrap_192",
+ "com.sun.crypto.provider.AESWrapCipher$AES192",
+ createAliasesWithOid(aes192Oid+"5"), attrs);
+ ps("Cipher", "AESWrap_256",
+ "com.sun.crypto.provider.AESWrapCipher$AES256",
+ createAliasesWithOid(aes256Oid+"5"), attrs);
- put("Cipher.PBEWithSHA1AndRC4_128",
- "com.sun.crypto.provider.PKCS12PBECipherCore$" +
- "PBEWithSHA1AndRC4_128");
- put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC4_128,
- "PBEWithSHA1AndRC4_128");
- put("Alg.Alias.Cipher." + OID_PKCS12_RC4_128,
- "PBEWithSHA1AndRC4_128");
-
- //PBES2
+ attrs.clear();
+ attrs.put("SupportedKeyFormats", "RAW");
+ ps("Cipher", "ChaCha20",
+ "com.sun.crypto.provider.ChaCha20Cipher$ChaCha20Only",
+ null, attrs);
+ ps("Cipher", "ChaCha20-Poly1305",
+ "com.sun.crypto.provider.ChaCha20Cipher$ChaCha20Poly1305",
+ chachaPolyAliases, attrs);
- put("Cipher.PBEWithHmacSHA1AndAES_128",
- "com.sun.crypto.provider.PBES2Core$HmacSHA1AndAES_128");
-
- put("Cipher.PBEWithHmacSHA224AndAES_128",
- "com.sun.crypto.provider.PBES2Core$" +
- "HmacSHA224AndAES_128");
-
- put("Cipher.PBEWithHmacSHA256AndAES_128",
- "com.sun.crypto.provider.PBES2Core$" +
- "HmacSHA256AndAES_128");
+ // PBES1
+ ps("Cipher", "PBEWithMD5AndDES",
+ "com.sun.crypto.provider.PBEWithMD5AndDESCipher",
+ pkcs5MD5_DESAliases, null);
+ ps("Cipher", "PBEWithMD5AndTripleDES",
+ "com.sun.crypto.provider.PBEWithMD5AndTripleDESCipher",
+ null, null);
+ ps("Cipher", "PBEWithSHA1AndDESede",
+ "com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndDESede",
+ pkcs12DESedeAliases, null);
+ ps("Cipher", "PBEWithSHA1AndRC2_40",
+ "com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC2_40",
+ pkcs12RC2_40Aliases, null);
+ ps("Cipher", "PBEWithSHA1AndRC2_128",
+ "com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC2_128",
+ pkcs12RC2_128Aliases, null);
+ ps("Cipher", "PBEWithSHA1AndRC4_40",
+ "com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC4_40",
+ pkcs12RC4_40Aliases, null);
- put("Cipher.PBEWithHmacSHA384AndAES_128",
- "com.sun.crypto.provider.PBES2Core$" +
- "HmacSHA384AndAES_128");
+ ps("Cipher", "PBEWithSHA1AndRC4_128",
+ "com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC4_128",
+ pkcs12RC4_128Aliases, null);
- put("Cipher.PBEWithHmacSHA512AndAES_128",
- "com.sun.crypto.provider.PBES2Core$" +
- "HmacSHA512AndAES_128");
+ // PBES2
+ ps("Cipher", "PBEWithHmacSHA1AndAES_128",
+ "com.sun.crypto.provider.PBES2Core$HmacSHA1AndAES_128",
+ null, null);
- put("Cipher.PBEWithHmacSHA1AndAES_256",
- "com.sun.crypto.provider.PBES2Core$HmacSHA1AndAES_256");
+ ps("Cipher", "PBEWithHmacSHA224AndAES_128",
+ "com.sun.crypto.provider.PBES2Core$HmacSHA224AndAES_128",
+ null, null);
- put("Cipher.PBEWithHmacSHA224AndAES_256",
- "com.sun.crypto.provider.PBES2Core$" +
- "HmacSHA224AndAES_256");
+ ps("Cipher", "PBEWithHmacSHA256AndAES_128",
+ "com.sun.crypto.provider.PBES2Core$HmacSHA256AndAES_128",
+ null, null);
- put("Cipher.PBEWithHmacSHA256AndAES_256",
- "com.sun.crypto.provider.PBES2Core$" +
- "HmacSHA256AndAES_256");
+ ps("Cipher", "PBEWithHmacSHA384AndAES_128",
+ "com.sun.crypto.provider.PBES2Core$HmacSHA384AndAES_128",
+ null, null);
- put("Cipher.PBEWithHmacSHA384AndAES_256",
- "com.sun.crypto.provider.PBES2Core$" +
- "HmacSHA384AndAES_256");
+ ps("Cipher", "PBEWithHmacSHA512AndAES_128",
+ "com.sun.crypto.provider.PBES2Core$HmacSHA512AndAES_128",
+ null, null);
- put("Cipher.PBEWithHmacSHA512AndAES_256",
- "com.sun.crypto.provider.PBES2Core$" +
- "HmacSHA512AndAES_256");
+ ps("Cipher", "PBEWithHmacSHA1AndAES_256",
+ "com.sun.crypto.provider.PBES2Core$HmacSHA1AndAES_256",
+ null, null);
+
+ ps("Cipher", "PBEWithHmacSHA224AndAES_256",
+ "com.sun.crypto.provider.PBES2Core$HmacSHA224AndAES_256",
+ null, null);
- put("Cipher.Blowfish",
- "com.sun.crypto.provider.BlowfishCipher");
- put("Cipher.Blowfish SupportedModes", BLOCK_MODES);
- put("Cipher.Blowfish SupportedPaddings", BLOCK_PADS);
- put("Cipher.Blowfish SupportedKeyFormats", "RAW");
+ ps("Cipher", "PBEWithHmacSHA256AndAES_256",
+ "com.sun.crypto.provider.PBES2Core$HmacSHA256AndAES_256",
+ null, null);
- put("Cipher.AES", "com.sun.crypto.provider.AESCipher$General");
- put("Alg.Alias.Cipher.Rijndael", "AES");
- put("Cipher.AES SupportedModes", BLOCK_MODES128);
- put("Cipher.AES SupportedPaddings", BLOCK_PADS);
- put("Cipher.AES SupportedKeyFormats", "RAW");
+ ps("Cipher", "PBEWithHmacSHA384AndAES_256",
+ "com.sun.crypto.provider.PBES2Core$HmacSHA384AndAES_256",
+ null, null);
+
+ ps("Cipher", "PBEWithHmacSHA512AndAES_256",
+ "com.sun.crypto.provider.PBES2Core$HmacSHA512AndAES_256",
+ null, null);
- put("Cipher.AES_128/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_ECB_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.1", "AES_128/ECB/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.1", "AES_128/ECB/NoPadding");
- put("Cipher.AES_128/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_CBC_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.2", "AES_128/CBC/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.2", "AES_128/CBC/NoPadding");
- put("Cipher.AES_128/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_OFB_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.3", "AES_128/OFB/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.3", "AES_128/OFB/NoPadding");
- put("Cipher.AES_128/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_CFB_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.4", "AES_128/CFB/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.4", "AES_128/CFB/NoPadding");
- put("Cipher.AES_128/GCM/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_GCM_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.6", "AES_128/GCM/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.6", "AES_128/GCM/NoPadding");
-
- put("Cipher.AES_192/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_ECB_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.21", "AES_192/ECB/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.21", "AES_192/ECB/NoPadding");
- put("Cipher.AES_192/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_CBC_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.22", "AES_192/CBC/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.22", "AES_192/CBC/NoPadding");
- put("Cipher.AES_192/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_OFB_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.23", "AES_192/OFB/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.23", "AES_192/OFB/NoPadding");
- put("Cipher.AES_192/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_CFB_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.24", "AES_192/CFB/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.24", "AES_192/CFB/NoPadding");
- put("Cipher.AES_192/GCM/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_GCM_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.26", "AES_192/GCM/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.26", "AES_192/GCM/NoPadding");
+ /*
+ * Key(pair) Generator engines
+ */
+ ps("KeyGenerator", "DES",
+ "com.sun.crypto.provider.DESKeyGenerator",
+ null, null);
+ ps("KeyGenerator", "DESede",
+ "com.sun.crypto.provider.DESedeKeyGenerator",
+ desEdeAliases, null);
+ ps("KeyGenerator", "Blowfish",
+ "com.sun.crypto.provider.BlowfishKeyGenerator",
+ null, null);
+ ps("KeyGenerator", "AES",
+ "com.sun.crypto.provider.AESKeyGenerator",
+ aesAliases, null);
+ ps("KeyGenerator", "RC2",
+ "com.sun.crypto.provider.KeyGeneratorCore$RC2KeyGenerator",
+ null, null);
+ ps("KeyGenerator", "ARCFOUR",
+ "com.sun.crypto.provider.KeyGeneratorCore$ARCFOURKeyGenerator",
+ arcFourAliases, null);
+ ps("KeyGenerator", "ChaCha20",
+ "com.sun.crypto.provider.KeyGeneratorCore$ChaCha20KeyGenerator",
+ null, null);
+ ps("KeyGenerator", "HmacMD5",
+ "com.sun.crypto.provider.HmacMD5KeyGenerator",
+ null, null);
- put("Cipher.AES_256/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_ECB_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.41", "AES_256/ECB/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.41", "AES_256/ECB/NoPadding");
- put("Cipher.AES_256/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_CBC_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.42", "AES_256/CBC/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.42", "AES_256/CBC/NoPadding");
- put("Cipher.AES_256/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_OFB_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.43", "AES_256/OFB/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.43", "AES_256/OFB/NoPadding");
- put("Cipher.AES_256/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_CFB_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.44", "AES_256/CFB/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.44", "AES_256/CFB/NoPadding");
- put("Cipher.AES_256/GCM/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_GCM_NoPadding");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.46", "AES_256/GCM/NoPadding");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.46", "AES_256/GCM/NoPadding");
+ ps("KeyGenerator", "HmacSHA1",
+ "com.sun.crypto.provider.HmacSHA1KeyGenerator",
+ macSHA1Aliases, null);
+ ps("KeyGenerator", "HmacSHA224",
+ "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA224",
+ macSHA224Aliases, null);
+ ps("KeyGenerator", "HmacSHA256",
+ "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA256",
+ macSHA256Aliases, null);
+ ps("KeyGenerator", "HmacSHA384",
+ "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA384",
+ macSHA384Aliases, null);
+ ps("KeyGenerator", "HmacSHA512",
+ "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA512",
+ macSHA512Aliases, null);
+
+ ps("KeyPairGenerator", "DiffieHellman",
+ "com.sun.crypto.provider.DHKeyPairGenerator",
+ diffieHellmanAliases, null);
- put("Cipher.AESWrap", "com.sun.crypto.provider.AESWrapCipher$General");
- put("Cipher.AESWrap SupportedModes", "ECB");
- put("Cipher.AESWrap SupportedPaddings", "NOPADDING");
- put("Cipher.AESWrap SupportedKeyFormats", "RAW");
+ /*
+ * Algorithm parameter generation engines
+ */
+ ps("AlgorithmParameterGenerator",
+ "DiffieHellman", "com.sun.crypto.provider.DHParameterGenerator",
+ diffieHellmanAliases, null);
- put("Cipher.AESWrap_128", "com.sun.crypto.provider.AESWrapCipher$AES128");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.5", "AESWrap_128");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.5", "AESWrap_128");
- put("Cipher.AESWrap_192", "com.sun.crypto.provider.AESWrapCipher$AES192");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.25", "AESWrap_192");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.25", "AESWrap_192");
- put("Cipher.AESWrap_256", "com.sun.crypto.provider.AESWrapCipher$AES256");
- put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.45", "AESWrap_256");
- put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.45", "AESWrap_256");
+ /*
+ * Key Agreement engines
+ */
+ attrs.clear();
+ attrs.put("SupportedKeyClasses", "javax.crypto.interfaces.DHPublicKey" +
+ "|javax.crypto.interfaces.DHPrivateKey");
+ ps("KeyAgreement", "DiffieHellman",
+ "com.sun.crypto.provider.DHKeyAgreement",
+ diffieHellmanAliases, attrs);
- put("Cipher.RC2",
- "com.sun.crypto.provider.RC2Cipher");
- put("Cipher.RC2 SupportedModes", BLOCK_MODES);
- put("Cipher.RC2 SupportedPaddings", BLOCK_PADS);
- put("Cipher.RC2 SupportedKeyFormats", "RAW");
+ /*
+ * Algorithm Parameter engines
+ */
+ ps("AlgorithmParameters", "DiffieHellman",
+ "com.sun.crypto.provider.DHParameters",
+ diffieHellmanAliases, null);
+
+ ps("AlgorithmParameters", "DES",
+ "com.sun.crypto.provider.DESParameters",
+ null, null);
+
+ ps("AlgorithmParameters", "DESede",
+ "com.sun.crypto.provider.DESedeParameters",
+ desEdeAliases, null);
- put("Cipher.ARCFOUR",
- "com.sun.crypto.provider.ARCFOURCipher");
- put("Alg.Alias.Cipher.RC4", "ARCFOUR");
- put("Cipher.ARCFOUR SupportedModes", "ECB");
- put("Cipher.ARCFOUR SupportedPaddings", "NOPADDING");
- put("Cipher.ARCFOUR SupportedKeyFormats", "RAW");
+ ps("AlgorithmParameters", "PBEWithMD5AndDES",
+ "com.sun.crypto.provider.PBEParameters",
+ pkcs5MD5_DESAliases, null);
+
+ ps("AlgorithmParameters", "PBEWithMD5AndTripleDES",
+ "com.sun.crypto.provider.PBEParameters",
+ null, null);
+
+ ps("AlgorithmParameters", "PBEWithSHA1AndDESede",
+ "com.sun.crypto.provider.PBEParameters",
+ pkcs12DESedeAliases, null);
- put("Cipher.ChaCha20",
- "com.sun.crypto.provider.ChaCha20Cipher$ChaCha20Only");
- put("Cipher.ChaCha20 SupportedKeyFormats", "RAW");
- put("Cipher.ChaCha20-Poly1305",
- "com.sun.crypto.provider.ChaCha20Cipher$ChaCha20Poly1305");
- put("Cipher.ChaCha20-Poly1305 SupportedKeyFormats", "RAW");
- put("Alg.Alias.Cipher.1.2.840.113549.1.9.16.3.18", "ChaCha20-Poly1305");
- put("Alg.Alias.Cipher.OID.1.2.840.113549.1.9.16.3.18", "ChaCha20-Poly1305");
+ ps("AlgorithmParameters", "PBEWithSHA1AndRC2_40",
+ "com.sun.crypto.provider.PBEParameters",
+ pkcs12RC2_40Aliases, null);
+
+ ps("AlgorithmParameters", "PBEWithSHA1AndRC2_128",
+ "com.sun.crypto.provider.PBEParameters",
+ pkcs12RC2_128Aliases, null);
- /*
- * Key(pair) Generator engines
- */
- put("KeyGenerator.DES",
- "com.sun.crypto.provider.DESKeyGenerator");
+ ps("AlgorithmParameters", "PBEWithSHA1AndRC4_40",
+ "com.sun.crypto.provider.PBEParameters",
+ pkcs12RC4_40Aliases, null);
- put("KeyGenerator.DESede",
- "com.sun.crypto.provider.DESedeKeyGenerator");
- put("Alg.Alias.KeyGenerator.TripleDES", "DESede");
+ ps("AlgorithmParameters", "PBEWithSHA1AndRC4_128",
+ "com.sun.crypto.provider.PBEParameters",
+ pkcs12RC4_128Aliases, null);
- put("KeyGenerator.Blowfish",
- "com.sun.crypto.provider.BlowfishKeyGenerator");
+ ps("AlgorithmParameters", "PBES2",
+ "com.sun.crypto.provider.PBES2Parameters$General",
+ pkcs5PBES2Aliases, null);
- put("KeyGenerator.AES",
- "com.sun.crypto.provider.AESKeyGenerator");
- put("Alg.Alias.KeyGenerator.Rijndael", "AES");
+ ps("AlgorithmParameters", "PBEWithHmacSHA1AndAES_128",
+ "com.sun.crypto.provider.PBES2Parameters$HmacSHA1AndAES_128",
+ null, null);
+
+ ps("AlgorithmParameters", "PBEWithHmacSHA224AndAES_128",
+ "com.sun.crypto.provider.PBES2Parameters$HmacSHA224AndAES_128",
+ null, null);
- put("KeyGenerator.RC2",
- "com.sun.crypto.provider.KeyGeneratorCore$" +
- "RC2KeyGenerator");
- put("KeyGenerator.ARCFOUR",
- "com.sun.crypto.provider.KeyGeneratorCore$" +
- "ARCFOURKeyGenerator");
- put("Alg.Alias.KeyGenerator.RC4", "ARCFOUR");
+ ps("AlgorithmParameters", "PBEWithHmacSHA256AndAES_128",
+ "com.sun.crypto.provider.PBES2Parameters$HmacSHA256AndAES_128",
+ null, null);
+
+ ps("AlgorithmParameters", "PBEWithHmacSHA384AndAES_128",
+ "com.sun.crypto.provider.PBES2Parameters$HmacSHA384AndAES_128",
+ null, null);
- put("KeyGenerator.ChaCha20",
- "com.sun.crypto.provider.KeyGeneratorCore$" +
- "ChaCha20KeyGenerator");
+ ps("AlgorithmParameters", "PBEWithHmacSHA512AndAES_128",
+ "com.sun.crypto.provider.PBES2Parameters$HmacSHA512AndAES_128",
+ null, null);
- put("KeyGenerator.HmacMD5",
- "com.sun.crypto.provider.HmacMD5KeyGenerator");
-
- put("KeyGenerator.HmacSHA1",
- "com.sun.crypto.provider.HmacSHA1KeyGenerator");
- put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.7", "HmacSHA1");
- put("Alg.Alias.KeyGenerator.1.2.840.113549.2.7", "HmacSHA1");
+ ps("AlgorithmParameters", "PBEWithHmacSHA1AndAES_256",
+ "com.sun.crypto.provider.PBES2Parameters$HmacSHA1AndAES_256",
+ null, null);
- put("KeyGenerator.HmacSHA224",
- "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA224");
- put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.8", "HmacSHA224");
- put("Alg.Alias.KeyGenerator.1.2.840.113549.2.8", "HmacSHA224");
+ ps("AlgorithmParameters", "PBEWithHmacSHA224AndAES_256",
+ "com.sun.crypto.provider.PBES2Parameters$HmacSHA224AndAES_256",
+ null, null);
- put("KeyGenerator.HmacSHA256",
- "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA256");
- put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.9", "HmacSHA256");
- put("Alg.Alias.KeyGenerator.1.2.840.113549.2.9", "HmacSHA256");
+ ps("AlgorithmParameters", "PBEWithHmacSHA256AndAES_256",
+ "com.sun.crypto.provider.PBES2Parameters$HmacSHA256AndAES_256",
+ null, null);
+
+ ps("AlgorithmParameters", "PBEWithHmacSHA384AndAES_256",
+ "com.sun.crypto.provider.PBES2Parameters$HmacSHA384AndAES_256",
+ null, null);
- put("KeyGenerator.HmacSHA384",
- "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA384");
- put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.10", "HmacSHA384");
- put("Alg.Alias.KeyGenerator.1.2.840.113549.2.10", "HmacSHA384");
+ ps("AlgorithmParameters", "PBEWithHmacSHA512AndAES_256",
+ "com.sun.crypto.provider.PBES2Parameters$HmacSHA512AndAES_256",
+ null, null);
+
+ ps("AlgorithmParameters", "Blowfish",
+ "com.sun.crypto.provider.BlowfishParameters",
+ null, null);
- put("KeyGenerator.HmacSHA512",
- "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA512");
- put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.11", "HmacSHA512");
- put("Alg.Alias.KeyGenerator.1.2.840.113549.2.11", "HmacSHA512");
+ ps("AlgorithmParameters", "AES",
+ "com.sun.crypto.provider.AESParameters",
+ aesAliases, null);
+
+ ps("AlgorithmParameters", "GCM",
+ "com.sun.crypto.provider.GCMParameters",
+ null, null);
- put("KeyPairGenerator.DiffieHellman",
- "com.sun.crypto.provider.DHKeyPairGenerator");
- put("Alg.Alias.KeyPairGenerator.DH", "DiffieHellman");
- put("Alg.Alias.KeyPairGenerator.OID."+OID_PKCS3,
- "DiffieHellman");
- put("Alg.Alias.KeyPairGenerator."+OID_PKCS3,
- "DiffieHellman");
+ ps("AlgorithmParameters", "RC2",
+ "com.sun.crypto.provider.RC2Parameters",
+ null, null);
+
+ ps("AlgorithmParameters", "OAEP",
+ "com.sun.crypto.provider.OAEPParameters",
+ null, null);
+
+ ps("AlgorithmParameters", "ChaCha20-Poly1305",
+ "com.sun.crypto.provider.ChaCha20Poly1305Parameters",
+ chachaPolyAliases, null);
- /*
- * Algorithm parameter generation engines
- */
- put("AlgorithmParameterGenerator.DiffieHellman",
- "com.sun.crypto.provider.DHParameterGenerator");
- put("Alg.Alias.AlgorithmParameterGenerator.DH",
- "DiffieHellman");
- put("Alg.Alias.AlgorithmParameterGenerator.OID."+OID_PKCS3,
- "DiffieHellman");
- put("Alg.Alias.AlgorithmParameterGenerator."+OID_PKCS3,
- "DiffieHellman");
+ /*
+ * Key factories
+ */
+ ps("KeyFactory", "DiffieHellman",
+ "com.sun.crypto.provider.DHKeyFactory",
+ diffieHellmanAliases, null);
- /*
- * Key Agreement engines
- */
- put("KeyAgreement.DiffieHellman",
- "com.sun.crypto.provider.DHKeyAgreement");
- put("Alg.Alias.KeyAgreement.DH", "DiffieHellman");
- put("Alg.Alias.KeyAgreement.OID."+OID_PKCS3, "DiffieHellman");
- put("Alg.Alias.KeyAgreement."+OID_PKCS3, "DiffieHellman");
+ /*
+ * Secret-key factories
+ */
+ ps("SecretKeyFactory", "DES",
+ "com.sun.crypto.provider.DESKeyFactory",
+ null, null);
- put("KeyAgreement.DiffieHellman SupportedKeyClasses",
- "javax.crypto.interfaces.DHPublicKey" +
- "|javax.crypto.interfaces.DHPrivateKey");
+ ps("SecretKeyFactory", "DESede",
+ "com.sun.crypto.provider.DESedeKeyFactory",
+ desEdeAliases, null);
+
+ ps("SecretKeyFactory", "PBEWithMD5AndDES",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithMD5AndDES",
+ pkcs5MD5_DESAliases, null);
- /*
- * Algorithm Parameter engines
- */
- put("AlgorithmParameters.DiffieHellman",
- "com.sun.crypto.provider.DHParameters");
- put("Alg.Alias.AlgorithmParameters.DH", "DiffieHellman");
- put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS3,
- "DiffieHellman");
- put("Alg.Alias.AlgorithmParameters."+OID_PKCS3,
- "DiffieHellman");
+ /*
+ * Internal in-house crypto algorithm used for
+ * the JCEKS keystore type. Since this was developed
+ * internally, there isn't an OID corresponding to this
+ * algorithm.
+ */
+ ps("SecretKeyFactory", "PBEWithMD5AndTripleDES",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithMD5AndTripleDES",
+ null, null);
+
+ ps("SecretKeyFactory", "PBEWithSHA1AndDESede",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndDESede",
+ pkcs12DESedeAliases, null);
- put("AlgorithmParameters.DES",
- "com.sun.crypto.provider.DESParameters");
+ ps("SecretKeyFactory", "PBEWithSHA1AndRC2_40",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_40",
+ pkcs12RC2_40Aliases, null);
+
+ ps("SecretKeyFactory", "PBEWithSHA1AndRC2_128",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_128",
+ pkcs12RC2_128Aliases, null);
- put("AlgorithmParameters.DESede",
- "com.sun.crypto.provider.DESedeParameters");
- put("Alg.Alias.AlgorithmParameters.TripleDES", "DESede");
+ ps("SecretKeyFactory", "PBEWithSHA1AndRC4_40",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC4_40",
+ pkcs12RC4_40Aliases,null);
- put("AlgorithmParameters.PBE",
- "com.sun.crypto.provider.PBEParameters");
+ ps("SecretKeyFactory", "PBEWithSHA1AndRC4_128",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC4_128",
+ pkcs12RC4_128Aliases, null);
- put("AlgorithmParameters.PBEWithMD5AndDES",
- "com.sun.crypto.provider.PBEParameters");
- put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS5_MD5_DES,
- "PBEWithMD5AndDES");
- put("Alg.Alias.AlgorithmParameters."+OID_PKCS5_MD5_DES,
- "PBEWithMD5AndDES");
+ ps("SecretKeyFactory", "PBEWithHmacSHA1AndAES_128",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA1AndAES_128",
+ null, null);
+
+ ps("SecretKeyFactory", "PBEWithHmacSHA224AndAES_128",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA224AndAES_128",
+ null, null);
- put("AlgorithmParameters.PBEWithMD5AndTripleDES",
- "com.sun.crypto.provider.PBEParameters");
+ ps("SecretKeyFactory", "PBEWithHmacSHA256AndAES_128",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA256AndAES_128",
+ null, null);
+
+ ps("SecretKeyFactory", "PBEWithHmacSHA384AndAES_128",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA384AndAES_128",
+ null, null);
- put("AlgorithmParameters.PBEWithSHA1AndDESede",
- "com.sun.crypto.provider.PBEParameters");
- put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_DESede,
- "PBEWithSHA1AndDESede");
- put("Alg.Alias.AlgorithmParameters."+OID_PKCS12_DESede,
- "PBEWithSHA1AndDESede");
+ ps("SecretKeyFactory", "PBEWithHmacSHA512AndAES_128",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA512AndAES_128",
+ null, null);
+
+ ps("SecretKeyFactory", "PBEWithHmacSHA1AndAES_256",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA1AndAES_256",
+ null, null);
- put("AlgorithmParameters.PBEWithSHA1AndRC2_40",
- "com.sun.crypto.provider.PBEParameters");
- put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC2_40,
- "PBEWithSHA1AndRC2_40");
- put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC2_40,
- "PBEWithSHA1AndRC2_40");
+ ps("SecretKeyFactory", "PBEWithHmacSHA224AndAES_256",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA224AndAES_256",
+ null, null);
- put("AlgorithmParameters.PBEWithSHA1AndRC2_128",
- "com.sun.crypto.provider.PBEParameters");
- put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC2_128,
- "PBEWithSHA1AndRC2_128");
- put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC2_128,
- "PBEWithSHA1AndRC2_128");
+ ps("SecretKeyFactory", "PBEWithHmacSHA256AndAES_256",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA256AndAES_256",
+ null, null);
+
+ ps("SecretKeyFactory", "PBEWithHmacSHA384AndAES_256",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA384AndAES_256",
+ null, null);
- put("AlgorithmParameters.PBEWithSHA1AndRC4_40",
- "com.sun.crypto.provider.PBEParameters");
- put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC4_40,
- "PBEWithSHA1AndRC4_40");
- put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC4_40,
- "PBEWithSHA1AndRC4_40");
-
- put("AlgorithmParameters.PBEWithSHA1AndRC4_128",
- "com.sun.crypto.provider.PBEParameters");
- put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC4_128,
- "PBEWithSHA1AndRC4_128");
- put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC4_128,
- "PBEWithSHA1AndRC4_128");
+ ps("SecretKeyFactory", "PBEWithHmacSHA512AndAES_256",
+ "com.sun.crypto.provider.PBEKeyFactory$PBEWithHmacSHA512AndAES_256",
+ null, null);
- put("AlgorithmParameters.PBES2",
- "com.sun.crypto.provider.PBES2Parameters$General");
- put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS5_PBES2,
- "PBES2");
- put("Alg.Alias.AlgorithmParameters." + OID_PKCS5_PBES2,
- "PBES2");
-
- put("AlgorithmParameters.PBEWithHmacSHA1AndAES_128",
- "com.sun.crypto.provider.PBES2Parameters$HmacSHA1AndAES_128");
-
- put("AlgorithmParameters.PBEWithHmacSHA224AndAES_128",
- "com.sun.crypto.provider.PBES2Parameters$HmacSHA224AndAES_128");
-
- put("AlgorithmParameters.PBEWithHmacSHA256AndAES_128",
- "com.sun.crypto.provider.PBES2Parameters$HmacSHA256AndAES_128");
+ // PBKDF2
+ ps("SecretKeyFactory", "PBKDF2WithHmacSHA1",
+ "com.sun.crypto.provider.PBKDF2Core$HmacSHA1",
+ pkcs5PBKDF2Aliases, null);
+ ps("SecretKeyFactory", "PBKDF2WithHmacSHA224",
+ "com.sun.crypto.provider.PBKDF2Core$HmacSHA224",
+ null, null);
+ ps("SecretKeyFactory", "PBKDF2WithHmacSHA256",
+ "com.sun.crypto.provider.PBKDF2Core$HmacSHA256",
+ null, null);
+ ps("SecretKeyFactory", "PBKDF2WithHmacSHA384",
+ "com.sun.crypto.provider.PBKDF2Core$HmacSHA384",
+ null, null);
+ ps("SecretKeyFactory", "PBKDF2WithHmacSHA512",
+ "com.sun.crypto.provider.PBKDF2Core$HmacSHA512",
+ null, null);
- put("AlgorithmParameters.PBEWithHmacSHA384AndAES_128",
- "com.sun.crypto.provider.PBES2Parameters$HmacSHA384AndAES_128");
-
- put("AlgorithmParameters.PBEWithHmacSHA512AndAES_128",
- "com.sun.crypto.provider.PBES2Parameters$HmacSHA512AndAES_128");
-
- put("AlgorithmParameters.PBEWithHmacSHA1AndAES_256",
- "com.sun.crypto.provider.PBES2Parameters$HmacSHA1AndAES_256");
-
- put("AlgorithmParameters.PBEWithHmacSHA224AndAES_256",
- "com.sun.crypto.provider.PBES2Parameters$HmacSHA224AndAES_256");
-
- put("AlgorithmParameters.PBEWithHmacSHA256AndAES_256",
- "com.sun.crypto.provider.PBES2Parameters$HmacSHA256AndAES_256");
-
- put("AlgorithmParameters.PBEWithHmacSHA384AndAES_256",
- "com.sun.crypto.provider.PBES2Parameters$HmacSHA384AndAES_256");
-
- put("AlgorithmParameters.PBEWithHmacSHA512AndAES_256",
- "com.sun.crypto.provider.PBES2Parameters$HmacSHA512AndAES_256");
-
- put("AlgorithmParameters.Blowfish",
- "com.sun.crypto.provider.BlowfishParameters");
-
- put("AlgorithmParameters.AES",
- "com.sun.crypto.provider.AESParameters");
- put("Alg.Alias.AlgorithmParameters.Rijndael", "AES");
- put("AlgorithmParameters.GCM",
- "com.sun.crypto.provider.GCMParameters");
+ /*
+ * MAC
+ */
+ attrs.clear();
+ attrs.put("SupportedKeyFormats", "RAW");
+ ps("Mac", "HmacMD5", "com.sun.crypto.provider.HmacMD5", null, attrs);
+ ps("Mac", "HmacSHA1", "com.sun.crypto.provider.HmacSHA1",
+ macSHA1Aliases, attrs);
+ ps("Mac", "HmacSHA224", "com.sun.crypto.provider.HmacCore$HmacSHA224",
+ macSHA224Aliases, attrs);
+ ps("Mac", "HmacSHA256", "com.sun.crypto.provider.HmacCore$HmacSHA256",
+ macSHA256Aliases, attrs);
+ ps("Mac", "HmacSHA384", "com.sun.crypto.provider.HmacCore$HmacSHA384",
+ macSHA384Aliases, attrs);
+ ps("Mac", "HmacSHA512", "com.sun.crypto.provider.HmacCore$HmacSHA512",
+ macSHA512Aliases, attrs);
+ // TODO: aliases with OIDs
+ ps("Mac", "HmacSHA512/224",
+ "com.sun.crypto.provider.HmacCore$HmacSHA512_224",
+ null, attrs);
+ ps("Mac", "HmacSHA512/256",
+ "com.sun.crypto.provider.HmacCore$HmacSHA512_256",
+ null, attrs);
+ ps("Mac", "HmacPBESHA1",
+ "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA1",
+ null, attrs);
+ ps("Mac", "HmacPBESHA224",
+ "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA224",
+ null, attrs);
+ ps("Mac", "HmacPBESHA256",
+ "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA256",
+ null, attrs);
+ ps("Mac", "HmacPBESHA384",
+ "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA384",
+ null, attrs);
+ ps("Mac", "HmacPBESHA512",
+ "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA512",
+ null, attrs);
+ ps("Mac", "HmacPBESHA512/224",
+ "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA512_224",
+ null, attrs);
+ ps("Mac", "HmacPBESHA512/256",
+ "com.sun.crypto.provider.HmacPKCS12PBECore$HmacPKCS12PBE_SHA512_256",
+ null, attrs);
- put("AlgorithmParameters.RC2",
- "com.sun.crypto.provider.RC2Parameters");
-
- put("AlgorithmParameters.OAEP",
- "com.sun.crypto.provider.OAEPParameters");
-
- put("AlgorithmParameters.ChaCha20-Poly1305",
- "com.sun.crypto.provider.ChaCha20Poly1305Parameters");
-
- /*
- * Key factories
- */
- put("KeyFactory.DiffieHellman",
- "com.sun.crypto.provider.DHKeyFactory");
- put("Alg.Alias.KeyFactory.DH", "DiffieHellman");
- put("Alg.Alias.KeyFactory.OID."+OID_PKCS3,
- "DiffieHellman");
- put("Alg.Alias.KeyFactory."+OID_PKCS3, "DiffieHellman");
-
- /*
- * Secret-key factories
- */
- put("SecretKeyFactory.DES",
- "com.sun.crypto.provider.DESKeyFactory");
-
- put("SecretKeyFactory.DESede",
- "com.sun.crypto.provider.DESedeKeyFactory");
- put("Alg.Alias.SecretKeyFactory.TripleDES", "DESede");
-
- put("SecretKeyFactory.PBEWithMD5AndDES",
- "com.sun.crypto.provider.PBEKeyFactory$PBEWithMD5AndDES"
- );
- put("Alg.Alias.SecretKeyFactory.OID."+OID_PKCS5_MD5_DES,
- "PBEWithMD5AndDES");
- put("Alg.Alias.SecretKeyFactory."+OID_PKCS5_MD5_DES,
- "PBEWithMD5AndDES");
-
- put("Alg.Alias.SecretKeyFactory.PBE",
- "PBEWithMD5AndDES");
-
- /*
- * Internal in-house crypto algorithm used for
- * the JCEKS keystore type. Since this was developed
- * internally, there isn't an OID corresponding to this
- * algorithm.
- */
- put("SecretKeyFactory.PBEWithMD5AndTripleDES",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithMD5AndTripleDES"
- );
-
- put("SecretKeyFactory.PBEWithSHA1AndDESede",
- "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndDESede"
- );
- put("Alg.Alias.SecretKeyFactory.OID."+OID_PKCS12_DESede,
- "PBEWithSHA1AndDESede");
- put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_DESede,
- "PBEWithSHA1AndDESede");
+ // PBMAC1
+ ps("Mac", "PBEWithHmacSHA1",
+ "com.sun.crypto.provider.PBMAC1Core$HmacSHA1", null, attrs);
+ ps("Mac", "PBEWithHmacSHA224",
+ "com.sun.crypto.provider.PBMAC1Core$HmacSHA224", null, attrs);
+ ps("Mac", "PBEWithHmacSHA256",
+ "com.sun.crypto.provider.PBMAC1Core$HmacSHA256", null, attrs);
+ ps("Mac", "PBEWithHmacSHA384",
+ "com.sun.crypto.provider.PBMAC1Core$HmacSHA384", null, attrs);
+ ps("Mac", "PBEWithHmacSHA512",
+ "com.sun.crypto.provider.PBMAC1Core$HmacSHA512", null, attrs);
+ ps("Mac", "SslMacMD5",
+ "com.sun.crypto.provider.SslMacCore$SslMacMD5", null, attrs);
+ ps("Mac", "SslMacSHA1",
+ "com.sun.crypto.provider.SslMacCore$SslMacSHA1", null, attrs);
- put("SecretKeyFactory.PBEWithSHA1AndRC2_40",
- "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_40"
- );
- put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC2_40,
- "PBEWithSHA1AndRC2_40");
- put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC2_40,
- "PBEWithSHA1AndRC2_40");
-
- put("SecretKeyFactory.PBEWithSHA1AndRC2_128",
- "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_128"
- );
- put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC2_128,
- "PBEWithSHA1AndRC2_128");
- put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC2_128,
- "PBEWithSHA1AndRC2_128");
-
- put("SecretKeyFactory.PBEWithSHA1AndRC4_40",
- "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC4_40"
- );
-
- put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC4_40,
- "PBEWithSHA1AndRC4_40");
- put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC4_40,
- "PBEWithSHA1AndRC4_40");
-
- put("SecretKeyFactory.PBEWithSHA1AndRC4_128",
- "com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC4_128"
- );
-
- put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC4_128,
- "PBEWithSHA1AndRC4_128");
- put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC4_128,
- "PBEWithSHA1AndRC4_128");
-
- put("SecretKeyFactory.PBEWithHmacSHA1AndAES_128",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithHmacSHA1AndAES_128");
-
- put("SecretKeyFactory.PBEWithHmacSHA224AndAES_128",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithHmacSHA224AndAES_128");
-
- put("SecretKeyFactory.PBEWithHmacSHA256AndAES_128",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithHmacSHA256AndAES_128");
-
- put("SecretKeyFactory.PBEWithHmacSHA384AndAES_128",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithHmacSHA384AndAES_128");
-
- put("SecretKeyFactory.PBEWithHmacSHA512AndAES_128",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithHmacSHA512AndAES_128");
-
- put("SecretKeyFactory.PBEWithHmacSHA1AndAES_256",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithHmacSHA1AndAES_256");
-
- put("SecretKeyFactory.PBEWithHmacSHA224AndAES_256",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithHmacSHA224AndAES_256");
-
- put("SecretKeyFactory.PBEWithHmacSHA256AndAES_256",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithHmacSHA256AndAES_256");
-
- put("SecretKeyFactory.PBEWithHmacSHA384AndAES_256",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithHmacSHA384AndAES_256");
+ /*
+ * KeyStore
+ */
+ ps("KeyStore", "JCEKS",
+ "com.sun.crypto.provider.JceKeyStore",
+ null, null);
- put("SecretKeyFactory.PBEWithHmacSHA512AndAES_256",
- "com.sun.crypto.provider.PBEKeyFactory$" +
- "PBEWithHmacSHA512AndAES_256");
-
- // PBKDF2
-
- put("SecretKeyFactory.PBKDF2WithHmacSHA1",
- "com.sun.crypto.provider.PBKDF2Core$HmacSHA1");
- put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS5_PBKDF2,
- "PBKDF2WithHmacSHA1");
- put("Alg.Alias.SecretKeyFactory." + OID_PKCS5_PBKDF2,
- "PBKDF2WithHmacSHA1");
-
- put("SecretKeyFactory.PBKDF2WithHmacSHA224",
- "com.sun.crypto.provider.PBKDF2Core$HmacSHA224");
- put("SecretKeyFactory.PBKDF2WithHmacSHA256",
- "com.sun.crypto.provider.PBKDF2Core$HmacSHA256");
- put("SecretKeyFactory.PBKDF2WithHmacSHA384",
- "com.sun.crypto.provider.PBKDF2Core$HmacSHA384");
- put("SecretKeyFactory.PBKDF2WithHmacSHA512",
- "com.sun.crypto.provider.PBKDF2Core$HmacSHA512");
-
- /*
- * MAC
- */
- put("Mac.HmacMD5", "com.sun.crypto.provider.HmacMD5");
- put("Mac.HmacSHA1", "com.sun.crypto.provider.HmacSHA1");
- put("Alg.Alias.Mac.OID.1.2.840.113549.2.7", "HmacSHA1");
- put("Alg.Alias.Mac.1.2.840.113549.2.7", "HmacSHA1");
- put("Mac.HmacSHA224",
- "com.sun.crypto.provider.HmacCore$HmacSHA224");
- put("Alg.Alias.Mac.OID.1.2.840.113549.2.8", "HmacSHA224");
- put("Alg.Alias.Mac.1.2.840.113549.2.8", "HmacSHA224");
- put("Mac.HmacSHA256",
- "com.sun.crypto.provider.HmacCore$HmacSHA256");
- put("Alg.Alias.Mac.OID.1.2.840.113549.2.9", "HmacSHA256");
- put("Alg.Alias.Mac.1.2.840.113549.2.9", "HmacSHA256");
- put("Mac.HmacSHA384",
- "com.sun.crypto.provider.HmacCore$HmacSHA384");
- put("Alg.Alias.Mac.OID.1.2.840.113549.2.10", "HmacSHA384");
- put("Alg.Alias.Mac.1.2.840.113549.2.10", "HmacSHA384");
- put("Mac.HmacSHA512",
- "com.sun.crypto.provider.HmacCore$HmacSHA512");
- put("Alg.Alias.Mac.OID.1.2.840.113549.2.11", "HmacSHA512");
- put("Alg.Alias.Mac.1.2.840.113549.2.11", "HmacSHA512");
-
- // TODO: aliases with OIDs
- put("Mac.HmacSHA512/224",
- "com.sun.crypto.provider.HmacCore$HmacSHA512_224");
- put("Mac.HmacSHA512/256",
- "com.sun.crypto.provider.HmacCore$HmacSHA512_256");
-
- put("Mac.HmacPBESHA1",
- "com.sun.crypto.provider.HmacPKCS12PBESHA1");
-
- // PBMAC1
+ /*
+ * SSL/TLS mechanisms
+ *
+ * These are strictly internal implementations and may
+ * be changed at any time. These names were chosen
+ * because PKCS11/SunPKCS11 does not yet have TLS1.2
+ * mechanisms, and it will cause calls to come here.
+ */
+ ps("KeyGenerator", "SunTlsPrf",
+ "com.sun.crypto.provider.TlsPrfGenerator$V10",
+ null, null);
+ ps("KeyGenerator", "SunTls12Prf",
+ "com.sun.crypto.provider.TlsPrfGenerator$V12",
+ null, null);
- put("Mac.PBEWithHmacSHA1",
- "com.sun.crypto.provider.PBMAC1Core$HmacSHA1");
- put("Mac.PBEWithHmacSHA224",
- "com.sun.crypto.provider.PBMAC1Core$HmacSHA224");
- put("Mac.PBEWithHmacSHA256",
- "com.sun.crypto.provider.PBMAC1Core$HmacSHA256");
- put("Mac.PBEWithHmacSHA384",
- "com.sun.crypto.provider.PBMAC1Core$HmacSHA384");
- put("Mac.PBEWithHmacSHA512",
- "com.sun.crypto.provider.PBMAC1Core$HmacSHA512");
-
- put("Mac.SslMacMD5",
- "com.sun.crypto.provider.SslMacCore$SslMacMD5");
- put("Mac.SslMacSHA1",
- "com.sun.crypto.provider.SslMacCore$SslMacSHA1");
-
- put("Mac.HmacMD5 SupportedKeyFormats", "RAW");
- put("Mac.HmacSHA1 SupportedKeyFormats", "RAW");
- put("Mac.HmacSHA224 SupportedKeyFormats", "RAW");
- put("Mac.HmacSHA256 SupportedKeyFormats", "RAW");
- put("Mac.HmacSHA384 SupportedKeyFormats", "RAW");
- put("Mac.HmacSHA512 SupportedKeyFormats", "RAW");
- put("Mac.HmacPBESHA1 SupportedKeyFormats", "RAW");
- put("Mac.PBEWithHmacSHA1 SupportedKeyFormatS", "RAW");
- put("Mac.PBEWithHmacSHA224 SupportedKeyFormats", "RAW");
- put("Mac.PBEWithHmacSHA256 SupportedKeyFormats", "RAW");
- put("Mac.PBEWithHmacSHA384 SupportedKeyFormats", "RAW");
- put("Mac.PBEWithHmacSHA512 SupportedKeyFormats", "RAW");
- put("Mac.SslMacMD5 SupportedKeyFormats", "RAW");
- put("Mac.SslMacSHA1 SupportedKeyFormats", "RAW");
-
- /*
- * KeyStore
- */
- put("KeyStore.JCEKS", "com.sun.crypto.provider.JceKeyStore");
+ ps("KeyGenerator", "SunTlsMasterSecret",
+ "com.sun.crypto.provider.TlsMasterSecretGenerator",
+ createAliases("SunTls12MasterSecret",
+ "SunTlsExtendedMasterSecret"), null);
- /*
- * SSL/TLS mechanisms
- *
- * These are strictly internal implementations and may
- * be changed at any time. These names were chosen
- * because PKCS11/SunPKCS11 does not yet have TLS1.2
- * mechanisms, and it will cause calls to come here.
- */
- put("KeyGenerator.SunTlsPrf",
- "com.sun.crypto.provider.TlsPrfGenerator$V10");
- put("KeyGenerator.SunTls12Prf",
- "com.sun.crypto.provider.TlsPrfGenerator$V12");
+ ps("KeyGenerator", "SunTlsKeyMaterial",
+ "com.sun.crypto.provider.TlsKeyMaterialGenerator",
+ createAliases("SunTls12KeyMaterial"), null);
- put("KeyGenerator.SunTlsMasterSecret",
- "com.sun.crypto.provider.TlsMasterSecretGenerator");
- put("Alg.Alias.KeyGenerator.SunTls12MasterSecret",
- "SunTlsMasterSecret");
- put("Alg.Alias.KeyGenerator.SunTlsExtendedMasterSecret",
- "SunTlsMasterSecret");
-
- put("KeyGenerator.SunTlsKeyMaterial",
- "com.sun.crypto.provider.TlsKeyMaterialGenerator");
- put("Alg.Alias.KeyGenerator.SunTls12KeyMaterial",
- "SunTlsKeyMaterial");
-
- put("KeyGenerator.SunTlsRsaPremasterSecret",
- "com.sun.crypto.provider.TlsRsaPremasterSecretGenerator");
- put("Alg.Alias.KeyGenerator.SunTls12RsaPremasterSecret",
- "SunTlsRsaPremasterSecret");
-
- return null;
- }
- });
-
- if (instance == null) {
- instance = this;
- }
+ ps("KeyGenerator", "SunTlsRsaPremasterSecret",
+ "com.sun.crypto.provider.TlsRsaPremasterSecretGenerator",
+ createAliases("SunTls12RsaPremasterSecret"), null);
}
// Return the instance of this class or create one if needed.
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Attribute.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Attribute.java Tue Dec 18 15:08:56 2018 -0500
@@ -996,7 +996,7 @@
endp = cstr.indexOf(',', cp);
if (endp < 0) endp = cstrlen;
String cstr1 = cstr.substring(cp, endp);
- if (cstr1.length() == 0)
+ if (cstr1.isEmpty())
cstr1 = "empty"; // will fail parse
int value0, value1;
// Check for a case range (new in 1.6).
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java Tue Dec 18 15:08:56 2018 -0500
@@ -50,6 +50,7 @@
1.10 to 1.10.X 54,0
1.11 to 1.11.X 55,0
1.12 to 1.12.X 56,0
+ 1.13 to 1.13.X 57,0
*/
public static final Package.Version JAVA_MIN_CLASS_VERSION =
@@ -79,6 +80,9 @@
public static final Package.Version JAVA12_MAX_CLASS_VERSION =
Package.Version.of(56, 00);
+ public static final Package.Version JAVA13_MAX_CLASS_VERSION =
+ Package.Version.of(57, 00);
+
public static final int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
public static final Package.Version JAVA5_PACKAGE_VERSION =
@@ -95,7 +99,7 @@
// upper limit, should point to the latest class version
public static final Package.Version JAVA_MAX_CLASS_VERSION =
- JAVA12_MAX_CLASS_VERSION;
+ JAVA13_MAX_CLASS_VERSION;
// upper limit should point to the latest package version, for version info!.
public static final Package.Version MAX_PACKAGE_VERSION =
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java Tue Dec 18 15:08:56 2018 -0500
@@ -279,7 +279,7 @@
junpack.properties().putAll(engProps);
if (doRepack && newfile.equals(jarfile)) {
String zipc = getZipComment(jarfile);
- if (verbose && zipc.length() > 0)
+ if (verbose && !zipc.isEmpty())
System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.DETECTED_ZIP_COMMENT), zipc));
if (zipc.indexOf(Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT) >= 0) {
System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.SKIP_FOR_REPACKED), jarfile));
@@ -552,7 +552,7 @@
if (words.length == 0) continue loadOptmap;
String opt = words[0];
words[0] = ""; // initial word is not a spec
- if (opt.length() == 0 && words.length >= 1) {
+ if (opt.isEmpty() && words.length >= 1) {
opt = words[1]; // initial "word" is empty due to leading ' '
words[1] = "";
}
@@ -622,7 +622,7 @@
switch (specop) {
case '+':
// + means we want an non-empty val suffix.
- ok = (val.length() != 0);
+ ok = !val.isEmpty();
specop = spec.charAt(sidx++);
break;
case '*':
@@ -641,10 +641,10 @@
String specarg = spec.substring(sidx);
switch (specop) {
case '.': // terminate the option sequence
- resultString = (specarg.length() != 0)? specarg.intern(): opt;
+ resultString = specarg.isEmpty() ? opt : specarg.intern();
break doArgs;
case '?': // abort the option sequence
- resultString = (specarg.length() != 0)? specarg.intern(): arg;
+ resultString = specarg.isEmpty() ? arg : specarg.intern();
isError = true;
break eachSpec;
case '@': // change the effective opt name
@@ -655,14 +655,14 @@
val = "";
break;
case '!': // negation option
- String negopt = (specarg.length() != 0)? specarg.intern(): opt;
+ String negopt = specarg.isEmpty() ? opt : specarg.intern();
properties.remove(negopt);
properties.put(negopt, null); // leave placeholder
didAction = true;
break;
case '$': // normal "boolean" option
String boolval;
- if (specarg.length() != 0) {
+ if (!specarg.isEmpty()) {
// If there is a given spec token, store it.
boolval = specarg;
} else {
--- a/src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactory.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactory.java Tue Dec 18 15:08:56 2018 -0500
@@ -153,7 +153,7 @@
String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
- if (provider == null || provider.length() == 0)
+ if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider");
Object[] objs = SSLSecurity.getImpl(algorithm, "KeyManagerFactory",
provider);
--- a/src/java.base/share/classes/com/sun/net/ssl/SSLContext.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/com/sun/net/ssl/SSLContext.java Tue Dec 18 15:08:56 2018 -0500
@@ -109,7 +109,7 @@
public static SSLContext getInstance(String protocol, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
- if (provider == null || provider.length() == 0)
+ if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider");
Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext",
provider);
--- a/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java Tue Dec 18 15:08:56 2018 -0500
@@ -155,7 +155,7 @@
String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
- if (provider == null || provider.length() == 0)
+ if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider");
Object[] objs = SSLSecurity.getImpl(algorithm, "TrustManagerFactory",
provider);
--- a/src/java.base/share/classes/java/io/Console.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/io/Console.java Tue Dec 18 15:08:56 2018 -0500
@@ -247,7 +247,7 @@
String line = null;
synchronized (writeLock) {
synchronized(readLock) {
- if (fmt.length() != 0)
+ if (!fmt.isEmpty())
pw.format(fmt, args);
try {
char[] ca = readline(false);
@@ -319,7 +319,7 @@
}
IOError ioe = null;
try {
- if (fmt.length() != 0)
+ if (!fmt.isEmpty())
pw.format(fmt, args);
passwd = readline(true);
} catch (IOException x) {
--- a/src/java.base/share/classes/java/lang/ClassLoader.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/ClassLoader.java Tue Dec 18 15:08:56 2018 -0500
@@ -1119,7 +1119,7 @@
// true if the name is null or has the potential to be a valid binary name
private boolean checkName(String name) {
- if ((name == null) || (name.length() == 0))
+ if ((name == null) || (name.isEmpty()))
return true;
if ((name.indexOf('/') != -1) || (name.charAt(0) == '['))
return false;
--- a/src/java.base/share/classes/java/lang/Double.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/Double.java Tue Dec 18 15:08:56 2018 -0500
@@ -1077,8 +1077,8 @@
}
/**
- * Returns a nominal descriptor for this instance, which is the instance
- * itself.
+ * Returns an {@link Optional} containing the nominal descriptor for this
+ * instance, which is the instance itself.
*
* @return an {@link Optional} describing the {@linkplain Double} instance
* @since 12
--- a/src/java.base/share/classes/java/lang/Float.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/Float.java Tue Dec 18 15:08:56 2018 -0500
@@ -989,8 +989,8 @@
}
/**
- * Returns a nominal descriptor for this instance, which is the instance
- * itself.
+ * Returns an {@link Optional} containing the nominal descriptor for this
+ * instance, which is the instance itself.
*
* @return an {@link Optional} describing the {@linkplain Float} instance
* @since 12
--- a/src/java.base/share/classes/java/lang/Integer.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/Integer.java Tue Dec 18 15:08:56 2018 -0500
@@ -1409,7 +1409,7 @@
boolean negative = false;
Integer result;
- if (nm.length() == 0)
+ if (nm.isEmpty())
throw new NumberFormatException("Zero length string");
char firstChar = nm.charAt(0);
// Handle sign, if present
@@ -1838,8 +1838,8 @@
}
/**
- * Returns a nominal descriptor for this instance, which is the instance
- * itself.
+ * Returns an {@link Optional} containing the nominal descriptor for this
+ * instance, which is the instance itself.
*
* @return an {@link Optional} describing the {@linkplain Integer} instance
* @since 12
--- a/src/java.base/share/classes/java/lang/Long.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/Long.java Tue Dec 18 15:08:56 2018 -0500
@@ -1248,7 +1248,7 @@
boolean negative = false;
Long result;
- if (nm.length() == 0)
+ if (nm.isEmpty())
throw new NumberFormatException("Zero length string");
char firstChar = nm.charAt(0);
// Handle sign, if present
@@ -1967,8 +1967,8 @@
}
/**
- * Returns a nominal descriptor for this instance, which is the instance
- * itself.
+ * Returns an {@link Optional} containing the nominal descriptor for this
+ * instance, which is the instance itself.
*
* @return an {@link Optional} describing the {@linkplain Long} instance
* @since 12
--- a/src/java.base/share/classes/java/lang/Package.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/Package.java Tue Dec 18 15:08:56 2018 -0500
@@ -397,11 +397,11 @@
public String toString() {
String spec = versionInfo.specTitle;
String ver = versionInfo.specVersion;
- if (spec != null && spec.length() > 0)
+ if (spec != null && !spec.isEmpty())
spec = ", " + spec;
else
spec = "";
- if (ver != null && ver.length() > 0)
+ if (ver != null && !ver.isEmpty())
ver = ", version " + ver;
else
ver = "";
--- a/src/java.base/share/classes/java/lang/Runtime.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/Runtime.java Tue Dec 18 15:08:56 2018 -0500
@@ -403,7 +403,7 @@
*/
public Process exec(String command, String[] envp, File dir)
throws IOException {
- if (command.length() == 0)
+ if (command.isEmpty())
throw new IllegalArgumentException("Empty command");
StringTokenizer st = new StringTokenizer(command);
--- a/src/java.base/share/classes/java/lang/String.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/String.java Tue Dec 18 15:08:56 2018 -0500
@@ -664,7 +664,7 @@
* object.
*/
public int length() {
- return value.length >> coder();
+ return isLatin1() ? value.length : value.length >> UTF16;
}
/**
@@ -1943,8 +1943,7 @@
* characters followed by the string argument's characters.
*/
public String concat(String str) {
- int olen = str.length();
- if (olen == 0) {
+ if (str.isEmpty()) {
return this;
}
if (coder() == str.coder()) {
@@ -1956,6 +1955,7 @@
return new String(buf, coder);
}
int len = length();
+ int olen = str.length();
byte[] buf = StringUTF16.newBytesFor(len + olen);
getBytes(buf, 0, UTF16);
str.getBytes(buf, len, UTF16);
@@ -2316,7 +2316,7 @@
// Construct result
int resultSize = list.size();
if (limit == 0) {
- while (resultSize > 0 && list.get(resultSize - 1).length() == 0) {
+ while (resultSize > 0 && list.get(resultSize - 1).isEmpty()) {
resultSize--;
}
}
@@ -3545,8 +3545,8 @@
}
/**
- * Returns a nominal descriptor for this instance, which is the instance
- * itself.
+ * Returns an {@link Optional} containing the nominal descriptor for this
+ * instance, which is the instance itself.
*
* @return an {@link Optional} describing the {@linkplain String} instance
* @since 12
--- a/src/java.base/share/classes/java/lang/VersionProps.java.template Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/VersionProps.java.template Tue Dec 18 15:08:56 2018 -0500
@@ -73,7 +73,7 @@
"@@VENDOR_VERSION_STRING@@";
private static final String vendor_version =
- (VENDOR_VERSION_STRING.length() > 0
+ (!VENDOR_VERSION_STRING.isEmpty()
? " " + VENDOR_VERSION_STRING : "");
private static final String VENDOR =
@@ -95,7 +95,7 @@
props.put("java.version.date", java_version_date);
props.put("java.runtime.version", java_runtime_version);
props.put("java.runtime.name", java_runtime_name);
- if (VENDOR_VERSION_STRING.length() > 0)
+ if (!VENDOR_VERSION_STRING.isEmpty())
props.put("java.vendor.version", VENDOR_VERSION_STRING);
props.put("java.class.version", CLASSFILE_MAJOR_MINOR);
--- a/src/java.base/share/classes/java/lang/constant/ClassDesc.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/constant/ClassDesc.java Tue Dec 18 15:08:56 2018 -0500
@@ -112,13 +112,13 @@
*
* A field type descriptor string for a non-array type is either
* a one-letter code corresponding to a primitive type
- * ({@code J,I,C,S,B,D,F,Z,V}), or the letter {@code L}, followed
- * by the fully qualified binary name of a class, followed by {@code ;}.
- * A field type descriptor for an array type is the character {@code [}
+ * ({@code "J", "I", "C", "S", "B", "D", "F", "Z", "V"}), or the letter {@code "L"}, followed
+ * by the fully qualified binary name of a class, followed by {@code ";"}.
+ * A field type descriptor for an array type is the character {@code "["}
* followed by the field descriptor for the component type. Examples of
- * valid type descriptor strings include {@code Ljava/lang/String;}, {@code I},
- * {@code [I}, {@code V}, {@code [Ljava/lang/String;}, etc.
- * for more detail.
+ * valid type descriptor strings include {@code "Ljava/lang/String;"}, {@code "I"},
+ * {@code "[I"}, {@code "V"}, {@code "[Ljava/lang/String;"}, etc.
+ * See JVMS 4.3.2 ("Field Descriptors") for more detail.
*
* @param descriptor a field descriptor string
* @return a {@linkplain ClassDesc} describing the desired class
@@ -126,9 +126,15 @@
* @throws IllegalArgumentException if the name string is not in the
* correct format
* @jvms 4.3.2 Field Descriptors
+ * @jvms 4.4.1 The CONSTANT_Class_info Structure
*/
static ClassDesc ofDescriptor(String descriptor) {
requireNonNull(descriptor);
+ int depth = ConstantUtils.arrayDepth(descriptor);
+ if (depth > ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS) {
+ throw new IllegalArgumentException(String.format("Cannot create an array type descriptor with more than %d dimensions",
+ ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS));
+ }
return (descriptor.length() == 1)
? new PrimitiveClassDescImpl(descriptor)
: new ReferenceClassDescImpl(descriptor);
@@ -139,8 +145,15 @@
* is described by this {@linkplain ClassDesc}.
*
* @return a {@linkplain ClassDesc} describing the array type
+ * @throws IllegalStateException if the resulting {@linkplain ClassDesc} would have an array rank of greater than 255
+ * @jvms 4.4.1 The CONSTANT_Class_info Structure
*/
default ClassDesc arrayType() {
+ int depth = ConstantUtils.arrayDepth(descriptorString());
+ if (depth >= ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS) {
+ throw new IllegalStateException(String.format("Cannot create an array type descriptor with more than %d dimensions",
+ ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS));
+ }
return arrayType(1);
}
@@ -150,11 +163,14 @@
*
* @param rank the rank of the array
* @return a {@linkplain ClassDesc} describing the array type
- * @throws IllegalArgumentException if the rank is zero or negative
+ * @throws IllegalArgumentException if the rank is less than zero or if the rank of the resulting array type is
+ * greater than 255
+ * @jvms 4.4.1 The CONSTANT_Class_info Structure
*/
default ClassDesc arrayType(int rank) {
- if (rank <= 0)
- throw new IllegalArgumentException("rank: " + rank);
+ int currentDepth = ConstantUtils.arrayDepth(descriptorString());
+ if (rank <= 0 || currentDepth + rank > ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS)
+ throw new IllegalArgumentException("rank: " + currentDepth + rank);
return ClassDesc.ofDescriptor("[".repeat(rank) + descriptorString());
}
@@ -162,6 +178,12 @@
* Returns a {@linkplain ClassDesc} for a nested class of the class or
* interface type described by this {@linkplain ClassDesc}.
*
+ * @apiNote
+ *
+ * Example: If descriptor {@code d} describes the class {@code java.util.Map}, a
+ * descriptor for the class {@code java.util.Map.Entry} could be obtained
+ * by {@code d.nested("Entry")}.
+ *
* @param nestedName the unqualified name of the nested class
* @return a {@linkplain ClassDesc} describing the nested class
* @throws NullPointerException if any argument is {@code null}
--- a/src/java.base/share/classes/java/lang/constant/Constable.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/constant/Constable.java Tue Dec 18 15:08:56 2018 -0500
@@ -65,8 +65,9 @@
*/
public interface Constable {
/**
- * Returns a nominal descriptor for this instance, if one can be
- * constructed, or an empty {@link Optional} if one cannot be constructed.
+ * Returns an {@link Optional} containing the nominal descriptor for this
+ * instance, if one can be constructed, or an empty {@link Optional}
+ * if one cannot be constructed.
*
* @return An {@link Optional} containing the resulting nominal descriptor,
* or an empty {@link Optional} if one cannot be constructed.
--- a/src/java.base/share/classes/java/lang/constant/ConstantUtils.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/constant/ConstantUtils.java Tue Dec 18 15:08:56 2018 -0500
@@ -37,6 +37,7 @@
/** an empty constant descriptor */
public static final ConstantDesc[] EMPTY_CONSTANTDESC = new ConstantDesc[0];
static final Constable[] EMPTY_CONSTABLE = new Constable[0];
+ static final int MAX_ARRAY_TYPE_DESC_DIMENSIONS = 255;
private static final Set<String> pointyNames = Set.of("<init>", "<clinit>");
--- a/src/java.base/share/classes/java/lang/constant/package-info.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/constant/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -49,7 +49,7 @@
* storing the value in a constant pool entry, or reconstituting the value given
* a class loading context. Every {@link java.lang.constant.ConstantDesc}
* knows how to <em>resolve</em> itself -- compute the value that it describes --
- * via {@link java.lang.constant.ConstantDesc#resolveConstantDesc(java.lang.invoke.MethodHandles.Lookup)}.
+ * via {@link java.lang.constant.ConstantDesc#resolveConstantDesc(java.lang.invoke.MethodHandles.Lookup) ConstantDesc.resolveConstantDesc}.
* This allows an API which accepts {@link java.lang.constant.ConstantDesc}
* objects to evaluate them reflectively, provided that the classes and methods
* referenced in their nominal description are present and accessible.
@@ -68,7 +68,7 @@
* When a bytecode-reading API encounters a constant pool entry, it can
* convert it to the appropriate type of nominal descriptor. For dynamic
* constants, bytecode-reading APIs may wish to use the factory
- * {@link java.lang.constant.DynamicConstantDesc#ofCanonical(DirectMethodHandleDesc, java.lang.String, ClassDesc, ConstantDesc[])},
+ * {@link java.lang.constant.DynamicConstantDesc#ofCanonical(DirectMethodHandleDesc, java.lang.String, ClassDesc, ConstantDesc[]) DynamicConstantDesc.ofCanonical},
* which will inspect the bootstrap and, for well-known bootstraps, return
* a more specific subtype of {@link java.lang.constant.DynamicConstantDesc}, such as
* {@link java.lang.Enum.EnumDesc}.
--- a/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java Tue Dec 18 15:08:56 2018 -0500
@@ -103,7 +103,7 @@
if (type != Class.class) {
throw new IllegalArgumentException();
}
- if (name.length() == 0 || name.length() > 1) {
+ if (name.length() != 1) {
throw new IllegalArgumentException(String.format("not primitive: %s", name));
}
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Tue Dec 18 15:08:56 2018 -0500
@@ -201,7 +201,7 @@
throw new IllegalAccessException(callerModule + " does not read " + targetModule);
if (targetModule.isNamed()) {
String pn = targetClass.getPackageName();
- assert pn.length() > 0 : "unnamed package cannot be in named module";
+ assert !pn.isEmpty() : "unnamed package cannot be in named module";
if (!targetModule.isOpen(pn, callerModule))
throw new IllegalAccessException(targetModule + " does not open " + pn + " to " + callerModule);
}
--- a/src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java Tue Dec 18 15:08:56 2018 -0500
@@ -62,7 +62,7 @@
}
try {
path = path.trim();
- final Path dir = Path.of(path.length() == 0 ? "." : path);
+ final Path dir = Path.of(path.isEmpty() ? "." : path);
AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Void run() {
--- a/src/java.base/share/classes/java/lang/invoke/TypeDescriptor.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/invoke/TypeDescriptor.java Tue Dec 18 15:08:56 2018 -0500
@@ -61,7 +61,8 @@
boolean isArray();
/**
- * Does this field descriptor describe a primitive type?
+ * Does this field descriptor describe a primitive type (including void.)
+ *
* @return whether this field descriptor describes a primitive type
*/
boolean isPrimitive();
--- a/src/java.base/share/classes/java/lang/invoke/VarHandle.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/lang/invoke/VarHandle.java Tue Dec 18 15:08:56 2018 -0500
@@ -1864,6 +1864,16 @@
}
}
+ /**
+ * Compare this {@linkplain VarHandle} with another object for equality.
+ * Two {@linkplain VarHandle}s are considered equal if they both describe the
+ * same instance field, both describe the same static field, both describe
+ * array elements for arrays with the same component type, or both describe
+ * the same component of an off-heap structure.
+ *
+ * @param o the other object
+ * @return Whether this {@linkplain VarHandle} is equal to the other object
+ */
@Override
public final boolean equals(Object o) {
if (this == o) return true;
@@ -1883,6 +1893,12 @@
abstract int internalHashCode();
+ /**
+ * Returns a compact textual description of this {@linkplain VarHandle},
+ * including the type of variable described, and a description of its coordinates.
+ *
+ * @return A compact textual description of this {@linkplain VarHandle}
+ */
@Override
public final String toString() {
return String.format("VarHandle[varType=%s, coord=%s]",
@@ -2272,6 +2288,14 @@
}
}
+ /**
+ * Returns a compact textual description of this constant description.
+ * For a field {@linkplain VarHandle}, includes the owner, name, and type
+ * of the field, and whether it is static; for an array {@linkplain VarHandle},
+ * the name of the component type.
+ *
+ * @return A compact textual description of this descriptor
+ */
@Override
public String toString() {
switch (kind) {
--- a/src/java.base/share/classes/java/net/HttpCookie.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/net/HttpCookie.java Tue Dec 18 15:08:56 2018 -0500
@@ -149,7 +149,7 @@
*/
HttpCookie(String name, String value, String header, long creationTime) {
name = name.trim();
- if (name.length() == 0 || !isToken(name) || name.charAt(0) == '$') {
+ if (name.isEmpty() || !isToken(name) || name.charAt(0) == '$') {
throw new IllegalArgumentException("Illegal cookie name");
}
--- a/src/java.base/share/classes/java/net/Inet6Address.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/net/Inet6Address.java Tue Dec 18 15:08:56 2018 -0500
@@ -433,7 +433,7 @@
NetworkInterface nif)
throws UnknownHostException
{
- if (host != null && host.length() > 0 && host.charAt(0) == '[') {
+ if (host != null && !host.isEmpty() && host.charAt(0) == '[') {
if (host.charAt(host.length()-1) == ']') {
host = host.substring(1, host.length() -1);
}
@@ -466,7 +466,7 @@
int scope_id)
throws UnknownHostException
{
- if (host != null && host.length() > 0 && host.charAt(0) == '[') {
+ if (host != null && !host.isEmpty() && host.charAt(0) == '[') {
if (host.charAt(host.length()-1) == ']') {
host = host.substring(1, host.length() -1);
}
@@ -601,7 +601,7 @@
boolean scope_ifname_set = gf.get("scope_ifname_set", false);
String ifname = (String)gf.get("ifname", null);
- if (ifname != null && !"".equals (ifname)) {
+ if (ifname != null && !ifname.isEmpty()) {
try {
scope_ifname = NetworkInterface.getByName(ifname);
if (scope_ifname == null) {
--- a/src/java.base/share/classes/java/net/InetAddress.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/net/InetAddress.java Tue Dec 18 15:08:56 2018 -0500
@@ -1187,7 +1187,7 @@
*/
public static InetAddress getByAddress(String host, byte[] addr)
throws UnknownHostException {
- if (host != null && host.length() > 0 && host.charAt(0) == '[') {
+ if (host != null && !host.isEmpty() && host.charAt(0) == '[') {
if (host.charAt(host.length()-1) == ']') {
host = host.substring(1, host.length() -1);
}
@@ -1301,7 +1301,7 @@
private static InetAddress[] getAllByName(String host, InetAddress reqAddr)
throws UnknownHostException {
- if (host == null || host.length() == 0) {
+ if (host == null || host.isEmpty()) {
InetAddress[] ret = new InetAddress[1];
ret[0] = impl.loopbackAddress();
return ret;
--- a/src/java.base/share/classes/java/net/SocketPermission.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/net/SocketPermission.java Tue Dec 18 15:08:56 2018 -0500
@@ -460,7 +460,7 @@
}
return;
} else {
- if (host.length() > 0) {
+ if (!host.isEmpty()) {
// see if we are being initialized with an IP address.
char ch = host.charAt(0);
if (ch == ':' || Character.digit(ch, 16) != -1) {
@@ -705,8 +705,7 @@
.orElse(b);
}
- return cdomain.length() != 0 && hdomain.length() != 0
- && cdomain.equals(hdomain);
+ return !cdomain.isEmpty() && !hdomain.isEmpty() && cdomain.equals(hdomain);
}
private boolean authorized(String cname, byte[] addr) {
--- a/src/java.base/share/classes/java/net/URI.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/net/URI.java Tue Dec 18 15:08:56 2018 -0500
@@ -1959,10 +1959,8 @@
throws URISyntaxException
{
if (scheme != null) {
- if ((path != null)
- && ((path.length() > 0) && (path.charAt(0) != '/')))
- throw new URISyntaxException(s,
- "Relative path in absolute URI");
+ if (path != null && !path.isEmpty() && path.charAt(0) != '/')
+ throw new URISyntaxException(s, "Relative path in absolute URI");
}
}
@@ -2163,7 +2161,7 @@
ru.port = base.port;
String cp = (child.path == null) ? "" : child.path;
- if ((cp.length() > 0) && (cp.charAt(0) == '/')) {
+ if (!cp.isEmpty() && cp.charAt(0) == '/') {
// 5.2 (5): Child path is absolute
ru.path = child.path;
} else {
@@ -2187,7 +2185,7 @@
// o.w., return a new URI containing the normalized path.
//
private static URI normalize(URI u) {
- if (u.isOpaque() || (u.path == null) || (u.path.length() == 0))
+ if (u.isOpaque() || u.path == null || u.path.isEmpty())
return u;
String np = normalize(u.path);
--- a/src/java.base/share/classes/java/net/URL.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/net/URL.java Tue Dec 18 15:08:56 2018 -0500
@@ -1513,7 +1513,7 @@
String ref = (String)gf.get("ref", null);
int hashCode = gf.get("hashCode", -1);
if (authority == null
- && ((host != null && host.length() > 0) || port != -1)) {
+ && ((host != null && !host.isEmpty()) || port != -1)) {
if (host == null)
host = "";
authority = (port == -1) ? host : host + ":" + port;
@@ -1560,7 +1560,7 @@
// Construct authority part
if (authority == null
- && ((host != null && host.length() > 0) || port != -1)) {
+ && ((host != null && !host.isEmpty()) || port != -1)) {
if (host == null)
host = "";
authority = (port == -1) ? host : host + ":" + port;
@@ -1716,7 +1716,7 @@
// pre-compute length of StringBuffer
int len = protocol.length() + 1;
- if (authority != null && authority.length() > 0)
+ if (authority != null && !authority.isEmpty())
len += 2 + authority.length();
if (file != null) {
len += file.length();
@@ -1726,7 +1726,7 @@
StringBuilder result = new StringBuilder(len);
result.append(protocol);
result.append(":");
- if (authority != null && authority.length() > 0) {
+ if (authority != null && !authority.isEmpty()) {
result.append("//");
result.append(authority);
}
--- a/src/java.base/share/classes/java/net/URLClassLoader.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/net/URLClassLoader.java Tue Dec 18 15:08:56 2018 -0500
@@ -743,7 +743,7 @@
locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
}
String host = locUrl.getHost();
- if (host != null && (host.length() > 0))
+ if (host != null && !host.isEmpty())
p = new SocketPermission(host,
SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION);
}
--- a/src/java.base/share/classes/java/net/URLDecoder.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/net/URLDecoder.java Tue Dec 18 15:08:56 2018 -0500
@@ -133,7 +133,7 @@
* @since 1.4
*/
public static String decode(String s, String enc) throws UnsupportedEncodingException {
- if (enc.length() == 0) {
+ if (enc.isEmpty()) {
throw new UnsupportedEncodingException ("URLDecoder: empty string enc parameter");
}
--- a/src/java.base/share/classes/java/net/URLPermission.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/net/URLPermission.java Tue Dec 18 15:08:56 2018 -0500
@@ -409,7 +409,7 @@
char c = methods.charAt(i);
if (c == ',') {
String s = b.toString();
- if (s.length() > 0)
+ if (!s.isEmpty())
l.add(s);
b = new StringBuilder();
} else if (c == ' ' || c == '\t') {
@@ -423,7 +423,7 @@
}
}
String s = b.toString();
- if (s.length() > 0)
+ if (!s.isEmpty())
l.add(s);
return l;
}
@@ -448,7 +448,7 @@
b.append(c);
} else if (c == ',') {
String s = b.toString();
- if (s.length() > 0)
+ if (!s.isEmpty())
l.add(s);
b = new StringBuilder();
capitalizeNext = true;
@@ -458,7 +458,7 @@
}
}
String s = b.toString();
- if (s.length() > 0)
+ if (!s.isEmpty())
l.add(s);
return l;
}
--- a/src/java.base/share/classes/java/net/URLStreamHandler.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/net/URLStreamHandler.java Tue Dec 18 15:08:56 2018 -0500
@@ -235,7 +235,7 @@
start = i;
// If the authority is defined then the path is defined by the
// spec only; See RFC 2396 Section 5.2.4.
- if (authority != null && authority.length() > 0)
+ if (authority != null && !authority.isEmpty())
path = "";
}
@@ -247,7 +247,7 @@
if (start < limit) {
if (spec.charAt(start) == '/') {
path = spec.substring(start, limit);
- } else if (path != null && path.length() > 0) {
+ } else if (path != null && !path.isEmpty()) {
isRelPath = true;
int ind = path.lastIndexOf('/');
String separator = "";
@@ -483,11 +483,11 @@
String s;
return u.getProtocol()
+ ':'
- + (((s = u.getAuthority()) != null && s.length() > 0)
+ + ((s = u.getAuthority()) != null && !s.isEmpty()
? "//" + s : "")
- + (((s = u.getPath()) != null) ? s : "")
- + (((s = u.getQuery()) != null) ? '?' + s : "")
- + (((s = u.getRef()) != null) ? '#' + s : "");
+ + ((s = u.getPath()) != null ? s : "")
+ + ((s = u.getQuery()) != null ? '?' + s : "")
+ + ((s = u.getRef()) != null ? '#' + s : "");
}
/**
@@ -544,7 +544,7 @@
*/
String authority = null;
String userInfo = null;
- if (host != null && host.length() != 0) {
+ if (host != null && !host.isEmpty()) {
authority = (port == -1) ? host : host + ":" + port;
int at = host.lastIndexOf('@');
if (at != -1) {
--- a/src/java.base/share/classes/java/nio/file/LinkPermission.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/nio/file/LinkPermission.java Tue Dec 18 15:08:56 2018 -0500
@@ -104,7 +104,7 @@
public LinkPermission(String name, String actions) {
super(name);
checkName(name);
- if (actions != null && actions.length() > 0) {
+ if (actions != null && !actions.isEmpty()) {
throw new IllegalArgumentException("actions: " + actions);
}
}
--- a/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java Tue Dec 18 15:08:56 2018 -0500
@@ -228,7 +228,7 @@
throws NoSuchAlgorithmException, NoSuchProviderException
{
Objects.requireNonNull(algorithm, "null algorithm name");
- if (provider == null || provider.length() == 0)
+ if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm,
"AlgorithmParameterGenerator",
--- a/src/java.base/share/classes/java/security/AlgorithmParameters.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/AlgorithmParameters.java Tue Dec 18 15:08:56 2018 -0500
@@ -209,7 +209,7 @@
throws NoSuchAlgorithmException, NoSuchProviderException
{
Objects.requireNonNull(algorithm, "null algorithm name");
- if (provider == null || provider.length() == 0)
+ if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters",
provider);
--- a/src/java.base/share/classes/java/security/KeyStore.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/KeyStore.java Tue Dec 18 15:08:56 2018 -0500
@@ -314,14 +314,7 @@
/**
* Gets the name of the protection algorithm.
* If none was set then the keystore provider will use its default
- * protection algorithm. The name of the default protection algorithm
- * for a given keystore type is set using the
- * {@code 'keystore.<type>.keyProtectionAlgorithm'} security property.
- * For example, the
- * {@code keystore.PKCS12.keyProtectionAlgorithm} property stores the
- * name of the default key protection algorithm used for PKCS12
- * keystores. If the security property is not set, an
- * implementation-specific algorithm will be used.
+ * protection algorithm.
*
* @return the algorithm name, or {@code null} if none was set
*
@@ -920,7 +913,7 @@
throws KeyStoreException, NoSuchProviderException
{
Objects.requireNonNull(type, "null type name");
- if (provider == null || provider.length() == 0)
+ if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider");
try {
Object[] objs = Security.getImpl(type, "KeyStore", provider);
@@ -1813,8 +1806,8 @@
}
}
- throw new KeyStoreException("This keystore does not support probing "
- + "and must be loaded with a specified type");
+ throw new KeyStoreException("Unrecognized keystore format. "
+ + "Please load it with a specified type");
}
/**
--- a/src/java.base/share/classes/java/security/MessageDigest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/MessageDigest.java Tue Dec 18 15:08:56 2018 -0500
@@ -237,7 +237,7 @@
throws NoSuchAlgorithmException, NoSuchProviderException
{
Objects.requireNonNull(algorithm, "null algorithm name");
- if (provider == null || provider.length() == 0)
+ if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
if (objs[0] instanceof MessageDigest) {
--- a/src/java.base/share/classes/java/security/Permission.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/Permission.java Tue Dec 18 15:08:56 2018 -0500
@@ -222,7 +222,7 @@
*/
public String toString() {
String actions = getActions();
- if ((actions == null) || (actions.length() == 0)) { // OPTIONAL
+ if (actions == null || actions.isEmpty()) { // OPTIONAL
return "(\"" + getClass().getName() + "\" \"" + name + "\")";
} else {
return "(\"" + getClass().getName() + "\" \"" + name +
--- a/src/java.base/share/classes/java/security/Policy.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/Policy.java Tue Dec 18 15:08:56 2018 -0500
@@ -456,7 +456,7 @@
throws NoSuchProviderException, NoSuchAlgorithmException {
Objects.requireNonNull(type, "null type name");
- if (provider == null || provider.length() == 0) {
+ if (provider == null || provider.isEmpty()) {
throw new IllegalArgumentException("missing provider");
}
--- a/src/java.base/share/classes/java/security/Provider.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/Provider.java Tue Dec 18 15:08:56 2018 -0500
@@ -33,6 +33,7 @@
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
+import java.util.concurrent.ConcurrentHashMap;
/**
* This class represents a "provider" for the
@@ -225,6 +226,7 @@
this.version = version;
this.versionStr = Double.toString(version);
this.info = info;
+ this.serviceMap = new ConcurrentHashMap<>();
putId();
initialized = true;
}
@@ -262,6 +264,7 @@
this.versionStr = versionStr;
this.version = parseVersionStr(versionStr);
this.info = info;
+ this.serviceMap = new ConcurrentHashMap<>();
putId();
initialized = true;
}
@@ -852,10 +855,7 @@
// legacy properties changed since last call to any services method?
private transient boolean legacyChanged;
// serviceMap changed since last call to getServices()
- private transient boolean servicesChanged;
-
- // Map<String,String>
- private transient Map<String,String> legacyStrings;
+ private volatile transient boolean servicesChanged;
// Map<ServiceKey,Service>
// used for services added via putService(), initialized on demand
@@ -905,22 +905,18 @@
// otherwise, set version based on versionStr
this.version = parseVersionStr(this.versionStr);
}
+ this.serviceMap = new ConcurrentHashMap<>();
implClear();
initialized = true;
putAll(copy);
}
- private boolean checkLegacy(Object key) {
+ private static boolean isProviderInfo(Object key) {
String keyString = (String)key;
if (keyString.startsWith("Provider.")) {
- return false;
+ return true;
}
-
- legacyChanged = true;
- if (legacyStrings == null) {
- legacyStrings = new LinkedHashMap<>();
- }
- return true;
+ return false;
}
/**
@@ -936,20 +932,20 @@
private Object implRemove(Object key) {
if (key instanceof String) {
- if (!checkLegacy(key)) {
+ if (isProviderInfo(key)) {
return null;
}
- legacyStrings.remove((String)key);
+ legacyChanged = true;
}
return super.remove(key);
}
private boolean implRemove(Object key, Object value) {
if (key instanceof String && value instanceof String) {
- if (!checkLegacy(key)) {
+ if (isProviderInfo(key)) {
return false;
}
- legacyStrings.remove((String)key, value);
+ legacyChanged = true;
}
return super.remove(key, value);
}
@@ -957,21 +953,20 @@
private boolean implReplace(Object key, Object oldValue, Object newValue) {
if ((key instanceof String) && (oldValue instanceof String) &&
(newValue instanceof String)) {
- if (!checkLegacy(key)) {
+ if (isProviderInfo(key)) {
return false;
}
- legacyStrings.replace((String)key, (String)oldValue,
- (String)newValue);
+ legacyChanged = true;
}
return super.replace(key, oldValue, newValue);
}
private Object implReplace(Object key, Object value) {
if ((key instanceof String) && (value instanceof String)) {
- if (!checkLegacy(key)) {
+ if (isProviderInfo(key)) {
return null;
}
- legacyStrings.replace((String)key, (String)value);
+ legacyChanged = true;
}
return super.replace(key, value);
}
@@ -980,12 +975,6 @@
private void implReplaceAll(BiFunction<? super Object, ? super Object,
? extends Object> function) {
legacyChanged = true;
- if (legacyStrings == null) {
- legacyStrings = new LinkedHashMap<>();
- } else {
- legacyStrings.replaceAll((BiFunction<? super String, ? super String,
- ? extends String>) function);
- }
super.replaceAll(function);
}
@@ -993,11 +982,10 @@
private Object implMerge(Object key, Object value, BiFunction<? super Object,
? super Object, ? extends Object> remappingFunction) {
if ((key instanceof String) && (value instanceof String)) {
- if (!checkLegacy(key)) {
+ if (isProviderInfo(key)) {
return null;
}
- legacyStrings.merge((String)key, (String)value,
- (BiFunction<? super String, ? super String, ? extends String>) remappingFunction);
+ legacyChanged = true;
}
return super.merge(key, value, remappingFunction);
}
@@ -1006,11 +994,10 @@
private Object implCompute(Object key, BiFunction<? super Object,
? super Object, ? extends Object> remappingFunction) {
if (key instanceof String) {
- if (!checkLegacy(key)) {
+ if (isProviderInfo(key)) {
return null;
}
- legacyStrings.compute((String) key,
- (BiFunction<? super String,? super String, ? extends String>) remappingFunction);
+ legacyChanged = true;
}
return super.compute(key, remappingFunction);
}
@@ -1019,11 +1006,10 @@
private Object implComputeIfAbsent(Object key, Function<? super Object,
? extends Object> mappingFunction) {
if (key instanceof String) {
- if (!checkLegacy(key)) {
+ if (isProviderInfo(key)) {
return null;
}
- legacyStrings.computeIfAbsent((String) key,
- (Function<? super String, ? extends String>) mappingFunction);
+ legacyChanged = true;
}
return super.computeIfAbsent(key, mappingFunction);
}
@@ -1032,45 +1018,39 @@
private Object implComputeIfPresent(Object key, BiFunction<? super Object,
? super Object, ? extends Object> remappingFunction) {
if (key instanceof String) {
- if (!checkLegacy(key)) {
+ if (isProviderInfo(key)) {
return null;
}
- legacyStrings.computeIfPresent((String) key,
- (BiFunction<? super String, ? super String, ? extends String>) remappingFunction);
+ legacyChanged = true;
}
return super.computeIfPresent(key, remappingFunction);
}
private Object implPut(Object key, Object value) {
if ((key instanceof String) && (value instanceof String)) {
- if (!checkLegacy(key)) {
+ if (isProviderInfo(key)) {
return null;
}
- legacyStrings.put((String)key, (String)value);
+ legacyChanged = true;
}
return super.put(key, value);
}
private Object implPutIfAbsent(Object key, Object value) {
if ((key instanceof String) && (value instanceof String)) {
- if (!checkLegacy(key)) {
+ if (isProviderInfo(key)) {
return null;
}
- legacyStrings.putIfAbsent((String)key, (String)value);
+ legacyChanged = true;
}
return super.putIfAbsent(key, value);
}
private void implClear() {
- if (legacyStrings != null) {
- legacyStrings.clear();
- }
if (legacyMap != null) {
legacyMap.clear();
}
- if (serviceMap != null) {
- serviceMap.clear();
- }
+ serviceMap.clear();
legacyChanged = false;
servicesChanged = false;
serviceSet = null;
@@ -1090,13 +1070,13 @@
this.algorithm = intern ? algorithm.intern() : algorithm;
}
public int hashCode() {
- return type.hashCode() + algorithm.hashCode();
+ return Objects.hash(type, algorithm);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
- if (obj instanceof ServiceKey == false) {
+ if (!(obj instanceof ServiceKey)) {
return false;
}
ServiceKey other = (ServiceKey)obj;
@@ -1113,16 +1093,16 @@
* service objects.
*/
private void ensureLegacyParsed() {
- if ((legacyChanged == false) || (legacyStrings == null)) {
+ if (legacyChanged == false) {
return;
}
serviceSet = null;
if (legacyMap == null) {
- legacyMap = new LinkedHashMap<>();
+ legacyMap = new ConcurrentHashMap<>();
} else {
legacyMap.clear();
}
- for (Map.Entry<String,String> entry : legacyStrings.entrySet()) {
+ for (Map.Entry<?,?> entry : super.entrySet()) {
parseLegacyPut(entry.getKey(), entry.getValue());
}
removeInvalidServices(legacyMap);
@@ -1161,7 +1141,15 @@
private static final String ALIAS_PREFIX_LOWER = "alg.alias.";
private static final int ALIAS_LENGTH = ALIAS_PREFIX.length();
- private void parseLegacyPut(String name, String value) {
+ private void parseLegacyPut(Object k, Object v) {
+ if (!(k instanceof String) || !(v instanceof String)) {
+ return;
+ }
+ String name = (String) k;
+ String value = (String) v;
+ if (isProviderInfo(name)) {
+ return;
+ }
if (name.toLowerCase(ENGLISH).startsWith(ALIAS_PREFIX_LOWER)) {
// e.g. put("Alg.Alias.MessageDigest.SHA", "SHA-1");
// aliasKey ~ MessageDigest.SHA
@@ -1248,22 +1236,28 @@
*
* @since 1.5
*/
- public synchronized Service getService(String type, String algorithm) {
+ public Service getService(String type, String algorithm) {
checkInitialized();
- // avoid allocating a new key object if possible
+
+ // avoid allocating a new ServiceKey object if possible
ServiceKey key = previousKey;
if (key.matches(type, algorithm) == false) {
key = new ServiceKey(type, algorithm, false);
previousKey = key;
}
- if (serviceMap != null) {
- Service service = serviceMap.get(key);
- if (service != null) {
- return service;
+ if (!serviceMap.isEmpty()) {
+ Service s = serviceMap.get(key);
+ if (s != null) {
+ return s;
}
}
- ensureLegacyParsed();
- return (legacyMap != null) ? legacyMap.get(key) : null;
+ synchronized (this) {
+ ensureLegacyParsed();
+ }
+ if (legacyMap != null && !legacyMap.isEmpty()) {
+ return legacyMap.get(key);
+ }
+ return null;
}
// ServiceKey from previous getService() call
@@ -1292,10 +1286,10 @@
if (serviceSet == null) {
ensureLegacyParsed();
Set<Service> set = new LinkedHashSet<>();
- if (serviceMap != null) {
+ if (!serviceMap.isEmpty()) {
set.addAll(serviceMap.values());
}
- if (legacyMap != null) {
+ if (legacyMap != null && !legacyMap.isEmpty()) {
set.addAll(legacyMap.values());
}
serviceSet = Collections.unmodifiableSet(set);
@@ -1333,7 +1327,7 @@
*
* @since 1.5
*/
- protected synchronized void putService(Service s) {
+ protected void putService(Service s) {
check("putProviderProperty." + name);
if (debug != null) {
debug.println(name + ".putService(): " + s);
@@ -1345,20 +1339,18 @@
throw new IllegalArgumentException
("service.getProvider() must match this Provider object");
}
- if (serviceMap == null) {
- serviceMap = new LinkedHashMap<>();
- }
- servicesChanged = true;
String type = s.getType();
String algorithm = s.getAlgorithm();
ServiceKey key = new ServiceKey(type, algorithm, true);
- // remove existing service
implRemoveService(serviceMap.get(key));
serviceMap.put(key, s);
for (String alias : s.getAliases()) {
serviceMap.put(new ServiceKey(type, alias, true), s);
}
- putPropertyStrings(s);
+ servicesChanged = true;
+ synchronized (this) {
+ putPropertyStrings(s);
+ }
}
/**
@@ -1425,7 +1417,7 @@
*
* @since 1.5
*/
- protected synchronized void removeService(Service s) {
+ protected void removeService(Service s) {
check("removeProviderProperty." + name);
if (debug != null) {
debug.println(name + ".removeService(): " + s);
@@ -1437,7 +1429,7 @@
}
private void implRemoveService(Service s) {
- if ((s == null) || (serviceMap == null)) {
+ if ((s == null) || serviceMap.isEmpty()) {
return;
}
String type = s.getType();
@@ -1452,7 +1444,9 @@
for (String alias : s.getAliases()) {
serviceMap.remove(new ServiceKey(type, alias, false));
}
- removePropertyStrings(s);
+ synchronized (this) {
+ removePropertyStrings(s);
+ }
}
// Wrapped String that behaves in a case insensitive way for equals/hashCode
--- a/src/java.base/share/classes/java/security/SecureRandom.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/SecureRandom.java Tue Dec 18 15:08:56 2018 -0500
@@ -942,7 +942,7 @@
}
});
- if ((property == null) || (property.length() == 0)) {
+ if (property == null || property.isEmpty()) {
throw new NoSuchAlgorithmException(
"Null/empty securerandom.strongAlgorithms Security Property");
}
--- a/src/java.base/share/classes/java/security/Security.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/Security.java Tue Dec 18 15:08:56 2018 -0500
@@ -649,7 +649,7 @@
}
}
- if ((candidates == null) || (candidates.isEmpty()))
+ if (candidates == null || candidates.isEmpty())
return null;
Object[] candidatesArray = candidates.toArray();
@@ -1005,11 +1005,11 @@
String algName = null;
String attrName = null;
- if (filterValue.length() == 0) {
+ if (filterValue.isEmpty()) {
// The filterValue is an empty string. So the filterKey
// should be in the format of <crypto_service>.<algorithm_or_type>.
algName = filterKey.substring(algIndex + 1).trim();
- if (algName.length() == 0) {
+ if (algName.isEmpty()) {
// There must be a algorithm or type name.
throw new InvalidParameterException("Invalid filter");
}
@@ -1024,7 +1024,7 @@
throw new InvalidParameterException("Invalid filter");
} else {
attrName = filterKey.substring(attrIndex + 1).trim();
- if (attrName.length() == 0) {
+ if (attrName.isEmpty()) {
// There is no attribute name in the filter.
throw new InvalidParameterException("Invalid filter");
}
@@ -1070,7 +1070,7 @@
**/
public static Set<String> getAlgorithms(String serviceName) {
- if ((serviceName == null) || (serviceName.length() == 0) ||
+ if ((serviceName == null) || (serviceName.isEmpty()) ||
(serviceName.endsWith("."))) {
return Collections.emptySet();
}
--- a/src/java.base/share/classes/java/security/Signature.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/Signature.java Tue Dec 18 15:08:56 2018 -0500
@@ -360,7 +360,7 @@
Objects.requireNonNull(algorithm, "null algorithm name");
if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
// exception compatibility with existing code
- if ((provider == null) || (provider.length() == 0)) {
+ if (provider == null || provider.isEmpty()) {
throw new IllegalArgumentException("missing provider");
}
Provider p = Security.getProvider(provider);
--- a/src/java.base/share/classes/java/security/cert/TrustAnchor.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/security/cert/TrustAnchor.java Tue Dec 18 15:08:56 2018 -0500
@@ -210,7 +210,7 @@
if (caName == null)
throw new NullPointerException("the caName parameter must be " +
"non-null");
- if (caName.length() == 0)
+ if (caName.isEmpty())
throw new IllegalArgumentException("the caName " +
"parameter must be a non-empty String");
// check if caName is formatted correctly
--- a/src/java.base/share/classes/java/text/AttributedString.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/text/AttributedString.java Tue Dec 18 15:08:56 2018 -0500
@@ -85,7 +85,7 @@
text = buffer.toString();
- if (text.length() > 0) {
+ if (!text.isEmpty()) {
// Determine the runs, creating a new run when the attributes
// differ.
int offset = 0;
@@ -144,7 +144,7 @@
}
this.text = text;
- if (text.length() == 0) {
+ if (text.isEmpty()) {
if (attributes.isEmpty())
return;
throw new IllegalArgumentException("Can't add attribute to 0-length text");
--- a/src/java.base/share/classes/java/text/CollationElementIterator.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/text/CollationElementIterator.java Tue Dec 18 15:08:56 2018 -0500
@@ -125,7 +125,7 @@
CollationElementIterator(String sourceText, RuleBasedCollator owner) {
this.owner = owner;
ordering = owner.getTables();
- if ( sourceText.length() != 0 ) {
+ if (!sourceText.isEmpty()) {
NormalizerBase.Mode mode =
CollatorUtilities.toNormalizerMode(owner.getDecomposition());
text = new NormalizerBase(sourceText, mode);
--- a/src/java.base/share/classes/java/text/CompactNumberFormat.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/text/CompactNumberFormat.java Tue Dec 18 15:08:56 2018 -0500
@@ -799,7 +799,7 @@
*/
private void append(StringBuffer result, String string,
FieldDelegate delegate, List<FieldPosition> positions) {
- if (string.length() > 0) {
+ if (!string.isEmpty()) {
int start = result.length();
result.append(string);
for (int counter = 0; counter < positions.size(); counter++) {
@@ -1213,7 +1213,7 @@
}
// If no 0s are specified in a non empty pattern, it is invalid
- if (pattern.length() != 0 && zeros.isEmpty()) {
+ if (!pattern.isEmpty() && zeros.isEmpty()) {
throw new IllegalArgumentException("Invalid pattern"
+ " [" + pattern + "]: all patterns must include digit"
+ " placement 0s");
--- a/src/java.base/share/classes/java/text/DecimalFormat.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/text/DecimalFormat.java Tue Dec 18 15:08:56 2018 -0500
@@ -1113,11 +1113,9 @@
// Records the need for adding prefix or suffix
fastPathData.positiveAffixesRequired
- = (positivePrefix.length() != 0)
- || (positiveSuffix.length() != 0);
+ = !positivePrefix.isEmpty() || !positiveSuffix.isEmpty();
fastPathData.negativeAffixesRequired
- = (negativePrefix.length() != 0)
- || (negativeSuffix.length() != 0);
+ = !negativePrefix.isEmpty() || !negativeSuffix.isEmpty();
// Creates a cached char container for result, with max possible size.
int maxNbIntegralDigits = 10;
@@ -2062,7 +2060,7 @@
Format.Field signAttribute) {
int start = result.length();
- if (string.length() > 0) {
+ if (!string.isEmpty()) {
result.append(string);
for (int counter = 0, max = positions.length; counter < max;
counter++) {
@@ -3042,7 +3040,7 @@
} else {
string = symbols.getCurrencySymbol();
}
- if (string.length() > 0) {
+ if (!string.isEmpty()) {
if (positions == null) {
positions = new ArrayList<>(2);
}
@@ -3613,7 +3611,7 @@
}
}
- if (pattern.length() == 0) {
+ if (pattern.isEmpty()) {
posPrefixPattern = posSuffixPattern = "";
setMinimumIntegerDigits(0);
setMaximumIntegerDigits(MAXIMUM_INTEGER_DIGITS);
--- a/src/java.base/share/classes/java/text/DecimalFormatSymbols.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/text/DecimalFormatSymbols.java Tue Dec 18 15:08:56 2018 -0500
@@ -663,7 +663,7 @@
// Check for empty country string separately because it's a valid
// country ID for Locale (and used for the C locale), but not a valid
// ISO 3166 country code, and exceptions are expensive.
- if (locale.getCountry().length() > 0) {
+ if (!locale.getCountry().isEmpty()) {
try {
currency = Currency.getInstance(locale);
} catch (IllegalArgumentException e) {
--- a/src/java.base/share/classes/java/text/MergeCollation.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/text/MergeCollation.java Tue Dec 18 15:08:56 2018 -0500
@@ -92,7 +92,7 @@
int i;
for (i = 0; i < patterns.size(); ++i) {
PatternEntry entry = patterns.get(i);
- if (entry.extension.length() != 0) {
+ if (!entry.extension.isEmpty()) {
if (extList == null)
extList = new ArrayList<>();
extList.add(entry);
@@ -122,7 +122,7 @@
private final PatternEntry findLastWithNoExtension(int i) {
for (--i;i >= 0; --i) {
PatternEntry entry = patterns.get(i);
- if (entry.extension.length() == 0) {
+ if (entry.extension.isEmpty()) {
return entry;
}
}
--- a/src/java.base/share/classes/java/text/MessageFormat.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/text/MessageFormat.java Tue Dec 18 15:08:56 2018 -0500
@@ -1330,7 +1330,7 @@
}
arg = null;
}
- if (arg != null && arg.length() > 0) {
+ if (arg != null && !arg.isEmpty()) {
result.append(arg);
characterIterators.add(
createAttributedCharacterIterator(
@@ -1476,7 +1476,7 @@
// now get the format
Format newFormat = null;
- if (segments[SEG_TYPE].length() != 0) {
+ if (!segments[SEG_TYPE].isEmpty()) {
int type = findKeyword(segments[SEG_TYPE], TYPE_KEYWORDS);
switch (type) {
case TYPE_NULL:
--- a/src/java.base/share/classes/java/text/PatternEntry.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/text/PatternEntry.java Tue Dec 18 15:08:56 2018 -0500
@@ -141,7 +141,7 @@
if (showWhiteSpace)
toAddTo.append(' ');
appendQuoted(chars,toAddTo);
- if (showExtension && extension.length() != 0) {
+ if (showExtension && !extension.isEmpty()) {
toAddTo.append('/');
appendQuoted(extension,toAddTo);
}
--- a/src/java.base/share/classes/java/text/RBTableBuilder.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/text/RBTableBuilder.java Tue Dec 18 15:08:56 2018 -0500
@@ -75,13 +75,10 @@
* @exception ParseException If the rules format is incorrect.
*/
- public void build(String pattern, int decmp) throws ParseException
- {
- boolean isSource = true;
- int i = 0;
+ public void build(String pattern, int decmp) throws ParseException {
String expChars;
String groupChars;
- if (pattern.length() == 0)
+ if (pattern.isEmpty())
throw new ParseException("Build rules empty.", 0);
// This array maps Unicode characters to their collation ordering
@@ -119,8 +116,7 @@
int order = 0;
// Now walk though each entry and add it to my own tables
- for (i = 0; i < mPattern.getCount(); ++i)
- {
+ for (int i = 0; i < mPattern.getCount(); ++i) {
PatternEntry entry = mPattern.getItemAt(i);
if (entry != null) {
groupChars = entry.getChars();
@@ -140,7 +136,7 @@
order = increment(entry.getStrength(), order);
expChars = entry.getExtension();
- if (expChars.length() != 0) {
+ if (!expChars.isEmpty()) {
addExpandOrder(groupChars, expChars, order);
} else if (groupChars.length() > 1) {
char ch = groupChars.charAt(0);
--- a/src/java.base/share/classes/java/time/ZoneId.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/time/ZoneId.java Tue Dec 18 15:08:56 2018 -0500
@@ -372,7 +372,7 @@
public static ZoneId ofOffset(String prefix, ZoneOffset offset) {
Objects.requireNonNull(prefix, "prefix");
Objects.requireNonNull(offset, "offset");
- if (prefix.length() == 0) {
+ if (prefix.isEmpty()) {
return offset;
}
--- a/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Tue Dec 18 15:08:56 2018 -0500
@@ -1439,7 +1439,7 @@
*/
public DateTimeFormatterBuilder appendLiteral(String literal) {
Objects.requireNonNull(literal, "literal");
- if (literal.length() > 0) {
+ if (!literal.isEmpty()) {
if (literal.length() == 1) {
appendInternal(new CharLiteralPrinterParser(literal.charAt(0)));
} else {
@@ -1832,7 +1832,7 @@
throw new IllegalArgumentException("Pattern ends with an incomplete string literal: " + pattern);
}
String str = pattern.substring(start + 1, pos);
- if (str.length() == 0) {
+ if (str.isEmpty()) {
appendLiteral('\'');
} else {
appendLiteral(str.replace("''", "'"));
@@ -4332,7 +4332,7 @@
this.key = k;
this.value = v;
this.child = child;
- if (k.length() == 0){
+ if (k.isEmpty()) {
c0 = 0xffff;
} else {
c0 = key.charAt(0);
--- a/src/java.base/share/classes/java/util/Calendar.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/util/Calendar.java Tue Dec 18 15:08:56 2018 -0500
@@ -2232,7 +2232,7 @@
if (strings != null) {
Map<String,Integer> names = new HashMap<>();
for (int i = 0; i < strings.length; i++) {
- if (strings[i].length() == 0) {
+ if (strings[i].isEmpty()) {
continue;
}
names.put(strings[i], i);
--- a/src/java.base/share/classes/java/util/Locale.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/util/Locale.java Tue Dec 18 15:08:56 2018 -0500
@@ -1396,11 +1396,11 @@
*/
@Override
public final String toString() {
- boolean l = (baseLocale.getLanguage().length() != 0);
- boolean s = (baseLocale.getScript().length() != 0);
- boolean r = (baseLocale.getRegion().length() != 0);
- boolean v = (baseLocale.getVariant().length() != 0);
- boolean e = (localeExtensions != null && localeExtensions.getID().length() != 0);
+ boolean l = !baseLocale.getLanguage().isEmpty();
+ boolean s = !baseLocale.getScript().isEmpty();
+ boolean r = !baseLocale.getRegion().isEmpty();
+ boolean v = !baseLocale.getVariant().isEmpty();
+ boolean e = localeExtensions != null && !localeExtensions.getID().isEmpty();
StringBuilder result = new StringBuilder(baseLocale.getLanguage());
if (r || (l && (v || s || e))) {
@@ -1504,18 +1504,18 @@
StringBuilder buf = new StringBuilder();
String subtag = tag.getLanguage();
- if (subtag.length() > 0) {
+ if (!subtag.isEmpty()) {
buf.append(LanguageTag.canonicalizeLanguage(subtag));
}
subtag = tag.getScript();
- if (subtag.length() > 0) {
+ if (!subtag.isEmpty()) {
buf.append(LanguageTag.SEP);
buf.append(LanguageTag.canonicalizeScript(subtag));
}
subtag = tag.getRegion();
- if (subtag.length() > 0) {
+ if (!subtag.isEmpty()) {
buf.append(LanguageTag.SEP);
buf.append(LanguageTag.canonicalizeRegion(subtag));
}
@@ -1534,7 +1534,7 @@
}
subtag = tag.getPrivateuse();
- if (subtag.length() > 0) {
+ if (!subtag.isEmpty()) {
if (buf.length() > 0) {
buf.append(LanguageTag.SEP);
}
@@ -1684,7 +1684,7 @@
bldr.setLanguageTag(tag);
BaseLocale base = bldr.getBaseLocale();
LocaleExtensions exts = bldr.getLocaleExtensions();
- if (exts == null && base.getVariant().length() > 0) {
+ if (exts == null && !base.getVariant().isEmpty()) {
exts = getCompatibilityExtensions(base.getLanguage(), base.getScript(),
base.getRegion(), base.getVariant());
}
@@ -1917,7 +1917,7 @@
* @exception NullPointerException if <code>inLocale</code> is <code>null</code>
*/
public String getDisplayVariant(Locale inLocale) {
- if (baseLocale.getVariant().length() == 0)
+ if (baseLocale.getVariant().isEmpty())
return "";
LocaleResources lr = LocaleProviderAdapter
@@ -1998,14 +1998,14 @@
// The display name consists of a main name, followed by qualifiers.
// Typically, the format is "MainName (Qualifier, Qualifier)" but this
// depends on what pattern is stored in the display locale.
- String mainName = null;
- String[] qualifierNames = null;
+ String mainName;
+ String[] qualifierNames;
// The main name is the language, or if there is no language, the script,
// then if no script, the country. If there is no language/script/country
// (an anomalous situation) then the display name is simply the variant's
// display name.
- if (languageName.length() == 0 && scriptName.length() == 0 && countryName.length() == 0) {
+ if (languageName.isEmpty() && scriptName.isEmpty() && countryName.isEmpty()) {
if (variantNames.length == 0) {
return "";
} else {
@@ -2013,13 +2013,13 @@
}
}
ArrayList<String> names = new ArrayList<>(4);
- if (languageName.length() != 0) {
+ if (!languageName.isEmpty()) {
names.add(languageName);
}
- if (scriptName.length() != 0) {
+ if (!scriptName.isEmpty()) {
names.add(scriptName);
}
- if (countryName.length() != 0) {
+ if (!countryName.isEmpty()) {
names.add(countryName);
}
if (variantNames.length != 0) {
@@ -2309,7 +2309,7 @@
String variant = (String)fields.get("variant", "");
String extStr = (String)fields.get("extensions", "");
baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
- if (extStr.length() > 0) {
+ if (!extStr.isEmpty()) {
try {
InternalLocaleBuilder bldr = new InternalLocaleBuilder();
bldr.setExtensions(extStr);
@@ -2367,13 +2367,13 @@
LocaleExtensions extensions = null;
// Special cases for backward compatibility support
if (LocaleUtils.caseIgnoreMatch(language, "ja")
- && script.length() == 0
+ && script.isEmpty()
&& LocaleUtils.caseIgnoreMatch(country, "jp")
&& "JP".equals(variant)) {
// ja_JP_JP -> u-ca-japanese (calendar = japanese)
extensions = LocaleExtensions.CALENDAR_JAPANESE;
} else if (LocaleUtils.caseIgnoreMatch(language, "th")
- && script.length() == 0
+ && script.isEmpty()
&& LocaleUtils.caseIgnoreMatch(country, "th")
&& "TH".equals(variant)) {
// th_TH_TH -> u-nu-thai (numbersystem = thai)
@@ -2806,7 +2806,7 @@
public Locale build() {
BaseLocale baseloc = localeBuilder.getBaseLocale();
LocaleExtensions extensions = localeBuilder.getLocaleExtensions();
- if (extensions == null && baseloc.getVariant().length() > 0) {
+ if (extensions == null && !baseloc.getVariant().isEmpty()) {
extensions = getCompatibilityExtensions(baseloc.getLanguage(), baseloc.getScript(),
baseloc.getRegion(), baseloc.getVariant());
}
--- a/src/java.base/share/classes/java/util/ResourceBundle.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/util/ResourceBundle.java Tue Dec 18 15:08:56 2018 -0500
@@ -771,8 +771,8 @@
@Override
public String toString() {
String l = locale.toString();
- if (l.length() == 0) {
- if (locale.getVariant().length() != 0) {
+ if (l.isEmpty()) {
+ if (!locale.getVariant().isEmpty()) {
l = "__" + locale.getVariant();
} else {
l = "\"\"";
@@ -2903,7 +2903,7 @@
List<Locale> bokmalList = new LinkedList<>();
for (Locale l : tmpList) {
bokmalList.add(l);
- if (l.getLanguage().length() == 0) {
+ if (l.getLanguage().isEmpty()) {
break;
}
bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
@@ -2921,7 +2921,7 @@
}
// Special handling for Chinese
else if (language.equals("zh")) {
- if (script.length() == 0 && region.length() > 0) {
+ if (script.isEmpty() && !region.isEmpty()) {
// Supply script for users who want to use zh_Hans/zh_Hant
// as bundle names (recommended for Java7+)
switch (region) {
@@ -2944,7 +2944,7 @@
private static List<Locale> getDefaultList(String language, String script, String region, String variant) {
List<String> variants = null;
- if (variant.length() > 0) {
+ if (!variant.isEmpty()) {
variants = new LinkedList<>();
int idx = variant.length();
while (idx != -1) {
@@ -2960,14 +2960,14 @@
list.add(Locale.getInstance(language, script, region, v, null));
}
}
- if (region.length() > 0) {
+ if (!region.isEmpty()) {
list.add(Locale.getInstance(language, script, region, "", null));
}
- if (script.length() > 0) {
+ if (!script.isEmpty()) {
list.add(Locale.getInstance(language, script, "", "", null));
// Special handling for Chinese
if (language.equals("zh")) {
- if (region.length() == 0) {
+ if (region.isEmpty()) {
// Supply region(country) for users who still package Chinese
// bundles using old convension.
switch (script) {
@@ -2988,11 +2988,11 @@
list.add(Locale.getInstance(language, "", region, v, null));
}
}
- if (region.length() > 0) {
+ if (!region.isEmpty()) {
list.add(Locale.getInstance(language, "", region, "", null));
}
}
- if (language.length() > 0) {
+ if (!language.isEmpty()) {
list.add(Locale.getInstance(language, "", "", "", null));
}
// Add root locale at the end
--- a/src/java.base/share/classes/java/util/Scanner.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/util/Scanner.java Tue Dec 18 15:08:56 2018 -0500
@@ -1297,16 +1297,16 @@
nanString = "\\Q" + dfs.getNaN() + "\\E";
infinityString = "\\Q" + dfs.getInfinity() + "\\E";
positivePrefix = df.getPositivePrefix();
- if (positivePrefix.length() > 0)
+ if (!positivePrefix.isEmpty())
positivePrefix = "\\Q" + positivePrefix + "\\E";
negativePrefix = df.getNegativePrefix();
- if (negativePrefix.length() > 0)
+ if (!negativePrefix.isEmpty())
negativePrefix = "\\Q" + negativePrefix + "\\E";
positiveSuffix = df.getPositiveSuffix();
- if (positiveSuffix.length() > 0)
+ if (!positiveSuffix.isEmpty())
positiveSuffix = "\\Q" + positiveSuffix + "\\E";
negativeSuffix = df.getNegativeSuffix();
- if (negativeSuffix.length() > 0)
+ if (!negativeSuffix.isEmpty())
negativeSuffix = "\\Q" + negativeSuffix + "\\E";
// Force rebuilding and recompilation of locale dependent
--- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java Tue Dec 18 15:08:56 2018 -0500
@@ -445,7 +445,8 @@
* if to its current value). This would be extremely costly. So
* we relax it in several ways: (1) Producers only signal when
* their queue is possibly empty at some point during a push
- * operation. (2) Other workers propagate this signal
+ * operation (which requires conservatively checking size zero or
+ * one to cover races). (2) Other workers propagate this signal
* when they find tasks in a queue with size greater than one. (3)
* Workers only enqueue after scanning (see below) and not finding
* any tasks. (4) Rather than CASing ctl to its current value in
@@ -761,8 +762,10 @@
/**
* The maximum number of top-level polls per worker before
- * checking other queues, expressed as a bit shift. See above for
- * rationale.
+ * checking other queues, expressed as a bit shift to, in effect,
+ * multiply by pool size, and then use as random value mask, so
+ * average bound is about poolSize*(1<<TOP_BOUND_SHIFT). See
+ * above for rationale.
*/
static final int TOP_BOUND_SHIFT = 10;
@@ -838,17 +841,18 @@
*/
final void push(ForkJoinTask<?> task) {
ForkJoinTask<?>[] a;
- int s = top, d = s - base, cap, m;
+ int s = top, d, cap, m;
ForkJoinPool p = pool;
if ((a = array) != null && (cap = a.length) > 0) {
QA.setRelease(a, (m = cap - 1) & s, task);
top = s + 1;
- if (d == m)
+ if (((d = s - (int)BASE.getAcquire(this)) & ~1) == 0 &&
+ p != null) { // size 0 or 1
+ VarHandle.fullFence();
+ p.signalWork();
+ }
+ else if (d == m)
growArray(false);
- else if (QA.getAcquire(a, m & (s - 1)) == null && p != null) {
- VarHandle.fullFence(); // was empty
- p.signalWork(null);
- }
}
}
@@ -859,16 +863,16 @@
final boolean lockedPush(ForkJoinTask<?> task) {
ForkJoinTask<?>[] a;
boolean signal = false;
- int s = top, d = s - base, cap, m;
+ int s = top, b = base, cap, d;
if ((a = array) != null && (cap = a.length) > 0) {
- a[(m = (cap - 1)) & s] = task;
+ a[(cap - 1) & s] = task;
top = s + 1;
- if (d == m)
+ if (b - s + cap - 1 == 0)
growArray(true);
else {
phase = 0; // full volatile unlock
- if (a[m & (s - 1)] == null)
- signal = true; // was empty
+ if (((s - base) & ~1) == 0) // size 0 or 1
+ signal = true;
}
}
return signal;
@@ -1010,30 +1014,25 @@
* queue, up to bound n (to avoid infinite unfairness).
*/
final void topLevelExec(ForkJoinTask<?> t, WorkQueue q, int n) {
- int nstolen = 1;
- for (int j = 0;;) {
- if (t != null)
+ if (t != null && q != null) { // hoist checks
+ int nstolen = 1;
+ for (;;) {
t.doExec();
- if (j++ <= n)
- t = nextLocalTask();
- else {
- j = 0;
- t = null;
+ if (n-- < 0)
+ break;
+ else if ((t = nextLocalTask()) == null) {
+ if ((t = q.poll()) == null)
+ break;
+ else
+ ++nstolen;
+ }
}
- if (t == null) {
- if (q != null && (t = q.poll()) != null) {
- ++nstolen;
- j = 0;
- }
- else if (j != 0)
- break;
- }
+ ForkJoinWorkerThread thread = owner;
+ nsteals += nstolen;
+ source = 0;
+ if (thread != null)
+ thread.afterTopLevelExec();
}
- ForkJoinWorkerThread thread = owner;
- nsteals += nstolen;
- source = 0;
- if (thread != null)
- thread.afterTopLevelExec();
}
/**
@@ -1456,7 +1455,7 @@
if (!tryTerminate(false, false) && // possibly replace worker
w != null && w.array != null) // avoid repeated failures
- signalWork(null);
+ signalWork();
if (ex == null) // help clean on way out
ForkJoinTask.helpExpungeStaleExceptions();
@@ -1466,9 +1465,8 @@
/**
* Tries to create or release a worker if too few are running.
- * @param q if non-null recheck if empty on CAS failure
*/
- final void signalWork(WorkQueue q) {
+ final void signalWork() {
for (;;) {
long c; int sp; WorkQueue[] ws; int i; WorkQueue v;
if ((c = ctl) >= 0L) // enough workers
@@ -1495,8 +1493,6 @@
LockSupport.unpark(vt);
break;
}
- else if (q != null && q.isEmpty()) // no need to retry
- break;
}
}
}
@@ -1617,24 +1613,19 @@
else if (rc <= 0 && (md & SHUTDOWN) != 0 &&
tryTerminate(false, false))
break; // quiescent shutdown
- else if (w.phase < 0) {
- if (rc <= 0 && pred != 0 && phase == (int)c) {
- long nc = (UC_MASK & (c - TC_UNIT)) | (SP_MASK & pred);
- long d = keepAlive + System.currentTimeMillis();
- LockSupport.parkUntil(this, d);
- if (ctl == c && // drop on timeout if all idle
- d - System.currentTimeMillis() <= TIMEOUT_SLOP &&
- CTL.compareAndSet(this, c, nc)) {
- w.phase = QUIET;
- break;
- }
- }
- else {
- LockSupport.park(this);
- if (w.phase < 0) // one spurious wakeup check
- LockSupport.park(this);
+ else if (rc <= 0 && pred != 0 && phase == (int)c) {
+ long nc = (UC_MASK & (c - TC_UNIT)) | (SP_MASK & pred);
+ long d = keepAlive + System.currentTimeMillis();
+ LockSupport.parkUntil(this, d);
+ if (ctl == c && // drop on timeout if all idle
+ d - System.currentTimeMillis() <= TIMEOUT_SLOP &&
+ CTL.compareAndSet(this, c, nc)) {
+ w.phase = QUIET;
+ break;
}
}
+ else if (w.phase < 0)
+ LockSupport.park(this); // OK if spuriously woken
w.source = 0; // disable signal
}
}
@@ -1650,8 +1641,8 @@
WorkQueue[] ws; int n;
if ((ws = workQueues) != null && (n = ws.length) > 0 && w != null) {
for (int m = n - 1, j = r & m;;) {
- WorkQueue q; int b, s;
- if ((q = ws[j]) != null && (s = q.top) != (b = q.base)) {
+ WorkQueue q; int b;
+ if ((q = ws[j]) != null && q.top != (b = q.base)) {
int qid = q.id;
ForkJoinTask<?>[] a; int cap, k; ForkJoinTask<?> t;
if ((a = q.array) != null && (cap = a.length) > 0) {
@@ -1660,10 +1651,10 @@
QA.compareAndSet(a, k, t, null)) {
q.base = b;
w.source = qid;
- if (s != b && a[(cap - 1) & b] != null)
- signalWork(q); // help signal if more tasks
+ if (q.top - b > 0)
+ signalWork();
w.topLevelExec(t, q, // random fairness bound
- (r | (1 << TOP_BOUND_SHIFT)) & SMASK);
+ r & ((n << TOP_BOUND_SHIFT) - 1));
}
}
return true;
@@ -1909,7 +1900,7 @@
r = ThreadLocalRandom.advanceProbe(r);
else {
if (q.lockedPush(task))
- signalWork(null);
+ signalWork();
return;
}
}
--- a/src/java.base/share/classes/java/util/regex/Pattern.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/java/util/regex/Pattern.java Tue Dec 18 15:08:56 2018 -0500
@@ -1390,7 +1390,7 @@
localTCNCount = 0;
// if length > 0, the Pattern is lazily compiled
- if (pattern.length() == 0) {
+ if (pattern.isEmpty()) {
root = new Start(lastAccept);
matchRoot = lastAccept;
compiled = true;
@@ -1423,7 +1423,7 @@
localCount = 0;
localTCNCount = 0;
- if (pattern.length() > 0) {
+ if (!pattern.isEmpty()) {
compile();
} else {
root = new Start(lastAccept);
--- a/src/java.base/share/classes/javax/crypto/Cipher.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/crypto/Cipher.java Tue Dec 18 15:08:56 2018 -0500
@@ -341,7 +341,7 @@
throw new NoSuchAlgorithmException("Invalid transformation " +
"format:" + transformation);
}
- if ((parts[0] == null) || (parts[0].length() == 0)) {
+ if ((parts[0] == null) || (parts[0].isEmpty())) {
throw new NoSuchAlgorithmException("Invalid transformation:" +
"algorithm not specified-"
+ transformation);
@@ -445,10 +445,10 @@
String alg = parts[0];
String mode = parts[1];
String pad = parts[2];
- if ((mode != null) && (mode.length() == 0)) {
+ if ((mode != null) && (mode.isEmpty())) {
mode = null;
}
- if ((pad != null) && (pad.length() == 0)) {
+ if ((pad != null) && (pad.isEmpty())) {
pad = null;
}
@@ -634,7 +634,7 @@
if ((transformation == null) || transformation.isEmpty()) {
throw new NoSuchAlgorithmException("Null or empty transformation");
}
- if ((provider == null) || (provider.length() == 0)) {
+ if ((provider == null) || (provider.isEmpty())) {
throw new IllegalArgumentException("Missing provider");
}
Provider p = Security.getProvider(provider);
--- a/src/java.base/share/classes/javax/crypto/SealedObject.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/crypto/SealedObject.java Tue Dec 18 15:08:56 2018 -0500
@@ -337,7 +337,7 @@
if (key == null) {
throw new NullPointerException("key is null");
}
- if (provider == null || provider.length() == 0) {
+ if (provider == null || provider.isEmpty()) {
throw new IllegalArgumentException("missing provider");
}
--- a/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java Tue Dec 18 15:08:56 2018 -0500
@@ -133,7 +133,7 @@
String s = java.security.Security.getProperty(name);
if (s != null) {
s = s.trim();
- if (s.length() == 0) {
+ if (s.isEmpty()) {
s = null;
}
}
--- a/src/java.base/share/classes/javax/security/auth/PrivateCredentialPermission.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/auth/PrivateCredentialPermission.java Tue Dec 18 15:08:56 2018 -0500
@@ -312,7 +312,7 @@
private void init(String name) {
- if (name == null || name.trim().length() == 0) {
+ if (name == null || name.trim().isEmpty()) {
throw new IllegalArgumentException("invalid empty name");
}
--- a/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java Tue Dec 18 15:08:56 2018 -0500
@@ -98,13 +98,13 @@
public ChoiceCallback(String prompt, String[] choices,
int defaultChoice, boolean multipleSelectionsAllowed) {
- if (prompt == null || prompt.length() == 0 ||
+ if (prompt == null || prompt.isEmpty() ||
choices == null || choices.length == 0 ||
defaultChoice < 0 || defaultChoice >= choices.length)
throw new IllegalArgumentException();
for (int i = 0; i < choices.length; i++) {
- if (choices[i] == null || choices[i].length() == 0)
+ if (choices[i] == null || choices[i].isEmpty())
throw new IllegalArgumentException();
}
--- a/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java Tue Dec 18 15:08:56 2018 -0500
@@ -248,7 +248,7 @@
throw new IllegalArgumentException();
for (int i = 0; i < options.length; i++) {
- if (options[i] == null || options[i].length() == 0)
+ if (options[i] == null || options[i].isEmpty())
throw new IllegalArgumentException();
}
@@ -294,7 +294,7 @@
public ConfirmationCallback(String prompt, int messageType,
int optionType, int defaultOption) {
- if (prompt == null || prompt.length() == 0 ||
+ if (prompt == null || prompt.isEmpty() ||
messageType < INFORMATION || messageType > ERROR ||
optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION)
throw new IllegalArgumentException();
@@ -357,14 +357,14 @@
public ConfirmationCallback(String prompt, int messageType,
String[] options, int defaultOption) {
- if (prompt == null || prompt.length() == 0 ||
+ if (prompt == null || prompt.isEmpty() ||
messageType < INFORMATION || messageType > ERROR ||
options == null || options.length == 0 ||
defaultOption < 0 || defaultOption >= options.length)
throw new IllegalArgumentException();
for (int i = 0; i < options.length; i++) {
- if (options[i] == null || options[i].length() == 0)
+ if (options[i] == null || options[i].isEmpty())
throw new IllegalArgumentException();
}
--- a/src/java.base/share/classes/javax/security/auth/callback/NameCallback.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/auth/callback/NameCallback.java Tue Dec 18 15:08:56 2018 -0500
@@ -62,7 +62,7 @@
* or if {@code prompt} has a length of 0.
*/
public NameCallback(String prompt) {
- if (prompt == null || prompt.length() == 0)
+ if (prompt == null || prompt.isEmpty())
throw new IllegalArgumentException();
this.prompt = prompt;
}
@@ -82,8 +82,8 @@
* or if {@code defaultName} has a length of 0.
*/
public NameCallback(String prompt, String defaultName) {
- if (prompt == null || prompt.length() == 0 ||
- defaultName == null || defaultName.length() == 0)
+ if (prompt == null || prompt.isEmpty() ||
+ defaultName == null || defaultName.isEmpty())
throw new IllegalArgumentException();
this.prompt = prompt;
--- a/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java Tue Dec 18 15:08:56 2018 -0500
@@ -67,7 +67,7 @@
* if {@code prompt} has a length of 0.
*/
public PasswordCallback(String prompt, boolean echoOn) {
- if (prompt == null || prompt.length() == 0)
+ if (prompt == null || prompt.isEmpty())
throw new IllegalArgumentException();
this.prompt = prompt;
--- a/src/java.base/share/classes/javax/security/auth/callback/TextInputCallback.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/auth/callback/TextInputCallback.java Tue Dec 18 15:08:56 2018 -0500
@@ -63,7 +63,7 @@
* or if {@code prompt} has a length of 0.
*/
public TextInputCallback(String prompt) {
- if (prompt == null || prompt.length() == 0)
+ if (prompt == null || prompt.isEmpty())
throw new IllegalArgumentException();
this.prompt = prompt;
}
@@ -83,8 +83,8 @@
* or if {@code defaultText} has a length of 0.
*/
public TextInputCallback(String prompt, String defaultText) {
- if (prompt == null || prompt.length() == 0 ||
- defaultText == null || defaultText.length() == 0)
+ if (prompt == null || prompt.isEmpty() ||
+ defaultText == null || defaultText.isEmpty())
throw new IllegalArgumentException();
this.prompt = prompt;
--- a/src/java.base/share/classes/javax/security/auth/callback/TextOutputCallback.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/auth/callback/TextOutputCallback.java Tue Dec 18 15:08:56 2018 -0500
@@ -74,7 +74,7 @@
public TextOutputCallback(int messageType, String message) {
if ((messageType != INFORMATION &&
messageType != WARNING && messageType != ERROR) ||
- message == null || message.length() == 0)
+ message == null || message.isEmpty())
throw new IllegalArgumentException();
this.messageType = messageType;
--- a/src/java.base/share/classes/javax/security/auth/login/AppConfigurationEntry.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/auth/login/AppConfigurationEntry.java Tue Dec 18 15:08:56 2018 -0500
@@ -75,7 +75,7 @@
LoginModuleControlFlag controlFlag,
Map<String,?> options)
{
- if (loginModuleName == null || loginModuleName.length() == 0 ||
+ if (loginModuleName == null || loginModuleName.isEmpty() ||
(controlFlag != LoginModuleControlFlag.REQUIRED &&
controlFlag != LoginModuleControlFlag.REQUISITE &&
controlFlag != LoginModuleControlFlag.SUFFICIENT &&
--- a/src/java.base/share/classes/javax/security/auth/login/Configuration.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/auth/login/Configuration.java Tue Dec 18 15:08:56 2018 -0500
@@ -418,7 +418,7 @@
throws NoSuchProviderException, NoSuchAlgorithmException {
Objects.requireNonNull(type, "null type name");
- if (provider == null || provider.length() == 0) {
+ if (provider == null || provider.isEmpty()) {
throw new IllegalArgumentException("missing provider");
}
--- a/src/java.base/share/classes/javax/security/auth/login/LoginContext.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/auth/login/LoginContext.java Tue Dec 18 15:08:56 2018 -0500
@@ -300,7 +300,7 @@
public CallbackHandler run() throws Exception {
String defaultHandler = java.security.Security.getProperty
(DEFAULT_HANDLER);
- if (defaultHandler == null || defaultHandler.length() == 0)
+ if (defaultHandler == null || defaultHandler.isEmpty())
return null;
Class<? extends CallbackHandler> c = Class.forName(
defaultHandler, true,
--- a/src/java.base/share/classes/javax/security/cert/X509Certificate.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/javax/security/cert/X509Certificate.java Tue Dec 18 15:08:56 2018 -0500
@@ -210,7 +210,7 @@
* under JDK1.1.
*/
String className = X509Provider;
- if (className == null || className.length() == 0) {
+ if (className == null || className.isEmpty()) {
// shouldn't happen, but assume corrupted properties file
// provide access to sun implementation
className = "com.sun.security.cert.internal.x509.X509V1CertImpl";
--- a/src/java.base/share/classes/jdk/internal/event/EventHelper.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/event/EventHelper.java Tue Dec 18 15:08:56 2018 -0500
@@ -101,6 +101,9 @@
*/
private static String getDurationString(Instant start) {
if (start != null) {
+ if (start.equals(Instant.MIN)) {
+ return "N/A";
+ }
Duration duration = Duration.between(start, Instant.now());
long micros = duration.toNanos() / 1_000;
if (micros < 1_000_000) {
--- a/src/java.base/share/classes/jdk/internal/jimage/decompressor/SignatureParser.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/jimage/decompressor/SignatureParser.java Tue Dec 18 15:08:56 2018 -0500
@@ -60,7 +60,7 @@
switch (c) {
case 'L': {
String pkg = arguments.get(arg_index);
- if(pkg.length() > 0) {
+ if(!pkg.isEmpty()) {
out.append(pkg).append("/");
}
arg_index+=1;
--- a/src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java Tue Dec 18 15:08:56 2018 -0500
@@ -168,7 +168,7 @@
int index = indices.get(argIndex);
argIndex += 1;
String pkg = reader.getString(index);
- if (pkg.length() > 0) {
+ if (!pkg.isEmpty()) {
pkg = pkg + "/";
byte[] encoded = getEncoded(pkg);
buffer = safeAdd(buffer, encoded);
--- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java Tue Dec 18 15:08:56 2018 -0500
@@ -123,7 +123,7 @@
StringBuilder sb = new StringBuilder();
sb.append(first);
for (String path : more) {
- if (path.length() > 0) {
+ if (!path.isEmpty()) {
if (sb.length() > 0) {
sb.append('/');
}
--- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java Tue Dec 18 15:08:56 2018 -0500
@@ -88,7 +88,7 @@
@Override
public final JrtPath getFileName() {
- if (path.length() == 0)
+ if (path.isEmpty())
return this;
if (path.length() == 1 && path.charAt(0) == '/')
return null;
@@ -210,7 +210,7 @@
if (o.equals(this)) {
return new JrtPath(jrtfs, "", true);
}
- if (path.length() == 0) {
+ if (path.isEmpty()) {
return o;
}
if (jrtfs != o.jrtfs || isAbsolute() != o.isAbsolute()) {
@@ -262,16 +262,16 @@
@Override
public final boolean isAbsolute() {
- return path.length() > 0 && path.charAt(0) == '/';
+ return !path.isEmpty() && path.charAt(0) == '/';
}
@Override
public final JrtPath resolve(Path other) {
final JrtPath o = checkPath(other);
- if (this.path.length() == 0 || o.isAbsolute()) {
+ if (this.path.isEmpty() || o.isAbsolute()) {
return o;
}
- if (o.path.length() == 0) {
+ if (o.path.isEmpty()) {
return this;
}
StringBuilder sb = new StringBuilder(path.length() + o.path.length() + 1);
@@ -301,7 +301,7 @@
}
int off = op.length();
if (off == 0) {
- return tp.length() == 0;
+ return tp.isEmpty();
}
// check match is on name boundary
return tp.length() == off || tp.charAt(off) == '/' ||
--- a/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java Tue Dec 18 15:08:56 2018 -0500
@@ -59,7 +59,7 @@
// -Xbootclasspath/a or -javaagent with Boot-Class-Path attribute
String append = VM.getSavedProperty("jdk.boot.class.path.append");
BOOT_LOADER =
- new BootClassLoader((append != null && append.length() > 0)
+ new BootClassLoader((append != null && !append.isEmpty())
? new URLClassPath(append, true)
: null);
PLATFORM_LOADER = new PlatformClassLoader(BOOT_LOADER);
@@ -70,7 +70,7 @@
// contrary, we drop this historic interpretation of the empty
// string and instead treat it as unspecified.
String cp = System.getProperty("java.class.path");
- if (cp == null || cp.length() == 0) {
+ if (cp == null || cp.isEmpty()) {
String initialModuleName = System.getProperty("jdk.module.main");
cp = (initialModuleName == null) ? "" : null;
}
--- a/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java Tue Dec 18 15:08:56 2018 -0500
@@ -190,7 +190,7 @@
String element = (next == -1)
? cp.substring(off)
: cp.substring(off, next);
- if (element.length() > 0 || !skipEmptyElements) {
+ if (!element.isEmpty() || !skipEmptyElements) {
URL url = toFileURL(element);
if (url != null) path.add(url);
}
--- a/src/java.base/share/classes/jdk/internal/module/Checks.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/module/Checks.java Tue Dec 18 15:08:56 2018 -0500
@@ -63,22 +63,6 @@
}
/**
- * Returns {@code true} if the given name is a legal module name.
- */
- public static boolean isModuleName(String name) {
- int next;
- int off = 0;
- while ((next = name.indexOf('.', off)) != -1) {
- String id = name.substring(off, next);
- if (!isJavaIdentifier(id))
- return false;
- off = next+1;
- }
- String last = name.substring(off);
- return isJavaIdentifier(last);
- }
-
- /**
* Checks a name to ensure that it's a legal package name.
*
* @throws IllegalArgumentException if name is null or not a legal
@@ -181,20 +165,20 @@
}
/**
- * Returns true if the given char sequence is a legal Java identifier,
+ * Returns true if the given string is a legal Java identifier,
* otherwise false.
*/
- private static boolean isJavaIdentifier(CharSequence cs) {
- if (cs.length() == 0 || RESERVED.contains(cs))
+ private static boolean isJavaIdentifier(String str) {
+ if (str.isEmpty() || RESERVED.contains(str))
return false;
- int first = Character.codePointAt(cs, 0);
+ int first = Character.codePointAt(str, 0);
if (!Character.isJavaIdentifierStart(first))
return false;
int i = Character.charCount(first);
- while (i < cs.length()) {
- int cp = Character.codePointAt(cs, i);
+ while (i < str.length()) {
+ int cp = Character.codePointAt(str, i);
if (!Character.isJavaIdentifierPart(cp))
return false;
i += Character.charCount(cp);
--- a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java Tue Dec 18 15:08:56 2018 -0500
@@ -604,7 +604,8 @@
Set<String> modules = new HashSet<>();
while (value != null) {
for (String s : value.split(",")) {
- if (s.length() > 0) modules.add(s);
+ if (!s.isEmpty())
+ modules.add(s);
}
index++;
value = getAndRemoveProperty(prefix + index);
@@ -895,7 +896,7 @@
List<String> values = map.computeIfAbsent(key, k -> new ArrayList<>());
int ntargets = 0;
for (String s : rhs.split(regex)) {
- if (s.length() > 0) {
+ if (!s.isEmpty()) {
values.add(s);
ntargets++;
}
--- a/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java Tue Dec 18 15:08:56 2018 -0500
@@ -63,7 +63,7 @@
public final class ModuleInfo {
private final int JAVA_MIN_SUPPORTED_VERSION = 53;
- private final int JAVA_MAX_SUPPORTED_VERSION = 56;
+ private final int JAVA_MAX_SUPPORTED_VERSION = 57;
private static final JavaLangModuleAccess JLMA
= SharedSecrets.getJavaLangModuleAccess();
--- a/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java Tue Dec 18 15:08:56 2018 -0500
@@ -552,7 +552,7 @@
public Stream<String> list() throws IOException {
return Files.walk(dir, Integer.MAX_VALUE)
.map(f -> Resources.toResourceName(dir, f))
- .filter(s -> s.length() > 0);
+ .filter(s -> !s.isEmpty());
}
}
--- a/src/java.base/share/classes/jdk/internal/module/ModulePath.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/module/ModulePath.java Tue Dec 18 15:08:56 2018 -0500
@@ -546,7 +546,7 @@
= new BufferedReader(new InputStreamReader(in, "UTF-8"));
String cn;
while ((cn = nextLine(reader)) != null) {
- if (cn.length() > 0) {
+ if (!cn.isEmpty()) {
String pn = packageName(cn);
if (!packages.contains(pn)) {
String msg = "Provider class " + cn + " not in module";
@@ -599,7 +599,7 @@
mn = Patterns.REPEATING_DOTS.matcher(mn).replaceAll(".");
// drop leading dots
- if (mn.length() > 0 && mn.charAt(0) == '.')
+ if (!mn.isEmpty() && mn.charAt(0) == '.')
mn = Patterns.LEADING_DOTS.matcher(mn).replaceAll("");
// drop trailing dots
--- a/src/java.base/share/classes/jdk/internal/module/Resources.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/module/Resources.java Tue Dec 18 15:08:56 2018 -0500
@@ -78,7 +78,7 @@
String s = dir.relativize(file)
.toString()
.replace(File.separatorChar, '/');
- if (s.length() > 0 && Files.isDirectory(file))
+ if (!s.isEmpty() && Files.isDirectory(file))
s += "/";
return s;
}
--- a/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java Tue Dec 18 15:08:56 2018 -0500
@@ -83,7 +83,7 @@
if (value == null) {
USE_FAST_PATH = true;
} else {
- USE_FAST_PATH = (value.length() > 0) && !Boolean.parseBoolean(value);
+ USE_FAST_PATH = !value.isEmpty() && !Boolean.parseBoolean(value);
}
}
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java Tue Dec 18 15:08:56 2018 -0500
@@ -210,7 +210,7 @@
b = classFileBuffer;
// Check the class' major_version. This field is after the magic and minor_version fields, which
// use 4 and 2 bytes respectively.
- if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V12) {
+ if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V13) {
throw new IllegalArgumentException(
"Unsupported class file major version " + readShort(classFileOffset + 6));
}
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java Tue Dec 18 15:08:56 2018 -0500
@@ -95,6 +95,7 @@
int V10 = 0 << 16 | 54;
int V11 = 0 << 16 | 55;
int V12 = 0 << 16 | 56;
+ int V13 = 0 << 16 | 57;
/**
* Version flag indicating that the class is using 'preview' features.
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java Tue Dec 18 15:08:56 2018 -0500
@@ -147,7 +147,7 @@
* @return the corresponding TypePath object, or {@literal null} if the path is empty.
*/
public static TypePath fromString(final String typePath) {
- if (typePath == null || typePath.length() == 0) {
+ if (typePath == null || typePath.isEmpty()) {
return null;
}
int typePathLength = typePath.length();
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java Tue Dec 18 15:08:56 2018 -0500
@@ -1314,7 +1314,7 @@
* @param message the message to use in case of error.
*/
static void checkMethodIdentifier(final int version, final String name, final String message) {
- if (name == null || name.length() == 0) {
+ if (name == null || name.isEmpty()) {
throw new IllegalArgumentException(INVALID + message + MUST_NOT_BE_NULL_OR_EMPTY);
}
if ((version & 0xFFFF) >= Opcodes.V1_5) {
@@ -1347,7 +1347,7 @@
* @param message the message to use in case of error.
*/
static void checkInternalName(final int version, final String name, final String message) {
- if (name == null || name.length() == 0) {
+ if (name == null || name.isEmpty()) {
throw new IllegalArgumentException(INVALID + message + MUST_NOT_BE_NULL_OR_EMPTY);
}
if (name.charAt(0) == '[') {
@@ -1457,7 +1457,7 @@
* @param descriptor the string to be checked.
*/
static void checkMethodDescriptor(final int version, final String descriptor) {
- if (descriptor == null || descriptor.length() == 0) {
+ if (descriptor == null || descriptor.isEmpty()) {
throw new IllegalArgumentException("Invalid method descriptor (must not be null or empty)");
}
if (descriptor.charAt(0) != '(' || descriptor.length() < 3) {
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java Tue Dec 18 15:08:56 2018 -0500
@@ -365,7 +365,7 @@
}
private void checkClassName(final String name, final String message) {
- if (name == null || name.length() == 0) {
+ if (name == null || name.isEmpty()) {
throw new IllegalArgumentException(INVALID + message + " (must not be null or empty)");
}
for (int i = 0; i < name.length(); ++i) {
@@ -377,7 +377,7 @@
}
private void checkIdentifier(final String name, final String message) {
- if (name == null || name.length() == 0) {
+ if (name == null || name.isEmpty()) {
throw new IllegalArgumentException(INVALID + message + " (must not be null or empty)");
}
for (int i = 0; i < name.length(); ++i) {
--- a/src/java.base/share/classes/jdk/internal/reflect/Reflection.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/reflect/Reflection.java Tue Dec 18 15:08:56 2018 -0500
@@ -56,6 +56,7 @@
Constructor.class, ALL_MEMBERS,
Field.class, ALL_MEMBERS,
Method.class, ALL_MEMBERS,
+ Module.class, ALL_MEMBERS,
System.class, Set.of("security")
);
methodFilterMap = Map.of();
--- a/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -151,10 +151,10 @@
if (isFinal)
err += " final";
err += " " + field.getType().getName() + " field " + getQualifiedFieldName() + " to ";
- if (attemptedValue.length() > 0) {
+ if (!attemptedValue.isEmpty()) {
err += "(" + attemptedType + ")" + attemptedValue;
} else {
- if (attemptedType.length() > 0)
+ if (!attemptedType.isEmpty())
err += attemptedType;
else
err += "null value";
--- a/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java Tue Dec 18 15:08:56 2018 -0500
@@ -291,7 +291,7 @@
while((line = br.readLine()) != null && !line.endsWith(".jar"));
for(;line != null; line = br.readLine()) {
- if (line.length() == 0)
+ if (line.isEmpty())
continue;
if (line.endsWith(".jar")) {
--- a/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java Tue Dec 18 15:08:56 2018 -0500
@@ -103,7 +103,7 @@
writer.writeStartDocument();
writer.writeDTD(PROPS_DTD_DECL);
writer.writeStartElement(ELEMENT_ROOT);
- if (comment != null && comment.length() > 0) {
+ if (comment != null && !comment.isEmpty()) {
writer.writeStartElement(ELEMENT_COMMENT);
writer.writeCharacters(comment);
writer.writeEndElement();
--- a/src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java Tue Dec 18 15:08:56 2018 -0500
@@ -1591,7 +1591,7 @@
str = name(false);
// PI target name may not be empty string [#2.6]
// PI target name 'XML' is reserved [#2.6]
- if ((str.length() == 0)
+ if ((str.isEmpty())
|| (mXml.name.equals(str.toLowerCase()) == true)) {
panic(FAULT);
}
--- a/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -205,7 +205,7 @@
* @throws XMLStreamException
*/
public void writeStartElement(String localName) throws XMLStreamException {
- if (localName == null || localName.length() == 0) {
+ if (localName == null || localName.isEmpty()) {
throw new XMLStreamException("Local Name cannot be null or empty");
}
@@ -420,7 +420,7 @@
}
private void writeXMLContent(String content) throws XMLStreamException {
- if ((content != null) && (content.length() > 0)) {
+ if (content != null && !content.isEmpty()) {
writeXMLContent(content,
_escapeCharacters, // boolean = escapeChars
false); // false = escapeDoubleQuotes
--- a/src/java.base/share/classes/sun/invoke/util/BytecodeName.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/invoke/util/BytecodeName.java Tue Dec 18 15:08:56 2018 -0500
@@ -451,7 +451,7 @@
* @return true if the name is non-empty and all of its characters are safe
*/
public static boolean isSafeBytecodeName(String s) {
- if (s.length() == 0) return false;
+ if (s.isEmpty()) return false;
// check occurrences of each DANGEROUS char
for (char xc : DANGEROUS_CHARS_A) {
if (xc == ESCAPE_C) continue; // not really that dangerous
@@ -476,7 +476,7 @@
}
private static String mangle(String s) {
- if (s.length() == 0)
+ if (s.isEmpty())
return NULL_ESCAPE;
// build this lazily, when we first need an escape:
--- a/src/java.base/share/classes/sun/net/TransferProtocolClient.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/TransferProtocolClient.java Tue Dec 18 15:08:56 2018 -0500
@@ -76,7 +76,7 @@
System.out.print(response);
}
- if (response.length() == 0) {
+ if (response.isEmpty()) {
code = -1;
} else {
try {
--- a/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java Tue Dec 18 15:08:56 2018 -0500
@@ -433,7 +433,7 @@
logger.finest("Server [" + serverAddr + "] --> " + response);
}
- if (response.length() == 0) {
+ if (response.isEmpty()) {
code = -1;
} else {
try {
@@ -1049,7 +1049,7 @@
if (!isConnected()) {
throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
}
- if (user == null || user.length() == 0) {
+ if (user == null || user.isEmpty()) {
throw new IllegalArgumentException("User name can't be null or empty");
}
tryLogin(user, password);
@@ -1088,7 +1088,7 @@
if (!isConnected()) {
throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
}
- if (user == null || user.length() == 0) {
+ if (user == null || user.isEmpty()) {
throw new IllegalArgumentException("User name can't be null or empty");
}
tryLogin(user, password);
@@ -1152,7 +1152,7 @@
* @exception <code>FtpProtocolException</code>
*/
public sun.net.ftp.FtpClient changeDirectory(String remoteDirectory) throws sun.net.ftp.FtpProtocolException, IOException {
- if (remoteDirectory == null || "".equals(remoteDirectory)) {
+ if (remoteDirectory == null || remoteDirectory.isEmpty()) {
throw new IllegalArgumentException("directory can't be null or empty");
}
@@ -1738,7 +1738,7 @@
* @throws IOException if an error occurs during the transmission.
*/
public long getSize(String path) throws sun.net.ftp.FtpProtocolException, IOException {
- if (path == null || path.length() == 0) {
+ if (path == null || path.isEmpty()) {
throw new IllegalArgumentException("path can't be null or empty");
}
issueCommandCheck("SIZE " + path);
--- a/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java Tue Dec 18 15:08:56 2018 -0500
@@ -238,7 +238,7 @@
if (phost != null && phost.length() != 0)
break;
}
- if (phost == null || phost.length() == 0) {
+ if (phost == null || phost.isEmpty()) {
/**
* No system property defined for that
* protocol. Let's check System Proxy
@@ -267,7 +267,7 @@
nprop.hostsSource = null;
nprop.pattern = null;
}
- } else if (nphosts.length() != 0) {
+ } else if (!nphosts.isEmpty()) {
// add the required default patterns
// but only if property no set. If it
// is empty, leave empty.
--- a/src/java.base/share/classes/sun/net/www/HeaderParser.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/HeaderParser.java Tue Dec 18 15:08:56 2018 -0500
@@ -226,7 +226,7 @@
for (int i=0; k.hasNext(); i++) {
String key = k.next();
String val = findValue (i);
- if (val != null && "".equals (val)) {
+ if (val != null && val.isEmpty()) {
val = null;
}
sb.append(" {").append(key).append(val == null ? "" : "," + val)
--- a/src/java.base/share/classes/sun/net/www/MimeEntry.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/MimeEntry.java Tue Dec 18 15:08:56 2018 -0500
@@ -201,9 +201,7 @@
}
private boolean isStarred(String typeName) {
- return (typeName != null)
- && (typeName.length() > 0)
- && (typeName.endsWith("/*"));
+ return typeName != null && typeName.endsWith("/*");
}
/**
@@ -300,7 +298,7 @@
}
String extensions = getExtensionsAsList();
- if (extensions.length() > 0) {
+ if (!extensions.isEmpty()) {
sj.add("file_extensions=" + extensions);
}
--- a/src/java.base/share/classes/sun/net/www/MimeLauncher.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/MimeLauncher.java Tue Dec 18 15:08:56 2018 -0500
@@ -162,7 +162,7 @@
location the application. If a valid path is not found, it
returns false else true. */
private boolean findExecutablePath(String str) {
- if (str == null || str.length() == 0) {
+ if (str == null || str.isEmpty()) {
return false;
}
--- a/src/java.base/share/classes/sun/net/www/ParseUtil.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/ParseUtil.java Tue Dec 18 15:08:56 2018 -0500
@@ -536,8 +536,7 @@
throws URISyntaxException
{
if (scheme != null) {
- if ((path != null)
- && ((path.length() > 0) && (path.charAt(0) != '/')))
+ if (path != null && !path.isEmpty() && path.charAt(0) != '/')
throw new URISyntaxException(s,
"Relative path in absolute URI");
}
--- a/src/java.base/share/classes/sun/net/www/http/HttpClient.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/http/HttpClient.java Tue Dec 18 15:08:56 2018 -0500
@@ -603,7 +603,7 @@
StringBuilder result = new StringBuilder(128);
result.append(url.getProtocol());
result.append(":");
- if (url.getAuthority() != null && url.getAuthority().length() > 0) {
+ if (url.getAuthority() != null && !url.getAuthority().isEmpty()) {
result.append("//");
result.append(url.getAuthority());
}
@@ -619,7 +619,7 @@
} else {
fileName = url.getFile();
- if ((fileName == null) || (fileName.length() == 0)) {
+ if ((fileName == null) || (fileName.isEmpty())) {
fileName = "/";
} else if (fileName.charAt(0) == '?') {
/* HTTP/1.1 spec says in 5.1.2. about Request-URI:
--- a/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java Tue Dec 18 15:08:56 2018 -0500
@@ -341,7 +341,7 @@
path.charAt(0) == '/') {
path = path.substring(1);
}
- if (path == null || path.length() == 0) {
+ if (path == null || path.isEmpty()) {
path = "./";
}
if (!path.endsWith("/")) {
@@ -555,7 +555,7 @@
}
decodePath(url.getPath());
- if (filename == null || filename.length() == 0) {
+ if (filename == null || filename.isEmpty()) {
throw new IOException("illegal filename for a PUT");
}
try {
--- a/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java Tue Dec 18 15:08:56 2018 -0500
@@ -248,7 +248,7 @@
this.realm = realm;
String urlPath = url.getPath();
- if (urlPath.length() == 0)
+ if (urlPath.isEmpty())
this.path = urlPath;
else {
this.path = reducePath (urlPath);
--- a/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java Tue Dec 18 15:08:56 2018 -0500
@@ -279,7 +279,7 @@
if (s == null || !s.equals("true"))
return false;
String newNonce = p.findValue ("nonce");
- if (newNonce == null || "".equals(newNonce)) {
+ if (newNonce == null || newNonce.isEmpty()) {
return false;
}
params.setNonce (newNonce);
@@ -323,7 +323,7 @@
+ authMethod.substring(1).toLowerCase();
}
String algorithm = p.findValue("algorithm");
- if (algorithm == null || "".equals(algorithm)) {
+ if (algorithm == null || algorithm.isEmpty()) {
algorithm = "MD5"; // The default, accoriding to rfc2069
}
params.setAlgorithm (algorithm);
@@ -451,7 +451,7 @@
}
/* Check if there is a nextnonce field */
String nextnonce = p.findValue ("nextnonce");
- if (nextnonce != null && ! "".equals(nextnonce)) {
+ if (nextnonce != null && !nextnonce.isEmpty()) {
params.setNonce (nextnonce);
}
--- a/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Tue Dec 18 15:08:56 2018 -0500
@@ -3026,7 +3026,7 @@
// Filtering only if there is a cookie handler. [Assumption: the
// cookie handler will store/retrieve the HttpOnly cookies]
- if (cookieHandler == null || value.length() == 0)
+ if (cookieHandler == null || value.isEmpty())
return value;
JavaNetHttpCookieAccess access =
--- a/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java Tue Dec 18 15:08:56 2018 -0500
@@ -143,7 +143,7 @@
String cipherString =
GetPropertyAction.privilegedGetProperty("https.cipherSuites");
- if (cipherString == null || "".equals(cipherString)) {
+ if (cipherString == null || cipherString.isEmpty()) {
ciphers = null;
} else {
StringTokenizer tokenizer;
@@ -167,7 +167,7 @@
String protocolString =
GetPropertyAction.privilegedGetProperty("https.protocols");
- if (protocolString == null || "".equals(protocolString)) {
+ if (protocolString == null || protocolString.isEmpty()) {
protocols = null;
} else {
StringTokenizer tokenizer;
@@ -187,7 +187,7 @@
private String getUserAgent() {
String userAgent =
GetPropertyAction.privilegedGetProperty("https.agent");
- if (userAgent == null || userAgent.length() == 0) {
+ if (userAgent == null || userAgent.isEmpty()) {
userAgent = "JSSE";
}
return userAgent;
--- a/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java Tue Dec 18 15:08:56 2018 -0500
@@ -66,7 +66,7 @@
JavaRuntimeURLConnection(URL url) throws IOException {
super(url);
String path = url.getPath();
- if (path.length() == 0 || path.charAt(0) != '/')
+ if (path.isEmpty() || path.charAt(0) != '/')
throw new MalformedURLException(url + " missing path or /");
if (path.length() == 1) {
this.module = null;
--- a/src/java.base/share/classes/sun/nio/ch/Net.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/nio/ch/Net.java Tue Dec 18 15:08:56 2018 -0500
@@ -403,14 +403,8 @@
public static boolean isFastTcpLoopbackRequested() {
String loopbackProp = GetPropertyAction
- .privilegedGetProperty("jdk.net.useFastTcpLoopback");
- boolean enable;
- if ("".equals(loopbackProp)) {
- enable = true;
- } else {
- enable = Boolean.parseBoolean(loopbackProp);
- }
- return enable;
+ .privilegedGetProperty("jdk.net.useFastTcpLoopback", "false");
+ return loopbackProp.isEmpty() ? true : Boolean.parseBoolean(loopbackProp);
}
// -- Socket operations --
--- a/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java Tue Dec 18 15:08:56 2018 -0500
@@ -73,7 +73,7 @@
throws IOException
{
String[] s = split(attribute);
- if (s[0].length() == 0)
+ if (s[0].isEmpty())
throw new IllegalArgumentException(attribute);
DynamicFileAttributeView view = getFileAttributeView(file, s[0], options);
if (view == null)
@@ -86,7 +86,7 @@
throws IOException
{
String[] s = split(attributes);
- if (s[0].length() == 0)
+ if (s[0].isEmpty())
throw new IllegalArgumentException(attributes);
DynamicFileAttributeView view = getFileAttributeView(file, s[0], options);
if (view == null)
--- a/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java Tue Dec 18 15:08:56 2018 -0500
@@ -83,7 +83,7 @@
names = list();
break;
} else {
- if (name.length() == 0)
+ if (name.isEmpty())
throw new IllegalArgumentException();
names.add(name);
}
--- a/src/java.base/share/classes/sun/security/jca/GetInstance.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/jca/GetInstance.java Tue Dec 18 15:08:56 2018 -0500
@@ -75,7 +75,7 @@
public static Service getService(String type, String algorithm,
String provider) throws NoSuchAlgorithmException,
NoSuchProviderException {
- if ((provider == null) || (provider.length() == 0)) {
+ if (provider == null || provider.isEmpty()) {
throw new IllegalArgumentException("missing provider");
}
Provider p = Providers.getProviderList().getProvider(provider);
--- a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java Tue Dec 18 15:08:56 2018 -0500
@@ -114,7 +114,7 @@
}
private boolean hasArgument() {
- return argument.length() != 0;
+ return !argument.isEmpty();
}
// should we try to load this provider?
--- a/src/java.base/share/classes/sun/security/jca/ProviderList.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/jca/ProviderList.java Tue Dec 18 15:08:56 2018 -0500
@@ -175,7 +175,7 @@
while ((entry = Security.getProperty("security.provider." + i)) != null) {
entry = entry.trim();
- if (entry.length() == 0) {
+ if (entry.isEmpty()) {
System.err.println("invalid entry for " +
"security.provider." + i);
break;
@@ -200,7 +200,7 @@
// Load config entries for use when getInstance is called
entry = Security.getProperty("jdk.security.provider.preferred");
- if (entry != null && (entry = entry.trim()).length() > 0) {
+ if (entry != null && !(entry = entry.trim()).isEmpty()) {
String[] entries = entry.split(",");
if (ProviderList.preferredPropList == null) {
ProviderList.preferredPropList = new PreferredList();
--- a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java Tue Dec 18 15:08:56 2018 -0500
@@ -53,7 +53,6 @@
import java.security.AlgorithmParameters;
import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
import javax.crypto.spec.PBEParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
@@ -70,6 +69,7 @@
import sun.security.util.DerValue;
import sun.security.util.ObjectIdentifier;
import sun.security.pkcs.ContentInfo;
+import sun.security.util.SecurityProperties;
import sun.security.x509.AlgorithmId;
import sun.security.pkcs.EncryptedPrivateKeyInfo;
import sun.security.provider.JavaKeyStore.JKS;
@@ -81,9 +81,11 @@
* Implements the PKCS#12 PFX protected using the Password privacy mode.
* The contents are protected using Password integrity mode.
*
- * Currently we support following PBE algorithms:
- * - pbeWithSHAAnd3KeyTripleDESCBC to encrypt private keys
- * - pbeWithSHAAnd40BitRC2CBC to encrypt certificates
+ * Currently these PBE algorithms are used by default:
+ * - PBEWithSHA1AndDESede to encrypt private keys, iteration count 50000.
+ * - PBEWithSHA1AndRC2_40 to encrypt certificates, iteration count 50000.
+ *
+ * The default Mac algorithm is HmacPBESHA1, iteration count 100000.
*
* Supported encryption of various implementations :
*
@@ -126,11 +128,7 @@
* @author Jeff Nisewanger
* @author Jan Luehe
*
- * @see KeyProtector
* @see java.security.KeyStoreSpi
- * @see KeyTool
- *
- *
*/
public final class PKCS12KeyStore extends KeyStoreSpi {
@@ -143,14 +141,7 @@
public static final int VERSION_3 = 3;
- private static final String[] KEY_PROTECTION_ALGORITHM = {
- "keystore.pkcs12.keyProtectionAlgorithm",
- "keystore.PKCS12.keyProtectionAlgorithm"
- };
-
private static final int MAX_ITERATION_COUNT = 5000000;
- private static final int PBE_ITERATION_COUNT = 50000; // default
- private static final int MAC_ITERATION_COUNT = 100000; // default
private static final int SALT_LEN = 20;
// friendlyName, localKeyId, trustedKeyUsage
@@ -171,10 +162,6 @@
private static final int[] pkcs9certType = {1, 2, 840, 113549, 1, 9, 22, 1};
- private static final int[] pbeWithSHAAnd40BitRC2CBC =
- {1, 2, 840, 113549, 1, 12, 1, 6};
- 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};
// TODO: temporary Oracle OID
/*
@@ -185,17 +172,15 @@
{2, 16, 840, 1, 113894, 746875, 1, 1};
private static final int[] AnyExtendedKeyUsage = {2, 5, 29, 37, 0};
- private static ObjectIdentifier PKCS8ShroudedKeyBag_OID;
- private static ObjectIdentifier CertBag_OID;
- private static ObjectIdentifier SecretBag_OID;
- private static ObjectIdentifier PKCS9FriendlyName_OID;
- private static ObjectIdentifier PKCS9LocalKeyId_OID;
- private static ObjectIdentifier PKCS9CertType_OID;
- private static ObjectIdentifier pbeWithSHAAnd40BitRC2CBC_OID;
- private static ObjectIdentifier pbeWithSHAAnd3KeyTripleDESCBC_OID;
- private static ObjectIdentifier pbes2_OID;
- private static ObjectIdentifier TrustedKeyUsage_OID;
- private static ObjectIdentifier[] AnyUsage;
+ private static final ObjectIdentifier PKCS8ShroudedKeyBag_OID;
+ private static final ObjectIdentifier CertBag_OID;
+ private static final ObjectIdentifier SecretBag_OID;
+ private static final ObjectIdentifier PKCS9FriendlyName_OID;
+ private static final ObjectIdentifier PKCS9LocalKeyId_OID;
+ private static final ObjectIdentifier PKCS9CertType_OID;
+ private static final ObjectIdentifier pbes2_OID;
+ private static final ObjectIdentifier TrustedKeyUsage_OID;
+ private static final ObjectIdentifier[] AnyUsage;
private int counter = 0;
@@ -210,6 +195,17 @@
// certificate count
private int certificateCount = 0;
+ // Alg/params used for *this* keystore. Initialized as -1 for ic and
+ // null for algorithm names. When an existing file is read, they will be
+ // assigned inside engineLoad() so storing an existing keystore uses the
+ // old alg/params. This makes sure if a keystore is created password-less
+ // it will be password-less forever. Otherwise, engineStore() will read
+ // the default values. These fields are always reset when load() is called.
+ private String certProtectionAlgorithm = null;
+ private int certPbeIterationCount = -1;
+ private String macAlgorithm = null;
+ private int macIterationCount = -1;
+
// the source of randomness
private SecureRandom random;
@@ -221,16 +217,12 @@
PKCS9FriendlyName_OID = new ObjectIdentifier(pkcs9Name);
PKCS9LocalKeyId_OID = new ObjectIdentifier(pkcs9KeyId);
PKCS9CertType_OID = new ObjectIdentifier(pkcs9certType);
- pbeWithSHAAnd40BitRC2CBC_OID =
- new ObjectIdentifier(pbeWithSHAAnd40BitRC2CBC);
- pbeWithSHAAnd3KeyTripleDESCBC_OID =
- new ObjectIdentifier(pbeWithSHAAnd3KeyTripleDESCBC);
pbes2_OID = new ObjectIdentifier(pbes2);
TrustedKeyUsage_OID = new ObjectIdentifier(TrustedKeyUsage);
AnyUsage = new ObjectIdentifier[]{
new ObjectIdentifier(AnyExtendedKeyUsage)};
} catch (IOException ioe) {
- // should not happen
+ throw new AssertionError("OID not initialized", ioe);
}
}
@@ -391,7 +383,7 @@
ic = pbeSpec.getIterationCount();
if (ic > MAX_ITERATION_COUNT) {
- throw new IOException("PBE iteration count too large");
+ throw new IOException("key PBE iteration count too large");
}
} else {
ic = 0;
@@ -424,7 +416,7 @@
if (debug != null) {
debug.println("Retrieved a protected private key at alias" +
" '" + alias + "' (" +
- new AlgorithmId(algOid).getName() +
+ mapPBEParamsToAlgorithm(algOid, algParams) +
" iterations: " + ic + ")");
}
return tmp;
@@ -449,7 +441,7 @@
if (debug != null) {
debug.println("Retrieved a protected secret key at alias " +
"'" + alias + "' (" +
- new AlgorithmId(algOid).getName() +
+ mapPBEParamsToAlgorithm(algOid, algParams) +
" iterations: " + ic + ")");
}
return tmp;
@@ -701,7 +693,7 @@
entries.put(alias.toLowerCase(Locale.ENGLISH), entry);
} catch (Exception nsae) {
- throw new KeyStoreException("Key protection " +
+ throw new KeyStoreException("Key protection" +
" algorithm not found: " + nsae, nsae);
}
}
@@ -801,14 +793,13 @@
/*
* Generate PBE Algorithm Parameters
*/
- private AlgorithmParameters getPBEAlgorithmParameters(String algorithm)
- throws IOException
- {
+ private AlgorithmParameters getPBEAlgorithmParameters(
+ String algorithm, int iterationCount) throws IOException {
AlgorithmParameters algParams = null;
// create PBE parameters from salt and iteration count
PBEParameterSpec paramSpec =
- new PBEParameterSpec(getSalt(), PBE_ITERATION_COUNT);
+ new PBEParameterSpec(getSalt(), iterationCount);
try {
algParams = AlgorithmParameters.getInstance(algorithm);
algParams.init(paramSpec);
@@ -871,13 +862,14 @@
}
/*
- * Encrypt private key using Password-based encryption (PBE)
+ * Encrypt private key or secret key using Password-based encryption (PBE)
* as defined in PKCS#5.
*
* NOTE: By default, pbeWithSHAAnd3-KeyTripleDES-CBC algorithmID is
* used to derive the key and IV.
*
- * @return encrypted private key encoded as EncryptedPrivateKeyInfo
+ * @return encrypted private key or secret key encoded as
+ * EncryptedPrivateKeyInfo
*/
private byte[] encryptPrivateKey(byte[] data,
KeyStore.PasswordProtection passwordProtection)
@@ -899,27 +891,14 @@
algParams = AlgorithmParameters.getInstance(algorithm);
algParams.init(algParamSpec);
} else {
- algParams = getPBEAlgorithmParameters(algorithm);
+ algParams = getPBEAlgorithmParameters(algorithm,
+ defaultKeyPbeIterationCount());
}
} else {
// Check default key protection algorithm for PKCS12 keystores
- algorithm = AccessController.doPrivileged(
- new PrivilegedAction<String>() {
- public String run() {
- String prop =
- Security.getProperty(
- KEY_PROTECTION_ALGORITHM[0]);
- if (prop == null) {
- prop = Security.getProperty(
- KEY_PROTECTION_ALGORITHM[1]);
- }
- return prop;
- }
- });
- if (algorithm == null || algorithm.isEmpty()) {
- algorithm = "PBEWithSHA1AndDESede";
- }
- algParams = getPBEAlgorithmParameters(algorithm);
+ algorithm = defaultKeyProtectionAlgorithm();
+ algParams = getPBEAlgorithmParameters(algorithm,
+ defaultKeyPbeIterationCount());
}
ObjectIdentifier pbeOID = mapPBEAlgorithmToOID(algorithm);
@@ -977,7 +956,7 @@
if (algorithm.equals(pbes2_OID) && algParams != null) {
return algParams.toString();
}
- return algorithm.toString();
+ return new AlgorithmId(algorithm).getName();
}
/**
@@ -1209,10 +1188,6 @@
public synchronized void engineStore(OutputStream stream, char[] password)
throws IOException, NoSuchAlgorithmException, CertificateException
{
- // password is mandatory when storing
- if (password == null) {
- throw new IllegalArgumentException("password can't be null");
- }
// -- Create PFX
DerOutputStream pfx = new DerOutputStream();
@@ -1245,16 +1220,28 @@
// -- create EncryptedContentInfo
if (certificateCount > 0) {
+ if (certProtectionAlgorithm == null) {
+ certProtectionAlgorithm = defaultCertProtectionAlgorithm();
+ }
+ if (certPbeIterationCount < 0) {
+ certPbeIterationCount = defaultCertPbeIterationCount();
+ }
+
if (debug != null) {
debug.println("Storing " + certificateCount +
" certificate(s) in a PKCS#7 encryptedData");
}
byte[] encrData = createEncryptedData(password);
- ContentInfo encrContentInfo =
- new ContentInfo(ContentInfo.ENCRYPTED_DATA_OID,
+ if (!certProtectionAlgorithm.equalsIgnoreCase("NONE")) {
+ ContentInfo encrContentInfo =
+ new ContentInfo(ContentInfo.ENCRYPTED_DATA_OID,
new DerValue(encrData));
- encrContentInfo.encode(authSafeContentInfo);
+ encrContentInfo.encode(authSafeContentInfo);
+ } else {
+ ContentInfo dataContentInfo = new ContentInfo(encrData);
+ dataContentInfo.encode(authSafeContentInfo);
+ }
}
// wrap as SequenceOf ContentInfos
@@ -1269,9 +1256,16 @@
pfx.write(authSafeData);
// -- MAC
- byte[] macData = calculateMac(password, authenticatedSafe);
- pfx.write(macData);
-
+ if (macAlgorithm == null) {
+ macAlgorithm = defaultMacAlgorithm();
+ }
+ if (macIterationCount < 0) {
+ macIterationCount = defaultMacIterationCount();
+ }
+ if (!macAlgorithm.equalsIgnoreCase("NONE")) {
+ byte[] macData = calculateMac(password, authenticatedSafe);
+ pfx.write(macData);
+ }
// write PFX to output stream
DerOutputStream pfxout = new DerOutputStream();
pfxout.write(DerValue.tag_Sequence, pfx);
@@ -1482,24 +1476,6 @@
}
/*
- * Generate Hash.
- */
- private byte[] generateHash(byte[] data) throws IOException
- {
- byte[] digest = null;
-
- try {
- MessageDigest md = MessageDigest.getInstance("SHA1");
- md.update(data);
- digest = md.digest();
- } catch (Exception e) {
- throw new IOException("generateHash failed: " + e, e);
- }
- return digest;
- }
-
-
- /*
* Calculate MAC using HMAC algorithm (required for password integrity)
*
* Hash-based MAC algorithm combines secret key with message digest to
@@ -1509,16 +1485,16 @@
throws IOException
{
byte[] mData = null;
- String algName = "SHA1";
+ String algName = macAlgorithm.substring(7);
try {
// Generate a random salt.
byte[] salt = getSalt();
// generate MAC (MAC key is generated within JCE)
- Mac m = Mac.getInstance("HmacPBESHA1");
+ Mac m = Mac.getInstance(macAlgorithm);
PBEParameterSpec params =
- new PBEParameterSpec(salt, MAC_ITERATION_COUNT);
+ new PBEParameterSpec(salt, macIterationCount);
SecretKey key = getPBEKey(passwd);
m.init(key, params);
m.update(data);
@@ -1526,7 +1502,7 @@
// encode as MacData
MacData macData = new MacData(algName, macResult, salt,
- MAC_ITERATION_COUNT);
+ macIterationCount);
DerOutputStream bytes = new DerOutputStream();
bytes.write(macData.getEncoded());
mData = bytes.toByteArray();
@@ -1799,15 +1775,19 @@
byte[] safeBagData = safeBagValue.toByteArray();
// encrypt the content (EncryptedContentInfo)
- byte[] encrContentInfo = encryptContent(safeBagData, password);
+ if (!certProtectionAlgorithm.equalsIgnoreCase("NONE")) {
+ byte[] encrContentInfo = encryptContent(safeBagData, password);
- // -- SEQUENCE of EncryptedData
- DerOutputStream encrData = new DerOutputStream();
- DerOutputStream encrDataContent = new DerOutputStream();
- encrData.putInteger(0);
- encrData.write(encrContentInfo);
- encrDataContent.write(DerValue.tag_Sequence, encrData);
- return encrDataContent.toByteArray();
+ // -- SEQUENCE of EncryptedData
+ DerOutputStream encrData = new DerOutputStream();
+ DerOutputStream encrDataContent = new DerOutputStream();
+ encrData.putInteger(0);
+ encrData.write(encrContentInfo);
+ encrDataContent.write(DerValue.tag_Sequence, encrData);
+ return encrDataContent.toByteArray();
+ } else {
+ return safeBagData;
+ }
}
/*
@@ -1916,47 +1896,52 @@
byte[] encryptedData = null;
- // create AlgorithmParameters
- AlgorithmParameters algParams =
- getPBEAlgorithmParameters("PBEWithSHA1AndRC2_40");
- DerOutputStream bytes = new DerOutputStream();
- AlgorithmId algId =
- new AlgorithmId(pbeWithSHAAnd40BitRC2CBC_OID, algParams);
- algId.encode(bytes);
- byte[] encodedAlgId = bytes.toByteArray();
try {
+ // create AlgorithmParameters
+ AlgorithmParameters algParams = getPBEAlgorithmParameters(
+ certProtectionAlgorithm, certPbeIterationCount);
+ DerOutputStream bytes = new DerOutputStream();
+
// Use JCE
SecretKey skey = getPBEKey(password);
- Cipher cipher = Cipher.getInstance("PBEWithSHA1AndRC2_40");
+ Cipher cipher = Cipher.getInstance(certProtectionAlgorithm);
cipher.init(Cipher.ENCRYPT_MODE, skey, algParams);
encryptedData = cipher.doFinal(data);
+ AlgorithmId algId = new AlgorithmId(
+ mapPBEAlgorithmToOID(certProtectionAlgorithm),
+ cipher.getParameters());
+ // cipher.getParameters() now has IV
+ algId.encode(bytes);
+ byte[] encodedAlgId = bytes.toByteArray();
+
if (debug != null) {
debug.println(" (Cipher algorithm: " + cipher.getAlgorithm() +
- ")");
+ ")");
}
+ // create EncryptedContentInfo
+ DerOutputStream bytes2 = new DerOutputStream();
+ bytes2.putOID(ContentInfo.DATA_OID);
+ bytes2.write(encodedAlgId);
+
+ // Wrap encrypted data in a context-specific tag.
+ DerOutputStream tmpout2 = new DerOutputStream();
+ tmpout2.putOctetString(encryptedData);
+ bytes2.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
+ false, (byte) 0), tmpout2);
+
+ // wrap EncryptedContentInfo in a Sequence
+ DerOutputStream out = new DerOutputStream();
+ out.write(DerValue.tag_Sequence, bytes2);
+ return out.toByteArray();
+ } catch (IOException ioe) {
+ throw ioe;
} catch (Exception e) {
throw new IOException("Failed to encrypt" +
" safe contents entry: " + e, e);
}
-
- // create EncryptedContentInfo
- DerOutputStream bytes2 = new DerOutputStream();
- bytes2.putOID(ContentInfo.DATA_OID);
- bytes2.write(encodedAlgId);
-
- // Wrap encrypted data in a context-specific tag.
- DerOutputStream tmpout2 = new DerOutputStream();
- tmpout2.putOctetString(encryptedData);
- bytes2.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
- false, (byte)0), tmpout2);
-
- // wrap EncryptedContentInfo in a Sequence
- DerOutputStream out = new DerOutputStream();
- out.write(DerValue.tag_Sequence, bytes2);
- return out.toByteArray();
}
/**
@@ -1979,10 +1964,12 @@
public synchronized void engineLoad(InputStream stream, char[] password)
throws IOException, NoSuchAlgorithmException, CertificateException
{
- DataInputStream dis;
- CertificateFactory cf = null;
- ByteArrayInputStream bais = null;
- byte[] encoded = null;
+
+ // Reset config when loading a different keystore.
+ certProtectionAlgorithm = null;
+ certPbeIterationCount = -1;
+ macAlgorithm = null;
+ macIterationCount = -1;
if (stream == null)
return;
@@ -2022,6 +2009,8 @@
secretKeyCount = 0;
certificateCount = 0;
+ boolean seeEncBag = false;
+
/*
* Spin over the ContentInfos.
*/
@@ -2047,6 +2036,21 @@
debug.println("Warning: skipping PKCS#7 encryptedData" +
" - no password was supplied");
}
+ // No password to decrypt ENCRYPTED_DATA_OID. *Skip it*.
+ // This means user will see a PrivateKeyEntry without
+ // certificates and a whole TrustedCertificateEntry will
+ // be lost. This is not a perfect solution but alternative
+ // solutions are more disruptive:
+ //
+ // We cannot just fail, since KeyStore.load(is, null)
+ // has been known to never fail because of a null password.
+ //
+ // We cannot just throw away the whole PrivateKeyEntry,
+ // this is too silent and no one will notice anything.
+ //
+ // We also cannot fail when getCertificate() on such a
+ // PrivateKeyEntry is called, since the method has not
+ // specified this behavior.
continue;
}
@@ -2084,13 +2088,18 @@
ic = pbeSpec.getIterationCount();
if (ic > MAX_ITERATION_COUNT) {
- throw new IOException("PBE iteration count too large");
+ throw new IOException("cert PBE iteration count too large");
}
+
+ certProtectionAlgorithm
+ = mapPBEParamsToAlgorithm(algOid, algParams);
+ certPbeIterationCount = ic;
+ seeEncBag = true;
}
if (debug != null) {
debug.println("Loading PKCS#7 encryptedData " +
- "(" + new AlgorithmId(algOid).getName() +
+ "(" + mapPBEParamsToAlgorithm(algOid, algParams) +
" iterations: " + ic + ")");
}
@@ -2115,48 +2124,62 @@
}
}
- // The MacData is optional.
- if (password != null && s.available() > 0) {
- MacData macData = new MacData(s);
- int ic = macData.getIterations();
-
- try {
- if (ic > MAX_ITERATION_COUNT) {
- throw new InvalidAlgorithmParameterException(
- "MAC iteration count too large: " + ic);
- }
-
- String algName =
- macData.getDigestAlgName().toUpperCase(Locale.ENGLISH);
+ // No ENCRYPTED_DATA_OID but see certificate. Must be passwordless.
+ if (!seeEncBag && certificateCount > 0) {
+ certProtectionAlgorithm = "NONE";
+ }
- // Change SHA-1 to SHA1
- algName = algName.replace("-", "");
-
- // generate MAC (MAC key is created within JCE)
- Mac m = Mac.getInstance("HmacPBE" + algName);
- PBEParameterSpec params =
- new PBEParameterSpec(macData.getSalt(), ic);
+ // The MacData is optional.
+ if (s.available() > 0) {
+ // If there is no password, we cannot fail. KeyStore.load(is, null)
+ // has been known to never fail because of a null password.
+ if (password != null) {
+ MacData macData = new MacData(s);
+ int ic = macData.getIterations();
- RetryWithZero.run(pass -> {
- SecretKey key = getPBEKey(pass);
- m.init(key, params);
- m.update(authSafeData);
- byte[] macResult = m.doFinal();
-
- if (debug != null) {
- debug.println("Checking keystore integrity " +
- "(" + m.getAlgorithm() + " iterations: " + ic + ")");
+ try {
+ if (ic > MAX_ITERATION_COUNT) {
+ throw new InvalidAlgorithmParameterException(
+ "MAC iteration count too large: " + ic);
}
- if (!MessageDigest.isEqual(macData.getDigest(), macResult)) {
- throw new UnrecoverableKeyException("Failed PKCS12" +
- " integrity checking");
- }
- return (Void)null;
- }, password);
- } catch (Exception e) {
- throw new IOException("Integrity check failed: " + e, e);
+ String algName =
+ macData.getDigestAlgName().toUpperCase(Locale.ENGLISH);
+
+ // Change SHA-1 to SHA1
+ algName = algName.replace("-", "");
+
+ macAlgorithm = "HmacPBE" + algName;
+ macIterationCount = ic;
+
+ // generate MAC (MAC key is created within JCE)
+ Mac m = Mac.getInstance(macAlgorithm);
+ PBEParameterSpec params =
+ new PBEParameterSpec(macData.getSalt(), ic);
+
+ RetryWithZero.run(pass -> {
+ SecretKey key = getPBEKey(pass);
+ m.init(key, params);
+ m.update(authSafeData);
+ byte[] macResult = m.doFinal();
+
+ if (debug != null) {
+ debug.println("Checking keystore integrity " +
+ "(" + m.getAlgorithm() + " iterations: " + ic + ")");
+ }
+
+ if (!MessageDigest.isEqual(macData.getDigest(), macResult)) {
+ throw new UnrecoverableKeyException("Failed PKCS12" +
+ " integrity checking");
+ }
+ return (Void) null;
+ }, password);
+ } catch (Exception e) {
+ throw new IOException("Integrity check failed: " + e, e);
+ }
}
+ } else {
+ macAlgorithm = "NONE";
}
/*
@@ -2196,8 +2219,14 @@
cert = certsMap.get(issuerDN);
}
/* Update existing KeyEntry in entries table */
- if (chain.size() > 0)
+ if (chain.size() > 0) {
entry.chain = chain.toArray(new Certificate[chain.size()]);
+ } else {
+ // Remove private key entries where there is no associated
+ // certs. Most likely the keystore is loaded with a null
+ // password.
+ entries.remove(entry);
+ }
}
}
@@ -2222,6 +2251,46 @@
}
/**
+ * Returns if a pkcs12 file is password-less. This means no cert is
+ * encrypted and there is no Mac. Please note that the private key
+ * can be encrypted.
+ *
+ * This is a simplified version of {@link #engineLoad} that only looks
+ * at the ContentInfo types.
+ *
+ * @param f the pkcs12 file
+ * @return if it's password-less
+ * @throws IOException
+ */
+ public static boolean isPasswordless(File f) throws IOException {
+
+ try (FileInputStream stream = new FileInputStream(f)) {
+ DerValue val = new DerValue(stream);
+ DerInputStream s = val.toDerInputStream();
+
+ s.getInteger(); // skip version
+
+ ContentInfo authSafe = new ContentInfo(s);
+ DerInputStream as = new DerInputStream(authSafe.getData());
+ for (DerValue seq : as.getSequence(2)) {
+ DerInputStream sci = new DerInputStream(seq.toByteArray());
+ ContentInfo safeContents = new ContentInfo(sci);
+ if (safeContents.getContentType()
+ .equals(ContentInfo.ENCRYPTED_DATA_OID)) {
+ // Certificate encrypted
+ return false;
+ }
+ }
+
+ if (s.available() > 0) {
+ // The MacData exists.
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
* Locates a matched CertEntry from certEntries, and returns its cert.
* @param entry the KeyEntry to match
* @return a certificate, null if not found
@@ -2368,8 +2437,8 @@
if (bagItem instanceof KeyEntry) {
KeyEntry entry = (KeyEntry)bagItem;
- if (bagItem instanceof PrivateKeyEntry) {
- if (keyId == null) {
+ if (keyId == null) {
+ if (bagItem instanceof PrivateKeyEntry) {
// Insert a localKeyID for the privateKey
// Note: This is a workaround to allow null localKeyID
// attribute in pkcs12 with one private key entry and
@@ -2379,6 +2448,9 @@
} else {
continue;
}
+ } else {
+ // keyId in a SecretKeyEntry is not significant
+ keyId = "00".getBytes("UTF8");
}
}
entry.keyId = keyId;
@@ -2518,4 +2590,83 @@
return result;
}
+
+ // 8076190: Customizing the generation of a PKCS12 keystore
+
+ private static String defaultCertProtectionAlgorithm() {
+ String result = SecurityProperties.privilegedGetOverridable(
+ "keystore.pkcs12.certProtectionAlgorithm");
+ return (result != null && !result.isEmpty())
+ ? result : "PBEWithSHA1AndRC2_40";
+ }
+
+ private static int defaultCertPbeIterationCount() {
+ String result = SecurityProperties.privilegedGetOverridable(
+ "keystore.pkcs12.certPbeIterationCount");
+ return (result != null && !result.isEmpty())
+ ? string2IC("certPbeIterationCount", result) : 50000;
+ }
+
+ // Read both "keystore.pkcs12.keyProtectionAlgorithm" and
+ // "keystore.PKCS12.keyProtectionAlgorithm" for compatibility.
+ private static String defaultKeyProtectionAlgorithm() {
+ String result = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ String result;
+ String name1 = "keystore.pkcs12.keyProtectionAlgorithm";
+ String name2 = "keystore.PKCS12.keyProtectionAlgorithm";
+ result = System.getProperty(name1);
+ if (result != null) {
+ return result;
+ }
+ result = System.getProperty(name2);
+ if (result != null) {
+ return result;
+ }
+ result = Security.getProperty(name1);
+ if (result != null) {
+ return result;
+ }
+ return Security.getProperty(name2);
+ }
+ });
+ return (result != null && !result.isEmpty())
+ ? result : "PBEWithSHA1AndDESede";
+ }
+
+ private static int defaultKeyPbeIterationCount() {
+ String result = SecurityProperties.privilegedGetOverridable(
+ "keystore.pkcs12.keyPbeIterationCount");
+ return (result != null && !result.isEmpty())
+ ? string2IC("keyPbeIterationCount", result) : 50000;
+ }
+
+ private static String defaultMacAlgorithm() {
+ String result = SecurityProperties.privilegedGetOverridable(
+ "keystore.pkcs12.macAlgorithm");
+ return (result != null && !result.isEmpty())
+ ? result : "HmacPBESHA1";
+ }
+
+ private static int defaultMacIterationCount() {
+ String result = SecurityProperties.privilegedGetOverridable(
+ "keystore.pkcs12.macIterationCount");
+ return (result != null && !result.isEmpty())
+ ? string2IC("macIterationCount", result) : 100000;
+ }
+
+ private static int string2IC(String type, String value) {
+ int number;
+ try {
+ number = Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("keystore.pkcs12." + type
+ + " is not a number: " + value);
+ }
+ if (number <= 0 || number > MAX_ITERATION_COUNT) {
+ throw new IllegalArgumentException("Invalid keystore.pkcs12."
+ + type + ": " + value);
+ }
+ return number;
+ }
}
--- a/src/java.base/share/classes/sun/security/provider/ConfigFile.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/provider/ConfigFile.java Tue Dec 18 15:08:56 2018 -0500
@@ -626,7 +626,7 @@
return url.openStream();
} catch (Exception e) {
String file = url.getPath();
- if (url.getHost().length() > 0) { // For Windows UNC
+ if (!url.getHost().isEmpty()) { // For Windows UNC
file = "//" + url.getHost() + file;
}
if (debugConfig != null) {
@@ -651,7 +651,7 @@
return value;
}
String s = PropertyExpander.expand(value);
- if (s == null || s.length() == 0) {
+ if (s == null || s.isEmpty()) {
throw ioException(
"Configuration.Error.Line.line.system.property.value.expanded.to.empty.value",
linenum, value);
--- a/src/java.base/share/classes/sun/security/provider/PolicyParser.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/provider/PolicyParser.java Tue Dec 18 15:08:56 2018 -0500
@@ -391,9 +391,9 @@
out.print("keystore \"");
out.print(keyStoreUrlString);
out.print('"');
- if (keyStoreType != null && keyStoreType.length() > 0)
+ if (keyStoreType != null && !keyStoreType.isEmpty())
out.print(", \"" + keyStoreType + "\"");
- if (keyStoreProvider != null && keyStoreProvider.length() > 0)
+ if (keyStoreProvider != null && !keyStoreProvider.isEmpty())
out.print(", \"" + keyStoreProvider + "\"");
out.println(";");
out.println();
@@ -446,7 +446,7 @@
String alias = aliases.nextToken().trim();
if (alias.equals(","))
cctr++;
- else if (alias.length() > 0)
+ else if (!alias.isEmpty())
actr++;
}
if (actr <= cctr)
--- a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java Tue Dec 18 15:08:56 2018 -0500
@@ -113,7 +113,7 @@
+ "generator: " + e.toString());
}
}
- } else if (egdSource.length() != 0) {
+ } else if (!egdSource.isEmpty()) {
try {
instance = new URLSeedGenerator(egdSource);
if (debug != null) {
--- a/src/java.base/share/classes/sun/security/provider/Sun.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/provider/Sun.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
import java.util.*;
import java.security.*;
-import sun.security.action.PutAllAction;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
@@ -51,17 +50,27 @@
/* We are the SUN provider */
super("SUN", PROVIDER_VER, INFO);
+ Provider p = this;
+ Iterator<Provider.Service> serviceIter = new SunEntries(p).iterator();
+
// if there is no security manager installed, put directly into
- // the provider. Otherwise, create a temporary map and use a
- // doPrivileged() call at the end to transfer the contents
+ // the provider
if (System.getSecurityManager() == null) {
- SunEntries.putEntries(this);
+ putEntries(serviceIter);
} else {
- // use LinkedHashMap to preserve the order of the PRNGs
- Map<Object, Object> map = new LinkedHashMap<>();
- SunEntries.putEntries(map);
- AccessController.doPrivileged(new PutAllAction(this, map));
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ @Override
+ public Void run() {
+ putEntries(serviceIter);
+ return null;
+ }
+ });
}
}
+ void putEntries(Iterator<Provider.Service> i) {
+ while (i.hasNext()) {
+ putService(i.next());
+ }
+ }
}
--- a/src/java.base/share/classes/sun/security/provider/SunEntries.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/provider/SunEntries.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
import java.io.*;
import java.net.*;
-import java.util.Map;
+import java.util.*;
import java.security.*;
import jdk.internal.util.StaticProperty;
@@ -75,17 +75,28 @@
* - JavaLoginConfig is the default file-based LoginModule Configuration type.
*/
-final class SunEntries {
+public final class SunEntries {
- private static final boolean useLegacyDSA =
- Boolean.parseBoolean(GetPropertyAction.privilegedGetProperty
- ("jdk.security.legacyDSAKeyPairGenerator"));
-
- private SunEntries() {
- // empty
+ // create an aliases List from the specified aliases
+ public static List<String> createAliases(String ... aliases) {
+ return Arrays.asList(aliases);
}
- static void putEntries(Map<Object, Object> map) {
+ // create an aliases List from the specified oid followed by other aliases
+ public static List<String> createAliasesWithOid(String ... oids) {
+ String[] result = Arrays.copyOf(oids, oids.length + 1);
+ result[result.length - 1] = "OID." + oids[0];
+ return Arrays.asList(result);
+ }
+
+ // extend LinkedHashSet to preserve the ordering (needed by SecureRandom?)
+ SunEntries(Provider p) {
+ services = new LinkedHashSet<>(50, 0.9f);
+
+ // start populating content using the specified provider
+
+ // common attribute map
+ HashMap<String, String> attrs = new HashMap<>(3);
/*
* SecureRandom
@@ -100,266 +111,217 @@
boolean useNativePRNG = seedSource.equals(URL_DEV_URANDOM) ||
seedSource.equals(URL_DEV_RANDOM);
+ attrs.put("ThreadSafe", "true");
if (nativeAvailable && useNativePRNG) {
- map.put("SecureRandom.NativePRNG",
- "sun.security.provider.NativePRNG");
- map.put("SecureRandom.NativePRNG ThreadSafe", "true");
+ add(p, "SecureRandom", "NativePRNG",
+ "sun.security.provider.NativePRNG", null, attrs);
}
-
- map.put("SecureRandom.DRBG", "sun.security.provider.DRBG");
- map.put("SecureRandom.DRBG ThreadSafe", "true");
-
- map.put("SecureRandom.SHA1PRNG",
- "sun.security.provider.SecureRandom");
-
- map.put("SecureRandom.SHA1PRNG ThreadSafe", "true");
+ attrs.put("ImplementedIn", "Software");
+ add(p, "SecureRandom", "DRBG", "sun.security.provider.DRBG", null, attrs);
+ add(p, "SecureRandom", "SHA1PRNG",
+ "sun.security.provider.SecureRandom", null, attrs);
+ attrs.remove("ImplementedIn");
if (nativeAvailable && !useNativePRNG) {
- map.put("SecureRandom.NativePRNG",
- "sun.security.provider.NativePRNG");
- map.put("SecureRandom.NativePRNG ThreadSafe", "true");
+ add(p, "SecureRandom", "NativePRNG", "sun.security.provider.NativePRNG",
+ null, attrs);
}
if (NativePRNG.Blocking.isAvailable()) {
- map.put("SecureRandom.NativePRNGBlocking",
- "sun.security.provider.NativePRNG$Blocking");
- map.put("SecureRandom.NativePRNGBlocking ThreadSafe", "true");
+ add(p, "SecureRandom", "NativePRNGBlocking",
+ "sun.security.provider.NativePRNG$Blocking", null, attrs);
}
-
if (NativePRNG.NonBlocking.isAvailable()) {
- map.put("SecureRandom.NativePRNGNonBlocking",
- "sun.security.provider.NativePRNG$NonBlocking");
- map.put("SecureRandom.NativePRNGNonBlocking ThreadSafe", "true");
+ add(p, "SecureRandom", "NativePRNGNonBlocking",
+ "sun.security.provider.NativePRNG$NonBlocking", null, attrs);
}
/*
* Signature engines
*/
- map.put("Signature.SHA1withDSA",
- "sun.security.provider.DSA$SHA1withDSA");
- map.put("Signature.NONEwithDSA", "sun.security.provider.DSA$RawDSA");
- map.put("Alg.Alias.Signature.RawDSA", "NONEwithDSA");
- map.put("Signature.SHA224withDSA",
- "sun.security.provider.DSA$SHA224withDSA");
- map.put("Signature.SHA256withDSA",
- "sun.security.provider.DSA$SHA256withDSA");
-
- map.put("Signature.SHA1withDSAinP1363Format",
- "sun.security.provider.DSA$SHA1withDSAinP1363Format");
- map.put("Signature.NONEwithDSAinP1363Format",
- "sun.security.provider.DSA$RawDSAinP1363Format");
- map.put("Signature.SHA224withDSAinP1363Format",
- "sun.security.provider.DSA$SHA224withDSAinP1363Format");
- map.put("Signature.SHA256withDSAinP1363Format",
- "sun.security.provider.DSA$SHA256withDSAinP1363Format");
-
+ attrs.clear();
String dsaKeyClasses = "java.security.interfaces.DSAPublicKey" +
"|java.security.interfaces.DSAPrivateKey";
- map.put("Signature.SHA1withDSA SupportedKeyClasses", dsaKeyClasses);
- map.put("Signature.NONEwithDSA SupportedKeyClasses", dsaKeyClasses);
- map.put("Signature.SHA224withDSA SupportedKeyClasses", dsaKeyClasses);
- map.put("Signature.SHA256withDSA SupportedKeyClasses", dsaKeyClasses);
+ attrs.put("SupportedKeyClasses", dsaKeyClasses);
+ attrs.put("ImplementedIn", "Software");
+
+ attrs.put("KeySize", "1024"); // for NONE and SHA1 DSA signatures
+
+ add(p, "Signature", "SHA1withDSA",
+ "sun.security.provider.DSA$SHA1withDSA",
+ createAliasesWithOid("1.2.840.10040.4.3", "DSA", "DSS", "SHA/DSA",
+ "SHA-1/DSA", "SHA1/DSA", "SHAwithDSA", "DSAWithSHA1",
+ "1.3.14.3.2.13", "1.3.14.3.2.27"), attrs);
+ add(p, "Signature", "NONEwithDSA", "sun.security.provider.DSA$RawDSA",
+ createAliases("RawDSA"), attrs);
+
+ attrs.put("KeySize", "2048"); // for SHA224 and SHA256 DSA signatures
- map.put("Alg.Alias.Signature.DSA", "SHA1withDSA");
- map.put("Alg.Alias.Signature.DSS", "SHA1withDSA");
- map.put("Alg.Alias.Signature.SHA/DSA", "SHA1withDSA");
- map.put("Alg.Alias.Signature.SHA-1/DSA", "SHA1withDSA");
- map.put("Alg.Alias.Signature.SHA1/DSA", "SHA1withDSA");
- map.put("Alg.Alias.Signature.SHAwithDSA", "SHA1withDSA");
- map.put("Alg.Alias.Signature.DSAWithSHA1", "SHA1withDSA");
- map.put("Alg.Alias.Signature.OID.1.2.840.10040.4.3",
- "SHA1withDSA");
- map.put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA1withDSA");
- map.put("Alg.Alias.Signature.1.3.14.3.2.13", "SHA1withDSA");
- map.put("Alg.Alias.Signature.1.3.14.3.2.27", "SHA1withDSA");
- map.put("Alg.Alias.Signature.OID.2.16.840.1.101.3.4.3.1",
- "SHA224withDSA");
- map.put("Alg.Alias.Signature.2.16.840.1.101.3.4.3.1", "SHA224withDSA");
- map.put("Alg.Alias.Signature.OID.2.16.840.1.101.3.4.3.2",
- "SHA256withDSA");
- map.put("Alg.Alias.Signature.2.16.840.1.101.3.4.3.2", "SHA256withDSA");
+ add(p, "Signature", "SHA224withDSA",
+ "sun.security.provider.DSA$SHA224withDSA",
+ createAliasesWithOid("2.16.840.1.101.3.4.3.1"), attrs);
+ add(p, "Signature", "SHA256withDSA",
+ "sun.security.provider.DSA$SHA256withDSA",
+ createAliasesWithOid("2.16.840.1.101.3.4.3.2"), attrs);
+
+ attrs.remove("KeySize");
+
+ add(p, "Signature", "SHA1withDSAinP1363Format",
+ "sun.security.provider.DSA$SHA1withDSAinP1363Format",
+ null, null);
+ add(p, "Signature", "NONEwithDSAinP1363Format",
+ "sun.security.provider.DSA$RawDSAinP1363Format",
+ null, null);
+ add(p, "Signature", "SHA224withDSAinP1363Format",
+ "sun.security.provider.DSA$SHA224withDSAinP1363Format",
+ null, null);
+ add(p, "Signature", "SHA256withDSAinP1363Format",
+ "sun.security.provider.DSA$SHA256withDSAinP1363Format",
+ null, null);
/*
* Key Pair Generator engines
*/
+ attrs.clear();
+ attrs.put("ImplementedIn", "Software");
+ attrs.put("KeySize", "2048"); // for DSA KPG and APG only
+
+ String dsaOid = "1.2.840.10040.4.1";
+ List<String> dsaAliases = createAliasesWithOid(dsaOid, "1.3.14.3.2.12");
String dsaKPGImplClass = "sun.security.provider.DSAKeyPairGenerator$";
dsaKPGImplClass += (useLegacyDSA? "Legacy" : "Current");
- map.put("KeyPairGenerator.DSA", dsaKPGImplClass);
- map.put("Alg.Alias.KeyPairGenerator.OID.1.2.840.10040.4.1", "DSA");
- map.put("Alg.Alias.KeyPairGenerator.1.2.840.10040.4.1", "DSA");
- map.put("Alg.Alias.KeyPairGenerator.1.3.14.3.2.12", "DSA");
+ add(p, "KeyPairGenerator", "DSA", dsaKPGImplClass, dsaAliases, attrs);
+
+ /*
+ * Algorithm Parameter Generator engines
+ */
+ add(p, "AlgorithmParameterGenerator", "DSA",
+ "sun.security.provider.DSAParameterGenerator", dsaAliases, attrs);
+ attrs.remove("KeySize");
+
+ /*
+ * Algorithm Parameter engines
+ */
+ add(p, "AlgorithmParameters", "DSA",
+ "sun.security.provider.DSAParameters", dsaAliases, attrs);
+
+ /*
+ * Key factories
+ */
+ add(p, "KeyFactory", "DSA", "sun.security.provider.DSAKeyFactory",
+ dsaAliases, attrs);
/*
* Digest engines
*/
- map.put("MessageDigest.MD2", "sun.security.provider.MD2");
- map.put("MessageDigest.MD5", "sun.security.provider.MD5");
- map.put("MessageDigest.SHA", "sun.security.provider.SHA");
-
- map.put("Alg.Alias.MessageDigest.SHA-1", "SHA");
- map.put("Alg.Alias.MessageDigest.SHA1", "SHA");
- map.put("Alg.Alias.MessageDigest.1.3.14.3.2.26", "SHA");
- map.put("Alg.Alias.MessageDigest.OID.1.3.14.3.2.26", "SHA");
-
- map.put("MessageDigest.SHA-224", "sun.security.provider.SHA2$SHA224");
- map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.4", "SHA-224");
- map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.4",
- "SHA-224");
-
- map.put("MessageDigest.SHA-256", "sun.security.provider.SHA2$SHA256");
- map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.1", "SHA-256");
- map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.1",
- "SHA-256");
- map.put("MessageDigest.SHA-384", "sun.security.provider.SHA5$SHA384");
- map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.2", "SHA-384");
- map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.2",
- "SHA-384");
- map.put("MessageDigest.SHA-512", "sun.security.provider.SHA5$SHA512");
- map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.3", "SHA-512");
- map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.3",
- "SHA-512");
- map.put("MessageDigest.SHA-512/224", "sun.security.provider.SHA5$SHA512_224");
- map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.5", "SHA-512/224");
- map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.5",
- "SHA-512/224");
- map.put("MessageDigest.SHA-512/256", "sun.security.provider.SHA5$SHA512_256");
- map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.6", "SHA-512/256");
- map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.6",
- "SHA-512/256");
+ add(p, "MessageDigest", "MD2", "sun.security.provider.MD2", null, attrs);
+ add(p, "MessageDigest", "MD5", "sun.security.provider.MD5", null, attrs);
+ add(p, "MessageDigest", "SHA", "sun.security.provider.SHA",
+ createAliasesWithOid("1.3.14.3.2.26", "SHA-1", "SHA1"), attrs);
- map.put("MessageDigest.SHA3-224", "sun.security.provider.SHA3$SHA224");
- map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.7", "SHA3-224");
- map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.7",
- "SHA3-224");
-
- map.put("MessageDigest.SHA3-256", "sun.security.provider.SHA3$SHA256");
- map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.8", "SHA3-256");
- map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.8",
- "SHA3-256");
- map.put("MessageDigest.SHA3-384", "sun.security.provider.SHA3$SHA384");
- map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.9", "SHA3-384");
- map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.9",
- "SHA3-384");
- map.put("MessageDigest.SHA3-512", "sun.security.provider.SHA3$SHA512");
- map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.10", "SHA3-512");
- map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.10",
- "SHA3-512");
-
-
- /*
- * Algorithm Parameter Generator engines
- */
- map.put("AlgorithmParameterGenerator.DSA",
- "sun.security.provider.DSAParameterGenerator");
-
- /*
- * Algorithm Parameter engines
- */
- map.put("AlgorithmParameters.DSA",
- "sun.security.provider.DSAParameters");
- map.put("Alg.Alias.AlgorithmParameters.OID.1.2.840.10040.4.1", "DSA");
- map.put("Alg.Alias.AlgorithmParameters.1.2.840.10040.4.1", "DSA");
- map.put("Alg.Alias.AlgorithmParameters.1.3.14.3.2.12", "DSA");
-
- /*
- * Key factories
- */
- map.put("KeyFactory.DSA", "sun.security.provider.DSAKeyFactory");
- map.put("Alg.Alias.KeyFactory.OID.1.2.840.10040.4.1", "DSA");
- map.put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA");
- map.put("Alg.Alias.KeyFactory.1.3.14.3.2.12", "DSA");
+ String sha2BaseOid = "2.16.840.1.101.3.4.2";
+ add(p, "MessageDigest", "SHA-224", "sun.security.provider.SHA2$SHA224",
+ createAliasesWithOid(sha2BaseOid + ".4"), attrs);
+ add(p, "MessageDigest", "SHA-256", "sun.security.provider.SHA2$SHA256",
+ createAliasesWithOid(sha2BaseOid + ".1"), attrs);
+ add(p, "MessageDigest", "SHA-384", "sun.security.provider.SHA5$SHA384",
+ createAliasesWithOid(sha2BaseOid + ".2"), attrs);
+ add(p, "MessageDigest", "SHA-512", "sun.security.provider.SHA5$SHA512",
+ createAliasesWithOid(sha2BaseOid + ".3"), attrs);
+ add(p, "MessageDigest", "SHA-512/224",
+ "sun.security.provider.SHA5$SHA512_224",
+ createAliasesWithOid(sha2BaseOid + ".5"), attrs);
+ add(p, "MessageDigest", "SHA-512/256",
+ "sun.security.provider.SHA5$SHA512_256",
+ createAliasesWithOid(sha2BaseOid + ".6"), attrs);
+ add(p, "MessageDigest", "SHA3-224", "sun.security.provider.SHA3$SHA224",
+ createAliasesWithOid(sha2BaseOid + ".7"), attrs);
+ add(p, "MessageDigest", "SHA3-256", "sun.security.provider.SHA3$SHA256",
+ createAliasesWithOid(sha2BaseOid + ".8"), attrs);
+ add(p, "MessageDigest", "SHA3-384", "sun.security.provider.SHA3$SHA384",
+ createAliasesWithOid(sha2BaseOid + ".9"), attrs);
+ add(p, "MessageDigest", "SHA3-512", "sun.security.provider.SHA3$SHA512",
+ createAliasesWithOid(sha2BaseOid + ".10"), attrs);
/*
* Certificates
*/
- map.put("CertificateFactory.X.509",
- "sun.security.provider.X509Factory");
- map.put("Alg.Alias.CertificateFactory.X509", "X.509");
+ add(p, "CertificateFactory", "X.509",
+ "sun.security.provider.X509Factory",
+ createAliases("X509"), attrs);
/*
* KeyStore
*/
- map.put("KeyStore.PKCS12",
- "sun.security.pkcs12.PKCS12KeyStore$DualFormatPKCS12");
- map.put("KeyStore.JKS",
- "sun.security.provider.JavaKeyStore$DualFormatJKS");
- map.put("KeyStore.CaseExactJKS",
- "sun.security.provider.JavaKeyStore$CaseExactJKS");
- map.put("KeyStore.DKS", "sun.security.provider.DomainKeyStore$DKS");
+ add(p, "KeyStore", "PKCS12",
+ "sun.security.pkcs12.PKCS12KeyStore$DualFormatPKCS12",
+ null, null);
+ add(p, "KeyStore", "JKS",
+ "sun.security.provider.JavaKeyStore$DualFormatJKS",
+ null, attrs);
+ add(p, "KeyStore", "CaseExactJKS",
+ "sun.security.provider.JavaKeyStore$CaseExactJKS",
+ null, attrs);
+ add(p, "KeyStore", "DKS", "sun.security.provider.DomainKeyStore$DKS",
+ null, attrs);
+
+
+ /*
+ * CertStores
+ */
+ add(p, "CertStore", "Collection",
+ "sun.security.provider.certpath.CollectionCertStore",
+ null, attrs);
+ add(p, "CertStore", "com.sun.security.IndexedCollection",
+ "sun.security.provider.certpath.IndexedCollectionCertStore",
+ null, attrs);
/*
* Policy
*/
- map.put("Policy.JavaPolicy", "sun.security.provider.PolicySpiFile");
+ add(p, "Policy", "JavaPolicy", "sun.security.provider.PolicySpiFile",
+ null, null);
/*
* Configuration
*/
- map.put("Configuration.JavaLoginConfig",
- "sun.security.provider.ConfigFile$Spi");
-
- /*
- * CertPathBuilder
- */
- map.put("CertPathBuilder.PKIX",
- "sun.security.provider.certpath.SunCertPathBuilder");
- map.put("CertPathBuilder.PKIX ValidationAlgorithm",
- "RFC5280");
-
- /*
- * CertPathValidator
- */
- map.put("CertPathValidator.PKIX",
- "sun.security.provider.certpath.PKIXCertPathValidator");
- map.put("CertPathValidator.PKIX ValidationAlgorithm",
- "RFC5280");
-
- /*
- * CertStores
- */
- map.put("CertStore.Collection",
- "sun.security.provider.certpath.CollectionCertStore");
- map.put("CertStore.com.sun.security.IndexedCollection",
- "sun.security.provider.certpath.IndexedCollectionCertStore");
+ add(p, "Configuration", "JavaLoginConfig",
+ "sun.security.provider.ConfigFile$Spi", null, null);
/*
- * KeySize
- */
- map.put("Signature.NONEwithDSA KeySize", "1024");
- map.put("Signature.SHA1withDSA KeySize", "1024");
- map.put("Signature.SHA224withDSA KeySize", "2048");
- map.put("Signature.SHA256withDSA KeySize", "2048");
-
- map.put("KeyPairGenerator.DSA KeySize", "2048");
- map.put("AlgorithmParameterGenerator.DSA KeySize", "2048");
-
- /*
- * Implementation type: software or hardware
+ * CertPathBuilder and CertPathValidator
*/
- map.put("Signature.SHA1withDSA ImplementedIn", "Software");
- map.put("KeyPairGenerator.DSA ImplementedIn", "Software");
- map.put("MessageDigest.MD5 ImplementedIn", "Software");
- map.put("MessageDigest.SHA ImplementedIn", "Software");
- map.put("AlgorithmParameterGenerator.DSA ImplementedIn",
- "Software");
- map.put("AlgorithmParameters.DSA ImplementedIn", "Software");
- map.put("KeyFactory.DSA ImplementedIn", "Software");
- map.put("SecureRandom.SHA1PRNG ImplementedIn", "Software");
- map.put("SecureRandom.DRBG ImplementedIn", "Software");
- map.put("CertificateFactory.X.509 ImplementedIn", "Software");
- map.put("KeyStore.JKS ImplementedIn", "Software");
- map.put("CertPathValidator.PKIX ImplementedIn", "Software");
- map.put("CertPathBuilder.PKIX ImplementedIn", "Software");
- map.put("CertStore.Collection ImplementedIn", "Software");
- map.put("CertStore.com.sun.security.IndexedCollection ImplementedIn",
- "Software");
+ attrs.clear();
+ attrs.put("ValidationAlgorithm", "RFC5280");
+ attrs.put("ImplementedIn", "Software");
+ add(p, "CertPathBuilder", "PKIX",
+ "sun.security.provider.certpath.SunCertPathBuilder",
+ null, attrs);
+ add(p, "CertPathValidator", "PKIX",
+ "sun.security.provider.certpath.PKIXCertPathValidator",
+ null, attrs);
}
+ Iterator<Provider.Service> iterator() {
+ return services.iterator();
+ }
+
+ private void add(Provider p, String type, String algo, String cn,
+ List<String> aliases, HashMap<String, String> attrs) {
+ services.add(new Provider.Service(p, type, algo, cn, aliases, attrs));
+ }
+
+ private LinkedHashSet<Provider.Service> services;
+
// name of the *System* property, takes precedence over PROP_RNDSOURCE
private static final String PROP_EGD = "java.security.egd";
// name of the *Security* property
private static final String PROP_RNDSOURCE = "securerandom.source";
+ private static final boolean useLegacyDSA =
+ Boolean.parseBoolean(GetPropertyAction.privilegedGetProperty
+ ("jdk.security.legacyDSAKeyPairGenerator"));
+
static final String URL_DEV_RANDOM = "file:/dev/random";
static final String URL_DEV_URANDOM = "file:/dev/urandom";
--- a/src/java.base/share/classes/sun/security/provider/VerificationProvider.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/provider/VerificationProvider.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,6 @@
import java.util.*;
import java.security.*;
-import sun.security.action.PutAllAction;
-
import sun.security.rsa.SunRsaSignEntries;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
@@ -70,18 +68,30 @@
return;
}
+ Provider p = this;
+ Iterator<Provider.Service> sunIter = new SunEntries(p).iterator();
+ Iterator<Provider.Service> rsaIter =
+ new SunRsaSignEntries(p).iterator();
+
// if there is no security manager installed, put directly into
- // the provider. Otherwise, create a temporary map and use a
- // doPrivileged() call at the end to transfer the contents
+ // the provider
if (System.getSecurityManager() == null) {
- SunEntries.putEntries(this);
- SunRsaSignEntries.putEntries(this);
+ putEntries(sunIter);
+ putEntries(rsaIter);
} else {
- // use LinkedHashMap to preserve the order of the PRNGs
- Map<Object, Object> map = new LinkedHashMap<>();
- SunEntries.putEntries(map);
- SunRsaSignEntries.putEntries(map);
- AccessController.doPrivileged(new PutAllAction(this, map));
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Void run() {
+ putEntries(sunIter);
+ putEntries(rsaIter);
+ return null;
+ }
+ });
+ }
+ }
+
+ void putEntries(Iterator<Provider.Service> i) {
+ while (i.hasNext()) {
+ putService(i.next());
}
}
--- a/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
import java.security.*;
-import sun.security.action.PutAllAction;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
/**
@@ -46,17 +45,24 @@
public SunRsaSign() {
super("SunRsaSign", PROVIDER_VER, "Sun RSA signature provider");
- // if there is no security manager installed, put directly into
- // the provider. Otherwise, create a temporary map and use a
- // doPrivileged() call at the end to transfer the contents
+ Provider p = this;
+ Iterator<Provider.Service> serviceIter = new SunRsaSignEntries(p).iterator();
+
if (System.getSecurityManager() == null) {
- SunRsaSignEntries.putEntries(this);
+ putEntries(serviceIter);
} else {
- // use LinkedHashMap to preserve the order of the PRNGs
- Map<Object, Object> map = new HashMap<>();
- SunRsaSignEntries.putEntries(map);
- AccessController.doPrivileged(new PutAllAction(this, map));
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ @Override
+ public Void run() {
+ putEntries(serviceIter);
+ return null;
+ }
+ });
}
}
-
+ void putEntries(Iterator<Provider.Service> i) {
+ while (i.hasNext()) {
+ putService(i.next());
+ }
+ }
}
--- a/src/java.base/share/classes/sun/security/rsa/SunRsaSignEntries.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/rsa/SunRsaSignEntries.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,9 @@
package sun.security.rsa;
-import java.util.Map;
+import java.util.*;
+import java.security.Provider;
+import static sun.security.provider.SunEntries.createAliasesWithOid;
/**
* Defines the entries of the SunRsaSign provider.
@@ -34,102 +36,81 @@
*/
public final class SunRsaSignEntries {
- private SunRsaSignEntries() {
- // empty
+ private void add(Provider p, String type, String algo, String cn,
+ List<String> aliases, HashMap<String, String> attrs) {
+ services.add(new Provider.Service(p, type, algo, cn, aliases, attrs));
}
- public static void putEntries(Map<Object, Object> map) {
+ // extend LinkedHashSet for consistency with SunEntries
+ // used by sun.security.provider.VerificationProvider
+ public SunRsaSignEntries(Provider p) {
+ services = new LinkedHashSet<>(20, 0.9f);
+
+ // start populating content using the specified provider
- // main algorithms
- map.put("KeyFactory.RSA",
- "sun.security.rsa.RSAKeyFactory$Legacy");
- map.put("KeyPairGenerator.RSA",
- "sun.security.rsa.RSAKeyPairGenerator$Legacy");
- map.put("Signature.MD2withRSA",
- "sun.security.rsa.RSASignature$MD2withRSA");
- map.put("Signature.MD5withRSA",
- "sun.security.rsa.RSASignature$MD5withRSA");
- map.put("Signature.SHA1withRSA",
- "sun.security.rsa.RSASignature$SHA1withRSA");
- map.put("Signature.SHA224withRSA",
- "sun.security.rsa.RSASignature$SHA224withRSA");
- map.put("Signature.SHA256withRSA",
- "sun.security.rsa.RSASignature$SHA256withRSA");
- map.put("Signature.SHA384withRSA",
- "sun.security.rsa.RSASignature$SHA384withRSA");
- map.put("Signature.SHA512withRSA",
- "sun.security.rsa.RSASignature$SHA512withRSA");
- map.put("Signature.SHA512/224withRSA",
- "sun.security.rsa.RSASignature$SHA512_224withRSA");
- map.put("Signature.SHA512/256withRSA",
- "sun.security.rsa.RSASignature$SHA512_256withRSA");
+ // common oids
+ String rsaOid = "1.2.840.113549.1.1";
+ List<String> rsaAliases = createAliasesWithOid(rsaOid);
+ List<String> rsapssAliases = createAliasesWithOid(rsaOid + ".10");
+ String sha1withRSAOid2 = "1.3.14.3.2.29";
- map.put("KeyFactory.RSASSA-PSS",
- "sun.security.rsa.RSAKeyFactory$PSS");
- map.put("KeyPairGenerator.RSASSA-PSS",
- "sun.security.rsa.RSAKeyPairGenerator$PSS");
- map.put("Signature.RSASSA-PSS",
- "sun.security.rsa.RSAPSSSignature");
- map.put("AlgorithmParameters.RSASSA-PSS",
- "sun.security.rsa.PSSParameters");
+ // common attribute map
+ HashMap<String, String> attrs = new HashMap<>(3);
+ attrs.put("SupportedKeyClasses",
+ "java.security.interfaces.RSAPublicKey" +
+ "|java.security.interfaces.RSAPrivateKey");
- // attributes for supported key classes
- String rsaKeyClasses = "java.security.interfaces.RSAPublicKey" +
- "|java.security.interfaces.RSAPrivateKey";
- map.put("Signature.MD2withRSA SupportedKeyClasses", rsaKeyClasses);
- map.put("Signature.MD5withRSA SupportedKeyClasses", rsaKeyClasses);
- map.put("Signature.SHA1withRSA SupportedKeyClasses", rsaKeyClasses);
- map.put("Signature.SHA224withRSA SupportedKeyClasses", rsaKeyClasses);
- map.put("Signature.SHA256withRSA SupportedKeyClasses", rsaKeyClasses);
- map.put("Signature.SHA384withRSA SupportedKeyClasses", rsaKeyClasses);
- map.put("Signature.SHA512withRSA SupportedKeyClasses", rsaKeyClasses);
- map.put("Signature.SHA512/224withRSA SupportedKeyClasses", rsaKeyClasses);
- map.put("Signature.SHA512/256withRSA SupportedKeyClasses", rsaKeyClasses);
- map.put("Signature.RSASSA-PSS SupportedKeyClasses", rsaKeyClasses);
-
- // aliases
- map.put("Alg.Alias.KeyFactory.1.2.840.113549.1.1", "RSA");
- map.put("Alg.Alias.KeyFactory.OID.1.2.840.113549.1.1", "RSA");
-
- map.put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1", "RSA");
- map.put("Alg.Alias.KeyPairGenerator.OID.1.2.840.113549.1.1", "RSA");
-
- map.put("Alg.Alias.Signature.1.2.840.113549.1.1.2", "MD2withRSA");
- map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.2", "MD2withRSA");
-
- map.put("Alg.Alias.Signature.1.2.840.113549.1.1.4", "MD5withRSA");
- map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.4", "MD5withRSA");
+ add(p, "KeyFactory", "RSA",
+ "sun.security.rsa.RSAKeyFactory$Legacy",
+ rsaAliases, null);
+ add(p, "KeyPairGenerator", "RSA",
+ "sun.security.rsa.RSAKeyPairGenerator$Legacy",
+ rsaAliases, null);
+ add(p, "Signature", "MD2withRSA",
+ "sun.security.rsa.RSASignature$MD2withRSA",
+ createAliasesWithOid(rsaOid + ".2"), attrs);
+ add(p, "Signature", "MD5withRSA",
+ "sun.security.rsa.RSASignature$MD5withRSA",
+ createAliasesWithOid(rsaOid + ".4"), attrs);
+ add(p, "Signature", "SHA1withRSA",
+ "sun.security.rsa.RSASignature$SHA1withRSA",
+ createAliasesWithOid(rsaOid + ".5", sha1withRSAOid2), attrs);
+ add(p, "Signature", "SHA224withRSA",
+ "sun.security.rsa.RSASignature$SHA224withRSA",
+ createAliasesWithOid(rsaOid + ".14"), attrs);
+ add(p, "Signature", "SHA256withRSA",
+ "sun.security.rsa.RSASignature$SHA256withRSA",
+ createAliasesWithOid(rsaOid + ".11"), attrs);
+ add(p, "Signature", "SHA384withRSA",
+ "sun.security.rsa.RSASignature$SHA384withRSA",
+ createAliasesWithOid(rsaOid + ".12"), attrs);
+ add(p, "Signature", "SHA512withRSA",
+ "sun.security.rsa.RSASignature$SHA512withRSA",
+ createAliasesWithOid(rsaOid + ".13"), attrs);
+ add(p, "Signature", "SHA512/224withRSA",
+ "sun.security.rsa.RSASignature$SHA512_224withRSA",
+ createAliasesWithOid(rsaOid + ".15"), attrs);
+ add(p, "Signature", "SHA512/256withRSA",
+ "sun.security.rsa.RSASignature$SHA512_256withRSA",
+ createAliasesWithOid(rsaOid + ".16"), attrs);
- map.put("Alg.Alias.Signature.1.2.840.113549.1.1.5", "SHA1withRSA");
- map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.5", "SHA1withRSA");
- map.put("Alg.Alias.Signature.1.3.14.3.2.29", "SHA1withRSA");
-
- map.put("Alg.Alias.Signature.1.2.840.113549.1.1.14", "SHA224withRSA");
- map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.14", "SHA224withRSA");
-
- map.put("Alg.Alias.Signature.1.2.840.113549.1.1.11", "SHA256withRSA");
- map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.11", "SHA256withRSA");
-
- map.put("Alg.Alias.Signature.1.2.840.113549.1.1.12", "SHA384withRSA");
- map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.12", "SHA384withRSA");
+ add(p, "KeyFactory", "RSASSA-PSS",
+ "sun.security.rsa.RSAKeyFactory$PSS",
+ rsapssAliases, null);
+ add(p, "KeyPairGenerator", "RSASSA-PSS",
+ "sun.security.rsa.RSAKeyPairGenerator$PSS",
+ rsapssAliases, null);
+ add(p, "Signature", "RSASSA-PSS",
+ "sun.security.rsa.RSAPSSSignature",
+ rsapssAliases, attrs);
+ add(p, "AlgorithmParameters", "RSASSA-PSS",
+ "sun.security.rsa.PSSParameters",
+ rsapssAliases, null);
+ }
- map.put("Alg.Alias.Signature.1.2.840.113549.1.1.13", "SHA512withRSA");
- map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.13", "SHA512withRSA");
- map.put("Alg.Alias.Signature.1.2.840.113549.1.1.15", "SHA512/224withRSA");
- map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.15", "SHA512/224withRSA");
- map.put("Alg.Alias.Signature.1.2.840.113549.1.1.16", "SHA512/256withRSA");
- map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.16", "SHA512/256withRSA");
-
- map.put("Alg.Alias.KeyFactory.1.2.840.113549.1.1.10", "RSASSA-PSS");
- map.put("Alg.Alias.KeyFactory.OID.1.2.840.113549.1.1.10", "RSASSA-PSS");
+ public Iterator<Provider.Service> iterator() {
+ return services.iterator();
+ }
- map.put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1.10", "RSASSA-PSS");
- map.put("Alg.Alias.KeyPairGenerator.OID.1.2.840.113549.1.1.10", "RSASSA-PSS");
-
- map.put("Alg.Alias.Signature.1.2.840.113549.1.1.10", "RSASSA-PSS");
- map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.10", "RSASSA-PSS");
-
- map.put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.1.10", "RSASSA-PSS");
- map.put("Alg.Alias.AlgorithmParameters.OID.1.2.840.113549.1.1.10", "RSASSA-PSS");
- }
+ private LinkedHashSet<Provider.Service> services;
}
--- a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java Tue Dec 18 15:08:56 2018 -0500
@@ -440,7 +440,7 @@
// It is not necessary to check the certificate update if
// endpoint identification is enabled.
String identityAlg = chc.sslConfig.identificationProtocol;
- if ((identityAlg == null || identityAlg.length() == 0) &&
+ if ((identityAlg == null || identityAlg.isEmpty()) &&
!isIdentityEquivalent(x509Certs[0],
chc.reservedServerCerts[0])) {
chc.conContext.fatal(Alert.BAD_CERTIFICATE,
--- a/src/java.base/share/classes/sun/security/ssl/ClientHello.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/ssl/ClientHello.java Tue Dec 18 15:08:56 2018 -0500
@@ -491,7 +491,7 @@
// It is fine to move on with abbreviate handshake if
// endpoint identification is enabled.
String identityAlg = chc.sslConfig.identificationProtocol;
- if ((identityAlg == null || identityAlg.length() == 0)) {
+ if (identityAlg == null || identityAlg.isEmpty()) {
if (isEmsAvailable) {
if (!session.useExtendedMasterSecret) {
// perform full handshake instead
--- a/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java Tue Dec 18 15:08:56 2018 -0500
@@ -253,7 +253,7 @@
static {
String property = GetPropertyAction.privilegedGetProperty(
"jdk.tls.ephemeralDHKeySize");
- if (property == null || property.length() == 0) {
+ if (property == null || property.isEmpty()) {
useLegacyEphemeralDHKeys = false;
useSmartEphemeralDHKeys = false;
customizedDHKeySize = -1;
--- a/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java Tue Dec 18 15:08:56 2018 -0500
@@ -237,7 +237,7 @@
public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, AlgorithmParameters parameters) {
- if (algorithm == null || algorithm.length() == 0) {
+ if (algorithm == null || algorithm.isEmpty()) {
throw new IllegalArgumentException(
"No algorithm name specified");
}
@@ -276,7 +276,7 @@
public final boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
- if (algorithm == null || algorithm.length() == 0) {
+ if (algorithm == null || algorithm.isEmpty()) {
throw new IllegalArgumentException(
"No algorithm name specified");
}
--- a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -436,7 +436,7 @@
"System property " + propertyName + " is set to '" +
property + "'");
}
- if (property != null && property.length() != 0) {
+ if (property != null && !property.isEmpty()) {
// remove double quote marks from beginning/end of the property
if (property.length() > 1 && property.charAt(0) == '"' &&
property.charAt(property.length() - 1) == '"') {
@@ -444,7 +444,7 @@
}
}
- if (property != null && property.length() != 0) {
+ if (property != null && !property.isEmpty()) {
String[] cipherSuiteNames = property.split(",");
Collection<CipherSuite> cipherSuites =
new ArrayList<>(cipherSuiteNames.length);
@@ -845,7 +845,7 @@
return;
}
- if (property.length() != 0) {
+ if (!property.isEmpty()) {
// remove double quote marks from beginning/end of the property
if (property.length() > 1 && property.charAt(0) == '"' &&
property.charAt(property.length() - 1) == '"') {
@@ -853,7 +853,7 @@
}
}
- if (property.length() != 0) {
+ if (!property.isEmpty()) {
String[] protocols = property.split(",");
for (int i = 0; i < protocols.length; i++) {
protocols[i] = protocols[i].trim();
@@ -1109,7 +1109,7 @@
KeyStore ks = null;
char[] passwd = null;
try {
- if (defaultKeyStore.length() != 0 &&
+ if (!defaultKeyStore.isEmpty() &&
!NONE.equals(defaultKeyStore)) {
fs = AccessController.doPrivileged(
new PrivilegedExceptionAction<FileInputStream>() {
@@ -1121,7 +1121,7 @@
}
String defaultKeyStorePassword = props.get("keyStorePasswd");
- if (defaultKeyStorePassword.length() != 0) {
+ if (!defaultKeyStorePassword.isEmpty()) {
passwd = defaultKeyStorePassword.toCharArray();
}
@@ -1132,7 +1132,7 @@
if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
SSLLogger.finest("init keystore");
}
- if (defaultKeyStoreProvider.length() == 0) {
+ if (defaultKeyStoreProvider.isEmpty()) {
ks = KeyStore.getInstance(defaultKeyStoreType);
} else {
ks = KeyStore.getInstance(defaultKeyStoreType,
@@ -1561,7 +1561,7 @@
// check endpoint identity
String identityAlg = sslSocket.getSSLParameters().
getEndpointIdentificationAlgorithm();
- if (identityAlg != null && identityAlg.length() != 0) {
+ if (identityAlg != null && !identityAlg.isEmpty()) {
String hostname = session.getPeerHost();
X509TrustManagerImpl.checkIdentity(
hostname, chain[0], identityAlg);
@@ -1601,7 +1601,7 @@
// check endpoint identity
String identityAlg = engine.getSSLParameters().
getEndpointIdentificationAlgorithm();
- if (identityAlg != null && identityAlg.length() != 0) {
+ if (identityAlg != null && !identityAlg.isEmpty()) {
String hostname = session.getPeerHost();
X509TrustManagerImpl.checkIdentity(
hostname, chain[0], identityAlg);
--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -1203,7 +1203,7 @@
synchronized void doneConnect() throws IOException {
// In server mode, it is not necessary to set host and serverNames.
// Otherwise, would require a reverse DNS lookup to get the hostname.
- if ((peerHost == null) || (peerHost.length() == 0)) {
+ if (peerHost == null || peerHost.isEmpty()) {
boolean useNameService =
trustNameService && conContext.sslConfig.isClientMode;
useImplicitHost(useNameService);
@@ -1238,8 +1238,7 @@
JavaNetInetAddressAccess jna =
SharedSecrets.getJavaNetInetAddressAccess();
String originalHostname = jna.getOriginalHostName(inetAddress);
- if ((originalHostname != null) &&
- (originalHostname.length() != 0)) {
+ if (originalHostname != null && !originalHostname.isEmpty()) {
this.peerHost = originalHostname;
if (conContext.sslConfig.serverNames.isEmpty() &&
--- a/src/java.base/share/classes/sun/security/ssl/SunJSSE.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/ssl/SunJSSE.java Tue Dec 18 15:08:56 2018 -0500
@@ -26,7 +26,10 @@
package sun.security.ssl;
import java.security.*;
+import java.util.*;
+import sun.security.rsa.SunRsaSignEntries;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
+import static sun.security.provider.SunEntries.createAliases;
/**
* The JSSE provider.
@@ -157,86 +160,62 @@
});
}
+ private void ps(String type, String algo, String cn,
+ List<String> aliases, HashMap<String, String> attrs) {
+ putService(new Provider.Service(this, type, algo, cn, aliases, attrs));
+ }
+
private void doRegister(boolean isfips) {
if (isfips == false) {
- put("KeyFactory.RSA",
- "sun.security.rsa.RSAKeyFactory$Legacy");
- put("Alg.Alias.KeyFactory.1.2.840.113549.1.1", "RSA");
- put("Alg.Alias.KeyFactory.OID.1.2.840.113549.1.1", "RSA");
-
- put("KeyPairGenerator.RSA",
- "sun.security.rsa.RSAKeyPairGenerator$Legacy");
- put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1", "RSA");
- put("Alg.Alias.KeyPairGenerator.OID.1.2.840.113549.1.1", "RSA");
-
- put("Signature.MD2withRSA",
- "sun.security.rsa.RSASignature$MD2withRSA");
- put("Alg.Alias.Signature.1.2.840.113549.1.1.2", "MD2withRSA");
- put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.2",
- "MD2withRSA");
+ Iterator<Provider.Service> rsaIter =
+ new SunRsaSignEntries(this).iterator();
+ while (rsaIter.hasNext()) {
+ putService(rsaIter.next());
+ }
+ }
+ ps("Signature", "MD5andSHA1withRSA",
+ "sun.security.ssl.RSASignature", null, null);
- put("Signature.MD5withRSA",
- "sun.security.rsa.RSASignature$MD5withRSA");
- put("Alg.Alias.Signature.1.2.840.113549.1.1.4", "MD5withRSA");
- put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.4",
- "MD5withRSA");
+ ps("KeyManagerFactory", "SunX509",
+ "sun.security.ssl.KeyManagerFactoryImpl$SunX509", null, null);
+ ps("KeyManagerFactory", "NewSunX509",
+ "sun.security.ssl.KeyManagerFactoryImpl$X509",
+ createAliases("PKIX"), null);
- put("Signature.SHA1withRSA",
- "sun.security.rsa.RSASignature$SHA1withRSA");
- put("Alg.Alias.Signature.1.2.840.113549.1.1.5", "SHA1withRSA");
- put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.5",
- "SHA1withRSA");
- put("Alg.Alias.Signature.1.3.14.3.2.29", "SHA1withRSA");
- put("Alg.Alias.Signature.OID.1.3.14.3.2.29", "SHA1withRSA");
-
- }
- put("Signature.MD5andSHA1withRSA",
- "sun.security.ssl.RSASignature");
+ ps("TrustManagerFactory", "SunX509",
+ "sun.security.ssl.TrustManagerFactoryImpl$SimpleFactory", null, null);
+ ps("TrustManagerFactory", "PKIX",
+ "sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory",
+ createAliases("SunPKIX", "X509", "X.509"), null);
- put("KeyManagerFactory.SunX509",
- "sun.security.ssl.KeyManagerFactoryImpl$SunX509");
- put("KeyManagerFactory.NewSunX509",
- "sun.security.ssl.KeyManagerFactoryImpl$X509");
- put("Alg.Alias.KeyManagerFactory.PKIX", "NewSunX509");
-
- put("TrustManagerFactory.SunX509",
- "sun.security.ssl.TrustManagerFactoryImpl$SimpleFactory");
- put("TrustManagerFactory.PKIX",
- "sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory");
- put("Alg.Alias.TrustManagerFactory.SunPKIX", "PKIX");
- put("Alg.Alias.TrustManagerFactory.X509", "PKIX");
- put("Alg.Alias.TrustManagerFactory.X.509", "PKIX");
+ ps("SSLContext", "TLSv1",
+ "sun.security.ssl.SSLContextImpl$TLS10Context",
+ (isfips? null : createAliases("SSLv3")), null);
+ ps("SSLContext", "TLSv1.1",
+ "sun.security.ssl.SSLContextImpl$TLS11Context", null, null);
+ ps("SSLContext", "TLSv1.2",
+ "sun.security.ssl.SSLContextImpl$TLS12Context", null, null);
+ ps("SSLContext", "TLSv1.3",
+ "sun.security.ssl.SSLContextImpl$TLS13Context", null, null);
+ ps("SSLContext", "TLS",
+ "sun.security.ssl.SSLContextImpl$TLSContext",
+ (isfips? null : createAliases("SSL")), null);
- put("SSLContext.TLSv1",
- "sun.security.ssl.SSLContextImpl$TLS10Context");
- put("SSLContext.TLSv1.1",
- "sun.security.ssl.SSLContextImpl$TLS11Context");
- put("SSLContext.TLSv1.2",
- "sun.security.ssl.SSLContextImpl$TLS12Context");
- put("SSLContext.TLSv1.3",
- "sun.security.ssl.SSLContextImpl$TLS13Context");
- put("SSLContext.TLS",
- "sun.security.ssl.SSLContextImpl$TLSContext");
- if (isfips == false) {
- put("Alg.Alias.SSLContext.SSL", "TLS");
- put("Alg.Alias.SSLContext.SSLv3", "TLSv1");
- }
+ ps("SSLContext", "DTLSv1.0",
+ "sun.security.ssl.SSLContextImpl$DTLS10Context", null, null);
+ ps("SSLContext", "DTLSv1.2",
+ "sun.security.ssl.SSLContextImpl$DTLS12Context", null, null);
+ ps("SSLContext", "DTLS",
+ "sun.security.ssl.SSLContextImpl$DTLSContext", null, null);
- put("SSLContext.DTLSv1.0",
- "sun.security.ssl.SSLContextImpl$DTLS10Context");
- put("SSLContext.DTLSv1.2",
- "sun.security.ssl.SSLContextImpl$DTLS12Context");
- put("SSLContext.DTLS",
- "sun.security.ssl.SSLContextImpl$DTLSContext");
-
- put("SSLContext.Default",
- "sun.security.ssl.SSLContextImpl$DefaultSSLContext");
+ ps("SSLContext", "Default",
+ "sun.security.ssl.SSLContextImpl$DefaultSSLContext", null, null);
/*
* KeyStore
*/
- put("KeyStore.PKCS12",
- "sun.security.pkcs12.PKCS12KeyStore");
+ ps("KeyStore", "PKCS12",
+ "sun.security.pkcs12.PKCS12KeyStore", null, null);
}
// com.sun.net.ssl.internal.ssl.Provider has been deprecated since JDK 9
--- a/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java Tue Dec 18 15:08:56 2018 -0500
@@ -483,7 +483,7 @@
// default groups and preferences will be used.
String property = GetPropertyAction
.privilegedGetProperty("jdk.tls.namedGroups");
- if (property != null && property.length() != 0) {
+ if (property != null && !property.isEmpty()) {
// remove double quote marks from beginning/end of the property
if (property.length() > 1 && property.charAt(0) == '"' &&
property.charAt(property.length() - 1) == '"') {
@@ -492,7 +492,7 @@
}
ArrayList<NamedGroup> groupList;
- if (property != null && property.length() != 0) {
+ if (property != null && !property.isEmpty()) {
String[] groups = property.split(",");
groupList = new ArrayList<>(groups.length);
for (String group : groups) {
--- a/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -148,7 +148,7 @@
"null or zero-length certificate chain");
}
- if (authType == null || authType.length() == 0) {
+ if (authType == null || authType.isEmpty()) {
throw new IllegalArgumentException(
"null or zero-length authentication type");
}
@@ -229,7 +229,7 @@
// check endpoint identity
String identityAlg = sslSocket.getSSLParameters().
getEndpointIdentificationAlgorithm();
- if (identityAlg != null && identityAlg.length() != 0) {
+ if (identityAlg != null && !identityAlg.isEmpty()) {
checkIdentity(session, trustedChain[0], identityAlg, isClient,
getRequestedServerNames(socket), chainsToPublicCA);
}
@@ -287,7 +287,7 @@
// check endpoint identity
String identityAlg = engine.getSSLParameters().
getEndpointIdentificationAlgorithm();
- if (identityAlg != null && identityAlg.length() != 0) {
+ if (identityAlg != null && !identityAlg.isEmpty()) {
checkIdentity(session, trustedChain[0], identityAlg, isClient,
getRequestedServerNames(engine), chainsToPublicCA);
}
@@ -448,7 +448,7 @@
private static void checkIdentity(String hostname, X509Certificate cert,
String algorithm, boolean chainsToPublicCA)
throws CertificateException {
- if (algorithm != null && algorithm.length() != 0) {
+ if (algorithm != null && !algorithm.isEmpty()) {
// if IPv6 strip off the "[]"
if ((hostname != null) && hostname.startsWith("[") &&
hostname.endsWith("]")) {
--- a/src/java.base/share/classes/sun/security/tools/PathList.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/tools/PathList.java Tue Dec 18 15:08:56 2018 -0500
@@ -46,9 +46,9 @@
* @return the resulting path
*/
public static String appendPath(String pathTo, String pathFrom) {
- if (pathTo == null || pathTo.length() == 0) {
+ if (pathTo == null || pathTo.isEmpty()) {
return pathFrom;
- } else if (pathFrom == null || pathFrom.length() == 0) {
+ } else if (pathFrom == null || pathFrom.isEmpty()) {
return pathTo;
} else {
return pathTo + File.pathSeparator + pathFrom;
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java Tue Dec 18 15:08:56 2018 -0500
@@ -70,6 +70,7 @@
import javax.security.auth.x500.X500Principal;
import java.util.Base64;
+import sun.security.pkcs12.PKCS12KeyStore;
import sun.security.util.ECKeySizeParameterSpec;
import sun.security.util.KeyUtil;
import sun.security.util.NamedCurve;
@@ -79,6 +80,7 @@
import sun.security.provider.X509Factory;
import sun.security.provider.certpath.ssl.SSLServerCertStore;
import sun.security.util.Password;
+import sun.security.util.SecurityProperties;
import sun.security.util.SecurityProviderConstants;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
@@ -188,6 +190,7 @@
private static final Set<CryptoPrimitive> SIG_PRIMITIVE_SET = Collections
.unmodifiableSet(EnumSet.of(CryptoPrimitive.SIGNATURE));
+ private boolean isPasswordlessKeyStore = false;
enum Command {
CERTREQ("Generates.a.certificate.request",
@@ -919,6 +922,9 @@
storetype == null && !inplaceImport) {
keyStore = KeyStore.getInstance(ksfile, storePass);
storetype = keyStore.getType();
+ if (storetype.equalsIgnoreCase("pkcs12")) {
+ isPasswordlessKeyStore = PKCS12KeyStore.isPasswordless(ksfile);
+ }
} else {
if (storetype == null) {
storetype = KeyStore.getDefaultType();
@@ -928,6 +934,15 @@
} else {
keyStore = KeyStore.getInstance(storetype, providerName);
}
+ // When creating a new pkcs12 file, Do not prompt for storepass
+ // if certProtectionAlgorithm and macAlgorithm are both NONE.
+ if (storetype.equalsIgnoreCase("pkcs12")) {
+ isPasswordlessKeyStore =
+ "NONE".equals(SecurityProperties.privilegedGetOverridable(
+ "keystore.pkcs12.certProtectionAlgorithm"))
+ && "NONE".equals(SecurityProperties.privilegedGetOverridable(
+ "keystore.pkcs12.macAlgorithm"));
+ }
/*
* Load the keystore data.
@@ -979,11 +994,10 @@
("Keystore.password.must.be.at.least.6.characters"));
}
} else if (storePass == null) {
-
- // only prompt if (protectedPath == false)
-
- if (!protectedPath && !KeyStoreUtil.isWindowsKeyStore(storetype) &&
- (command == CERTREQ ||
+ if (!protectedPath && !KeyStoreUtil.isWindowsKeyStore(storetype)
+ && isKeyStoreRelated(command)
+ && !isPasswordlessKeyStore) {
+ if (command == CERTREQ ||
command == DELETE ||
command == GENKEYPAIR ||
command == GENSECKEY ||
@@ -995,59 +1009,58 @@
command == SELFCERT ||
command == STOREPASSWD ||
command == KEYPASSWD ||
- command == IDENTITYDB)) {
- int count = 0;
- do {
- if (command == IMPORTKEYSTORE) {
- System.err.print
- (rb.getString("Enter.destination.keystore.password."));
- } else {
- System.err.print
- (rb.getString("Enter.keystore.password."));
- }
- System.err.flush();
- storePass = Password.readPassword(System.in);
- passwords.add(storePass);
-
- // If we are creating a new non nullStream-based keystore,
- // insist that the password be at least 6 characters
- if (!nullStream && (storePass == null || storePass.length < 6)) {
- System.err.println(rb.getString
- ("Keystore.password.is.too.short.must.be.at.least.6.characters"));
- storePass = null;
- }
-
- // If the keystore file does not exist and needs to be
- // created, the storepass should be prompted twice.
- if (storePass != null && !nullStream && ksStream == null) {
- System.err.print(rb.getString("Re.enter.new.password."));
- char[] storePassAgain = Password.readPassword(System.in);
- passwords.add(storePassAgain);
- if (!Arrays.equals(storePass, storePassAgain)) {
- System.err.println
- (rb.getString("They.don.t.match.Try.again"));
+ command == IDENTITYDB) {
+ int count = 0;
+ do {
+ if (command == IMPORTKEYSTORE) {
+ System.err.print
+ (rb.getString("Enter.destination.keystore.password."));
+ } else {
+ System.err.print
+ (rb.getString("Enter.keystore.password."));
+ }
+ System.err.flush();
+ storePass = Password.readPassword(System.in);
+ passwords.add(storePass);
+
+ // If we are creating a new non nullStream-based keystore,
+ // insist that the password be at least 6 characters
+ if (!nullStream && (storePass == null || storePass.length < 6)) {
+ System.err.println(rb.getString
+ ("Keystore.password.is.too.short.must.be.at.least.6.characters"));
storePass = null;
}
+
+ // If the keystore file does not exist and needs to be
+ // created, the storepass should be prompted twice.
+ if (storePass != null && !nullStream && ksStream == null) {
+ System.err.print(rb.getString("Re.enter.new.password."));
+ char[] storePassAgain = Password.readPassword(System.in);
+ passwords.add(storePassAgain);
+ if (!Arrays.equals(storePass, storePassAgain)) {
+ System.err.println
+ (rb.getString("They.don.t.match.Try.again"));
+ storePass = null;
+ }
+ }
+
+ count++;
+ } while ((storePass == null) && count < 3);
+
+
+ if (storePass == null) {
+ System.err.println
+ (rb.getString("Too.many.failures.try.later"));
+ return;
}
-
- count++;
- } while ((storePass == null) && count < 3);
-
-
- if (storePass == null) {
- System.err.println
- (rb.getString("Too.many.failures.try.later"));
- return;
- }
- } else if (!protectedPath
- && !KeyStoreUtil.isWindowsKeyStore(storetype)
- && isKeyStoreRelated(command)) {
- // here we have EXPORTCERT and LIST (info valid until STOREPASSWD)
- if (command != PRINTCRL) {
- System.err.print(rb.getString("Enter.keystore.password."));
- System.err.flush();
- storePass = Password.readPassword(System.in);
- passwords.add(storePass);
+ } else {
+ // here we have EXPORTCERT and LIST (info valid until STOREPASSWD)
+ if (command != PRINTCRL) {
+ System.err.print(rb.getString("Enter.keystore.password."));
+ System.err.flush();
+ storePass = Password.readPassword(System.in);
+ passwords.add(storePass);
+ }
}
}
@@ -1233,7 +1246,8 @@
kssave = true;
} else if (command == LIST) {
if (storePass == null
- && !KeyStoreUtil.isWindowsKeyStore(storetype)) {
+ && !KeyStoreUtil.isWindowsKeyStore(storetype)
+ && !isPasswordlessKeyStore) {
printNoIntegrityWarning();
}
@@ -1602,7 +1616,8 @@
throws Exception
{
if (storePass == null
- && !KeyStoreUtil.isWindowsKeyStore(storetype)) {
+ && !KeyStoreUtil.isWindowsKeyStore(storetype)
+ && !isPasswordlessKeyStore) {
printNoIntegrityWarning();
}
if (alias == null) {
@@ -1633,7 +1648,7 @@
* @param origPass the password to copy from if user press ENTER
*/
private char[] promptForKeyPass(String alias, String orig, char[] origPass) throws Exception{
- if (P12KEYSTORE.equalsIgnoreCase(storetype)) {
+ if (origPass != null && P12KEYSTORE.equalsIgnoreCase(storetype)) {
return origPass;
} else if (!token && !protectedPath) {
// Prompt for key password
@@ -1642,22 +1657,25 @@
MessageFormat form = new MessageFormat(rb.getString
("Enter.key.password.for.alias."));
Object[] source = {alias};
- System.err.println(form.format(source));
- if (orig == null) {
- System.err.print(rb.getString
- (".RETURN.if.same.as.keystore.password."));
- } else {
- form = new MessageFormat(rb.getString
- (".RETURN.if.same.as.for.otherAlias."));
- Object[] src = {orig};
- System.err.print(form.format(src));
+ System.err.print(form.format(source));
+ if (origPass != null) {
+ System.err.println();
+ if (orig == null) {
+ System.err.print(rb.getString
+ (".RETURN.if.same.as.keystore.password."));
+ } else {
+ form = new MessageFormat(rb.getString
+ (".RETURN.if.same.as.for.otherAlias."));
+ Object[] src = {orig};
+ System.err.print(form.format(src));
+ }
}
System.err.flush();
char[] entered = Password.readPassword(System.in);
passwords.add(entered);
- if (entered == null) {
+ if (entered == null && origPass != null) {
return origPass;
- } else if (entered.length >= 6) {
+ } else if (entered != null && entered.length >= 6) {
System.err.print(rb.getString("Re.enter.new.password."));
char[] passAgain = Password.readPassword(System.in);
passwords.add(passAgain);
@@ -2066,6 +2084,9 @@
getCertFingerPrint("SHA-256", chain[0]));
checkWeak(label, chain);
}
+ } else {
+ out.println(rb.getString
+ ("Certificate.chain.length.") + 0);
}
} else if (keyStore.entryInstanceOf(alias,
KeyStore.TrustedCertificateEntry.class)) {
@@ -2130,6 +2151,7 @@
InputStream is = null;
File srcksfile = null;
+ boolean srcIsPasswordless = false;
if (P11KEYSTORE.equalsIgnoreCase(srcstoretype) ||
KeyStoreUtil.isWindowsKeyStore(srcstoretype)) {
@@ -2151,6 +2173,9 @@
srcstoretype == null) {
store = KeyStore.getInstance(srcksfile, srcstorePass);
srcstoretype = store.getType();
+ if (srcstoretype.equalsIgnoreCase("pkcs12")) {
+ srcIsPasswordless = PKCS12KeyStore.isPasswordless(srcksfile);
+ }
} else {
if (srcstoretype == null) {
srcstoretype = KeyStore.getDefaultType();
@@ -2164,7 +2189,8 @@
if (srcstorePass == null
&& !srcprotectedPath
- && !KeyStoreUtil.isWindowsKeyStore(srcstoretype)) {
+ && !KeyStoreUtil.isWindowsKeyStore(srcstoretype)
+ && !srcIsPasswordless) {
System.err.print(rb.getString("Enter.source.keystore.password."));
System.err.flush();
srcstorePass = Password.readPassword(System.in);
@@ -2191,6 +2217,7 @@
}
if (srcstorePass == null
+ && !srcIsPasswordless
&& !KeyStoreUtil.isWindowsKeyStore(srcstoretype)) {
// anti refactoring, copied from printNoIntegrityWarning(),
// but change 2 lines
@@ -3537,25 +3564,25 @@
if (keyPass == null) {
// Try to recover the key using the keystore password
- try {
- key = keyStore.getKey(alias, storePass);
-
- keyPass = storePass;
- passwords.add(keyPass);
- } catch (UnrecoverableKeyException e) {
- // Did not work out, so prompt user for key password
- if (!token) {
- keyPass = getKeyPasswd(alias, null, null);
- key = keyStore.getKey(alias, keyPass);
- } else {
- throw e;
+ if (storePass != null) {
+ try {
+ key = keyStore.getKey(alias, storePass);
+ passwords.add(storePass);
+ return Pair.of(key, storePass);
+ } catch (UnrecoverableKeyException e) {
+ if (token) {
+ throw e;
+ }
}
}
+ // prompt user for key password
+ keyPass = getKeyPasswd(alias, null, null);
+ key = keyStore.getKey(alias, keyPass);
+ return Pair.of(key, keyPass);
} else {
key = keyStore.getKey(alias, keyPass);
+ return Pair.of(key, keyPass);
}
-
- return Pair.of(key, keyPass);
}
/**
@@ -3570,68 +3597,59 @@
char[] pstore,
char[] pkey) throws Exception {
- if (ks.containsAlias(alias) == false) {
- MessageFormat form = new MessageFormat
- (rb.getString("Alias.alias.does.not.exist"));
+ if (!ks.containsAlias(alias)) {
+ MessageFormat form = new MessageFormat(
+ rb.getString("Alias.alias.does.not.exist"));
Object[] source = {alias};
throw new Exception(form.format(source));
}
- PasswordProtection pp = null;
- Entry entry;
-
+ // Step 1: First attempt to access entry without key password
+ // (PKCS11 entry or trusted certificate entry, for example).
+ // If fail, go next.
try {
- // First attempt to access entry without key password
- // (PKCS11 entry or trusted certificate entry, for example)
-
- entry = ks.getEntry(alias, pp);
- pkey = null;
+ Entry entry = ks.getEntry(alias, null);
+ return Pair.of(entry, null);
} catch (UnrecoverableEntryException une) {
-
if(P11KEYSTORE.equalsIgnoreCase(ks.getType()) ||
- KeyStoreUtil.isWindowsKeyStore(ks.getType())) {
+ KeyStoreUtil.isWindowsKeyStore(ks.getType())) {
// should not happen, but a possibility
throw une;
}
-
- // entry is protected
-
- if (pkey != null) {
-
- // try provided key password
-
- pp = new PasswordProtection(pkey);
- entry = ks.getEntry(alias, pp);
-
- } else {
-
- // try store pass
-
- try {
- pp = new PasswordProtection(pstore);
- entry = ks.getEntry(alias, pp);
- pkey = pstore;
- } catch (UnrecoverableEntryException une2) {
- if (P12KEYSTORE.equalsIgnoreCase(ks.getType())) {
-
- // P12 keystore currently does not support separate
- // store and entry passwords
-
- throw une2;
- } else {
-
- // prompt for entry password
-
- pkey = getKeyPasswd(alias, null, null);
- pp = new PasswordProtection(pkey);
- entry = ks.getEntry(alias, pp);
- }
+ }
+
+ // entry is protected
+
+ // Step 2: try pkey if not null. If fail, fail.
+ if (pkey != null) {
+ PasswordProtection pp = new PasswordProtection(pkey);
+ Entry entry = ks.getEntry(alias, pp);
+ return Pair.of(entry, pkey);
+ }
+
+ // Step 3: try pstore if not null. If fail, go next.
+ if (pstore != null) {
+ try {
+ PasswordProtection pp = new PasswordProtection(pstore);
+ Entry entry = ks.getEntry(alias, pp);
+ return Pair.of(entry, pstore);
+ } catch (UnrecoverableEntryException une) {
+ if (P12KEYSTORE.equalsIgnoreCase(ks.getType())) {
+ // P12 keystore currently does not support separate
+ // store and entry passwords. We will not prompt for
+ // entry password.
+ throw une;
}
}
}
+ // Step 4: prompt for entry password
+ pkey = getKeyPasswd(alias, null, null);
+ PasswordProtection pp = new PasswordProtection(pkey);
+ Entry entry = ks.getEntry(alias, pp);
return Pair.of(entry, pkey);
}
+
/**
* Gets the requested finger print of the certificate.
*/
--- a/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java Tue Dec 18 15:08:56 2018 -0500
@@ -75,7 +75,7 @@
static boolean checkAlgorithm(String[] algorithms, String algorithm,
AlgorithmDecomposer decomposer) {
- if (algorithm == null || algorithm.length() == 0) {
+ if (algorithm == null || algorithm.isEmpty()) {
throw new IllegalArgumentException("No algorithm name specified");
}
--- a/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java Tue Dec 18 15:08:56 2018 -0500
@@ -80,7 +80,7 @@
* Please override the method if need to support more name pattern.
*/
public Set<String> decompose(String algorithm) {
- if (algorithm == null || algorithm.length() == 0) {
+ if (algorithm == null || algorithm.isEmpty()) {
return new HashSet<>();
}
@@ -167,7 +167,7 @@
* message digest algorithm name to avoid overly complicated checking.
*/
public static Set<String> decomposeOneHash(String algorithm) {
- if (algorithm == null || algorithm.length() == 0) {
+ if (algorithm == null || algorithm.isEmpty()) {
return new HashSet<>();
}
--- a/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java Tue Dec 18 15:08:56 2018 -0500
@@ -135,7 +135,7 @@
public final boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
- if (algorithm == null || algorithm.length() == 0) {
+ if (algorithm == null || algorithm.isEmpty()) {
throw new IllegalArgumentException("No algorithm name specified");
}
@@ -188,7 +188,7 @@
}
// check the signature algorithm with parameters
- if (algorithm != null && algorithm.length() != 0) {
+ if (algorithm != null && !algorithm.isEmpty()) {
if (!permits(primitives, algorithm, parameters)) {
return false;
}
--- a/src/java.base/share/classes/sun/security/util/ECUtil.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/util/ECUtil.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
* 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,17 +26,11 @@
package sun.security.util;
import java.io.IOException;
-
import java.math.BigInteger;
-
import java.security.*;
-
import java.security.interfaces.*;
-
import java.security.spec.*;
-
import java.util.Arrays;
-
import sun.security.x509.X509Key;
public class ECUtil {
@@ -227,5 +221,64 @@
return nameSpec.getName();
}
+ // Convert the concatenation R and S in into their DER encoding
+ public static byte[] encodeSignature(byte[] signature) throws SignatureException {
+
+ try {
+
+ int n = signature.length >> 1;
+ byte[] bytes = new byte[n];
+ System.arraycopy(signature, 0, bytes, 0, n);
+ BigInteger r = new BigInteger(1, bytes);
+ System.arraycopy(signature, n, bytes, 0, n);
+ BigInteger s = new BigInteger(1, bytes);
+
+ DerOutputStream out = new DerOutputStream(signature.length + 10);
+ out.putInteger(r);
+ out.putInteger(s);
+ DerValue result =
+ new DerValue(DerValue.tag_Sequence, out.toByteArray());
+
+ return result.toByteArray();
+
+ } catch (Exception e) {
+ throw new SignatureException("Could not encode signature", e);
+ }
+ }
+
+ // Convert the DER encoding of R and S into a concatenation of R and S
+ public static byte[] decodeSignature(byte[] sig) throws SignatureException {
+
+ try {
+ // Enforce strict DER checking for signatures
+ DerInputStream in = new DerInputStream(sig, 0, sig.length, false);
+ DerValue[] values = in.getSequence(2);
+
+ // check number of components in the read sequence
+ // and trailing data
+ if ((values.length != 2) || (in.available() != 0)) {
+ throw new IOException("Invalid encoding for signature");
+ }
+
+ BigInteger r = values[0].getPositiveBigInteger();
+ BigInteger s = values[1].getPositiveBigInteger();
+
+ // trim leading zeroes
+ byte[] rBytes = trimZeroes(r.toByteArray());
+ byte[] sBytes = trimZeroes(s.toByteArray());
+ int k = Math.max(rBytes.length, sBytes.length);
+ // r and s each occupy half the array
+ byte[] result = new byte[k << 1];
+ System.arraycopy(rBytes, 0, result, k - rBytes.length,
+ rBytes.length);
+ System.arraycopy(sBytes, 0, result, result.length - sBytes.length,
+ sBytes.length);
+ return result;
+
+ } catch (Exception e) {
+ throw new SignatureException("Invalid encoding for signature", e);
+ }
+ }
+
private ECUtil() {}
}
--- a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java Tue Dec 18 15:08:56 2018 -0500
@@ -423,7 +423,7 @@
// This means we have an error in finding weak algorithms, run in
// debug mode to see permittedAlgs map's values.
- if (w.length() == 0) {
+ if (w.isEmpty()) {
return "Unknown Algorithm(s)";
}
--- a/src/java.base/share/classes/sun/security/x509/AVA.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/x509/AVA.java Tue Dec 18 15:08:56 2018 -0500
@@ -1245,7 +1245,7 @@
}
boolean number = false;
- if (keyword.length() != 0) {
+ if (!keyword.isEmpty()) {
char ch = keyword.charAt(0);
if ((ch >= '0') && (ch <= '9')) {
number = true;
@@ -1285,7 +1285,7 @@
return ak.keyword;
}
} else {
- if (keywordString.length() == 0) {
+ if (keywordString.isEmpty()) {
throw new IllegalArgumentException("keyword cannot be empty");
}
keywordString = keywordString.trim();
--- a/src/java.base/share/classes/sun/security/x509/AlgorithmId.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/x509/AlgorithmId.java Tue Dec 18 15:08:56 2018 -0500
@@ -771,8 +771,14 @@
ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 10});
public static final ObjectIdentifier pbeWithSHA1AndRC2_oid =
ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 11});
+ public static ObjectIdentifier pbeWithSHA1AndRC4_128_oid =
+ ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 1});
+ public static ObjectIdentifier pbeWithSHA1AndRC4_40_oid =
+ ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 2});
public static ObjectIdentifier pbeWithSHA1AndDESede_oid =
ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 3});
+ public static ObjectIdentifier pbeWithSHA1AndRC2_128_oid =
+ ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 5});
public static ObjectIdentifier pbeWithSHA1AndRC2_40_oid =
ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 6});
@@ -961,7 +967,10 @@
nameTable.put(pbeWithMD5AndRC2_oid, "PBEWithMD5AndRC2");
nameTable.put(pbeWithSHA1AndDES_oid, "PBEWithSHA1AndDES");
nameTable.put(pbeWithSHA1AndRC2_oid, "PBEWithSHA1AndRC2");
+ nameTable.put(pbeWithSHA1AndRC4_128_oid, "PBEWithSHA1AndRC4_128");
+ nameTable.put(pbeWithSHA1AndRC4_40_oid, "PBEWithSHA1AndRC4_40");
nameTable.put(pbeWithSHA1AndDESede_oid, "PBEWithSHA1AndDESede");
+ nameTable.put(pbeWithSHA1AndRC2_128_oid, "PBEWithSHA1AndRC2_128");
nameTable.put(pbeWithSHA1AndRC2_40_oid, "PBEWithSHA1AndRC2_40");
}
--- a/src/java.base/share/classes/sun/security/x509/DNSName.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/x509/DNSName.java Tue Dec 18 15:08:56 2018 -0500
@@ -72,7 +72,7 @@
* @throws IOException if the name is not a valid DNSName subjectAltName
*/
public DNSName(String name) throws IOException {
- if (name == null || name.length() == 0)
+ if (name == null || name.isEmpty())
throw new IOException("DNSName must not be null or empty");
if (name.contains(" "))
throw new IOException("DNSName with blank components is not permitted");
--- a/src/java.base/share/classes/sun/security/x509/IPAddressName.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/x509/IPAddressName.java Tue Dec 18 15:08:56 2018 -0500
@@ -125,7 +125,7 @@
*/
public IPAddressName(String name) throws IOException {
- if (name == null || name.length() == 0) {
+ if (name == null || name.isEmpty()) {
throw new IOException("IPAddress cannot be null or empty");
}
if (name.charAt(name.length() - 1) == '/') {
--- a/src/java.base/share/classes/sun/security/x509/RDN.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/x509/RDN.java Tue Dec 18 15:08:56 2018 -0500
@@ -121,7 +121,7 @@
* Plus sign is a separator
*/
String avaString = name.substring(avaOffset, nextPlus);
- if (avaString.length() == 0) {
+ if (avaString.isEmpty()) {
throw new IOException("empty AVA in RDN \"" + name + "\"");
}
@@ -141,7 +141,7 @@
// parse last or only AVA
String avaString = name.substring(avaOffset);
- if (avaString.length() == 0) {
+ if (avaString.isEmpty()) {
throw new IOException("empty AVA in RDN \"" + name + "\"");
}
AVA ava = new AVA(new StringReader(avaString), keywordMap);
@@ -199,7 +199,7 @@
* Plus sign is a separator
*/
String avaString = name.substring(avaOffset, nextPlus);
- if (avaString.length() == 0) {
+ if (avaString.isEmpty()) {
throw new IOException("empty AVA in RDN \"" + name + "\"");
}
@@ -217,7 +217,7 @@
// parse last or only AVA
String avaString = name.substring(avaOffset);
- if (avaString.length() == 0) {
+ if (avaString.isEmpty()) {
throw new IOException("empty AVA in RDN \"" + name + "\"");
}
AVA ava = new AVA(new StringReader(avaString), AVA.RFC2253, keywordMap);
--- a/src/java.base/share/classes/sun/security/x509/RFC822Name.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/x509/RFC822Name.java Tue Dec 18 15:08:56 2018 -0500
@@ -79,12 +79,12 @@
* @throws IOException if name is not valid
*/
public void parseName(String name) throws IOException {
- if (name == null || name.length() == 0) {
+ if (name == null || name.isEmpty()) {
throw new IOException("RFC822Name may not be null or empty");
}
// See if domain is a valid domain name
String domain = name.substring(name.indexOf('@')+1);
- if (domain.length() == 0) {
+ if (domain.isEmpty()) {
throw new IOException("RFC822Name may not end with @");
} else {
//An RFC822 NameConstraint could start with a ., although
--- a/src/java.base/share/classes/sun/security/x509/X500Name.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/x509/X500Name.java Tue Dec 18 15:08:56 2018 -0500
@@ -865,7 +865,7 @@
*/
private void parseDN(String input, Map<String, String> keywordMap)
throws IOException {
- if (input == null || input.length() == 0) {
+ if (input == null || input.isEmpty()) {
names = new RDN[0];
return;
}
@@ -937,7 +937,7 @@
}
private void parseRFC2253DN(String dnString) throws IOException {
- if (dnString.length() == 0) {
+ if (dnString.isEmpty()) {
names = new RDN[0];
return;
}
--- a/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -370,7 +370,7 @@
throw new CRLException("Uninitialized CRL");
}
Signature sigVerf = null;
- if (sigProvider.length() == 0) {
+ if (sigProvider.isEmpty()) {
sigVerf = Signature.getInstance(sigAlgId.getName());
} else {
sigVerf = Signature.getInstance(sigAlgId.getName(), sigProvider);
@@ -495,7 +495,7 @@
if (readOnly)
throw new CRLException("cannot over-write existing CRL");
Signature sigEngine = null;
- if ((provider == null) || (provider.length() == 0))
+ if (provider == null || provider.isEmpty())
sigEngine = Signature.getInstance(algorithm);
else
sigEngine = Signature.getInstance(algorithm, provider);
--- a/src/java.base/share/classes/sun/security/x509/X509CertImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/security/x509/X509CertImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -429,7 +429,7 @@
}
// Verify the signature ...
Signature sigVerf = null;
- if (sigProvider.length() == 0) {
+ if (sigProvider.isEmpty()) {
sigVerf = Signature.getInstance(algId.getName());
} else {
sigVerf = Signature.getInstance(algId.getName(), sigProvider);
@@ -598,7 +598,7 @@
throw new CertificateEncodingException(
"cannot over-write existing certificate");
Signature sigEngine = null;
- if ((provider == null) || (provider.length() == 0))
+ if (provider == null || provider.isEmpty())
sigEngine = Signature.getInstance(algorithm);
else
sigEngine = Signature.getInstance(algorithm, provider);
--- a/src/java.base/share/classes/sun/util/locale/InternalLocaleBuilder.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/util/locale/InternalLocaleBuilder.java Tue Dec 18 15:08:56 2018 -0500
@@ -331,7 +331,7 @@
done.add(key);
}
}
- if (privateuse != null && privateuse.length() > 0) {
+ if (privateuse != null && !privateuse.isEmpty()) {
// privateuse string contains prefix, e.g. "x-abc-def"
if (extensions == null) {
extensions = new HashMap<>(1);
@@ -406,19 +406,19 @@
// Validate base locale fields before updating internal state.
// LocaleExtensions always store validated/canonicalized values,
// so no checks are necessary.
- if (language.length() > 0 && !LanguageTag.isLanguage(language)) {
+ if (!language.isEmpty() && !LanguageTag.isLanguage(language)) {
throw new LocaleSyntaxException("Ill-formed language: " + language);
}
- if (script.length() > 0 && !LanguageTag.isScript(script)) {
+ if (!script.isEmpty() && !LanguageTag.isScript(script)) {
throw new LocaleSyntaxException("Ill-formed script: " + script);
}
- if (region.length() > 0 && !LanguageTag.isRegion(region)) {
+ if (!region.isEmpty() && !LanguageTag.isRegion(region)) {
throw new LocaleSyntaxException("Ill-formed region: " + region);
}
- if (variant.length() > 0) {
+ if (!variant.isEmpty()) {
int errIdx = checkVariants(variant, BaseLocale.SEP);
if (errIdx != -1) {
throw new LocaleSyntaxException("Ill-formed variant: " + variant, errIdx);
--- a/src/java.base/share/classes/sun/util/locale/LanguageTag.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/util/locale/LanguageTag.java Tue Dec 18 15:08:56 2018 -0500
@@ -212,7 +212,7 @@
if (!itr.isDone() && !sts.isError()) {
String s = itr.current();
sts.errorIndex = itr.currentStart();
- if (s.length() == 0) {
+ if (s.isEmpty()) {
sts.errorMsg = "Empty subtag";
} else {
sts.errorMsg = "Invalid subtag: " + s;
@@ -454,7 +454,7 @@
variant = "";
}
- if (variant.length() > 0) {
+ if (!variant.isEmpty()) {
List<String> variants = null;
StringTokenIterator varitr = new StringTokenIterator(variant, BaseLocale.SEP);
while (!varitr.isDone()) {
@@ -527,7 +527,7 @@
tag.privateuse = privateuse;
}
- if (tag.language.length() == 0 && (hasSubtag || privateuse == null)) {
+ if (tag.language.isEmpty() && (hasSubtag || privateuse == null)) {
// use lang "und" when 1) no language is available AND
// 2) any of other subtags other than private use are available or
// no private use tag is available
@@ -712,18 +712,18 @@
public String toString() {
StringBuilder sb = new StringBuilder();
- if (language.length() > 0) {
+ if (!language.isEmpty()) {
sb.append(language);
for (String extlang : extlangs) {
sb.append(SEP).append(extlang);
}
- if (script.length() > 0) {
+ if (!script.isEmpty()) {
sb.append(SEP).append(script);
}
- if (region.length() > 0) {
+ if (!region.isEmpty()) {
sb.append(SEP).append(region);
}
@@ -735,7 +735,7 @@
sb.append(SEP).append(extension);
}
}
- if (privateuse.length() > 0) {
+ if (!privateuse.isEmpty()) {
if (sb.length() > 0) {
sb.append(SEP);
}
--- a/src/java.base/share/classes/sun/util/locale/LocaleMatcher.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/util/locale/LocaleMatcher.java Tue Dec 18 15:08:56 2018 -0500
@@ -402,7 +402,7 @@
}
String rangeForRegex = range.replace("*", "\\p{Alnum}*");
- while (rangeForRegex.length() > 0) {
+ while (!rangeForRegex.isEmpty()) {
for (String tag : tags) {
// change to lowercase for case-insensitive matching
String lowerCaseTag = tag.toLowerCase(Locale.ROOT);
@@ -437,7 +437,7 @@
}
String rangeForRegex = range.replace("*", "\\p{Alnum}*");
- while (rangeForRegex.length() > 0) {
+ while (!rangeForRegex.isEmpty()) {
if (tag.matches(rangeForRegex)) {
return true;
}
@@ -591,7 +591,7 @@
private static String[] getEquivalentsForLanguage(String range) {
String r = range;
- while (r.length() > 0) {
+ while (!r.isEmpty()) {
if (LocaleEquivalentMaps.singleEquivMap.containsKey(r)) {
String equiv = LocaleEquivalentMaps.singleEquivMap.get(r);
// Return immediately for performance if the first matching
@@ -680,7 +680,7 @@
String r = range;
boolean hasEquivalent = false;
- while (r.length() > 0) {
+ while (!r.isEmpty()) {
if (keyMap.containsKey(r)) {
hasEquivalent = true;
List<String> equivalents = map.get(keyMap.get(r));
--- a/src/java.base/share/classes/sun/util/locale/LocaleUtils.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/util/locale/LocaleUtils.java Tue Dec 18 15:08:56 2018 -0500
@@ -207,7 +207,7 @@
}
static boolean isEmpty(String str) {
- return str == null || str.length() == 0;
+ return str == null || str.isEmpty();
}
static boolean isEmpty(Set<?> set) {
--- a/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java Tue Dec 18 15:08:56 2018 -0500
@@ -80,7 +80,7 @@
String value = keyword.getValue();
sj.add(key);
- if (value.length() > 0) {
+ if (!value.isEmpty()) {
sj.add(value);
}
}
--- a/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -117,7 +117,7 @@
}
name = strings[value];
// If name is empty in standalone, try its `format' style.
- if (name.length() == 0
+ if (name.isEmpty()
&& (style == SHORT_STANDALONE || style == LONG_STANDALONE
|| style == NARROW_STANDALONE)) {
name = getDisplayName(calendarType, field, value,
@@ -183,7 +183,7 @@
String name = strings[i];
// Ignore any empty string (some standalone month names
// are not defined)
- if (name.length() == 0) {
+ if (name.isEmpty()) {
continue;
}
map.put(name, base + i);
--- a/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java Tue Dec 18 15:08:56 2018 -0500
@@ -503,7 +503,7 @@
*/
String supportedLocaleString = createSupportedLocaleString("AvailableLocales");
- if (supportedLocaleString.length() == 0) {
+ if (supportedLocaleString.isEmpty()) {
throw new InternalError("No available locales for JRE");
}
--- a/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java Tue Dec 18 15:08:56 2018 -0500
@@ -121,7 +121,7 @@
List<Type> typeList = new ArrayList<>();
// Check user specified adapter preference
- if (order != null && order.length() != 0) {
+ if (order != null && !order.isEmpty()) {
String[] types = order.split(",");
for (String type : types) {
type = type.trim().toUpperCase(Locale.ROOT);
--- a/src/java.base/share/conf/security/java.security Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/share/conf/security/java.security Tue Dec 18 15:08:56 2018 -0500
@@ -1061,6 +1061,77 @@
java.base/java.security.KeyRep$Type;java.base/javax.crypto.spec.SecretKeySpec;!*
#
+# PKCS12 KeyStore properties
+#
+# The following properties, if configured, are used by the PKCS12 KeyStore
+# implementation during the creation of a new keystore. Several of the
+# properties may also be used when modifying an existing keystore. The
+# properties can be overridden by a KeyStore API that specifies its own
+# algorithms and parameters.
+#
+# If an existing PKCS12 keystore is loaded and then stored, the algorithm and
+# parameter used to generate the existing Mac will be reused. If the existing
+# keystore does not have a Mac, no Mac will be created while storing. If there
+# is at least one certificate in the existing keystore, the algorithm and
+# parameters used to encrypt the last certificate in the existing keystore will
+# be reused to encrypt all certificates while storing. If the last certificate
+# in the existing keystore is not encrypted, all certificates will be stored
+# unencrypted. If there is no certificate in the existing keystore, any newly
+# added certificate will be encrypted (or stored unencrypted if algorithm
+# value is "NONE") using the "keystore.pkcs12.certProtectionAlgorithm" and
+# "keystore.pkcs12.certPbeIterationCount" values defined here. Existing private
+# and secret key(s) are not changed. Newly set private and secret key(s) will
+# be encrypted using the "keystore.pkcs12.keyProtectionAlgorithm" and
+# "keystore.pkcs12.keyPbeIterationCount" values defined here.
+#
+# In order to apply new algorithms and parameters to all entries in an
+# existing keystore, one can create a new keystore and add entries in the
+# existing keystore into the new keystore. This can be achieved by calling the
+# "keytool -importkeystore" command.
+#
+# If a system property of the same name is also specified, it supersedes the
+# security property value defined here.
+#
+# If the property is set to an illegal value,
+# an iteration count that is not a positive integer, or an unknown algorithm
+# name, an exception will be thrown when the property is used.
+# If the property is not set or empty, a default value will be used.
+#
+# Note: These properties are currently used by the JDK Reference implementation.
+# They are not guaranteed to be examined and used by other implementations.
+
+# The algorithm used to encrypt a certificate. This can be any non-Hmac PBE
+# algorithm defined in the Cipher section of the Java Security Standard
+# Algorithm Names Specification. When set to "NONE", the certificate
+# is not encrypted. The default value is "PBEWithSHA1AndRC2_40".
+#keystore.pkcs12.certProtectionAlgorithm = PBEWithSHA1AndRC2_40
+
+# The iteration count used by the PBE algorithm when encrypting a certificate.
+# This value must be a positive integer. The default value is 50000.
+#keystore.pkcs12.certPbeIterationCount = 50000
+
+# The algorithm used to encrypt a private key or secret key. This can be
+# any non-Hmac PBE algorithm defined in the Cipher section of the Java
+# Security Standard Algorithm Names Specification. The value must not be "NONE".
+# The default value is "PBEWithSHA1AndDESede".
+#keystore.pkcs12.keyProtectionAlgorithm = PBEWithSHA1AndDESede
+
+# The iteration count used by the PBE algorithm when encrypting a private key
+# or a secret key. This value must be a positive integer. The default value
+# is 50000.
+#keystore.pkcs12.keyPbeIterationCount = 50000
+
+# The algorithm used to calculate the optional MacData at the end of a PKCS12
+# file. This can be any HmacPBE algorithm defined in the Mac section of the
+# Java Security Standard Algorithm Names Specification. When set to "NONE",
+# no Mac is generated. The default value is "HmacPBESHA1".
+#keystore.pkcs12.macAlgorithm = HmacPBESHA1
+
+# The iteration count used by the MacData algorithm. This value must be a
+# positive integer. The default value is 100000.
+#keystore.pkcs12.macIterationCount = 100000
+
+#
# Enhanced exception message information
#
# By default, exception messages should not include potentially sensitive
--- a/src/java.base/unix/classes/java/io/UnixFileSystem.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/unix/classes/java/io/UnixFileSystem.java Tue Dec 18 15:08:56 2018 -0500
@@ -98,7 +98,7 @@
}
public int prefixLength(String pathname) {
- if (pathname.length() == 0) return 0;
+ if (pathname.isEmpty()) return 0;
return (pathname.charAt(0) == '/') ? 1 : 0;
}
@@ -249,7 +249,7 @@
public int getBooleanAttributes(File f) {
int rv = getBooleanAttributes0(f);
String name = f.getName();
- boolean hidden = (name.length() > 0) && (name.charAt(0) == '.');
+ boolean hidden = !name.isEmpty() && name.charAt(0) == '.';
return rv | (hidden ? BA_HIDDEN : 0);
}
--- a/src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java Tue Dec 18 15:08:56 2018 -0500
@@ -59,9 +59,9 @@
return path;
}
String host = url.getHost();
- if (host == null || "".equals(host) || "localhost".equalsIgnoreCase (host)) {
+ if (host == null || host.isEmpty() || "localhost".equalsIgnoreCase(host)) {
path = url.getFile();
- path = ParseUtil.decode (path);
+ path = ParseUtil.decode(path);
}
return path;
}
--- a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -68,14 +68,14 @@
String line;
while ((line = in.readLine()) != null) {
int maxvalues = maxperkeyword;
- if (line.length() == 0)
+ if (line.isEmpty())
continue;
if (line.charAt(0) == '#' || line.charAt(0) == ';')
continue;
if (!line.startsWith(keyword))
continue;
String value = line.substring(keyword.length());
- if (value.length() == 0)
+ if (value.isEmpty())
continue;
if (value.charAt(0) != ' ' && value.charAt(0) != '\t')
continue;
@@ -181,7 +181,7 @@
// LOCALDOMAIN has absolute priority on Solaris
String localDomain = localDomain0();
- if (localDomain != null && localDomain.length() > 0) {
+ if (localDomain != null && !localDomain.isEmpty()) {
sl = new LinkedList<>();
sl.add(localDomain);
return sl;
@@ -211,7 +211,7 @@
sl = new LinkedList<>();
String domain = fallbackDomain0();
- if (domain != null && domain.length() > 0) {
+ if (domain != null && !domain.isEmpty()) {
sl.add(domain);
}
--- a/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java Tue Dec 18 15:08:56 2018 -0500
@@ -77,7 +77,7 @@
String logfile = props.getProperty("com.sun.sdp.debug");
if (logfile != null) {
out = System.out;
- if (logfile.length() > 0) {
+ if (!logfile.isEmpty()) {
try {
out = new PrintStream(logfile);
} catch (IOException ignore) { }
@@ -167,9 +167,9 @@
result[1] = all ? MAX_PORT : result[0];
} else {
String low = s.substring(0, pos);
- if (low.length() == 0) low = "*";
+ if (low.isEmpty()) low = "*";
String high = s.substring(pos+1);
- if (high.length() == 0) high = "*";
+ if (high.isEmpty()) high = "*";
result[0] = low.equals("*") ? 0 : Integer.parseInt(low);
result[1] = high.equals("*") ? MAX_PORT : Integer.parseInt(high);
}
@@ -199,7 +199,7 @@
String line = scanner.nextLine().trim();
// skip blank lines and comments
- if (line.length() == 0 || line.charAt(0) == '#')
+ if (line.isEmpty() || line.charAt(0) == '#')
continue;
// must have 3 fields
--- a/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java Tue Dec 18 15:08:56 2018 -0500
@@ -127,9 +127,9 @@
*/
String s1 = u1.getHost();
String s2 = u2.getHost();
- if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2)))
+ if ("localhost".equalsIgnoreCase(s1) && (s2 == null || s2.isEmpty()))
return true;
- if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1)))
+ if ("localhost".equalsIgnoreCase(s2) && (s1 == null || s1.isEmpty()))
return true;
return super.hostsEqual(u1, u2);
}
--- a/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -49,8 +49,8 @@
static {
String propValue = GetPropertyAction.privilegedGetProperty(
"sun.nio.ch.disableSynchronousRead", "false");
- disableSynchronousRead = (propValue.length() == 0) ?
- true : Boolean.valueOf(propValue);
+ disableSynchronousRead = propValue.isEmpty() ?
+ true : Boolean.parseBoolean(propValue);
}
private final Port port;
--- a/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java Tue Dec 18 15:08:56 2018 -0500
@@ -58,8 +58,7 @@
// default directory.
String propValue = GetPropertyAction
.privilegedGetProperty("sun.nio.fs.chdirAllowed", "false");
- boolean chdirAllowed = (propValue.length() == 0) ?
- true : Boolean.valueOf(propValue);
+ boolean chdirAllowed = propValue.isEmpty() ? true : Boolean.parseBoolean(propValue);
if (chdirAllowed) {
this.needToResolveAgainstDefaultDirectory = true;
} else {
@@ -269,7 +268,7 @@
StringBuilder sb = new StringBuilder();
sb.append(first);
for (String segment: more) {
- if (segment.length() > 0) {
+ if (!segment.isEmpty()) {
if (sb.length() > 0)
sb.append('/');
sb.append(segment);
--- a/src/java.base/unix/native/libjava/TimeZone_md.c Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/unix/native/libjava/TimeZone_md.c Tue Dec 18 15:08:56 2018 -0500
@@ -56,6 +56,12 @@
#define fileclose fclose
#endif
+#if defined(_ALLBSD_SOURCE)
+#define stat64 stat
+#define lstat64 lstat
+#define fstat64 fstat
+#endif
+
#if defined(__linux__) || defined(_ALLBSD_SOURCE)
static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
@@ -115,7 +121,7 @@
findZoneinfoFile(char *buf, size_t size, const char *dir)
{
DIR *dirp = NULL;
- struct stat statbuf;
+ struct stat64 statbuf;
struct dirent *dp = NULL;
char *pathname = NULL;
int fd = -1;
@@ -156,7 +162,7 @@
if (pathname == NULL) {
break;
}
- RESTARTABLE(stat(pathname, &statbuf), res);
+ RESTARTABLE(stat64(pathname, &statbuf), res);
if (res == -1) {
break;
}
@@ -219,7 +225,7 @@
static char *
getPlatformTimeZoneID()
{
- struct stat statbuf;
+ struct stat64 statbuf;
char *tz = NULL;
FILE *fp;
int fd;
@@ -256,7 +262,7 @@
/*
* Next, try /etc/localtime to find the zone ID.
*/
- RESTARTABLE(lstat(DEFAULT_ZONEINFO_FILE, &statbuf), res);
+ RESTARTABLE(lstat64(DEFAULT_ZONEINFO_FILE, &statbuf), res);
if (res == -1) {
return NULL;
}
@@ -296,7 +302,7 @@
return NULL;
}
- RESTARTABLE(fstat(fd, &statbuf), res);
+ RESTARTABLE(fstat64(fd, &statbuf), res);
if (res == -1) {
(void) close(fd);
return NULL;
@@ -557,7 +563,7 @@
static char *
getSolarisDefaultZoneID() {
char *tz = NULL;
- struct stat statbuf;
+ struct stat64 statbuf;
size_t size;
char *buf;
int fd;
@@ -597,7 +603,7 @@
}
cleanupScf(h, snap, inst, pg, prop, val, tz);
- RESTARTABLE(stat(DEFAULT_ZONEINFO_FILE, &statbuf), res);
+ RESTARTABLE(stat64(DEFAULT_ZONEINFO_FILE, &statbuf), res);
if (res == -1) {
return NULL;
}
--- a/src/java.base/unix/native/libjava/UnixFileSystem_md.c Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/unix/native/libjava/UnixFileSystem_md.c Tue Dec 18 15:08:56 2018 -0500
@@ -69,6 +69,7 @@
#if defined(_ALLBSD_SOURCE)
#ifndef MACOSX
#define statvfs64 statvfs
+ #define stat64 stat
#endif
#endif
@@ -121,8 +122,8 @@
static jboolean
statMode(const char *path, int *mode)
{
- struct stat sb;
- if (stat(path, &sb) == 0) {
+ struct stat64 sb;
+ if (stat64(path, &sb) == 0) {
*mode = sb.st_mode;
return JNI_TRUE;
}
@@ -229,8 +230,8 @@
jlong rv = 0;
WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
- struct stat sb;
- if (stat(path, &sb) == 0) {
+ struct stat64 sb;
+ if (stat64(path, &sb) == 0) {
#if defined(_AIX)
rv = (jlong)sb.st_mtime * 1000;
rv += (jlong)sb.st_mtime_n / 1000000;
@@ -254,8 +255,8 @@
jlong rv = 0;
WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
- struct stat sb;
- if (stat(path, &sb) == 0) {
+ struct stat64 sb;
+ if (stat64(path, &sb) == 0) {
rv = sb.st_size;
}
} END_PLATFORM_STRING(env, path);
@@ -408,9 +409,9 @@
jboolean rv = JNI_FALSE;
WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
- struct stat sb;
+ struct stat64 sb;
- if (stat(path, &sb) == 0) {
+ if (stat64(path, &sb) == 0) {
struct timeval tv[2];
/* Preserve access time */
--- a/src/java.base/windows/classes/java/io/WinNTFileSystem.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/windows/classes/java/io/WinNTFileSystem.java Tue Dec 18 15:08:56 2018 -0500
@@ -64,7 +64,7 @@
}
private String slashify(String p) {
- if ((p.length() > 0) && (p.charAt(0) != slash)) return slash + p;
+ if (!p.isEmpty() && p.charAt(0) != slash) return slash + p;
else return p;
}
--- a/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java Tue Dec 18 15:08:56 2018 -0500
@@ -145,9 +145,9 @@
*/
String s1 = u1.getHost();
String s2 = u2.getHost();
- if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2)))
+ if ("localhost".equalsIgnoreCase(s1) && (s2 == null || s2.isEmpty()))
return true;
- if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1)))
+ if ("localhost".equalsIgnoreCase(s2) && (s1 == null || s1.isEmpty()))
return true;
return super.hostsEqual(u1, u2);
}
--- a/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java Tue Dec 18 15:08:56 2018 -0500
@@ -141,14 +141,8 @@
static boolean isFastFileTransferRequested() {
String fileTransferProp = GetPropertyAction
- .privilegedGetProperty("jdk.nio.enableFastFileTransfer");
- boolean enable;
- if ("".equals(fileTransferProp)) {
- enable = true;
- } else {
- enable = Boolean.parseBoolean(fileTransferProp);
- }
- return enable;
+ .privilegedGetProperty("jdk.nio.enableFastFileTransfer", "false");
+ return fileTransferProp.isEmpty() ? true : Boolean.parseBoolean(fileTransferProp);
}
static {
--- a/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java Tue Dec 18 15:08:56 2018 -0500
@@ -116,8 +116,7 @@
static {
String propValue = GetPropertyAction.privilegedGetProperty(
"sun.nio.fs.ensureAccurateMetadata", "false");
- ensureAccurateMetadata = (propValue.length() == 0) ?
- true : Boolean.valueOf(propValue);
+ ensureAccurateMetadata = propValue.isEmpty() ? true : Boolean.parseBoolean(propValue);
}
// attributes
--- a/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java Tue Dec 18 15:08:56 2018 -0500
@@ -52,7 +52,7 @@
// file store "display name" is the volume name if available
String vol = volInfo.volumeName();
- if (vol.length() > 0) {
+ if (!vol.isEmpty()) {
this.displayName = vol;
} else {
// TBD - should we map all types? Does this need to be localized?
--- a/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java Tue Dec 18 15:08:56 2018 -0500
@@ -218,7 +218,7 @@
StringBuilder sb = new StringBuilder();
sb.append(first);
for (String segment: more) {
- if (segment.length() > 0) {
+ if (!segment.isEmpty()) {
if (sb.length() > 0)
sb.append('\\');
sb.append(segment);
--- a/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java Tue Dec 18 15:08:56 2018 -0500
@@ -329,7 +329,7 @@
// remove special prefix
String target = stripPrefix(new String(name));
- if (target.length() == 0) {
+ if (target.isEmpty()) {
throw new IOException("Symbolic link target is invalid");
}
return target;
--- a/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java Tue Dec 18 15:08:56 2018 -0500
@@ -243,7 +243,7 @@
// relative to default directory
String remaining = path.substring(root.length());
String defaultDirectory = getFileSystem().defaultDirectory();
- if (remaining.length() == 0) {
+ if (remaining.isEmpty()) {
return defaultDirectory;
} else if (defaultDirectory.endsWith("\\")) {
return defaultDirectory + remaining;
@@ -299,7 +299,7 @@
// -- Path operations --
private boolean isEmpty() {
- return path.length() == 0;
+ return path.isEmpty();
}
private WindowsPath emptyPath() {
@@ -340,7 +340,7 @@
@Override
public WindowsPath getRoot() {
- if (root.length() == 0)
+ if (root.isEmpty())
return null;
return new WindowsPath(getFileSystem(), type, root, root);
}
@@ -556,7 +556,7 @@
// corner case - all names removed
if (remaining == 0) {
- return (root.length() == 0) ? emptyPath() : getRoot();
+ return root.isEmpty() ? emptyPath() : getRoot();
}
// re-constitute the path from the remaining names.
--- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java Tue Dec 18 15:08:56 2018 -0500
@@ -59,6 +59,7 @@
* 10: local-variable type inference (var)
* 11: local-variable syntax for lambda parameters
* 12: TBD
+ * 13: TBD
*/
/**
@@ -183,7 +184,15 @@
*
* @since 12
*/
- RELEASE_12;
+ RELEASE_12,
+
+ /**
+ * The version recognized by the Java Platform, Standard Edition
+ * 13.
+ *
+ * @since 13
+ */
+ RELEASE_13;
// Note that when adding constants for newer releases, the
// behavior of latest() and latestSupported() must be updated too.
@@ -194,7 +203,7 @@
* @return the latest source version that can be modeled
*/
public static SourceVersion latest() {
- return RELEASE_12;
+ return RELEASE_13;
}
private static final SourceVersion latestSupported = getLatestSupported();
@@ -204,6 +213,8 @@
String specVersion = System.getProperty("java.specification.version");
switch (specVersion) {
+ case "13":
+ return RELEASE_13;
case "12":
return RELEASE_12;
case "11":
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor9.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor9.java Tue Dec 18 15:08:56 2018 -0500
@@ -32,7 +32,7 @@
/**
* A skeletal visitor for annotation values with default behavior
* appropriate for source versions {@link SourceVersion#RELEASE_9
- * RELEASE_9} through {@link SourceVersion#RELEASE_12 RELEASE_12}.
+ * RELEASE_9} through {@link SourceVersion#RELEASE_13 RELEASE_13}.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
@@ -59,7 +59,7 @@
* @see AbstractAnnotationValueVisitor8
* @since 9
*/
-@SupportedSourceVersion(RELEASE_12)
+@SupportedSourceVersion(RELEASE_13)
public abstract class AbstractAnnotationValueVisitor9<R, P> extends AbstractAnnotationValueVisitor8<R, P> {
/**
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor9.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor9.java Tue Dec 18 15:08:56 2018 -0500
@@ -34,7 +34,7 @@
/**
* A skeletal visitor of program elements with default behavior
* appropriate for source versions {@link SourceVersion#RELEASE_9
- * RELEASE_9} through {@link SourceVersion#RELEASE_12 RELEASE_12}.
+ * RELEASE_9} through {@link SourceVersion#RELEASE_13 RELEASE_13}.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
@@ -65,7 +65,7 @@
* @since 9
* @spec JPMS
*/
-@SupportedSourceVersion(RELEASE_12)
+@SupportedSourceVersion(RELEASE_13)
public abstract class AbstractElementVisitor9<R, P> extends AbstractElementVisitor8<R, P> {
/**
* Constructor for concrete subclasses to call.
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java Tue Dec 18 15:08:56 2018 -0500
@@ -33,7 +33,7 @@
/**
* A skeletal visitor of types with default behavior appropriate for
* source versions {@link SourceVersion#RELEASE_9 RELEASE_9} through
- * {@link SourceVersion#RELEASE_12 RELEASE_12}.
+ * {@link SourceVersion#RELEASE_13 RELEASE_13}.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
@@ -63,7 +63,7 @@
* @see AbstractTypeVisitor8
* @since 9
*/
-@SupportedSourceVersion(RELEASE_12)
+@SupportedSourceVersion(RELEASE_13)
public abstract class AbstractTypeVisitor9<R, P> extends AbstractTypeVisitor8<R, P> {
/**
* Constructor for concrete subclasses to call.
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java Tue Dec 18 15:08:56 2018 -0500
@@ -34,7 +34,7 @@
* A visitor of program elements based on their {@linkplain
* ElementKind kind} with default behavior appropriate for source
* versions {@link SourceVersion#RELEASE_9 RELEASE_9} through {@link
- * SourceVersion#RELEASE_12 RELEASE_12}.
+ * SourceVersion#RELEASE_13 RELEASE_13}.
*
* For {@linkplain
* Element elements} <code><i>Xyz</i></code> that may have more than one
@@ -80,7 +80,7 @@
* @since 9
* @spec JPMS
*/
-@SupportedSourceVersion(RELEASE_12)
+@SupportedSourceVersion(RELEASE_13)
public class ElementKindVisitor9<R, P> extends ElementKindVisitor8<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java Tue Dec 18 15:08:56 2018 -0500
@@ -34,7 +34,7 @@
/**
* A scanning visitor of program elements with default behavior
* appropriate for source versions {@link SourceVersion#RELEASE_9
- * RELEASE_9} through {@link SourceVersion#RELEASE_12 RELEASE_12}.
+ * RELEASE_9} through {@link SourceVersion#RELEASE_13 RELEASE_13}.
*
* The <code>visit<i>Xyz</i></code> methods in this
* class scan their component elements by calling {@code scan} on
@@ -92,7 +92,7 @@
* @since 9
* @spec JPMS
*/
-@SupportedSourceVersion(RELEASE_12)
+@SupportedSourceVersion(RELEASE_13)
public class ElementScanner9<R, P> extends ElementScanner8<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor9.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor9.java Tue Dec 18 15:08:56 2018 -0500
@@ -32,7 +32,7 @@
/**
* A simple visitor for annotation values with default behavior
* appropriate for source versions {@link SourceVersion#RELEASE_9
- * RELEASE_9} through {@link SourceVersion#RELEASE_12 RELEASE_12}.
+ * RELEASE_9} through {@link SourceVersion#RELEASE_13 RELEASE_13}.
*
* Visit methods call {@link #defaultAction
* defaultAction} passing their arguments to {@code defaultAction}'s
@@ -68,7 +68,7 @@
* @see SimpleAnnotationValueVisitor8
* @since 9
*/
-@SupportedSourceVersion(RELEASE_12)
+@SupportedSourceVersion(RELEASE_13)
public class SimpleAnnotationValueVisitor9<R, P> extends SimpleAnnotationValueVisitor8<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor9.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor9.java Tue Dec 18 15:08:56 2018 -0500
@@ -33,7 +33,7 @@
/**
* A simple visitor of program elements with default behavior
* appropriate for source versions {@link SourceVersion#RELEASE_9
- * RELEASE_9} through {@link SourceVersion#RELEASE_12 RELEASE_12}.
+ * RELEASE_9} through {@link SourceVersion#RELEASE_13 RELEASE_13}.
*
* Visit methods corresponding to {@code RELEASE_9} and earlier
* language constructs call {@link #defaultAction defaultAction},
@@ -73,7 +73,7 @@
* @since 9
* @spec JPMS
*/
-@SupportedSourceVersion(RELEASE_12)
+@SupportedSourceVersion(RELEASE_13)
public class SimpleElementVisitor9<R, P> extends SimpleElementVisitor8<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java Tue Dec 18 15:08:56 2018 -0500
@@ -33,7 +33,7 @@
/**
* A simple visitor of types with default behavior appropriate for
* source versions {@link SourceVersion#RELEASE_9 RELEASE_9} through
- * {@link SourceVersion#RELEASE_12 RELEASE_12}.
+ * {@link SourceVersion#RELEASE_13 RELEASE_13}.
*
* Visit methods corresponding to {@code RELEASE_9} and earlier
* language constructs call {@link #defaultAction defaultAction},
@@ -73,7 +73,7 @@
* @see SimpleTypeVisitor8
* @since 9
*/
-@SupportedSourceVersion(RELEASE_12)
+@SupportedSourceVersion(RELEASE_13)
public class SimpleTypeVisitor9<R, P> extends SimpleTypeVisitor8<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
--- a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java Tue Dec 18 15:08:56 2018 -0500
@@ -34,7 +34,7 @@
* A visitor of types based on their {@linkplain TypeKind kind} with
* default behavior appropriate for source versions {@link
* SourceVersion#RELEASE_9 RELEASE_9} through {@link
- * SourceVersion#RELEASE_12 RELEASE_12}.
+ * SourceVersion#RELEASE_13 RELEASE_13}.
*
* For {@linkplain
* TypeMirror types} <code><i>Xyz</i></code> that may have more than one
@@ -77,7 +77,7 @@
* @see TypeKindVisitor8
* @since 9
*/
-@SupportedSourceVersion(RELEASE_12)
+@SupportedSourceVersion(RELEASE_13)
public class TypeKindVisitor9<R, P> extends TypeKindVisitor8<R, P> {
/**
* Constructor for concrete subclasses to call; uses {@code null}
--- a/src/java.desktop/share/classes/com/sun/media/sound/SoftChannel.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.desktop/share/classes/com/sun/media/sound/SoftChannel.java Tue Dec 18 15:08:56 2018 -0500
@@ -1472,7 +1472,7 @@
}
for (int controller : co_midi_nrpn_nrpn.keySet())
nrpnChange(controller, 0);
- rpnChange(0, 2 << 7); // Bitch Bend sensitivity
+ rpnChange(0, 2 << 7); // Pitch Bend sensitivity
rpnChange(1, 64 << 7); // Channel fine tunning
rpnChange(2, 64 << 7); // Channel Coarse Tuning
rpnChange(5, 64); // Modulation Depth, +/- 50 cent
--- a/src/java.desktop/unix/classes/sun/awt/X11/XMSelection.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XMSelection.java Tue Dec 18 15:08:56 2018 -0500
@@ -97,7 +97,15 @@
XToolkit.awtLock();
try {
long root = XlibWrapper.RootWindow(display,screen);
- XlibWrapper.XSelectInput(display, root, XConstants.StructureNotifyMask);
+ XWindowAttributes wattr = new XWindowAttributes();
+ try {
+ XlibWrapper.XGetWindowAttributes(display, root, wattr.pData);
+ XlibWrapper.XSelectInput(display, root,
+ XConstants.StructureNotifyMask |
+ wattr.get_your_event_mask());
+ } finally {
+ wattr.dispose();
+ }
XToolkit.addEventDispatcher(root,
new XEventDispatcher() {
public void dispatchEvent(XEvent ev) {
--- a/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c Tue Dec 18 15:08:56 2018 -0500
@@ -1277,9 +1277,14 @@
/* mark that XIM server was destroyed */
X11im = NULL;
JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+ AWT_LOCK();
/* free the old pX11IMData and set it to null. this also avoids crashing
* the jvm if the XIM server reappears */
- X11InputMethodData *pX11IMData = getX11InputMethodData(env, currentX11InputMethodInstance);
+ while (x11InputMethodGRefListHead != NULL) {
+ getX11InputMethodData(env, x11InputMethodGRefListHead->inputMethodGRef);
+ }
+ AWT_UNLOCK();
}
JNIEXPORT jboolean JNICALL
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.logging/share/classes/java/util/logging/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+/**
+ * Provides the classes and interfaces of
+ * the Java™ 2 platform's core logging facilities.
+ * The central goal of the logging APIs is to support maintaining and servicing
+ * software at customer sites.
+ *
+ * <P>
+ * There are four main target uses of the logs:
+ * </P>
+ *
+ * <OL>
+ * <LI> <I>Problem diagnosis by end users and system administrators</I>.
+ * This consists of simple logging of common problems that can be fixed
+ * or tracked locally, such as running out of resources, security failures,
+ * and simple configuration errors.
+ *
+ * <LI> <I>Problem diagnosis by field service engineers</I>. The logging information
+ * used by field service engineers may be considerably more complex and
+ * verbose than that required by system administrators. Typically such information
+ * will require extra logging within particular subsystems.
+ *
+ * <LI> <I>Problem diagnosis by the development organization</I>.
+ * When a problem occurs in the field, it may be necessary to return the captured logging
+ * information to the original development team for diagnosis. This logging
+ * information may be extremely detailed and fairly inscrutable. Such information might include
+ * detailed tracing on the internal execution of particular subsystems.
+ *
+ * <LI> <I>Problem diagnosis by developers</I>. The Logging APIs may also be
+ * used to help debug an application under development. This may
+ * include logging information generated by the target application
+ * as well as logging information generated by lower-level libraries.
+ * Note however that while this use is perfectly reasonable,
+ * the logging APIs are not intended to replace the normal debugging
+ * and profiling tools that may already exist in the development environment.
+ * </OL>
+ *
+ * <p>
+ * The key elements of this package include:
+ * <UL>
+ * <LI> <I>Logger</I>: The main entity on which applications make
+ * logging calls. A Logger object is used to log messages
+ * for a specific system or application
+ * component.
+ * <LI> <I>LogRecord</I>: Used to pass logging requests between the logging
+ * framework and individual log handlers.
+ * <LI> <I>Handler</I>: Exports LogRecord objects to a variety of destinations
+ * including memory, output streams, consoles, files, and sockets.
+ * A variety of Handler subclasses exist for this purpose. Additional Handlers
+ * may be developed by third parties and delivered on top of the core platform.
+ * <LI> <I>Level</I>: Defines a set of standard logging levels that can be used
+ * to control logging output. Programs can be configured to output logging
+ * for some levels while ignoring output for others.
+ * <LI> <I>Filter</I>: Provides fine-grained control over what gets logged,
+ * beyond the control provided by log levels. The logging APIs support a general-purpose
+ * filter mechanism that allows application code to attach arbitrary filters to
+ * control logging output.
+ *
+ * <LI> <I>Formatter</I>: Provides support for formatting LogRecord objects. This
+ * package includes two formatters, SimpleFormatter and
+ * XMLFormatter, for formatting log records in plain text
+ * or XML respectively. As with Handlers, additional Formatters
+ * may be developed by third parties.
+ * </UL>
+ * <P>
+ * The Logging APIs offer both static and dynamic configuration control.
+ * Static control enables field service staff to set up a particular configuration and then re-launch the
+ * application with the new logging settings. Dynamic control allows for updates to the
+ * logging configuration within a currently running program. The APIs also allow for logging to be
+ * enabled or disabled for different functional areas of the system. For example,
+ * a field service engineer might be interested in tracing all AWT events, but might have no interest in
+ * socket events or memory management.
+ * </P>
+ *
+ * <h2>Null Pointers</h2>
+ * <p>
+ * In general, unless otherwise noted in the javadoc, methods and
+ * constructors will throw NullPointerException if passed a null argument.
+ * The one broad exception to this rule is that the logging convenience
+ * methods in the Logger class (the config, entering, exiting, fine, finer, finest,
+ * log, logp, logrb, severe, throwing, and warning methods)
+ * will accept null values
+ * for all arguments except for the initial Level argument (if any).
+ *
+ * <H2>Related Documentation</H2>
+ * <P>
+ * For an overview of control flow,
+ * please refer to the
+ * {@extLink logging_overview Java Logging Overview}
+ * </P>
+ *
+ * @since 1.4
+ */
+package java.util.logging;
--- a/src/java.logging/share/classes/java/util/logging/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
-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.
--->
-
-</head>
-<body bgcolor="white">
-<P>
-Provides the classes and interfaces of
-the Java™ 2 platform's core logging facilities.
-The central goal of the logging APIs is to support maintaining and servicing
-software at customer sites.
-
-<P>
-There are four main target uses of the logs:
-</P>
-
-<OL>
- <LI> <I>Problem diagnosis by end users and system administrators</I>.
- This consists of simple logging of common problems that can be fixed
- or tracked locally, such as running out of resources, security failures,
- and simple configuration errors.
-
- <LI> <I>Problem diagnosis by field service engineers</I>. The logging information
- used by field service engineers may be considerably more complex and
- verbose than that required by system administrators. Typically such information
- will require extra logging within particular subsystems.
-
- <LI> <I>Problem diagnosis by the development organization</I>.
- When a problem occurs in the field, it may be necessary to return the captured logging
- information to the original development team for diagnosis. This logging
- information may be extremely detailed and fairly inscrutable. Such information might include
- detailed tracing on the internal execution of particular subsystems.
-
- <LI> <I>Problem diagnosis by developers</I>. The Logging APIs may also be
- used to help debug an application under development. This may
- include logging information generated by the target application
- as well as logging information generated by lower-level libraries.
- Note however that while this use is perfectly reasonable,
- the logging APIs are not intended to replace the normal debugging
- and profiling tools that may already exist in the development environment.
-</OL>
-
-<p>
-The key elements of this package include:
-<UL>
- <LI> <I>Logger</I>: The main entity on which applications make
- logging calls. A Logger object is used to log messages
- for a specific system or application
- component.
- <LI> <I>LogRecord</I>: Used to pass logging requests between the logging
- framework and individual log handlers.
- <LI> <I>Handler</I>: Exports LogRecord objects to a variety of destinations
- including memory, output streams, consoles, files, and sockets.
- A variety of Handler subclasses exist for this purpose. Additional Handlers
- may be developed by third parties and delivered on top of the core platform.
- <LI> <I>Level</I>: Defines a set of standard logging levels that can be used
- to control logging output. Programs can be configured to output logging
- for some levels while ignoring output for others.
- <LI> <I>Filter</I>: Provides fine-grained control over what gets logged,
- beyond the control provided by log levels. The logging APIs support a general-purpose
- filter mechanism that allows application code to attach arbitrary filters to
- control logging output.
-
- <LI> <I>Formatter</I>: Provides support for formatting LogRecord objects. This
- package includes two formatters, SimpleFormatter and
- XMLFormatter, for formatting log records in plain text
- or XML respectively. As with Handlers, additional Formatters
- may be developed by third parties.
-</UL>
-<P>
-The Logging APIs offer both static and dynamic configuration control.
-Static control enables field service staff to set up a particular configuration and then re-launch the
-application with the new logging settings. Dynamic control allows for updates to the
-logging configuration within a currently running program. The APIs also allow for logging to be
-enabled or disabled for different functional areas of the system. For example,
-a field service engineer might be interested in tracing all AWT events, but might have no interest in
-socket events or memory management.
-</P>
-
-<h2>Null Pointers</h2>
-<p>
-In general, unless otherwise noted in the javadoc, methods and
-constructors will throw NullPointerException if passed a null argument.
-The one broad exception to this rule is that the logging convenience
-methods in the Logger class (the config, entering, exiting, fine, finer, finest,
-log, logp, logrb, severe, throwing, and warning methods)
-will accept null values
-for all arguments except for the initial Level argument (if any).
-
-<H2>Related Documentation</H2>
-<P>
-For an overview of control flow,
-please refer to the
-{@extLink logging_overview Java Logging Overview}
-</P>
-
-<!-- Put @see and @since tags down here. -->
-
-@since 1.4
-
-
-</body>
-</html>
--- a/src/java.logging/share/conf/logging.properties Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.logging/share/conf/logging.properties Tue Dec 18 15:08:56 2018 -0500
@@ -60,4 +60,4 @@
# For example, set the com.xyz.foo logger to only log SEVERE
# messages:
-com.xyz.foo.level = SEVERE
+# com.xyz.foo.level = SEVERE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.prefs/share/classes/java/util/prefs/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+/**
+ * This package allows applications to store and retrieve user and system
+ * preference and configuration data. This data is stored persistently in an
+ * implementation-dependent backing store. There are two separate trees of
+ * preference nodes, one for user preferences and one for system preferences.
+ *
+ * @since 1.4
+ */
+package java.util.prefs;
--- a/src/java.prefs/share/classes/java/util/prefs/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
-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.
--->
-
-</head>
-<body bgcolor="white">
-
-This package allows applications to store and retrieve user and system
-preference and configuration data. This data is stored persistently in an
-implementation-dependent backing store. There are two separate trees of
-preference nodes, one for user preferences and one for system preferences.
-
-<!--
-<h2>Package Specification</h2>
-<h2>Related Documentation</h2>
--->
-
-@since 1.4
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.rmi/share/classes/java/rmi/activation/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * <p>
+ * 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.
+ * <p>
+ * 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).
+ * <p>
+ * 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.
+ * <p>
+ * 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.
+ */
+
+/**
+ * Provides support for RMI Object Activation. A remote
+ * object's reference can be made ``persistent'' and later activated into a
+ * ``live'' object using the RMI activation mechanism.
+ *
+ * <p>Implementations are not required to support the activation
+ * mechanism. If activation is not supported by this implementation,
+ * several specific activation API methods are all required to throw
+ * {@code UnsupportedOperationException}. If activation is supported by this
+ * implementation, these methods must never throw {@code
+ * UnsupportedOperationException}. These methods are denoted by the
+ * presence of an entry for {@code UnsupportedOperationException} in the
+ * <strong>Throws</strong> section of each method's specification.
+ *
+ * @since 1.2
+ */
+package java.rmi.activation;
--- a/src/java.rmi/share/classes/java/rmi/activation/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-<!--
- Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License version 2 only, as
- published by the Free Software Foundation. Oracle designates this
- particular file as subject to the "Classpath" exception as provided
- by Oracle in the LICENSE file that accompanied this code.
-
- This code is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- version 2 for more details (a copy is included in the LICENSE file that
- accompanied this code).
-
- You should have received a copy of the GNU General Public License version
- 2 along with this work; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-
- Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions.
--->
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<body bgcolor="white">
-
-Provides support for RMI Object Activation. A remote
-object's reference can be made ``persistent'' and later activated into a
-``live'' object using the RMI activation mechanism.
-
-<p>Implementations are not required to support the activation
-mechanism. If activation is not supported by this implementation,
-several specific activation API methods are all required to throw
-{@code UnsupportedOperationException}. If activation is supported by this
-implementation, these methods must never throw {@code
-UnsupportedOperationException}. These methods are denoted by the
-presence of an entry for {@code UnsupportedOperationException} in the
-<strong>Throws</strong> section of each method's specification.
-
-<!--
-<h2>Package Specification</h2>
-
-##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
-<ul>
- <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
-</ul>
-
-<h2>Related Documentation</h2>
-
-For overviews, tutorials, examples, guides, and tool documentation, please see:
-<ul>
- <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
-</ul>
--->
-
-@since 1.2
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.rmi/share/classes/java/rmi/dgc/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * <p>
+ * 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.
+ * <p>
+ * 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).
+ * <p>
+ * 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.
+ * <p>
+ * 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.
+ */
+
+/**
+ * Provides classes and interface for RMI distributed
+ * garbage-collection (DGC). When the RMI server returns an object to
+ * its client (caller of the remote method), it tracks the remote
+ * object's usage in the client. When there are no more references to the
+ * remote object on the client, or if the reference's ``lease'' expires and
+ * not renewed, the server garbage-collects the remote object.
+ *
+ *
+ * @since 1.1
+ */
+package java.rmi.dgc;
--- a/src/java.rmi/share/classes/java/rmi/dgc/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-<!--
- Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- 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.
--->
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<body bgcolor="white">
-
-Provides classes and interface for RMI distributed
-garbage-collection (DGC). When the RMI server returns an object to
-its client (caller of the remote method), it tracks the remote
-object's usage in the client. When there are no more references to the
-remote object on the client, or if the reference's ``lease'' expires and
-not renewed, the server garbage-collects the remote object.
-
-<!--
-<h2>Package Specification</h2>
-
-##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
-<ul>
- <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
-</ul>
-
-<h2>Related Documentation</h2>
-
-For overviews, tutorials, examples, guides, and tool documentation, please see:
-<ul>
- <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
-</ul>
--->
-
-@since 1.1
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.rmi/share/classes/java/rmi/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * <p>
+ * 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.
+ * <p>
+ * 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).
+ * <p>
+ * 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.
+ * <p>
+ * 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.
+ */
+
+/**
+ * Provides the RMI package. RMI is Remote Method Invocation. It is a
+ * mechanism that enables an object on one Java virtual machine to invoke
+ * methods on an object in another Java virtual machine. Any object that
+ * can be invoked this way must implement the Remote interface. When such
+ * an object is invoked, its arguments are ``marshalled'' and sent from the
+ * local virtual machine to the remote one, where the arguments are
+ * ``unmarshalled.'' When the method terminates, the results are
+ * marshalled from the remote machine and sent to the caller's virtual
+ * machine. If the method invocation results in an exception being
+ * thrown, the exception is indicated to caller.
+ *
+ * @since 1.1
+ */
+package java.rmi;
--- a/src/java.rmi/share/classes/java/rmi/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-<!--
- Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- 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.
--->
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<body bgcolor="white">
-
-Provides the RMI package. RMI is Remote Method Invocation. It is a
-mechanism that enables an object on one Java virtual machine to invoke
-methods on an object in another Java virtual machine. Any object that
-can be invoked this way must implement the Remote interface. When such
-an object is invoked, its arguments are ``marshalled'' and sent from the
-local virtual machine to the remote one, where the arguments are
-``unmarshalled.'' When the method terminates, the results are
-marshalled from the remote machine and sent to the caller's virtual
-machine. If the method invocation results in an exception being
-thrown, the exception is indicated to caller.
-
-<!--
-<h2>Package Specification</h2>
-
-##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
-<ul>
- <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
-</ul>
-
-<h2>Related Documentation</h2>
-
-For overviews, tutorials, examples, guides, and tool documentation, please see:
-<ul>
- <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
-</ul>
--->
-
-@since 1.1
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.rmi/share/classes/java/rmi/registry/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * <p>
+ * 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.
+ * <p>
+ * 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).
+ * <p>
+ * 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.
+ * <p>
+ * 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.
+ */
+
+/**
+ * Provides a class and two interfaces for the RMI registry.
+ * A registry is a remote object that maps names to remote objects. A
+ * server registers its remote objects with the registry so that they can
+ * be looked up. When an object wants to invoke a method on a remote
+ * object, it must first lookup the remote object using its name. The
+ * registry returns to the calling object a reference to the remote
+ * object, using which a remote method can be invoked.
+ *
+ * @since 1.1
+ */
+package java.rmi.registry;
--- a/src/java.rmi/share/classes/java/rmi/registry/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-<!--
- Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- 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.
--->
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-</head>
-<body bgcolor="white">
-
-Provides a class and two interfaces for the RMI registry.
-A registry is a remote object that maps names to remote objects. A
-server registers its remote objects with the registry so that they can
-be looked up. When an object wants to invoke a method on a remote
-object, it must first lookup the remote object using its name. The
-registry returns to the calling object a reference to the remote
-object, using which a remote method can be invoked.
-
-<!--
-<h2>Package Specification</h2>
-
-##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
-<ul>
- <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
-</ul>
-
-<h2>Related Documentation</h2>
-
-For overviews, tutorials, examples, guides, and tool documentation, please see:
-<ul>
- <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
-</ul>
--->
-
-@since 1.1
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.rmi/share/classes/java/rmi/server/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * <p>
+ * 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.
+ * <p>
+ * 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).
+ * <p>
+ * 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.
+ * <p>
+ * 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.
+ */
+
+/**
+ * Provides classes and interfaces for supporting the server
+ * side of RMI. A group of classes are used by the stubs and skeletons
+ * generated by the rmic stub compiler. Another group of classes
+ * implements the RMI Transport protocol and HTTP tunneling.
+ *
+ * <p><strong>Deprecated: HTTP Tunneling.</strong> <em>The HTTP tunneling
+ * mechanism has been deprecated. See {@link java.rmi.server.RMISocketFactory} for
+ * further information.</em>
+ *
+ * <p><strong>Deprecated: Skeletons and Static Stubs.</strong>
+ *
+ * <em>Skeletons and statically generated stubs are deprecated. This
+ * includes the APIs in this package that require the use of skeletons
+ * or static stubs, the runtime support for them, and the use of the
+ * {@code rmic} stub compiler to generate them. Support for skeletons
+ * and static stubs may be removed in a future release of the
+ * platform. Skeletons are unnecessary, as server-side method dispatching
+ * is handled directly by the RMI runtime. Statically generated stubs are
+ * unnecessary, as stubs are generated dynamically using {@link
+ * java.lang.reflect.Proxy Proxy} objects. See {@link
+ * java.rmi.server.UnicastRemoteObject UnicastRemoteObject} for
+ * information about dynamic stub generation. Generation of skeletons and
+ * static stubs was typically performed as part of an application's build
+ * process by calling the {@code rmic} tool. This is unnecessary, and
+ * calls to {@code rmic} can simply be omitted.</em>
+ *
+ * @since 1.1
+ */
+package java.rmi.server;
--- a/src/java.rmi/share/classes/java/rmi/server/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-<!--
- Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License version 2 only, as
- published by the Free Software Foundation. Oracle designates this
- particular file as subject to the "Classpath" exception as provided
- by Oracle in the LICENSE file that accompanied this code.
-
- This code is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- version 2 for more details (a copy is included in the LICENSE file that
- accompanied this code).
-
- You should have received a copy of the GNU General Public License version
- 2 along with this work; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-
- Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions.
--->
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<body bgcolor="white">
-
-Provides classes and interfaces for supporting the server
-side of RMI. A group of classes are used by the stubs and skeletons
-generated by the rmic stub compiler. Another group of classes
-implements the RMI Transport protocol and HTTP tunneling.
-
-<p><strong>Deprecated: HTTP Tunneling.</strong> <em>The HTTP tunneling
-mechanism has been deprecated. See {@link java.rmi.server.RMISocketFactory} for
-further information.</em>
-
-<p><strong>Deprecated: Skeletons and Static Stubs.</strong>
-
-<em>Skeletons and statically generated stubs are deprecated. This
-includes the APIs in this package that require the use of skeletons
-or static stubs, the runtime support for them, and the use of the
-{@code rmic} stub compiler to generate them. Support for skeletons
-and static stubs may be removed in a future release of the
-platform. Skeletons are unnecessary, as server-side method dispatching
-is handled directly by the RMI runtime. Statically generated stubs are
-unnecessary, as stubs are generated dynamically using {@link
-java.lang.reflect.Proxy Proxy} objects. See {@link
-java.rmi.server.UnicastRemoteObject UnicastRemoteObject} for
-information about dynamic stub generation. Generation of skeletons and
-static stubs was typically performed as part of an application's build
-process by calling the {@code rmic} tool. This is unnecessary, and
-calls to {@code rmic} can simply be omitted.</em>
-
-<!--
-<h2>Package Specification</h2>
-
-##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
-<ul>
- <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
-</ul>
-
-<h2>Related Documentation</h2>
-
-For overviews, tutorials, examples, guides, and tool documentation, please see:
-<ul>
- <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
-</ul>
--->
-
-@since 1.1
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.rmi/share/classes/javax/rmi/ssl/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+/**
+ * Provides implementations of {@link java.rmi.server.RMIClientSocketFactory}
+ * and {@link java.rmi.server.RMIServerSocketFactory} over
+ * the Secure Sockets Layer (SSL) or Transport Layer Security (TLS) protocols.
+ *
+ * @since 1.5
+ */
+package javax.rmi.ssl;
--- a/src/java.rmi/share/classes/javax/rmi/ssl/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
-DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
-This code is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 2 only, as
-published by the Free Software Foundation. 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.
--->
-
-</head>
-<body bgcolor="white">
-
-Provides implementations of {@link java.rmi.server.RMIClientSocketFactory}
-and {@link java.rmi.server.RMIServerSocketFactory} over
-the Secure Sockets Layer (SSL) or Transport Layer Security (TLS) protocols.
-
-@since 1.5
-</body>
-</html>
--- a/src/java.security.jgss/share/classes/javax/security/auth/kerberos/package-info.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.security.jgss/share/classes/javax/security/auth/kerberos/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,10 +38,10 @@
*
* You can provide the name of your default realm and Key Distribution
* Center (KDC) host for that realm using the system properties
- * {@code java.security.krb5.realm} and {@code java.security.krb5.kdc}.
- * Both properties must be set.
- * Alternatively, the {@code java.security.krb5.conf} system property can
- * be set to the location of an MIT style {@code krb5.conf} configuration
+ * {@systemProperty java.security.krb5.realm} and
+ * {@systemProperty java.security.krb5.kdc}. Both properties must be set.
+ * Alternatively, the {@systemProperty java.security.krb5.conf} system property
+ * can be set to the location of an MIT style {@code krb5.conf} configuration
* file. If none of these system properties are set, the {@code krb5.conf}
* file is searched for in an implementation-specific manner. Typically,
* an implementation will first look for a {@code krb5.conf} file in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.security.jgss/share/classes/org/ietf/jgss/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+/**
+ * This package presents a framework that allows application developers to
+ * make use of security services like authentication, data integrity and
+ * data confidentiality from a variety of underlying security mechanisms
+ * like Kerberos, using a unified API. The security mechanisms that an
+ * application can
+ * chose to use are identified with unique object identifiers. One example
+ * of such a mechanism is the Kerberos v5 GSS-API mechanism (object
+ * identifier 1.2.840.113554.1.2.2). This mechanism is available through
+ * the default instance of the GSSManager class.<p>
+ *
+ * The GSS-API is defined in a language independent way in
+ * <a href=http://www.ietf.org/rfc/rfc2743.txt>RFC 2743</a>. The Java
+ * language bindings are defined in
+ * <a href=http://www.ietf.org/rfc/rfc2853.txt>RFC 2853</a><p>
+ *
+ * An application starts out by instantiating a {@code GSSManager}
+ * which then serves as a factory for a security context. An application
+ * can use specific principal names and credentials that are also created
+ * using the GSSManager; or it can instantiate a
+ * context with system defaults. It then goes through a context
+ * establishment loop. Once a context is established with the
+ * peer, authentication is complete. Data protection such as integrity
+ * and confidentiality can then be obtained from this context.<p>
+ *
+ * The GSS-API does not perform any communication with the peer. It merely
+ * produces tokens that the application must somehow transport to the
+ * other end.
+ *
+ * <h3 id="useSubjectCredsOnly">Credential Acquisition</h3>
+ * The GSS-API itself does not dictate how an underlying mechanism
+ * obtains the credentials that are needed for authentication. It is
+ * assumed that prior to calling the GSS-API, these credentials are
+ * obtained and stored in a location that the mechanism provider is
+ * aware of. However, the default model in the Java platform will be
+ * that mechanism providers must obtain credentials only from the private
+ * or public credential sets associated with the
+ * {@link javax.security.auth.Subject Subject} in the
+ * current access control context. The Kerberos v5
+ * mechanism will search for the required INITIATE and ACCEPT credentials
+ * ({@link javax.security.auth.kerberos.KerberosTicket KerberosTicket} and
+ * {@link javax.security.auth.kerberos.KerberosKey KerberosKey}) in
+ * the private credential set where as some other mechanism might look
+ * in the public set or in both. If the desired credential is not
+ * present in the appropriate sets of the current Subject, the GSS-API
+ * call must fail.<p>
+ *
+ * This model has the advantage that credential management
+ * is simple and predictable from the applications point of view. An
+ * application, given the right permissions, can purge the credentials in
+ * the Subject or renew them using standard Java API's. If it purged
+ * the credentials, it would be sure that the JGSS mechanism would fail,
+ * or if it renewed a time based credential it would be sure that a JGSS
+ * mechanism would succeed.<p>
+ *
+ * This model does require that a {@link
+ * javax.security.auth.login JAAS login} be performed in order to
+ * authenticate and populate a Subject that the JGSS mechanism can later
+ * utilize. However, applications have the ability to relax this
+ * restriction by means of a system property:
+ * {@systemProperty javax.security.auth.useSubjectCredsOnly}. By default
+ * this system property will be assumed to be {@code true} (even when
+ * it is unset) indicating that providers must only use the credentials
+ * that are present in the current Subject. However, if this property is
+ * explicitly set to false by the application, then it indicates that
+ * the provider is free to use any credentials cache of its choice. Such
+ * a credential cache might be a disk cache, an in-memory cache, or even
+ * just the current Subject itself.
+ *
+ * <h2>Related Documentation</h2>
+ * <p>
+ * For an online tutorial on using Java GSS-API, please see
+ * {@extLink security_guide_jgss_tutorial
+ * Introduction to JAAS and Java GSS-API}.
+ * </p>
+ *
+ * <!--
+ * <h2>Package Specification</h2>
+ *
+ * ##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
+ * <ul>
+ * <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
+ * </ul>
+ *
+ * <h2>Related Documentation</h2>
+ *
+ * For overviews, tutorials, examples, guides, and tool documentation, please see:
+ * <ul>
+ * <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
+ * </ul>
+ *
+ * -->
+ *
+ * @since 1.4
+ * */
+package org.ietf.jgss;
--- a/src/java.security.jgss/share/classes/org/ietf/jgss/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
-DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
-This code is free software; you can redistribute it and/or modify it
-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.
--->
-
-</head>
-<body bgcolor="white">
-
- This package presents a framework that allows application developers to
- make use of security services like authentication, data integrity and
- data confidentiality from a variety of underlying security mechanisms
- like Kerberos, using a unified API. The security mechanisms that an
- application can
- chose to use are identified with unique object identifiers. One example
- of such a mechanism is the Kerberos v5 GSS-API mechanism (object
- identifier 1.2.840.113554.1.2.2). This mechanism is available through
- the default instance of the GSSManager class.<p>
-
- The GSS-API is defined in a language independent way in
- <a href=http://www.ietf.org/rfc/rfc2743.txt>RFC 2743</a>. The Java
- language bindings are defined in
- <a href=http://www.ietf.org/rfc/rfc2853.txt>RFC 2853</a><p>
-
- An application starts out by instantiating a <code>GSSManager</code>
- which then serves as a factory for a security context. An application
- can use specific principal names and credentials that are also created
- using the GSSManager; or it can instantiate a
- context with system defaults. It then goes through a context
- establishment loop. Once a context is established with the
- peer, authentication is complete. Data protection such as integrity
- and confidentiality can then be obtained from this context.<p>
-
- The GSS-API does not perform any communication with the peer. It merely
- produces tokens that the application must somehow transport to the
- other end.
-
-<h3 id="useSubjectCredsOnly">Credential Acquisition</h3>
- The GSS-API itself does not dictate how an underlying mechanism
- obtains the credentials that are needed for authentication. It is
- assumed that prior to calling the GSS-API, these credentials are
- obtained and stored in a location that the mechanism provider is
- aware of. However, the default model in the Java platform will be
- that mechanism providers must obtain credentials only from the private
- or public credential sets associated with the
- {@link javax.security.auth.Subject Subject} in the
- current access control context. The Kerberos v5
- mechanism will search for the required INITIATE and ACCEPT credentials
- ({@link javax.security.auth.kerberos.KerberosTicket KerberosTicket} and
- {@link javax.security.auth.kerberos.KerberosKey KerberosKey}) in
- the private credential set where as some other mechanism might look
- in the public set or in both. If the desired credential is not
- present in the appropriate sets of the current Subject, the GSS-API
- call must fail.<p>
-
- This model has the advantage that credential management
- is simple and predictable from the applications point of view. An
- application, given the right permissions, can purge the credentials in
- the Subject or renew them using standard Java API's. If it purged
- the credentials, it would be sure that the JGSS mechanism would fail,
- or if it renewed a time based credential it would be sure that a JGSS
- mechanism would succeed.<p>
-
- This model does require that a {@link
- javax.security.auth.login JAAS login} be performed in order to
- authenticate and populate a Subject that the JGSS mechanism can later
- utilize. However, applications have the ability to relax this
- restriction by means of a system property:
- <code>javax.security.auth.useSubjectCredsOnly</code>. By default
- this system property will be assumed to be <code>true</code> (even when
- it is unset) indicating that providers must only use the credentials
- that are present in the current Subject. However, if this property is
- explicitly set to false by the application, then it indicates that
- the provider is free to use any credentials cache of its choice. Such
- a credential cache might be a disk cache, an in-memory cache, or even
- just the current Subject itself.
-
-<h2>Related Documentation</h2>
-<p>
-For an online tutorial on using Java GSS-API, please see
-{@extLink security_guide_jgss_tutorial
-Introduction to JAAS and Java GSS-API}.
-</p>
-
-<!--
-<h2>Package Specification</h2>
-
-##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
-<ul>
- <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
-</ul>
-
-<h2>Related Documentation</h2>
-
-For overviews, tutorials, examples, guides, and tool documentation, please see:
-<ul>
- <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
-</ul>
-
--->
-
-@since 1.4
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.smartcardio/share/classes/javax/smartcardio/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+/**
+ * Java™ Smart Card I/O API.
+ *
+ * This specification describes the Java Smart Card I/O API defined by
+ * <a href="http://jcp.org/en/jsr/detail?id=268">JSR 268</a>.
+ *
+ * It defines a Java API for communication with Smart Cards
+ * using ISO/IEC 7816-4 APDUs. It thereby allows Java applications to interact with
+ * applications running on the Smart Card, to store and retrieve data
+ * on the card, etc.
+ *
+ * <p>
+ * The API is defined by classes in the package
+ * <code>javax.smartcardio</code>. They can be classified as follows:
+ *
+ * <dl>
+ * <dt>Classes describing the corresponding Smart Card structures
+ * <dd>
+ * <a href="ATR.html">ATR</a>,
+ * <a href="CommandAPDU.html">CommandAPDU</a>,
+ * <a href="ResponseAPDU.html">ResponseAPDU</a>
+ *
+ * <dt>Factory to obtain implementations
+ * <dd>
+ * <a href="TerminalFactory.html">TerminalFactory</a>
+ *
+ * <dt>Main classes for card and terminal functions
+ * <dd>
+ * <a href="CardTerminals.html">CardTerminals</a>,
+ * <a href="CardTerminal.html">CardTerminal</a>,
+ * <a href="Card.html">Card</a>,
+ * <a href="CardChannel.html">CardChannel</a>
+ *
+ * <dt>Supporting permission and exception classes
+ * <dd>
+ * <a href="CardPermission.html">CardPermission</a>,
+ * <a href="CardException.html">CardException</a>,
+ * <a href="CardNotPresentException.html">CardNotPresentException</a>
+ *
+ * <dt>Service provider interface, not accessed directly by applications
+ * <dd>
+ * <a href="TerminalFactorySpi.html">TerminalFactorySpi</a>
+ *
+ * </dl>
+ *
+ *
+ * <h3>API Example</h3>
+ *
+ * A simple example of using the API is:
+ * <pre>
+ * // show the list of available terminals
+ * TerminalFactory factory = TerminalFactory.getDefault();
+ * List<CardTerminal> terminals = factory.terminals().list();
+ * System.out.println("Terminals: " + terminals);
+ * // get the first terminal
+ * CardTerminal terminal = terminals.get(0);
+ * // establish a connection with the card
+ * Card card = terminal.connect("T=0");
+ * System.out.println("card: " + card);
+ * CardChannel channel = card.getBasicChannel();
+ * ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
+ * System.out.println("response: " + toString(r.getBytes()));
+ * // disconnect
+ * card.disconnect(false);
+ * </pre>
+ *
+ * @since 1.6
+ * @author Andreas Sterbenz
+ * @author JSR 268 Expert Group
+ */
+package javax.smartcardio;
--- a/src/java.smartcardio/share/classes/javax/smartcardio/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-<!--
- Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
- 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.
--->
-
-<html>
-<body>
-<h2>Java™ Smart Card I/O API</h2>
-
-This specification describes the Java Smart Card I/O API defined by
-<a href="http://jcp.org/en/jsr/detail?id=268">JSR 268</a>.
-
-It defines a Java API for communication with Smart Cards
-using ISO/IEC 7816-4 APDUs. It thereby allows Java applications to interact with
-applications running on the Smart Card, to store and retrieve data
-on the card, etc.
-
-<p>
-The API is defined by classes in the package
-<code>javax.smartcardio</code>. They can be classified as follows:
-
-<dl>
-<dt>Classes describing the corresponding Smart Card structures
-<dd>
-<a href="ATR.html">ATR</a>,
-<a href="CommandAPDU.html">CommandAPDU</a>,
-<a href="ResponseAPDU.html">ResponseAPDU</a>
-
-<dt>Factory to obtain implementations
-<dd>
-<a href="TerminalFactory.html">TerminalFactory</a>
-
-<dt>Main classes for card and terminal functions
-<dd>
-<a href="CardTerminals.html">CardTerminals</a>,
-<a href="CardTerminal.html">CardTerminal</a>,
-<a href="Card.html">Card</a>,
-<a href="CardChannel.html">CardChannel</a>
-
-<dt>Supporting permission and exception classes
-<dd>
-<a href="CardPermission.html">CardPermission</a>,
-<a href="CardException.html">CardException</a>,
-<a href="CardNotPresentException.html">CardNotPresentException</a>
-
-<dt>Service provider interface, not accessed directly by applications
-<dd>
-<a href="TerminalFactorySpi.html">TerminalFactorySpi</a>
-
-</dl>
-
-
-<h3>API Example</h3>
-
-A simple example of using the API is:
-<pre>
- // show the list of available terminals
- TerminalFactory factory = TerminalFactory.getDefault();
- List<CardTerminal> terminals = factory.terminals().list();
- System.out.println("Terminals: " + terminals);
- // get the first terminal
- CardTerminal terminal = terminals.get(0);
- // establish a connection with the card
- Card card = terminal.connect("T=0");
- System.out.println("card: " + card);
- CardChannel channel = card.getBasicChannel();
- ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
- System.out.println("response: " + toString(r.getBytes()));
- // disconnect
- card.disconnect(false);
-</pre>
-
-@since 1.6
-@author Andreas Sterbenz
-@author JSR 268 Expert Group
-
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.sql.rowset/share/classes/com/sun/rowset/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+/**
+ * Provides five standard implementations of the standard JDBC <code>RowSet</code> implementation
+ * interface definitions. These reference implementations are included with the J2SE version
+ * 1.5 platform and represent the benchmark standard <code>RowSet</code> implementations as verified
+ * by the Test Compatibility Kit (TCK) as mandated by the Java Community Process.
+ * <br>
+ *
+ * <h3>1.0 Available JDBC RowSet Reference Implementations </h3>
+ * The following implementations are provided:<br>
+ *
+ * <blockquote><code><b>JdbcRowSetImpl</b></code> - The <code>javax.sql.rowset.JdbcRowSet</code>
+ * interface reference implementation. <br>
+ * <br>
+ * <code><b>CachedRowSetImpl</b></code> - The <code>javax.sql.rowset.CachedRowSet</code> interface
+ * reference implementation.<br>
+ * <br>
+ * <code><b>WebRowSetImpl</b></code> - The <code>javax.sql.rowset.WebRowSet</code> interface
+ * reference implementation.<br>
+ * <br>
+ * <code><b>FilteredRowSetImpl</b></code> - The <code>javax.sql.rowset.FilteredRowSet</code>
+ * interface reference implementation.<br>
+ * <br>
+ * <code><b>JoinRowSetImpl</b></code> - The <code>javax.sql.rowset.JoinRowSet</code> interface
+ * reference implementation.<br>
+ * </blockquote>
+ *
+ * All details on their expected behavior, including their interactions with the <code>SyncProvider</code>
+ * SPI and helper classes are provided in the interface definitions in the <code>javax.sql.rowset</code>
+ * package specification.<br>
+ *
+ * <h3>2.0 Usage</h3>
+ * The reference implementations represent robust implementations of the standard
+ * <code>RowSet</code> interfaces defined in the <code>javax.sql.rowset</code> package.
+ * All disconnected <code>RowSet</code> implementations, such as the <code>CachedRowSetImpl</code>
+ * and <code>WebRowSetImpl</code>, are flexible enough to use the <code>SyncFactory</code> SPIs to
+ * leverage non-reference implementation <code>SyncProvider</code> implementations to obtain
+ * differing synchronization semantics. Furthermore, developers and vendors alike are free
+ * to use these implementations and integrate them into their products just as they
+ * can with to other components of the Java platform.<br>
+ *
+ * <h3>3.0 Extending the JDBC RowSet Implementations</h3>
+ *
+ * The JDBC <code>RowSet</code> reference implementations are provided as non-final
+ * classes so that any developer can extend them to provide additional features
+ * while maintaining the core required standard functionality and compatibility. It
+ * is anticipated that many vendors and developers will extend the standard feature
+ * set to their their particular needs. The website for JDBC Technology will
+ * provider a portal where implementations can be listed, similar to the way it
+ * provides a site for JDBC drivers.
+ */
+ package com.sun.rowset;
--- a/src/java.sql.rowset/share/classes/com/sun/rowset/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-<!--
- Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License version 2 only, as
- published by the Free Software Foundation. Oracle designates this
- particular file as subject to the "Classpath" exception as provided
- by Oracle in the LICENSE file that accompanied this code.
-
- This code is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- version 2 for more details (a copy is included in the LICENSE file that
- accompanied this code).
-
- You should have received a copy of the GNU General Public License version
- 2 along with this work; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-
- Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions.
--->
-
-<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
-
- <meta http-equiv="Content-Type"
- content="text/html; charset=iso-8859-1">
- <title>com.sun.rowset Package</title>
-</head>
- <body bgcolor="#ffffff">
-Provides five standard implementations of the standard JDBC <code>RowSet</code> implementation
-interface definitions. These reference implementations are included with the J2SE version
-1.5 platform and represent the benchmark standard <code>RowSet</code> implementations as verified
-by the Test Compatibility Kit (TCK) as mandated by the Java Community Process.
-<br>
-
-<h3>1.0 Available JDBC RowSet Reference Implementations </h3>
-The following implementations are provided:<br>
-
-<blockquote><code><b>JdbcRowSetImpl</b></code> - The <code>javax.sql.rowset.JdbcRowSet</code>
-interface reference implementation. <br>
-<br>
-<code><b>CachedRowSetImpl</b></code> - The <code>javax.sql.rowset.CachedRowSet</code> interface
-reference implementation.<br>
-<br>
-<code><b>WebRowSetImpl</b></code> - The <code>javax.sql.rowset.WebRowSet</code> interface
-reference implementation.<br>
-<br>
-<code><b>FilteredRowSetImpl</b></code> - The <code>javax.sql.rowset.FilteredRowSet</code>
-interface reference implementation.<br>
-<br>
-<code><b>JoinRowSetImpl</b></code> - The <code>javax.sql.rowset.JoinRowSet</code> interface
-reference implementation.<br>
-</blockquote>
-
-All details on their expected behavior, including their interactions with the <code>SyncProvider</code>
-SPI and helper classes are provided in the interface definitions in the <code>javax.sql.rowset</code>
-package specification.<br>
-
-<h3>2.0 Usage</h3>
-The reference implementations represent robust implementations of the standard
-<code>RowSet</code> interfaces defined in the <code>javax.sql.rowset</code> package.
-All disconnected <code>RowSet</code> implementations, such as the <code>CachedRowSetImpl</code>
-and <code>WebRowSetImpl</code>, are flexible enough to use the <code>SyncFactory</code> SPIs to
-leverage non-reference implementation <code>SyncProvider</code> implementations to obtain
-differing synchronization semantics. Furthermore, developers and vendors alike are free
-to use these implementations and integrate them into their products just as they
-can with to other components of the Java platform.<br>
-
-<h3>3.0 Extending the JDBC RowSet Implementations</h3>
-
-The JDBC <code>RowSet</code> reference implementations are provided as non-final
-classes so that any developer can extend them to provide additional features
-while maintaining the core required standard functionality and compatibility. It
-is anticipated that many vendors and developers will extend the standard feature
-set to their their particular needs. The website for JDBC Technology will
-provider a portal where implementations can be listed, similar to the way it
-provides a site for JDBC drivers.
-<br>
-<br>
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.sql.rowset/share/classes/com/sun/rowset/providers/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+/**
+ *
+ * Repository for the <code>RowSet</code> reference implementations of the
+ * <code>SyncProvider</code> abstract class. These implementations provide a
+ * disconnected <code>RowSet</code>
+ * object with the ability to synchronize the data in the underlying data
+ * source with its data. These implementations are provided as
+ * the default <code>SyncProvider</code> implementations and are accessible via the
+ * <code>SyncProvider</code> SPI managed by the <code>SyncFactory</code>.
+ *
+ * <h3>1.0 <code>SyncProvider</code> Reference Implementations</h3>
+ * The main job of a <code>SyncProvider</code> implementation is to manage
+ * the reader and writer mechanisms.
+ * The <code>SyncProvider</code> SPI, as specified in the <code>javax.sql.rowset.spi</code>
+ * package, provides a pluggable mechanism by which <code>javax.sql.RowSetReader</code>
+ * and <code>javax.sql.RowSetWriter</code> implementations can be supplied to a disconnected
+ * <code>RowSet</code> object.
+ * <P>
+ * A reader, a <code>javax.sql.RowSetReader</code>
+ * object, does the work necessary to populate a <code>RowSet</code> object with data.
+ * A writer, a <code>javax.sql.RowSetWriter</code> object, does the work necessary for
+ * synchronizing a <code>RowSet</code> object's data with the data in the originating
+ * source of data. Put another way, a writer writes a <code>RowSet</code>
+ * object's data back to the data source.
+ * <P>
+ * Generally speaking, the course of events is this. The reader makes a connection to
+ * the data source and reads the data from a <code>ResultSet</code> object into its
+ * <code>RowSet</code> object. Then it closes the connection. While
+ * the <code>RowSet</code> object is disconnected, an application makes some modifications
+ * to the data and calls the method <code>acceptChanges</code>. At this point, the
+ * writer is called to write the changes back to the database table or view
+ * from which the original data came. This is called <i>synchronization</i>.
+ * <P>
+ * If the data in the originating data source has not changed, there is no problem
+ * with just writing the <code>RowSet</code> object's new data to the data source.
+ * If it has changed, however, there is a conflict that needs to be resolved. One
+ * way to solve the problem is not to let the data in the data source be changed in
+ * the first place, which can be done by setting locks on a row, a table, or the
+ * whole data source. Setting locks is a way to avoid conflicts, but it can be
+ * very expensive. Another approach, which is at the other end of the spectrum,
+ * is simply to assume that no conflicts will occur and thus do nothing to avoid
+ * conflicts.
+ * Different <code>SyncProvider</code> implementations may handle synchronization in
+ * any of these ways, varying from doing no checking for
+ * conflicts, to doing various levels of checking, to guaranteeing that there are no
+ * conflicts.
+ * <P>
+ * The <code>SyncProvider</code> class offers methods to help a <code>RowSet</code>
+ * object discover and manage how a provider handles synchronization.
+ * The method <code>getProviderGrade</code> returns the
+ * grade of synchronization a provider offers. An application can
+ * direct the provider to use a particular level of locking by calling
+ * the method <code>setDataSourceLock</code> and specifying the level of locking desired.
+ * If a <code>RowSet</code> object's data came from an SQL <code>VIEW</code>, an
+ * application may call the method <code>supportsUpdatableView</code> to
+ * find out whether the <code>VIEW</code> can be updated.
+ * <P>
+ * Synchronization is done completely behind the scenes, so it is third party vendors of
+ * synchronization provider implementations who have to take care of this complex task.
+ * Application programmers can decide which provider to use and the level of locking to
+ * be done, but they are free from having to worry about the implementation details.
+ * <P>
+ * The JDBC <code>RowSet</code> Implementations reference implementation provides two
+ * implementations of the <code>SyncProvider</code> class:
+ *
+ * <UL>
+ * <LI>
+ * <b><code>RIOptimisticProvider</code></b> - provides the <code>javax.sql.RowSetReader</code>
+ * and <code>javax.sql.RowSetWriter</code> interface implementations and provides
+ * an optimistic concurrency model for synchronization. This model assumes that there
+ * will be few conflicts and therefore uses a relatively low grade of synchronization.
+ * If no other provider is available, this is the default provider that the
+ * <code>SyncFactory</code> will supply to a <code>RowSet</code> object.
+ * <br>
+ * <LI>
+ * <b><code>RIXMLProvider</code></b> - provides the <code>XmlReader</code> (an extension
+ * of the <code>javax.sql.RowSetReader</code> interface) and the <code>XmlWriter</code>
+ * (an extension of the <code>javax.sql.RowSetWriter</code> interface) to enable
+ * <code>WebRowSet</code> objects to write their state to a
+ * well formed XML document according to the <code>WebRowSet</code> XML schema
+ * definition.<br>
+ * </UL>
+ *
+ * <h3>2.0 Basics in RowSet Population & Synchronization</h3>
+ * A rowset's first task is to populate itself with rows of column values.
+ * Generally, these rows will come from a relational database, so a rowset
+ * has properties that supply what is necessary for making a connection to
+ * a database and executing a query. A rowset that does not need to establish
+ * a connection and execute a command, such as one that gets its data from
+ * a tabular file instead of a relational database, does not need to have these
+ * properties set. The vast majority of RowSets, however, do need to set these
+ * properties. The general rule is that a RowSet is required to set only the
+ * properties that it uses.<br>
+ * <br>
+ * The <code>command</code> property contains the query that determines what
+ * data a <code>RowSet</code> will contain. Rowsets have methods for setting a query's
+ * parameter(s), which means that a query can be executed multiple times with
+ * different parameters to produce different result sets. Or the query can be
+ * changed to something completely new to get a new result set.
+ * <p>Once a rowset contains the rows from a <code>ResultSet</code> object or some
+ * other data source, its column values can be updated, and its rows can be
+ * inserted or deleted. Any method that causes a change in the rowset's values
+ * or cursor position also notifies any object that has been registered as
+ * a listener with the rowset. So, for example, a table that displays the rowset's
+ * data in an applet can be notified of changes and make updates as they
+ * occur.<br>
+ * <br>
+ * The changes made to a rowset can be propagated back to the original data
+ * source to keep the rowset and its data source synchronized. Although this
+ * involves many operations behind the scenes, it is completely transparent
+ * to the application programmer and remains the concern of the RowSet provider
+ * developer. All an application has to do is invoke the method <code>acceptChanges</code>,
+ * and the data source backing the rowset will be updated to match the current
+ * values in the rowset. </p>
+ *
+ * <p>A disconnected rowset, such as a <code>CachedRowSet</code> or <code>WebRowSet</code>
+ * object, establishes a connection to populate itself with data from a database
+ * and then closes the connection. The <code>RowSet</code> object will remain
+ * disconnected until it wants to propagate changes back to its database table,
+ * which is optional. To write its changes back to the database (synchronize with
+ * the database), the rowset establishes a connection, write the changes, and then
+ * once again disconnects itself.<br>
+ * </p>
+ *
+ * <h3> 3.0 Other Possible Implementations</h3>
+ * There are many other possible implementations of the <code>SyncProvider</code> abstract
+ * class. One possibility is to employ a more robust synchronization model, which
+ * would give a <code>RowSet</code> object increased trust in the provider's
+ * ability to get any updates back to the original data source. Another possibility
+ * is a more formal synchronization mechanism such as SyncML
+ * (<a href="http://www.syncml.org/">http://www.syncml.org/</a>) <br>
+ */
+package com.sun.rowset.providers;
--- a/src/java.sql.rowset/share/classes/com/sun/rowset/providers/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +0,0 @@
-<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
-
- <meta http-equiv="Content-Type"
- content="text/html; charset=iso-8859-1">
-
- <meta name="GENERATOR"
- content="Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]">
- <!--
-
-Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
-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.
--->
- <title>javax.sql.rowset.providers Package</title>
-</head>
- <body bgcolor="#ffffff">
-Repository for the <code>RowSet</code> reference implementations of the
-<code>SyncProvider</code> abstract class. These implementations provide a
-disconnected <code>RowSet</code>
-object with the ability to synchronize the data in the underlying data
-source with its data. These implementations are provided as
-the default <code>SyncProvider</code> implementations and are accessible via the
-<code>SyncProvider</code> SPI managed by the <code>SyncFactory</code>.
-
-<h3>1.0 <code>SyncProvider</code> Reference Implementations</h3>
- The main job of a <code>SyncProvider</code> implementation is to manage
-the reader and writer mechanisms.
- The <code>SyncProvider</code> SPI, as specified in the <code>javax.sql.rowset.spi</code>
-package, provides a pluggable mechanism by which <code>javax.sql.RowSetReader</code>
-and <code>javax.sql.RowSetWriter</code> implementations can be supplied to a disconnected
-<code>RowSet</code> object.
-<P>
- A reader, a <code>javax.sql.RowSetReader</code>
-object, does the work necessary to populate a <code>RowSet</code> object with data.
-A writer, a <code>javax.sql.RowSetWriter</code> object, does the work necessary for
-synchronizing a <code>RowSet</code> object's data with the data in the originating
-source of data. Put another way, a writer writes a <code>RowSet</code>
-object's data back to the data source.
-<P>
-Generally speaking, the course of events is this. The reader makes a connection to
-the data source and reads the data from a <code>ResultSet</code> object into its
-<code>RowSet</code> object. Then it closes the connection. While
-the <code>RowSet</code> object is disconnected, an application makes some modifications
-to the data and calls the method <code>acceptChanges</code>. At this point, the
-writer is called to write the changes back to the database table or view
-from which the original data came. This is called <i>synchronization</i>.
-<P>
-If the data in the originating data source has not changed, there is no problem
-with just writing the <code>RowSet</code> object's new data to the data source.
-If it has changed, however, there is a conflict that needs to be resolved. One
-way to solve the problem is not to let the data in the data source be changed in
-the first place, which can be done by setting locks on a row, a table, or the
-whole data source. Setting locks is a way to avoid conflicts, but it can be
-very expensive. Another approach, which is at the other end of the spectrum,
- is simply to assume that no conflicts will occur and thus do nothing to avoid
-conflicts.
-Different <code>SyncProvider</code> implementations may handle synchronization in
-any of these ways, varying from doing no checking for
-conflicts, to doing various levels of checking, to guaranteeing that there are no
-conflicts.
-<P>
-The <code>SyncProvider</code> class offers methods to help a <code>RowSet</code>
-object discover and manage how a provider handles synchronization.
-The method <code>getProviderGrade</code> returns the
-grade of synchronization a provider offers. An application can
-direct the provider to use a particular level of locking by calling
-the method <code>setDataSourceLock</code> and specifying the level of locking desired.
-If a <code>RowSet</code> object's data came from an SQL <code>VIEW</code>, an
-application may call the method <code>supportsUpdatableView</code> to
-find out whether the <code>VIEW</code> can be updated.
-<P>
-Synchronization is done completely behind the scenes, so it is third party vendors of
-synchronization provider implementations who have to take care of this complex task.
-Application programmers can decide which provider to use and the level of locking to
-be done, but they are free from having to worry about the implementation details.
-<P>
-The JDBC <code>RowSet</code> Implementations reference implementation provides two
-implementations of the <code>SyncProvider</code> class:
-
-<UL>
-<LI>
-<b><code>RIOptimisticProvider</code></b> - provides the <code>javax.sql.RowSetReader</code>
-and <code>javax.sql.RowSetWriter</code> interface implementations and provides
-an optimistic concurrency model for synchronization. This model assumes that there
-will be few conflicts and therefore uses a relatively low grade of synchronization.
-If no other provider is available, this is the default provider that the
-<code>SyncFactory</code> will supply to a <code>RowSet</code> object.
- <br>
-<LI>
-<b><code>RIXMLProvider</code></b> - provides the <code>XmlReader</code> (an extension
-of the <code>javax.sql.RowSetReader</code> interface) and the <code>XmlWriter</code>
-(an extension of the <code>javax.sql.RowSetWriter</code> interface) to enable
-<code>WebRowSet</code> objects to write their state to a
-well formed XML document according to the <code>WebRowSet</code> XML schema
-definition.<br>
-</UL>
-
-<h3>2.0 Basics in RowSet Population & Synchronization</h3>
-A rowset's first task is to populate itself with rows of column values.
-Generally, these rows will come from a relational database, so a rowset
-has properties that supply what is necessary for making a connection to
-a database and executing a query. A rowset that does not need to establish
-a connection and execute a command, such as one that gets its data from
-a tabular file instead of a relational database, does not need to have these
-properties set. The vast majority of RowSets, however, do need to set these
-properties. The general rule is that a RowSet is required to set only the
-properties that it uses.<br>
- <br>
-The <code>command</code> property contains the query that determines what
-data a <code>RowSet</code> will contain. Rowsets have methods for setting a query's
-parameter(s), which means that a query can be executed multiple times with
-different parameters to produce different result sets. Or the query can be
-changed to something completely new to get a new result set.
-<p>Once a rowset contains the rows from a <code>ResultSet</code> object or some
-other data source, its column values can be updated, and its rows can be
-inserted or deleted. Any method that causes a change in the rowset's values
-or cursor position also notifies any object that has been registered as
-a listener with the rowset. So, for example, a table that displays the rowset's
-data in an applet can be notified of changes and make updates as they
-occur.<br>
- <br>
-The changes made to a rowset can be propagated back to the original data
-source to keep the rowset and its data source synchronized. Although this
-involves many operations behind the scenes, it is completely transparent
-to the application programmer and remains the concern of the RowSet provider
-developer. All an application has to do is invoke the method <code>acceptChanges</code>,
-and the data source backing the rowset will be updated to match the current
-values in the rowset. </p>
-
-<p>A disconnected rowset, such as a <code>CachedRowSet</code> or <code>WebRowSet</code>
- object, establishes a connection to populate itself with data from a database
- and then closes the connection. The <code>RowSet</code> object will remain
- disconnected until it wants to propagate changes back to its database table,
- which is optional. To write its changes back to the database (synchronize with
- the database), the rowset establishes a connection, write the changes, and then
- once again disconnects itself.<br>
- </p>
-
-<h3> 3.0 Other Possible Implementations</h3>
- There are many other possible implementations of the <code>SyncProvider</code> abstract
- class. One possibility is to employ a more robust synchronization model, which
- would give a <code>RowSet</code> object increased trust in the provider's
- ability to get any updates back to the original data source. Another possibility
- is a more formal synchronization mechanism such as SyncML
- (<a href="http://www.syncml.org/">http://www.syncml.org/</a>) <br>
- <br>
- <br>
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+/**
+ * Provides utility classes to allow serializable mappings between SQL types
+ * and data types in the Java programming language.
+ * <p> Standard JDBC <code>RowSet</code> implementations may use these utility
+ * classes to
+ * assist in the serialization of disconnected <code>RowSet</code> objects.
+ * This is useful
+ * when transmitting a disconnected <code>RowSet</code> object over the wire to
+ * a different VM or across layers within an application.<br>
+ * </p>
+ *
+ * <h3>1.0 SerialArray</h3>
+ * A serializable mapping in the Java programming language of an SQL ARRAY
+ * value. <br>
+ * <br>
+ * The <code>SerialArray</code> class provides a constructor for creating a <code>SerialArray</code>
+ * instance from an Array object, methods for getting the base type and
+ * the SQL name for the base type, and methods for copying all or part of a
+ * <code>SerialArray</code> object. <br>
+ *
+ * <h3>2.0 SerialBlob</h3>
+ * A serializable mapping in the Java programming language of an SQL BLOB
+ * value. <br>
+ * <br>
+ * The <code>SerialBlob</code>class provides a constructor for creating an instance
+ * from a Blob object. Note that the Blob object should have brought the SQL
+ * BLOB value's data over to the client before a <code>SerialBlob</code>object
+ * is constructed from it. The data of an SQL BLOB value can be materialized
+ * on the client as an array of bytes (using the method <code>Blob.getBytes</code>)
+ * or as a stream of uninterpreted bytes (using the method <code>Blob.getBinaryStream</code>).
+ * <br>
+ * <br>
+ * <code>SerialBlob</code> methods make it possible to make a copy of a <code>SerialBlob</code>
+ * object as an array of bytes or as a stream. They also make it possible
+ * to locate a given pattern of bytes or a <code>Blob</code> object within a <code>SerialBlob</code>
+ * object. <br>
+ *
+ * <h3>3.0 SerialClob</h3>
+ * A serializable mapping in the Java programming language of an SQL CLOB
+ * value. <br>
+ * <br>
+ * The <code>SerialClob</code> class provides a constructor for creating an instance
+ * from a <code>Clob</code> object. Note that the <code>Clob</code> object should have
+ * brought the SQL CLOB value's data over to the client before a <code>SerialClob</code>
+ * object is constructed from it. The data of an SQL CLOB value can be
+ * materialized on the client as a stream of Unicode characters. <br>
+ * <br>
+ * <code>SerialClob</code> methods make it possible to get a substring from a
+ * <code>SerialClob</code> object or to locate the start of a pattern of characters.
+ * <br>
+ *
+ * <h3>5.0 SerialDatalink</h3>
+ * A serializable mapping in the Java programming language of an SQL DATALINK
+ * value. A DATALINK value references a file outside of the underlying data source
+ * that the originating data source manages. <br>
+ * <br>
+ * <code>RowSet</code> implementations can use the method <code>RowSet.getURL()</code> to retrieve
+ * a <code>java.net.URL</code> object, which can be used to manipulate the external data.
+ * <br>
+ * <br>
+ * <code> java.net.URL url = rowset.getURL(1);</code><br>
+ *
+ * <h3>6.0 SerialJavaObject</h3>
+ * A serializable mapping in the Java programming language of an SQL JAVA_OBJECT
+ * value. Assuming the Java object instance implements the Serializable interface,
+ * this simply wraps the serialization process. <br>
+ * <br>
+ * If however, the serialization is not possible in the case where the Java
+ * object is not immediately serializable, this class will attempt to serialize
+ * all non static members to permit the object instance state to be serialized.
+ * Static or transient fields cannot be serialized and attempting to do so
+ * will result in a <code>SerialException</code> being thrown. <br>
+ *
+ * <h3>7.0 SerialRef</h3>
+ * A serializable mapping between the SQL REF type and the Java programming
+ * language. <br>
+ * <br>
+ * The <code>SerialRef</code> class provides a constructor for creating a <code>SerialRef</code>
+ * instance from a <code>Ref</code> type and provides methods for getting
+ * and setting the <code>Ref</code> object type. <br>
+ *
+ * <h3>8.0 SerialStruct</h3>
+ * A serializable mapping in the Java programming language of an SQL structured
+ * type. Each attribute that is not already serializable is mapped to a serializable
+ * form, and if an attribute is itself a structured type, each of its attributes
+ * that is not already serializable is mapped to a serializable form. <br>
+ * <br>
+ * In addition, if a <code>Map</code> object is passed to one of the constructors or
+ * to the method <code>getAttributes</code>, the structured type is custom mapped
+ * according to the mapping specified in the <code>Map</code> object.
+ * <br>
+ * The <code>SerialStruct</code> class provides a constructor for creating an
+ * instance from a <code>Struct</code> object, a method for retrieving the SQL
+ * type name of the SQL structured type in the database, and methods for retrieving
+ * its attribute values. <br>
+ *
+ * <h3>9.0 SQLInputImpl</h3>
+ * An input stream used for custom mapping user-defined types (UDTs). An
+ * <code>SQLInputImpl</code> object is an input stream that contains a stream of
+ * values that are
+ * the attributes of a UDT. This class is used by the driver behind the scenes
+ * when the method <code>getObject</code> is called on an SQL structured or distinct
+ * type that has a custom mapping; a programmer never invokes <code>SQLInputImpl</code>
+ * methods directly. <br>
+ * <br>
+ * The <code>SQLInputImpl</code> class provides a set of reader methods
+ * analogous to the <code>ResultSet</code> getter methods. These methods make it
+ * possible to read the values in an <code>SQLInputImpl</code> object. The method
+ * <code>wasNull</code> is used to determine whether the last value read was SQL NULL.
+ * <br>
+ * <br>
+ * When a constructor or getter method that takes a <code>Map</code> object is called,
+ * the JDBC driver calls the method
+ * <code>SQLData.getSQLType</code> to determine the SQL type of the UDT being custom
+ * mapped. The driver creates an instance of <code>SQLInputImpl</code>, populating it with
+ * the attributes of the UDT. The driver then passes the input stream to the
+ * method <code>SQLData.readSQL</code>, which in turn calls the <code>SQLInputImpl</code>
+ * methods to read the attributes from the input stream. <br>
+ *
+ * <h3>10.0 SQLOutputImpl</h3>
+ * The output stream for writing the attributes of a custom mapped user-defined
+ * type (UDT) back to the database. The driver uses this interface internally,
+ * and its methods are never directly invoked by an application programmer.
+ * <br>
+ * <br>
+ * When an application calls the method <code>PreparedStatement.setObject</code>, the
+ * driver checks to see whether the value to be written is a UDT with a custom
+ * mapping. If it is, there will be an entry in a type map containing the Class
+ * object for the class that implements <code>SQLData</code> for this UDT. If the
+ * value to be written is an instance of <code>SQLData</code>, the driver will
+ * create an instance of <code>SQLOutputImpl</code> and pass it to the method
+ * <code>SQLData.writeSQL</code>.
+ * The method <code>writeSQL</code> in turn calls the appropriate <code>SQLOutputImpl</code>
+ * writer methods to write data from the <code>SQLData</code> object to the
+ * <code>SQLOutputImpl</code>
+ * output stream as the representation of an SQL user-defined type.
+ *
+ * <h3>Custom Mapping</h3>
+ * The JDBC API provides mechanisms for mapping an SQL structured type or DISTINCT
+ * type to the Java programming language. Typically, a structured type is mapped
+ * to a class, and its attributes are mapped to fields in the class.
+ * (A DISTINCT type can thought of as having one attribute.) However, there are
+ * many other possibilities, and there may be any number of different mappings.
+ * <P>
+ * A programmer defines the mapping by implementing the interface <code>SQLData</code>.
+ * For example, if an SQL structured type named AUTHORS has the attributes NAME,
+ * TITLE, and PUBLISHER, it could be mapped to a Java class named Authors. The
+ * Authors class could have the fields name, title, and publisher, to which the
+ * attributes of AUTHORS are mapped. In such a case, the implementation of
+ * <code>SQLData</code> could look like the following:
+ * <PRE>
+ * public class Authors implements SQLData {
+ * public String name;
+ * public String title;
+ * public String publisher;
+ *
+ * private String sql_type;
+ * public String getSQLTypeName() {
+ * return sql_type;
+ * }
+ *
+ * public void readSQL(SQLInput stream, String type)
+ * throws SQLException {
+ * sql_type = type;
+ * name = stream.readString();
+ * title = stream.readString();
+ * publisher = stream.readString();
+ * }
+ *
+ * public void writeSQL(SQLOutput stream) throws SQLException {
+ * stream.writeString(name);
+ * stream.writeString(title);
+ * stream.writeString(publisher);
+ * }
+ * }
+ * </PRE>
+ *
+ * A <code>java.util.Map</code> object is used to associate the SQL structured
+ * type with its mapping to the class <code>Authors</code>. The following code fragment shows
+ * how a <code>Map</code> object might be created and given an entry associating
+ * <code>AUTHORS</code> and <code>Authors</code>.
+ * <PRE>
+ * java.util.Map map = new java.util.HashMap();
+ * map.put("SCHEMA_NAME.AUTHORS", Class.forName("Authors");
+ * </PRE>
+ *
+ * The <code>Map</code> object <i>map</i> now contains an entry with the
+ * fully qualified name of the SQL structured type and the <code>Class</code>
+ * object for the class <code>Authors</code>. It can be passed to a method
+ * to tell the driver how to map <code>AUTHORS</code> to <code>Authors</code>.
+ * <P>
+ * For a disconnected <code>RowSet</code> object, custom mapping can be done
+ * only when a <code>Map</code> object is passed to the method or constructor
+ * that will be doing the custom mapping. The situation is different for
+ * connected <code>RowSet</code> objects because they maintain a connection
+ * with the data source. A method that does custom mapping and is called by
+ * a disconnected <code>RowSet</code> object may use the <code>Map</code>
+ * object that is associated with the <code>Connection</code> object being
+ * used. So, in other words, if no map is specified, the connection's type
+ * map can be used by default.
+ */
+package javax.sql.rowset.serial;
--- a/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,239 +0,0 @@
-<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
-
- <meta http-equiv="Content-Type"
- content="text/html; charset=iso-8859-1">
-
- <meta name="GENERATOR"
- content="Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]">
-<!--
-Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
-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.
--->
-<title>javax.sql.rowset.serial</title>
-</head>
-<body bgcolor="#ffffff">
-Provides utility classes to allow serializable mappings between SQL types
-and data types in the Java programming language.
-<p> Standard JDBC <code>RowSet</code> implementations may use these utility
-classes to
-assist in the serialization of disconnected <code>RowSet</code> objects.
-This is useful
-when transmitting a disconnected <code>RowSet</code> object over the wire to
-a different VM or across layers within an application.<br>
-</p>
-
-<h3>1.0 SerialArray</h3>
-A serializable mapping in the Java programming language of an SQL ARRAY
-value. <br>
-<br>
-The <code>SerialArray</code> class provides a constructor for creating a <code>SerialArray</code>
-instance from an Array object, methods for getting the base type and
-the SQL name for the base type, and methods for copying all or part of a
-<code>SerialArray</code> object. <br>
-
-<h3>2.0 SerialBlob</h3>
-A serializable mapping in the Java programming language of an SQL BLOB
-value. <br>
-<br>
-The <code>SerialBlob</code>class provides a constructor for creating an instance
-from a Blob object. Note that the Blob object should have brought the SQL
-BLOB value's data over to the client before a <code>SerialBlob</code>object
-is constructed from it. The data of an SQL BLOB value can be materialized
-on the client as an array of bytes (using the method <code>Blob.getBytes</code>)
-or as a stream of uninterpreted bytes (using the method <code>Blob.getBinaryStream</code>).
-<br>
-<br>
-<code>SerialBlob</code> methods make it possible to make a copy of a <code>SerialBlob</code>
-object as an array of bytes or as a stream. They also make it possible
-to locate a given pattern of bytes or a <code>Blob</code> object within a <code>SerialBlob</code>
-object. <br>
-
-<h3>3.0 SerialClob</h3>
-A serializable mapping in the Java programming language of an SQL CLOB
-value. <br>
-<br>
-The <code>SerialClob</code> class provides a constructor for creating an instance
-from a <code>Clob</code> object. Note that the <code>Clob</code> object should have
-brought the SQL CLOB value's data over to the client before a <code>SerialClob</code>
-object is constructed from it. The data of an SQL CLOB value can be
-materialized on the client as a stream of Unicode characters. <br>
-<br>
-<code>SerialClob</code> methods make it possible to get a substring from a
-<code>SerialClob</code> object or to locate the start of a pattern of characters.
-<br>
-
-<h3>5.0 SerialDatalink</h3>
-A serializable mapping in the Java programming language of an SQL DATALINK
-value. A DATALINK value references a file outside of the underlying data source
-that the originating data source manages. <br>
-<br>
-<code>RowSet</code> implementations can use the method <code>RowSet.getURL()</code> to retrieve
-a <code>java.net.URL</code> object, which can be used to manipulate the external data.
-<br>
-<br>
- <code> java.net.URL url = rowset.getURL(1);</code><br>
-
-<h3>6.0 SerialJavaObject</h3>
-A serializable mapping in the Java programming language of an SQL JAVA_OBJECT
-value. Assuming the Java object instance implements the Serializable interface,
-this simply wraps the serialization process. <br>
-<br>
-If however, the serialization is not possible in the case where the Java
-object is not immediately serializable, this class will attempt to serialize
-all non static members to permit the object instance state to be serialized.
-Static or transient fields cannot be serialized and attempting to do so
-will result in a <code>SerialException</code> being thrown. <br>
-
-<h3>7.0 SerialRef</h3>
-A serializable mapping between the SQL REF type and the Java programming
-language. <br>
-<br>
-The <code>SerialRef</code> class provides a constructor for creating a <code>SerialRef</code>
-instance from a <code>Ref</code> type and provides methods for getting
-and setting the <code>Ref</code> object type. <br>
-
-<h3>8.0 SerialStruct</h3>
-A serializable mapping in the Java programming language of an SQL structured
-type. Each attribute that is not already serializable is mapped to a serializable
-form, and if an attribute is itself a structured type, each of its attributes
-that is not already serializable is mapped to a serializable form. <br>
-<br>
-In addition, if a <code>Map</code> object is passed to one of the constructors or
-to the method <code>getAttributes</code>, the structured type is custom mapped
-according to the mapping specified in the <code>Map</code> object.
-<br>
-The <code>SerialStruct</code> class provides a constructor for creating an
-instance from a <code>Struct</code> object, a method for retrieving the SQL
-type name of the SQL structured type in the database, and methods for retrieving
-its attribute values. <br>
-
-<h3>9.0 SQLInputImpl</h3>
- An input stream used for custom mapping user-defined types (UDTs). An
- <code>SQLInputImpl</code> object is an input stream that contains a stream of
- values that are
-the attributes of a UDT. This class is used by the driver behind the scenes
-when the method <code>getObject</code> is called on an SQL structured or distinct
-type that has a custom mapping; a programmer never invokes <code>SQLInputImpl</code>
-methods directly. <br>
- <br>
-The <code>SQLInputImpl</code> class provides a set of reader methods
-analogous to the <code>ResultSet</code> getter methods. These methods make it
-possible to read the values in an <code>SQLInputImpl</code> object. The method
-<code>wasNull</code> is used to determine whether the last value read was SQL NULL.
-<br>
- <br>
-When a constructor or getter method that takes a <code>Map</code> object is called,
-the JDBC driver calls the method
-<code>SQLData.getSQLType</code> to determine the SQL type of the UDT being custom
-mapped. The driver creates an instance of <code>SQLInputImpl</code>, populating it with
-the attributes of the UDT. The driver then passes the input stream to the
-method <code>SQLData.readSQL</code>, which in turn calls the <code>SQLInputImpl</code>
-methods to read the attributes from the input stream. <br>
-
-<h3>10.0 SQLOutputImpl</h3>
- The output stream for writing the attributes of a custom mapped user-defined
- type (UDT) back to the database. The driver uses this interface internally,
- and its methods are never directly invoked by an application programmer.
-<br>
- <br>
-When an application calls the method <code>PreparedStatement.setObject</code>, the
-driver checks to see whether the value to be written is a UDT with a custom
-mapping. If it is, there will be an entry in a type map containing the Class
-object for the class that implements <code>SQLData</code> for this UDT. If the
-value to be written is an instance of <code>SQLData</code>, the driver will
-create an instance of <code>SQLOutputImpl</code> and pass it to the method
-<code>SQLData.writeSQL</code>.
-The method <code>writeSQL</code> in turn calls the appropriate <code>SQLOutputImpl</code>
-writer methods to write data from the <code>SQLData</code> object to the
-<code>SQLOutputImpl</code>
-output stream as the representation of an SQL user-defined type.
-
-<h3>Custom Mapping</h3>
-The JDBC API provides mechanisms for mapping an SQL structured type or DISTINCT
-type to the Java programming language. Typically, a structured type is mapped
-to a class, and its attributes are mapped to fields in the class.
-(A DISTINCT type can thought of as having one attribute.) However, there are
-many other possibilities, and there may be any number of different mappings.
-<P>
-A programmer defines the mapping by implementing the interface <code>SQLData</code>.
-For example, if an SQL structured type named AUTHORS has the attributes NAME,
-TITLE, and PUBLISHER, it could be mapped to a Java class named Authors. The
-Authors class could have the fields name, title, and publisher, to which the
-attributes of AUTHORS are mapped. In such a case, the implementation of
-<code>SQLData</code> could look like the following:
-<PRE>
- public class Authors implements SQLData {
- public String name;
- public String title;
- public String publisher;
-
- private String sql_type;
- public String getSQLTypeName() {
- return sql_type;
- }
-
- public void readSQL(SQLInput stream, String type)
- throws SQLException {
- sql_type = type;
- name = stream.readString();
- title = stream.readString();
- publisher = stream.readString();
- }
-
- public void writeSQL(SQLOutput stream) throws SQLException {
- stream.writeString(name);
- stream.writeString(title);
- stream.writeString(publisher);
- }
- }
-</PRE>
-
-A <code>java.util.Map</code> object is used to associate the SQL structured
-type with its mapping to the class <code>Authors</code>. The following code fragment shows
-how a <code>Map</code> object might be created and given an entry associating
-<code>AUTHORS</code> and <code>Authors</code>.
-<PRE>
- java.util.Map map = new java.util.HashMap();
- map.put("SCHEMA_NAME.AUTHORS", Class.forName("Authors");
-</PRE>
-
-The <code>Map</code> object <i>map</i> now contains an entry with the
-fully qualified name of the SQL structured type and the <code>Class</code>
- object for the class <code>Authors</code>. It can be passed to a method
-to tell the driver how to map <code>AUTHORS</code> to <code>Authors</code>.
-<P>
-For a disconnected <code>RowSet</code> object, custom mapping can be done
-only when a <code>Map</code> object is passed to the method or constructor
-that will be doing the custom mapping. The situation is different for
-connected <code>RowSet</code> objects because they maintain a connection
-with the data source. A method that does custom mapping and is called by
-a disconnected <code>RowSet</code> object may use the <code>Map</code>
-object that is associated with the <code>Connection</code> object being
-used. So, in other words, if no map is specified, the connection's type
-map can be used by default.
-
-<br>
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.sql/share/classes/java/sql/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,343 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+/**
+ *
+ * Provides the API for accessing and processing data stored in a
+ * data source (usually a relational database) using the
+ * Java™ programming language.
+ * This API includes a framework whereby different
+ * drivers can be installed dynamically to access different data sources.
+ * Although the JDBC™ API is mainly geared
+ * to passing SQL statements to a database, it provides for reading and
+ * writing data from any data source with a tabular format.
+ * The reader/writer facility, available through the
+ * <code>javax.sql.RowSet</code> group of interfaces, can be customized to
+ * use and update data from a spread sheet, flat file, or any other tabular
+ * data source.
+ *
+ * <h2>What the JDBC™ 4.3 API Includes</h2>
+ * The JDBC™ 4.3 API includes both
+ * the <code>java.sql</code> package, referred to as the JDBC core API,
+ * and the <code>javax.sql</code> package, referred to as the JDBC Optional
+ * Package API. This complete JDBC API
+ * is included in the Java™ Standard Edition (Java SE™), version 7.
+ * The <code>javax.sql</code> package extends the functionality of the JDBC API
+ * from a client-side API to a server-side API, and it is an essential part
+ * of the Java™ Enterprise Edition
+ * (Java EE™) technology.
+ *
+ * <h2>Versions</h2>
+ * The JDBC 4.3 API incorporates all of the previous JDBC API versions:
+ * <UL>
+ * <LI> The JDBC 4.2 API</li>
+ * <LI> The JDBC 4.1 API</li>
+ * <LI> The JDBC 4.0 API</li>
+ * <LI> The JDBC 3.0 API</li>
+ * <LI> The JDBC 2.1 core API</li>
+ * <LI> The JDBC 2.0 Optional Package API<br>
+ * (Note that the JDBC 2.1 core API and the JDBC 2.0 Optional Package
+ * API together are referred to as the JDBC 2.0 API.)</li>
+ * <LI> The JDBC 1.2 API</li>
+ * <LI> The JDBC 1.0 API</li>
+ * </UL>
+ * <P>
+ * Classes, interfaces, methods, fields, constructors, and exceptions
+ * have the following "since" tags that indicate when they were introduced
+ * into the Java platform. When these "since" tags are used in
+ * Javadoc™ comments for the JDBC API,
+ * they indicate the following:
+ * <UL>
+ * <LI>Since 9 -- new in the JDBC 4.3 API and part of the Java SE platform,
+ * version 9</li>
+ * <LI>Since 1.8 -- new in the JDBC 4.2 API and part of the Java SE platform,
+ * version 8</li>
+ * <LI>Since 1.7 -- new in the JDBC 4.1 API and part of the Java SE platform,
+ * version 7</li>
+ * <LI>Since 1.6 -- new in the JDBC 4.0 API and part of the Java SE platform,
+ * version 6</li>
+ * <LI>Since 1.4 -- new in the JDBC 3.0 API and part of the J2SE platform,
+ * version 1.4</li>
+ * <LI>Since 1.2 -- new in the JDBC 2.0 API and part of the J2SE platform,
+ * version 1.2</li>
+ * <LI>Since 1.1 or no "since" tag -- in the original JDBC 1.0 API and part of
+ * the JDK™, version 1.1</li>
+ * </UL>
+ * <P>
+ * <b>NOTE:</b> Many of the new features are optional; consequently, there is
+ * some variation in drivers and the features they support. Always
+ * check your driver's documentation to see whether it supports a feature before
+ * you try to use it.
+ * <P>
+ * <b>NOTE:</b> The class <code>SQLPermission</code> was added in the
+ * Java™ 2 SDK, Standard Edition,
+ * version 1.3 release. This class is used to prevent unauthorized
+ * access to the logging stream associated with the <code>DriverManager</code>,
+ * which may contain information such as table names, column data, and so on.
+ *
+ * <h2>What the <code>java.sql</code> Package Contains</h2>
+ * The <code>java.sql</code> package contains API for the following:
+ * <UL>
+ * <LI>Making a connection with a database via the <code>DriverManager</code> facility
+ * <UL>
+ * <LI><code>DriverManager</code> class -- makes a connection with a driver
+ * <LI><code>SQLPermission</code> class -- provides permission when code
+ * running within a Security Manager, such as an applet,
+ * attempts to set up a logging stream through the
+ * <code>DriverManager</code>
+ * <LI><code>Driver</code> interface -- provides the API for registering
+ * and connecting drivers based on JDBC technology ("JDBC drivers");
+ * generally used only by the <code>DriverManager</code> class
+ * <LI><code>DriverPropertyInfo</code> class -- provides properties for a
+ * JDBC driver; not used by the general user
+ * </UL>
+ * <LI>Sending SQL statements to a database
+ * <UL>
+ * <LI><code>Statement</code> -- used to send basic SQL statements
+ * <LI><code>PreparedStatement</code> -- used to send prepared statements or
+ * basic SQL statements (derived from <code>Statement</code>)
+ * <LI><code>CallableStatement</code> -- used to call database stored
+ * procedures (derived from <code>PreparedStatement</code>)
+ * <LI><code>Connection</code> interface -- provides methods for creating
+ * statements and managing connections and their properties
+ * <LI><code>Savepoint</code> -- provides savepoints in a transaction
+ *
+ * </UL>
+ * <LI>Retrieving and updating the results of a query
+ * <UL>
+ * <LI><code>ResultSet</code> interface
+ * </UL>
+ * <LI>Standard mappings for SQL types to classes and interfaces in the
+ * Java programming language
+ * <UL>
+ * <LI><code>Array</code> interface -- mapping for SQL <code>ARRAY</code>
+ * <LI><code>Blob</code> interface -- mapping for SQL <code>BLOB</code>
+ * <LI><code>Clob</code> interface -- mapping for SQL <code>CLOB</code>
+ * <LI><code>Date</code> class -- mapping for SQL <code>DATE</code>
+ * <LI><code>NClob</code> interface -- mapping for SQL <code>NCLOB</code>
+ * <LI><code>Ref</code> interface -- mapping for SQL <code>REF</code>
+ * <LI><code>RowId</code> interface -- mapping for SQL <code>ROWID</code>
+ * <LI><code>Struct</code> interface -- mapping for SQL <code>STRUCT</code>
+ * <LI><code>SQLXML</code> interface -- mapping for SQL <code>XML</code>
+ * <LI><code>Time</code> class -- mapping for SQL <code>TIME</code>
+ * <LI><code>Timestamp</code> class -- mapping for SQL <code>TIMESTAMP</code>
+ * <LI><code>Types</code> class -- provides constants for SQL types
+ * </UL>
+ * <LI>Custom mapping an SQL user-defined type (UDT) to a class in the
+ * Java programming language
+ * <UL>
+ * <LI><code>SQLData</code> interface -- specifies the mapping of
+ * a UDT to an instance of this class
+ * <LI><code>SQLInput</code> interface -- provides methods for reading
+ * UDT attributes from a stream
+ * <LI><code>SQLOutput</code> interface -- provides methods for writing
+ * UDT attributes back to a stream
+ * </UL>
+ * <LI>Metadata
+ * <UL>
+ * <LI><code>DatabaseMetaData</code> interface -- provides information
+ * about the database
+ * <LI><code>ResultSetMetaData</code> interface -- provides information
+ * about the columns of a <code>ResultSet</code> object
+ * <LI><code>ParameterMetaData</code> interface -- provides information
+ * about the parameters to <code>PreparedStatement</code> commands
+ * </UL>
+ * <LI>Exceptions
+ * <UL>
+ * <LI><code>SQLException</code> -- thrown by most methods when there
+ * is a problem accessing data and by some methods for other reasons
+ * <LI><code>SQLWarning</code> -- thrown to indicate a warning
+ * <LI><code>DataTruncation</code> -- thrown to indicate that data may have
+ * been truncated
+ * <LI><code>BatchUpdateException</code> -- thrown to indicate that not all
+ * commands in a batch update executed successfully
+ * </UL>
+ * </UL>
+ *
+ * <h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.3 API</h3>
+ * <UL>
+ * <LI>Added <code>Sharding</code> support</LI>
+ * <LI>Enhanced <code>Connection</code> to be able to provide hints
+ * to the driver that a request, an independent unit of work,
+ * is beginning or ending</LI>
+ * <LI>Enhanced <code>DatabaseMetaData</code> to determine if Sharding is
+ * supported</LI>
+ * <LI>Added the method <code>drivers</code> to <code>DriverManager</code>
+ * to return a Stream of the currently loaded and
+ * available JDBC drivers</LI>
+ * <LI>Added support to <code>Statement</code> for enquoting literals
+ * and simple identifiers</LI>
+ * <LI>Clarified the Java SE version that methods were deprecated</LI>
+ * </UL>
+ *
+ * <h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.2 API</h3>
+ * <UL>
+ * <LI>Added <code>JDBCType</code> enum and <code>SQLType</code> interface</li>
+ * <LI>Support for <code>REF CURSORS</code> in <code>CallableStatement</code>
+ * </LI>
+ * <LI><code>DatabaseMetaData</code> methods to return maximum Logical LOB size
+ * and if Ref Cursors are supported</LI>
+ * <LI>Added support for large update counts</LI>
+ *
+ * </UL>
+ *
+ * <h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.1 API</h3>
+ * <UL>
+ * <LI>Allow <code>Connection</code>,
+ * <code>ResultSet</code> and <code>Statement</code> objects to be
+ * used with the try-with-resources statement</LI>
+ * <LI>Support added to <code>CallableStatement</code> and
+ * <code>ResultSet</code> to specify the Java type to convert to via the
+ * <code>getObject</code> method</LI>
+ * <LI><code>DatabaseMetaData</code> methods to return PseudoColumns and if a
+ * generated key is always returned</LI>
+ * <LI>Added support to <code>Connection</code> to specify a database schema,
+ * abort and timeout a physical connection.</LI>
+ * <LI>Added support to close a <code>Statement</code> object when its dependent
+ * objects have been closed</LI>
+ * <LI>Support for obtaining the parent logger for a <code>Driver</code>,
+ * <code>DataSource</code>, <code>ConnectionPoolDataSource</code> and
+ * <code>XADataSource</code></LI>
+ *
+ * </UL>
+ * <h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.0 API</h3>
+ * <UL>
+ * <LI>auto java.sql.Driver discovery -- no longer need to load a
+ * <code>java.sql.Driver</code> class via <code>Class.forName</code>
+ * <LI>National Character Set support added
+ * <li>Support added for the SQL:2003 XML data type
+ * <lI>SQLException enhancements -- Added support for cause chaining; New SQLExceptions
+ * added for common SQLState class value codes
+ * <li>Enhanced Blob/Clob functionality -- Support provided to create and free a Blob/Clob instance
+ * as well as additional methods added to improve accessibility
+ * <li>Support added for accessing a SQL ROWID
+ * <li>Support added to allow a JDBC application to access an instance of a JDBC resource
+ * that has been wrapped by a vendor, usually in an application server or connection
+ * pooling environment.
+ * <li>Availability to be notified when a <code>PreparedStatement</code> that is associated
+ * with a <code>PooledConnection</code> has been closed or the driver determines is invalid
+ *
+ *
+ * </UL>
+ *
+ *
+ * <h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 3.0 API</h3>
+ * <UL>
+ * <LI>Pooled statements -- reuse of statements associated with a pooled
+ * connection
+ * <LI>Savepoints -- allow a transaction to be rolled back to a designated
+ * savepoint
+ * <LI>Properties defined for <code>ConnectionPoolDataSource</code> -- specify
+ * how connections are to be pooled
+ * <LI>Metadata for parameters of a <code>PreparedStatement</code> object
+ * <LI>Ability to retrieve values from automatically generated columns
+ * <LI>Ability to have multiple <code>ResultSet</code> objects
+ * returned from <code>CallableStatement</code> objects open at the
+ * same time
+ * <LI>Ability to identify parameters to <code>CallableStatement</code>
+ * objects by name as well as by index
+ * <LI><code>ResultSet</code> holdability -- ability to specify whether cursors
+ * should be held open or closed at the end of a transaction
+ * <LI>Ability to retrieve and update the SQL structured type instance that a
+ * <code>Ref</code> object references
+ * <LI>Ability to programmatically update <code>BLOB</code>,
+ * <code>CLOB</code>, <code>ARRAY</code>, and <code>REF</code> values.
+ * <LI>Addition of the <code>java.sql.Types.DATALINK</code> data type --
+ * allows JDBC drivers access to objects stored outside a data source
+ * <LI>Addition of metadata for retrieving SQL type hierarchies
+ * </UL>
+ *
+ * <h3><code>java.sql</code> Features Introduced in the JDBC 2.1 Core API</h3>
+ * <UL>
+ * <LI>Scrollable result sets--using new methods in the <code>ResultSet</code>
+ * interface that allow the cursor to be moved to a particular row or to a
+ * position relative to its current position
+ * <LI>Batch updates
+ * <LI>Programmatic updates--using <code>ResultSet</code> updater methods
+ * <LI>New data types--interfaces mapping the SQL3 data types
+ * <LI>Custom mapping of user-defined types (UDTs)
+ * <LI>Miscellaneous features, including performance hints, the use of character
+ * streams, full precision for <code>java.math.BigDecimal</code> values,
+ * additional security, and
+ * support for time zones in date, time, and timestamp values.
+ * </UL>
+ *
+ * <h3><code>javax.sql</code> Features Introduced in the JDBC 2.0 Optional
+ * Package API</h3>
+ * <UL>
+ * <LI>The <code>DataSource</code> interface as a means of making a connection. The
+ * Java Naming and Directory Interface™
+ * (JNDI) is used for registering a <code>DataSource</code> object with a
+ * naming service and also for retrieving it.
+ * <LI>Pooled connections -- allowing connections to be used and reused
+ * <LI>Distributed transactions -- allowing a transaction to span diverse
+ * DBMS servers
+ * <LI><code>RowSet</code> technology -- providing a convenient means of
+ * handling and passing data
+ * </UL>
+ *
+ *
+ * <h3>Custom Mapping of UDTs</h3>
+ * A user-defined type (UDT) defined in SQL can be mapped to a class in the Java
+ * programming language. An SQL structured type or an SQL <code>DISTINCT</code>
+ * type are the UDTs that may be custom mapped. The following three
+ * steps set up a custom mapping:
+ * <ol>
+ * <li>Defining the SQL structured type or <code>DISTINCT</code> type in SQL
+ * <li>Defining the class in the Java programming language to which the
+ * SQL UDT will be mapped. This class must implement the
+ * <code>SQLData</code> interface.
+ * <li>Making an entry in a <code>Connection</code> object's type map
+ * that contains two things:
+ * <ul>
+ * <li>the fully-qualified SQL name of the UDT
+ * <li>the <code>Class</code> object for the class that implements the
+ * <code>SQLData</code> interface
+ * </ul>
+ * </ol>
+ * <p>
+ * When these are in place for a UDT, calling the methods
+ * <code>ResultSet.getObject</code> or <code>CallableStatement.getObject</code>
+ * on that UDT will automatically retrieve the custom mapping for it. Also, the
+ * <code>PreparedStatement.setObject</code> method will automatically map the
+ * object back to its SQL type to store it in the data source.
+ *
+ * <h2>Package Specification</h2>
+ *
+ * <ul>
+ * <li><a href="https://jcp.org/en/jsr/detail?id=221">JDBC 4.3 Specification</a>
+ * </ul>
+ *
+ * <h2>Related Documentation</h2>
+ *
+ * <ul>
+ * <li><a href="http://docs.oracle.com/javase/tutorial/jdbc/basics/index.html">
+ * Lesson:JDBC Basics(The Javaxx Tutorials > JDBC™ Database Access)</a>
+ *
+ * <li><a href="http://www.oracle.com/technetwork/java/index-142838.html">
+ * <i>JDBC™ API Tutorial and Reference, Third Edition</i></a>
+ * </ul>
+ */
+package java.sql;
--- a/src/java.sql/share/classes/java/sql/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,351 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
- Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
-DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
-This code is free software; you can redistribute it and/or modify it
-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.
--->
-
-</head>
-
-
-
-<body bgcolor="white">
-
-Provides the API for accessing and processing data stored in a
-data source (usually a relational database) using the
-Java™ programming language.
-This API includes a framework whereby different
-drivers can be installed dynamically to access different data sources.
-Although the JDBC™ API is mainly geared
-to passing SQL statements to a database, it provides for reading and
-writing data from any data source with a tabular format.
-The reader/writer facility, available through the
-<code>javax.sql.RowSet</code> group of interfaces, can be customized to
-use and update data from a spread sheet, flat file, or any other tabular
-data source.
-
-<h2>What the JDBC™ 4.3 API Includes</h2>
-The JDBC™ 4.3 API includes both
-the <code>java.sql</code> package, referred to as the JDBC core API,
-and the <code>javax.sql</code> package, referred to as the JDBC Optional
-Package API. This complete JDBC API
-is included in the Java™ Standard Edition (Java SE™), version 7.
-The <code>javax.sql</code> package extends the functionality of the JDBC API
-from a client-side API to a server-side API, and it is an essential part
-of the Java™ Enterprise Edition
-(Java EE™) technology.
-
-<h2>Versions</h2>
-The JDBC 4.3 API incorporates all of the previous JDBC API versions:
-<UL>
- <LI> The JDBC 4.2 API</li>
- <LI> The JDBC 4.1 API</li>
- <LI> The JDBC 4.0 API</li>
- <LI> The JDBC 3.0 API</li>
- <LI> The JDBC 2.1 core API</li>
- <LI> The JDBC 2.0 Optional Package API<br>
- (Note that the JDBC 2.1 core API and the JDBC 2.0 Optional Package
- API together are referred to as the JDBC 2.0 API.)</li>
- <LI> The JDBC 1.2 API</li>
- <LI> The JDBC 1.0 API</li>
-</UL>
-<P>
-Classes, interfaces, methods, fields, constructors, and exceptions
-have the following "since" tags that indicate when they were introduced
-into the Java platform. When these "since" tags are used in
-Javadoc™ comments for the JDBC API,
-they indicate the following:
-<UL>
- <LI>Since 9 -- new in the JDBC 4.3 API and part of the Java SE platform,
- version 9</li>
- <LI>Since 1.8 -- new in the JDBC 4.2 API and part of the Java SE platform,
- version 8</li>
- <LI>Since 1.7 -- new in the JDBC 4.1 API and part of the Java SE platform,
- version 7</li>
-<LI>Since 1.6 -- new in the JDBC 4.0 API and part of the Java SE platform,
- version 6</li>
- <LI>Since 1.4 -- new in the JDBC 3.0 API and part of the J2SE platform,
- version 1.4</li>
- <LI>Since 1.2 -- new in the JDBC 2.0 API and part of the J2SE platform,
- version 1.2</li>
- <LI>Since 1.1 or no "since" tag -- in the original JDBC 1.0 API and part of
- the JDK™, version 1.1</li>
-</UL>
-<P>
-<b>NOTE:</b> Many of the new features are optional; consequently, there is
-some variation in drivers and the features they support. Always
-check your driver's documentation to see whether it supports a feature before
-you try to use it.
-<P>
-<b>NOTE:</b> The class <code>SQLPermission</code> was added in the
-Java™ 2 SDK, Standard Edition,
-version 1.3 release. This class is used to prevent unauthorized
-access to the logging stream associated with the <code>DriverManager</code>,
-which may contain information such as table names, column data, and so on.
-
-<h2>What the <code>java.sql</code> Package Contains</h2>
-The <code>java.sql</code> package contains API for the following:
-<UL>
- <LI>Making a connection with a database via the <code>DriverManager</code> facility
- <UL>
- <LI><code>DriverManager</code> class -- makes a connection with a driver
- <LI><code>SQLPermission</code> class -- provides permission when code
- running within a Security Manager, such as an applet,
- attempts to set up a logging stream through the
- <code>DriverManager</code>
- <LI><code>Driver</code> interface -- provides the API for registering
- and connecting drivers based on JDBC technology ("JDBC drivers");
- generally used only by the <code>DriverManager</code> class
- <LI><code>DriverPropertyInfo</code> class -- provides properties for a
- JDBC driver; not used by the general user
- </UL>
- <LI>Sending SQL statements to a database
- <UL>
- <LI><code>Statement</code> -- used to send basic SQL statements
- <LI><code>PreparedStatement</code> -- used to send prepared statements or
- basic SQL statements (derived from <code>Statement</code>)
- <LI><code>CallableStatement</code> -- used to call database stored
- procedures (derived from <code>PreparedStatement</code>)
- <LI><code>Connection</code> interface -- provides methods for creating
- statements and managing connections and their properties
- <LI><code>Savepoint</code> -- provides savepoints in a transaction
-
- </UL>
- <LI>Retrieving and updating the results of a query
- <UL>
- <LI><code>ResultSet</code> interface
- </UL>
- <LI>Standard mappings for SQL types to classes and interfaces in the
- Java programming language
- <UL>
- <LI><code>Array</code> interface -- mapping for SQL <code>ARRAY</code>
- <LI><code>Blob</code> interface -- mapping for SQL <code>BLOB</code>
- <LI><code>Clob</code> interface -- mapping for SQL <code>CLOB</code>
- <LI><code>Date</code> class -- mapping for SQL <code>DATE</code>
- <LI><code>NClob</code> interface -- mapping for SQL <code>NCLOB</code>
- <LI><code>Ref</code> interface -- mapping for SQL <code>REF</code>
- <LI><code>RowId</code> interface -- mapping for SQL <code>ROWID</code>
- <LI><code>Struct</code> interface -- mapping for SQL <code>STRUCT</code>
- <LI><code>SQLXML</code> interface -- mapping for SQL <code>XML</code>
- <LI><code>Time</code> class -- mapping for SQL <code>TIME</code>
- <LI><code>Timestamp</code> class -- mapping for SQL <code>TIMESTAMP</code>
- <LI><code>Types</code> class -- provides constants for SQL types
- </UL>
- <LI>Custom mapping an SQL user-defined type (UDT) to a class in the
- Java programming language
- <UL>
- <LI><code>SQLData</code> interface -- specifies the mapping of
- a UDT to an instance of this class
- <LI><code>SQLInput</code> interface -- provides methods for reading
- UDT attributes from a stream
- <LI><code>SQLOutput</code> interface -- provides methods for writing
- UDT attributes back to a stream
- </UL>
- <LI>Metadata
- <UL>
- <LI><code>DatabaseMetaData</code> interface -- provides information
- about the database
- <LI><code>ResultSetMetaData</code> interface -- provides information
- about the columns of a <code>ResultSet</code> object
- <LI><code>ParameterMetaData</code> interface -- provides information
- about the parameters to <code>PreparedStatement</code> commands
- </UL>
- <LI>Exceptions
- <UL>
- <LI><code>SQLException</code> -- thrown by most methods when there
- is a problem accessing data and by some methods for other reasons
- <LI><code>SQLWarning</code> -- thrown to indicate a warning
- <LI><code>DataTruncation</code> -- thrown to indicate that data may have
- been truncated
- <LI><code>BatchUpdateException</code> -- thrown to indicate that not all
- commands in a batch update executed successfully
- </UL>
-</UL>
-
- <h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.3 API</h3>
-<UL>
- <LI>Added <code>Sharding</code> support</LI>
- <LI>Enhanced <code>Connection</code> to be able to provide hints
- to the driver that a request, an independent unit of work,
- is beginning or ending</LI>
- <LI>Enhanced <code>DatabaseMetaData</code> to determine if Sharding is
- supported</LI>
- <LI>Added the method <code>drivers</code> to <code>DriverManager</code>
- to return a Stream of the currently loaded and
- available JDBC drivers</LI>
- <LI>Added support to <code>Statement</code> for enquoting literals
- and simple identifiers</LI>
- <LI>Clarified the Java SE version that methods were deprecated</LI>
-</UL>
-
- <h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.2 API</h3>
-<UL>
- <LI>Added <code>JDBCType</code> enum and <code>SQLType</code> interface</li>
- <LI>Support for <code>REF CURSORS</code> in <code>CallableStatement</code>
- </LI>
- <LI><code>DatabaseMetaData</code> methods to return maximum Logical LOB size
- and if Ref Cursors are supported</LI>
- <LI>Added support for large update counts</LI>
-
-</UL>
-
- <h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.1 API</h3>
-<UL>
- <LI>Allow <code>Connection</code>,
- <code>ResultSet</code> and <code>Statement</code> objects to be
- used with the try-with-resources statement</LI>
- <LI>Support added to <code>CallableStatement</code> and
- <code>ResultSet</code> to specify the Java type to convert to via the
- <code>getObject</code> method</LI>
- <LI><code>DatabaseMetaData</code> methods to return PseudoColumns and if a
- generated key is always returned</LI>
- <LI>Added support to <code>Connection</code> to specify a database schema,
- abort and timeout a physical connection.</LI>
- <LI>Added support to close a <code>Statement</code> object when its dependent
- objects have been closed</LI>
- <LI>Support for obtaining the parent logger for a <code>Driver</code>,
- <code>DataSource</code>, <code>ConnectionPoolDataSource</code> and
- <code>XADataSource</code></LI>
-
-</UL>
-<h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.0 API</h3>
-<UL>
- <LI>auto java.sql.Driver discovery -- no longer need to load a
-<code>java.sql.Driver</code> class via <code>Class.forName</code>
- <LI>National Character Set support added
- <li>Support added for the SQL:2003 XML data type
- <lI>SQLException enhancements -- Added support for cause chaining; New SQLExceptions
- added for common SQLState class value codes
- <li>Enhanced Blob/Clob functionality -- Support provided to create and free a Blob/Clob instance
- as well as additional methods added to improve accessibility
- <li>Support added for accessing a SQL ROWID
- <li>Support added to allow a JDBC application to access an instance of a JDBC resource
- that has been wrapped by a vendor, usually in an application server or connection
- pooling environment.
- <li>Availability to be notified when a <code>PreparedStatement</code> that is associated
- with a <code>PooledConnection</code> has been closed or the driver determines is invalid
-
-
-</UL>
-
-
-<h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 3.0 API</h3>
-<UL>
- <LI>Pooled statements -- reuse of statements associated with a pooled
- connection
- <LI>Savepoints -- allow a transaction to be rolled back to a designated
- savepoint
- <LI>Properties defined for <code>ConnectionPoolDataSource</code> -- specify
- how connections are to be pooled
- <LI>Metadata for parameters of a <code>PreparedStatement</code> object
- <LI>Ability to retrieve values from automatically generated columns
- <LI>Ability to have multiple <code>ResultSet</code> objects
- returned from <code>CallableStatement</code> objects open at the
- same time
- <LI>Ability to identify parameters to <code>CallableStatement</code>
- objects by name as well as by index
- <LI><code>ResultSet</code> holdability -- ability to specify whether cursors
- should be held open or closed at the end of a transaction
- <LI>Ability to retrieve and update the SQL structured type instance that a
- <code>Ref</code> object references
- <LI>Ability to programmatically update <code>BLOB</code>,
- <code>CLOB</code>, <code>ARRAY</code>, and <code>REF</code> values.
- <LI>Addition of the <code>java.sql.Types.DATALINK</code> data type --
- allows JDBC drivers access to objects stored outside a data source
- <LI>Addition of metadata for retrieving SQL type hierarchies
-</UL>
-
-<h3><code>java.sql</code> Features Introduced in the JDBC 2.1 Core API</h3>
-<UL>
- <LI>Scrollable result sets--using new methods in the <code>ResultSet</code>
- interface that allow the cursor to be moved to a particular row or to a
- position relative to its current position
- <LI>Batch updates
- <LI>Programmatic updates--using <code>ResultSet</code> updater methods
- <LI>New data types--interfaces mapping the SQL3 data types
- <LI>Custom mapping of user-defined types (UDTs)
- <LI>Miscellaneous features, including performance hints, the use of character
- streams, full precision for <code>java.math.BigDecimal</code> values,
- additional security, and
- support for time zones in date, time, and timestamp values.
-</UL>
-
-<h3><code>javax.sql</code> Features Introduced in the JDBC 2.0 Optional
-Package API</h3>
-<UL>
- <LI>The <code>DataSource</code> interface as a means of making a connection. The
- Java Naming and Directory Interface™
- (JNDI) is used for registering a <code>DataSource</code> object with a
- naming service and also for retrieving it.
- <LI>Pooled connections -- allowing connections to be used and reused
- <LI>Distributed transactions -- allowing a transaction to span diverse
- DBMS servers
- <LI><code>RowSet</code> technology -- providing a convenient means of
- handling and passing data
-</UL>
-
-
-<h3>Custom Mapping of UDTs</h3>
-A user-defined type (UDT) defined in SQL can be mapped to a class in the Java
-programming language. An SQL structured type or an SQL <code>DISTINCT</code>
-type are the UDTs that may be custom mapped. The following three
-steps set up a custom mapping:
-<ol>
- <li>Defining the SQL structured type or <code>DISTINCT</code> type in SQL
- <li>Defining the class in the Java programming language to which the
- SQL UDT will be mapped. This class must implement the
- <code>SQLData</code> interface.
- <li>Making an entry in a <code>Connection</code> object's type map
- that contains two things:
- <ul>
- <li>the fully-qualified SQL name of the UDT
- <li>the <code>Class</code> object for the class that implements the
- <code>SQLData</code> interface
- </ul>
-</ol>
-<p>
-When these are in place for a UDT, calling the methods
-<code>ResultSet.getObject</code> or <code>CallableStatement.getObject</code>
-on that UDT will automatically retrieve the custom mapping for it. Also, the
-<code>PreparedStatement.setObject</code> method will automatically map the
-object back to its SQL type to store it in the data source.
-
-<h2>Package Specification</h2>
-
-<ul>
- <li><a href="https://jcp.org/en/jsr/detail?id=221">JDBC 4.3 Specification</a>
-</ul>
-
-<h2>Related Documentation</h2>
-
-<ul>
- <li><a href="http://docs.oracle.com/javase/tutorial/jdbc/basics/index.html">
- Lesson:JDBC Basics(The Javaxx Tutorials > JDBC™ Database Access)</a>
-
- <li><a href="http://www.oracle.com/technetwork/java/index-142838.html">
- <i>JDBC™ API Tutorial and Reference, Third Edition</i></a>
-</ul>
-
-</body>
-</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.sql/share/classes/javax/sql/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,294 @@
+/**
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * <p>
+ * 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.
+ * <p>
+ * 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).
+ * <p>
+ * 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.
+ * <p>
+ * 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.
+ */
+
+/**
+ * Provides the API for server side data source access and processing from
+ * the Java™ programming language.
+ * This package supplements the <code>java.sql</code>
+ * package and, as of the version 1.4 release, is included in the
+ * Java Platform, Standard Edition (Java SE™).
+ * It remains an essential part of the Java Platform, Enterprise Edition
+ * (Java EE™).
+ * <p>
+ * The <code>javax.sql</code> package provides for the following:
+ * <OL>
+ * <LI>The <code>DataSource</code> interface as an alternative to the
+ * <code>DriverManager</code> for establishing a
+ * connection with a data source
+ * <LI>Connection pooling and Statement pooling
+ * <LI>Distributed transactions
+ * <LI>Rowsets
+ * </OL>
+ * <p>
+ * Applications use the <code>DataSource</code> and <code>RowSet</code>
+ * APIs directly, but the connection pooling and distributed transaction
+ * APIs are used internally by the middle-tier infrastructure.
+ *
+ * <H2>Using a <code>DataSource</code> Object to Make a Connection</H2>
+ * <p>
+ * The <code>javax.sql</code> package provides the preferred
+ * way to make a connection with a data source. The <code>DriverManager</code>
+ * class, the original mechanism, is still valid, and code using it will
+ * continue to run. However, the newer <code>DataSource</code> mechanism
+ * is preferred because it offers many advantages over the
+ * <code>DriverManager</code> mechanism.
+ * <p>
+ * These are the main advantages of using a <code>DataSource</code> object to
+ * make a connection:
+ * <UL>
+ *
+ * <LI>Changes can be made to a data source's properties, which means
+ * that it is not necessary to make changes in application code when
+ * something about the data source or driver changes.
+ * <LI>Connection and Statement pooling and distributed transactions are available
+ * through a <code>DataSource</code> object that is
+ * implemented to work with the middle-tier infrastructure.
+ * Connections made through the <code>DriverManager</code>
+ * do not have connection and statement pooling or distributed transaction
+ * capabilities.
+ * </UL>
+ * <p>
+ * Driver vendors provide <code>DataSource</code> implementations. A
+ * particular <code>DataSource</code> object represents a particular
+ * physical data source, and each connection the <code>DataSource</code> object
+ * creates is a connection to that physical data source.
+ * <p>
+ * A logical name for the data source is registered with a naming service that
+ * uses the Java Naming and Directory Interface™
+ * (JNDI) API, usually by a system administrator or someone performing the
+ * duties of a system administrator. An application can retrieve the
+ * <code>DataSource</code> object it wants by doing a lookup on the logical
+ * name that has been registered for it. The application can then use the
+ * <code>DataSource</code> object to create a connection to the physical data
+ * source it represents.
+ * <p>
+ * A <code>DataSource</code> object can be implemented to work with the
+ * middle tier infrastructure so that the connections it produces will be
+ * pooled for reuse. An application that uses such a <code>DataSource</code>
+ * implementation will automatically get a connection that participates in
+ * connection pooling.
+ * A <code>DataSource</code> object can also be implemented to work with the
+ * middle tier infrastructure so that the connections it produces can be
+ * used for distributed transactions without any special coding.
+ *
+ * <H2>Connection Pooling and Statement Pooling</H2>
+ * <p>
+ * Connections made via a <code>DataSource</code>
+ * object that is implemented to work with a middle tier connection pool manager
+ * will participate in connection pooling. This can improve performance
+ * dramatically because creating new connections is very expensive.
+ * Connection pooling allows a connection to be used and reused,
+ * thus cutting down substantially on the number of new connections
+ * that need to be created.
+ * <p>
+ * Connection pooling is totally transparent. It is done automatically
+ * in the middle tier of a Java EE configuration, so from an application's
+ * viewpoint, no change in code is required. An application simply uses
+ * the <code>DataSource.getConnection</code> method to get the pooled
+ * connection and uses it the same way it uses any <code>Connection</code>
+ * object.
+ * <p>
+ * The classes and interfaces used for connection pooling are:
+ * <UL>
+ * <LI><code>ConnectionPoolDataSource</code>
+ * <LI><code>PooledConnection</code>
+ * <LI><code>ConnectionEvent</code>
+ * <LI><code>ConnectionEventListener</code>
+ * <LI><code>StatementEvent</code>
+ * <LI><code>StatementEventListener</code>
+ * </UL>
+ * The connection pool manager, a facility in the middle tier of
+ * a three-tier architecture, uses these classes and interfaces
+ * behind the scenes. When a <code>ConnectionPoolDataSource</code> object
+ * is called on to create a <code>PooledConnection</code> object, the
+ * connection pool manager will register as a <code>ConnectionEventListener</code>
+ * object with the new <code>PooledConnection</code> object. When the connection
+ * is closed or there is an error, the connection pool manager (being a listener)
+ * gets a notification that includes a <code>ConnectionEvent</code> object.
+ * <p>
+ * If the connection pool manager supports <code>Statement</code> pooling, for
+ * <code>PreparedStatements</code>, which can be determined by invoking the method
+ * <code>DatabaseMetaData.supportsStatementPooling</code>, the
+ * connection pool manager will register as a <code>StatementEventListener</code>
+ * object with the new <code>PooledConnection</code> object. When the
+ * <code>PreparedStatement</code> is closed or there is an error, the connection
+ * pool manager (being a listener)
+ * gets a notification that includes a <code>StatementEvent</code> object.
+ *
+ * <H2>Distributed Transactions</H2>
+ * <p>
+ * As with pooled connections, connections made via a <code>DataSource</code>
+ * object that is implemented to work with the middle tier infrastructure
+ * may participate in distributed transactions. This gives an application
+ * the ability to involve data sources on multiple servers in a single
+ * transaction.
+ * <p>
+ * The classes and interfaces used for distributed transactions are:
+ * <UL>
+ * <LI><code>XADataSource</code>
+ * <LI><code>XAConnection</code>
+ * </UL>
+ * These interfaces are used by the transaction manager; an application does
+ * not use them directly.
+ * <p>
+ * The <code>XAConnection</code> interface is derived from the
+ * <code>PooledConnection</code> interface, so what applies to a pooled connection
+ * also applies to a connection that is part of a distributed transaction.
+ * A transaction manager in the middle tier handles everything transparently.
+ * The only change in application code is that an application cannot do anything
+ * that would interfere with the transaction manager's handling of the transaction.
+ * Specifically, an application cannot call the methods <code>Connection.commit</code>
+ * or <code>Connection.rollback</code>, and it cannot set the connection to be in
+ * auto-commit mode (that is, it cannot call
+ * <code>Connection.setAutoCommit(true)</code>).
+ * <p>
+ * An application does not need to do anything special to participate in a
+ * distributed transaction.
+ * It simply creates connections to the data sources it wants to use via
+ * the <code>DataSource.getConnection</code> method, just as it normally does.
+ * The transaction manager manages the transaction behind the scenes. The
+ * <code>XADataSource</code> interface creates <code>XAConnection</code> objects, and
+ * each <code>XAConnection</code> object creates an <code>XAResource</code> object
+ * that the transaction manager uses to manage the connection.
+ *
+ *
+ * <H2>Rowsets</H2>
+ * The <code>RowSet</code> interface works with various other classes and
+ * interfaces behind the scenes. These can be grouped into three categories.
+ * <OL>
+ * <LI>Event Notification
+ * <UL>
+ * <LI><code>RowSetListener</code><br>
+ * A <code>RowSet</code> object is a JavaBeans™
+ * component because it has properties and participates in the JavaBeans
+ * event notification mechanism. The <code>RowSetListener</code> interface
+ * is implemented by a component that wants to be notified about events that
+ * occur to a particular <code>RowSet</code> object. Such a component registers
+ * itself as a listener with a rowset via the <code>RowSet.addRowSetListener</code>
+ * method.
+ * <p>
+ * When the <code>RowSet</code> object changes one of its rows, changes all of
+ * it rows, or moves its cursor, it also notifies each listener that is registered
+ * with it. The listener reacts by carrying out its implementation of the
+ * notification method called on it.
+ * <LI><code>RowSetEvent</code><br>
+ * As part of its internal notification process, a <code>RowSet</code> object
+ * creates an instance of <code>RowSetEvent</code> and passes it to the listener.
+ * The listener can use this <code>RowSetEvent</code> object to find out which rowset
+ * had the event.
+ * </UL>
+ * <LI>Metadata
+ * <UL>
+ * <LI><code>RowSetMetaData</code><br>
+ * This interface, derived from the
+ * <code>ResultSetMetaData</code> interface, provides information about
+ * the columns in a <code>RowSet</code> object. An application can use
+ * <code>RowSetMetaData</code> methods to find out how many columns the
+ * rowset contains and what kind of data each column can contain.
+ * <p>
+ * The <code>RowSetMetaData</code> interface provides methods for
+ * setting the information about columns, but an application would not
+ * normally use these methods. When an application calls the <code>RowSet</code>
+ * method <code>execute</code>, the <code>RowSet</code> object will contain
+ * a new set of rows, and its <code>RowSetMetaData</code> object will have been
+ * internally updated to contain information about the new columns.
+ * </UL>
+ * <LI>The Reader/Writer Facility<br>
+ * A <code>RowSet</code> object that implements the <code>RowSetInternal</code>
+ * interface can call on the <code>RowSetReader</code> object associated with it
+ * to populate itself with data. It can also call on the <code>RowSetWriter</code>
+ * object associated with it to write any changes to its rows back to the
+ * data source from which it originally got the rows.
+ * A rowset that remains connected to its data source does not need to use a
+ * reader and writer because it can simply operate on the data source directly.
+ *
+ * <UL>
+ * <LI><code>RowSetInternal</code><br>
+ * By implementing the <code>RowSetInternal</code> interface, a
+ * <code>RowSet</code> object gets access to
+ * its internal state and is able to call on its reader and writer. A rowset
+ * keeps track of the values in its current rows and of the values that immediately
+ * preceded the current ones, referred to as the <i>original</i> values. A rowset
+ * also keeps track of (1) the parameters that have been set for its command and
+ * (2) the connection that was passed to it, if any. A rowset uses the
+ * <code>RowSetInternal</code> methods behind the scenes to get access to
+ * this information. An application does not normally invoke these methods directly.
+ *
+ * <LI><code>RowSetReader</code><br>
+ * A disconnected <code>RowSet</code> object that has implemented the
+ * <code>RowSetInternal</code> interface can call on its reader (the
+ * <code>RowSetReader</code> object associated with it) to populate it with
+ * data. When an application calls the <code>RowSet.execute</code> method,
+ * that method calls on the rowset's reader to do much of the work. Implementations
+ * can vary widely, but generally a reader makes a connection to the data source,
+ * reads data from the data source and populates the rowset with it, and closes
+ * the connection. A reader may also update the <code>RowSetMetaData</code> object
+ * for its rowset. The rowset's internal state is also updated, either by the
+ * reader or directly by the method <code>RowSet.execute</code>.
+ *
+ *
+ * <LI><code>RowSetWriter</code><br>
+ * A disconnected <code>RowSet</code> object that has implemented the
+ * <code>RowSetInternal</code> interface can call on its writer (the
+ * <code>RowSetWriter</code> object associated with it) to write changes
+ * back to the underlying data source. Implementations may vary widely, but
+ * generally, a writer will do the following:
+ *
+ * <UL>
+ * <LI>Make a connection to the data source
+ * <LI>Check to see whether there is a conflict, that is, whether
+ * a value that has been changed in the rowset has also been changed
+ * in the data source
+ * <LI>Write the new values to the data source if there is no conflict
+ * <LI>Close the connection
+ * </UL>
+ *
+ *
+ * </UL>
+ * </OL>
+ * <p>
+ * The <code>RowSet</code> interface may be implemented in any number of
+ * ways, and anyone may write an implementation. Developers are encouraged
+ * to use their imaginations in coming up with new ways to use rowsets.
+ *
+ *
+ * <h2>Package Specification</h2>
+ *
+ * <ul>
+ * <li><a href="https://jcp.org/en/jsr/detail?id=221">JDBC 4.3 Specification</a>
+ * </ul>
+ *
+ * <h2>Related Documentation</h2>
+ * <p>
+ * The Java Series book published by Addison-Wesley Longman provides detailed
+ * information about the classes and interfaces in the <code>javax.sql</code>
+ * package:
+ *
+ * <ul>
+ * <li><a href="http://www.oracle.com/technetwork/java/index-142838.html">
+ * <i>JDBC™API Tutorial and Reference, Third Edition</i></a>
+ * </ul>
+ */
+package javax.sql;
--- a/src/java.sql/share/classes/javax/sql/package.html Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,302 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
-DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
-This code is free software; you can redistribute it and/or modify it
-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.
--->
-
-</head>
-
-
-
-<body bgcolor="white">
-
-Provides the API for server side data source access and processing from
-the Java™ programming language.
-This package supplements the <code>java.sql</code>
-package and, as of the version 1.4 release, is included in the
-Java Platform, Standard Edition (Java SE™).
-It remains an essential part of the Java Platform, Enterprise Edition
-(Java EE™).
-<P>
-The <code>javax.sql</code> package provides for the following:
-<OL>
- <LI>The <code>DataSource</code> interface as an alternative to the
- <code>DriverManager</code> for establishing a
- connection with a data source
- <LI>Connection pooling and Statement pooling
- <LI>Distributed transactions
- <LI>Rowsets
-</OL>
-<P>
-Applications use the <code>DataSource</code> and <code>RowSet</code>
-APIs directly, but the connection pooling and distributed transaction
-APIs are used internally by the middle-tier infrastructure.
-
-<H2>Using a <code>DataSource</code> Object to Make a Connection</H2>
-
-The <code>javax.sql</code> package provides the preferred
-way to make a connection with a data source. The <code>DriverManager</code>
-class, the original mechanism, is still valid, and code using it will
-continue to run. However, the newer <code>DataSource</code> mechanism
-is preferred because it offers many advantages over the
-<code>DriverManager</code> mechanism.
-<P>
-These are the main advantages of using a <code>DataSource</code> object to
-make a connection:
-<UL>
-
- <LI>Changes can be made to a data source's properties, which means
- that it is not necessary to make changes in application code when
- something about the data source or driver changes.
- <LI>Connection and Statement pooling and distributed transactions are available
- through a <code>DataSource</code> object that is
- implemented to work with the middle-tier infrastructure.
- Connections made through the <code>DriverManager</code>
- do not have connection and statement pooling or distributed transaction
- capabilities.
-</UL>
-<P>
-Driver vendors provide <code>DataSource</code> implementations. A
-particular <code>DataSource</code> object represents a particular
-physical data source, and each connection the <code>DataSource</code> object
-creates is a connection to that physical data source.
-<P>
-A logical name for the data source is registered with a naming service that
-uses the Java Naming and Directory Interface™
-(JNDI) API, usually by a system administrator or someone performing the
-duties of a system administrator. An application can retrieve the
-<code>DataSource</code> object it wants by doing a lookup on the logical
-name that has been registered for it. The application can then use the
-<code>DataSource</code> object to create a connection to the physical data
-source it represents.
-<P>
-A <code>DataSource</code> object can be implemented to work with the
-middle tier infrastructure so that the connections it produces will be
-pooled for reuse. An application that uses such a <code>DataSource</code>
-implementation will automatically get a connection that participates in
-connection pooling.
-A <code>DataSource</code> object can also be implemented to work with the
-middle tier infrastructure so that the connections it produces can be
-used for distributed transactions without any special coding.
-
-<H2>Connection Pooling and Statement Pooling</H2>
-
-Connections made via a <code>DataSource</code>
-object that is implemented to work with a middle tier connection pool manager
-will participate in connection pooling. This can improve performance
-dramatically because creating new connections is very expensive.
-Connection pooling allows a connection to be used and reused,
-thus cutting down substantially on the number of new connections
-that need to be created.
-<P>
-Connection pooling is totally transparent. It is done automatically
-in the middle tier of a Java EE configuration, so from an application's
-viewpoint, no change in code is required. An application simply uses
-the <code>DataSource.getConnection</code> method to get the pooled
-connection and uses it the same way it uses any <code>Connection</code>
-object.
-<P>
-The classes and interfaces used for connection pooling are:
-<UL>
- <LI><code>ConnectionPoolDataSource</code>
- <LI><code>PooledConnection</code>
- <LI><code>ConnectionEvent</code>
- <LI><code>ConnectionEventListener</code>
- <LI><code>StatementEvent</code>
- <LI><code>StatementEventListener</code>
-</UL>
-The connection pool manager, a facility in the middle tier of
-a three-tier architecture, uses these classes and interfaces
-behind the scenes. When a <code>ConnectionPoolDataSource</code> object
-is called on to create a <code>PooledConnection</code> object, the
-connection pool manager will register as a <code>ConnectionEventListener</code>
-object with the new <code>PooledConnection</code> object. When the connection
-is closed or there is an error, the connection pool manager (being a listener)
-gets a notification that includes a <code>ConnectionEvent</code> object.
-<p>
-If the connection pool manager supports <code>Statement</code> pooling, for
-<code>PreparedStatements</code>, which can be determined by invoking the method
-<code>DatabaseMetaData.supportsStatementPooling</code>, the
-connection pool manager will register as a <code>StatementEventListener</code>
-object with the new <code>PooledConnection</code> object. When the
-<code>PreparedStatement</code> is closed or there is an error, the connection
-pool manager (being a listener)
-gets a notification that includes a <code>StatementEvent</code> object.
-
-<H2>Distributed Transactions</H2>
-
-As with pooled connections, connections made via a <code>DataSource</code>
-object that is implemented to work with the middle tier infrastructure
-may participate in distributed transactions. This gives an application
-the ability to involve data sources on multiple servers in a single
-transaction.
-<P>
-The classes and interfaces used for distributed transactions are:
-<UL>
- <LI><code>XADataSource</code>
- <LI><code>XAConnection</code>
-</UL>
-These interfaces are used by the transaction manager; an application does
-not use them directly.
-<P>
-The <code>XAConnection</code> interface is derived from the
-<code>PooledConnection</code> interface, so what applies to a pooled connection
-also applies to a connection that is part of a distributed transaction.
-A transaction manager in the middle tier handles everything transparently.
-The only change in application code is that an application cannot do anything
-that would interfere with the transaction manager's handling of the transaction.
-Specifically, an application cannot call the methods <code>Connection.commit</code>
-or <code>Connection.rollback</code>, and it cannot set the connection to be in
-auto-commit mode (that is, it cannot call
-<code>Connection.setAutoCommit(true)</code>).
-<P>
-An application does not need to do anything special to participate in a
-distributed transaction.
-It simply creates connections to the data sources it wants to use via
-the <code>DataSource.getConnection</code> method, just as it normally does.
-The transaction manager manages the transaction behind the scenes. The
-<code>XADataSource</code> interface creates <code>XAConnection</code> objects, and
-each <code>XAConnection</code> object creates an <code>XAResource</code> object
-that the transaction manager uses to manage the connection.
-
-
-<H2>Rowsets</H2>
-The <code>RowSet</code> interface works with various other classes and
-interfaces behind the scenes. These can be grouped into three categories.
-<OL>
-<LI>Event Notification
-<UL>
- <LI><code>RowSetListener</code><br>
-A <code>RowSet</code> object is a JavaBeans™
-component because it has properties and participates in the JavaBeans
-event notification mechanism. The <code>RowSetListener</code> interface
-is implemented by a component that wants to be notified about events that
-occur to a particular <code>RowSet</code> object. Such a component registers
-itself as a listener with a rowset via the <code>RowSet.addRowSetListener</code>
-method.
-<P>
-When the <code>RowSet</code> object changes one of its rows, changes all of
-it rows, or moves its cursor, it also notifies each listener that is registered
-with it. The listener reacts by carrying out its implementation of the
-notification method called on it.
- <LI><code>RowSetEvent</code><br>
-As part of its internal notification process, a <code>RowSet</code> object
-creates an instance of <code>RowSetEvent</code> and passes it to the listener.
-The listener can use this <code>RowSetEvent</code> object to find out which rowset
-had the event.
-</UL>
-<LI>Metadata
-<UL>
- <LI><code>RowSetMetaData</code><br>
-This interface, derived from the
-<code>ResultSetMetaData</code> interface, provides information about
-the columns in a <code>RowSet</code> object. An application can use
-<code>RowSetMetaData</code> methods to find out how many columns the
-rowset contains and what kind of data each column can contain.
-<P>
-The <code>RowSetMetaData</code> interface provides methods for
-setting the information about columns, but an application would not
-normally use these methods. When an application calls the <code>RowSet</code>
-method <code>execute</code>, the <code>RowSet</code> object will contain
-a new set of rows, and its <code>RowSetMetaData</code> object will have been
-internally updated to contain information about the new columns.
-</UL>
-<LI>The Reader/Writer Facility<br>
-A <code>RowSet</code> object that implements the <code>RowSetInternal</code>
-interface can call on the <code>RowSetReader</code> object associated with it
-to populate itself with data. It can also call on the <code>RowSetWriter</code>
-object associated with it to write any changes to its rows back to the
-data source from which it originally got the rows.
-A rowset that remains connected to its data source does not need to use a
-reader and writer because it can simply operate on the data source directly.
-
-<UL>
- <LI><code>RowSetInternal</code><br>
-By implementing the <code>RowSetInternal</code> interface, a
-<code>RowSet</code> object gets access to
-its internal state and is able to call on its reader and writer. A rowset
-keeps track of the values in its current rows and of the values that immediately
-preceded the current ones, referred to as the <i>original</i> values. A rowset
-also keeps track of (1) the parameters that have been set for its command and
-(2) the connection that was passed to it, if any. A rowset uses the
-<code>RowSetInternal</code> methods behind the scenes to get access to
-this information. An application does not normally invoke these methods directly.
-
- <LI><code>RowSetReader</code><br>
-A disconnected <code>RowSet</code> object that has implemented the
-<code>RowSetInternal</code> interface can call on its reader (the
-<code>RowSetReader</code> object associated with it) to populate it with
-data. When an application calls the <code>RowSet.execute</code> method,
-that method calls on the rowset's reader to do much of the work. Implementations
-can vary widely, but generally a reader makes a connection to the data source,
-reads data from the data source and populates the rowset with it, and closes
-the connection. A reader may also update the <code>RowSetMetaData</code> object
-for its rowset. The rowset's internal state is also updated, either by the
-reader or directly by the method <code>RowSet.execute</code>.
-
-
- <LI><code>RowSetWriter</code><br>
-A disconnected <code>RowSet</code> object that has implemented the
-<code>RowSetInternal</code> interface can call on its writer (the
-<code>RowSetWriter</code> object associated with it) to write changes
-back to the underlying data source. Implementations may vary widely, but
-generally, a writer will do the following:
-
-<UL>
- <LI>Make a connection to the data source
- <LI>Check to see whether there is a conflict, that is, whether
- a value that has been changed in the rowset has also been changed
- in the data source
- <LI>Write the new values to the data source if there is no conflict
- <LI>Close the connection
-</UL>
-
-
-</UL>
-</OL>
-<P>
-The <code>RowSet</code> interface may be implemented in any number of
-ways, and anyone may write an implementation. Developers are encouraged
-to use their imaginations in coming up with new ways to use rowsets.
-
-
-<h2>Package Specification</h2>
-
-<ul>
- <li><a href="https://jcp.org/en/jsr/detail?id=221">JDBC 4.3 Specification</a>
-</ul>
-
-<h2>Related Documentation</h2>
-
-The Java Series book published by Addison-Wesley Longman provides detailed
-information about the classes and interfaces in the <code>javax.sql</code>
-package:
-
-<ul>
- <li><a href="http://www.oracle.com/technetwork/java/index-142838.html">
- <i>JDBC™API Tutorial and Reference, Third Edition</i></a>
-</ul>
-</body>
-</html>
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/BitArray.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/BitArray.java Tue Dec 18 15:08:56 2018 -0500
@@ -133,7 +133,7 @@
* This method returns the Nth bit that is set in the bit array. The
* current position is cached in the following 4 variables and will
* help speed up a sequence of next() call in an index iterator. This
- * method is a mess, but it is fast and it works, so don't fuck with it.
+ * method is a mess, but it is fast and it works, so don't change it.
*/
private int _pos = Integer.MAX_VALUE;
private int _node = 0;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java Tue Dec 18 15:08:56 2018 -0500
@@ -85,7 +85,10 @@
JDK11("11"),
/** 12 covers the to be determined language features that will be added in JDK 12. */
- JDK12("12");
+ JDK12("12"),
+
+ /** 13 covers the to be determined language features that will be added in JDK 13. */
+ JDK13("13");
private static final Context.Key<Source> sourceKey = new Context.Key<>();
@@ -136,6 +139,7 @@
}
public Target requiredTarget() {
+ if (this.compareTo(JDK13) >= 0) return Target.JDK1_13;
if (this.compareTo(JDK12) >= 0) return Target.JDK1_12;
if (this.compareTo(JDK11) >= 0) return Target.JDK1_11;
if (this.compareTo(JDK10) >= 0) return Target.JDK1_10;
@@ -182,10 +186,10 @@
LOCAL_VARIABLE_TYPE_INFERENCE(JDK10),
VAR_SYNTAX_IMPLICIT_LAMBDAS(JDK11, Fragments.FeatureVarSyntaxInImplicitLambda, DiagKind.PLURAL),
IMPORT_ON_DEMAND_OBSERVABLE_PACKAGES(JDK1_2, JDK8),
- SWITCH_MULTIPLE_CASE_LABELS(JDK12, Fragments.FeatureMultipleCaseLabels, DiagKind.PLURAL),
- SWITCH_RULE(JDK12, Fragments.FeatureSwitchRules, DiagKind.PLURAL),
- SWITCH_EXPRESSION(JDK12, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL),
- RAW_STRING_LITERALS(JDK12, Fragments.FeatureRawStringLiterals, DiagKind.PLURAL);
+ SWITCH_MULTIPLE_CASE_LABELS(JDK13, Fragments.FeatureMultipleCaseLabels, DiagKind.PLURAL),
+ SWITCH_RULE(JDK13, Fragments.FeatureSwitchRules, DiagKind.PLURAL),
+ SWITCH_EXPRESSION(JDK13, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL),
+ RAW_STRING_LITERALS(JDK13, Fragments.FeatureRawStringLiterals, DiagKind.PLURAL);
enum DiagKind {
NORMAL,
@@ -270,6 +274,8 @@
return RELEASE_11;
case JDK12:
return RELEASE_12;
+ case JDK13:
+ return RELEASE_13;
default:
return null;
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Dec 18 15:08:56 2018 -0500
@@ -427,6 +427,10 @@
if (annotations.isEmpty()) {
return type;
}
+ // All annotations share the same position
+ for (TypeCompound tc : annotations) {
+ Assert.check(tc.position == pos);
+ }
if (type.hasTag(TypeTag.ARRAY))
return rewriteArrayType((ArrayType)type, annotations, pos);
@@ -522,10 +526,7 @@
if (depth.nonEmpty()) {
// Only need to change the annotation positions
// if they are on an enclosed type.
- // All annotations share the same position; modify the first one.
- Attribute.TypeCompound a = annotations.get(0);
- TypeAnnotationPosition p = a.position;
- p.location = p.location.appendList(depth.toList());
+ pos.location = pos.location.appendList(depth.toList());
}
Type ret = typeWithAnnotations(type, enclTy, annotations);
@@ -583,11 +584,7 @@
tomodify.elemtype = elemType;
// Update positions
- for (TypeCompound tc : annotations) {
- if (tc.position == null)
- tc.position = pos;
- tc.position.location = loc;
- }
+ pos.location = loc;
return res;
}
@@ -1396,16 +1393,6 @@
scan(tree.elems);
}
-
- private void findTypeCompoundPosition(JCTree tree, JCTree frame, List<Attribute.TypeCompound> annotations) {
- if (!annotations.isEmpty()) {
- final TypeAnnotationPosition p =
- resolveFrame(tree, frame, frames, currentLambda, 0, new ListBuffer<>());
- for (TypeCompound tc : annotations)
- tc.position = p;
- }
- }
-
private void findPosition(JCTree tree, JCTree frame, List<JCAnnotation> annotations) {
if (!annotations.isEmpty())
{
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Tue Dec 18 15:08:56 2018 -0500
@@ -26,6 +26,7 @@
package com.sun.tools.javac.comp;
import java.util.*;
+import java.util.function.Supplier;
import javax.tools.JavaFileManager;
@@ -1797,7 +1798,7 @@
if (!isDeprecatedOverrideIgnorable(other, origin)) {
Lint prevLint = setLint(lint.augment(m));
try {
- checkDeprecated(TreeInfo.diagnosticPositionFor(m, tree), m, other);
+ checkDeprecated(() -> TreeInfo.diagnosticPositionFor(m, tree), m, other);
} finally {
setLint(prevLint);
}
@@ -3259,10 +3260,14 @@
}
void checkDeprecated(final DiagnosticPosition pos, final Symbol other, final Symbol s) {
+ checkDeprecated(() -> pos, other, s);
+ }
+
+ void checkDeprecated(Supplier<DiagnosticPosition> pos, final Symbol other, final Symbol s) {
if ( (s.isDeprecatedForRemoval()
|| s.isDeprecated() && !other.isDeprecated())
&& (s.outermostClass() != other.outermostClass() || s.outermostClass() == null)) {
- deferredLintHandler.report(() -> warnDeprecated(pos, s));
+ deferredLintHandler.report(() -> warnDeprecated(pos.get(), s));
}
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java Tue Dec 18 15:08:56 2018 -0500
@@ -116,7 +116,8 @@
V53(53, 0), // JDK 1.9: modules, indy string concat
V54(54, 0), // JDK 10
V55(55, 0), // JDK 11: constant dynamic, nest mates
- V56(56, 0); // JDK 12
+ V56(56, 0), // JDK 12
+ V57(57, 0); // JDK 13
Version(int major, int minor) {
this.major = major;
this.minor = minor;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java Tue Dec 18 15:08:56 2018 -0500
@@ -40,9 +40,9 @@
* deletion without notice.</b>
*/
public enum Profile {
- COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11, Target.JDK1_12),
- COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11, Target.JDK1_12),
- COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11, Target.JDK1_12),
+ COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11, Target.JDK1_12, Target.JDK1_13),
+ COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11, Target.JDK1_12, Target.JDK1_13),
+ COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11, Target.JDK1_12, Target.JDK1_13),
DEFAULT {
@Override
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java Tue Dec 18 15:08:56 2018 -0500
@@ -70,7 +70,10 @@
JDK1_11("11", 55, 0),
/** JDK 12. */
- JDK1_12("12", 56, 0);
+ JDK1_12("12", 56, 0),
+
+ /** JDK 13. */
+ JDK1_13("13", 57, 0);
private static final Context.Key<Target> targetKey = new Context.Key<>();
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Tue Dec 18 15:08:56 2018 -0500
@@ -55,7 +55,7 @@
* deletion without notice.</b>
*/
@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_12)
+@SupportedSourceVersion(SourceVersion.RELEASE_13)
public class PrintingProcessor extends AbstractProcessor {
PrintWriter writer;
--- a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,9 +25,7 @@
package sun.security.ec;
-import java.io.IOException;
import java.nio.ByteBuffer;
-import java.math.BigInteger;
import java.security.*;
import java.security.interfaces.*;
@@ -453,7 +451,7 @@
if (p1363Format) {
return sig;
} else {
- return encodeSignature(sig);
+ return ECUtil.encodeSignature(sig);
}
}
@@ -476,7 +474,7 @@
if (p1363Format) {
sig = signature;
} else {
- sig = decodeSignature(signature);
+ sig = ECUtil.decodeSignature(signature);
}
try {
@@ -515,79 +513,6 @@
return null;
}
- // Convert the concatenation of R and S into their DER encoding
- private byte[] encodeSignature(byte[] signature) throws SignatureException {
-
- try {
-
- int n = signature.length >> 1;
- byte[] bytes = new byte[n];
- System.arraycopy(signature, 0, bytes, 0, n);
- BigInteger r = new BigInteger(1, bytes);
- System.arraycopy(signature, n, bytes, 0, n);
- BigInteger s = new BigInteger(1, bytes);
-
- DerOutputStream out = new DerOutputStream(signature.length + 10);
- out.putInteger(r);
- out.putInteger(s);
- DerValue result =
- new DerValue(DerValue.tag_Sequence, out.toByteArray());
-
- return result.toByteArray();
-
- } catch (Exception e) {
- throw new SignatureException("Could not encode signature", e);
- }
- }
-
- // Convert the DER encoding of R and S into a concatenation of R and S
- private byte[] decodeSignature(byte[] sig) throws SignatureException {
-
- try {
- // Enforce strict DER checking for signatures
- DerInputStream in = new DerInputStream(sig, 0, sig.length, false);
- DerValue[] values = in.getSequence(2);
-
- // check number of components in the read sequence
- // and trailing data
- if ((values.length != 2) || (in.available() != 0)) {
- throw new IOException("Invalid encoding for signature");
- }
-
- BigInteger r = values[0].getPositiveBigInteger();
- BigInteger s = values[1].getPositiveBigInteger();
-
- // trim leading zeroes
- byte[] rBytes = trimZeroes(r.toByteArray());
- byte[] sBytes = trimZeroes(s.toByteArray());
- int k = Math.max(rBytes.length, sBytes.length);
- // r and s each occupy half the array
- byte[] result = new byte[k << 1];
- System.arraycopy(rBytes, 0, result, k - rBytes.length,
- rBytes.length);
- System.arraycopy(sBytes, 0, result, result.length - sBytes.length,
- sBytes.length);
- return result;
-
- } catch (Exception e) {
- throw new SignatureException("Invalid encoding for signature", e);
- }
- }
-
- // trim leading (most significant) zeroes from the result
- private static byte[] trimZeroes(byte[] b) {
- int i = 0;
- while ((i < b.length - 1) && (b[i] == 0)) {
- i++;
- }
- if (i == 0) {
- return b;
- }
- byte[] t = new byte[b.length - i];
- System.arraycopy(b, i, t, 0, t.length);
- return t;
- }
-
/**
* Signs the digest using the private key.
*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CKey.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.mscapi;
+
+import sun.security.util.KeyUtil;
+import sun.security.util.Length;
+
+import java.math.BigInteger;
+import java.security.Key;
+import java.security.interfaces.ECPrivateKey;
+import java.security.interfaces.ECPublicKey;
+
+/**
+ * The handle for a key using the Microsoft Crypto API.
+ *
+ * @see CPrivateKey
+ * @see CPublicKey
+ *
+ * @since 1.6
+ * @author Stanley Man-Kit Ho
+ */
+abstract class CKey implements Key, Length {
+ private static final long serialVersionUID = -1088859394025049194L;
+
+ static class NativeHandles {
+
+ long hCryptProv = 0;
+ long hCryptKey = 0;
+
+ public NativeHandles(long hCryptProv, long hCryptKey) {
+ this.hCryptProv = hCryptProv;
+ this.hCryptKey = hCryptKey;
+ }
+
+ @SuppressWarnings("deprecation")
+ protected void finalize() throws Throwable {
+ try {
+ synchronized(this) {
+ cleanUp(hCryptProv, hCryptKey);
+ hCryptProv = 0;
+ hCryptKey = 0;
+ }
+ } finally {
+ super.finalize();
+ }
+ }
+ }
+
+ protected final NativeHandles handles;
+
+ protected final int keyLength;
+
+ protected final String algorithm;
+
+ protected CKey(String algorithm, long hCryptProv, long hCryptKey, int keyLength) {
+ this.algorithm = algorithm;
+ this.handles = new NativeHandles(hCryptProv, hCryptKey);
+ this.keyLength = keyLength;
+ }
+
+ // Native method to cleanup the key handle.
+ private native static void cleanUp(long hCryptProv, long hCryptKey);
+
+ @Override
+ public int length() {
+ return keyLength;
+ }
+
+ public long getHCryptKey() {
+ return handles.hCryptKey;
+ }
+
+ public long getHCryptProvider() {
+ return handles.hCryptProv;
+ }
+
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ protected native static String getContainerName(long hCryptProv);
+
+ protected native static String getKeyType(long hCryptKey);
+
+ // This java method generates EC BLOBs for public key or private key.
+ // See https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_ecckey_blob
+ static byte[] generateECBlob(Key k) {
+
+ int keyBitLength = KeyUtil.getKeySize(k);
+ int keyLen = (keyBitLength + 7) / 8;
+ boolean isPrivate = k instanceof ECPrivateKey;
+
+ byte[] keyBlob = new byte[8 + keyLen * (isPrivate ? 3 : 2)];
+ keyBlob[0] = 'E';
+ keyBlob[1] = 'C';
+ keyBlob[2] = 'S';
+ if (isPrivate) {
+ keyBlob[3] = (byte) (keyBitLength == 256 ? '2'
+ : (keyBitLength == 384 ? '4' : '6'));
+ } else {
+ keyBlob[3] = (byte) (keyBitLength == 256 ? '1'
+ : (keyBitLength == 384 ? '3' : '5'));
+ }
+ BigInteger x;
+ BigInteger y;
+ // Fill the array in reverse order (s -> y -> x -> len) in case
+ // one BigInteger encoding has an extra 0 at the beginning
+ if (isPrivate) {
+ // We can keep X and Y zero and it still works
+ ECPrivateKey prk = (ECPrivateKey)k;
+ BigInteger s = prk.getS();
+ byte[] bs = s.toByteArray();
+ System.arraycopy(
+ bs, 0,
+ keyBlob, 8 + keyLen + keyLen + keyLen - bs.length,
+ bs.length);
+ } else {
+ ECPublicKey puk = (ECPublicKey)k;
+ x = puk.getW().getAffineX();
+ y = puk.getW().getAffineY();
+ byte[] by = y.toByteArray();
+ System.arraycopy(by, 0, keyBlob, 8 + keyLen + keyLen - by.length,
+ by.length);
+ byte[] bx = x.toByteArray();
+ System.arraycopy(bx, 0, keyBlob, 8 + keyLen - bx.length, bx.length);
+ }
+ keyBlob[4] = (byte) keyLen;
+ keyBlob[5] = keyBlob[6] = keyBlob[7] = 0;
+ return keyBlob;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CKeyPair.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.mscapi;
+
+/**
+ * The handle for an RSA public/private keypair using the Microsoft Crypto API.
+ *
+ * @since 1.6
+ */
+class CKeyPair {
+
+ private final CPrivateKey privateKey;
+
+ private final CPublicKey publicKey;
+
+ CKeyPair(String alg, long hCryptProv, long hCryptKey, int keyLength) {
+ privateKey = CPrivateKey.of(alg, hCryptProv, hCryptKey, keyLength);
+ publicKey = CPublicKey.of(alg, hCryptProv, hCryptKey, keyLength);
+ }
+
+ public CPrivateKey getPrivate() {
+ return privateKey;
+ }
+
+ public CPublicKey getPublic() {
+ return publicKey;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CKeyPairGenerator.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.mscapi;
+
+import java.util.UUID;
+import java.security.*;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.RSAKeyGenParameterSpec;
+
+import sun.security.rsa.RSAKeyFactory;
+import static sun.security.util.SecurityProviderConstants.DEF_RSA_KEY_SIZE;
+
+/**
+ * RSA keypair generator.
+ *
+ * Standard algorithm, minimum key length is 512 bit, maximum is 16,384.
+ * Generates a private key that is exportable.
+ *
+ * @since 1.6
+ */
+public abstract class CKeyPairGenerator extends KeyPairGeneratorSpi {
+
+ protected String keyAlg;
+
+ public CKeyPairGenerator(String keyAlg) {
+ this.keyAlg = keyAlg;
+ }
+
+ public static class RSA extends CKeyPairGenerator {
+ public RSA() {
+ super("RSA");
+ // initialize to default in case the app does not call initialize()
+ initialize(DEF_RSA_KEY_SIZE, null);
+ }
+
+ // Supported by Microsoft Base, Strong and Enhanced Cryptographic Providers
+ static final int KEY_SIZE_MIN = 512; // disallow MSCAPI min. of 384
+ static final int KEY_SIZE_MAX = 16384;
+
+ // size of the key to generate, KEY_SIZE_MIN <= keySize <= KEY_SIZE_MAX
+ private int keySize;
+
+ // initialize the generator. See JCA doc
+ // random is always ignored
+ @Override
+ public void initialize(int keySize, SecureRandom random) {
+
+ try {
+ RSAKeyFactory.checkKeyLengths(keySize, null,
+ KEY_SIZE_MIN, KEY_SIZE_MAX);
+ } catch (InvalidKeyException e) {
+ throw new InvalidParameterException(e.getMessage());
+ }
+
+ this.keySize = keySize;
+ }
+
+ // second initialize method. See JCA doc
+ // random and exponent are always ignored
+ @Override
+ public void initialize(AlgorithmParameterSpec params, SecureRandom random)
+ throws InvalidAlgorithmParameterException {
+
+ int tmpSize;
+ if (params == null) {
+ tmpSize = DEF_RSA_KEY_SIZE;
+ } else if (params instanceof RSAKeyGenParameterSpec) {
+
+ if (((RSAKeyGenParameterSpec) params).getPublicExponent() != null) {
+ throw new InvalidAlgorithmParameterException
+ ("Exponent parameter is not supported");
+ }
+ tmpSize = ((RSAKeyGenParameterSpec) params).getKeysize();
+
+ } else {
+ throw new InvalidAlgorithmParameterException
+ ("Params must be an instance of RSAKeyGenParameterSpec");
+ }
+
+ try {
+ RSAKeyFactory.checkKeyLengths(tmpSize, null,
+ KEY_SIZE_MIN, KEY_SIZE_MAX);
+ } catch (InvalidKeyException e) {
+ throw new InvalidAlgorithmParameterException(
+ "Invalid Key sizes", e);
+ }
+
+ this.keySize = tmpSize;
+ }
+
+ // generate the keypair. See JCA doc
+ @Override
+ public KeyPair generateKeyPair() {
+
+ try {
+ // Generate each keypair in a unique key container
+ CKeyPair keys =
+ generateCKeyPair(keyAlg, keySize,
+ "{" + UUID.randomUUID().toString() + "}");
+ return new KeyPair(keys.getPublic(), keys.getPrivate());
+
+ } catch (KeyException e) {
+ throw new ProviderException(e);
+ }
+ }
+
+ private static native CKeyPair generateCKeyPair(String alg, int keySize,
+ String keyContainerName) throws KeyException;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CKeyStore.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,880 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.mscapi;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.AccessController;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyStoreSpi;
+import java.security.KeyStoreException;
+import java.security.PrivilegedAction;
+import java.security.UnrecoverableKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecurityPermission;
+import java.security.cert.X509Certificate;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.interfaces.RSAPrivateCrtKey;
+import java.util.*;
+
+/**
+ * Implementation of key store for Windows using the Microsoft Crypto API.
+ *
+ * @since 1.6
+ */
+abstract class CKeyStore extends KeyStoreSpi {
+
+ public static final class MY extends CKeyStore {
+ public MY() {
+ super("MY");
+ }
+ }
+
+ public static final class ROOT extends CKeyStore {
+ public ROOT() {
+ super("ROOT");
+ }
+ }
+
+ class KeyEntry {
+ private CKey privateKey;
+ private X509Certificate[] certChain;
+ private String alias;
+
+ KeyEntry(CKey key, X509Certificate[] chain) {
+ this(null, key, chain);
+ }
+
+ KeyEntry(String alias, CKey key, X509Certificate[] chain) {
+ this.privateKey = key;
+ this.certChain = chain;
+ /*
+ * The default alias for both entry types is derived from a
+ * hash value intrinsic to the first certificate in the chain.
+ */
+ if (alias == null) {
+ this.alias = Integer.toString(chain[0].hashCode());
+ } else {
+ this.alias = alias;
+ }
+ }
+
+ /**
+ * Gets the alias for the keystore entry.
+ */
+ String getAlias() {
+ return alias;
+ }
+
+ /**
+ * Sets the alias for the keystore entry.
+ */
+ void setAlias(String alias) {
+ // TODO - set friendly name prop in cert store
+ this.alias = alias;
+ }
+
+ /**
+ * Gets the private key for the keystore entry.
+ */
+ CKey getPrivateKey() {
+ return privateKey;
+ }
+
+ /**
+ * Sets the private key for the keystore entry.
+ */
+ void setRSAPrivateKey(Key k)
+ throws InvalidKeyException, KeyStoreException {
+ RSAPrivateCrtKey key = (RSAPrivateCrtKey) k;
+ byte[] modulusBytes = key.getModulus().toByteArray();
+
+ // Adjust key length due to sign bit
+ int keyBitLength = (modulusBytes[0] == 0)
+ ? (modulusBytes.length - 1) * 8
+ : modulusBytes.length * 8;
+
+ byte[] keyBlob = generateRSAPrivateKeyBlob(
+ keyBitLength,
+ modulusBytes,
+ key.getPublicExponent().toByteArray(),
+ key.getPrivateExponent().toByteArray(),
+ key.getPrimeP().toByteArray(),
+ key.getPrimeQ().toByteArray(),
+ key.getPrimeExponentP().toByteArray(),
+ key.getPrimeExponentQ().toByteArray(),
+ key.getCrtCoefficient().toByteArray());
+
+ privateKey = storePrivateKey("RSA", Objects.requireNonNull(keyBlob),
+ "{" + UUID.randomUUID().toString() + "}", keyBitLength);
+ }
+
+ /**
+ * Gets the certificate chain for the keystore entry.
+ */
+ X509Certificate[] getCertificateChain() {
+ return certChain;
+ }
+
+ /**
+ * Sets the certificate chain for the keystore entry.
+ */
+ void setCertificateChain(X509Certificate[] chain)
+ throws CertificateException, KeyStoreException {
+ for (int i = 0; i < chain.length; i++) {
+ byte[] encoding = chain[i].getEncoded();
+ if (i == 0 && privateKey != null) {
+ storeCertificate(getName(), alias, encoding,
+ encoding.length, privateKey.getHCryptProvider(),
+ privateKey.getHCryptKey());
+
+ } else {
+ storeCertificate(getName(), alias, encoding,
+ encoding.length, 0L, 0L); // no private key to attach
+ }
+ }
+ certChain = chain;
+ }
+ }
+
+ /*
+ * An X.509 certificate factory.
+ * Used to create an X.509 certificate from its DER-encoding.
+ */
+ private CertificateFactory certificateFactory = null;
+
+ /*
+ * Compatibility mode: for applications that assume keystores are
+ * stream-based this mode tolerates (but ignores) a non-null stream
+ * or password parameter when passed to the load or store methods.
+ * The mode is enabled by default.
+ */
+ private static final String KEYSTORE_COMPATIBILITY_MODE_PROP =
+ "sun.security.mscapi.keyStoreCompatibilityMode";
+ private final boolean keyStoreCompatibilityMode;
+
+ /*
+ * The keystore entries.
+ * Keys in the map are unique aliases (thus can differ from
+ * KeyEntry.getAlias())
+ */
+ private Map<String,KeyEntry> entries = new HashMap<>();
+
+ /*
+ * The keystore name.
+ * Case is not significant.
+ */
+ private final String storeName;
+
+ CKeyStore(String storeName) {
+ // Get the compatibility mode
+ String prop = AccessController.doPrivileged(
+ (PrivilegedAction<String>) () -> System.getProperty(KEYSTORE_COMPATIBILITY_MODE_PROP));
+
+ if ("false".equalsIgnoreCase(prop)) {
+ keyStoreCompatibilityMode = false;
+ } else {
+ keyStoreCompatibilityMode = true;
+ }
+
+ this.storeName = storeName;
+ }
+
+ /**
+ * Returns the key associated with the given alias.
+ * <p>
+ * A compatibility mode is supported for applications that assume
+ * a password must be supplied. It permits (but ignores) a non-null
+ * <code>password</code>. The mode is enabled by default.
+ * Set the
+ * <code>sun.security.mscapi.keyStoreCompatibilityMode</code>
+ * system property to <code>false</code> to disable compatibility mode
+ * and reject a non-null <code>password</code>.
+ *
+ * @param alias the alias name
+ * @param password the password, which should be <code>null</code>
+ *
+ * @return the requested key, or null if the given alias does not exist
+ * or does not identify a <i>key entry</i>.
+ *
+ * @exception NoSuchAlgorithmException if the algorithm for recovering the
+ * key cannot be found,
+ * or if compatibility mode is disabled and <code>password</code> is
+ * non-null.
+ * @exception UnrecoverableKeyException if the key cannot be recovered.
+ */
+ public java.security.Key engineGetKey(String alias, char[] password)
+ throws NoSuchAlgorithmException, UnrecoverableKeyException {
+ if (alias == null) {
+ return null;
+ }
+
+ if (password != null && !keyStoreCompatibilityMode) {
+ throw new UnrecoverableKeyException("Password must be null");
+ }
+
+ if (engineIsKeyEntry(alias) == false)
+ return null;
+
+ KeyEntry entry = entries.get(alias);
+ return (entry == null)
+ ? null
+ : entry.getPrivateKey();
+ }
+
+ /**
+ * Returns the certificate chain associated with the given alias.
+ *
+ * @param alias the alias name
+ *
+ * @return the certificate chain (ordered with the user's certificate first
+ * and the root certificate authority last), or null if the given alias
+ * does not exist or does not contain a certificate chain (i.e., the given
+ * alias identifies either a <i>trusted certificate entry</i> or a
+ * <i>key entry</i> without a certificate chain).
+ */
+ public Certificate[] engineGetCertificateChain(String alias) {
+ if (alias == null) {
+ return null;
+ }
+
+ KeyEntry entry = entries.get(alias);
+ X509Certificate[] certChain = (entry == null)
+ ? null
+ : entry.getCertificateChain();
+ return (certChain == null)
+ ? null
+ : certChain.clone();
+ }
+
+ /**
+ * Returns the certificate associated with the given alias.
+ *
+ * <p>If the given alias name identifies a
+ * <i>trusted certificate entry</i>, the certificate associated with that
+ * entry is returned. If the given alias name identifies a
+ * <i>key entry</i>, the first element of the certificate chain of that
+ * entry is returned, or null if that entry does not have a certificate
+ * chain.
+ *
+ * @param alias the alias name
+ *
+ * @return the certificate, or null if the given alias does not exist or
+ * does not contain a certificate.
+ */
+ public Certificate engineGetCertificate(String alias) {
+ if (alias == null) {
+ return null;
+ }
+
+ KeyEntry entry = entries.get(alias);
+ X509Certificate[] certChain = (entry == null)
+ ? null
+ : entry.getCertificateChain();
+ return (certChain == null || certChain.length == 0)
+ ? null
+ : certChain[0];
+ }
+
+ /**
+ * Returns the creation date of the entry identified by the given alias.
+ *
+ * @param alias the alias name
+ *
+ * @return the creation date of this entry, or null if the given alias does
+ * not exist
+ */
+ public Date engineGetCreationDate(String alias) {
+ if (alias == null) {
+ return null;
+ }
+ return new Date();
+ }
+
+ /**
+ * Stores the given private key and associated certificate chain in the
+ * keystore.
+ *
+ * <p>The given java.security.PrivateKey <code>key</code> must
+ * be accompanied by a certificate chain certifying the
+ * corresponding public key.
+ *
+ * <p>If the given alias already exists, the keystore information
+ * associated with it is overridden by the given key and certificate
+ * chain. Otherwise, a new entry is created.
+ *
+ * <p>
+ * A compatibility mode is supported for applications that assume
+ * a password must be supplied. It permits (but ignores) a non-null
+ * <code>password</code>. The mode is enabled by default.
+ * Set the
+ * <code>sun.security.mscapi.keyStoreCompatibilityMode</code>
+ * system property to <code>false</code> to disable compatibility mode
+ * and reject a non-null <code>password</code>.
+ *
+ * @param alias the alias name
+ * @param key the private key to be associated with the alias
+ * @param password the password, which should be <code>null</code>
+ * @param chain the certificate chain for the corresponding public
+ * key (only required if the given key is of type
+ * <code>java.security.PrivateKey</code>).
+ *
+ * @exception KeyStoreException if the given key is not a private key,
+ * cannot be protected, or if compatibility mode is disabled and
+ * <code>password</code> is non-null, or if this operation fails for
+ * some other reason.
+ */
+ public void engineSetKeyEntry(String alias, java.security.Key key,
+ char[] password, Certificate[] chain) throws KeyStoreException {
+ if (alias == null) {
+ throw new KeyStoreException("alias must not be null");
+ }
+
+ if (password != null && !keyStoreCompatibilityMode) {
+ throw new KeyStoreException("Password must be null");
+ }
+
+ if (key instanceof RSAPrivateCrtKey) {
+
+ KeyEntry entry = entries.get(alias);
+
+ X509Certificate[] xchain;
+ if (chain != null) {
+ if (chain instanceof X509Certificate[]) {
+ xchain = (X509Certificate[]) chain;
+ } else {
+ xchain = new X509Certificate[chain.length];
+ System.arraycopy(chain, 0, xchain, 0, chain.length);
+ }
+ } else {
+ xchain = null;
+ }
+
+ if (entry == null) {
+ entry =
+ //TODO new KeyEntry(alias, key, (X509Certificate[]) chain);
+ new KeyEntry(alias, null, xchain);
+ storeWithUniqueAlias(alias, entry);
+ }
+
+ entry.setAlias(alias);
+
+ try {
+ entry.setRSAPrivateKey(key);
+ entry.setCertificateChain(xchain);
+
+ } catch (CertificateException ce) {
+ throw new KeyStoreException(ce);
+
+ } catch (InvalidKeyException ike) {
+ throw new KeyStoreException(ike);
+ }
+
+ } else {
+ throw new UnsupportedOperationException(
+ "Cannot assign the key to the given alias.");
+ }
+ }
+
+ /**
+ * Assigns the given key (that has already been protected) to the given
+ * alias.
+ *
+ * <p>If the protected key is of type
+ * <code>java.security.PrivateKey</code>, it must be accompanied by a
+ * certificate chain certifying the corresponding public key. If the
+ * underlying keystore implementation is of type <code>jks</code>,
+ * <code>key</code> must be encoded as an
+ * <code>EncryptedPrivateKeyInfo</code> as defined in the PKCS #8 standard.
+ *
+ * <p>If the given alias already exists, the keystore information
+ * associated with it is overridden by the given key (and possibly
+ * certificate chain).
+ *
+ * @param alias the alias name
+ * @param key the key (in protected format) to be associated with the alias
+ * @param chain the certificate chain for the corresponding public
+ * key (only useful if the protected key is of type
+ * <code>java.security.PrivateKey</code>).
+ *
+ * @exception KeyStoreException if this operation fails.
+ */
+ public void engineSetKeyEntry(String alias, byte[] key,
+ Certificate[] chain)
+ throws KeyStoreException {
+ throw new UnsupportedOperationException(
+ "Cannot assign the encoded key to the given alias.");
+ }
+
+ /**
+ * Assigns the given certificate to the given alias.
+ *
+ * <p>If the given alias already exists in this keystore and identifies a
+ * <i>trusted certificate entry</i>, the certificate associated with it is
+ * overridden by the given certificate.
+ *
+ * @param alias the alias name
+ * @param cert the certificate
+ *
+ * @exception KeyStoreException if the given alias already exists and does
+ * not identify a <i>trusted certificate entry</i>, or this operation
+ * fails for some other reason.
+ */
+ public void engineSetCertificateEntry(String alias, Certificate cert)
+ throws KeyStoreException {
+ if (alias == null) {
+ throw new KeyStoreException("alias must not be null");
+ }
+
+ if (cert instanceof X509Certificate) {
+
+ // TODO - build CryptoAPI chain?
+ X509Certificate[] chain =
+ new X509Certificate[]{ (X509Certificate) cert };
+ KeyEntry entry = entries.get(alias);
+
+ if (entry == null) {
+ entry =
+ new KeyEntry(alias, null, chain);
+ storeWithUniqueAlias(alias, entry);
+ }
+
+ if (entry.getPrivateKey() == null) { // trusted-cert entry
+ entry.setAlias(alias);
+
+ try {
+ entry.setCertificateChain(chain);
+
+ } catch (CertificateException ce) {
+ throw new KeyStoreException(ce);
+ }
+ }
+
+ } else {
+ throw new UnsupportedOperationException(
+ "Cannot assign the certificate to the given alias.");
+ }
+ }
+
+ /**
+ * Deletes the entry identified by the given alias from this keystore.
+ *
+ * @param alias the alias name
+ *
+ * @exception KeyStoreException if the entry cannot be removed.
+ */
+ public void engineDeleteEntry(String alias) throws KeyStoreException {
+ if (alias == null) {
+ throw new KeyStoreException("alias must not be null");
+ }
+
+ KeyEntry entry = entries.remove(alias);
+ if (entry != null) {
+ // Get end-entity certificate and remove from system cert store
+ X509Certificate[] certChain = entry.getCertificateChain();
+ if (certChain != null && certChain.length > 0) {
+
+ try {
+
+ byte[] encoding = certChain[0].getEncoded();
+ removeCertificate(getName(), entry.getAlias(), encoding,
+ encoding.length);
+
+ } catch (CertificateException e) {
+ throw new KeyStoreException("Cannot remove entry: ", e);
+ }
+ }
+ CKey privateKey = entry.getPrivateKey();
+ if (privateKey != null) {
+ destroyKeyContainer(
+ CKey.getContainerName(privateKey.getHCryptProvider()));
+ }
+ }
+ }
+
+ /**
+ * Lists all the alias names of this keystore.
+ *
+ * @return enumeration of the alias names
+ */
+ public Enumeration<String> engineAliases() {
+ final Iterator<String> iter = entries.keySet().iterator();
+
+ return new Enumeration<String>() {
+ public boolean hasMoreElements() {
+ return iter.hasNext();
+ }
+
+ public String nextElement() {
+ return iter.next();
+ }
+ };
+ }
+
+ /**
+ * Checks if the given alias exists in this keystore.
+ *
+ * @param alias the alias name
+ *
+ * @return true if the alias exists, false otherwise
+ */
+ public boolean engineContainsAlias(String alias) {
+ return entries.containsKey(alias);
+ }
+
+ /**
+ * Retrieves the number of entries in this keystore.
+ *
+ * @return the number of entries in this keystore
+ */
+ public int engineSize() {
+ return entries.size();
+ }
+
+ /**
+ * Returns true if the entry identified by the given alias is a
+ * <i>key entry</i>, and false otherwise.
+ *
+ * @return true if the entry identified by the given alias is a
+ * <i>key entry</i>, false otherwise.
+ */
+ public boolean engineIsKeyEntry(String alias) {
+
+ if (alias == null) {
+ return false;
+ }
+
+ KeyEntry entry = entries.get(alias);
+ return entry != null && entry.getPrivateKey() != null;
+ }
+
+ /**
+ * Returns true if the entry identified by the given alias is a
+ * <i>trusted certificate entry</i>, and false otherwise.
+ *
+ * @return true if the entry identified by the given alias is a
+ * <i>trusted certificate entry</i>, false otherwise.
+ */
+ public boolean engineIsCertificateEntry(String alias) {
+
+ if (alias == null) {
+ return false;
+ }
+
+ KeyEntry entry = entries.get(alias);
+ return entry != null && entry.getPrivateKey() == null;
+ }
+
+ /**
+ * Returns the (alias) name of the first keystore entry whose certificate
+ * matches the given certificate.
+ *
+ * <p>This method attempts to match the given certificate with each
+ * keystore entry. If the entry being considered
+ * is a <i>trusted certificate entry</i>, the given certificate is
+ * compared to that entry's certificate. If the entry being considered is
+ * a <i>key entry</i>, the given certificate is compared to the first
+ * element of that entry's certificate chain (if a chain exists).
+ *
+ * @param cert the certificate to match with.
+ *
+ * @return the (alias) name of the first entry with matching certificate,
+ * or null if no such entry exists in this keystore.
+ */
+ public String engineGetCertificateAlias(Certificate cert) {
+
+ for (Map.Entry<String,KeyEntry> mapEntry : entries.entrySet()) {
+ KeyEntry entry = mapEntry.getValue();
+ if (entry.certChain != null &&
+ entry.certChain.length > 0 &&
+ entry.certChain[0].equals(cert)) {
+ return entry.getAlias();
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * engineStore is currently a no-op.
+ * Entries are stored during engineSetEntry.
+ *
+ * A compatibility mode is supported for applications that assume
+ * keystores are stream-based. It permits (but ignores) a non-null
+ * <code>stream</code> or <code>password</code>.
+ * The mode is enabled by default.
+ * Set the
+ * <code>sun.security.mscapi.keyStoreCompatibilityMode</code>
+ * system property to <code>false</code> to disable compatibility mode
+ * and reject a non-null <code>stream</code> or <code>password</code>.
+ *
+ * @param stream the output stream, which should be <code>null</code>
+ * @param password the password, which should be <code>null</code>
+ *
+ * @exception IOException if compatibility mode is disabled and either
+ * parameter is non-null.
+ */
+ public void engineStore(OutputStream stream, char[] password)
+ throws IOException, NoSuchAlgorithmException, CertificateException {
+ if (stream != null && !keyStoreCompatibilityMode) {
+ throw new IOException("Keystore output stream must be null");
+ }
+
+ if (password != null && !keyStoreCompatibilityMode) {
+ throw new IOException("Keystore password must be null");
+ }
+ }
+
+ /**
+ * Loads the keystore.
+ *
+ * A compatibility mode is supported for applications that assume
+ * keystores are stream-based. It permits (but ignores) a non-null
+ * <code>stream</code> or <code>password</code>.
+ * The mode is enabled by default.
+ * Set the
+ * <code>sun.security.mscapi.keyStoreCompatibilityMode</code>
+ * system property to <code>false</code> to disable compatibility mode
+ * and reject a non-null <code>stream</code> or <code>password</code>.
+ *
+ * @param stream the input stream, which should be <code>null</code>.
+ * @param password the password, which should be <code>null</code>.
+ *
+ * @exception IOException if there is an I/O or format problem with the
+ * keystore data. Or if compatibility mode is disabled and either
+ * parameter is non-null.
+ * @exception NoSuchAlgorithmException if the algorithm used to check
+ * the integrity of the keystore cannot be found
+ * @exception CertificateException if any of the certificates in the
+ * keystore could not be loaded
+ * @exception SecurityException if the security check for
+ * <code>SecurityPermission("authProvider.<i>name</i>")</code> does not
+ * pass, where <i>name</i> is the value returned by
+ * this provider's <code>getName</code> method.
+ */
+ public void engineLoad(InputStream stream, char[] password)
+ throws IOException, NoSuchAlgorithmException, CertificateException {
+ if (stream != null && !keyStoreCompatibilityMode) {
+ throw new IOException("Keystore input stream must be null");
+ }
+
+ if (password != null && !keyStoreCompatibilityMode) {
+ throw new IOException("Keystore password must be null");
+ }
+
+ /*
+ * Use the same security check as AuthProvider.login
+ */
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(new SecurityPermission(
+ "authProvider.SunMSCAPI"));
+ }
+
+ // Clear all key entries
+ entries.clear();
+
+ try {
+
+ // Load keys and/or certificate chains
+ loadKeysOrCertificateChains(getName());
+
+ } catch (KeyStoreException e) {
+ throw new IOException(e);
+ }
+ }
+
+ /**
+ * Stores the given entry into the map, making sure
+ * the alias, used as the key is unique.
+ * If the same alias already exists, it tries to append
+ * a suffix (1), (2), etc to it until it finds a unique
+ * value.
+ */
+ private void storeWithUniqueAlias(String alias, KeyEntry entry) {
+ String uniqAlias = alias;
+ int uniqNum = 1;
+
+ while (true) {
+ if (entries.putIfAbsent(uniqAlias, entry) == null) {
+ break;
+ }
+ uniqAlias = alias + " (" + (uniqNum++) + ")";
+ }
+ }
+
+
+ /**
+ * Generates a certificate chain from the collection of
+ * certificates and stores the result into a key entry.
+ * <p>
+ * This method is called by native codes in security.cpp.
+ */
+ private void generateCertificateChain(String alias,
+ Collection<? extends Certificate> certCollection) {
+ try {
+ X509Certificate[] certChain =
+ new X509Certificate[certCollection.size()];
+
+ int i = 0;
+ for (Iterator<? extends Certificate> iter =
+ certCollection.iterator(); iter.hasNext(); i++) {
+ certChain[i] = (X509Certificate) iter.next();
+ }
+
+ storeWithUniqueAlias(alias,
+ new KeyEntry(alias, null, certChain));
+ } catch (Throwable e) {
+ // Ignore the exception and skip this entry
+ // TODO - throw CertificateException?
+ }
+ }
+
+ /**
+ * Generates key and certificate chain from the private key handle,
+ * collection of certificates and stores the result into key entries.
+ * <p>
+ * This method is called by native codes in security.cpp.
+ */
+ private void generateKeyAndCertificateChain(boolean isRSA, String alias,
+ long hCryptProv, long hCryptKey, int keyLength,
+ Collection<? extends Certificate> certCollection) {
+ try {
+ X509Certificate[] certChain =
+ new X509Certificate[certCollection.size()];
+
+ int i = 0;
+ for (Iterator<? extends Certificate> iter =
+ certCollection.iterator(); iter.hasNext(); i++) {
+ certChain[i] = (X509Certificate) iter.next();
+ }
+ storeWithUniqueAlias(alias, new KeyEntry(alias,
+ CPrivateKey.of(isRSA ? "RSA" : "EC", hCryptProv, hCryptKey, keyLength),
+ certChain));
+ } catch (Throwable e) {
+ // Ignore the exception and skip this entry
+ // TODO - throw CertificateException?
+ }
+ }
+
+ /**
+ * Generates certificates from byte data and stores into cert collection.
+ * <p>
+ * This method is called by native codes in security.cpp.
+ *
+ * @param data Byte data.
+ * @param certCollection Collection of certificates.
+ */
+ private void generateCertificate(byte[] data,
+ Collection<Certificate> certCollection) {
+ try {
+ ByteArrayInputStream bis = new ByteArrayInputStream(data);
+
+ // Obtain certificate factory
+ if (certificateFactory == null) {
+ certificateFactory = CertificateFactory.getInstance("X.509", "SUN");
+ }
+
+ // Generate certificate
+ Collection<? extends Certificate> c =
+ certificateFactory.generateCertificates(bis);
+ certCollection.addAll(c);
+ } catch (CertificateException e) {
+ // Ignore the exception and skip this certificate
+ // TODO - throw CertificateException?
+ } catch (Throwable te) {
+ // Ignore the exception and skip this certificate
+ // TODO - throw CertificateException?
+ }
+ }
+
+ /**
+ * Returns the name of the keystore.
+ */
+ private String getName() {
+ return storeName;
+ }
+
+ /**
+ * Load keys and/or certificates from keystore into Collection.
+ *
+ * @param name Name of keystore.
+ */
+ private native void loadKeysOrCertificateChains(String name)
+ throws KeyStoreException;
+
+ /**
+ * Stores a DER-encoded certificate into the certificate store
+ *
+ * @param name Name of the keystore.
+ * @param alias Name of the certificate.
+ * @param encoding DER-encoded certificate.
+ */
+ private native void storeCertificate(String name, String alias,
+ byte[] encoding, int encodingLength, long hCryptProvider,
+ long hCryptKey) throws CertificateException, KeyStoreException;
+
+ /**
+ * Removes the certificate from the certificate store
+ *
+ * @param name Name of the keystore.
+ * @param alias Name of the certificate.
+ * @param encoding DER-encoded certificate.
+ */
+ private native void removeCertificate(String name, String alias,
+ byte[] encoding, int encodingLength)
+ throws CertificateException, KeyStoreException;
+
+ /**
+ * Destroys the key container.
+ *
+ * @param keyContainerName The name of the key container.
+ */
+ private native void destroyKeyContainer(String keyContainerName)
+ throws KeyStoreException;
+
+ /**
+ * Generates a private-key BLOB from a key's components.
+ */
+ private native byte[] generateRSAPrivateKeyBlob(
+ int keyBitLength,
+ byte[] modulus,
+ byte[] publicExponent,
+ byte[] privateExponent,
+ byte[] primeP,
+ byte[] primeQ,
+ byte[] exponentP,
+ byte[] exponentQ,
+ byte[] crtCoefficient) throws InvalidKeyException;
+
+ private native CPrivateKey storePrivateKey(String alg, byte[] keyBlob,
+ String keyContainerName, int keySize) throws KeyStoreException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPrivateKey.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.mscapi;
+
+import java.security.PrivateKey;
+
+/**
+ * The handle for a private key using the Microsoft Crypto API.
+ *
+ * @author Stanley Man-Kit Ho
+ * @since 1.6
+ */
+class CPrivateKey extends CKey implements PrivateKey {
+
+ private static final long serialVersionUID = 8113152807912338063L;
+
+ private CPrivateKey(String alg, long hCryptProv, long hCryptKey, int keyLength) {
+ super(alg, hCryptProv, hCryptKey, keyLength);
+ }
+
+ public static CPrivateKey of(String alg, long hCryptProv, long hCryptKey, int keyLength) {
+ return new CPrivateKey(alg, hCryptProv, hCryptKey, keyLength);
+ }
+
+ // this key does not support encoding
+ public String getFormat() {
+ return null;
+ }
+
+ // this key does not support encoding
+ public byte[] getEncoded() {
+ return null;
+ }
+
+ public String toString() {
+ return algorithm + "PrivateKey [size=" + keyLength + " bits, type=" +
+ getKeyType(handles.hCryptKey) + ", container=" +
+ getContainerName(handles.hCryptProv) + "]";
+ }
+
+ // This class is not serializable
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws java.io.IOException {
+ throw new java.io.NotSerializableException();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPublicKey.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.mscapi;
+
+import java.math.BigInteger;
+import java.security.AlgorithmParameters;
+import java.security.KeyException;
+import java.security.KeyFactory;
+import java.security.KeyRep;
+import java.security.ProviderException;
+import java.security.PublicKey;
+import java.security.interfaces.ECPublicKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECPoint;
+import java.security.spec.ECPublicKeySpec;
+import java.util.Arrays;
+
+import sun.security.rsa.RSAUtil.KeyType;
+import sun.security.rsa.RSAPublicKeyImpl;
+import sun.security.util.ECKeySizeParameterSpec;
+
+/**
+ * The handle for an RSA public key using the Microsoft Crypto API.
+ *
+ * @since 1.6
+ */
+public abstract class CPublicKey extends CKey implements PublicKey {
+
+ private static final long serialVersionUID = -2289561342425825391L;
+
+ protected byte[] encoding = null;
+
+ public static class CECPublicKey extends CPublicKey implements ECPublicKey {
+
+ private ECPoint w = null;
+ private static final long serialVersionUID = 12L;
+
+ CECPublicKey(long hCryptProv, int keyLength) {
+ super("EC", hCryptProv, 0, keyLength);
+ }
+
+ @Override
+ public ECPoint getW() {
+ if (w == null) {
+ // See CKey::generateECBlob.
+ try {
+ byte[] blob = getPublicKeyBlob(
+ handles.hCryptProv, handles.hCryptKey);
+ int len = blob[8] & 0xff;
+ byte[] x = Arrays.copyOfRange(blob, 8, 8 + len);
+ byte[] y = Arrays.copyOfRange(blob, 8 + len, 8 + len + len);
+ w = new ECPoint(new BigInteger(1, x), new BigInteger(1, y));
+ } catch (KeyException e) {
+ throw new ProviderException(e);
+ }
+ }
+ return w;
+ }
+
+ @Override
+ public byte[] getEncoded() {
+ if (encoding == null) {
+ try {
+ encoding = KeyFactory.getInstance("EC").generatePublic(
+ new ECPublicKeySpec(getW(), getParams()))
+ .getEncoded();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ return encoding;
+ }
+
+ @Override
+ public ECParameterSpec getParams() {
+ try {
+ AlgorithmParameters ap = AlgorithmParameters.getInstance("EC");
+ ap.init(new ECKeySizeParameterSpec(keyLength));
+ return ap.getParameterSpec(ECParameterSpec.class);
+ } catch (Exception e) {
+ throw new ProviderException(e);
+ }
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(algorithm + "PublicKey [size=").append(keyLength)
+ .append("]\n ECPoint: ").append(getW())
+ .append("\n params: ").append(getParams());
+ return sb.toString();
+ }
+ }
+
+ public static class CRSAPublicKey extends CPublicKey implements RSAPublicKey {
+
+ private BigInteger modulus = null;
+ private BigInteger exponent = null;
+ private static final long serialVersionUID = 12L;
+
+ CRSAPublicKey(long hCryptProv, long hCryptKey, int keyLength) {
+ super("RSA", hCryptProv, hCryptKey, keyLength);
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(algorithm + "PublicKey [size=").append(keyLength)
+ .append(" bits, type=").append(getKeyType(handles.hCryptKey))
+ .append(", container=").append(getContainerName(handles.hCryptProv))
+ .append("]\n modulus: ").append(getModulus())
+ .append("\n public exponent: ").append(getPublicExponent());
+ return sb.toString();
+ }
+
+ @Override
+ public BigInteger getPublicExponent() {
+ if (exponent == null) {
+ try {
+ byte[] publicKeyBlob = getPublicKeyBlob(
+ handles.hCryptProv, handles.hCryptKey);
+ exponent = new BigInteger(1, getExponent(publicKeyBlob));
+ } catch (KeyException e) {
+ throw new ProviderException(e);
+ }
+ }
+ return exponent;
+ }
+
+ @Override
+ public BigInteger getModulus() {
+ if (modulus == null) {
+ try {
+ byte[] publicKeyBlob = getPublicKeyBlob(
+ handles.hCryptProv, handles.hCryptKey);
+ modulus = new BigInteger(1, getModulus(publicKeyBlob));
+ } catch (KeyException e) {
+ throw new ProviderException(e);
+ }
+ }
+ return modulus;
+ }
+
+ @Override
+ public byte[] getEncoded() {
+ if (encoding == null) {
+ try {
+ encoding = RSAPublicKeyImpl.newKey(KeyType.RSA, null,
+ getModulus(), getPublicExponent()).getEncoded();
+ } catch (KeyException e) {
+ // ignore
+ }
+ }
+ return encoding;
+ }
+
+ private native byte[] getExponent(byte[] keyBlob) throws KeyException;
+
+ private native byte[] getModulus(byte[] keyBlob) throws KeyException;
+ }
+
+ public static CPublicKey of(
+ String alg, long hCryptProv, long hCryptKey, int keyLength) {
+ switch (alg) {
+ case "RSA":
+ return new CRSAPublicKey(hCryptProv, hCryptKey, keyLength);
+ case "EC":
+ return new CECPublicKey(hCryptProv, keyLength);
+ default:
+ throw new AssertionError("Unsupported algorithm: " + alg);
+ }
+ }
+
+ protected CPublicKey(
+ String alg, long hCryptProv, long hCryptKey, int keyLength) {
+ super(alg, hCryptProv, hCryptKey, keyLength);
+ }
+
+ @Override
+ public String getFormat() {
+ return "X.509";
+ }
+
+ protected Object writeReplace() throws java.io.ObjectStreamException {
+ return new KeyRep(KeyRep.Type.PUBLIC,
+ getAlgorithm(),
+ getFormat(),
+ getEncoded());
+ }
+
+ // Returns the CAPI or CNG representation of the key.
+ native byte[] getPublicKeyBlob(long hCryptProv, long hCryptKey)
+ throws KeyException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CRSACipher.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,501 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.mscapi;
+
+import java.math.BigInteger;
+import java.security.*;
+import java.security.Key;
+import java.security.interfaces.*;
+import java.security.spec.*;
+
+import javax.crypto.*;
+import javax.crypto.spec.*;
+
+import sun.security.rsa.RSAKeyFactory;
+import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
+import sun.security.util.KeyUtil;
+
+/**
+ * Cipher implementation using the Microsoft Crypto API.
+ * Supports RSA en/decryption and signing/verifying using PKCS#1 v1.5 padding.
+ *
+ * Objects should be instantiated by calling Cipher.getInstance() using the
+ * following algorithm name:
+ *
+ * . "RSA/ECB/PKCS1Padding" (or "RSA") for PKCS#1 padding. The mode (blocktype)
+ * is selected based on the en/decryption mode and public/private key used.
+ *
+ * We only do one RSA operation per doFinal() call. If the application passes
+ * more data via calls to update() or doFinal(), we throw an
+ * IllegalBlockSizeException when doFinal() is called (see JCE API spec).
+ * Bulk encryption using RSA does not make sense and is not standardized.
+ *
+ * Note: RSA keys should be at least 512 bits long
+ *
+ * @since 1.6
+ * @author Andreas Sterbenz
+ * @author Vincent Ryan
+ */
+public final class CRSACipher extends CipherSpi {
+
+ // constant for an empty byte array
+ private final static byte[] B0 = new byte[0];
+
+ // mode constant for public key encryption
+ private final static int MODE_ENCRYPT = 1;
+ // mode constant for private key decryption
+ private final static int MODE_DECRYPT = 2;
+ // mode constant for private key encryption (signing)
+ private final static int MODE_SIGN = 3;
+ // mode constant for public key decryption (verifying)
+ private final static int MODE_VERIFY = 4;
+
+ // constant for PKCS#1 v1.5 RSA
+ private final static String PAD_PKCS1 = "PKCS1Padding";
+ private final static int PAD_PKCS1_LENGTH = 11;
+
+ // current mode, one of MODE_* above. Set when init() is called
+ private int mode;
+
+ // active padding type, one of PAD_* above. Set by setPadding()
+ private String paddingType;
+ private int paddingLength = 0;
+
+ // buffer for the data
+ private byte[] buffer;
+ // offset into the buffer (number of bytes buffered)
+ private int bufOfs;
+
+ // size of the output (the length of the key).
+ private int outputSize;
+
+ // the public key, if we were initialized using a public key
+ private CKey publicKey;
+
+ // the private key, if we were initialized using a private key
+ private CKey privateKey;
+
+ // cipher parameter for TLS RSA premaster secret
+ private AlgorithmParameterSpec spec = null;
+
+ // the source of randomness
+ private SecureRandom random;
+
+ public CRSACipher() {
+ paddingType = PAD_PKCS1;
+ }
+
+ // modes do not make sense for RSA, but allow ECB
+ // see JCE spec
+ protected void engineSetMode(String mode) throws NoSuchAlgorithmException {
+ if (mode.equalsIgnoreCase("ECB") == false) {
+ throw new NoSuchAlgorithmException("Unsupported mode " + mode);
+ }
+ }
+
+ // set the padding type
+ // see JCE spec
+ protected void engineSetPadding(String paddingName)
+ throws NoSuchPaddingException {
+ if (paddingName.equalsIgnoreCase(PAD_PKCS1)) {
+ paddingType = PAD_PKCS1;
+ } else {
+ throw new NoSuchPaddingException
+ ("Padding " + paddingName + " not supported");
+ }
+ }
+
+ // return 0 as block size, we are not a block cipher
+ // see JCE spec
+ protected int engineGetBlockSize() {
+ return 0;
+ }
+
+ // return the output size
+ // see JCE spec
+ protected int engineGetOutputSize(int inputLen) {
+ return outputSize;
+ }
+
+ // no iv, return null
+ // see JCE spec
+ protected byte[] engineGetIV() {
+ return null;
+ }
+
+ // no parameters, return null
+ // see JCE spec
+ protected AlgorithmParameters engineGetParameters() {
+ return null;
+ }
+
+ // see JCE spec
+ protected void engineInit(int opmode, Key key, SecureRandom random)
+ throws InvalidKeyException {
+ init(opmode, key);
+ }
+
+ // see JCE spec
+ @SuppressWarnings("deprecation")
+ protected void engineInit(int opmode, Key key,
+ AlgorithmParameterSpec params, SecureRandom random)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+
+ if (params != null) {
+ if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
+ throw new InvalidAlgorithmParameterException(
+ "Parameters not supported");
+ }
+ spec = params;
+ this.random = random; // for TLS RSA premaster secret
+ }
+ init(opmode, key);
+ }
+
+ // see JCE spec
+ protected void engineInit(int opmode, Key key,
+ AlgorithmParameters params, SecureRandom random)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+
+ if (params != null) {
+ throw new InvalidAlgorithmParameterException
+ ("Parameters not supported");
+ }
+ init(opmode, key);
+ }
+
+ // initialize this cipher
+ private void init(int opmode, Key key) throws InvalidKeyException {
+
+ boolean encrypt;
+
+ switch (opmode) {
+ case Cipher.ENCRYPT_MODE:
+ case Cipher.WRAP_MODE:
+ paddingLength = PAD_PKCS1_LENGTH;
+ encrypt = true;
+ break;
+ case Cipher.DECRYPT_MODE:
+ case Cipher.UNWRAP_MODE:
+ paddingLength = 0; // reset
+ encrypt = false;
+ break;
+ default:
+ throw new InvalidKeyException("Unknown mode: " + opmode);
+ }
+
+ if (!(key instanceof CKey)) {
+ if (key instanceof java.security.interfaces.RSAPublicKey) {
+ java.security.interfaces.RSAPublicKey rsaKey =
+ (java.security.interfaces.RSAPublicKey) key;
+
+ // Convert key to MSCAPI format
+
+ BigInteger modulus = rsaKey.getModulus();
+ BigInteger exponent = rsaKey.getPublicExponent();
+
+ // Check against the local and global values to make sure
+ // the sizes are ok. Round up to the nearest byte.
+ RSAKeyFactory.checkKeyLengths(((modulus.bitLength() + 7) & ~7),
+ exponent, -1, CKeyPairGenerator.RSA.KEY_SIZE_MAX);
+
+ byte[] modulusBytes = modulus.toByteArray();
+ byte[] exponentBytes = exponent.toByteArray();
+
+ // Adjust key length due to sign bit
+ int keyBitLength = (modulusBytes[0] == 0)
+ ? (modulusBytes.length - 1) * 8
+ : modulusBytes.length * 8;
+
+ byte[] keyBlob = CSignature.RSA.generatePublicKeyBlob(
+ keyBitLength, modulusBytes, exponentBytes);
+
+ try {
+ key = CSignature.importPublicKey("RSA", keyBlob, keyBitLength);
+
+ } catch (KeyStoreException e) {
+ throw new InvalidKeyException(e);
+ }
+
+ } else {
+ throw new InvalidKeyException("Unsupported key type: " + key);
+ }
+ }
+
+ if (key instanceof PublicKey) {
+ mode = encrypt ? MODE_ENCRYPT : MODE_VERIFY;
+ publicKey = (CKey)key;
+ privateKey = null;
+ outputSize = publicKey.length() / 8;
+ } else if (key instanceof PrivateKey) {
+ mode = encrypt ? MODE_SIGN : MODE_DECRYPT;
+ privateKey = (CKey)key;
+ publicKey = null;
+ outputSize = privateKey.length() / 8;
+ } else {
+ throw new InvalidKeyException("Unknown key type: " + key);
+ }
+
+ bufOfs = 0;
+ buffer = new byte[outputSize];
+ }
+
+ // internal update method
+ private void update(byte[] in, int inOfs, int inLen) {
+ if ((inLen == 0) || (in == null)) {
+ return;
+ }
+ if (bufOfs + inLen > (buffer.length - paddingLength)) {
+ bufOfs = buffer.length + 1;
+ return;
+ }
+ System.arraycopy(in, inOfs, buffer, bufOfs, inLen);
+ bufOfs += inLen;
+ }
+
+ // internal doFinal() method. Here we perform the actual RSA operation
+ private byte[] doFinal() throws BadPaddingException,
+ IllegalBlockSizeException {
+ if (bufOfs > buffer.length) {
+ throw new IllegalBlockSizeException("Data must not be longer "
+ + "than " + (buffer.length - paddingLength) + " bytes");
+ }
+
+ try {
+ byte[] data = buffer;
+ switch (mode) {
+ case MODE_SIGN:
+ return encryptDecrypt(data, bufOfs,
+ privateKey.getHCryptKey(), true);
+
+ case MODE_VERIFY:
+ return encryptDecrypt(data, bufOfs,
+ publicKey.getHCryptKey(), false);
+
+ case MODE_ENCRYPT:
+ return encryptDecrypt(data, bufOfs,
+ publicKey.getHCryptKey(), true);
+
+ case MODE_DECRYPT:
+ return encryptDecrypt(data, bufOfs,
+ privateKey.getHCryptKey(), false);
+
+ default:
+ throw new AssertionError("Internal error");
+ }
+
+ } catch (KeyException e) {
+ throw new ProviderException(e);
+
+ } finally {
+ bufOfs = 0;
+ }
+ }
+
+ // see JCE spec
+ protected byte[] engineUpdate(byte[] in, int inOfs, int inLen) {
+ update(in, inOfs, inLen);
+ return B0;
+ }
+
+ // see JCE spec
+ protected int engineUpdate(byte[] in, int inOfs, int inLen, byte[] out,
+ int outOfs) {
+ update(in, inOfs, inLen);
+ return 0;
+ }
+
+ // see JCE spec
+ protected byte[] engineDoFinal(byte[] in, int inOfs, int inLen)
+ throws BadPaddingException, IllegalBlockSizeException {
+ update(in, inOfs, inLen);
+ return doFinal();
+ }
+
+ // see JCE spec
+ protected int engineDoFinal(byte[] in, int inOfs, int inLen, byte[] out,
+ int outOfs) throws ShortBufferException, BadPaddingException,
+ IllegalBlockSizeException {
+ if (outputSize > out.length - outOfs) {
+ throw new ShortBufferException
+ ("Need " + outputSize + " bytes for output");
+ }
+ update(in, inOfs, inLen);
+ byte[] result = doFinal();
+ int n = result.length;
+ System.arraycopy(result, 0, out, outOfs, n);
+ return n;
+ }
+
+ // see JCE spec
+ protected byte[] engineWrap(Key key) throws InvalidKeyException,
+ IllegalBlockSizeException {
+ byte[] encoded = key.getEncoded(); // TODO - unextractable key
+ if ((encoded == null) || (encoded.length == 0)) {
+ throw new InvalidKeyException("Could not obtain encoded key");
+ }
+ if (encoded.length > buffer.length) {
+ throw new InvalidKeyException("Key is too long for wrapping");
+ }
+ update(encoded, 0, encoded.length);
+ try {
+ return doFinal();
+ } catch (BadPaddingException e) {
+ // should not occur
+ throw new InvalidKeyException("Wrapping failed", e);
+ }
+ }
+
+ // see JCE spec
+ @SuppressWarnings("deprecation")
+ protected java.security.Key engineUnwrap(byte[] wrappedKey,
+ String algorithm,
+ int type) throws InvalidKeyException, NoSuchAlgorithmException {
+
+ if (wrappedKey.length > buffer.length) {
+ throw new InvalidKeyException("Key is too long for unwrapping");
+ }
+
+ boolean isTlsRsaPremasterSecret =
+ algorithm.equals("TlsRsaPremasterSecret");
+ Exception failover = null;
+ byte[] encoded = null;
+
+ update(wrappedKey, 0, wrappedKey.length);
+ try {
+ encoded = doFinal();
+ } catch (BadPaddingException e) {
+ if (isTlsRsaPremasterSecret) {
+ failover = e;
+ } else {
+ throw new InvalidKeyException("Unwrapping failed", e);
+ }
+ } catch (IllegalBlockSizeException e) {
+ // should not occur, handled with length check above
+ throw new InvalidKeyException("Unwrapping failed", e);
+ }
+
+ if (isTlsRsaPremasterSecret) {
+ if (!(spec instanceof TlsRsaPremasterSecretParameterSpec)) {
+ throw new IllegalStateException(
+ "No TlsRsaPremasterSecretParameterSpec specified");
+ }
+
+ // polish the TLS premaster secret
+ encoded = KeyUtil.checkTlsPreMasterSecretKey(
+ ((TlsRsaPremasterSecretParameterSpec)spec).getClientVersion(),
+ ((TlsRsaPremasterSecretParameterSpec)spec).getServerVersion(),
+ random, encoded, (failover != null));
+ }
+
+ return constructKey(encoded, algorithm, type);
+ }
+
+ // see JCE spec
+ protected int engineGetKeySize(Key key) throws InvalidKeyException {
+
+ if (key instanceof CKey) {
+ return ((CKey) key).length();
+
+ } else if (key instanceof RSAKey) {
+ return ((RSAKey) key).getModulus().bitLength();
+
+ } else {
+ throw new InvalidKeyException("Unsupported key type: " + key);
+ }
+ }
+
+ // Construct an X.509 encoded public key.
+ private static PublicKey constructPublicKey(byte[] encodedKey,
+ String encodedKeyAlgorithm)
+ throws InvalidKeyException, NoSuchAlgorithmException {
+
+ try {
+ KeyFactory keyFactory = KeyFactory.getInstance(encodedKeyAlgorithm);
+ X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encodedKey);
+
+ return keyFactory.generatePublic(keySpec);
+
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new NoSuchAlgorithmException("No installed provider " +
+ "supports the " + encodedKeyAlgorithm + " algorithm", nsae);
+
+ } catch (InvalidKeySpecException ike) {
+ throw new InvalidKeyException("Cannot construct public key", ike);
+ }
+ }
+
+ // Construct a PKCS #8 encoded private key.
+ private static PrivateKey constructPrivateKey(byte[] encodedKey,
+ String encodedKeyAlgorithm)
+ throws InvalidKeyException, NoSuchAlgorithmException {
+
+ try {
+ KeyFactory keyFactory = KeyFactory.getInstance(encodedKeyAlgorithm);
+ PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey);
+
+ return keyFactory.generatePrivate(keySpec);
+
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new NoSuchAlgorithmException("No installed provider " +
+ "supports the " + encodedKeyAlgorithm + " algorithm", nsae);
+
+ } catch (InvalidKeySpecException ike) {
+ throw new InvalidKeyException("Cannot construct private key", ike);
+ }
+ }
+
+ // Construct an encoded secret key.
+ private static SecretKey constructSecretKey(byte[] encodedKey,
+ String encodedKeyAlgorithm) {
+
+ return new SecretKeySpec(encodedKey, encodedKeyAlgorithm);
+ }
+
+ private static Key constructKey(byte[] encodedKey,
+ String encodedKeyAlgorithm,
+ int keyType) throws InvalidKeyException, NoSuchAlgorithmException {
+
+ switch (keyType) {
+ case Cipher.PUBLIC_KEY:
+ return constructPublicKey(encodedKey, encodedKeyAlgorithm);
+ case Cipher.PRIVATE_KEY:
+ return constructPrivateKey(encodedKey, encodedKeyAlgorithm);
+ case Cipher.SECRET_KEY:
+ return constructSecretKey(encodedKey, encodedKeyAlgorithm);
+ default:
+ throw new InvalidKeyException("Unknown key type " + keyType);
+ }
+ }
+
+ /*
+ * Encrypt/decrypt a data buffer using Microsoft Crypto API with HCRYPTKEY.
+ * It expects and returns ciphertext data in big-endian form.
+ */
+ private native static byte[] encryptDecrypt(byte[] data, int dataSize,
+ long hCryptKey, boolean doEncrypt) throws KeyException;
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CSignature.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,920 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.mscapi;
+
+import java.nio.ByteBuffer;
+import java.security.*;
+import java.security.interfaces.ECPublicKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.AlgorithmParameterSpec;
+import java.math.BigInteger;
+import java.security.spec.MGF1ParameterSpec;
+import java.security.spec.PSSParameterSpec;
+import java.util.Locale;
+
+import sun.security.rsa.RSAKeyFactory;
+import sun.security.util.ECUtil;
+import sun.security.util.KeyUtil;
+
+/**
+ * Signature implementation.
+ *
+ * Objects should be instantiated by calling Signature.getInstance() using the
+ * following algorithm names:
+ *
+ * . "NONEwithRSA"
+ * . "SHA1withRSA"
+ * . "SHA256withRSA"
+ * . "SHA384withRSA"
+ * . "SHA512withRSA"
+ * . "MD5withRSA"
+ * . "MD2withRSA"
+ * . "RSASSA-PSS"
+ * . "SHA1withECDSA"
+ * . "SHA224withECDSA"
+ * . "SHA256withECDSA"
+ * . "SHA384withECDSA"
+ * . "SHA512withECDSA"
+ *
+ * NOTE: RSA keys must be at least 512 bits long.
+ *
+ * NOTE: NONEwithRSA must be supplied with a pre-computed message digest.
+ * Only the following digest algorithms are supported: MD5, SHA-1,
+ * SHA-256, SHA-384, SHA-512 and a special-purpose digest
+ * algorithm which is a concatenation of SHA-1 and MD5 digests.
+ *
+ * @since 1.6
+ * @author Stanley Man-Kit Ho
+ */
+abstract class CSignature extends SignatureSpi {
+ // private key algorithm name
+ protected String keyAlgorithm;
+
+ // message digest implementation we use
+ protected MessageDigest messageDigest;
+
+ // message digest name
+ protected String messageDigestAlgorithm;
+
+ // flag indicating whether the digest has been reset
+ protected boolean needsReset;
+
+ // the signing key
+ protected CPrivateKey privateKey = null;
+
+ // the verification key
+ protected CPublicKey publicKey = null;
+
+ /**
+ * Constructs a new CSignature. Used by subclasses.
+ */
+ CSignature(String keyName, String digestName) {
+
+ this.keyAlgorithm = keyName;
+ if (digestName != null) {
+ try {
+ messageDigest = MessageDigest.getInstance(digestName);
+ // Get the digest's canonical name
+ messageDigestAlgorithm = messageDigest.getAlgorithm();
+ } catch (NoSuchAlgorithmException e) {
+ throw new ProviderException(e);
+ }
+ } else {
+ messageDigest = null;
+ messageDigestAlgorithm = null;
+ }
+ needsReset = false;
+ }
+
+ static class RSA extends CSignature {
+
+ public RSA(String digestAlgorithm) {
+ super("RSA", digestAlgorithm);
+ }
+
+ // initialize for signing. See JCA doc
+ @Override
+ protected void engineInitSign(PrivateKey key) throws InvalidKeyException {
+
+ if ((key instanceof CPrivateKey) == false
+ || !key.getAlgorithm().equalsIgnoreCase("RSA")) {
+ throw new InvalidKeyException("Key type not supported");
+ }
+ privateKey = (CPrivateKey) key;
+
+ // Check against the local and global values to make sure
+ // the sizes are ok. Round up to nearest byte.
+ RSAKeyFactory.checkKeyLengths(((privateKey.length() + 7) & ~7),
+ null, CKeyPairGenerator.RSA.KEY_SIZE_MIN,
+ CKeyPairGenerator.RSA.KEY_SIZE_MAX);
+
+ this.publicKey = null;
+ resetDigest();
+ }
+
+ // initialize for signing. See JCA doc
+ @Override
+ protected void engineInitVerify(PublicKey key) throws InvalidKeyException {
+ // This signature accepts only RSAPublicKey
+ if ((key instanceof RSAPublicKey) == false) {
+ throw new InvalidKeyException("Key type not supported");
+ }
+
+
+ if ((key instanceof CPublicKey) == false) {
+
+ // convert key to MSCAPI format
+ java.security.interfaces.RSAPublicKey rsaKey =
+ (java.security.interfaces.RSAPublicKey) key;
+
+ BigInteger modulus = rsaKey.getModulus();
+ BigInteger exponent = rsaKey.getPublicExponent();
+
+ // Check against the local and global values to make sure
+ // the sizes are ok. Round up to the nearest byte.
+ RSAKeyFactory.checkKeyLengths(((modulus.bitLength() + 7) & ~7),
+ exponent, -1, CKeyPairGenerator.RSA.KEY_SIZE_MAX);
+
+ byte[] modulusBytes = modulus.toByteArray();
+ byte[] exponentBytes = exponent.toByteArray();
+
+ // Adjust key length due to sign bit
+ int keyBitLength = (modulusBytes[0] == 0)
+ ? (modulusBytes.length - 1) * 8
+ : modulusBytes.length * 8;
+
+ byte[] keyBlob = generatePublicKeyBlob(
+ keyBitLength, modulusBytes, exponentBytes);
+
+ try {
+ publicKey = importPublicKey("RSA", keyBlob, keyBitLength);
+
+ } catch (KeyStoreException e) {
+ throw new InvalidKeyException(e);
+ }
+
+ } else {
+ publicKey = (CPublicKey) key;
+ }
+
+ this.privateKey = null;
+ resetDigest();
+ }
+
+ /**
+ * Returns the signature bytes of all the data
+ * updated so far.
+ * The format of the signature depends on the underlying
+ * signature scheme.
+ *
+ * @return the signature bytes of the signing operation's result.
+ *
+ * @exception SignatureException if the engine is not
+ * initialized properly or if this signature algorithm is unable to
+ * process the input data provided.
+ */
+ @Override
+ protected byte[] engineSign() throws SignatureException {
+
+ byte[] hash = getDigestValue();
+
+ // Omit the hash OID when generating a NONEwithRSA signature
+ boolean noHashOID = this instanceof NONEwithRSA;
+
+ // Sign hash using MS Crypto APIs
+ byte[] result = signHash(noHashOID, hash, hash.length,
+ messageDigestAlgorithm, privateKey.getHCryptProvider(),
+ privateKey.getHCryptKey());
+
+ // Convert signature array from little endian to big endian
+ return convertEndianArray(result);
+ }
+
+ /**
+ * Verifies the passed-in signature.
+ *
+ * @param sigBytes the signature bytes to be verified.
+ *
+ * @return true if the signature was verified, false if not.
+ *
+ * @exception SignatureException if the engine is not
+ * initialized properly, the passed-in signature is improperly
+ * encoded or of the wrong type, if this signature algorithm is unable to
+ * process the input data provided, etc.
+ */
+ @Override
+ protected boolean engineVerify(byte[] sigBytes)
+ throws SignatureException {
+ byte[] hash = getDigestValue();
+
+ return verifySignedHash(hash, hash.length,
+ messageDigestAlgorithm, convertEndianArray(sigBytes),
+ sigBytes.length, publicKey.getHCryptProvider(),
+ publicKey.getHCryptKey());
+ }
+
+ /**
+ * Generates a public-key BLOB from a key's components.
+ */
+ // used by CRSACipher
+ static native byte[] generatePublicKeyBlob(
+ int keyBitLength, byte[] modulus, byte[] publicExponent)
+ throws InvalidKeyException;
+
+ }
+
+ // Nested class for NONEwithRSA signatures
+ public static final class NONEwithRSA extends RSA {
+
+ // the longest supported digest is 512 bits (SHA-512)
+ private static final int RAW_RSA_MAX = 64;
+
+ private final byte[] precomputedDigest;
+ private int offset = 0;
+
+ public NONEwithRSA() {
+ super(null);
+ precomputedDigest = new byte[RAW_RSA_MAX];
+ }
+
+ // Stores the precomputed message digest value.
+ @Override
+ protected void engineUpdate(byte b) throws SignatureException {
+ if (offset >= precomputedDigest.length) {
+ offset = RAW_RSA_MAX + 1;
+ return;
+ }
+ precomputedDigest[offset++] = b;
+ }
+
+ // Stores the precomputed message digest value.
+ @Override
+ protected void engineUpdate(byte[] b, int off, int len)
+ throws SignatureException {
+ if (len > (precomputedDigest.length - offset)) {
+ offset = RAW_RSA_MAX + 1;
+ return;
+ }
+ System.arraycopy(b, off, precomputedDigest, offset, len);
+ offset += len;
+ }
+
+ // Stores the precomputed message digest value.
+ @Override
+ protected void engineUpdate(ByteBuffer byteBuffer) {
+ int len = byteBuffer.remaining();
+ if (len <= 0) {
+ return;
+ }
+ if (len > (precomputedDigest.length - offset)) {
+ offset = RAW_RSA_MAX + 1;
+ return;
+ }
+ byteBuffer.get(precomputedDigest, offset, len);
+ offset += len;
+ }
+
+ @Override
+ protected void resetDigest(){
+ offset = 0;
+ }
+
+ // Returns the precomputed message digest value.
+ @Override
+ protected byte[] getDigestValue() throws SignatureException {
+ if (offset > RAW_RSA_MAX) {
+ throw new SignatureException("Message digest is too long");
+ }
+
+ // Determine the digest algorithm from the digest length
+ if (offset == 20) {
+ setDigestName("SHA1");
+ } else if (offset == 36) {
+ setDigestName("SHA1+MD5");
+ } else if (offset == 32) {
+ setDigestName("SHA-256");
+ } else if (offset == 48) {
+ setDigestName("SHA-384");
+ } else if (offset == 64) {
+ setDigestName("SHA-512");
+ } else if (offset == 16) {
+ setDigestName("MD5");
+ } else {
+ throw new SignatureException(
+ "Message digest length is not supported");
+ }
+
+ byte[] result = new byte[offset];
+ System.arraycopy(precomputedDigest, 0, result, 0, offset);
+ offset = 0;
+
+ return result;
+ }
+ }
+
+ public static final class SHA1withRSA extends RSA {
+ public SHA1withRSA() {
+ super("SHA1");
+ }
+ }
+
+ public static final class SHA256withRSA extends RSA {
+ public SHA256withRSA() {
+ super("SHA-256");
+ }
+ }
+
+ public static final class SHA384withRSA extends RSA {
+ public SHA384withRSA() {
+ super("SHA-384");
+ }
+ }
+
+ public static final class SHA512withRSA extends RSA {
+ public SHA512withRSA() {
+ super("SHA-512");
+ }
+ }
+
+ public static final class MD5withRSA extends RSA {
+ public MD5withRSA() {
+ super("MD5");
+ }
+ }
+
+ public static final class MD2withRSA extends RSA {
+ public MD2withRSA() {
+ super("MD2");
+ }
+ }
+
+ public static final class SHA1withECDSA extends ECDSA {
+ public SHA1withECDSA() {
+ super("SHA-1");
+ }
+ }
+
+ public static final class SHA224withECDSA extends ECDSA {
+ public SHA224withECDSA() {
+ super("SHA-224");
+ }
+ }
+
+ public static final class SHA256withECDSA extends ECDSA {
+ public SHA256withECDSA() {
+ super("SHA-256");
+ }
+ }
+
+ public static final class SHA384withECDSA extends ECDSA {
+ public SHA384withECDSA() {
+ super("SHA-384");
+ }
+ }
+
+ public static final class SHA512withECDSA extends ECDSA {
+ public SHA512withECDSA() {
+ super("SHA-512");
+ }
+ }
+
+ static class ECDSA extends CSignature {
+
+ public ECDSA(String messageDigestAlgorithm) {
+ super("EC", messageDigestAlgorithm);
+ }
+
+ // initialize for signing. See JCA doc
+ @Override
+ protected void engineInitSign(PrivateKey key) throws InvalidKeyException {
+ if ((key instanceof CPrivateKey) == false
+ || !key.getAlgorithm().equalsIgnoreCase("EC")) {
+ throw new InvalidKeyException("Key type not supported");
+ }
+ privateKey = (CPrivateKey) key;
+
+ this.publicKey = null;
+ resetDigest();
+ }
+
+ // initialize for signing. See JCA doc
+ @Override
+ protected void engineInitVerify(PublicKey key) throws InvalidKeyException {
+ // This signature accepts only ECPublicKey
+ if ((key instanceof ECPublicKey) == false) {
+ throw new InvalidKeyException("Key type not supported");
+ }
+
+
+ if ((key instanceof CPublicKey) == false) {
+ try {
+ publicKey = importECPublicKey("EC",
+ CKey.generateECBlob(key),
+ KeyUtil.getKeySize(key));
+ } catch (KeyStoreException e) {
+ throw new InvalidKeyException(e);
+ }
+ } else {
+ publicKey = (CPublicKey) key;
+ }
+
+ this.privateKey = null;
+ resetDigest();
+ }
+
+ @Override
+ protected byte[] engineSign() throws SignatureException {
+ byte[] hash = getDigestValue();
+ byte[] raw = signCngHash(0, hash, hash.length,
+ 0,
+ null,
+ privateKey.getHCryptProvider(), 0);
+ return ECUtil.encodeSignature(raw);
+ }
+
+ @Override
+ protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
+ byte[] hash = getDigestValue();
+ sigBytes = ECUtil.decodeSignature(sigBytes);
+ return verifyCngSignedHash(
+ 0,
+ hash, hash.length,
+ sigBytes, sigBytes.length,
+ 0,
+ null,
+ publicKey.getHCryptProvider(),
+ 0
+ );
+ }
+ }
+
+ public static final class PSS extends RSA {
+
+ private PSSParameterSpec pssParams = null;
+
+ // Workaround: Cannot import raw public key to CNG. This signature
+ // will be used for verification if key is not from MSCAPI.
+ private Signature fallbackSignature;
+
+ public PSS() {
+ super(null);
+ }
+
+ @Override
+ protected void engineInitSign(PrivateKey key) throws InvalidKeyException {
+ super.engineInitSign(key);
+ fallbackSignature = null;
+ }
+
+ @Override
+ protected void engineInitVerify(PublicKey key) throws InvalidKeyException {
+ // This signature accepts only RSAPublicKey
+ if ((key instanceof java.security.interfaces.RSAPublicKey) == false) {
+ throw new InvalidKeyException("Key type not supported");
+ }
+
+ this.privateKey = null;
+
+ if (key instanceof CPublicKey) {
+ fallbackSignature = null;
+ publicKey = (CPublicKey) key;
+ } else {
+ if (fallbackSignature == null) {
+ try {
+ fallbackSignature = Signature.getInstance(
+ "RSASSA-PSS", "SunRsaSign");
+ } catch (NoSuchAlgorithmException | NoSuchProviderException e) {
+ throw new InvalidKeyException("Invalid key", e);
+ }
+ }
+ fallbackSignature.initVerify(key);
+ if (pssParams != null) {
+ try {
+ fallbackSignature.setParameter(pssParams);
+ } catch (InvalidAlgorithmParameterException e) {
+ throw new InvalidKeyException("Invalid params", e);
+ }
+ }
+ publicKey = null;
+ }
+ resetDigest();
+ }
+
+ @Override
+ protected void engineUpdate(byte b) throws SignatureException {
+ ensureInit();
+ if (fallbackSignature != null) {
+ fallbackSignature.update(b);
+ } else {
+ messageDigest.update(b);
+ }
+ needsReset = true;
+ }
+
+ @Override
+ protected void engineUpdate(byte[] b, int off, int len) throws SignatureException {
+ ensureInit();
+ if (fallbackSignature != null) {
+ fallbackSignature.update(b, off, len);
+ } else {
+ messageDigest.update(b, off, len);
+ }
+ needsReset = true;
+ }
+
+ @Override
+ protected void engineUpdate(ByteBuffer input) {
+ try {
+ ensureInit();
+ } catch (SignatureException se) {
+ // hack for working around API bug
+ throw new RuntimeException(se.getMessage());
+ }
+ if (fallbackSignature != null) {
+ try {
+ fallbackSignature.update(input);
+ } catch (SignatureException se) {
+ // hack for working around API bug
+ throw new RuntimeException(se.getMessage());
+ }
+ } else {
+ messageDigest.update(input);
+ }
+ needsReset = true;
+ }
+
+ @Override
+ protected byte[] engineSign() throws SignatureException {
+ ensureInit();
+ byte[] hash = getDigestValue();
+ return signCngHash(2, hash, hash.length,
+ pssParams.getSaltLength(),
+ ((MGF1ParameterSpec)
+ pssParams.getMGFParameters()).getDigestAlgorithm(),
+ privateKey.getHCryptProvider(), privateKey.getHCryptKey());
+ }
+
+ @Override
+ protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
+ ensureInit();
+ if (fallbackSignature != null) {
+ needsReset = false;
+ return fallbackSignature.verify(sigBytes);
+ } else {
+ byte[] hash = getDigestValue();
+ return verifyCngSignedHash(
+ 2, hash, hash.length,
+ sigBytes, sigBytes.length,
+ pssParams.getSaltLength(),
+ ((MGF1ParameterSpec)
+ pssParams.getMGFParameters()).getDigestAlgorithm(),
+ publicKey.getHCryptProvider(),
+ publicKey.getHCryptKey()
+ );
+ }
+ }
+
+ @Override
+ protected void engineSetParameter(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException {
+ if (needsReset) {
+ throw new ProviderException
+ ("Cannot set parameters during operations");
+ }
+ this.pssParams = validateSigParams(params);
+ if (fallbackSignature != null) {
+ fallbackSignature.setParameter(params);
+ }
+ }
+
+ @Override
+ protected AlgorithmParameters engineGetParameters() {
+ AlgorithmParameters ap = null;
+ if (this.pssParams != null) {
+ try {
+ ap = AlgorithmParameters.getInstance("RSASSA-PSS");
+ ap.init(this.pssParams);
+ } catch (GeneralSecurityException gse) {
+ throw new ProviderException(gse.getMessage());
+ }
+ }
+ return ap;
+ }
+
+ private void ensureInit() throws SignatureException {
+ if (this.privateKey == null && this.publicKey == null
+ && fallbackSignature == null) {
+ throw new SignatureException("Missing key");
+ }
+ if (this.pssParams == null) {
+ // Parameters are required for signature verification
+ throw new SignatureException
+ ("Parameters required for RSASSA-PSS signatures");
+ }
+ if (fallbackSignature == null && messageDigest == null) {
+ // This could happen if initVerify(softKey), setParameter(),
+ // and initSign() were called. No messageDigest. Create it.
+ try {
+ messageDigest = MessageDigest
+ .getInstance(pssParams.getDigestAlgorithm());
+ } catch (NoSuchAlgorithmException e) {
+ throw new SignatureException(e);
+ }
+ }
+ }
+
+ /**
+ * Validate the specified Signature PSS parameters.
+ */
+ private PSSParameterSpec validateSigParams(AlgorithmParameterSpec p)
+ throws InvalidAlgorithmParameterException {
+
+ if (p == null) {
+ throw new InvalidAlgorithmParameterException
+ ("Parameters cannot be null");
+ }
+
+ if (!(p instanceof PSSParameterSpec)) {
+ throw new InvalidAlgorithmParameterException
+ ("parameters must be type PSSParameterSpec");
+ }
+
+ // no need to validate again if same as current signature parameters
+ PSSParameterSpec params = (PSSParameterSpec) p;
+ if (params == this.pssParams) return params;
+
+ // now sanity check the parameter values
+ if (!(params.getMGFAlgorithm().equalsIgnoreCase("MGF1"))) {
+ throw new InvalidAlgorithmParameterException("Only supports MGF1");
+
+ }
+
+ if (params.getTrailerField() != PSSParameterSpec.TRAILER_FIELD_BC) {
+ throw new InvalidAlgorithmParameterException
+ ("Only supports TrailerFieldBC(1)");
+ }
+
+ AlgorithmParameterSpec algSpec = params.getMGFParameters();
+ if (!(algSpec instanceof MGF1ParameterSpec)) {
+ throw new InvalidAlgorithmParameterException
+ ("Only support MGF1ParameterSpec");
+ }
+
+ MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)algSpec;
+
+ String msgHashAlg = params.getDigestAlgorithm()
+ .toLowerCase(Locale.ROOT).replaceAll("-", "");
+ if (msgHashAlg.equals("sha")) {
+ msgHashAlg = "sha1";
+ }
+ String mgf1HashAlg = mgfSpec.getDigestAlgorithm()
+ .toLowerCase(Locale.ROOT).replaceAll("-", "");
+ if (mgf1HashAlg.equals("sha")) {
+ mgf1HashAlg = "sha1";
+ }
+
+ if (!mgf1HashAlg.equals(msgHashAlg)) {
+ throw new InvalidAlgorithmParameterException
+ ("MGF1 hash must be the same as message hash");
+ }
+
+ return params;
+ }
+ }
+
+ /**
+ * Sign hash using CNG API with HCRYPTKEY.
+ * @param type 0 no padding, 1, pkcs1, 2, pss
+ */
+ native static byte[] signCngHash(
+ int type, byte[] hash,
+ int hashSize, int saltLength, String hashAlgorithm,
+ long hCryptProv, long nCryptKey)
+ throws SignatureException;
+
+ /**
+ * Verify a signed hash using CNG API with HCRYPTKEY.
+ * @param type 0 no padding, 1, pkcs1, 2, pss
+ */
+ private native static boolean verifyCngSignedHash(
+ int type, byte[] hash, int hashSize,
+ byte[] signature, int signatureSize,
+ int saltLength, String hashAlgorithm,
+ long hCryptProv, long hKey) throws SignatureException;
+
+ /**
+ * Resets the message digest if needed.
+ */
+ protected void resetDigest() {
+ if (needsReset) {
+ if (messageDigest != null) {
+ messageDigest.reset();
+ }
+ needsReset = false;
+ }
+ }
+
+ protected byte[] getDigestValue() throws SignatureException {
+ needsReset = false;
+ return messageDigest.digest();
+ }
+
+ protected void setDigestName(String name) {
+ messageDigestAlgorithm = name;
+ }
+
+ /**
+ * Updates the data to be signed or verified
+ * using the specified byte.
+ *
+ * @param b the byte to use for the update.
+ *
+ * @exception SignatureException if the engine is not initialized
+ * properly.
+ */
+ @Override
+ protected void engineUpdate(byte b) throws SignatureException {
+ messageDigest.update(b);
+ needsReset = true;
+ }
+
+ /**
+ * Updates the data to be signed or verified, using the
+ * specified array of bytes, starting at the specified offset.
+ *
+ * @param b the array of bytes
+ * @param off the offset to start from in the array of bytes
+ * @param len the number of bytes to use, starting at offset
+ *
+ * @exception SignatureException if the engine is not initialized
+ * properly
+ */
+ @Override
+ protected void engineUpdate(byte[] b, int off, int len)
+ throws SignatureException {
+ messageDigest.update(b, off, len);
+ needsReset = true;
+ }
+
+ /**
+ * Updates the data to be signed or verified, using the
+ * specified ByteBuffer.
+ *
+ * @param input the ByteBuffer
+ */
+ @Override
+ protected void engineUpdate(ByteBuffer input) {
+ messageDigest.update(input);
+ needsReset = true;
+ }
+
+ /**
+ * Convert array from big endian to little endian, or vice versa.
+ */
+ private static byte[] convertEndianArray(byte[] byteArray) {
+ if (byteArray == null || byteArray.length == 0)
+ return byteArray;
+
+ byte [] retval = new byte[byteArray.length];
+
+ // make it big endian
+ for (int i=0;i < byteArray.length;i++)
+ retval[i] = byteArray[byteArray.length - i - 1];
+
+ return retval;
+ }
+
+ /**
+ * Sign hash using Microsoft Crypto API with HCRYPTKEY.
+ * The returned data is in little-endian.
+ */
+ private native static byte[] signHash(boolean noHashOID, byte[] hash,
+ int hashSize, String hashAlgorithm, long hCryptProv, long hCryptKey)
+ throws SignatureException;
+
+ /**
+ * Verify a signed hash using Microsoft Crypto API with HCRYPTKEY.
+ */
+ private native static boolean verifySignedHash(byte[] hash, int hashSize,
+ String hashAlgorithm, byte[] signature, int signatureSize,
+ long hCryptProv, long hCryptKey) throws SignatureException;
+
+ /**
+ * Sets the specified algorithm parameter to the specified
+ * value. This method supplies a general-purpose mechanism through
+ * which it is possible to set the various parameters of this object.
+ * A parameter may be any settable parameter for the algorithm, such as
+ * a parameter size, or a source of random bits for signature generation
+ * (if appropriate), or an indication of whether or not to perform
+ * a specific but optional computation. A uniform algorithm-specific
+ * naming scheme for each parameter is desirable but left unspecified
+ * at this time.
+ *
+ * @param param the string identifier of the parameter.
+ *
+ * @param value the parameter value.
+ *
+ * @exception InvalidParameterException if <code>param</code> is an
+ * invalid parameter for this signature algorithm engine,
+ * the parameter is already set
+ * and cannot be set again, a security exception occurs, and so on.
+ *
+ * @deprecated Replaced by {@link
+ * #engineSetParameter(java.security.spec.AlgorithmParameterSpec)
+ * engineSetParameter}.
+ */
+ @Override
+ @Deprecated
+ protected void engineSetParameter(String param, Object value)
+ throws InvalidParameterException {
+ throw new InvalidParameterException("Parameter not supported");
+ }
+
+ /**
+ * Sets this signature engine with the specified algorithm parameter.
+ *
+ * @param params the parameters
+ *
+ * @exception InvalidAlgorithmParameterException if the given
+ * parameter is invalid
+ */
+ @Override
+ protected void engineSetParameter(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException {
+ if (params != null) {
+ throw new InvalidAlgorithmParameterException("No parameter accepted");
+ }
+ }
+
+ /**
+ * Gets the value of the specified algorithm parameter.
+ * This method supplies a general-purpose mechanism through which it
+ * is possible to get the various parameters of this object. A parameter
+ * may be any settable parameter for the algorithm, such as a parameter
+ * size, or a source of random bits for signature generation (if
+ * appropriate), or an indication of whether or not to perform a
+ * specific but optional computation. A uniform algorithm-specific
+ * naming scheme for each parameter is desirable but left unspecified
+ * at this time.
+ *
+ * @param param the string name of the parameter.
+ *
+ * @return the object that represents the parameter value, or null if
+ * there is none.
+ *
+ * @exception InvalidParameterException if <code>param</code> is an
+ * invalid parameter for this engine, or another exception occurs while
+ * trying to get this parameter.
+ *
+ * @deprecated
+ */
+ @Override
+ @Deprecated
+ protected Object engineGetParameter(String param)
+ throws InvalidParameterException {
+ throw new InvalidParameterException("Parameter not supported");
+ }
+
+ /**
+ * Gets the algorithm parameter from this signature engine.
+ *
+ * @return the parameter, or null if no parameter is used.
+ */
+ @Override
+ protected AlgorithmParameters engineGetParameters() {
+ return null;
+ }
+
+ /**
+ * Imports a public-key BLOB.
+ */
+ // used by CRSACipher
+ static native CPublicKey importPublicKey(
+ String alg, byte[] keyBlob, int keySize) throws KeyStoreException;
+
+ static native CPublicKey importECPublicKey(
+ String alg, byte[] keyBlob, int keySize) throws KeyStoreException;
+}
--- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/Key.java Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.mscapi;
-
-import sun.security.util.Length;
-
-/**
- * The handle for an RSA or DSA key using the Microsoft Crypto API.
- *
- * @see RSAPrivateKey
- * @see RSAPublicKey
- *
- * @since 1.6
- * @author Stanley Man-Kit Ho
- */
-abstract class Key implements java.security.Key, Length
-{
- private static final long serialVersionUID = -1088859394025049194L;
-
- static class NativeHandles {
- long hCryptProv = 0;
- long hCryptKey = 0;
-
- public NativeHandles(long hCryptProv, long hCryptKey) {
- this.hCryptProv = hCryptProv;
- this.hCryptKey = hCryptKey;
- }
-
- /**
- * Finalization method
- */
- @SuppressWarnings("deprecation")
- protected void finalize() throws Throwable
- {
- try {
- synchronized(this)
- {
- cleanUp(hCryptProv, hCryptKey);
- hCryptProv = 0;
- hCryptKey = 0;
- }
-
- } finally {
- super.finalize();
- }
- }
- }
-
- protected NativeHandles handles;
-
- // Key length
- protected int keyLength = 0;
-
- /**
- * Construct a Key object.
- */
- protected Key(NativeHandles handles, int keyLength)
- {
- this.handles = handles;
- this.keyLength = keyLength;
- }
-
- /**
- * Native method to cleanup the key handle.
- */
- private native static void cleanUp(long hCryptProv, long hCryptKey);
-
- /**
- * Return bit length of the key.
- */
- @Override
- public int length()
- {
- return keyLength;
- }
-
-
- /**
- * Return native HCRYPTKEY handle.
- */
- public long getHCryptKey()
- {
- return handles.hCryptKey;
- }
-
- /**
- * Return native HCRYPTPROV handle.
- */
- public long getHCryptProvider()
- {
- return handles.hCryptProv;
- }
-
- /**
- * Returns the standard algorithm name for this key. For
- * example, "RSA" would indicate that this key is a RSA key.
- * See Appendix A in the <a href=
- * "../../../guide/security/CryptoSpec.html#AppA">
- * Java Cryptography Architecture API Specification & Reference </a>
- * for information about standard algorithm names.
- *
- * @return the name of the algorithm associated with this key.
- */
- public abstract String getAlgorithm();
-
- /**
- * Returns the name of the primary encoding format of this key,
- * or null if this key does not support encoding.
- * The primary encoding format is
- * named in terms of the appropriate ASN.1 data format, if an
- * ASN.1 specification for this key exists.
- * For example, the name of the ASN.1 data format for public
- * keys is <I>SubjectPublicKeyInfo</I>, as
- * defined by the X.509 standard; in this case, the returned format is
- * <code>"X.509"</code>. Similarly,
- * the name of the ASN.1 data format for private keys is
- * <I>PrivateKeyInfo</I>,
- * as defined by the PKCS #8 standard; in this case, the returned format is
- * <code>"PKCS#8"</code>.
- *
- * @return the primary encoding format of the key.
- */
- public String getFormat()
- {
- return null;
- }
-
- /**
- * Returns the key in its primary encoding format, or null
- * if this key does not support encoding.
- *
- * @return the encoded key, or null if the key does not support
- * encoding.
- */
- public byte[] getEncoded()
- {
- return null;
- }
-
- protected native static String getContainerName(long hCryptProv);
-
- protected native static String getKeyType(long hCryptKey);
-}
--- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,910 +0,0 @@
-/*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.mscapi;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.AccessController;
-import java.security.InvalidKeyException;
-import java.security.KeyStoreSpi;
-import java.security.KeyStoreException;
-import java.security.PrivilegedAction;
-import java.security.UnrecoverableKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecurityPermission;
-import java.security.cert.X509Certificate;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.interfaces.RSAPrivateCrtKey;
-import java.util.*;
-
-/**
- * Implementation of key store for Windows using the Microsoft Crypto API.
- *
- * @since 1.6
- */
-abstract class KeyStore extends KeyStoreSpi {
-
- public static final class MY extends KeyStore {
- public MY() {
- super("MY");
- }
- }
-
- public static final class ROOT extends KeyStore {
- public ROOT() {
- super("ROOT");
- }
- }
-
- class KeyEntry
- {
- private Key privateKey;
- private X509Certificate[] certChain;
- private String alias;
-
- KeyEntry(Key key, X509Certificate[] chain) {
- this(null, key, chain);
- }
-
- KeyEntry(String alias, Key key, X509Certificate[] chain) {
- this.privateKey = key;
- this.certChain = chain;
- /*
- * The default alias for both entry types is derived from a
- * hash value intrinsic to the first certificate in the chain.
- */
- if (alias == null) {
- this.alias = Integer.toString(chain[0].hashCode());
- } else {
- this.alias = alias;
- }
- }
-
- /**
- * Gets the alias for the keystore entry.
- */
- String getAlias()
- {
- return alias;
- }
-
- /**
- * Sets the alias for the keystore entry.
- */
- void setAlias(String alias)
- {
- // TODO - set friendly name prop in cert store
- this.alias = alias;
- }
-
- /**
- * Gets the private key for the keystore entry.
- */
- Key getPrivateKey()
- {
- return privateKey;
- }
-
- /**
- * Sets the private key for the keystore entry.
- */
- void setPrivateKey(RSAPrivateCrtKey key)
- throws InvalidKeyException, KeyStoreException
- {
- byte[] modulusBytes = key.getModulus().toByteArray();
-
- // Adjust key length due to sign bit
- int keyBitLength = (modulusBytes[0] == 0)
- ? (modulusBytes.length - 1) * 8
- : modulusBytes.length * 8;
-
- byte[] keyBlob = generatePrivateKeyBlob(
- keyBitLength,
- modulusBytes,
- key.getPublicExponent().toByteArray(),
- key.getPrivateExponent().toByteArray(),
- key.getPrimeP().toByteArray(),
- key.getPrimeQ().toByteArray(),
- key.getPrimeExponentP().toByteArray(),
- key.getPrimeExponentQ().toByteArray(),
- key.getCrtCoefficient().toByteArray());
-
- privateKey = storePrivateKey(Objects.requireNonNull(keyBlob),
- "{" + UUID.randomUUID().toString() + "}", keyBitLength);
- }
-
- /**
- * Gets the certificate chain for the keystore entry.
- */
- X509Certificate[] getCertificateChain()
- {
- return certChain;
- }
-
- /**
- * Sets the certificate chain for the keystore entry.
- */
- void setCertificateChain(X509Certificate[] chain)
- throws CertificateException, KeyStoreException
- {
- for (int i = 0; i < chain.length; i++) {
- byte[] encoding = chain[i].getEncoded();
- if (i == 0 && privateKey != null) {
- storeCertificate(getName(), alias, encoding,
- encoding.length, privateKey.getHCryptProvider(),
- privateKey.getHCryptKey());
-
- } else {
- storeCertificate(getName(), alias, encoding,
- encoding.length, 0L, 0L); // no private key to attach
- }
- }
- certChain = chain;
- }
- }
-
- /*
- * An X.509 certificate factory.
- * Used to create an X.509 certificate from its DER-encoding.
- */
- private CertificateFactory certificateFactory = null;
-
- /*
- * Compatibility mode: for applications that assume keystores are
- * stream-based this mode tolerates (but ignores) a non-null stream
- * or password parameter when passed to the load or store methods.
- * The mode is enabled by default.
- */
- private static final String KEYSTORE_COMPATIBILITY_MODE_PROP =
- "sun.security.mscapi.keyStoreCompatibilityMode";
- private final boolean keyStoreCompatibilityMode;
-
- /*
- * The keystore entries.
- * Keys in the map are unique aliases (thus can differ from
- * KeyEntry.getAlias())
- */
- private Map<String,KeyEntry> entries = new HashMap<>();
-
- /*
- * The keystore name.
- * Case is not significant.
- */
- private final String storeName;
-
- KeyStore(String storeName) {
- // Get the compatibility mode
- String prop = AccessController.doPrivileged(
- (PrivilegedAction<String>) () -> System.getProperty(KEYSTORE_COMPATIBILITY_MODE_PROP));
-
- if ("false".equalsIgnoreCase(prop)) {
- keyStoreCompatibilityMode = false;
- } else {
- keyStoreCompatibilityMode = true;
- }
-
- this.storeName = storeName;
- }
-
- /**
- * Returns the key associated with the given alias.
- * <p>
- * A compatibility mode is supported for applications that assume
- * a password must be supplied. It permits (but ignores) a non-null
- * <code>password</code>. The mode is enabled by default.
- * Set the
- * <code>sun.security.mscapi.keyStoreCompatibilityMode</code>
- * system property to <code>false</code> to disable compatibility mode
- * and reject a non-null <code>password</code>.
- *
- * @param alias the alias name
- * @param password the password, which should be <code>null</code>
- *
- * @return the requested key, or null if the given alias does not exist
- * or does not identify a <i>key entry</i>.
- *
- * @exception NoSuchAlgorithmException if the algorithm for recovering the
- * key cannot be found,
- * or if compatibility mode is disabled and <code>password</code> is
- * non-null.
- * @exception UnrecoverableKeyException if the key cannot be recovered.
- */
- public java.security.Key engineGetKey(String alias, char[] password)
- throws NoSuchAlgorithmException, UnrecoverableKeyException
- {
- if (alias == null) {
- return null;
- }
-
- if (password != null && !keyStoreCompatibilityMode) {
- throw new UnrecoverableKeyException("Password must be null");
- }
-
- if (engineIsKeyEntry(alias) == false)
- return null;
-
- KeyEntry entry = entries.get(alias);
- return (entry == null)
- ? null
- : entry.getPrivateKey();
- }
-
- /**
- * Returns the certificate chain associated with the given alias.
- *
- * @param alias the alias name
- *
- * @return the certificate chain (ordered with the user's certificate first
- * and the root certificate authority last), or null if the given alias
- * does not exist or does not contain a certificate chain (i.e., the given
- * alias identifies either a <i>trusted certificate entry</i> or a
- * <i>key entry</i> without a certificate chain).
- */
- public Certificate[] engineGetCertificateChain(String alias)
- {
- if (alias == null) {
- return null;
- }
-
- KeyEntry entry = entries.get(alias);
- X509Certificate[] certChain = (entry == null)
- ? null
- : entry.getCertificateChain();
- return (certChain == null)
- ? null
- : certChain.clone();
- }
-
- /**
- * Returns the certificate associated with the given alias.
- *
- * <p>If the given alias name identifies a
- * <i>trusted certificate entry</i>, the certificate associated with that
- * entry is returned. If the given alias name identifies a
- * <i>key entry</i>, the first element of the certificate chain of that
- * entry is returned, or null if that entry does not have a certificate
- * chain.
- *
- * @param alias the alias name
- *
- * @return the certificate, or null if the given alias does not exist or
- * does not contain a certificate.
- */
- public Certificate engineGetCertificate(String alias)
- {
- if (alias == null) {
- return null;
- }
-
- KeyEntry entry = entries.get(alias);
- X509Certificate[] certChain = (entry == null)
- ? null
- : entry.getCertificateChain();
- return (certChain == null || certChain.length == 0)
- ? null
- : certChain[0];
- }
-
- /**
- * Returns the creation date of the entry identified by the given alias.
- *
- * @param alias the alias name
- *
- * @return the creation date of this entry, or null if the given alias does
- * not exist
- */
- public Date engineGetCreationDate(String alias) {
- if (alias == null) {
- return null;
- }
- return new Date();
- }
-
- /**
- * Stores the given private key and associated certificate chain in the
- * keystore.
- *
- * <p>The given java.security.PrivateKey <code>key</code> must
- * be accompanied by a certificate chain certifying the
- * corresponding public key.
- *
- * <p>If the given alias already exists, the keystore information
- * associated with it is overridden by the given key and certificate
- * chain. Otherwise, a new entry is created.
- *
- * <p>
- * A compatibility mode is supported for applications that assume
- * a password must be supplied. It permits (but ignores) a non-null
- * <code>password</code>. The mode is enabled by default.
- * Set the
- * <code>sun.security.mscapi.keyStoreCompatibilityMode</code>
- * system property to <code>false</code> to disable compatibility mode
- * and reject a non-null <code>password</code>.
- *
- * @param alias the alias name
- * @param key the private key to be associated with the alias
- * @param password the password, which should be <code>null</code>
- * @param chain the certificate chain for the corresponding public
- * key (only required if the given key is of type
- * <code>java.security.PrivateKey</code>).
- *
- * @exception KeyStoreException if the given key is not a private key,
- * cannot be protected, or if compatibility mode is disabled and
- * <code>password</code> is non-null, or if this operation fails for
- * some other reason.
- */
- public void engineSetKeyEntry(String alias, java.security.Key key,
- char[] password, Certificate[] chain) throws KeyStoreException
- {
- if (alias == null) {
- throw new KeyStoreException("alias must not be null");
- }
-
- if (password != null && !keyStoreCompatibilityMode) {
- throw new KeyStoreException("Password must be null");
- }
-
- if (key instanceof RSAPrivateCrtKey) {
-
- KeyEntry entry = entries.get(alias);
-
- X509Certificate[] xchain;
- if (chain != null) {
- if (chain instanceof X509Certificate[]) {
- xchain = (X509Certificate[]) chain;
- } else {
- xchain = new X509Certificate[chain.length];
- System.arraycopy(chain, 0, xchain, 0, chain.length);
- }
- } else {
- xchain = null;
- }
-
- if (entry == null) {
- entry =
- //TODO new KeyEntry(alias, key, (X509Certificate[]) chain);
- new KeyEntry(alias, null, xchain);
- storeWithUniqueAlias(alias, entry);
- }
-
- entry.setAlias(alias);
-
- try {
- entry.setPrivateKey((RSAPrivateCrtKey) key);
- entry.setCertificateChain(xchain);
-
- } catch (CertificateException ce) {
- throw new KeyStoreException(ce);
-
- } catch (InvalidKeyException ike) {
- throw new KeyStoreException(ike);
- }
-
- } else {
- throw new UnsupportedOperationException(
- "Cannot assign the key to the given alias.");
- }
- }
-
- /**
- * Assigns the given key (that has already been protected) to the given
- * alias.
- *
- * <p>If the protected key is of type
- * <code>java.security.PrivateKey</code>, it must be accompanied by a
- * certificate chain certifying the corresponding public key. If the
- * underlying keystore implementation is of type <code>jks</code>,
- * <code>key</code> must be encoded as an
- * <code>EncryptedPrivateKeyInfo</code> as defined in the PKCS #8 standard.
- *
- * <p>If the given alias already exists, the keystore information
- * associated with it is overridden by the given key (and possibly
- * certificate chain).
- *
- * @param alias the alias name
- * @param key the key (in protected format) to be associated with the alias
- * @param chain the certificate chain for the corresponding public
- * key (only useful if the protected key is of type
- * <code>java.security.PrivateKey</code>).
- *
- * @exception KeyStoreException if this operation fails.
- */
- public void engineSetKeyEntry(String alias, byte[] key,
- Certificate[] chain)
- throws KeyStoreException
- {
- throw new UnsupportedOperationException(
- "Cannot assign the encoded key to the given alias.");
- }
-
- /**
- * Assigns the given certificate to the given alias.
- *
- * <p>If the given alias already exists in this keystore and identifies a
- * <i>trusted certificate entry</i>, the certificate associated with it is
- * overridden by the given certificate.
- *
- * @param alias the alias name
- * @param cert the certificate
- *
- * @exception KeyStoreException if the given alias already exists and does
- * not identify a <i>trusted certificate entry</i>, or this operation
- * fails for some other reason.
- */
- public void engineSetCertificateEntry(String alias, Certificate cert)
- throws KeyStoreException
- {
- if (alias == null) {
- throw new KeyStoreException("alias must not be null");
- }
-
- if (cert instanceof X509Certificate) {
-
- // TODO - build CryptoAPI chain?
- X509Certificate[] chain =
- new X509Certificate[]{ (X509Certificate) cert };
- KeyEntry entry = entries.get(alias);
-
- if (entry == null) {
- entry =
- new KeyEntry(alias, null, chain);
- storeWithUniqueAlias(alias, entry);
- }
-
- if (entry.getPrivateKey() == null) { // trusted-cert entry
- entry.setAlias(alias);
-
- try {
- entry.setCertificateChain(chain);
-
- } catch (CertificateException ce) {
- throw new KeyStoreException(ce);
- }
- }
-
- } else {
- throw new UnsupportedOperationException(
- "Cannot assign the certificate to the given alias.");
- }
- }
-
- /**
- * Deletes the entry identified by the given alias from this keystore.
- *
- * @param alias the alias name
- *
- * @exception KeyStoreException if the entry cannot be removed.
- */
- public void engineDeleteEntry(String alias)
- throws KeyStoreException
- {
- if (alias == null) {
- throw new KeyStoreException("alias must not be null");
- }
-
- KeyEntry entry = entries.remove(alias);
- if (entry != null) {
- // Get end-entity certificate and remove from system cert store
- X509Certificate[] certChain = entry.getCertificateChain();
- if (certChain != null && certChain.length > 0) {
-
- try {
-
- byte[] encoding = certChain[0].getEncoded();
- removeCertificate(getName(), entry.getAlias(), encoding,
- encoding.length);
-
- } catch (CertificateException e) {
- throw new KeyStoreException("Cannot remove entry: ", e);
- }
- }
- Key privateKey = entry.getPrivateKey();
- if (privateKey != null) {
- destroyKeyContainer(
- Key.getContainerName(privateKey.getHCryptProvider()));
- }
- }
- }
-
- /**
- * Lists all the alias names of this keystore.
- *
- * @return enumeration of the alias names
- */
- public Enumeration<String> engineAliases() {
- final Iterator<String> iter = entries.keySet().iterator();
-
- return new Enumeration<String>()
- {
- public boolean hasMoreElements()
- {
- return iter.hasNext();
- }
-
- public String nextElement()
- {
- return iter.next();
- }
- };
- }
-
- /**
- * Checks if the given alias exists in this keystore.
- *
- * @param alias the alias name
- *
- * @return true if the alias exists, false otherwise
- */
- public boolean engineContainsAlias(String alias) {
- return entries.containsKey(alias);
- }
-
- /**
- * Retrieves the number of entries in this keystore.
- *
- * @return the number of entries in this keystore
- */
- public int engineSize() {
- return entries.size();
- }
-
- /**
- * Returns true if the entry identified by the given alias is a
- * <i>key entry</i>, and false otherwise.
- *
- * @return true if the entry identified by the given alias is a
- * <i>key entry</i>, false otherwise.
- */
- public boolean engineIsKeyEntry(String alias) {
-
- if (alias == null) {
- return false;
- }
-
- KeyEntry entry = entries.get(alias);
- return entry != null && entry.getPrivateKey() != null;
- }
-
- /**
- * Returns true if the entry identified by the given alias is a
- * <i>trusted certificate entry</i>, and false otherwise.
- *
- * @return true if the entry identified by the given alias is a
- * <i>trusted certificate entry</i>, false otherwise.
- */
- public boolean engineIsCertificateEntry(String alias) {
-
- if (alias == null) {
- return false;
- }
-
- KeyEntry entry = entries.get(alias);
- return entry != null && entry.getPrivateKey() == null;
- }
-
- /**
- * Returns the (alias) name of the first keystore entry whose certificate
- * matches the given certificate.
- *
- * <p>This method attempts to match the given certificate with each
- * keystore entry. If the entry being considered
- * is a <i>trusted certificate entry</i>, the given certificate is
- * compared to that entry's certificate. If the entry being considered is
- * a <i>key entry</i>, the given certificate is compared to the first
- * element of that entry's certificate chain (if a chain exists).
- *
- * @param cert the certificate to match with.
- *
- * @return the (alias) name of the first entry with matching certificate,
- * or null if no such entry exists in this keystore.
- */
- public String engineGetCertificateAlias(Certificate cert) {
-
- for (Map.Entry<String,KeyEntry> mapEntry : entries.entrySet()) {
- KeyEntry entry = mapEntry.getValue();
- if (entry.certChain != null &&
- entry.certChain.length > 0 &&
- entry.certChain[0].equals(cert)) {
- return entry.getAlias();
- }
- }
-
- return null;
- }
-
- /**
- * engineStore is currently a no-op.
- * Entries are stored during engineSetEntry.
- *
- * A compatibility mode is supported for applications that assume
- * keystores are stream-based. It permits (but ignores) a non-null
- * <code>stream</code> or <code>password</code>.
- * The mode is enabled by default.
- * Set the
- * <code>sun.security.mscapi.keyStoreCompatibilityMode</code>
- * system property to <code>false</code> to disable compatibility mode
- * and reject a non-null <code>stream</code> or <code>password</code>.
- *
- * @param stream the output stream, which should be <code>null</code>
- * @param password the password, which should be <code>null</code>
- *
- * @exception IOException if compatibility mode is disabled and either
- * parameter is non-null.
- */
- public void engineStore(OutputStream stream, char[] password)
- throws IOException, NoSuchAlgorithmException, CertificateException
- {
- if (stream != null && !keyStoreCompatibilityMode) {
- throw new IOException("Keystore output stream must be null");
- }
-
- if (password != null && !keyStoreCompatibilityMode) {
- throw new IOException("Keystore password must be null");
- }
- }
-
- /**
- * Loads the keystore.
- *
- * A compatibility mode is supported for applications that assume
- * keystores are stream-based. It permits (but ignores) a non-null
- * <code>stream</code> or <code>password</code>.
- * The mode is enabled by default.
- * Set the
- * <code>sun.security.mscapi.keyStoreCompatibilityMode</code>
- * system property to <code>false</code> to disable compatibility mode
- * and reject a non-null <code>stream</code> or <code>password</code>.
- *
- * @param stream the input stream, which should be <code>null</code>.
- * @param password the password, which should be <code>null</code>.
- *
- * @exception IOException if there is an I/O or format problem with the
- * keystore data. Or if compatibility mode is disabled and either
- * parameter is non-null.
- * @exception NoSuchAlgorithmException if the algorithm used to check
- * the integrity of the keystore cannot be found
- * @exception CertificateException if any of the certificates in the
- * keystore could not be loaded
- * @exception SecurityException if the security check for
- * <code>SecurityPermission("authProvider.<i>name</i>")</code> does not
- * pass, where <i>name</i> is the value returned by
- * this provider's <code>getName</code> method.
- */
- public void engineLoad(InputStream stream, char[] password)
- throws IOException, NoSuchAlgorithmException, CertificateException
- {
- if (stream != null && !keyStoreCompatibilityMode) {
- throw new IOException("Keystore input stream must be null");
- }
-
- if (password != null && !keyStoreCompatibilityMode) {
- throw new IOException("Keystore password must be null");
- }
-
- /*
- * Use the same security check as AuthProvider.login
- */
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new SecurityPermission(
- "authProvider.SunMSCAPI"));
- }
-
- // Clear all key entries
- entries.clear();
-
- try {
-
- // Load keys and/or certificate chains
- loadKeysOrCertificateChains(getName());
-
- } catch (KeyStoreException e) {
- throw new IOException(e);
- }
- }
-
- /**
- * Stores the given entry into the map, making sure
- * the alias, used as the key is unique.
- * If the same alias already exists, it tries to append
- * a suffix (1), (2), etc to it until it finds a unique
- * value.
- */
- private void storeWithUniqueAlias(String alias, KeyEntry entry) {
- String uniqAlias = alias;
- int uniqNum = 1;
-
- while (true) {
- if (entries.putIfAbsent(uniqAlias, entry) == null) {
- break;
- }
- uniqAlias = alias + " (" + (uniqNum++) + ")";
- }
- }
-
-
- /**
- * Generates a certificate chain from the collection of
- * certificates and stores the result into a key entry.
- */
- private void generateCertificateChain(String alias,
- Collection<? extends Certificate> certCollection)
- {
- try
- {
- X509Certificate[] certChain =
- new X509Certificate[certCollection.size()];
-
- int i = 0;
- for (Iterator<? extends Certificate> iter =
- certCollection.iterator(); iter.hasNext(); i++)
- {
- certChain[i] = (X509Certificate) iter.next();
- }
-
- storeWithUniqueAlias(alias,
- new KeyEntry(alias, null, certChain));
- }
- catch (Throwable e)
- {
- // Ignore the exception and skip this entry
- // TODO - throw CertificateException?
- }
- }
-
- /**
- * Generates RSA key and certificate chain from the private key handle,
- * collection of certificates and stores the result into key entries.
- */
- private void generateRSAKeyAndCertificateChain(String alias,
- long hCryptProv, long hCryptKey, int keyLength,
- Collection<? extends Certificate> certCollection)
- {
- try
- {
- X509Certificate[] certChain =
- new X509Certificate[certCollection.size()];
-
- int i = 0;
- for (Iterator<? extends Certificate> iter =
- certCollection.iterator(); iter.hasNext(); i++)
- {
- certChain[i] = (X509Certificate) iter.next();
- }
-
- storeWithUniqueAlias(alias, new KeyEntry(alias,
- new RSAPrivateKey(new Key.NativeHandles(hCryptProv,
- hCryptKey), keyLength),
- certChain));
- }
- catch (Throwable e)
- {
- // Ignore the exception and skip this entry
- // TODO - throw CertificateException?
- }
- }
-
- /**
- * Generates certificates from byte data and stores into cert collection.
- *
- * @param data Byte data.
- * @param certCollection Collection of certificates.
- */
- private void generateCertificate(byte[] data,
- Collection<Certificate> certCollection) {
- try
- {
- ByteArrayInputStream bis = new ByteArrayInputStream(data);
-
- // Obtain certificate factory
- if (certificateFactory == null) {
- certificateFactory = CertificateFactory.getInstance("X.509", "SUN");
- }
-
- // Generate certificate
- Collection<? extends Certificate> c =
- certificateFactory.generateCertificates(bis);
- certCollection.addAll(c);
- }
- catch (CertificateException e)
- {
- // Ignore the exception and skip this certificate
- // TODO - throw CertificateException?
- }
- catch (Throwable te)
- {
- // Ignore the exception and skip this certificate
- // TODO - throw CertificateException?
- }
- }
-
- /**
- * Returns the name of the keystore.
- */
- private String getName()
- {
- return storeName;
- }
-
- /**
- * Load keys and/or certificates from keystore into Collection.
- *
- * @param name Name of keystore.
- */
- private native void loadKeysOrCertificateChains(String name)
- throws KeyStoreException;
-
- /**
- * Stores a DER-encoded certificate into the certificate store
- *
- * @param name Name of the keystore.
- * @param alias Name of the certificate.
- * @param encoding DER-encoded certificate.
- */
- private native void storeCertificate(String name, String alias,
- byte[] encoding, int encodingLength, long hCryptProvider,
- long hCryptKey) throws CertificateException, KeyStoreException;
-
- /**
- * Removes the certificate from the certificate store
- *
- * @param name Name of the keystore.
- * @param alias Name of the certificate.
- * @param encoding DER-encoded certificate.
- */
- private native void removeCertificate(String name, String alias,
- byte[] encoding, int encodingLength)
- throws CertificateException, KeyStoreException;
-
- /**
- * Destroys the key container.
- *
- * @param keyContainerName The name of the key container.
- */
- private native void destroyKeyContainer(String keyContainerName)
- throws KeyStoreException;
-
- /**
- * Generates a private-key BLOB from a key's components.
- */
- private native byte[] generatePrivateKeyBlob(
- int keyBitLength,
- byte[] modulus,
- byte[] publicExponent,
- byte[] privateExponent,
- byte[] primeP,
- byte[] primeQ,
- byte[] exponentP,
- byte[] exponentQ,
- byte[] crtCoefficient) throws InvalidKeyException;
-
- private native RSAPrivateKey storePrivateKey(byte[] keyBlob,
- String keyContainerName, int keySize) throws KeyStoreException;
-}
--- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/PRNG.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/PRNG.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSACipher.java Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,501 +0,0 @@
-/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.mscapi;
-
-import java.math.BigInteger;
-import java.security.*;
-import java.security.Key;
-import java.security.interfaces.*;
-import java.security.spec.*;
-
-import javax.crypto.*;
-import javax.crypto.spec.*;
-
-import sun.security.rsa.RSAKeyFactory;
-import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
-import sun.security.util.KeyUtil;
-
-/**
- * RSA cipher implementation using the Microsoft Crypto API.
- * Supports RSA en/decryption and signing/verifying using PKCS#1 v1.5 padding.
- *
- * Objects should be instantiated by calling Cipher.getInstance() using the
- * following algorithm name:
- *
- * . "RSA/ECB/PKCS1Padding" (or "RSA") for PKCS#1 padding. The mode (blocktype)
- * is selected based on the en/decryption mode and public/private key used.
- *
- * We only do one RSA operation per doFinal() call. If the application passes
- * more data via calls to update() or doFinal(), we throw an
- * IllegalBlockSizeException when doFinal() is called (see JCE API spec).
- * Bulk encryption using RSA does not make sense and is not standardized.
- *
- * Note: RSA keys should be at least 512 bits long
- *
- * @since 1.6
- * @author Andreas Sterbenz
- * @author Vincent Ryan
- */
-public final class RSACipher extends CipherSpi {
-
- // constant for an empty byte array
- private final static byte[] B0 = new byte[0];
-
- // mode constant for public key encryption
- private final static int MODE_ENCRYPT = 1;
- // mode constant for private key decryption
- private final static int MODE_DECRYPT = 2;
- // mode constant for private key encryption (signing)
- private final static int MODE_SIGN = 3;
- // mode constant for public key decryption (verifying)
- private final static int MODE_VERIFY = 4;
-
- // constant for PKCS#1 v1.5 RSA
- private final static String PAD_PKCS1 = "PKCS1Padding";
- private final static int PAD_PKCS1_LENGTH = 11;
-
- // current mode, one of MODE_* above. Set when init() is called
- private int mode;
-
- // active padding type, one of PAD_* above. Set by setPadding()
- private String paddingType;
- private int paddingLength = 0;
-
- // buffer for the data
- private byte[] buffer;
- // offset into the buffer (number of bytes buffered)
- private int bufOfs;
-
- // size of the output (the length of the key).
- private int outputSize;
-
- // the public key, if we were initialized using a public key
- private sun.security.mscapi.Key publicKey;
-
- // the private key, if we were initialized using a private key
- private sun.security.mscapi.Key privateKey;
-
- // cipher parameter for TLS RSA premaster secret
- private AlgorithmParameterSpec spec = null;
-
- // the source of randomness
- private SecureRandom random;
-
- public RSACipher() {
- paddingType = PAD_PKCS1;
- }
-
- // modes do not make sense for RSA, but allow ECB
- // see JCE spec
- protected void engineSetMode(String mode) throws NoSuchAlgorithmException {
- if (mode.equalsIgnoreCase("ECB") == false) {
- throw new NoSuchAlgorithmException("Unsupported mode " + mode);
- }
- }
-
- // set the padding type
- // see JCE spec
- protected void engineSetPadding(String paddingName)
- throws NoSuchPaddingException {
- if (paddingName.equalsIgnoreCase(PAD_PKCS1)) {
- paddingType = PAD_PKCS1;
- } else {
- throw new NoSuchPaddingException
- ("Padding " + paddingName + " not supported");
- }
- }
-
- // return 0 as block size, we are not a block cipher
- // see JCE spec
- protected int engineGetBlockSize() {
- return 0;
- }
-
- // return the output size
- // see JCE spec
- protected int engineGetOutputSize(int inputLen) {
- return outputSize;
- }
-
- // no iv, return null
- // see JCE spec
- protected byte[] engineGetIV() {
- return null;
- }
-
- // no parameters, return null
- // see JCE spec
- protected AlgorithmParameters engineGetParameters() {
- return null;
- }
-
- // see JCE spec
- protected void engineInit(int opmode, Key key, SecureRandom random)
- throws InvalidKeyException {
- init(opmode, key);
- }
-
- // see JCE spec
- @SuppressWarnings("deprecation")
- protected void engineInit(int opmode, Key key,
- AlgorithmParameterSpec params, SecureRandom random)
- throws InvalidKeyException, InvalidAlgorithmParameterException {
-
- if (params != null) {
- if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
- throw new InvalidAlgorithmParameterException(
- "Parameters not supported");
- }
- spec = params;
- this.random = random; // for TLS RSA premaster secret
- }
- init(opmode, key);
- }
-
- // see JCE spec
- protected void engineInit(int opmode, Key key,
- AlgorithmParameters params, SecureRandom random)
- throws InvalidKeyException, InvalidAlgorithmParameterException {
-
- if (params != null) {
- throw new InvalidAlgorithmParameterException
- ("Parameters not supported");
- }
- init(opmode, key);
- }
-
- // initialize this cipher
- private void init(int opmode, Key key) throws InvalidKeyException {
-
- boolean encrypt;
-
- switch (opmode) {
- case Cipher.ENCRYPT_MODE:
- case Cipher.WRAP_MODE:
- paddingLength = PAD_PKCS1_LENGTH;
- encrypt = true;
- break;
- case Cipher.DECRYPT_MODE:
- case Cipher.UNWRAP_MODE:
- paddingLength = 0; // reset
- encrypt = false;
- break;
- default:
- throw new InvalidKeyException("Unknown mode: " + opmode);
- }
-
- if (!(key instanceof sun.security.mscapi.Key)) {
- if (key instanceof java.security.interfaces.RSAPublicKey) {
- java.security.interfaces.RSAPublicKey rsaKey =
- (java.security.interfaces.RSAPublicKey) key;
-
- // Convert key to MSCAPI format
-
- BigInteger modulus = rsaKey.getModulus();
- BigInteger exponent = rsaKey.getPublicExponent();
-
- // Check against the local and global values to make sure
- // the sizes are ok. Round up to the nearest byte.
- RSAKeyFactory.checkKeyLengths(((modulus.bitLength() + 7) & ~7),
- exponent, -1, RSAKeyPairGenerator.KEY_SIZE_MAX);
-
- byte[] modulusBytes = modulus.toByteArray();
- byte[] exponentBytes = exponent.toByteArray();
-
- // Adjust key length due to sign bit
- int keyBitLength = (modulusBytes[0] == 0)
- ? (modulusBytes.length - 1) * 8
- : modulusBytes.length * 8;
-
- byte[] keyBlob = RSASignature.generatePublicKeyBlob(
- keyBitLength, modulusBytes, exponentBytes);
-
- try {
- key = RSASignature.importPublicKey(keyBlob, keyBitLength);
-
- } catch (KeyStoreException e) {
- throw new InvalidKeyException(e);
- }
-
- } else {
- throw new InvalidKeyException("Unsupported key type: " + key);
- }
- }
-
- if (key instanceof PublicKey) {
- mode = encrypt ? MODE_ENCRYPT : MODE_VERIFY;
- publicKey = (sun.security.mscapi.Key)key;
- privateKey = null;
- outputSize = publicKey.length() / 8;
- } else if (key instanceof PrivateKey) {
- mode = encrypt ? MODE_SIGN : MODE_DECRYPT;
- privateKey = (sun.security.mscapi.Key)key;
- publicKey = null;
- outputSize = privateKey.length() / 8;
- } else {
- throw new InvalidKeyException("Unknown key type: " + key);
- }
-
- bufOfs = 0;
- buffer = new byte[outputSize];
- }
-
- // internal update method
- private void update(byte[] in, int inOfs, int inLen) {
- if ((inLen == 0) || (in == null)) {
- return;
- }
- if (bufOfs + inLen > (buffer.length - paddingLength)) {
- bufOfs = buffer.length + 1;
- return;
- }
- System.arraycopy(in, inOfs, buffer, bufOfs, inLen);
- bufOfs += inLen;
- }
-
- // internal doFinal() method. Here we perform the actual RSA operation
- private byte[] doFinal() throws BadPaddingException,
- IllegalBlockSizeException {
- if (bufOfs > buffer.length) {
- throw new IllegalBlockSizeException("Data must not be longer "
- + "than " + (buffer.length - paddingLength) + " bytes");
- }
-
- try {
- byte[] data = buffer;
- switch (mode) {
- case MODE_SIGN:
- return encryptDecrypt(data, bufOfs,
- privateKey.getHCryptKey(), true);
-
- case MODE_VERIFY:
- return encryptDecrypt(data, bufOfs,
- publicKey.getHCryptKey(), false);
-
- case MODE_ENCRYPT:
- return encryptDecrypt(data, bufOfs,
- publicKey.getHCryptKey(), true);
-
- case MODE_DECRYPT:
- return encryptDecrypt(data, bufOfs,
- privateKey.getHCryptKey(), false);
-
- default:
- throw new AssertionError("Internal error");
- }
-
- } catch (KeyException e) {
- throw new ProviderException(e);
-
- } finally {
- bufOfs = 0;
- }
- }
-
- // see JCE spec
- protected byte[] engineUpdate(byte[] in, int inOfs, int inLen) {
- update(in, inOfs, inLen);
- return B0;
- }
-
- // see JCE spec
- protected int engineUpdate(byte[] in, int inOfs, int inLen, byte[] out,
- int outOfs) {
- update(in, inOfs, inLen);
- return 0;
- }
-
- // see JCE spec
- protected byte[] engineDoFinal(byte[] in, int inOfs, int inLen)
- throws BadPaddingException, IllegalBlockSizeException {
- update(in, inOfs, inLen);
- return doFinal();
- }
-
- // see JCE spec
- protected int engineDoFinal(byte[] in, int inOfs, int inLen, byte[] out,
- int outOfs) throws ShortBufferException, BadPaddingException,
- IllegalBlockSizeException {
- if (outputSize > out.length - outOfs) {
- throw new ShortBufferException
- ("Need " + outputSize + " bytes for output");
- }
- update(in, inOfs, inLen);
- byte[] result = doFinal();
- int n = result.length;
- System.arraycopy(result, 0, out, outOfs, n);
- return n;
- }
-
- // see JCE spec
- protected byte[] engineWrap(Key key) throws InvalidKeyException,
- IllegalBlockSizeException {
- byte[] encoded = key.getEncoded(); // TODO - unextractable key
- if ((encoded == null) || (encoded.length == 0)) {
- throw new InvalidKeyException("Could not obtain encoded key");
- }
- if (encoded.length > buffer.length) {
- throw new InvalidKeyException("Key is too long for wrapping");
- }
- update(encoded, 0, encoded.length);
- try {
- return doFinal();
- } catch (BadPaddingException e) {
- // should not occur
- throw new InvalidKeyException("Wrapping failed", e);
- }
- }
-
- // see JCE spec
- @SuppressWarnings("deprecation")
- protected java.security.Key engineUnwrap(byte[] wrappedKey,
- String algorithm,
- int type) throws InvalidKeyException, NoSuchAlgorithmException {
-
- if (wrappedKey.length > buffer.length) {
- throw new InvalidKeyException("Key is too long for unwrapping");
- }
-
- boolean isTlsRsaPremasterSecret =
- algorithm.equals("TlsRsaPremasterSecret");
- Exception failover = null;
- byte[] encoded = null;
-
- update(wrappedKey, 0, wrappedKey.length);
- try {
- encoded = doFinal();
- } catch (BadPaddingException e) {
- if (isTlsRsaPremasterSecret) {
- failover = e;
- } else {
- throw new InvalidKeyException("Unwrapping failed", e);
- }
- } catch (IllegalBlockSizeException e) {
- // should not occur, handled with length check above
- throw new InvalidKeyException("Unwrapping failed", e);
- }
-
- if (isTlsRsaPremasterSecret) {
- if (!(spec instanceof TlsRsaPremasterSecretParameterSpec)) {
- throw new IllegalStateException(
- "No TlsRsaPremasterSecretParameterSpec specified");
- }
-
- // polish the TLS premaster secret
- encoded = KeyUtil.checkTlsPreMasterSecretKey(
- ((TlsRsaPremasterSecretParameterSpec)spec).getClientVersion(),
- ((TlsRsaPremasterSecretParameterSpec)spec).getServerVersion(),
- random, encoded, (failover != null));
- }
-
- return constructKey(encoded, algorithm, type);
- }
-
- // see JCE spec
- protected int engineGetKeySize(Key key) throws InvalidKeyException {
-
- if (key instanceof sun.security.mscapi.Key) {
- return ((sun.security.mscapi.Key) key).length();
-
- } else if (key instanceof RSAKey) {
- return ((RSAKey) key).getModulus().bitLength();
-
- } else {
- throw new InvalidKeyException("Unsupported key type: " + key);
- }
- }
-
- // Construct an X.509 encoded public key.
- private static PublicKey constructPublicKey(byte[] encodedKey,
- String encodedKeyAlgorithm)
- throws InvalidKeyException, NoSuchAlgorithmException {
-
- try {
- KeyFactory keyFactory = KeyFactory.getInstance(encodedKeyAlgorithm);
- X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encodedKey);
-
- return keyFactory.generatePublic(keySpec);
-
- } catch (NoSuchAlgorithmException nsae) {
- throw new NoSuchAlgorithmException("No installed provider " +
- "supports the " + encodedKeyAlgorithm + " algorithm", nsae);
-
- } catch (InvalidKeySpecException ike) {
- throw new InvalidKeyException("Cannot construct public key", ike);
- }
- }
-
- // Construct a PKCS #8 encoded private key.
- private static PrivateKey constructPrivateKey(byte[] encodedKey,
- String encodedKeyAlgorithm)
- throws InvalidKeyException, NoSuchAlgorithmException {
-
- try {
- KeyFactory keyFactory = KeyFactory.getInstance(encodedKeyAlgorithm);
- PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey);
-
- return keyFactory.generatePrivate(keySpec);
-
- } catch (NoSuchAlgorithmException nsae) {
- throw new NoSuchAlgorithmException("No installed provider " +
- "supports the " + encodedKeyAlgorithm + " algorithm", nsae);
-
- } catch (InvalidKeySpecException ike) {
- throw new InvalidKeyException("Cannot construct private key", ike);
- }
- }
-
- // Construct an encoded secret key.
- private static SecretKey constructSecretKey(byte[] encodedKey,
- String encodedKeyAlgorithm) {
-
- return new SecretKeySpec(encodedKey, encodedKeyAlgorithm);
- }
-
- private static Key constructKey(byte[] encodedKey,
- String encodedKeyAlgorithm,
- int keyType) throws InvalidKeyException, NoSuchAlgorithmException {
-
- switch (keyType) {
- case Cipher.PUBLIC_KEY:
- return constructPublicKey(encodedKey, encodedKeyAlgorithm);
- case Cipher.PRIVATE_KEY:
- return constructPrivateKey(encodedKey, encodedKeyAlgorithm);
- case Cipher.SECRET_KEY:
- return constructSecretKey(encodedKey, encodedKeyAlgorithm);
- default:
- throw new InvalidKeyException("Unknown key type " + keyType);
- }
- }
-
- /*
- * Encrypt/decrypt a data buffer using Microsoft Crypto API with HCRYPTKEY.
- * It expects and returns ciphertext data in big-endian form.
- */
- private native static byte[] encryptDecrypt(byte[] data, int dataSize,
- long hCryptKey, boolean doEncrypt) throws KeyException;
-
-}
--- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSAKeyPair.java Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.mscapi;
-
-/**
- * The handle for an RSA public/private keypair using the Microsoft Crypto API.
- *
- * @since 1.6
- */
-class RSAKeyPair {
-
- private final RSAPrivateKey privateKey;
-
- private final RSAPublicKey publicKey;
-
- /**
- * Construct an RSAKeyPair object.
- */
- RSAKeyPair(long hCryptProv, long hCryptKey, int keyLength)
- {
- Key.NativeHandles handles = new Key.NativeHandles(hCryptProv, hCryptKey);
- privateKey = new RSAPrivateKey(handles, keyLength);
- publicKey = new RSAPublicKey(handles, keyLength);
- }
-
- public RSAPrivateKey getPrivate() {
- return privateKey;
- }
-
- public RSAPublicKey getPublic() {
- return publicKey;
- }
-}
--- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.mscapi;
-
-import java.util.UUID;
-import java.security.*;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.RSAKeyGenParameterSpec;
-
-import sun.security.rsa.RSAKeyFactory;
-import static sun.security.util.SecurityProviderConstants.DEF_RSA_KEY_SIZE;
-
-/**
- * RSA keypair generator.
- *
- * Standard algorithm, minimum key length is 512 bit, maximum is 16,384.
- * Generates a private key that is exportable.
- *
- * @since 1.6
- */
-public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi {
-
- // Supported by Microsoft Base, Strong and Enhanced Cryptographic Providers
- static final int KEY_SIZE_MIN = 512; // disallow MSCAPI min. of 384
- static final int KEY_SIZE_MAX = 16384;
-
- // size of the key to generate, KEY_SIZE_MIN <= keySize <= KEY_SIZE_MAX
- private int keySize;
-
- public RSAKeyPairGenerator() {
- // initialize to default in case the app does not call initialize()
- initialize(DEF_RSA_KEY_SIZE, null);
- }
-
- // initialize the generator. See JCA doc
- // random is always ignored
- public void initialize(int keySize, SecureRandom random) {
-
- try {
- RSAKeyFactory.checkKeyLengths(keySize, null,
- KEY_SIZE_MIN, KEY_SIZE_MAX);
- } catch (InvalidKeyException e) {
- throw new InvalidParameterException(e.getMessage());
- }
-
- this.keySize = keySize;
- }
-
- // second initialize method. See JCA doc
- // random and exponent are always ignored
- public void initialize(AlgorithmParameterSpec params, SecureRandom random)
- throws InvalidAlgorithmParameterException {
-
- int tmpSize;
- if (params == null) {
- tmpSize = DEF_RSA_KEY_SIZE;
- } else if (params instanceof RSAKeyGenParameterSpec) {
-
- if (((RSAKeyGenParameterSpec) params).getPublicExponent() != null) {
- throw new InvalidAlgorithmParameterException
- ("Exponent parameter is not supported");
- }
- tmpSize = ((RSAKeyGenParameterSpec) params).getKeysize();
-
- } else {
- throw new InvalidAlgorithmParameterException
- ("Params must be an instance of RSAKeyGenParameterSpec");
- }
-
- try {
- RSAKeyFactory.checkKeyLengths(tmpSize, null,
- KEY_SIZE_MIN, KEY_SIZE_MAX);
- } catch (InvalidKeyException e) {
- throw new InvalidAlgorithmParameterException(
- "Invalid Key sizes", e);
- }
-
- this.keySize = tmpSize;
- }
-
- // generate the keypair. See JCA doc
- public KeyPair generateKeyPair() {
-
- try {
-
- // Generate each keypair in a unique key container
- RSAKeyPair keys =
- generateRSAKeyPair(keySize,
- "{" + UUID.randomUUID().toString() + "}");
-
- return new KeyPair(keys.getPublic(), keys.getPrivate());
-
- } catch (KeyException e) {
- throw new ProviderException(e);
- }
- }
-
- private static native RSAKeyPair generateRSAKeyPair(int keySize,
- String keyContainerName) throws KeyException;
-}
--- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSAPrivateKey.java Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.mscapi;
-
-import java.security.PrivateKey;
-
-/**
- * The handle for an RSA private key using the Microsoft Crypto API.
- *
- * @author Stanley Man-Kit Ho
- * @since 1.6
- */
-class RSAPrivateKey extends Key implements PrivateKey
-{
- private static final long serialVersionUID = 8113152807912338063L;
-
- /**
- * Construct an RSAPrivateKey object.
- */
- RSAPrivateKey(long hCryptProv, long hCryptKey, int keyLength)
- {
- super(new NativeHandles(hCryptProv, hCryptKey), keyLength);
- }
-
- /**
- * Construct an RSAPrivateKey object.
- */
- RSAPrivateKey(NativeHandles handles, int keyLength)
- {
- super(handles, keyLength);
- }
-
- /**
- * Returns the standard algorithm name for this key. For
- * example, "RSA" would indicate that this key is a RSA key.
- * See Appendix A in the <a href=
- * "../../../guide/security/CryptoSpec.html#AppA">
- * Java Cryptography Architecture API Specification & Reference </a>
- * for information about standard algorithm names.
- *
- * @return the name of the algorithm associated with this key.
- */
- public String getAlgorithm()
- {
- return "RSA";
- }
-
- public String toString()
- {
- return "RSAPrivateKey [size=" + keyLength + " bits, type=" +
- getKeyType(handles.hCryptKey) + ", container=" +
- getContainerName(handles.hCryptProv) + "]";
- }
-
- // This class is not serializable
- private void writeObject(java.io.ObjectOutputStream out)
- throws java.io.IOException {
-
- throw new java.io.NotSerializableException();
- }
-}
--- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSAPublicKey.java Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.mscapi;
-
-import java.math.BigInteger;
-import java.security.KeyException;
-import java.security.KeyRep;
-import java.security.ProviderException;
-
-import sun.security.rsa.RSAUtil.KeyType;
-import sun.security.rsa.RSAPublicKeyImpl;
-
-/**
- * The handle for an RSA public key using the Microsoft Crypto API.
- *
- * @since 1.6
- */
-class RSAPublicKey extends Key implements java.security.interfaces.RSAPublicKey
-{
- private static final long serialVersionUID = -2289561342425825391L;
-
- private byte[] publicKeyBlob = null;
- private byte[] encoding = null;
- private BigInteger modulus = null;
- private BigInteger exponent = null;
-
- /**
- * Construct an RSAPublicKey object.
- */
- RSAPublicKey(long hCryptProv, long hCryptKey, int keyLength)
- {
- super(new NativeHandles(hCryptProv, hCryptKey), keyLength);
- }
-
- /**
- * Construct an RSAPublicKey object.
- */
- RSAPublicKey(NativeHandles handles, int keyLength)
- {
- super(handles, keyLength);
- }
-
- /**
- * Returns the standard algorithm name for this key. For
- * example, "RSA" would indicate that this key is a RSA key.
- * See Appendix A in the <a href=
- * "../../../guide/security/CryptoSpec.html#AppA">
- * Java Cryptography Architecture API Specification & Reference </a>
- * for information about standard algorithm names.
- *
- * @return the name of the algorithm associated with this key.
- */
- public String getAlgorithm()
- {
- return "RSA";
- }
-
- /**
- * Returns a printable description of the key.
- */
- public String toString()
- {
- StringBuffer sb = new StringBuffer();
-
- sb.append("RSAPublicKey [size=").append(keyLength)
- .append(" bits, type=").append(getKeyType(handles.hCryptKey))
- .append(", container=").append(getContainerName(handles.hCryptProv))
- .append("]\n modulus: ").append(getModulus())
- .append("\n public exponent: ").append(getPublicExponent());
-
- return sb.toString();
- }
-
- /**
- * Returns the public exponent.
- */
- public BigInteger getPublicExponent() {
-
- if (exponent == null) {
-
- try {
- publicKeyBlob = getPublicKeyBlob(handles.hCryptKey);
- exponent = new BigInteger(1, getExponent(publicKeyBlob));
-
- } catch (KeyException e) {
- throw new ProviderException(e);
- }
- }
-
- return exponent;
- }
-
- /**
- * Returns the modulus.
- */
- public BigInteger getModulus() {
-
- if (modulus == null) {
-
- try {
- publicKeyBlob = getPublicKeyBlob(handles.hCryptKey);
- modulus = new BigInteger(1, getModulus(publicKeyBlob));
-
- } catch (KeyException e) {
- throw new ProviderException(e);
- }
- }
-
- return modulus;
- }
-
- /**
- * Returns the name of the primary encoding format of this key,
- * or null if this key does not support encoding.
- * The primary encoding format is
- * named in terms of the appropriate ASN.1 data format, if an
- * ASN.1 specification for this key exists.
- * For example, the name of the ASN.1 data format for public
- * keys is <I>SubjectPublicKeyInfo</I>, as
- * defined by the X.509 standard; in this case, the returned format is
- * <code>"X.509"</code>. Similarly,
- * the name of the ASN.1 data format for private keys is
- * <I>PrivateKeyInfo</I>,
- * as defined by the PKCS #8 standard; in this case, the returned format is
- * <code>"PKCS#8"</code>.
- *
- * @return the primary encoding format of the key.
- */
- public String getFormat()
- {
- return "X.509";
- }
-
- /**
- * Returns the key in its primary encoding format, or null
- * if this key does not support encoding.
- *
- * @return the encoded key, or null if the key does not support
- * encoding.
- */
- public byte[] getEncoded()
- {
- if (encoding == null) {
-
- try {
- encoding = RSAPublicKeyImpl.newKey(KeyType.RSA, null,
- getModulus(), getPublicExponent()).getEncoded();
-
- } catch (KeyException e) {
- // ignore
- }
- }
- return encoding;
- }
-
- protected Object writeReplace() throws java.io.ObjectStreamException {
- return new KeyRep(KeyRep.Type.PUBLIC,
- getAlgorithm(),
- getFormat(),
- getEncoded());
- }
-
- /*
- * Returns the Microsoft CryptoAPI representation of the key.
- */
- private native byte[] getPublicKeyBlob(long hCryptKey) throws KeyException;
-
- /*
- * Returns the key's public exponent (in big-endian 2's complement format).
- */
- private native byte[] getExponent(byte[] keyBlob) throws KeyException;
-
- /*
- * Returns the key's modulus (in big-endian 2's complement format).
- */
- private native byte[] getModulus(byte[] keyBlob) throws KeyException;
-}
--- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSASignature.java Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,805 +0,0 @@
-/*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.mscapi;
-
-import java.nio.ByteBuffer;
-import java.security.*;
-import java.security.spec.AlgorithmParameterSpec;
-import java.math.BigInteger;
-import java.security.spec.MGF1ParameterSpec;
-import java.security.spec.PSSParameterSpec;
-import java.util.Locale;
-
-import sun.security.rsa.RSAKeyFactory;
-
-/**
- * RSA signature implementation. Supports RSA signing using PKCS#1 v1.5 padding.
- *
- * Objects should be instantiated by calling Signature.getInstance() using the
- * following algorithm names:
- *
- * . "NONEwithRSA"
- * . "SHA1withRSA"
- * . "SHA256withRSA"
- * . "SHA384withRSA"
- * . "SHA512withRSA"
- * . "MD5withRSA"
- * . "MD2withRSA"
- * . "RSASSA-PSS"
- *
- * NOTE: RSA keys must be at least 512 bits long.
- *
- * NOTE: NONEwithRSA must be supplied with a pre-computed message digest.
- * Only the following digest algorithms are supported: MD5, SHA-1,
- * SHA-256, SHA-384, SHA-512 and a special-purpose digest
- * algorithm which is a concatenation of SHA-1 and MD5 digests.
- *
- * @since 1.6
- * @author Stanley Man-Kit Ho
- */
-abstract class RSASignature extends java.security.SignatureSpi
-{
- // message digest implementation we use
- protected MessageDigest messageDigest;
-
- // message digest name
- private String messageDigestAlgorithm;
-
- // flag indicating whether the digest has been reset
- protected boolean needsReset;
-
- // the signing key
- protected Key privateKey = null;
-
- // the verification key
- protected Key publicKey = null;
-
- /**
- * Constructs a new RSASignature. Used by Raw subclass.
- */
- RSASignature() {
- messageDigest = null;
- messageDigestAlgorithm = null;
- }
-
- /**
- * Constructs a new RSASignature. Used by subclasses.
- */
- RSASignature(String digestName) {
-
- try {
- messageDigest = MessageDigest.getInstance(digestName);
- // Get the digest's canonical name
- messageDigestAlgorithm = messageDigest.getAlgorithm();
-
- } catch (NoSuchAlgorithmException e) {
- throw new ProviderException(e);
- }
-
- needsReset = false;
- }
-
- // Nested class for NONEwithRSA signatures
- public static final class Raw extends RSASignature {
-
- // the longest supported digest is 512 bits (SHA-512)
- private static final int RAW_RSA_MAX = 64;
-
- private final byte[] precomputedDigest;
- private int offset = 0;
-
- public Raw() {
- precomputedDigest = new byte[RAW_RSA_MAX];
- }
-
- // Stores the precomputed message digest value.
- @Override
- protected void engineUpdate(byte b) throws SignatureException {
- if (offset >= precomputedDigest.length) {
- offset = RAW_RSA_MAX + 1;
- return;
- }
- precomputedDigest[offset++] = b;
- }
-
- // Stores the precomputed message digest value.
- @Override
- protected void engineUpdate(byte[] b, int off, int len)
- throws SignatureException {
- if (len > (precomputedDigest.length - offset)) {
- offset = RAW_RSA_MAX + 1;
- return;
- }
- System.arraycopy(b, off, precomputedDigest, offset, len);
- offset += len;
- }
-
- // Stores the precomputed message digest value.
- @Override
- protected void engineUpdate(ByteBuffer byteBuffer) {
- int len = byteBuffer.remaining();
- if (len <= 0) {
- return;
- }
- if (len > (precomputedDigest.length - offset)) {
- offset = RAW_RSA_MAX + 1;
- return;
- }
- byteBuffer.get(precomputedDigest, offset, len);
- offset += len;
- }
-
- @Override
- protected void resetDigest(){
- offset = 0;
- }
-
- // Returns the precomputed message digest value.
- @Override
- protected byte[] getDigestValue() throws SignatureException {
- if (offset > RAW_RSA_MAX) {
- throw new SignatureException("Message digest is too long");
- }
-
- // Determine the digest algorithm from the digest length
- if (offset == 20) {
- setDigestName("SHA1");
- } else if (offset == 36) {
- setDigestName("SHA1+MD5");
- } else if (offset == 32) {
- setDigestName("SHA-256");
- } else if (offset == 48) {
- setDigestName("SHA-384");
- } else if (offset == 64) {
- setDigestName("SHA-512");
- } else if (offset == 16) {
- setDigestName("MD5");
- } else {
- throw new SignatureException(
- "Message digest length is not supported");
- }
-
- byte[] result = new byte[offset];
- System.arraycopy(precomputedDigest, 0, result, 0, offset);
- offset = 0;
-
- return result;
- }
- }
-
- public static final class SHA1 extends RSASignature {
- public SHA1() {
- super("SHA1");
- }
- }
-
- public static final class SHA256 extends RSASignature {
- public SHA256() {
- super("SHA-256");
- }
- }
-
- public static final class SHA384 extends RSASignature {
- public SHA384() {
- super("SHA-384");
- }
- }
-
- public static final class SHA512 extends RSASignature {
- public SHA512() {
- super("SHA-512");
- }
- }
-
- public static final class MD5 extends RSASignature {
- public MD5() {
- super("MD5");
- }
- }
-
- public static final class MD2 extends RSASignature {
- public MD2() {
- super("MD2");
- }
- }
-
- public static final class PSS extends RSASignature {
-
- private PSSParameterSpec pssParams = null;
-
- // Workaround: Cannot import raw public key to CNG. This signature
- // will be used for verification if key is not from MSCAPI.
- private Signature fallbackSignature;
-
- @Override
- protected void engineInitSign(PrivateKey key) throws InvalidKeyException {
- super.engineInitSign(key);
- fallbackSignature = null;
- }
-
- @Override
- protected void engineInitVerify(PublicKey key) throws InvalidKeyException {
- // This signature accepts only RSAPublicKey
- if ((key instanceof java.security.interfaces.RSAPublicKey) == false) {
- throw new InvalidKeyException("Key type not supported");
- }
-
- this.privateKey = null;
-
- if (key instanceof sun.security.mscapi.RSAPublicKey) {
- fallbackSignature = null;
- publicKey = (sun.security.mscapi.RSAPublicKey) key;
- } else {
- if (fallbackSignature == null) {
- try {
- fallbackSignature = Signature.getInstance(
- "RSASSA-PSS", "SunRsaSign");
- } catch (NoSuchAlgorithmException | NoSuchProviderException e) {
- throw new InvalidKeyException("Invalid key", e);
- }
- }
- fallbackSignature.initVerify(key);
- if (pssParams != null) {
- try {
- fallbackSignature.setParameter(pssParams);
- } catch (InvalidAlgorithmParameterException e) {
- throw new InvalidKeyException("Invalid params", e);
- }
- }
- publicKey = null;
- }
- resetDigest();
- }
-
- @Override
- protected void engineUpdate(byte b) throws SignatureException {
- ensureInit();
- if (fallbackSignature != null) {
- fallbackSignature.update(b);
- } else {
- messageDigest.update(b);
- }
- needsReset = true;
- }
-
- @Override
- protected void engineUpdate(byte[] b, int off, int len) throws SignatureException {
- ensureInit();
- if (fallbackSignature != null) {
- fallbackSignature.update(b, off, len);
- } else {
- messageDigest.update(b, off, len);
- }
- needsReset = true;
- }
-
- @Override
- protected void engineUpdate(ByteBuffer input) {
- try {
- ensureInit();
- } catch (SignatureException se) {
- // hack for working around API bug
- throw new RuntimeException(se.getMessage());
- }
- if (fallbackSignature != null) {
- try {
- fallbackSignature.update(input);
- } catch (SignatureException se) {
- // hack for working around API bug
- throw new RuntimeException(se.getMessage());
- }
- } else {
- messageDigest.update(input);
- }
- needsReset = true;
- }
-
- @Override
- protected byte[] engineSign() throws SignatureException {
- ensureInit();
- byte[] hash = getDigestValue();
- return signPssHash(hash, hash.length,
- pssParams.getSaltLength(),
- ((MGF1ParameterSpec)
- pssParams.getMGFParameters()).getDigestAlgorithm(),
- privateKey.getHCryptProvider(), privateKey.getHCryptKey());
- }
-
- @Override
- protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
- ensureInit();
- if (fallbackSignature != null) {
- needsReset = false;
- return fallbackSignature.verify(sigBytes);
- } else {
- byte[] hash = getDigestValue();
- return verifyPssSignedHash(
- hash, hash.length,
- sigBytes, sigBytes.length,
- pssParams.getSaltLength(),
- ((MGF1ParameterSpec)
- pssParams.getMGFParameters()).getDigestAlgorithm(),
- publicKey.getHCryptProvider(),
- publicKey.getHCryptKey()
- );
- }
- }
-
- @Override
- protected void engineSetParameter(AlgorithmParameterSpec params)
- throws InvalidAlgorithmParameterException {
- if (needsReset) {
- throw new ProviderException
- ("Cannot set parameters during operations");
- }
- this.pssParams = validateSigParams(params);
- if (fallbackSignature != null) {
- fallbackSignature.setParameter(params);
- }
- }
-
- @Override
- protected AlgorithmParameters engineGetParameters() {
- AlgorithmParameters ap = null;
- if (this.pssParams != null) {
- try {
- ap = AlgorithmParameters.getInstance("RSASSA-PSS");
- ap.init(this.pssParams);
- } catch (GeneralSecurityException gse) {
- throw new ProviderException(gse.getMessage());
- }
- }
- return ap;
- }
-
- private void ensureInit() throws SignatureException {
- if (this.privateKey == null && this.publicKey == null
- && fallbackSignature == null) {
- throw new SignatureException("Missing key");
- }
- if (this.pssParams == null) {
- // Parameters are required for signature verification
- throw new SignatureException
- ("Parameters required for RSASSA-PSS signatures");
- }
- if (fallbackSignature == null && messageDigest == null) {
- // This could happen if initVerify(softKey), setParameter(),
- // and initSign() were called. No messageDigest. Create it.
- try {
- messageDigest = MessageDigest
- .getInstance(pssParams.getDigestAlgorithm());
- } catch (NoSuchAlgorithmException e) {
- throw new SignatureException(e);
- }
- }
- }
-
- /**
- * Validate the specified Signature PSS parameters.
- */
- private PSSParameterSpec validateSigParams(AlgorithmParameterSpec p)
- throws InvalidAlgorithmParameterException {
-
- if (p == null) {
- throw new InvalidAlgorithmParameterException
- ("Parameters cannot be null");
- }
-
- if (!(p instanceof PSSParameterSpec)) {
- throw new InvalidAlgorithmParameterException
- ("parameters must be type PSSParameterSpec");
- }
-
- // no need to validate again if same as current signature parameters
- PSSParameterSpec params = (PSSParameterSpec) p;
- if (params == this.pssParams) return params;
-
- // now sanity check the parameter values
- if (!(params.getMGFAlgorithm().equalsIgnoreCase("MGF1"))) {
- throw new InvalidAlgorithmParameterException("Only supports MGF1");
-
- }
-
- if (params.getTrailerField() != PSSParameterSpec.TRAILER_FIELD_BC) {
- throw new InvalidAlgorithmParameterException
- ("Only supports TrailerFieldBC(1)");
- }
-
- AlgorithmParameterSpec algSpec = params.getMGFParameters();
- if (!(algSpec instanceof MGF1ParameterSpec)) {
- throw new InvalidAlgorithmParameterException
- ("Only support MGF1ParameterSpec");
- }
-
- MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)algSpec;
-
- String msgHashAlg = params.getDigestAlgorithm()
- .toLowerCase(Locale.ROOT).replaceAll("-", "");
- if (msgHashAlg.equals("sha")) {
- msgHashAlg = "sha1";
- }
- String mgf1HashAlg = mgfSpec.getDigestAlgorithm()
- .toLowerCase(Locale.ROOT).replaceAll("-", "");
- if (mgf1HashAlg.equals("sha")) {
- mgf1HashAlg = "sha1";
- }
-
- if (!mgf1HashAlg.equals(msgHashAlg)) {
- throw new InvalidAlgorithmParameterException
- ("MGF1 hash must be the same as message hash");
- }
-
- return params;
- }
-
- /**
- * Sign hash using CNG API with HCRYPTKEY. Used by RSASSA-PSS.
- */
- private native static byte[] signPssHash(byte[] hash,
- int hashSize, int saltLength, String hashAlgorithm,
- long hCryptProv, long nCryptKey)
- throws SignatureException;
-
- /**
- * Verify a signed hash using CNG API with HCRYPTKEY. Used by RSASSA-PSS.
- * This method is not used now. See {@link #fallbackSignature}.
- */
- private native static boolean verifyPssSignedHash(byte[] hash, int hashSize,
- byte[] signature, int signatureSize,
- int saltLength, String hashAlgorithm,
- long hCryptProv, long hKey) throws SignatureException;
- }
-
- // initialize for signing. See JCA doc
- @Override
- protected void engineInitVerify(PublicKey key)
- throws InvalidKeyException
- {
- // This signature accepts only RSAPublicKey
- if ((key instanceof java.security.interfaces.RSAPublicKey) == false) {
- throw new InvalidKeyException("Key type not supported");
- }
-
- java.security.interfaces.RSAPublicKey rsaKey =
- (java.security.interfaces.RSAPublicKey) key;
-
- if ((key instanceof sun.security.mscapi.RSAPublicKey) == false) {
-
- // convert key to MSCAPI format
-
- BigInteger modulus = rsaKey.getModulus();
- BigInteger exponent = rsaKey.getPublicExponent();
-
- // Check against the local and global values to make sure
- // the sizes are ok. Round up to the nearest byte.
- RSAKeyFactory.checkKeyLengths(((modulus.bitLength() + 7) & ~7),
- exponent, -1, RSAKeyPairGenerator.KEY_SIZE_MAX);
-
- byte[] modulusBytes = modulus.toByteArray();
- byte[] exponentBytes = exponent.toByteArray();
-
- // Adjust key length due to sign bit
- int keyBitLength = (modulusBytes[0] == 0)
- ? (modulusBytes.length - 1) * 8
- : modulusBytes.length * 8;
-
- byte[] keyBlob = generatePublicKeyBlob(
- keyBitLength, modulusBytes, exponentBytes);
-
- try {
- publicKey = importPublicKey(keyBlob, keyBitLength);
-
- } catch (KeyStoreException e) {
- throw new InvalidKeyException(e);
- }
-
- } else {
- publicKey = (sun.security.mscapi.RSAPublicKey) key;
- }
-
- this.privateKey = null;
- resetDigest();
- }
-
- // initialize for signing. See JCA doc
- @Override
- protected void engineInitSign(PrivateKey key) throws InvalidKeyException
- {
- // This signature accepts only RSAPrivateKey
- if ((key instanceof sun.security.mscapi.RSAPrivateKey) == false) {
- throw new InvalidKeyException("Key type not supported");
- }
- privateKey = (sun.security.mscapi.RSAPrivateKey) key;
-
- // Check against the local and global values to make sure
- // the sizes are ok. Round up to nearest byte.
- RSAKeyFactory.checkKeyLengths(((privateKey.length() + 7) & ~7),
- null, RSAKeyPairGenerator.KEY_SIZE_MIN,
- RSAKeyPairGenerator.KEY_SIZE_MAX);
-
- this.publicKey = null;
- resetDigest();
- }
-
- /**
- * Resets the message digest if needed.
- */
- protected void resetDigest() {
- if (needsReset) {
- if (messageDigest != null) {
- messageDigest.reset();
- }
- needsReset = false;
- }
- }
-
- protected byte[] getDigestValue() throws SignatureException {
- needsReset = false;
- return messageDigest.digest();
- }
-
- protected void setDigestName(String name) {
- messageDigestAlgorithm = name;
- }
-
- /**
- * Updates the data to be signed or verified
- * using the specified byte.
- *
- * @param b the byte to use for the update.
- *
- * @exception SignatureException if the engine is not initialized
- * properly.
- */
- @Override
- protected void engineUpdate(byte b) throws SignatureException
- {
- messageDigest.update(b);
- needsReset = true;
- }
-
- /**
- * Updates the data to be signed or verified, using the
- * specified array of bytes, starting at the specified offset.
- *
- * @param b the array of bytes
- * @param off the offset to start from in the array of bytes
- * @param len the number of bytes to use, starting at offset
- *
- * @exception SignatureException if the engine is not initialized
- * properly
- */
- @Override
- protected void engineUpdate(byte[] b, int off, int len)
- throws SignatureException
- {
- messageDigest.update(b, off, len);
- needsReset = true;
- }
-
- /**
- * Updates the data to be signed or verified, using the
- * specified ByteBuffer.
- *
- * @param input the ByteBuffer
- */
- @Override
- protected void engineUpdate(ByteBuffer input)
- {
- messageDigest.update(input);
- needsReset = true;
- }
-
- /**
- * Returns the signature bytes of all the data
- * updated so far.
- * The format of the signature depends on the underlying
- * signature scheme.
- *
- * @return the signature bytes of the signing operation's result.
- *
- * @exception SignatureException if the engine is not
- * initialized properly or if this signature algorithm is unable to
- * process the input data provided.
- */
- @Override
- protected byte[] engineSign() throws SignatureException {
-
- byte[] hash = getDigestValue();
-
- // Omit the hash OID when generating a Raw signature
- boolean noHashOID = this instanceof Raw;
-
- // Sign hash using MS Crypto APIs
-
- byte[] result = signHash(noHashOID, hash, hash.length,
- messageDigestAlgorithm, privateKey.getHCryptProvider(),
- privateKey.getHCryptKey());
-
- // Convert signature array from little endian to big endian
- return convertEndianArray(result);
- }
-
- /**
- * Convert array from big endian to little endian, or vice versa.
- */
- private byte[] convertEndianArray(byte[] byteArray)
- {
- if (byteArray == null || byteArray.length == 0)
- return byteArray;
-
- byte [] retval = new byte[byteArray.length];
-
- // make it big endian
- for (int i=0;i < byteArray.length;i++)
- retval[i] = byteArray[byteArray.length - i - 1];
-
- return retval;
- }
-
- /**
- * Sign hash using Microsoft Crypto API with HCRYPTKEY.
- * The returned data is in little-endian.
- */
- private native static byte[] signHash(boolean noHashOID, byte[] hash,
- int hashSize, String hashAlgorithm, long hCryptProv, long hCryptKey)
- throws SignatureException;
-
- /**
- * Verify a signed hash using Microsoft Crypto API with HCRYPTKEY.
- */
- private native static boolean verifySignedHash(byte[] hash, int hashSize,
- String hashAlgorithm, byte[] signature, int signatureSize,
- long hCryptProv, long hCryptKey) throws SignatureException;
-
- /**
- * Verifies the passed-in signature.
- *
- * @param sigBytes the signature bytes to be verified.
- *
- * @return true if the signature was verified, false if not.
- *
- * @exception SignatureException if the engine is not
- * initialized properly, the passed-in signature is improperly
- * encoded or of the wrong type, if this signature algorithm is unable to
- * process the input data provided, etc.
- */
- @Override
- protected boolean engineVerify(byte[] sigBytes)
- throws SignatureException
- {
- byte[] hash = getDigestValue();
-
- return verifySignedHash(hash, hash.length,
- messageDigestAlgorithm, convertEndianArray(sigBytes),
- sigBytes.length, publicKey.getHCryptProvider(),
- publicKey.getHCryptKey());
- }
-
- /**
- * Sets the specified algorithm parameter to the specified
- * value. This method supplies a general-purpose mechanism through
- * which it is possible to set the various parameters of this object.
- * A parameter may be any settable parameter for the algorithm, such as
- * a parameter size, or a source of random bits for signature generation
- * (if appropriate), or an indication of whether or not to perform
- * a specific but optional computation. A uniform algorithm-specific
- * naming scheme for each parameter is desirable but left unspecified
- * at this time.
- *
- * @param param the string identifier of the parameter.
- *
- * @param value the parameter value.
- *
- * @exception InvalidParameterException if <code>param</code> is an
- * invalid parameter for this signature algorithm engine,
- * the parameter is already set
- * and cannot be set again, a security exception occurs, and so on.
- *
- * @deprecated Replaced by {@link
- * #engineSetParameter(java.security.spec.AlgorithmParameterSpec)
- * engineSetParameter}.
- */
- @Override
- @Deprecated
- protected void engineSetParameter(String param, Object value)
- throws InvalidParameterException
- {
- throw new InvalidParameterException("Parameter not supported");
- }
-
- /**
- * Sets this signature engine with the specified algorithm parameter.
- *
- * @param params the parameters
- *
- * @exception InvalidAlgorithmParameterException if the given
- * parameter is invalid
- */
- @Override
- protected void engineSetParameter(AlgorithmParameterSpec params)
- throws InvalidAlgorithmParameterException
- {
- if (params != null) {
- throw new InvalidAlgorithmParameterException("No parameter accepted");
- }
- }
-
- /**
- * Gets the value of the specified algorithm parameter.
- * This method supplies a general-purpose mechanism through which it
- * is possible to get the various parameters of this object. A parameter
- * may be any settable parameter for the algorithm, such as a parameter
- * size, or a source of random bits for signature generation (if
- * appropriate), or an indication of whether or not to perform a
- * specific but optional computation. A uniform algorithm-specific
- * naming scheme for each parameter is desirable but left unspecified
- * at this time.
- *
- * @param param the string name of the parameter.
- *
- * @return the object that represents the parameter value, or null if
- * there is none.
- *
- * @exception InvalidParameterException if <code>param</code> is an
- * invalid parameter for this engine, or another exception occurs while
- * trying to get this parameter.
- *
- * @deprecated
- */
- @Override
- @Deprecated
- protected Object engineGetParameter(String param)
- throws InvalidParameterException
- {
- throw new InvalidParameterException("Parameter not supported");
- }
-
- /**
- * Gets the algorithm parameter from this signature engine.
- *
- * @return the parameter, or null if no parameter is used.
- */
- @Override
- protected AlgorithmParameters engineGetParameters() {
- return null;
- }
-
- /**
- * Generates a public-key BLOB from a key's components.
- */
- // used by RSACipher
- static native byte[] generatePublicKeyBlob(
- int keyBitLength, byte[] modulus, byte[] publicExponent)
- throws InvalidKeyException;
-
- /**
- * Imports a public-key BLOB.
- */
- // used by RSACipher
- static native RSAPublicKey importPublicKey(byte[] keyBlob, int keySize)
- throws KeyStoreException;
-}
--- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/SunMSCAPI.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/SunMSCAPI.java Tue Dec 18 15:08:56 2018 -0500
@@ -33,7 +33,6 @@
import java.security.ProviderException;
import java.util.HashMap;
import java.util.Arrays;
-import java.util.Map;
import static sun.security.util.SecurityConstants.PROVIDER_VER;
@@ -86,36 +85,46 @@
}
} else if (type.equals("KeyStore")) {
if (algo.equals("Windows-MY")) {
- return new KeyStore.MY();
+ return new CKeyStore.MY();
} else if (algo.equals("Windows-ROOT")) {
- return new KeyStore.ROOT();
+ return new CKeyStore.ROOT();
}
} else if (type.equals("Signature")) {
if (algo.equals("NONEwithRSA")) {
- return new RSASignature.Raw();
+ return new CSignature.NONEwithRSA();
} else if (algo.equals("SHA1withRSA")) {
- return new RSASignature.SHA1();
+ return new CSignature.SHA1withRSA();
} else if (algo.equals("SHA256withRSA")) {
- return new RSASignature.SHA256();
+ return new CSignature.SHA256withRSA();
} else if (algo.equals("SHA384withRSA")) {
- return new RSASignature.SHA384();
+ return new CSignature.SHA384withRSA();
} else if (algo.equals("SHA512withRSA")) {
- return new RSASignature.SHA512();
+ return new CSignature.SHA512withRSA();
} else if (algo.equals("MD5withRSA")) {
- return new RSASignature.MD5();
+ return new CSignature.MD5withRSA();
} else if (algo.equals("MD2withRSA")) {
- return new RSASignature.MD2();
+ return new CSignature.MD2withRSA();
} else if (algo.equals("RSASSA-PSS")) {
- return new RSASignature.PSS();
+ return new CSignature.PSS();
+ } else if (algo.equals("SHA1withECDSA")) {
+ return new CSignature.SHA1withECDSA();
+ } else if (algo.equals("SHA224withECDSA")) {
+ return new CSignature.SHA224withECDSA();
+ } else if (algo.equals("SHA256withECDSA")) {
+ return new CSignature.SHA256withECDSA();
+ } else if (algo.equals("SHA384withECDSA")) {
+ return new CSignature.SHA384withECDSA();
+ } else if (algo.equals("SHA512withECDSA")) {
+ return new CSignature.SHA512withECDSA();
}
} else if (type.equals("KeyPairGenerator")) {
if (algo.equals("RSA")) {
- return new RSAKeyPairGenerator();
+ return new CKeyPairGenerator.RSA();
}
} else if (type.equals("Cipher")) {
if (algo.equals("RSA") ||
algo.equals("RSA/ECB/PKCS1Padding")) {
- return new RSACipher();
+ return new CRSACipher();
}
}
} catch (Exception ex) {
@@ -147,56 +156,75 @@
* Key store
*/
putService(new ProviderService(p, "KeyStore",
- "Windows-MY", "sun.security.mscapi.KeyStore$MY"));
+ "Windows-MY", "sun.security.mscapi.CKeyStore$MY"));
putService(new ProviderService(p, "KeyStore",
- "Windows-ROOT", "sun.security.mscapi.KeyStore$ROOT"));
+ "Windows-ROOT", "sun.security.mscapi.CKeyStore$ROOT"));
/*
* Signature engines
*/
HashMap<String, String> attrs = new HashMap<>(1);
- attrs.put("SupportedKeyClasses", "sun.security.mscapi.Key");
+ attrs.put("SupportedKeyClasses", "sun.security.mscapi.CKey");
// NONEwithRSA must be supplied with a pre-computed message digest.
// Only the following digest algorithms are supported: MD5, SHA-1,
// SHA-256, SHA-384, SHA-512 and a special-purpose digest
// algorithm which is a concatenation of SHA-1 and MD5 digests.
putService(new ProviderService(p, "Signature",
- "NONEwithRSA", "sun.security.mscapi.RSASignature$Raw",
+ "NONEwithRSA", "sun.security.mscapi.CSignature$NONEwithRSA",
null, attrs));
putService(new ProviderService(p, "Signature",
- "SHA1withRSA", "sun.security.mscapi.RSASignature$SHA1",
+ "SHA1withRSA", "sun.security.mscapi.CSignature$SHA1withRSA",
null, attrs));
putService(new ProviderService(p, "Signature",
- "SHA256withRSA", "sun.security.mscapi.RSASignature$SHA256",
+ "SHA256withRSA", "sun.security.mscapi.CSignature$SHA256withRSA",
new String[] { "1.2.840.113549.1.1.11", "OID.1.2.840.113549.1.1.11" },
attrs));
putService(new ProviderService(p, "Signature",
- "SHA384withRSA", "sun.security.mscapi.RSASignature$SHA384",
+ "SHA384withRSA", "sun.security.mscapi.CSignature$SHA384withRSA",
new String[] { "1.2.840.113549.1.1.12", "OID.1.2.840.113549.1.1.12" },
attrs));
putService(new ProviderService(p, "Signature",
- "SHA512withRSA", "sun.security.mscapi.RSASignature$SHA512",
+ "SHA512withRSA", "sun.security.mscapi.CSignature$SHA512withRSA",
new String[] { "1.2.840.113549.1.1.13", "OID.1.2.840.113549.1.1.13" },
attrs));
putService(new ProviderService(p, "Signature",
- "RSASSA-PSS", "sun.security.mscapi.RSASignature$PSS",
+ "RSASSA-PSS", "sun.security.mscapi.CSignature$PSS",
new String[] { "1.2.840.113549.1.1.10", "OID.1.2.840.113549.1.1.10" },
attrs));
putService(new ProviderService(p, "Signature",
- "MD5withRSA", "sun.security.mscapi.RSASignature$MD5",
+ "MD5withRSA", "sun.security.mscapi.CSignature$MD5withRSA",
+ null, attrs));
+ putService(new ProviderService(p, "Signature",
+ "MD2withRSA", "sun.security.mscapi.CSignature$MD2withRSA",
null, attrs));
putService(new ProviderService(p, "Signature",
- "MD2withRSA", "sun.security.mscapi.RSASignature$MD2",
- null, attrs));
-
+ "SHA1withECDSA", "sun.security.mscapi.CSignature$SHA1withECDSA",
+ new String[] { "1.2.840.10045.4.1", "OID.1.2.840.10045.4.1" },
+ attrs));
+ putService(new ProviderService(p, "Signature",
+ "SHA224withECDSA", "sun.security.mscapi.CSignature$SHA224withECDSA",
+ new String[] { "1.2.840.10045.4.3.1", "OID.1.2.840.10045.4.3.1"},
+ attrs));
+ putService(new ProviderService(p, "Signature",
+ "SHA256withECDSA", "sun.security.mscapi.CSignature$SHA256withECDSA",
+ new String[] { "1.2.840.10045.4.3.2", "OID.1.2.840.10045.4.3.2"},
+ attrs));
+ putService(new ProviderService(p, "Signature",
+ "SHA384withECDSA", "sun.security.mscapi.CSignature$SHA384withECDSA",
+ new String[] { "1.2.840.10045.4.3.3", "OID.1.2.840.10045.4.3.3"},
+ attrs));
+ putService(new ProviderService(p, "Signature",
+ "SHA512withECDSA", "sun.security.mscapi.CSignature$SHA512withECDSA",
+ new String[] { "1.2.840.10045.4.3.4", "OID.1.2.840.10045.4.3.4"},
+ attrs));
/*
* Key Pair Generator engines
*/
attrs.clear();
attrs.put("KeySize", "16384");
putService(new ProviderService(p, "KeyPairGenerator",
- "RSA", "sun.security.mscapi.RSAKeyPairGenerator",
+ "RSA", "sun.security.mscapi.CKeyPairGenerator$RSA",
null, attrs));
/*
@@ -205,12 +233,12 @@
attrs.clear();
attrs.put("SupportedModes", "ECB");
attrs.put("SupportedPaddings", "PKCS1PADDING");
- attrs.put("SupportedKeyClasses", "sun.security.mscapi.Key");
+ attrs.put("SupportedKeyClasses", "sun.security.mscapi.CKey");
putService(new ProviderService(p, "Cipher",
- "RSA", "sun.security.mscapi.RSACipher",
+ "RSA", "sun.security.mscapi.CRSACipher",
null, attrs));
putService(new ProviderService(p, "Cipher",
- "RSA/ECB/PKCS1Padding", "sun.security.mscapi.RSACipher",
+ "RSA/ECB/PKCS1Padding", "sun.security.mscapi.CRSACipher",
null, attrs));
return null;
}
--- a/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -37,13 +37,15 @@
#include <wincrypt.h>
#include <stdio.h>
#include <memory>
-#include "sun_security_mscapi_Key.h"
-#include "sun_security_mscapi_KeyStore.h"
+#include "sun_security_mscapi_CKey.h"
+#include "sun_security_mscapi_CKeyStore.h"
#include "sun_security_mscapi_PRNG.h"
-#include "sun_security_mscapi_RSACipher.h"
-#include "sun_security_mscapi_RSAKeyPairGenerator.h"
-#include "sun_security_mscapi_RSAPublicKey.h"
-#include "sun_security_mscapi_RSASignature.h"
+#include "sun_security_mscapi_CRSACipher.h"
+#include "sun_security_mscapi_CKeyPairGenerator_RSA.h"
+#include "sun_security_mscapi_CPublicKey.h"
+#include "sun_security_mscapi_CPublicKey_CRSAPublicKey.h"
+#include "sun_security_mscapi_CSignature.h"
+#include "sun_security_mscapi_CSignature_RSA.h"
#define OID_EKU_ANY "2.5.29.37.0"
@@ -63,30 +65,53 @@
__leave; \
}
-//#define PP(fmt, ...) \
-// fprintf(stdout, "SSPI (%ld): ", __LINE__); \
-// fprintf(stdout, fmt, ##__VA_ARGS__); \
-// fprintf(stdout, "\n"); \
-// fflush(stdout)
+#define PP(fmt, ...) \
+ if (trace) { \
+ fprintf(stdout, "MSCAPI (%ld): ", __LINE__); \
+ fprintf(stdout, fmt, ##__VA_ARGS__); \
+ fprintf(stdout, "\n"); \
+ fflush(stdout); \
+ }
extern "C" {
+char* trace = getenv("CAPI_TRACE");
+
/*
* Declare library specific JNI_Onload entry if static build
*/
DEF_STATIC_JNI_OnLoad
-//void dump(LPSTR title, PBYTE data, DWORD len)
-//{
-// printf("==== %s ====\n", title);
-// for (DWORD i = 0; i < len; i++) {
-// if (i != 0 && i % 16 == 0) {
-// printf("\n");
-// }
-// printf("%02X ", *(data + i) & 0xff);
-// }
-// printf("\n");
-//}
+void showProperty(NCRYPT_HANDLE hKey);
+
+void dump(LPSTR title, PBYTE data, DWORD len)
+{
+ if (trace) {
+ printf("==== %s ====\n", title);
+ for (DWORD i = 0; i < len; i+=16) {
+ printf("%04x: ", i);
+ for (int j = 0; j < 16; j++) {
+ if (j == 8) {
+ printf(" ");
+ }
+ if (i + j < len) {
+ printf("%02X ", *(data + i + j) & 0xff);
+ } else {
+ printf(" ");
+ }
+ }
+ for (int j = 0; j < 16; j++) {
+ if (i + j < len) {
+ int k = *(data + i + j) & 0xff;
+ if (k < 32 || k > 127) printf(".");
+ else printf("%c", (char)k);
+ }
+ }
+ printf("\n");
+ }
+ fflush(stdout);
+ }
+}
/*
* Throws an arbitrary Java exception with the given message.
@@ -248,7 +273,7 @@
JNIEXPORT jlong JNICALL Java_sun_security_mscapi_PRNG_getContext
(JNIEnv *env, jclass clazz) {
HCRYPTPROV hCryptProv = NULL;
- if(::CryptAcquireContext(
+ if(::CryptAcquireContext( //deprecated
&hCryptProv,
NULL,
NULL,
@@ -269,7 +294,7 @@
JNIEXPORT void JNICALL Java_sun_security_mscapi_PRNG_releaseContext
(JNIEnv *env, jclass clazz, jlong ctxt) {
if (ctxt) {
- ::CryptReleaseContext((HCRYPTPROV)ctxt, 0);
+ ::CryptReleaseContext((HCRYPTPROV)ctxt, 0); //deprecated
}
}
@@ -304,7 +329,7 @@
__leave;
}
- if (::CryptGenRandom(
+ if (::CryptGenRandom( //deprecated
hCryptProv,
length,
(BYTE *) reseedBytes) == FALSE) {
@@ -330,7 +355,7 @@
__leave;
}
- if (::CryptGenRandom(
+ if (::CryptGenRandom( //deprecated
hCryptProv,
length,
(BYTE *) seedBytes) == FALSE) {
@@ -359,11 +384,11 @@
/*
- * Class: sun_security_mscapi_KeyStore
+ * Class: sun_security_mscapi_CKeyStore
* Method: loadKeysOrCertificateChains
- * Signature: (Ljava/lang/String;Ljava/util/Collection;)V
+ * Signature: (Ljava/lang/String;)V
*/
-JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateChains
+JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_loadKeysOrCertificateChains
(JNIEnv *env, jobject obj, jstring jCertStoreName)
{
/**
@@ -429,10 +454,10 @@
}
// Determine method ID to generate RSA certificate chain
- jmethodID mGenRSAKeyAndCertChain = env->GetMethodID(clazzOfThis,
- "generateRSAKeyAndCertificateChain",
- "(Ljava/lang/String;JJILjava/util/Collection;)V");
- if (mGenRSAKeyAndCertChain == NULL) {
+ jmethodID mGenKeyAndCertChain = env->GetMethodID(clazzOfThis,
+ "generateKeyAndCertificateChain",
+ "(ZLjava/lang/String;JJILjava/util/Collection;)V");
+ if (mGenKeyAndCertChain == NULL) {
__leave;
}
@@ -441,6 +466,7 @@
// NULL to retrieve the first certificate in the store.
while (pCertContext = ::CertEnumCertificatesInStore(hCertStore, pCertContext))
{
+ PP("--------------------------");
// Check if private key available - client authentication certificate
// must have private key available.
HCRYPTPROV hCryptProv = NULL;
@@ -451,41 +477,48 @@
DWORD dwPublicKeyLength = 0;
// First, probe it silently
- if (::CryptAcquireCertificatePrivateKey(pCertContext, CRYPT_ACQUIRE_SILENT_FLAG, NULL,
+ if (::CryptAcquireCertificatePrivateKey(pCertContext,
+ CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG | CRYPT_ACQUIRE_SILENT_FLAG, NULL,
&hCryptProv, &dwKeySpec, &bCallerFreeProv) == FALSE
&& GetLastError() != NTE_SILENT_CONTEXT)
{
+ PP("bHasNoPrivateKey = TRUE!");
bHasNoPrivateKey = TRUE;
}
else
{
if (bCallerFreeProv == TRUE) {
- ::CryptReleaseContext(hCryptProv, NULL);
+ ::CryptReleaseContext(hCryptProv, NULL); // deprecated
bCallerFreeProv = FALSE;
}
// Second, acquire the key normally (not silently)
- if (::CryptAcquireCertificatePrivateKey(pCertContext, 0, NULL,
+ if (::CryptAcquireCertificatePrivateKey(pCertContext, CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG, NULL,
&hCryptProv, &dwKeySpec, &bCallerFreeProv) == FALSE)
{
+ PP("bHasNoPrivateKey = TRUE!!");
bHasNoPrivateKey = TRUE;
}
else
{
- // Private key is available
- BOOL bGetUserKey = ::CryptGetUserKey(hCryptProv, dwKeySpec, &hUserKey);
+ if ((dwKeySpec & CERT_NCRYPT_KEY_SPEC) == CERT_NCRYPT_KEY_SPEC) {
+ PP("CNG %I64d", hCryptProv);
+ } else {
+ // Private key is available
+ BOOL bGetUserKey = ::CryptGetUserKey(hCryptProv, dwKeySpec, &hUserKey); //deprecated
- // Skip certificate if cannot find private key
- if (bGetUserKey == FALSE) {
- if (bCallerFreeProv)
- ::CryptReleaseContext(hCryptProv, NULL);
- continue;
+ // Skip certificate if cannot find private key
+ if (bGetUserKey == FALSE) {
+ if (bCallerFreeProv)
+ ::CryptReleaseContext(hCryptProv, NULL); // deprecated
+ continue;
+ }
+
+ // Set cipher mode to ECB
+ DWORD dwCipherMode = CRYPT_MODE_ECB;
+ ::CryptSetKeyParam(hUserKey, KP_MODE, (BYTE*)&dwCipherMode, NULL); //deprecated
+ PP("CAPI %I64d %I64d", hCryptProv, hUserKey);
}
-
- // Set cipher mode to ECB
- DWORD dwCipherMode = CRYPT_MODE_ECB;
- ::CryptSetKeyParam(hUserKey, KP_MODE, (BYTE*)&dwCipherMode, NULL);
-
// If the private key is present in smart card, we may not be able to
// determine the key length by using the private key handle. However,
// since public/private key pairs must have the same length, we could
@@ -557,6 +590,7 @@
env->CallVoidMethod(obj, mGenCert, byteArray, jArrayList);
}
+ PP("%s: %s", pszNameString, pCertContext->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId);
if (bHasNoPrivateKey)
{
// Generate certificate chain and store into cert chain
@@ -567,20 +601,40 @@
}
else
{
- // Determine key type: RSA or DSA
- DWORD dwData = CALG_RSA_KEYX;
- DWORD dwSize = sizeof(DWORD);
- ::CryptGetKeyParam(hUserKey, KP_ALGID, (BYTE*)&dwData,
- &dwSize, NULL);
-
- if ((dwData & ALG_TYPE_RSA) == ALG_TYPE_RSA)
- {
- // Generate RSA certificate chain and store into cert
- // chain collection
- env->CallVoidMethod(obj, mGenRSAKeyAndCertChain,
- env->NewStringUTF(pszNameString),
- (jlong) hCryptProv, (jlong) hUserKey,
- dwPublicKeyLength, jArrayList);
+ if (hUserKey) {
+ // Only accept RSA for CAPI
+ DWORD dwData = CALG_RSA_KEYX;
+ DWORD dwSize = sizeof(DWORD);
+ ::CryptGetKeyParam(hUserKey, KP_ALGID, (BYTE*)&dwData, //deprecated
+ &dwSize, NULL);
+ if ((dwData & ALG_TYPE_RSA) == ALG_TYPE_RSA)
+ {
+ // Generate RSA certificate chain and store into cert
+ // chain collection
+ env->CallVoidMethod(obj, mGenKeyAndCertChain,
+ 1,
+ env->NewStringUTF(pszNameString),
+ (jlong) hCryptProv, (jlong) hUserKey,
+ dwPublicKeyLength, jArrayList);
+ }
+ } else {
+ // Only accept EC for CNG
+ BYTE buffer[32];
+ DWORD len = 0;
+ if (::NCryptGetProperty(
+ hCryptProv, NCRYPT_ALGORITHM_PROPERTY,
+ (PBYTE)buffer, 32, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) {
+ if (buffer[0] == 'E' && buffer[2] == 'C'
+ && (dwPublicKeyLength == 256
+ || dwPublicKeyLength == 384
+ || dwPublicKeyLength == 521)) {
+ env->CallVoidMethod(obj, mGenKeyAndCertChain,
+ 0,
+ env->NewStringUTF(pszNameString),
+ (jlong) hCryptProv, 0,
+ dwPublicKeyLength, jArrayList);
+ }
+ }
}
}
}
@@ -588,6 +642,8 @@
// Free cert chain
if (pCertChainContext)
::CertFreeCertificateChain(pCertChainContext);
+ } else {
+ PP("GetCertificateChain failed %d", GetLastError());
}
}
}
@@ -614,18 +670,18 @@
(JNIEnv *env, jclass clazz, jlong hCryptProv, jlong hCryptKey)
{
if (hCryptKey != NULL)
- ::CryptDestroyKey((HCRYPTKEY) hCryptKey);
+ ::CryptDestroyKey((HCRYPTKEY) hCryptKey); // deprecated
if (hCryptProv != NULL)
- ::CryptReleaseContext((HCRYPTPROV) hCryptProv, NULL);
+ ::CryptReleaseContext((HCRYPTPROV) hCryptProv, NULL); // deprecated
}
/*
- * Class: sun_security_mscapi_RSASignature
+ * Class: sun_security_mscapi_CSignature
* Method: signHash
* Signature: (Z[BILjava/lang/String;JJ)[B
*/
-JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash
+JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CSignature_signHash
(JNIEnv *env, jclass clazz, jboolean noHashOID, jbyteArray jHash,
jint jHashSize, jstring jHashAlgorithm, jlong hCryptProv,
jlong hCryptKey)
@@ -642,7 +698,7 @@
ALG_ID algId = MapHashAlgorithm(env, jHashAlgorithm);
// Acquire a hash object handle.
- if (::CryptCreateHash(HCRYPTPROV(hCryptProv), algId, 0, 0, &hHash) == FALSE)
+ if (::CryptCreateHash(HCRYPTPROV(hCryptProv), algId, 0, 0, &hHash) == FALSE) //deprecated
{
// Failover to using the PROV_RSA_AES CSP
@@ -651,11 +707,11 @@
pbData[0] = '\0';
// Get name of the key container
- ::CryptGetProvParam((HCRYPTPROV)hCryptProv, PP_CONTAINER,
+ ::CryptGetProvParam((HCRYPTPROV)hCryptProv, PP_CONTAINER, //deprecated
(BYTE *)pbData, &cbData, 0);
// Acquire an alternative CSP handle
- if (::CryptAcquireContext(&hCryptProvAlt, LPCSTR(pbData), NULL,
+ if (::CryptAcquireContext(&hCryptProvAlt, LPCSTR(pbData), NULL, //deprecated
PROV_RSA_AES, 0) == FALSE)
{
@@ -664,7 +720,7 @@
}
// Acquire a hash object handle.
- if (::CryptCreateHash(HCRYPTPROV(hCryptProvAlt), algId, 0, 0,
+ if (::CryptCreateHash(HCRYPTPROV(hCryptProvAlt), algId, 0, 0, //deprecated
&hHash) == FALSE)
{
ThrowException(env, SIGNATURE_EXCEPTION, GetLastError());
@@ -680,7 +736,7 @@
env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer);
// Set hash value in the hash object
- if (::CryptSetHashParam(hHash, HP_HASHVAL, (BYTE*)pHashBuffer, NULL) == FALSE)
+ if (::CryptSetHashParam(hHash, HP_HASHVAL, (BYTE*)pHashBuffer, NULL) == FALSE) //deprecated
{
ThrowException(env, SIGNATURE_EXCEPTION, GetLastError());
__leave;
@@ -691,7 +747,7 @@
ALG_ID dwAlgId;
DWORD dwAlgIdLen = sizeof(ALG_ID);
- if (! ::CryptGetKeyParam((HCRYPTKEY) hCryptKey, KP_ALGID, (BYTE*)&dwAlgId, &dwAlgIdLen, 0)) {
+ if (! ::CryptGetKeyParam((HCRYPTKEY) hCryptKey, KP_ALGID, (BYTE*)&dwAlgId, &dwAlgIdLen, 0)) { //deprecated
ThrowException(env, SIGNATURE_EXCEPTION, GetLastError());
__leave;
@@ -708,7 +764,7 @@
dwFlags = CRYPT_NOHASHOID; // omit hash OID in NONEwithRSA signature
}
- if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, NULL, &dwBufLen) == FALSE)
+ if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, NULL, &dwBufLen) == FALSE) //deprecated
{
ThrowException(env, SIGNATURE_EXCEPTION, GetLastError());
__leave;
@@ -718,7 +774,7 @@
if (pSignedHashBuffer == NULL) {
__leave;
}
- if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, (BYTE*)pSignedHashBuffer, &dwBufLen) == FALSE)
+ if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, (BYTE*)pSignedHashBuffer, &dwBufLen) == FALSE) //deprecated
{
ThrowException(env, SIGNATURE_EXCEPTION, GetLastError());
__leave;
@@ -741,22 +797,22 @@
delete [] pHashBuffer;
if (hHash)
- ::CryptDestroyHash(hHash);
+ ::CryptDestroyHash(hHash); //deprecated
if (hCryptProvAlt)
- ::CryptReleaseContext(hCryptProvAlt, 0);
+ ::CryptReleaseContext(hCryptProvAlt, 0); // deprecated
}
return jSignedHash;
}
/*
- * Class: sun_security_mscapi_RSASignature_PSS
- * Method: signPssHash
- * Signature: ([BIILjava/lang/String;JJ)[B
+ * Class: sun_security_mscapi_CSignature
+ * Method: signCngHash
+ * Signature: (I[BIILjava/lang/String;JJ)[B
*/
-JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_00024PSS_signPssHash
- (JNIEnv *env, jclass clazz, jbyteArray jHash,
+JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CSignature_signCngHash
+ (JNIEnv *env, jclass clazz, jint type, jbyteArray jHash,
jint jHashSize, jint saltLen, jstring jHashAlgorithm, jlong hCryptProv,
jlong hCryptKey)
{
@@ -768,13 +824,17 @@
__try
{
- SS_CHECK(::NCryptTranslateHandle(
+ if (hCryptKey == 0) {
+ hk = (NCRYPT_KEY_HANDLE)hCryptProv;
+ } else {
+ SS_CHECK(::NCryptTranslateHandle(
NULL,
&hk,
hCryptProv,
hCryptKey,
NULL,
0));
+ }
// Copy hash from Java to native buffer
pHashBuffer = new (env) jbyte[jHashSize];
@@ -783,43 +843,66 @@
}
env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer);
- BCRYPT_PSS_PADDING_INFO pssInfo;
- pssInfo.pszAlgId = MapHashIdentifier(env, jHashAlgorithm);
- pssInfo.cbSalt = saltLen;
+ VOID* param;
+ DWORD dwFlags;
- if (pssInfo.pszAlgId == NULL) {
- ThrowExceptionWithMessage(env, SIGNATURE_EXCEPTION,
- "Unrecognised hash algorithm");
- __leave;
+ switch (type) {
+ case 0:
+ param = NULL;
+ dwFlags = 0;
+ break;
+ case 1:
+ BCRYPT_PKCS1_PADDING_INFO pkcs1Info;
+ pkcs1Info.pszAlgId = MapHashIdentifier(env, jHashAlgorithm);
+ if (pkcs1Info.pszAlgId == NULL) {
+ ThrowExceptionWithMessage(env, SIGNATURE_EXCEPTION,
+ "Unrecognised hash algorithm");
+ __leave;
+ }
+ param = &pkcs1Info;
+ dwFlags = BCRYPT_PAD_PKCS1;
+ break;
+ case 2:
+ BCRYPT_PSS_PADDING_INFO pssInfo;
+ pssInfo.pszAlgId = MapHashIdentifier(env, jHashAlgorithm);
+ pssInfo.cbSalt = saltLen;
+ if (pssInfo.pszAlgId == NULL) {
+ ThrowExceptionWithMessage(env, SIGNATURE_EXCEPTION,
+ "Unrecognised hash algorithm");
+ __leave;
+ }
+ param = &pssInfo;
+ dwFlags = BCRYPT_PAD_PSS;
+ break;
}
- DWORD dwBufLen = 0;
+ DWORD jSignedHashSize = 0;
SS_CHECK(::NCryptSignHash(
hk,
- &pssInfo,
+ param,
(BYTE*)pHashBuffer, jHashSize,
- NULL, 0, &dwBufLen,
- BCRYPT_PAD_PSS
+ NULL, 0, &jSignedHashSize,
+ dwFlags
));
- pSignedHashBuffer = new (env) jbyte[dwBufLen];
+ pSignedHashBuffer = new (env) jbyte[jSignedHashSize];
if (pSignedHashBuffer == NULL) {
__leave;
}
SS_CHECK(::NCryptSignHash(
hk,
- &pssInfo,
+ param,
(BYTE*)pHashBuffer, jHashSize,
- (BYTE*)pSignedHashBuffer, dwBufLen, &dwBufLen,
- BCRYPT_PAD_PSS
+ (BYTE*)pSignedHashBuffer, jSignedHashSize, &jSignedHashSize,
+ dwFlags
));
// Create new byte array
- jbyteArray temp = env->NewByteArray(dwBufLen);
+ jbyteArray temp = env->NewByteArray(jSignedHashSize);
// Copy data from native buffer
- env->SetByteArrayRegion(temp, 0, dwBufLen, pSignedHashBuffer);
+ env->SetByteArrayRegion(temp, 0, jSignedHashSize, pSignedHashBuffer);
jSignedHash = temp;
}
@@ -831,7 +914,7 @@
if (pHashBuffer)
delete [] pHashBuffer;
- if (hk != NULL)
+ if (hCryptKey != 0 && hk != NULL)
::NCryptFreeObject(hk);
}
@@ -839,11 +922,11 @@
}
/*
- * Class: sun_security_mscapi_RSASignature
+ * Class: sun_security_mscapi_CSignature
* Method: verifySignedHash
* Signature: ([BIL/java/lang/String;[BIJJ)Z
*/
-JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHash
+JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_CSignature_verifySignedHash
(JNIEnv *env, jclass clazz, jbyteArray jHash, jint jHashSize,
jstring jHashAlgorithm, jbyteArray jSignedHash, jint jSignedHashSize,
jlong hCryptProv, jlong hCryptKey)
@@ -871,11 +954,11 @@
pbData[0] = '\0';
// Get name of the key container
- ::CryptGetProvParam((HCRYPTPROV)hCryptProv, PP_CONTAINER,
+ ::CryptGetProvParam((HCRYPTPROV)hCryptProv, PP_CONTAINER, //deprecated
(BYTE *)pbData, &cbData, 0);
// Acquire an alternative CSP handle
- if (::CryptAcquireContext(&hCryptProvAlt, LPCSTR(pbData), NULL,
+ if (::CryptAcquireContext(&hCryptProvAlt, LPCSTR(pbData), NULL, //deprecated
PROV_RSA_AES, 0) == FALSE)
{
@@ -907,7 +990,7 @@
pSignedHashBuffer);
// Set hash value in the hash object
- if (::CryptSetHashParam(hHash, HP_HASHVAL, (BYTE*) pHashBuffer, NULL)
+ if (::CryptSetHashParam(hHash, HP_HASHVAL, (BYTE*) pHashBuffer, NULL) //deprecated
== FALSE)
{
ThrowException(env, SIGNATURE_EXCEPTION, GetLastError());
@@ -918,7 +1001,7 @@
// public key algorithm, so AT_SIGNATURE is used.
// Verify the signature
- if (::CryptVerifySignatureA(hHash, (BYTE *) pSignedHashBuffer,
+ if (::CryptVerifySignatureA(hHash, (BYTE *) pSignedHashBuffer, //deprecated
dwSignedHashBufferLen, (HCRYPTKEY) hCryptKey, NULL, 0) == TRUE)
{
result = JNI_TRUE;
@@ -934,26 +1017,26 @@
delete [] pHashBuffer;
if (hHash)
- ::CryptDestroyHash(hHash);
+ ::CryptDestroyHash(hHash); //deprecated
if (hCryptProvAlt)
- ::CryptReleaseContext(hCryptProvAlt, 0);
+ ::CryptReleaseContext(hCryptProvAlt, 0); // deprecated
}
return result;
}
/*
- * Class: sun_security_mscapi_RSASignature_PSS
- * Method: verifyPssSignedHash
- * Signature: ([BI[BIILjava/lang/String;JJ)Z
+ * Class: sun_security_mscapi_CSignature
+ * Method: verifyCngSignedHash
+ * Signature: (I[BI[BIILjava/lang/String;JJ)Z
*/
-JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_00024PSS_verifyPssSignedHash
- (JNIEnv *env, jclass clazz,
+JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_CSignature_verifyCngSignedHash
+ (JNIEnv *env, jclass clazz, jint type,
jbyteArray jHash, jint jHashSize,
jbyteArray jSignedHash, jint jSignedHashSize,
jint saltLen, jstring jHashAlgorithm,
- jlong hCryptProv, jlong hKey)
+ jlong hCryptProv, jlong hCryptKey)
{
jbyte* pHashBuffer = NULL;
jbyte* pSignedHashBuffer = NULL;
@@ -962,13 +1045,17 @@
__try
{
- SS_CHECK(::NCryptTranslateHandle(
+ if (hCryptKey == 0) {
+ hk = (NCRYPT_KEY_HANDLE)hCryptProv;
+ } else {
+ SS_CHECK(::NCryptTranslateHandle(
NULL,
&hk,
hCryptProv,
- hKey,
+ hCryptKey,
NULL,
0));
+ }
// Copy hash and signedHash from Java to native buffer
pHashBuffer = new (env) jbyte[jHashSize];
@@ -984,24 +1071,43 @@
env->GetByteArrayRegion(jSignedHash, 0, jSignedHashSize,
pSignedHashBuffer);
- BCRYPT_PSS_PADDING_INFO pssInfo;
- pssInfo.pszAlgId = MapHashIdentifier(env, jHashAlgorithm);
- pssInfo.cbSalt = saltLen;
+ VOID* param;
+ DWORD dwFlags;
- if (pssInfo.pszAlgId == NULL) {
- ThrowExceptionWithMessage(env, SIGNATURE_EXCEPTION,
- "Unrecognised hash algorithm");
- __leave;
+ switch (type) {
+ case 0:
+ param = NULL;
+ dwFlags = 0;
+ break;
+ case 1:
+ BCRYPT_PKCS1_PADDING_INFO pkcs1Info;
+ pkcs1Info.pszAlgId = MapHashIdentifier(env, jHashAlgorithm);
+ if (pkcs1Info.pszAlgId == NULL) {
+ ThrowExceptionWithMessage(env, SIGNATURE_EXCEPTION,
+ "Unrecognised hash algorithm");
+ __leave;
+ }
+ param = &pkcs1Info;
+ dwFlags = NCRYPT_PAD_PKCS1_FLAG;
+ break;
+ case 2:
+ BCRYPT_PSS_PADDING_INFO pssInfo;
+ pssInfo.pszAlgId = MapHashIdentifier(env, jHashAlgorithm);
+ pssInfo.cbSalt = saltLen;
+ if (pssInfo.pszAlgId == NULL) {
+ ThrowExceptionWithMessage(env, SIGNATURE_EXCEPTION,
+ "Unrecognised hash algorithm");
+ __leave;
+ }
+ param = &pssInfo;
+ dwFlags = NCRYPT_PAD_PSS_FLAG;
+ break;
}
- // For RSA, the hash encryption algorithm is normally the same as the
- // public key algorithm, so AT_SIGNATURE is used.
-
- // Verify the signature
- if (::NCryptVerifySignature(hk, &pssInfo,
+ if (::NCryptVerifySignature(hk, param,
(BYTE *) pHashBuffer, jHashSize,
(BYTE *) pSignedHashBuffer, jSignedHashSize,
- NCRYPT_PAD_PSS_FLAG) == ERROR_SUCCESS)
+ dwFlags) == ERROR_SUCCESS)
{
result = JNI_TRUE;
}
@@ -1015,20 +1121,115 @@
if (pHashBuffer)
delete [] pHashBuffer;
- if (hk != NULL)
+ if (hCryptKey != 0 && hk != NULL)
::NCryptFreeObject(hk);
}
return result;
}
+#define DUMP_PROP(p) \
+ if (::NCryptGetProperty(hKey, p, (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { \
+ sprintf(header, "%s %ls", #p, p); \
+ dump(header, buffer, len); \
+ }
+
+#define EXPORT_BLOB(p) \
+ desc.cBuffers = 0; \
+ if (::NCryptExportKey(hKey, NULL, p, &desc, (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { \
+ sprintf(header, "%s %ls (%ld)", #p, p, desc.cBuffers); \
+ dump(header, buffer, len); \
+ for (int i = 0; i < (int)desc.cBuffers; i++) { \
+ sprintf(header, "desc %ld", desc.pBuffers[i].BufferType); \
+ dump(header, (PBYTE)desc.pBuffers[i].pvBuffer, desc.pBuffers[i].cbBuffer); \
+ } \
+ }
+
+void showProperty(NCRYPT_HANDLE hKey) {
+ char header[100];
+ BYTE buffer[8192];
+ DWORD len = 9;
+ NCryptBufferDesc desc;
+ DUMP_PROP(NCRYPT_ALGORITHM_GROUP_PROPERTY);
+ DUMP_PROP(NCRYPT_ALGORITHM_PROPERTY);
+ DUMP_PROP(NCRYPT_ASSOCIATED_ECDH_KEY);
+ DUMP_PROP(NCRYPT_BLOCK_LENGTH_PROPERTY);
+ DUMP_PROP(NCRYPT_CERTIFICATE_PROPERTY);
+ DUMP_PROP(NCRYPT_DH_PARAMETERS_PROPERTY);
+ DUMP_PROP(NCRYPT_EXPORT_POLICY_PROPERTY);
+ DUMP_PROP(NCRYPT_IMPL_TYPE_PROPERTY);
+ DUMP_PROP(NCRYPT_KEY_TYPE_PROPERTY);
+ DUMP_PROP(NCRYPT_KEY_USAGE_PROPERTY);
+ DUMP_PROP(NCRYPT_LAST_MODIFIED_PROPERTY);
+ DUMP_PROP(NCRYPT_LENGTH_PROPERTY);
+ DUMP_PROP(NCRYPT_LENGTHS_PROPERTY);
+ DUMP_PROP(NCRYPT_MAX_NAME_LENGTH_PROPERTY);
+ DUMP_PROP(NCRYPT_NAME_PROPERTY);
+ DUMP_PROP(NCRYPT_PIN_PROMPT_PROPERTY);
+ DUMP_PROP(NCRYPT_PIN_PROPERTY);
+ DUMP_PROP(NCRYPT_PROVIDER_HANDLE_PROPERTY);
+ DUMP_PROP(NCRYPT_READER_PROPERTY);
+ DUMP_PROP(NCRYPT_ROOT_CERTSTORE_PROPERTY);
+ DUMP_PROP(NCRYPT_SCARD_PIN_ID);
+ DUMP_PROP(NCRYPT_SCARD_PIN_INFO);
+ DUMP_PROP(NCRYPT_SECURE_PIN_PROPERTY);
+ DUMP_PROP(NCRYPT_SECURITY_DESCR_PROPERTY);
+ DUMP_PROP(NCRYPT_SECURITY_DESCR_SUPPORT_PROPERTY);
+ DUMP_PROP(NCRYPT_SMARTCARD_GUID_PROPERTY);
+ DUMP_PROP(NCRYPT_UI_POLICY_PROPERTY);
+ DUMP_PROP(NCRYPT_UNIQUE_NAME_PROPERTY);
+ DUMP_PROP(NCRYPT_USE_CONTEXT_PROPERTY);
+ DUMP_PROP(NCRYPT_USE_COUNT_ENABLED_PROPERTY);
+ DUMP_PROP(NCRYPT_USE_COUNT_PROPERTY);
+ DUMP_PROP(NCRYPT_USER_CERTSTORE_PROPERTY);
+ DUMP_PROP(NCRYPT_VERSION_PROPERTY);
+ DUMP_PROP(NCRYPT_WINDOW_HANDLE_PROPERTY);
+
+ EXPORT_BLOB(BCRYPT_DH_PRIVATE_BLOB);
+ EXPORT_BLOB(BCRYPT_DH_PUBLIC_BLOB);
+ EXPORT_BLOB(BCRYPT_DSA_PRIVATE_BLOB);
+ EXPORT_BLOB(BCRYPT_DSA_PUBLIC_BLOB);
+ EXPORT_BLOB(BCRYPT_ECCPRIVATE_BLOB);
+ EXPORT_BLOB(BCRYPT_ECCPUBLIC_BLOB);
+ EXPORT_BLOB(BCRYPT_PUBLIC_KEY_BLOB);
+ EXPORT_BLOB(BCRYPT_PRIVATE_KEY_BLOB);
+ EXPORT_BLOB(BCRYPT_RSAFULLPRIVATE_BLOB);
+ EXPORT_BLOB(BCRYPT_RSAPRIVATE_BLOB);
+ EXPORT_BLOB(BCRYPT_RSAPUBLIC_BLOB);
+ EXPORT_BLOB(LEGACY_DH_PRIVATE_BLOB);
+ EXPORT_BLOB(LEGACY_DH_PUBLIC_BLOB);
+ EXPORT_BLOB(LEGACY_DSA_PRIVATE_BLOB);
+ EXPORT_BLOB(LEGACY_DSA_PUBLIC_BLOB);
+ EXPORT_BLOB(LEGACY_RSAPRIVATE_BLOB);
+ EXPORT_BLOB(LEGACY_RSAPUBLIC_BLOB);
+ EXPORT_BLOB(NCRYPT_CIPHER_KEY_BLOB);
+ EXPORT_BLOB(NCRYPT_OPAQUETRANSPORT_BLOB);
+ EXPORT_BLOB(NCRYPT_PKCS7_ENVELOPE_BLOB);
+ //EXPORT_BLOB(NCRYPTBUFFER_CERT_BLOB);
+ //EXPORT_BLOB(NCRYPT_PKCS8_PRIVATE_KEY_BLOB);
+ BCryptBuffer bb;
+ bb.BufferType = NCRYPTBUFFER_PKCS_SECRET;
+ bb.cbBuffer = 18;
+ bb.pvBuffer = L"changeit";
+ BCryptBufferDesc bbd;
+ bbd.ulVersion = 0;
+ bbd.cBuffers = 1;
+ bbd.pBuffers = &bb;
+ if(::NCryptExportKey(hKey, NULL, NCRYPT_PKCS8_PRIVATE_KEY_BLOB, NULL,
+ (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) {
+ sprintf(header, "NCRYPT_PKCS8_PRIVATE_KEY_BLOB %ls", NCRYPT_PKCS8_PRIVATE_KEY_BLOB);
+ dump(header, buffer, len);
+ }
+ EXPORT_BLOB(NCRYPT_PROTECTED_KEY_BLOB);
+}
+
/*
- * Class: sun_security_mscapi_RSAKeyPairGenerator
- * Method: generateRSAKeyPair
- * Signature: (ILjava/lang/String;)Lsun/security/mscapi/RSAKeyPair;
+ * Class: sun_security_mscapi_CKeyPairGenerator_RSA
+ * Method: generateCKeyPair
+ * Signature: (Ljava/lang/String;ILjava/lang/String;)Lsun/security/mscapi/CKeyPair;
*/
-JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSAKeyPairGenerator_generateRSAKeyPair
- (JNIEnv *env, jclass clazz, jint keySize, jstring keyContainerName)
+JNIEXPORT jobject JNICALL Java_sun_security_mscapi_CKeyPairGenerator_00024RSA_generateCKeyPair
+ (JNIEnv *env, jclass clazz, jstring alg, jint keySize, jstring keyContainerName)
{
HCRYPTPROV hCryptProv = NULL;
HCRYPTKEY hKeyPair;
@@ -1046,7 +1247,7 @@
// Acquire a CSP context (create a new key container).
// Prefer a PROV_RSA_AES CSP, when available, due to its support
// for SHA-2-based signatures.
- if (::CryptAcquireContext(
+ if (::CryptAcquireContext( //deprecated
&hCryptProv,
pszKeyContainerName,
NULL,
@@ -1055,7 +1256,7 @@
{
// Failover to using the default CSP (PROV_RSA_FULL)
- if (::CryptAcquireContext(
+ if (::CryptAcquireContext( //deprecated
&hCryptProv,
pszKeyContainerName,
NULL,
@@ -1067,8 +1268,8 @@
}
}
- // Generate an RSA keypair
- if(::CryptGenKey(
+ // Generate an keypair
+ if(::CryptGenKey( //deprecated
hCryptProv,
AT_KEYEXCHANGE,
dwFlags,
@@ -1078,22 +1279,22 @@
__leave;
}
- // Get the method ID for the RSAKeyPair constructor
- jclass clazzRSAKeyPair =
- env->FindClass("sun/security/mscapi/RSAKeyPair");
- if (clazzRSAKeyPair == NULL) {
+ // Get the method ID for the CKeyPair constructor
+ jclass clazzCKeyPair =
+ env->FindClass("sun/security/mscapi/CKeyPair");
+ if (clazzCKeyPair == NULL) {
__leave;
}
- jmethodID mNewRSAKeyPair =
- env->GetMethodID(clazzRSAKeyPair, "<init>", "(JJI)V");
- if (mNewRSAKeyPair == NULL) {
+ jmethodID mNewCKeyPair =
+ env->GetMethodID(clazzCKeyPair, "<init>", "(Ljava/lang/String;JJI)V");
+ if (mNewCKeyPair == NULL) {
__leave;
}
- // Create a new RSA keypair
- keypair = env->NewObject(clazzRSAKeyPair, mNewRSAKeyPair,
- (jlong) hCryptProv, (jlong) hKeyPair, keySize);
+ // Create a new keypair
+ keypair = env->NewObject(clazzCKeyPair, mNewCKeyPair,
+ alg, (jlong) hCryptProv, (jlong) hKeyPair, keySize);
}
__finally
@@ -1109,18 +1310,18 @@
}
/*
- * Class: sun_security_mscapi_Key
+ * Class: sun_security_mscapi_CKey
* Method: getContainerName
* Signature: (J)Ljava/lang/String;
*/
-JNIEXPORT jstring JNICALL Java_sun_security_mscapi_Key_getContainerName
+JNIEXPORT jstring JNICALL Java_sun_security_mscapi_CKey_getContainerName
(JNIEnv *env, jclass jclazz, jlong hCryptProv)
{
DWORD cbData = 256;
BYTE pbData[256];
pbData[0] = '\0';
- ::CryptGetProvParam(
+ ::CryptGetProvParam( //deprecated
(HCRYPTPROV)hCryptProv,
PP_CONTAINER,
(BYTE *)pbData,
@@ -1131,17 +1332,17 @@
}
/*
- * Class: sun_security_mscapi_Key
+ * Class: sun_security_mscapi_CKey
* Method: getKeyType
* Signature: (J)Ljava/lang/String;
*/
-JNIEXPORT jstring JNICALL Java_sun_security_mscapi_Key_getKeyType
+JNIEXPORT jstring JNICALL Java_sun_security_mscapi_CKey_getKeyType
(JNIEnv *env, jclass jclazz, jlong hCryptKey)
{
ALG_ID dwAlgId;
DWORD dwAlgIdLen = sizeof(ALG_ID);
- if (::CryptGetKeyParam((HCRYPTKEY) hCryptKey, KP_ALGID, (BYTE*)&dwAlgId, &dwAlgIdLen, 0)) {
+ if (::CryptGetKeyParam((HCRYPTKEY) hCryptKey, KP_ALGID, (BYTE*)&dwAlgId, &dwAlgIdLen, 0)) { //deprecated
if (CALG_RSA_SIGN == dwAlgId) {
return env->NewStringUTF("Signature");
@@ -1161,11 +1362,11 @@
}
/*
- * Class: sun_security_mscapi_KeyStore
+ * Class: sun_security_mscapi_CKeyStore
* Method: storeCertificate
* Signature: (Ljava/lang/String;Ljava/lang/String;[BIJJ)V
*/
-JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
+JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_storeCertificate
(JNIEnv *env, jobject obj, jstring jCertStoreName, jstring jCertAliasName,
jbyteArray jCertEncoding, jint jCertEncodingSize, jlong hCryptProv,
jlong hCryptKey)
@@ -1240,7 +1441,7 @@
DWORD dwDataLen;
// Get the name of the key container
- if (! ::CryptGetProvParam(
+ if (! ::CryptGetProvParam( //deprecated
(HCRYPTPROV) hCryptProv,
PP_CONTAINER,
NULL,
@@ -1256,7 +1457,7 @@
__leave;
}
- if (! ::CryptGetProvParam(
+ if (! ::CryptGetProvParam( //deprecated
(HCRYPTPROV) hCryptProv,
PP_CONTAINER,
(BYTE *) pszContainerName,
@@ -1283,7 +1484,7 @@
// Get the name of the provider
- if (! ::CryptGetProvParam(
+ if (! ::CryptGetProvParam( //deprecated
(HCRYPTPROV) hCryptProv,
PP_NAME,
NULL,
@@ -1299,7 +1500,7 @@
__leave;
}
- if (! ::CryptGetProvParam(
+ if (! ::CryptGetProvParam( //deprecated
(HCRYPTPROV) hCryptProv,
PP_NAME,
(BYTE *) pszProviderName,
@@ -1325,7 +1526,7 @@
keyProviderInfo.pwszProvName = pwszProviderName;
// Get and set the type of the provider
- if (! ::CryptGetProvParam(
+ if (! ::CryptGetProvParam( //deprecated
(HCRYPTPROV) hCryptProv,
PP_PROVTYPE,
(LPBYTE) &keyProviderInfo.dwProvType,
@@ -1344,7 +1545,7 @@
keyProviderInfo.rgProvParam = NULL;
// Get the key's algorithm ID
- if (! ::CryptGetKeyParam(
+ if (! ::CryptGetKeyParam( //deprecated
(HCRYPTKEY) hCryptKey,
KP_ALGID,
(LPBYTE) &keyProviderInfo.dwKeySpec,
@@ -1423,11 +1624,11 @@
}
/*
- * Class: sun_security_mscapi_KeyStore
+ * Class: sun_security_mscapi_CKeyStore
* Method: removeCertificate
* Signature: (Ljava/lang/String;Ljava/lang/String;[BI)V
*/
-JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_removeCertificate
+JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_removeCertificate
(JNIEnv *env, jobject obj, jstring jCertStoreName, jstring jCertAliasName,
jbyteArray jCertEncoding, jint jCertEncodingSize) {
@@ -1539,11 +1740,11 @@
}
/*
- * Class: sun_security_mscapi_KeyStore
+ * Class: sun_security_mscapi_CKeyStore
* Method: destroyKeyContainer
* Signature: (Ljava/lang/String;)V
*/
-JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_destroyKeyContainer
+JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_destroyKeyContainer
(JNIEnv *env, jobject clazz, jstring keyContainerName)
{
HCRYPTPROV hCryptProv = NULL;
@@ -1565,7 +1766,7 @@
}
// Acquire a CSP context (to the key container).
- if (::CryptAcquireContext(
+ if (::CryptAcquireContext( //deprecated
&hCryptProv,
pszKeyContainerName,
NULL,
@@ -1588,11 +1789,11 @@
}
/*
- * Class: sun_security_mscapi_RSACipher
+ * Class: sun_security_mscapi_CRSACipher
* Method: encryptDecrypt
* Signature: ([BIJZ)[B
*/
-JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSACipher_encryptDecrypt
+JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CRSACipher_encryptDecrypt
(JNIEnv *env, jclass clazz, jbyteArray jData, jint jDataSize, jlong hKey,
jboolean doEncrypt)
{
@@ -1614,7 +1815,7 @@
if (doEncrypt == JNI_TRUE) {
// encrypt
- if (! ::CryptEncrypt((HCRYPTKEY) hKey, 0, TRUE, 0, (BYTE *)pData,
+ if (! ::CryptEncrypt((HCRYPTKEY) hKey, 0, TRUE, 0, (BYTE *)pData, //deprecated
&dwDataLen, dwBufLen)) {
ThrowException(env, KEY_EXCEPTION, GetLastError());
@@ -1637,7 +1838,7 @@
}
// decrypt
- if (! ::CryptDecrypt((HCRYPTKEY) hKey, 0, TRUE, 0, (BYTE *)pData,
+ if (! ::CryptDecrypt((HCRYPTKEY) hKey, 0, TRUE, 0, (BYTE *)pData, //deprecated
&dwBufLen)) {
ThrowException(env, KEY_EXCEPTION, GetLastError());
@@ -1661,12 +1862,12 @@
}
/*
- * Class: sun_security_mscapi_RSAPublicKey
+ * Class: sun_security_mscapi_CPublicKey
* Method: getPublicKeyBlob
- * Signature: (J)[B
+ * Signature: (JJ)[B
*/
-JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getPublicKeyBlob
- (JNIEnv *env, jobject clazz, jlong hCryptKey) {
+JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CPublicKey_getPublicKeyBlob
+ (JNIEnv *env, jobject clazz, jlong hCryptProv, jlong hCryptKey) {
jbyteArray blob = NULL;
DWORD dwBlobLen;
@@ -1676,11 +1877,17 @@
{
// Determine the size of the blob
- if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, NULL,
- &dwBlobLen)) {
+ if (hCryptKey == 0) {
+ SS_CHECK(::NCryptExportKey(
+ hCryptProv, NULL, BCRYPT_ECCPUBLIC_BLOB,
+ NULL, NULL, 0, &dwBlobLen, NCRYPT_SILENT_FLAG));
+ } else {
+ if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, NULL, //deprecated
+ &dwBlobLen)) {
- ThrowException(env, KEY_EXCEPTION, GetLastError());
- __leave;
+ ThrowException(env, KEY_EXCEPTION, GetLastError());
+ __leave;
+ }
}
pbKeyBlob = new (env) BYTE[dwBlobLen];
@@ -1689,11 +1896,17 @@
}
// Generate key blob
- if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0,
- pbKeyBlob, &dwBlobLen)) {
+ if (hCryptKey == 0) {
+ SS_CHECK(::NCryptExportKey(
+ hCryptProv, NULL, BCRYPT_ECCPUBLIC_BLOB,
+ NULL, pbKeyBlob, dwBlobLen, &dwBlobLen, NCRYPT_SILENT_FLAG));
+ } else {
+ if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, //deprecated
+ pbKeyBlob, &dwBlobLen)) {
- ThrowException(env, KEY_EXCEPTION, GetLastError());
- __leave;
+ ThrowException(env, KEY_EXCEPTION, GetLastError());
+ __leave;
+ }
}
// Create new byte array
@@ -1712,11 +1925,11 @@
}
/*
- * Class: sun_security_mscapi_RSAPublicKey
+ * Class: sun_security_mscapi_CPublicKey_CRSAPublicKey
* Method: getExponent
* Signature: ([B)[B
*/
-JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getExponent
+JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CPublicKey_00024CRSAPublicKey_getExponent
(JNIEnv *env, jobject clazz, jbyteArray jKeyBlob) {
jbyteArray exponent = NULL;
@@ -1768,11 +1981,11 @@
}
/*
- * Class: sun_security_mscapi_RSAPublicKey
+ * Class: sun_security_mscapi_CPublicKey_CRSAPublicKey
* Method: getModulus
* Signature: ([B)[B
*/
-JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getModulus
+JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CPublicKey_00024CRSAPublicKey_getModulus
(JNIEnv *env, jobject clazz, jbyteArray jKeyBlob) {
jbyteArray modulus = NULL;
@@ -2041,11 +2254,11 @@
}
/*
- * Class: sun_security_mscapi_KeyStore
- * Method: generatePrivateKeyBlob
+ * Class: sun_security_mscapi_CKeyStore
+ * Method: generateRSAPrivateKeyBlob
* Signature: (I[B[B[B[B[B[B[B[B)[B
*/
-JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_KeyStore_generatePrivateKeyBlob
+JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CKeyStore_generateRSAPrivateKeyBlob
(JNIEnv *env, jobject clazz,
jint jKeyBitLength,
jbyteArray jModulus,
@@ -2063,11 +2276,11 @@
}
/*
- * Class: sun_security_mscapi_RSASignature
+ * Class: sun_security_mscapi_CSignature_RSA
* Method: generatePublicKeyBlob
* Signature: (I[B[B)[B
*/
-JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_generatePublicKeyBlob
+JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CSignature_00024RSA_generatePublicKeyBlob
(JNIEnv *env, jclass clazz,
jint jKeyBitLength,
jbyteArray jModulus,
@@ -2078,13 +2291,13 @@
}
/*
- * Class: sun_security_mscapi_KeyStore
+ * Class: sun_security_mscapi_CKeyStore
* Method: storePrivateKey
- * Signature: ([BLjava/lang/String;I)Lsun/security/mscapi/RSAPrivateKey;
+ * Signature: (Ljava/lang/String;[BLjava/lang/String;I)Lsun/security/mscapi/CPrivateKey;
*/
-JNIEXPORT jobject JNICALL Java_sun_security_mscapi_KeyStore_storePrivateKey
- (JNIEnv *env, jobject clazz, jbyteArray keyBlob, jstring keyContainerName,
- jint keySize)
+JNIEXPORT jobject JNICALL Java_sun_security_mscapi_CKeyStore_storePrivateKey
+ (JNIEnv *env, jobject clazz, jstring alg, jbyteArray keyBlob,
+ jstring keyContainerName, jint keySize)
{
HCRYPTPROV hCryptProv = NULL;
HCRYPTKEY hKey = NULL;
@@ -2106,7 +2319,7 @@
}
// Acquire a CSP context (create a new key container).
- if (::CryptAcquireContext(
+ if (::CryptAcquireContext( //deprecated
&hCryptProv,
pszKeyContainerName,
NULL,
@@ -2118,7 +2331,7 @@
}
// Import the private key
- if (::CryptImportKey(
+ if (::CryptImportKey( //deprecated
hCryptProv,
pbKeyBlob,
dwBlobLen,
@@ -2130,22 +2343,23 @@
__leave;
}
- // Get the method ID for the RSAPrivateKey constructor
- jclass clazzRSAPrivateKey =
- env->FindClass("sun/security/mscapi/RSAPrivateKey");
- if (clazzRSAPrivateKey == NULL) {
+ // Get the method ID for the CPrivateKey constructor
+ jclass clazzCPrivateKey =
+ env->FindClass("sun/security/mscapi/CPrivateKey");
+ if (clazzCPrivateKey == NULL) {
__leave;
}
- jmethodID mNewRSAPrivateKey =
- env->GetMethodID(clazzRSAPrivateKey, "<init>", "(JJI)V");
- if (mNewRSAPrivateKey == NULL) {
+ jmethodID mNewCPrivateKey =
+ env->GetStaticMethodID(clazzCPrivateKey, "of",
+ "(Ljava/lang/String;JJI)Lsun/security/mscapi/CPrivateKey;");
+ if (mNewCPrivateKey == NULL) {
__leave;
}
- // Create a new RSA private key
- privateKey = env->NewObject(clazzRSAPrivateKey, mNewRSAPrivateKey,
- (jlong) hCryptProv, (jlong) hKey, keySize);
+ // Create a new private key
+ privateKey = env->CallStaticObjectMethod(clazzCPrivateKey, mNewCPrivateKey,
+ alg, (jlong) hCryptProv, (jlong) hKey, keySize);
}
__finally
@@ -2165,12 +2379,72 @@
}
/*
- * Class: sun_security_mscapi_RSASignature
+ * Class: sun_security_mscapi_CSignature
+ * Method: importECPublicKey
+ * Signature: (Ljava/lang/String;[BI)Lsun/security/mscapi/CPublicKey;
+ */
+JNIEXPORT jobject JNICALL Java_sun_security_mscapi_CSignature_importECPublicKey
+ (JNIEnv *env, jclass clazz, jstring alg, jbyteArray keyBlob, jint keySize)
+{
+ BCRYPT_ALG_HANDLE hSignAlg = NULL;
+ NCRYPT_KEY_HANDLE hTmpKey = NULL;
+ DWORD dwBlobLen;
+ BYTE * pbKeyBlob = NULL;
+ jobject publicKey = NULL;
+
+ __try
+ {
+ dwBlobLen = env->GetArrayLength(keyBlob);
+ if ((pbKeyBlob = (BYTE *) env->GetByteArrayElements(keyBlob, 0))
+ == NULL) {
+ __leave;
+ }
+ dump("NCryptImportKey", pbKeyBlob, dwBlobLen);
+ NCRYPT_PROV_HANDLE hProv;
+ SS_CHECK(NCryptOpenStorageProvider(
+ &hProv, L"Microsoft Software Key Storage Provider", 0 ));
+ SS_CHECK(NCryptImportKey(
+ hProv,
+ NULL,
+ BCRYPT_ECCPUBLIC_BLOB,
+ NULL,
+ &hTmpKey,
+ pbKeyBlob,
+ dwBlobLen,
+ 0));
+ NCryptFreeObject( hProv );
+ // Get the method ID for the CPublicKey constructor
+ jclass clazzCPublicKey =
+ env->FindClass("sun/security/mscapi/CPublicKey");
+ if (clazzCPublicKey == NULL) {
+ __leave;
+ }
+
+ jmethodID mNewCPublicKey =
+ env->GetStaticMethodID(clazzCPublicKey, "of",
+ "(Ljava/lang/String;JJI)Lsun/security/mscapi/CPublicKey;");
+ if (mNewCPublicKey == NULL) {
+ __leave;
+ }
+
+ // Create a new public key
+ publicKey = env->CallStaticObjectMethod(clazzCPublicKey, mNewCPublicKey,
+ alg, (jlong) hTmpKey, (jlong) 0, keySize);
+ }
+ __finally
+ {
+ }
+
+ return publicKey;
+}
+
+/*
+ * Class: sun_security_mscapi_CSignature
* Method: importPublicKey
- * Signature: ([BI)Lsun/security/mscapi/RSAPublicKey;
+ * Signature: (Ljava/lang/String;[BI)Lsun/security/mscapi/CPublicKey;
*/
-JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSASignature_importPublicKey
- (JNIEnv *env, jclass clazz, jbyteArray keyBlob, jint keySize)
+JNIEXPORT jobject JNICALL Java_sun_security_mscapi_CSignature_importPublicKey
+ (JNIEnv *env, jclass clazz, jstring alg, jbyteArray keyBlob, jint keySize)
{
HCRYPTPROV hCryptProv = NULL;
HCRYPTKEY hKey = NULL;
@@ -2189,7 +2463,7 @@
// Acquire a CSP context (create a new key container).
// Prefer a PROV_RSA_AES CSP, when available, due to its support
// for SHA-2-based signatures.
- if (::CryptAcquireContext(
+ if (::CryptAcquireContext( //deprecated
&hCryptProv,
NULL,
NULL,
@@ -2198,7 +2472,7 @@
{
// Failover to using the default CSP (PROV_RSA_FULL)
- if (::CryptAcquireContext(
+ if (::CryptAcquireContext( //deprecated
&hCryptProv,
NULL,
NULL,
@@ -2211,7 +2485,7 @@
}
// Import the public key
- if (::CryptImportKey(
+ if (::CryptImportKey( //deprecated
hCryptProv,
pbKeyBlob,
dwBlobLen,
@@ -2223,22 +2497,23 @@
__leave;
}
- // Get the method ID for the RSAPublicKey constructor
- jclass clazzRSAPublicKey =
- env->FindClass("sun/security/mscapi/RSAPublicKey");
- if (clazzRSAPublicKey == NULL) {
+ // Get the method ID for the CPublicKey constructor
+ jclass clazzCPublicKey =
+ env->FindClass("sun/security/mscapi/CPublicKey");
+ if (clazzCPublicKey == NULL) {
__leave;
}
- jmethodID mNewRSAPublicKey =
- env->GetMethodID(clazzRSAPublicKey, "<init>", "(JJI)V");
- if (mNewRSAPublicKey == NULL) {
+ jmethodID mNewCPublicKey =
+ env->GetStaticMethodID(clazzCPublicKey, "of",
+ "(Ljava/lang/String;JJI)Lsun/security/mscapi/CPublicKey;");
+ if (mNewCPublicKey == NULL) {
__leave;
}
- // Create a new RSA public key
- publicKey = env->NewObject(clazzRSAPublicKey, mNewRSAPublicKey,
- (jlong) hCryptProv, (jlong) hKey, keySize);
+ // Create a new public key
+ publicKey = env->CallStaticObjectMethod(clazzCPublicKey, mNewCPublicKey,
+ alg, (jlong) hCryptProv, (jlong) hKey, keySize);
}
__finally
--- a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c Tue Dec 18 15:08:56 2018 -0500
@@ -274,6 +274,26 @@
return newthr;
}
+void delete_thread_info(struct ps_prochandle* ph, thread_info* thr_to_be_removed) {
+ thread_info* current_thr = ph->threads;
+
+ if (thr_to_be_removed == ph->threads) {
+ ph->threads = ph->threads->next;
+ } else {
+ thread_info* previous_thr;
+ while (current_thr && current_thr != thr_to_be_removed) {
+ previous_thr = current_thr;
+ current_thr = current_thr->next;
+ }
+ if (current_thr == NULL) {
+ print_error("Could not find the thread to be removed");
+ return;
+ }
+ previous_thr->next = current_thr->next;
+ }
+ ph->num_threads--;
+ free(current_thr);
+}
// struct used for client data from thread_db callback
struct thread_db_client_data {
@@ -296,6 +316,11 @@
print_debug("thread_db : pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid);
+ if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE) {
+ print_debug("Skipping pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid);
+ return TD_OK;
+ }
+
if (ptr->callback(ptr->ph, ti.ti_tid, ti.ti_lid) != true)
return TD_ERR;
--- a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.h Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.h Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -113,6 +113,9 @@
// reads thread info using libthread_db and calls above callback for each thread
bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb);
+// deletes a thread from the thread list
+void delete_thread_info(struct ps_prochandle* ph, thread_info* thr);
+
// adds a new shared object to lib list, returns NULL on failure
lib_info* add_lib_info(struct ps_prochandle* ph, const char* libname, uintptr_t base);
--- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c Tue Dec 18 15:08:56 2018 -0500
@@ -29,6 +29,7 @@
#include <errno.h>
#include <elf.h>
#include <dirent.h>
+#include <ctype.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/ptrace.h>
@@ -46,6 +47,12 @@
// This file has the libproc implementation specific to live process
// For core files, refer to ps_core.c
+typedef enum {
+ ATTACH_SUCCESS,
+ ATTACH_FAIL,
+ ATTACH_THREAD_DEAD
+} attach_state_t;
+
static inline uintptr_t align(uintptr_t ptr, size_t size) {
return (ptr & ~(size - 1));
}
@@ -168,9 +175,10 @@
// waits until the ATTACH has stopped the process
// by signal SIGSTOP
-static bool ptrace_waitpid(pid_t pid) {
+static attach_state_t ptrace_waitpid(pid_t pid) {
int ret;
int status;
+ errno = 0;
while (true) {
// Wait for debuggee to stop.
ret = waitpid(pid, &status, 0);
@@ -185,15 +193,15 @@
// will go to sleep.
if (WSTOPSIG(status) == SIGSTOP) {
// Debuggee stopped by SIGSTOP.
- return true;
+ return ATTACH_SUCCESS;
}
if (!ptrace_continue(pid, WSTOPSIG(status))) {
print_error("Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
- return false;
+ return ATTACH_FAIL;
}
} else {
- print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
- return false;
+ print_debug("waitpid(): Child process %d exited/terminated (status = 0x%x)\n", pid, status);
+ return ATTACH_THREAD_DEAD;
}
} else {
switch (errno) {
@@ -202,29 +210,89 @@
break;
case ECHILD:
print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
- break;
+ return ATTACH_THREAD_DEAD;
case EINVAL:
- print_debug("waitpid() failed. Invalid options argument.\n");
- break;
+ print_error("waitpid() failed. Invalid options argument.\n");
+ return ATTACH_FAIL;
default:
- print_debug("waitpid() failed. Unexpected error %d\n",errno);
- break;
+ print_error("waitpid() failed. Unexpected error %d\n", errno);
+ return ATTACH_FAIL;
}
- return false;
+ } // else
+ } // while
+}
+
+// checks the state of the thread/process specified by "pid", by reading
+// in the 'State:' value from the /proc/<pid>/status file. From the proc
+// man page, "Current state of the process. One of "R (running)",
+// "S (sleeping)", "D (disk sleep)", "T (stopped)", "T (tracing stop)",
+// "Z (zombie)", or "X (dead)"." Assumes that the thread is dead if we
+// don't find the status file or if the status is 'X' or 'Z'.
+static bool process_doesnt_exist(pid_t pid) {
+ char fname[32];
+ char buf[30];
+ FILE *fp = NULL;
+ const char state_string[] = "State:";
+
+ sprintf(fname, "/proc/%d/status", pid);
+ fp = fopen(fname, "r");
+ if (fp == NULL) {
+ print_debug("can't open /proc/%d/status file\n", pid);
+ // Assume the thread does not exist anymore.
+ return true;
+ }
+ bool found_state = false;
+ size_t state_len = strlen(state_string);
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ char *state = NULL;
+ if (strncmp (buf, state_string, state_len) == 0) {
+ found_state = true;
+ state = buf + state_len;
+ // Skip the spaces
+ while (isspace(*state)) {
+ state++;
+ }
+ // A state value of 'X' indicates that the thread is dead. 'Z'
+ // indicates that the thread is a zombie.
+ if (*state == 'X' || *state == 'Z') {
+ fclose (fp);
+ return true;
+ }
+ break;
}
}
+ // If the state value is not 'X' or 'Z', the thread exists.
+ if (!found_state) {
+ // We haven't found the line beginning with 'State:'.
+ // Assuming the thread exists.
+ print_error("Could not find the 'State:' string in the /proc/%d/status file\n", pid);
+ }
+ fclose (fp);
+ return false;
}
// attach to a process/thread specified by "pid"
-static bool ptrace_attach(pid_t pid, char* err_buf, size_t err_buf_len) {
+static attach_state_t ptrace_attach(pid_t pid, char* err_buf, size_t err_buf_len) {
+ errno = 0;
if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
+ if (errno == EPERM || errno == ESRCH) {
+ // Check if the process/thread is exiting or is a zombie
+ if (process_doesnt_exist(pid)) {
+ print_debug("Thread with pid %d does not exist\n", pid);
+ return ATTACH_THREAD_DEAD;
+ }
+ }
char buf[200];
char* msg = strerror_r(errno, buf, sizeof(buf));
snprintf(err_buf, err_buf_len, "ptrace(PTRACE_ATTACH, ..) failed for %d: %s", pid, msg);
- print_debug("%s\n", err_buf);
- return false;
+ print_error("%s\n", err_buf);
+ return ATTACH_FAIL;
} else {
- return ptrace_waitpid(pid);
+ attach_state_t wait_ret = ptrace_waitpid(pid);
+ if (wait_ret == ATTACH_THREAD_DEAD) {
+ print_debug("Thread with pid %d does not exist\n", pid);
+ }
+ return wait_ret;
}
}
@@ -378,16 +446,20 @@
Pgrab(pid_t pid, char* err_buf, size_t err_buf_len, bool is_in_container) {
struct ps_prochandle* ph = NULL;
thread_info* thr = NULL;
+ attach_state_t attach_status = ATTACH_SUCCESS;
if ( (ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle))) == NULL) {
- snprintf(err_buf, err_buf_len, "can't allocate memory for ps_prochandle");
- print_debug("%s\n", err_buf);
- return NULL;
+ snprintf(err_buf, err_buf_len, "can't allocate memory for ps_prochandle");
+ print_debug("%s\n", err_buf);
+ return NULL;
}
- if (ptrace_attach(pid, err_buf, err_buf_len) != true) {
- free(ph);
- return NULL;
+ if ((attach_status = ptrace_attach(pid, err_buf, err_buf_len)) != ATTACH_SUCCESS) {
+ if (attach_status == ATTACH_THREAD_DEAD) {
+ print_error("The process with pid %d does not exist.\n", pid);
+ }
+ free(ph);
+ return NULL;
}
// initialize ps_prochandle
@@ -431,14 +503,23 @@
// attach to the threads
thr = ph->threads;
+
while (thr) {
- // don't attach to the main thread again
- if (ph->pid != thr->lwp_id && ptrace_attach(thr->lwp_id, err_buf, err_buf_len) != true) {
- // even if one attach fails, we get return NULL
- Prelease(ph);
- return NULL;
- }
- thr = thr->next;
+ thread_info* current_thr = thr;
+ thr = thr->next;
+ // don't attach to the main thread again
+ if (ph->pid != current_thr->lwp_id) {
+ if ((attach_status = ptrace_attach(current_thr->lwp_id, err_buf, err_buf_len)) != ATTACH_SUCCESS) {
+ if (attach_status == ATTACH_THREAD_DEAD) {
+ // Remove this thread from the threads list
+ delete_thread_info(ph, current_thr);
+ }
+ else {
+ Prelease(ph);
+ return NULL;
+ } // ATTACH_THREAD_DEAD
+ } // !ATTACH_SUCCESS
+ }
}
return ph;
}
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/linux_amd64/LinuxAMD64JavaThreadPDAccess.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/linux_amd64/LinuxAMD64JavaThreadPDAccess.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -97,6 +97,10 @@
}
if (guesser.getPC() == null) {
return new X86Frame(guesser.getSP(), guesser.getFP());
+ } else if (VM.getVM().getInterpreter().contains(guesser.getPC())) {
+ // pass the value of R13 which contains the bcp for the top level frame
+ Address bcp = context.getRegisterAsAddress(AMD64ThreadContext.R13);
+ return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC(), null, bcp);
} else {
return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
}
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* 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,6 +95,7 @@
// an additional field beyond sp and pc:
Address raw_fp; // frame pointer
private Address raw_unextendedSP;
+ private Address live_bcp;
private X86Frame() {
}
@@ -117,15 +118,29 @@
}
}
- public X86Frame(Address raw_sp, Address raw_fp, Address pc) {
+ private void initFrame(Address raw_sp, Address raw_fp, Address pc, Address raw_unextendedSp, Address live_bcp) {
this.raw_sp = raw_sp;
- this.raw_unextendedSP = raw_sp;
this.raw_fp = raw_fp;
- this.pc = pc;
+ if (raw_unextendedSp == null) {
+ this.raw_unextendedSP = raw_sp;
+ } else {
+ this.raw_unextendedSP = raw_unextendedSp;
+ }
+ if (pc == null) {
+ this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
+ } else {
+ this.pc = pc;
+ }
+ this.live_bcp = live_bcp;
adjustUnextendedSP();
// Frame must be fully constructed before this call
adjustForDeopt();
+}
+
+
+ public X86Frame(Address raw_sp, Address raw_fp, Address pc) {
+ initFrame(raw_sp, raw_fp, pc, null, null);
if (DEBUG) {
System.out.println("X86Frame(sp, fp, pc): " + this);
@@ -134,14 +149,7 @@
}
public X86Frame(Address raw_sp, Address raw_fp) {
- this.raw_sp = raw_sp;
- this.raw_unextendedSP = raw_sp;
- this.raw_fp = raw_fp;
- this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
- adjustUnextendedSP();
-
- // Frame must be fully constructed before this call
- adjustForDeopt();
+ initFrame(raw_sp, raw_fp, null, null, null);
if (DEBUG) {
System.out.println("X86Frame(sp, fp): " + this);
@@ -150,20 +158,21 @@
}
public X86Frame(Address raw_sp, Address raw_unextendedSp, Address raw_fp, Address pc) {
- this.raw_sp = raw_sp;
- this.raw_unextendedSP = raw_unextendedSp;
- this.raw_fp = raw_fp;
- this.pc = pc;
- adjustUnextendedSP();
-
- // Frame must be fully constructed before this call
- adjustForDeopt();
+ initFrame(raw_sp, raw_fp, pc, raw_unextendedSp, null);
if (DEBUG) {
System.out.println("X86Frame(sp, unextendedSP, fp, pc): " + this);
dumpStack();
}
+ }
+ public X86Frame(Address raw_sp, Address raw_fp, Address pc, Address raw_unextendedSp, Address live_bcp) {
+ initFrame(raw_sp, raw_fp, pc, raw_unextendedSp, live_bcp);
+
+ if (DEBUG) {
+ System.out.println("X86Frame(sp, fp, pc, unextendedSP, live_bcp): " + this);
+ dumpStack();
+ }
}
public Object clone() {
@@ -173,6 +182,7 @@
frame.raw_fp = raw_fp;
frame.pc = pc;
frame.deoptimized = deoptimized;
+ frame.live_bcp = live_bcp;
return frame;
}
@@ -433,6 +443,14 @@
// for use in a non-debugging, or reflective, system. Need to
// figure out how to express this.
Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0);
+
+ // If we are in the top level frame then the bcp may have been set for us. If so then let it
+ // take priority. If we are in a top level interpreter frame, the bcp is live in R13 (on x86)
+ // and not saved in the BCX stack slot.
+ if (live_bcp != null) {
+ bcp = live_bcp;
+ }
+
Address methodHandle = addressOfInterpreterFrameMethod().getAddressAt(0);
Method method = (Method)Metadata.instantiateWrapperFor(methodHandle);
return bcpToBci(bcp, method);
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java Tue Dec 18 15:08:56 2018 -0500
@@ -374,6 +374,14 @@
"jdk/jfr/internal/JVM.getEventWriter()Ljava/lang/Object;");
}
+ if (isJDK12OrHigher()) {
+ add(toBeInvestigated,
+ "java/lang/CharacterDataLatin1.isDigit(I)Z",
+ "java/lang/CharacterDataLatin1.isLowerCase(I)Z",
+ "java/lang/CharacterDataLatin1.isUpperCase(I)Z",
+ "java/lang/CharacterDataLatin1.isWhitespace(I)Z");
+ }
+
if (!config.inlineNotify()) {
add(ignore, "java/lang/Object.notify()V");
}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java Tue Dec 18 15:08:56 2018 -0500
@@ -4195,7 +4195,6 @@
handleIllegalNewInstance(resolvedType);
return;
}
-
maybeEagerlyInitialize(resolvedType);
ClassInitializationPlugin classInitializationPlugin = graphBuilderConfig.getPlugins().getClassInitializationPlugin();
@@ -4509,7 +4508,6 @@
}
ResolvedJavaType holder = resolvedField.getDeclaringClass();
- maybeEagerlyInitialize(holder);
ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
if (classInitializationPlugin != null) {
classInitializationPlugin.apply(this, holder, this::createCurrentFrameState);
@@ -4545,16 +4543,20 @@
private ResolvedJavaField resolveStaticFieldAccess(JavaField field, ValueNode value) {
if (field instanceof ResolvedJavaField) {
ResolvedJavaField resolvedField = (ResolvedJavaField) field;
- if (resolvedField.getDeclaringClass().isInitialized() || graphBuilderConfig.getPlugins().getClassInitializationPlugin() != null) {
+ ResolvedJavaType resolvedType = resolvedField.getDeclaringClass();
+ maybeEagerlyInitialize(resolvedType);
+
+ if (resolvedType.isInitialized() || graphBuilderConfig.getPlugins().getClassInitializationPlugin() != null) {
return resolvedField;
}
+
/*
* Static fields have initialization semantics but may be safely accessed under certain
* conditions while the class is being initialized. Executing in the clinit or init of
- * classes which are subtypes of the field holder are sure to be running in a context
- * where the access is safe.
+ * subclasses (but not implementers) of the field holder are sure to be running in a
+ * context where the access is safe.
*/
- if (resolvedField.getDeclaringClass().isAssignableFrom(method.getDeclaringClass())) {
+ if (!resolvedType.isInterface() && resolvedType.isAssignableFrom(method.getDeclaringClass())) {
if (method.isClassInitializer() || method.isConstructor()) {
return resolvedField;
}
@@ -4588,7 +4590,6 @@
ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
ResolvedJavaType holder = resolvedField.getDeclaringClass();
- maybeEagerlyInitialize(holder);
if (classInitializationPlugin != null) {
Supplier<FrameState> stateBefore = () -> {
JavaKind[] pushedSlotKinds = {field.getJavaKind()};
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java Tue Dec 18 15:08:56 2018 -0500
@@ -49,7 +49,7 @@
private final List<ClassfileBytecode> codeAttributes;
private static final int MAJOR_VERSION_JAVA_MIN = 51; // JDK7
- private static final int MAJOR_VERSION_JAVA_MAX = 56; // JDK12
+ private static final int MAJOR_VERSION_JAVA_MAX = 57; // JDK13
private static final int MAGIC = 0xCAFEBABE;
/**
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java Tue Dec 18 15:08:56 2018 -0500
@@ -106,7 +106,7 @@
// Keep these updated manually until there's a compiler API
// that allows querying of supported releases.
final Set<String> releasesWithoutForRemoval = Set.of("6", "7", "8");
- final Set<String> releasesWithForRemoval = Set.of("9", "10", "11", "12");
+ final Set<String> releasesWithForRemoval = Set.of("9", "10", "11", "12", "13");
final Set<String> validReleases;
{
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java Tue Dec 18 15:08:56 2018 -0500
@@ -115,7 +115,7 @@
public boolean isJDK() {
String mn = name();
return isSystem &&
- (mn.startsWith("java.") || mn.startsWith("jdk.") || mn.startsWith("javafx."));
+ (mn.startsWith("java.") || mn.startsWith("jdk."));
}
public boolean isSystem() {
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleDotGraph.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleDotGraph.java Tue Dec 18 15:08:56 2018 -0500
@@ -307,9 +307,7 @@
.map(ModuleReference::descriptor)
.map(ModuleDescriptor::name)
.filter(name -> !JAVA_SE_SUBGRAPH.contains(name) &&
- (name.startsWith("java.") ||
- name.startsWith("jdk.") ||
- name.startsWith("javafx.")))
+ (name.startsWith("java.") || name.startsWith("jdk.")))
.collect(Collectors.toSet());
}
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdk8_internals.txt Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdk8_internals.txt Tue Dec 18 15:08:56 2018 -0500
@@ -9,19 +9,8 @@
com.apple.eio
com.apple.laf
com.apple.laf.resources
-com.oracle.jrockit.jfr
-com.oracle.jrockit.jfr.client
-com.oracle.jrockit.jfr.management
com.oracle.security.ucrypto
-com.oracle.util
-com.oracle.webservices.internal.api
-com.oracle.webservices.internal.api.databinding
-com.oracle.webservices.internal.api.message
-com.oracle.webservices.internal.impl.encoding
-com.oracle.webservices.internal.impl.internalspi.encoding
-com.oracle.xmlns.internal.webservices.jaxws_databinding
com.sun.accessibility.internal.resources
-com.sun.activation.registries
com.sun.awt
com.sun.beans
com.sun.beans.decoder
@@ -29,90 +18,8 @@
com.sun.beans.finder
com.sun.beans.infos
com.sun.beans.util
-com.sun.codemodel.internal
-com.sun.codemodel.internal.fmt
-com.sun.codemodel.internal.util
-com.sun.codemodel.internal.writer
-com.sun.corba.se.impl.activation
-com.sun.corba.se.impl.copyobject
-com.sun.corba.se.impl.corba
-com.sun.corba.se.impl.dynamicany
-com.sun.corba.se.impl.encoding
-com.sun.corba.se.impl.interceptors
-com.sun.corba.se.impl.io
-com.sun.corba.se.impl.ior
-com.sun.corba.se.impl.ior.iiop
-com.sun.corba.se.impl.javax.rmi
-com.sun.corba.se.impl.javax.rmi.CORBA
-com.sun.corba.se.impl.legacy.connection
-com.sun.corba.se.impl.logging
-com.sun.corba.se.impl.monitoring
-com.sun.corba.se.impl.naming.cosnaming
-com.sun.corba.se.impl.naming.namingutil
-com.sun.corba.se.impl.naming.pcosnaming
-com.sun.corba.se.impl.oa
-com.sun.corba.se.impl.oa.poa
-com.sun.corba.se.impl.oa.toa
-com.sun.corba.se.impl.orb
-com.sun.corba.se.impl.orbutil
-com.sun.corba.se.impl.orbutil.closure
-com.sun.corba.se.impl.orbutil.concurrent
-com.sun.corba.se.impl.orbutil.fsm
-com.sun.corba.se.impl.orbutil.graph
-com.sun.corba.se.impl.orbutil.threadpool
-com.sun.corba.se.impl.presentation.rmi
-com.sun.corba.se.impl.protocol
-com.sun.corba.se.impl.protocol.giopmsgheaders
-com.sun.corba.se.impl.resolver
-com.sun.corba.se.impl.transport
-com.sun.corba.se.impl.util
-com.sun.corba.se.internal.CosNaming
-com.sun.corba.se.internal.Interceptors
-com.sun.corba.se.internal.POA
-com.sun.corba.se.internal.corba
-com.sun.corba.se.internal.iiop
-com.sun.corba.se.org.omg.CORBA
-com.sun.corba.se.pept.broker
-com.sun.corba.se.pept.encoding
-com.sun.corba.se.pept.protocol
-com.sun.corba.se.pept.transport
-com.sun.corba.se.spi.activation
-com.sun.corba.se.spi.activation.InitialNameServicePackage
-com.sun.corba.se.spi.activation.LocatorPackage
-com.sun.corba.se.spi.activation.RepositoryPackage
-com.sun.corba.se.spi.copyobject
-com.sun.corba.se.spi.encoding
-com.sun.corba.se.spi.extension
-com.sun.corba.se.spi.ior
-com.sun.corba.se.spi.ior.iiop
-com.sun.corba.se.spi.legacy.connection
-com.sun.corba.se.spi.legacy.interceptor
-com.sun.corba.se.spi.logging
-com.sun.corba.se.spi.monitoring
-com.sun.corba.se.spi.oa
-com.sun.corba.se.spi.orb
-com.sun.corba.se.spi.orbutil.closure
-com.sun.corba.se.spi.orbutil.fsm
-com.sun.corba.se.spi.orbutil.proxy
-com.sun.corba.se.spi.orbutil.threadpool
-com.sun.corba.se.spi.presentation.rmi
-com.sun.corba.se.spi.protocol
-com.sun.corba.se.spi.resolver
-com.sun.corba.se.spi.servicecontext
-com.sun.corba.se.spi.transport
com.sun.crypto.provider
com.sun.demo.jvmti.hprof
-com.sun.deploy.uitoolkit.impl.fx
-com.sun.deploy.uitoolkit.impl.fx.ui
-com.sun.deploy.uitoolkit.impl.fx.ui.resources
-com.sun.glass.events
-com.sun.glass.events.mac
-com.sun.glass.ui
-com.sun.glass.ui.delegate
-com.sun.glass.ui.gtk
-com.sun.glass.ui.mac
-com.sun.glass.ui.win
-com.sun.glass.utils
com.sun.image.codec.jpeg
com.sun.imageio.plugins.bmp
com.sun.imageio.plugins.common
@@ -122,10 +29,6 @@
com.sun.imageio.plugins.wbmp
com.sun.imageio.spi
com.sun.imageio.stream
-com.sun.istack.internal
-com.sun.istack.internal.localization
-com.sun.istack.internal.logging
-com.sun.istack.internal.tools
com.sun.java.accessibility
com.sun.java.accessibility.util.java.awt
com.sun.java.browser.dom
@@ -140,130 +43,27 @@
com.sun.java.swing.plaf.windows.resources
com.sun.java.util.jar.pack
com.sun.java_cup.internal.runtime
-com.sun.javafx
-com.sun.javafx.animation
-com.sun.javafx.applet
-com.sun.javafx.application
-com.sun.javafx.beans
-com.sun.javafx.beans.event
-com.sun.javafx.binding
-com.sun.javafx.charts
-com.sun.javafx.collections
-com.sun.javafx.css
-com.sun.javafx.css.converters
-com.sun.javafx.css.parser
-com.sun.javafx.cursor
-com.sun.javafx.effect
-com.sun.javafx.embed
-com.sun.javafx.event
-com.sun.javafx.font
-com.sun.javafx.font.coretext
-com.sun.javafx.font.directwrite
-com.sun.javafx.font.freetype
-com.sun.javafx.font.t2k
-com.sun.javafx.fxml
-com.sun.javafx.fxml.builder
-com.sun.javafx.fxml.expression
-com.sun.javafx.geom
-com.sun.javafx.geom.transform
-com.sun.javafx.geometry
-com.sun.javafx.iio
-com.sun.javafx.iio.bmp
-com.sun.javafx.iio.common
-com.sun.javafx.iio.gif
-com.sun.javafx.iio.ios
-com.sun.javafx.iio.jpeg
-com.sun.javafx.iio.png
-com.sun.javafx.image
-com.sun.javafx.image.impl
-com.sun.javafx.jmx
-com.sun.javafx.logging
-com.sun.javafx.media
-com.sun.javafx.menu
-com.sun.javafx.perf
-com.sun.javafx.print
-com.sun.javafx.property
-com.sun.javafx.property.adapter
-com.sun.javafx.robot
-com.sun.javafx.robot.impl
-com.sun.javafx.runtime
-com.sun.javafx.runtime.async
-com.sun.javafx.runtime.eula
-com.sun.javafx.scene
-com.sun.javafx.scene.control
-com.sun.javafx.scene.control.behavior
-com.sun.javafx.scene.control.skin
-com.sun.javafx.scene.control.skin.resources
-com.sun.javafx.scene.input
-com.sun.javafx.scene.layout.region
-com.sun.javafx.scene.paint
-com.sun.javafx.scene.shape
-com.sun.javafx.scene.text
-com.sun.javafx.scene.transform
-com.sun.javafx.scene.traversal
-com.sun.javafx.scene.web
-com.sun.javafx.scene.web.behavior
-com.sun.javafx.scene.web.skin
-com.sun.javafx.sg.prism
-com.sun.javafx.sg.prism.web
-com.sun.javafx.stage
-com.sun.javafx.text
-com.sun.javafx.tk
-com.sun.javafx.tk.quantum
-com.sun.javafx.util
-com.sun.javafx.webkit
-com.sun.javafx.webkit.drt
-com.sun.javafx.webkit.prism
-com.sun.javafx.webkit.prism.theme
-com.sun.javafx.webkit.theme
com.sun.jmx.defaults
com.sun.jmx.interceptor
com.sun.jmx.mbeanserver
com.sun.jmx.remote.internal
-com.sun.jmx.remote.protocol.iiop
com.sun.jmx.remote.protocol.rmi
com.sun.jmx.remote.security
com.sun.jmx.remote.util
-com.sun.jmx.snmp
-com.sun.jmx.snmp.IPAcl
-com.sun.jmx.snmp.agent
-com.sun.jmx.snmp.daemon
-com.sun.jmx.snmp.defaults
-com.sun.jmx.snmp.internal
-com.sun.jmx.snmp.mpm
-com.sun.jmx.snmp.tasks
-com.sun.jndi.cosnaming
com.sun.jndi.dns
com.sun.jndi.ldap
com.sun.jndi.ldap.ext
com.sun.jndi.ldap.pool
com.sun.jndi.ldap.sasl
com.sun.jndi.rmi.registry
-com.sun.jndi.toolkit.corba
com.sun.jndi.toolkit.ctx
com.sun.jndi.toolkit.dir
com.sun.jndi.toolkit.url
-com.sun.jndi.url.corbaname
com.sun.jndi.url.dns
-com.sun.jndi.url.iiop
-com.sun.jndi.url.iiopname
com.sun.jndi.url.ldap
com.sun.jndi.url.ldaps
com.sun.jndi.url.rmi
com.sun.management.jmx
-com.sun.media.jfxmedia
-com.sun.media.jfxmedia.control
-com.sun.media.jfxmedia.effects
-com.sun.media.jfxmedia.events
-com.sun.media.jfxmedia.locator
-com.sun.media.jfxmedia.logging
-com.sun.media.jfxmedia.track
-com.sun.media.jfxmediaimpl
-com.sun.media.jfxmediaimpl.platform
-com.sun.media.jfxmediaimpl.platform.gstreamer
-com.sun.media.jfxmediaimpl.platform.ios
-com.sun.media.jfxmediaimpl.platform.java
-com.sun.media.jfxmediaimpl.platform.osx
com.sun.media.sound
com.sun.naming.internal
com.sun.net.ssl
@@ -375,20 +175,6 @@
com.sun.org.apache.xpath.internal.operations
com.sun.org.apache.xpath.internal.patterns
com.sun.org.apache.xpath.internal.res
-com.sun.org.glassfish.external.amx
-com.sun.org.glassfish.external.arc
-com.sun.org.glassfish.external.probe.provider
-com.sun.org.glassfish.external.probe.provider.annotations
-com.sun.org.glassfish.external.statistics
-com.sun.org.glassfish.external.statistics.annotations
-com.sun.org.glassfish.external.statistics.impl
-com.sun.org.glassfish.gmbal
-com.sun.org.glassfish.gmbal.util
-com.sun.org.omg.CORBA
-com.sun.org.omg.CORBA.ValueDefPackage
-com.sun.org.omg.CORBA.portable
-com.sun.org.omg.SendingContext
-com.sun.org.omg.SendingContext.CodeBasePackage
com.sun.pisces
com.sun.prism
com.sun.prism.d3d
@@ -411,22 +197,6 @@
com.sun.rowset
com.sun.rowset.internal
com.sun.rowset.providers
-com.sun.scenario
-com.sun.scenario.animation
-com.sun.scenario.animation.shared
-com.sun.scenario.effect
-com.sun.scenario.effect.impl
-com.sun.scenario.effect.impl.es2
-com.sun.scenario.effect.impl.hw
-com.sun.scenario.effect.impl.hw.d3d
-com.sun.scenario.effect.impl.prism
-com.sun.scenario.effect.impl.prism.ps
-com.sun.scenario.effect.impl.prism.sw
-com.sun.scenario.effect.impl.state
-com.sun.scenario.effect.impl.sw
-com.sun.scenario.effect.impl.sw.java
-com.sun.scenario.effect.impl.sw.sse
-com.sun.scenario.effect.light
com.sun.security.cert.internal.x509
com.sun.security.ntlm
com.sun.security.sasl
@@ -438,11 +208,6 @@
com.sun.swing.internal.plaf.metal.resources
com.sun.swing.internal.plaf.synth.resources
com.sun.tools.classfile
-com.sun.tools.corba.se.idl
-com.sun.tools.corba.se.idl.constExpr
-com.sun.tools.corba.se.idl.som.cff
-com.sun.tools.corba.se.idl.som.idlemit
-com.sun.tools.corba.se.idl.toJavaPortable
com.sun.tools.doclets.formats.html
com.sun.tools.doclets.formats.html.markup
com.sun.tools.doclets.formats.html.resources
@@ -457,75 +222,6 @@
com.sun.tools.example.debug.expr
com.sun.tools.example.debug.tty
com.sun.tools.extcheck
-com.sun.tools.hat
-com.sun.tools.hat.internal.model
-com.sun.tools.hat.internal.oql
-com.sun.tools.hat.internal.parser
-com.sun.tools.hat.internal.server
-com.sun.tools.hat.internal.util
-com.sun.tools.internal.jxc
-com.sun.tools.internal.jxc.ap
-com.sun.tools.internal.jxc.api
-com.sun.tools.internal.jxc.api.impl.j2s
-com.sun.tools.internal.jxc.gen.config
-com.sun.tools.internal.jxc.model.nav
-com.sun.tools.internal.ws
-com.sun.tools.internal.ws.api
-com.sun.tools.internal.ws.api.wsdl
-com.sun.tools.internal.ws.processor
-com.sun.tools.internal.ws.processor.generator
-com.sun.tools.internal.ws.processor.model
-com.sun.tools.internal.ws.processor.model.exporter
-com.sun.tools.internal.ws.processor.model.java
-com.sun.tools.internal.ws.processor.model.jaxb
-com.sun.tools.internal.ws.processor.modeler
-com.sun.tools.internal.ws.processor.modeler.annotation
-com.sun.tools.internal.ws.processor.modeler.wsdl
-com.sun.tools.internal.ws.processor.util
-com.sun.tools.internal.ws.resources
-com.sun.tools.internal.ws.spi
-com.sun.tools.internal.ws.util
-com.sun.tools.internal.ws.util.xml
-com.sun.tools.internal.ws.wscompile
-com.sun.tools.internal.ws.wscompile.plugin.at_generated
-com.sun.tools.internal.ws.wsdl.document
-com.sun.tools.internal.ws.wsdl.document.http
-com.sun.tools.internal.ws.wsdl.document.jaxws
-com.sun.tools.internal.ws.wsdl.document.mime
-com.sun.tools.internal.ws.wsdl.document.schema
-com.sun.tools.internal.ws.wsdl.document.soap
-com.sun.tools.internal.ws.wsdl.framework
-com.sun.tools.internal.ws.wsdl.parser
-com.sun.tools.internal.xjc
-com.sun.tools.internal.xjc.addon.accessors
-com.sun.tools.internal.xjc.addon.at_generated
-com.sun.tools.internal.xjc.addon.code_injector
-com.sun.tools.internal.xjc.addon.episode
-com.sun.tools.internal.xjc.addon.locator
-com.sun.tools.internal.xjc.addon.sync
-com.sun.tools.internal.xjc.api
-com.sun.tools.internal.xjc.api.impl.s2j
-com.sun.tools.internal.xjc.api.util
-com.sun.tools.internal.xjc.generator.annotation.spec
-com.sun.tools.internal.xjc.generator.bean
-com.sun.tools.internal.xjc.generator.bean.field
-com.sun.tools.internal.xjc.generator.util
-com.sun.tools.internal.xjc.model
-com.sun.tools.internal.xjc.model.nav
-com.sun.tools.internal.xjc.outline
-com.sun.tools.internal.xjc.reader
-com.sun.tools.internal.xjc.reader.dtd
-com.sun.tools.internal.xjc.reader.dtd.bindinfo
-com.sun.tools.internal.xjc.reader.gbind
-com.sun.tools.internal.xjc.reader.internalizer
-com.sun.tools.internal.xjc.reader.relaxng
-com.sun.tools.internal.xjc.reader.xmlschema
-com.sun.tools.internal.xjc.reader.xmlschema.bindinfo
-com.sun.tools.internal.xjc.reader.xmlschema.ct
-com.sun.tools.internal.xjc.reader.xmlschema.parser
-com.sun.tools.internal.xjc.runtime
-com.sun.tools.internal.xjc.util
-com.sun.tools.internal.xjc.writer
com.sun.tools.javac.api
com.sun.tools.javac.code
com.sun.tools.javac.comp
@@ -551,212 +247,8 @@
com.sun.tools.jdi
com.sun.tools.jdi.resources
com.sun.tools.script.shell
-com.sun.tracing
-com.sun.tracing.dtrace
-com.sun.webkit
-com.sun.webkit.dom
-com.sun.webkit.event
-com.sun.webkit.graphics
-com.sun.webkit.network
-com.sun.webkit.network.about
-com.sun.webkit.network.data
-com.sun.webkit.perf
-com.sun.webkit.plugin
-com.sun.webkit.text
-com.sun.xml.internal.bind
-com.sun.xml.internal.bind.annotation
-com.sun.xml.internal.bind.api
-com.sun.xml.internal.bind.api.impl
-com.sun.xml.internal.bind.marshaller
-com.sun.xml.internal.bind.unmarshaller
-com.sun.xml.internal.bind.util
-com.sun.xml.internal.bind.v2
-com.sun.xml.internal.bind.v2.bytecode
-com.sun.xml.internal.bind.v2.model.annotation
-com.sun.xml.internal.bind.v2.model.core
-com.sun.xml.internal.bind.v2.model.impl
-com.sun.xml.internal.bind.v2.model.nav
-com.sun.xml.internal.bind.v2.model.runtime
-com.sun.xml.internal.bind.v2.model.util
-com.sun.xml.internal.bind.v2.runtime
-com.sun.xml.internal.bind.v2.runtime.output
-com.sun.xml.internal.bind.v2.runtime.property
-com.sun.xml.internal.bind.v2.runtime.reflect
-com.sun.xml.internal.bind.v2.runtime.reflect.opt
-com.sun.xml.internal.bind.v2.runtime.unmarshaller
-com.sun.xml.internal.bind.v2.schemagen
-com.sun.xml.internal.bind.v2.schemagen.episode
-com.sun.xml.internal.bind.v2.schemagen.xmlschema
-com.sun.xml.internal.bind.v2.util
-com.sun.xml.internal.dtdparser
-com.sun.xml.internal.fastinfoset
-com.sun.xml.internal.fastinfoset.algorithm
-com.sun.xml.internal.fastinfoset.alphabet
-com.sun.xml.internal.fastinfoset.dom
-com.sun.xml.internal.fastinfoset.org.apache.xerces.util
-com.sun.xml.internal.fastinfoset.sax
-com.sun.xml.internal.fastinfoset.stax
-com.sun.xml.internal.fastinfoset.stax.events
-com.sun.xml.internal.fastinfoset.stax.factory
-com.sun.xml.internal.fastinfoset.stax.util
-com.sun.xml.internal.fastinfoset.tools
-com.sun.xml.internal.fastinfoset.util
-com.sun.xml.internal.fastinfoset.vocab
-com.sun.xml.internal.messaging.saaj
-com.sun.xml.internal.messaging.saaj.client.p2p
-com.sun.xml.internal.messaging.saaj.packaging.mime
-com.sun.xml.internal.messaging.saaj.packaging.mime.internet
-com.sun.xml.internal.messaging.saaj.packaging.mime.util
-com.sun.xml.internal.messaging.saaj.soap
-com.sun.xml.internal.messaging.saaj.soap.dynamic
-com.sun.xml.internal.messaging.saaj.soap.impl
-com.sun.xml.internal.messaging.saaj.soap.name
-com.sun.xml.internal.messaging.saaj.soap.ver1_1
-com.sun.xml.internal.messaging.saaj.soap.ver1_2
-com.sun.xml.internal.messaging.saaj.util
-com.sun.xml.internal.messaging.saaj.util.transform
-com.sun.xml.internal.org.jvnet.fastinfoset
-com.sun.xml.internal.org.jvnet.fastinfoset.sax
-com.sun.xml.internal.org.jvnet.fastinfoset.sax.helpers
-com.sun.xml.internal.org.jvnet.fastinfoset.stax
-com.sun.xml.internal.org.jvnet.mimepull
-com.sun.xml.internal.org.jvnet.staxex
-com.sun.xml.internal.rngom.ast.builder
-com.sun.xml.internal.rngom.ast.om
-com.sun.xml.internal.rngom.ast.util
-com.sun.xml.internal.rngom.binary
-com.sun.xml.internal.rngom.binary.visitor
-com.sun.xml.internal.rngom.digested
-com.sun.xml.internal.rngom.dt
-com.sun.xml.internal.rngom.dt.builtin
-com.sun.xml.internal.rngom.nc
-com.sun.xml.internal.rngom.parse
-com.sun.xml.internal.rngom.parse.compact
-com.sun.xml.internal.rngom.parse.host
-com.sun.xml.internal.rngom.parse.xml
-com.sun.xml.internal.rngom.util
-com.sun.xml.internal.rngom.xml.sax
-com.sun.xml.internal.rngom.xml.util
-com.sun.xml.internal.stream
-com.sun.xml.internal.stream.buffer
-com.sun.xml.internal.stream.buffer.sax
-com.sun.xml.internal.stream.buffer.stax
-com.sun.xml.internal.stream.dtd
-com.sun.xml.internal.stream.dtd.nonvalidating
-com.sun.xml.internal.stream.events
-com.sun.xml.internal.stream.util
-com.sun.xml.internal.stream.writers
-com.sun.xml.internal.txw2
-com.sun.xml.internal.txw2.annotation
-com.sun.xml.internal.txw2.output
-com.sun.xml.internal.ws
-com.sun.xml.internal.ws.addressing
-com.sun.xml.internal.ws.addressing.model
-com.sun.xml.internal.ws.addressing.policy
-com.sun.xml.internal.ws.addressing.v200408
-com.sun.xml.internal.ws.api
-com.sun.xml.internal.ws.api.addressing
-com.sun.xml.internal.ws.api.client
-com.sun.xml.internal.ws.api.config.management
-com.sun.xml.internal.ws.api.config.management.policy
-com.sun.xml.internal.ws.api.databinding
-com.sun.xml.internal.ws.api.fastinfoset
-com.sun.xml.internal.ws.api.ha
-com.sun.xml.internal.ws.api.handler
-com.sun.xml.internal.ws.api.message
-com.sun.xml.internal.ws.api.message.saaj
-com.sun.xml.internal.ws.api.message.stream
-com.sun.xml.internal.ws.api.model
-com.sun.xml.internal.ws.api.model.soap
-com.sun.xml.internal.ws.api.model.wsdl
-com.sun.xml.internal.ws.api.model.wsdl.editable
-com.sun.xml.internal.ws.api.pipe
-com.sun.xml.internal.ws.api.pipe.helper
-com.sun.xml.internal.ws.api.policy
-com.sun.xml.internal.ws.api.policy.subject
-com.sun.xml.internal.ws.api.server
-com.sun.xml.internal.ws.api.streaming
-com.sun.xml.internal.ws.api.wsdl.parser
-com.sun.xml.internal.ws.api.wsdl.writer
-com.sun.xml.internal.ws.assembler
-com.sun.xml.internal.ws.assembler.dev
-com.sun.xml.internal.ws.assembler.jaxws
-com.sun.xml.internal.ws.binding
-com.sun.xml.internal.ws.client
-com.sun.xml.internal.ws.client.dispatch
-com.sun.xml.internal.ws.client.sei
-com.sun.xml.internal.ws.commons.xmlutil
-com.sun.xml.internal.ws.config.management.policy
-com.sun.xml.internal.ws.config.metro.dev
-com.sun.xml.internal.ws.config.metro.util
-com.sun.xml.internal.ws.db
-com.sun.xml.internal.ws.db.glassfish
-com.sun.xml.internal.ws.developer
-com.sun.xml.internal.ws.dump
-com.sun.xml.internal.ws.encoding
-com.sun.xml.internal.ws.encoding.fastinfoset
-com.sun.xml.internal.ws.encoding.policy
-com.sun.xml.internal.ws.encoding.soap
-com.sun.xml.internal.ws.encoding.soap.streaming
-com.sun.xml.internal.ws.encoding.xml
-com.sun.xml.internal.ws.fault
-com.sun.xml.internal.ws.handler
-com.sun.xml.internal.ws.message
-com.sun.xml.internal.ws.message.jaxb
-com.sun.xml.internal.ws.message.saaj
-com.sun.xml.internal.ws.message.source
-com.sun.xml.internal.ws.message.stream
-com.sun.xml.internal.ws.model
-com.sun.xml.internal.ws.model.soap
-com.sun.xml.internal.ws.model.wsdl
-com.sun.xml.internal.ws.org.objectweb.asm
-com.sun.xml.internal.ws.policy
-com.sun.xml.internal.ws.policy.jaxws
-com.sun.xml.internal.ws.policy.jaxws.spi
-com.sun.xml.internal.ws.policy.privateutil
-com.sun.xml.internal.ws.policy.sourcemodel
-com.sun.xml.internal.ws.policy.sourcemodel.attach
-com.sun.xml.internal.ws.policy.sourcemodel.wspolicy
-com.sun.xml.internal.ws.policy.spi
-com.sun.xml.internal.ws.policy.subject
-com.sun.xml.internal.ws.protocol.soap
-com.sun.xml.internal.ws.protocol.xml
-com.sun.xml.internal.ws.resources
-com.sun.xml.internal.ws.runtime.config
-com.sun.xml.internal.ws.server
-com.sun.xml.internal.ws.server.provider
-com.sun.xml.internal.ws.server.sei
-com.sun.xml.internal.ws.spi
-com.sun.xml.internal.ws.spi.db
-com.sun.xml.internal.ws.streaming
-com.sun.xml.internal.ws.transport
-com.sun.xml.internal.ws.transport.http
-com.sun.xml.internal.ws.transport.http.client
-com.sun.xml.internal.ws.transport.http.server
-com.sun.xml.internal.ws.util
-com.sun.xml.internal.ws.util.exception
-com.sun.xml.internal.ws.util.pipe
-com.sun.xml.internal.ws.util.xml
-com.sun.xml.internal.ws.wsdl
-com.sun.xml.internal.ws.wsdl.parser
-com.sun.xml.internal.ws.wsdl.writer
-com.sun.xml.internal.ws.wsdl.writer.document
-com.sun.xml.internal.ws.wsdl.writer.document.http
-com.sun.xml.internal.ws.wsdl.writer.document.soap
-com.sun.xml.internal.ws.wsdl.writer.document.soap12
-com.sun.xml.internal.ws.wsdl.writer.document.xsd
-com.sun.xml.internal.xsom
-com.sun.xml.internal.xsom.impl
-com.sun.xml.internal.xsom.impl.parser
-com.sun.xml.internal.xsom.impl.parser.state
-com.sun.xml.internal.xsom.impl.scd
-com.sun.xml.internal.xsom.impl.util
-com.sun.xml.internal.xsom.parser
-com.sun.xml.internal.xsom.util
-com.sun.xml.internal.xsom.visitor
java.awt.dnd.peer
java.awt.peer
-javafx.embed.swt
jdk
jdk.internal.cmm
jdk.internal.dynalink
@@ -774,7 +266,6 @@
jdk.internal.org.xml.sax.helpers
jdk.internal.util.xml
jdk.internal.util.xml.impl
-jdk.jfr.events
jdk.management.resource.internal
jdk.management.resource.internal.inst
jdk.nashorn.internal
@@ -802,21 +293,8 @@
jdk.nashorn.internal.runtime.regexp.joni.exception
jdk.nashorn.internal.scripts
jdk.nashorn.tools
-oracle.jrockit.jfr
-oracle.jrockit.jfr.events
-oracle.jrockit.jfr.jdkevents
-oracle.jrockit.jfr.jdkevents.throwabletransform
-oracle.jrockit.jfr.openmbean
-oracle.jrockit.jfr.parser
-oracle.jrockit.jfr.settings
-oracle.jrockit.jfr.tools
org.jcp.xml.dsig.internal
org.jcp.xml.dsig.internal.dom
-org.omg.stub.javax.management.remote.rmi
-org.relaxng.datatype
-org.relaxng.datatype.helpers
-sun.applet
-sun.applet.resources
sun.audio
sun.awt
sun.awt.X11
@@ -832,7 +310,6 @@
sun.awt.shell
sun.awt.util
sun.awt.windows
-sun.corba
sun.dc
sun.dc.path
sun.dc.pr
@@ -876,10 +353,6 @@
sun.management.jdp
sun.management.jmxremote
sun.management.resources
-sun.management.snmp
-sun.management.snmp.jvminstr
-sun.management.snmp.jvmmib
-sun.management.snmp.util
sun.misc
sun.misc.resources
sun.net
@@ -930,9 +403,6 @@
sun.rmi.log
sun.rmi.registry
sun.rmi.rmic
-sun.rmi.rmic.iiop
-sun.rmi.rmic.newrmic
-sun.rmi.rmic.newrmic.jrmp
sun.rmi.runtime
sun.rmi.server
sun.rmi.transport
@@ -1008,13 +478,9 @@
sun.tools.jstack
sun.tools.jstat
sun.tools.jstatd
-sun.tools.native2ascii
-sun.tools.native2ascii.resources
sun.tools.serialver
sun.tools.tree
sun.tools.util
-sun.tracing
-sun.tracing.dtrace
sun.usagetracker
sun.util
sun.util.calendar
--- a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java Tue Dec 18 15:08:56 2018 -0500
@@ -54,7 +54,7 @@
* System.gc();
* Thread.sleep(5000);
* r.stop();
- * r.copyTo(Files.createTempFile("my-recording", ".jfr"));
+ * r.dump(Files.createTempFile("my-recording", ".jfr"));
* </code>
* </pre>
*
--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java Tue Dec 18 15:08:56 2018 -0500
@@ -726,6 +726,9 @@
private Duration getDuration(long timespan, String name) throws InternalError {
ValueDescriptor v = getValueDescriptor(descriptors, name, null);
+ if (timespan == Long.MIN_VALUE) {
+ return Duration.ofSeconds(Long.MIN_VALUE, 0);
+ }
Timespan ts = v.getAnnotation(Timespan.class);
if (ts != null) {
switch (ts.value()) {
@@ -797,13 +800,16 @@
return getInstant(Short.toUnsignedLong((Byte) u), name);
}
}
- throw newIllegalArgumentException(name, "java,time.Instant");
+ throw newIllegalArgumentException(name, "java.time.Instant");
}
private Instant getInstant(long timestamp, String name) {
ValueDescriptor v = getValueDescriptor(descriptors, name, null);
Timestamp ts = v.getAnnotation(Timestamp.class);
if (ts != null) {
+ if (timestamp == Long.MIN_VALUE) {
+ return Instant.MIN;
+ }
switch (ts.value()) {
case Timestamp.MILLISECONDS_SINCE_EPOCH:
return Instant.ofEpochMilli(timestamp);
@@ -884,6 +890,10 @@
// package private for now. Used by EventWriter
OffsetDateTime getOffsetDateTime(String name) {
+ Instant instant = getInstant(name);
+ if (instant.equals(Instant.MIN)) {
+ return OffsetDateTime.MIN;
+ }
return OffsetDateTime.ofInstant(getInstant(name), timeConverter.getZoneOffset());
}
--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/package-info.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -29,40 +29,27 @@
* In the following example, the program prints a histogram of all method samples in a recording.
* <pre>
* <code>
- * public static void main(String[] args) {
- * if (args.length != 0) {
- * System.out.println("Must specify recording file.");
- * return;
+ * public static void main(String[] args) throws IOException {
+ * if (args.length != 1) {
+ * System.err.println("Must specify a recording file.");
+ * return;
* }
- * try (RecordingFile f = new RecordingFile(Paths.get(args[0]))) {
- * Map{@literal <}String, SimpleEntry{@literal <}String, Integer{@literal >}{@literal >} histogram = new HashMap{@literal <}{@literal >}();
- * int total = 0;
- * while (f.hasMoreEvents()) {
- * RecordedEvent event = f.readEvent();
- * if (event.getEventType().getName().equals("jdk.ExecutionSample")) {
- * RecordedStackTrace s = event.getStackTrace();
- * if (s != null) {
- * RecordedFrame topFrame= s.getFrames().get(0);
- * if (topFrame.isJavaFrame()) {
- * RecordedMethod method = topFrame.getMethod();
- * String methodName = method.getType().getName() + "#" + method.getName() + " " + method.getDescriptor();
- * Entry entry = histogram.computeIfAbsent(methodName, u -{@literal >} new SimpleEntry{@literal <}String, Integer{@literal >}(methodName, 0));
- * entry.setValue(entry.getValue() + 1);
- * total++;
- * }
- * }
- * }
- * }
- * List{@literal <}SimpleEntry{@literal <}String, Integer{@literal >}{@literal >} entries = new ArrayList{@literal <}{@literal >}(histogram.values());
- * entries.sort((u, v) -{@literal >} v.getValue().compareTo(u.getValue()));
- * for (SimpleEntry{@literal <}String, Integer{@literal >} c : entries) {
- * System.out.printf("%2.0f%% %s\n", 100 * (float) c.getValue() / total, c.getKey());
- * }
- * System.out.println("\nSample count: " + total);
- * } catch (IOException ioe) {
- * System.out.println("Error reading file " + args[0] + ". " + ioe.getMessage());
- * }
- * }
+ *
+ * RecordingFile.readAllEvents(Path.of(args[0])).stream()
+ * .filter(e -> e.getEventType().getName().equals("jdk.ExecutionSample"))
+ * .map(e -> e.getStackTrace())
+ * .filter(s -> s != null)
+ * .map(s -> s.getFrames().get(0))
+ * .filter(f -> f.isJavaFrame())
+ * .map(f -> f.getMethod())
+ * .collect(
+ * Collectors.groupingBy(m -> m.getType().getName() + "." + m.getName() + " " + m.getDescriptor(),
+ * Collectors.counting()))
+ * .entrySet()
+ * .stream()
+ * .sorted((a, b) -> b.getValue().compareTo(a.getValue()))
+ * .forEach(e -> System.out.printf("%8d %s\n", e.getValue(), e.getKey()));
+ * }
* </code>
* </pre>
* <p>
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java Tue Dec 18 15:08:56 2018 -0500
@@ -516,4 +516,11 @@
* @param emitAll emit all samples in old object queue
*/
public native void emitOldObjectSamples(long cutoff, boolean emitAll);
+
+ /**
+ * Test if a chunk rotation is warranted.
+ *
+ * @return if it is time to perform a chunk rotation
+ */
+ public native boolean shouldRotateDisk();
}
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataHandler.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataHandler.java Tue Dec 18 15:08:56 2018 -0500
@@ -100,7 +100,7 @@
final Map<String, TypeElement> types = new LinkedHashMap<>(200);
final Map<String, XmlType> xmlTypes = new HashMap<>(20);
- final Map<String, AnnotationElement> xmlContentTypes = new HashMap<>(20);
+ final Map<String, List<AnnotationElement>> xmlContentTypes = new HashMap<>(20);
final List<String> relations = new ArrayList<>();
long eventTypeId = 255;
long structTypeId = 33;
@@ -148,11 +148,8 @@
break;
case "XmlContentType":
String name = attributes.getValue("name");
- String type = attributes.getValue("annotationType");
- String value = attributes.getValue("annotationValue");
- Class<? extends Annotation> annotationType = createAnnotationClass(type);
- AnnotationElement ae = value == null ? new AnnotationElement(annotationType) : new AnnotationElement(annotationType, value);
- xmlContentTypes.put(name, ae);
+ String annotation = attributes.getValue("annotation");
+ xmlContentTypes.put(name, createAnnotationElements(annotation));
break;
case "Relation":
String n = attributes.getValue("name");
@@ -161,6 +158,27 @@
}
}
+ private List<AnnotationElement> createAnnotationElements(String annotation) throws InternalError {
+ String[] annotations = annotation.split(",");
+ List<AnnotationElement> annotationElements = new ArrayList<>();
+ for (String a : annotations) {
+ a = a.trim();
+ int leftParenthesis = a.indexOf("(");
+ if (leftParenthesis == -1) {
+ annotationElements.add(new AnnotationElement(createAnnotationClass(a)));
+ } else {
+ int rightParenthesis = a.lastIndexOf(")");
+ if (rightParenthesis == -1) {
+ throw new InternalError("Expected closing parenthesis for 'XMLContentType'");
+ }
+ String value = a.substring(leftParenthesis + 1, rightParenthesis);
+ String type = a.substring(0, leftParenthesis);
+ annotationElements.add(new AnnotationElement(createAnnotationClass(type), value));
+ }
+ }
+ return annotationElements;
+ }
+
@SuppressWarnings("unchecked")
private Class<? extends Annotation> createAnnotationClass(String type) {
try {
@@ -255,7 +273,7 @@
aes.add(new AnnotationElement(Unsigned.class));
}
if (f.contentType != null) {
- aes.add(Objects.requireNonNull(xmlContentTypes.get(f.contentType)));
+ aes.addAll(Objects.requireNonNull(xmlContentTypes.get(f.contentType)));
}
if (f.relation != null) {
aes.add(Objects.requireNonNull(relationMap.get(f.relation)));
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java Tue Dec 18 15:08:56 2018 -0500
@@ -427,19 +427,13 @@
}
private void periodicTask() {
+ if (!jvm.hasNativeJFR()) {
+ return;
+ }
while (true) {
synchronized (this) {
- if (!jvm.hasNativeJFR()) {
- return;
- }
- if (currentChunk != null) {
- try {
- if (SecuritySupport.getFileSize(currentChunk.getUnfishedFile()) > Options.getMaxChunkSize()) {
- rotateDisk();
- }
- } catch (IOException e) {
- Logger.log(JFR_SYSTEM, WARN, "Could not check file size to determine chunk rotation");
- }
+ if (jvm.shouldRotateDisk()) {
+ rotateDisk();
}
}
long minDelta = RequestEngine.doPeriodic();
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java Tue Dec 18 15:08:56 2018 -0500
@@ -123,7 +123,7 @@
options.add("maxage=" + Utils.formatTimespan(maxAge, ""));
}
if (maxSize != 0) {
- options.add("maxsize=" + Utils.formatBytes(maxSize, ""));
+ options.add("maxsize=" + Utils.formatBytesCompact(maxSize));
}
if (dumpOnExit) {
options.add("dumponexit=true");
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java Tue Dec 18 15:08:56 2018 -0500
@@ -103,18 +103,53 @@
}
}
- public static String formatBytes(long bytes, String separation) {
- if (bytes == 1) {
- return "1 byte";
+ // Tjis method can't handle Long.MIN_VALUE because absolute value is negative
+ private static String formatDataAmount(String formatter, long amount) {
+ int exp = (int) (Math.log(Math.abs(amount)) / Math.log(1024));
+ char unitPrefix = "kMGTPE".charAt(exp - 1);
+ return String.format(formatter, amount / Math.pow(1024, exp), unitPrefix);
+ }
+
+ public static String formatBytesCompact(long bytes) {
+ if (bytes < 1024) {
+ return String.valueOf(bytes);
}
- if (bytes < 1024) {
+ return formatDataAmount("%.1f%cB", bytes);
+ }
+
+ public static String formatBits(long bits) {
+ if (bits == 1 || bits == -1) {
+ return bits + " bit";
+ }
+ if (bits < 1024 && bits > -1024) {
+ return bits + " bits";
+ }
+ return formatDataAmount("%.1f %cbit", bits);
+ }
+
+ public static String formatBytes(long bytes) {
+ if (bytes == 1 || bytes == -1) {
+ return bytes + " byte";
+ }
+ if (bytes < 1024 && bytes > -1024) {
return bytes + " bytes";
}
- int exp = (int) (Math.log(bytes) / Math.log(1024));
- char bytePrefix = "kMGTPE".charAt(exp - 1);
- return String.format("%.1f%s%cB", bytes / Math.pow(1024, exp), separation, bytePrefix);
+ return formatDataAmount("%.1f %cB", bytes);
}
+ public static String formatBytesPerSecond(long bytes) {
+ if (bytes < 1024 && bytes > -1024) {
+ return bytes + " byte/s";
+ }
+ return formatDataAmount("%.1f %cB/s", bytes);
+ }
+
+ public static String formatBitsPerSecond(long bits) {
+ if (bits < 1024 && bits > -1024) {
+ return bits + " bps";
+ }
+ return formatDataAmount("%.1f %cbps", bits);
+ }
public static String formatTimespan(Duration dValue, String separation) {
if (dValue == null) {
return "0";
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java Tue Dec 18 15:08:56 2018 -0500
@@ -109,7 +109,7 @@
try {
print(" ");
long bytes = SecuritySupport.getFileSize(file);
- printBytes(bytes, " ");
+ printBytes(bytes);
} catch (IOException e) {
// Ignore, not essential
}
@@ -152,8 +152,8 @@
println();
}
- protected final void printBytes(long bytes, String separation) {
- print(Utils.formatBytes(bytes, separation));
+ protected final void printBytes(long bytes) {
+ print(Utils.formatBytes(bytes));
}
protected final void printTimespan(Duration timespan, String separator) {
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java Tue Dec 18 15:08:56 2018 -0500
@@ -39,6 +39,7 @@
import jdk.jfr.internal.LogLevel;
import jdk.jfr.internal.LogTag;
import jdk.jfr.internal.Logger;
+import jdk.jfr.internal.Utils;
/**
* JFR.check - invoked from native
@@ -117,7 +118,7 @@
long maxSize = recording.getMaxSize();
if (maxSize != 0) {
print(" maxsize=");
- printBytes(maxSize, "");
+ print(Utils.formatBytesCompact(maxSize));
}
Duration maxAge = recording.getMaxAge();
if (maxAge != null) {
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java Tue Dec 18 15:08:56 2018 -0500
@@ -193,25 +193,25 @@
private void printGlobalBufferSize() {
print("Global buffer size: ");
- printBytes(Options.getGlobalBufferSize(), " ");
+ printBytes(Options.getGlobalBufferSize());
println();
}
private void printThreadBufferSize() {
print("Thread buffer size: ");
- printBytes(Options.getThreadBufferSize(), " ");
+ printBytes(Options.getThreadBufferSize());
println();
}
private void printMemorySize() {
print("Memory size: ");
- printBytes(Options.getMemorySize(), " ");
+ printBytes(Options.getMemorySize());
println();
}
private void printMaxChunkSize() {
print("Max chunk size: ");
- printBytes(Options.getMaxChunkSize(), " ");
+ printBytes(Options.getMaxChunkSize());
println();
}
}
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java Tue Dec 18 15:08:56 2018 -0500
@@ -281,7 +281,7 @@
private void printValue(Object value, ValueDescriptor field, String postFix) {
if (value == null) {
- println("null" + postFix);
+ println("N/A" + postFix);
return;
}
if (value instanceof RecordedObject) {
@@ -315,11 +315,42 @@
printArray((Object[]) value);
return;
}
+
+ if (value instanceof Double) {
+ Double d = (Double) value;
+ if (Double.isNaN(d) || d == Double.NEGATIVE_INFINITY) {
+ println("N/A");
+ return;
+ }
+ }
+ if (value instanceof Float) {
+ Float f = (Float) value;
+ if (Float.isNaN(f) || f == Float.NEGATIVE_INFINITY) {
+ println("N/A");
+ return;
+ }
+ }
+ if (value instanceof Long) {
+ Long l = (Long) value;
+ if (l == Long.MIN_VALUE) {
+ println("N/A");
+ return;
+ }
+ }
+ if (value instanceof Integer) {
+ Integer i = (Integer) value;
+ if (i == Integer.MIN_VALUE) {
+ println("N/A");
+ return;
+ }
+ }
+
if (field.getContentType() != null) {
if (printFormatted(field, value)) {
return;
}
}
+
String text = String.valueOf(value);
if (value instanceof String) {
text = "\"" + text + "\"";
@@ -443,6 +474,10 @@
private boolean printFormatted(ValueDescriptor field, Object value) {
if (value instanceof Duration) {
Duration d = (Duration) value;
+ if (d.getSeconds() == Long.MIN_VALUE && d.getNano() == 0) {
+ println("N/A");
+ return true;
+ }
double s = d.toNanosPart() / 1000_000_000.0 + d.toSecondsPart();
if (s < 1.0) {
if (s < 0.001) {
@@ -460,8 +495,12 @@
return true;
}
if (value instanceof OffsetDateTime) {
- OffsetDateTime zdt = (OffsetDateTime) value;
- println(TIME_FORMAT.format(zdt));
+ OffsetDateTime odt = (OffsetDateTime) value;
+ if (odt.equals(OffsetDateTime.MIN)) {
+ println("N/A");
+ return true;
+ }
+ println(TIME_FORMAT.format(odt));
return true;
}
Percentage percentage = field.getAnnotation(Percentage.class);
@@ -476,12 +515,26 @@
if (dataAmount != null) {
if (value instanceof Number) {
Number n = (Number) value;
- String bytes = Utils.formatBytes(n.longValue(), " ");
+ long amount = n.longValue();
if (field.getAnnotation(Frequency.class) != null) {
- bytes += "/s";
+ if (dataAmount.value().equals(DataAmount.BYTES)) {
+ println(Utils.formatBytesPerSecond(amount));
+ return true;
+ }
+ if (dataAmount.value().equals(DataAmount.BITS)) {
+ println(Utils.formatBitsPerSecond(amount));
+ return true;
+ }
+ } else {
+ if (dataAmount.value().equals(DataAmount.BYTES)) {
+ println(Utils.formatBytes(amount));
+ return true;
+ }
+ if (dataAmount.value().equals(DataAmount.BITS)) {
+ println(Utils.formatBits(amount));
+ return true;
+ }
}
- println(bytes);
- return true;
}
}
MemoryAddress memoryAddress = field.getAnnotation(MemoryAddress.class);
@@ -492,6 +545,14 @@
return true;
}
}
+ Frequency frequency = field.getAnnotation(Frequency.class);
+ if (frequency != null) {
+ if (value instanceof Number) {
+ println(value + " Hz");
+ return true;
+ }
+ }
+
return false;
}
--- a/src/jdk.jfr/share/classes/jdk/jfr/package-info.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/package-info.java Tue Dec 18 15:08:56 2018 -0500
@@ -105,7 +105,6 @@
* {@link jdk.jfr.ValueDescriptor#getName()}.
* <p>
* <b>Predefined settings</b>
- * <p>
* <table class="striped">
* <caption>Event setting names and their purpose.</caption> <thead>
* <tr>
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java Tue Dec 18 15:08:56 2018 -0500
@@ -113,7 +113,7 @@
}
public synchronized void write(int b) {
- if (state != State.BUFFER) {
+ if (state == State.READ) {
state = State.WAIT;
}
int newEnd = (end + 1) % buffer.length;
--- a/src/jdk.management.jfr/share/classes/jdk/management/jfr/FlightRecorderMXBean.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.management.jfr/share/classes/jdk/management/jfr/FlightRecorderMXBean.java Tue Dec 18 15:08:56 2018 -0500
@@ -517,7 +517,6 @@
* event type is obtained by invoking
* {@link jdk.jfr.EventType#getSettingDescriptors()} and
* {@link jdk.jfr.ValueDescriptor#getName()}.
- * <p>
*
* @param recordingId ID of the recording
*
--- a/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java Tue Dec 18 15:08:56 2018 -0500
@@ -67,7 +67,7 @@
/* Class File Constants */
int JAVA_MAGIC = 0xcafebabe;
int JAVA_MIN_SUPPORTED_VERSION = 45;
- int JAVA_MAX_SUPPORTED_VERSION = 56;
+ int JAVA_MAX_SUPPORTED_VERSION = 57;
int JAVA_MAX_SUPPORTED_MINOR_VERSION = 0;
/* Generate class file version for 1.1 by default */
--- a/src/jdk.security.auth/share/classes/com/sun/security/auth/login/ConfigFile.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/login/ConfigFile.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,8 +55,8 @@
* each configuration.
*
* <li>
- * The {@code java.lang.System} property
- * <i>java.security.auth.login.config</i>
+ * The system property
+ * {@systemProperty java.security.auth.login.config}
* may also be set to a {@code URL} pointing to another
* login configuration file
* (which is the case when a user uses the -D switch at runtime).
--- a/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java Wed Dec 12 08:38:45 2018 -0500
+++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -84,7 +84,7 @@
* by using the option {@code principal}. The principal name
* can either be a simple user name, a service name such as
* {@code host/mission.eng.sun.com}, or "*". The principal can also
- * be set using the system property {@code sun.security.krb5.principal}.
+ * be set using the system property {@systemProperty sun.security.krb5.principal}.
* This property is checked during login. If this property is not set, then
* the principal name from the configuration is used. In the
* case where the principal property is not set and the principal
--- a/test/hotspot/gtest/jfr/test_networkUtilization.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/gtest/jfr/test_networkUtilization.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -258,7 +258,7 @@
JfrNetworkUtilization::send_events();
ASSERT_EQ(1u, MockEventNetworkUtilization::committed.size());
MockEventNetworkUtilization& e = MockEventNetworkUtilization::committed[0];
- EXPECT_EQ(5, e.readRate);
+ EXPECT_EQ(40, e.readRate);
EXPECT_EQ(0, e.writeRate);
EXPECT_STREQ("eth0", e.iface.c_str());
}
@@ -282,16 +282,16 @@
const MockEventNetworkUtilization& eth1_event = MockEventNetworkUtilization::get_committed("eth1");
const MockEventNetworkUtilization& ppp0_event = MockEventNetworkUtilization::get_committed("ppp0");
- EXPECT_EQ(5, eth0_event.readRate);
+ EXPECT_EQ(40, eth0_event.readRate);
EXPECT_EQ(0, eth0_event.writeRate);
EXPECT_STREQ("eth0", eth0_event.iface.c_str());
- EXPECT_EQ(50, eth1_event.readRate);
+ EXPECT_EQ(400, eth1_event.readRate);
EXPECT_EQ(0, eth1_event.writeRate);
EXPECT_STREQ("eth1", eth1_event.iface.c_str());
EXPECT_EQ(0, ppp0_event.readRate);
- EXPECT_EQ(25, ppp0_event.writeRate);
+ EXPECT_EQ(200, ppp0_event.writeRate);
EXPECT_STREQ("ppp0", ppp0_event.iface.c_str());
}
@@ -310,11 +310,11 @@
const MockEventNetworkUtilization& eth0_event = MockEventNetworkUtilization::get_committed("eth0");
const MockEventNetworkUtilization& eth1_event = MockEventNetworkUtilization::get_committed("eth1");
- EXPECT_EQ(5, eth0_event.readRate);
+ EXPECT_EQ(40, eth0_event.readRate);
EXPECT_EQ(0, eth0_event.writeRate);
EXPECT_STREQ("eth0", eth0_event.iface.c_str());
- EXPECT_EQ(10, eth1_event.readRate);
+ EXPECT_EQ(80, eth1_event.readRate);
EXPECT_EQ(0, eth1_event.writeRate);
EXPECT_STREQ("eth1", eth1_event.iface.c_str());
@@ -327,7 +327,7 @@
ASSERT_EQ(1u, MockEventNetworkUtilization::committed.size());
const MockEventNetworkUtilization& eth1_event_v2 = MockEventNetworkUtilization::get_committed("eth1");
- EXPECT_EQ(5, eth1_event_v2.readRate);
+ EXPECT_EQ(40, eth1_event_v2.readRate);
EXPECT_EQ(0, eth1_event_v2.writeRate);
EXPECT_STREQ("eth1", eth1_event_v2.iface.c_str());
}
@@ -343,7 +343,7 @@
JfrNetworkUtilization::send_events();
ASSERT_EQ(1u, MockEventNetworkUtilization::committed.size());
const MockEventNetworkUtilization& event = MockEventNetworkUtilization::committed[0];
- EXPECT_EQ(5, event.readRate);
+ EXPECT_EQ(40, event.readRate);
EXPECT_EQ(0, event.writeRate);
EXPECT_STREQ("eth0", event.iface.c_str());
@@ -360,7 +360,7 @@
JfrNetworkUtilization::send_events();
ASSERT_EQ(1u, MockEventNetworkUtilization::committed.size());
const MockEventNetworkUtilization& event_v2 = MockEventNetworkUtilization::committed[0];
- EXPECT_EQ(5, event_v2.readRate);
+ EXPECT_EQ(40, event_v2.readRate);
EXPECT_EQ(0, event_v2.writeRate);
EXPECT_STREQ("eth0", event_v2.iface.c_str());
}
--- a/test/hotspot/jtreg/ProblemList-graal.txt Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/jtreg/ProblemList-graal.txt Tue Dec 18 15:08:56 2018 -0500
@@ -159,7 +159,6 @@
org.graalvm.compiler.replacements.test.classfile.ClassfileBytecodeProviderTest 8205081
org.graalvm.compiler.core.test.deopt.CompiledMethodTest 8202955
-org.graalvm.compiler.core.test.CountedLoopTest 8211179
org.graalvm.compiler.debug.test.DebugContextTest 8203504
org.graalvm.compiler.hotspot.test.GraalOSRTest 8206947
--- a/test/hotspot/jtreg/ProblemList.txt Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/jtreg/ProblemList.txt Tue Dec 18 15:08:56 2018 -0500
@@ -187,7 +187,6 @@
vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted004/TestDescription.java 7013634,6606767 generic-all
vmTestbase/nsk/jvmti/ThreadStart/threadstart001/TestDescription.java 8016181 generic-all
vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/TestDescription.java 8173658 generic-all
-vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/TestDescription.java 8051349 generic-all
vmTestbase/nsk/jvmti/AttachOnDemand/attach034/TestDescription.java 8042145 generic-all
vmTestbase/nsk/jvmti/AttachOnDemand/attach045/TestDescription.java 8202971 generic-all
vmTestbase/nsk/jvmti/unit/heap/HeapWalkTests/TestDescription.java 8016181 generic-all
--- a/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java Tue Dec 18 15:08:56 2018 -0500
@@ -89,6 +89,11 @@
private static String[] getCmd(String[] args) {
List<String> extraFlags = new ArrayList<>();
+ // java.io.tmpdir is set for both harness and forked VM so temporary files
+ // created like this File.createTempFile("jcstress", "stdout");
+ // don't pollute temporary directories
+ extraFlags.add("-Djava.io.tmpdir=" + System.getProperty("user.dir"));
+
// add jar with jcstress tests and harness to CP
extraFlags.add("-cp");
extraFlags.add(System.getProperty("java.class.path")
@@ -97,16 +102,11 @@
extraFlags.add(MAIN_CLASS);
- String[] javaOpts = Utils.getTestJavaOpts();
- // disable flags auto-detection
- if (0 == javaOpts.length) {
+ extraFlags.add("--jvmArgs");
+ extraFlags.add("-Djava.io.tmpdir=" + System.getProperty("user.dir"));
+ for (String jvmArg : Utils.getTestJavaOpts()) {
extraFlags.add("--jvmArgs");
- extraFlags.add("");
- } else {
- for (String jvmArg : Utils.getTestJavaOpts()) {
- extraFlags.add("--jvmArgs");
- extraFlags.add(jvmArg);
- }
+ extraFlags.add(jvmArg);
}
String[] result = new String[extraFlags.size() + args.length];
--- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java Tue Dec 18 15:08:56 2018 -0500
@@ -772,7 +772,8 @@
f.getDeclaringClass().equals(metaAccess.lookupJavaType(AccessibleObject.class)) ||
f.getDeclaringClass().equals(metaAccess.lookupJavaType(Constructor.class)) ||
f.getDeclaringClass().equals(metaAccess.lookupJavaType(Field.class)) ||
- f.getDeclaringClass().equals(metaAccess.lookupJavaType(Method.class))) {
+ f.getDeclaringClass().equals(metaAccess.lookupJavaType(Method.class)) ||
+ f.getDeclaringClass().equals(metaAccess.lookupJavaType(Module.class))) {
return true;
}
return false;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/loopopts/superword/Vec_MulAddS2I.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8214751
+ * @summary Add C2 x86 Superword support for VNNI VPDPWSSD Instruction
+ * @requires os.arch=="x86" | os.arch=="i386" | os.arch=="amd64" | os.arch=="x86_64"
+ *
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
+ * -XX:CompileThresholdScaling=0.1
+ * -XX:+SuperWord
+ * -XX:LoopMaxUnroll=2
+ * compiler.loopopts.superword.Vec_MulAddS2I
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
+ * -XX:CompileThresholdScaling=0.1
+ * -XX:-SuperWord
+ * -XX:LoopMaxUnroll=2
+ * compiler.loopopts.superword.Vec_MulAddS2I
+ *
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
+ * -XX:CompileThresholdScaling=0.1
+ * -XX:+SuperWord
+ * -XX:LoopMaxUnroll=4
+ * compiler.loopopts.superword.Vec_MulAddS2I
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
+ * -XX:CompileThresholdScaling=0.1
+ * -XX:-SuperWord
+ * -XX:LoopMaxUnroll=4
+ * compiler.loopopts.superword.Vec_MulAddS2I
+ *
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
+ * -XX:CompileThresholdScaling=0.1
+ * -XX:+SuperWord
+ * -XX:LoopMaxUnroll=8
+ * compiler.loopopts.superword.Vec_MulAddS2I
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
+ * -XX:CompileThresholdScaling=0.1
+ * -XX:-SuperWord
+ * -XX:LoopMaxUnroll=8
+ * compiler.loopopts.superword.Vec_MulAddS2I
+ *
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
+ * -XX:CompileThresholdScaling=0.1
+ * -XX:+SuperWord
+ * -XX:LoopMaxUnroll=16
+ * compiler.loopopts.superword.Vec_MulAddS2I
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=250
+ * -XX:CompileThresholdScaling=0.1
+ * -XX:-SuperWord
+ * -XX:LoopMaxUnroll=16
+ * compiler.loopopts.superword.Vec_MulAddS2I
+ */
+
+package compiler.loopopts.superword;
+import java.util.Random;
+
+public class Vec_MulAddS2I {
+ static final int NUM = 1024;
+ static int[] out = new int[NUM];
+ static short[] in1 = new short[2*NUM];
+ static short[] in2 = new short[2*NUM];
+ public static void main(String[] args) throws Exception {
+ Vec_MulAddS2IInit(in1, in2);
+ int result = 0;
+ int valid = 204800000;
+ for (int j = 0; j < 10000*512; j++) {
+ result = Vec_MulAddS2IImplement(in1, in2, out);
+ }
+ if (result == valid) {
+ System.out.println("Success");
+ } else {
+ System.out.println("Invalid calculation of element variables in the out array: " + result);
+ System.out.println("Expected value for each element of out array = " + valid);
+ throw new Exception("Failed");
+ }
+ }
+
+ public static void Vec_MulAddS2IInit(
+ short[] in1,
+ short[] in2) {
+ for (int i=0; i<2*NUM; i++) {
+ in1[i] = (short)4;
+ in2[i] = (short)5;
+ }
+ }
+
+ public static int Vec_MulAddS2IImplement(
+ short[] in1,
+ short[] in2,
+ int[] out) {
+ for (int i = 0; i < NUM; i++) {
+ out[i] += ((in1[2*i] * in2[2*i]) + (in1[2*i+1] * in2[2*i+1]));
+ }
+ Random rand = new Random();
+ int n = rand.nextInt(NUM-1);
+ return out[n];
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018, 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 jdk.test.lib.*;
+import jdk.test.lib.process.*;
+
+/*
+ * @test TestAbortOnVMOperationTimeout
+ * @bug 8181143
+ * @summary Check abort on VM timeout is working
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * java.management
+ */
+
+public class TestAbortOnVMOperationTimeout {
+
+ public static void main(String[] args) throws Exception {
+ if (args.length > 0) {
+ Object[] arr = new Object[10_000_000];
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = new Object();
+ }
+ return;
+ }
+
+ // These should definitely pass: more than a minute is enough for Serial to act.
+ // The values are deliberately non-round to trip off periodic task granularity.
+ for (int delay : new int[]{63423, 12388131}) {
+ testWith(delay, true);
+ }
+
+ // These should fail: Serial is not very fast. Traversing 10M objects in 5 ms
+ // means less than 0.5 ns per object, which is not doable.
+ for (int delay : new int[]{0, 1, 5}) {
+ testWith(delay, false);
+ }
+ }
+
+ public static void testWith(int delay, boolean shouldPass) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:+AbortVMOnVMOperationTimeout",
+ "-XX:AbortVMOnVMOperationTimeoutDelay=" + delay,
+ "-Xmx256m",
+ "-XX:+UseSerialGC",
+ "-XX:-CreateCoredumpOnCrash",
+ "TestAbortOnVMOperationTimeout",
+ "foo"
+ );
+
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ if (shouldPass) {
+ output.shouldHaveExitValue(0);
+ } else {
+ output.shouldMatch("VM operation took too long");
+ output.shouldNotHaveExitValue(0);
+ }
+ }
+}
+
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorEventsForTwoThreadsTest.java Wed Dec 12 08:38:45 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2018, Google and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package MyPackage;
-
-/**
- * @test
- * @build Frame HeapMonitor ThreadInformation
- * @summary Ensures the JVMTI Heap Monitor is not thread enable (test to change when it becomes so)
- * @compile HeapMonitorEventsForTwoThreadsTest.java
- * @run main/othervm/native -agentlib:HeapMonitorTest MyPackage.HeapMonitorEventsForTwoThreadsTest
- */
-
-import java.util.List;
-
-public class HeapMonitorEventsForTwoThreadsTest {
- public native static boolean checkSamples();
-
- public static void main(String[] args) {
- final int numThreads = 24;
- List<ThreadInformation> threadList = ThreadInformation.createThreadList(numThreads);
-
- Thread firstThread = threadList.get(0).getThread();
- Thread secondThread = threadList.get(1).getThread();
- if (HeapMonitor.enableSamplingEventsForTwoThreads(firstThread, secondThread)) {
- throw new RuntimeException("Sampling event is thread enabled, that is unexpected.");
- }
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorThreadDisabledTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, Google and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package MyPackage;
+
+/**
+ * @test
+ * @build Frame HeapMonitor ThreadInformation
+ * @summary Verifies the JVMTI Heap Monitor Thread can disable events for a given thread.
+ * @compile HeapMonitorThreadDisabledTest.java
+ * @run main/othervm/native -Xmx512m -agentlib:HeapMonitorTest MyPackage.HeapMonitorThreadDisabledTest
+ */
+
+import java.util.List;
+
+public class HeapMonitorThreadDisabledTest {
+ private native static void enableSamplingEvents(Thread thread);
+ private native static boolean checkThreadSamplesOnlyFrom(Thread thread);
+
+ public static void main(String[] args) {
+ final int numThreads = 4;
+ List<ThreadInformation> threadList = ThreadInformation.createThreadList(numThreads);
+
+ // Sample at a interval of 8k.
+ HeapMonitor.setSamplingInterval(1 << 13);
+
+ // Only enable the sampling for a given thread.
+ Thread thread = threadList.get(0).getThread();
+ enableSamplingEvents(thread);
+
+ System.err.println("Starting threads");
+ ThreadInformation.startThreads(threadList);
+ ThreadInformation.waitForThreads(threadList);
+ System.err.println("Waited for threads");
+
+ // Only have the samples for a given thread should be captured.
+ if (!checkThreadSamplesOnlyFrom(thread)) {
+ throw new RuntimeException(
+ "Problem with checkSamples: got no events from the expected thread");
+ }
+
+ // Now inform each thread we are done and wait for them to be done.
+ ThreadInformation.stopThreads(threadList);
+ }
+}
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorThreadTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorThreadTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -30,7 +30,7 @@
* @summary Verifies the JVMTI Heap Monitor Thread information sanity.
* @compile HeapMonitorThreadTest.java
* @run main/othervm/native -Xmx512m -agentlib:HeapMonitorTest MyPackage.HeapMonitorThreadTest
- * @requires !vm.gc.Z
+ * @requires vm.gc != "Z"
*/
import java.util.List;
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.c Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.c Tue Dec 18 15:08:56 2018 -0500
@@ -720,101 +720,86 @@
#define MAX_THREADS 500
typedef struct ThreadStats {
- int number_threads;
+ int thread_count;
int counts[MAX_THREADS];
- int not_helper_counts[MAX_THREADS];
- int index[MAX_THREADS];
- jthread threads[MAX_THREADS];
-
- int method_resolution_problem;
+ char* threads[MAX_THREADS];
} ThreadStats;
static ThreadStats thread_stats;
-static void add_thread_count(jthread thread, int lock, int helper) {
- int i;
+JNIEXPORT jboolean JNICALL
+Java_MyPackage_HeapMonitorThreadDisabledTest_checkThreadSamplesOnlyFrom(
+ JNIEnv* env, jclass cls, jthread thread) {
jvmtiThreadInfo info;
- const char* name;
- char* end;
- int idx;
- int err;
+ jvmtiError err;
+ char* expected_name;
+ int found_thread = FALSE;
+
+ err = (*jvmti)->GetThreadInfo(jvmti, thread, &info);
+ expected_name = info.name;
- if (lock) {
- event_storage_lock(&global_event_storage);
+ if (err != JVMTI_ERROR_NONE) {
+ fprintf(stderr, "Failed to get thread information\n");
+ return FALSE;
+ }
+
+ if (thread_stats.thread_count != 1) {
+ fprintf(stderr, "Wrong thread number: %d (expected 1)\n",
+ thread_stats.thread_count);
+ return FALSE;
}
- for (i = 0; i < thread_stats.number_threads; i++) {
- if (thread_stats.threads[i] == thread) {
- if (helper) {
- thread_stats.counts[i]++;
- } else {
- thread_stats.not_helper_counts[i]++;
- }
+ if (strcmp(expected_name, thread_stats.threads[0]) != 0) {
+ fprintf(stderr, "Unexpected thread name: '%s' (expected '%s')\n",
+ thread_stats.threads[0], expected_name);
+ return FALSE;
+ }
+
+ return TRUE;
+}
- if (lock) {
- event_storage_unlock(&global_event_storage);
- }
+static void add_thread_count(jthread thread) {
+ int i;
+ jvmtiThreadInfo info;
+ jvmtiError err;
+
+ err = (*jvmti)->GetThreadInfo(jvmti, thread, &info);
+ if (err != JVMTI_ERROR_NONE) {
+ fprintf(stderr, "Thread info for %p failed, ignoring thread count\n",
+ thread);
+ return;
+ }
+
+ event_storage_lock(&global_event_storage);
+ for (i = 0; i < thread_stats.thread_count; i++) {
+ if (!strcmp(thread_stats.threads[i], info.name)) {
+ thread_stats.counts[i]++;
+ event_storage_unlock(&global_event_storage);
return;
}
}
- thread_stats.threads[thread_stats.number_threads] = thread;
-
- err = (*jvmti)->GetThreadInfo(jvmti, thread, &info);
- if (err != JVMTI_ERROR_NONE) {
- if (lock) {
- event_storage_unlock(&global_event_storage);
- }
-
- // Just to have it accounted as an error...
- info.name = "Allocator99";
- }
-
- if (!strstr(info.name, "Allocator")) {
- if (lock) {
- event_storage_unlock(&global_event_storage);
- }
-
- // Just to have it accounted as an error...
- info.name = "Allocator98";
- }
+ thread_stats.threads[thread_stats.thread_count] = info.name;
+ thread_stats.counts[thread_stats.thread_count]++;
+ thread_stats.thread_count++;
+ event_storage_unlock(&global_event_storage);
+}
- name = info.name + 9;
- end = NULL;
- idx = strtol(name, &end, 0);
-
- if (*end == '\0') {
- if (helper) {
- thread_stats.counts[thread_stats.number_threads]++;
- } else {
- thread_stats.not_helper_counts[thread_stats.number_threads]++;
- }
-
- thread_stats.index[thread_stats.number_threads] = idx;
- thread_stats.number_threads++;
- } else {
- fprintf(stderr, "Problem with thread name...: %p %s\n", thread, name);
- }
-
- if (PRINT_OUT) {
- fprintf(stderr, "Added %s - %p - %d - lock: %d\n", info.name, thread, idx, lock);
- }
-
- if (lock) {
- event_storage_unlock(&global_event_storage);
- }
+JNIEXPORT void JNICALL
+Java_MyPackage_HeapMonitorThreadDisabledTest_enableSamplingEvents(
+ JNIEnv* env, jclass cls, jthread thread) {
+ fprintf(stderr, "Enabling for %p\n", thread);
+ check_error((*jvmti)->SetEventNotificationMode(
+ jvmti, JVMTI_ENABLE, JVMTI_EVENT_SAMPLED_OBJECT_ALLOC, thread),
+ "Set event notifications for a single thread");
}
static void print_thread_stats() {
int i;
event_storage_lock(&global_event_storage);
- fprintf(stderr, "Method resolution problem: %d\n", thread_stats.method_resolution_problem);
fprintf(stderr, "Thread count:\n");
- for (i = 0; i < thread_stats.number_threads; i++) {
- fprintf(stderr, "\t%p: %d: %d - %d\n", thread_stats.threads[i],
- thread_stats.index[i],
- thread_stats.counts[i],
- thread_stats.not_helper_counts[i]);
+ for (i = 0; i < thread_stats.thread_count; i++) {
+ fprintf(stderr, "\t%s: %d\n", thread_stats.threads[i], thread_stats.counts[i]);
}
event_storage_unlock(&global_event_storage);
}
@@ -826,7 +811,7 @@
jobject object,
jclass object_klass,
jlong size) {
- add_thread_count(thread, 1, 1);
+ add_thread_count(thread);
if (event_storage_get_compaction_required(&global_event_storage)) {
event_storage_compact(&global_event_storage, jni_env);
@@ -864,29 +849,6 @@
"Set event notifications");
}
-static int enable_notifications_for_two_threads(jthread first, jthread second) {
- if (check_error((*jvmti)->SetEventNotificationMode(
- jvmti, JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL),
- "Set event notifications")) {
- return 0;
- }
-
- if (check_error((*jvmti)->SetEventNotificationMode(
- jvmti, JVMTI_ENABLE, JVMTI_EVENT_SAMPLED_OBJECT_ALLOC, first),
- "Set event notifications")) {
- return 0;
- }
-
- // Second thread should fail.
- if (check_error((*jvmti)->SetEventNotificationMode(
- jvmti, JVMTI_ENABLE, JVMTI_EVENT_SAMPLED_OBJECT_ALLOC, second),
- "Set event notifications")) {
- return 0;
- }
-
- return 1;
-}
-
static
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jint res;
@@ -970,14 +932,6 @@
enable_notifications();
}
-JNIEXPORT jboolean JNICALL
-Java_MyPackage_HeapMonitor_enableSamplingEventsForTwoThreads(JNIEnv* env,
- jclass cls,
- jthread first,
- jthread second) {
- return enable_notifications_for_two_threads(first, second);
-}
-
JNIEXPORT void JNICALL
Java_MyPackage_HeapMonitor_disableSamplingEvents(JNIEnv* env, jclass cls) {
check_error((*jvmti)->SetEventNotificationMode(
@@ -1130,10 +1084,9 @@
JNIEXPORT jboolean JNICALL
Java_MyPackage_HeapMonitorThreadTest_checkSamples(JNIEnv* env, jclass cls,
jint num_threads) {
-
print_thread_stats();
// Ensure we got stacks from at least num_threads.
- return thread_stats.number_threads >= num_threads;
+ return thread_stats.thread_count >= num_threads;
}
JNIEXPORT
--- a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/IntxTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/IntxTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -34,17 +34,28 @@
* @summary testing of WB::set/getIntxVMFlag()
* @author igor.ignatyev@oracle.com
*/
-
+import jdk.test.lib.Platform;
public class IntxTest {
private static final String FLAG_NAME = "OnStackReplacePercentage";
private static final String FLAG_DEBUG_NAME = "InlineFrequencyCount";
- private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE};
+ private static final long COMPILE_THRESHOLD = VmFlagTest.WHITE_BOX.getIntxVMFlag("CompileThreshold");
+ private static final Long[] TESTS = {0L, 100L, (long)(Integer.MAX_VALUE>>3)*100L};
public static void main(String[] args) throws Exception {
+ find_and_set_max_osrp();
VmFlagTest.runTest(FLAG_NAME, TESTS,
VmFlagTest.WHITE_BOX::setIntxVMFlag,
VmFlagTest.WHITE_BOX::getIntxVMFlag);
VmFlagTest.runTest(FLAG_DEBUG_NAME, VmFlagTest.WHITE_BOX::getIntxVMFlag);
}
+
+ static void find_and_set_max_osrp() {
+ long max_percentage_limit = (long)(Integer.MAX_VALUE>>3)*100L;
+ max_percentage_limit = COMPILE_THRESHOLD == 0 ? max_percentage_limit : max_percentage_limit/COMPILE_THRESHOLD;
+ if (Platform.is32bit() && max_percentage_limit > Integer.MAX_VALUE) {
+ max_percentage_limit = Integer.MAX_VALUE;
+ }
+ TESTS[2] = max_percentage_limit;
+ }
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -310,7 +310,8 @@
(long)frameStack[j].location);
/* query frame location */
if (!NSK_JVMTI_VERIFY(
- jvmti->GetFrameLocation(threadsDesc[i].thread, j, &qMethod, &qLocation))) {
+ jvmti->GetFrameLocation(threadsDesc[i].thread, j, &qMethod, &qLocation))
+ && (suspended == NSK_TRUE)) {
nsk_jvmti_setFailStatus();
continue;
}
@@ -318,8 +319,8 @@
NSK_DISPLAY2(" queried: method: %p, location: %ld\n",
(void*)qMethod, (long)qLocation);
- /* check frame equalaty */
- if (frameStack[j].method != qMethod) {
+ /* check frame equality */
+ if ((suspended == NSK_TRUE) && (frameStack[j].method != qMethod)) {
NSK_COMPLAIN6("Different method in stack frame #%d for %s thread #%d (%s):\n"
"# GetStackTrace(): %p\n"
"# GetFrameLocation(): %p\n",
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001.java Tue Dec 18 15:08:56 2018 -0500
@@ -268,6 +268,7 @@
class sp06t001ThreadRunningInterrupted extends sp06t001Thread {
private Object waitingMonitor = new Object();
+ volatile boolean interruptReady = false;
public sp06t001ThreadRunningInterrupted(String name, Log log) {
super(name, log);
@@ -275,8 +276,9 @@
public void testedMethod(boolean simulate, int i) {
if (!simulate) {
+ interruptReady = true;
synchronized (waitingMonitor) {
- // wait on watingMonitor until interrupted
+ // wait on waitingMonitor until interrupted
try {
waitingMonitor.wait();
} catch (InterruptedException ignore) {
@@ -303,6 +305,14 @@
public boolean checkReady() {
// interrupt thread on wait()
+ // delay until testMethod is ready
+ while (!interruptReady) {
+ try {
+ sleep(1000);
+ } catch (InterruptedException ie) {
+ // ignored
+ }
+ }
synchronized (waitingMonitor) {
interrupt();
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp Wed Dec 12 08:38:45 2018 -0500
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp Tue Dec 18 15:08:56 2018 -0500
@@ -333,7 +333,8 @@
(long)frameStack[j].location);
/* query frame location */
if (!NSK_JVMTI_VERIFY(
- jvmti->GetFrameLocation(threadsDesc[i].thread, j, &qMethod, &qLocation))) {
+ jvmti->GetFrameLocation(threadsDesc[i].thread, j, &qMethod, &qLocation))
+ && (suspended == NSK_TRUE)) {
nsk_jvmti_setFailStatus();
continue;
}
@@ -341,8 +342,8 @@
NSK_DISPLAY2(" queried: method: 0x%p, location: %ld\n",
(void*)qMethod, (long)qLocation);
- /* check frame equalaty */
- if (frameStack[j].method != qMethod) {
+ /* check frame equality */
+ if ((suspended == NSK_TRUE) && (frameStack[j].method != qMethod)) {
NSK_COMPLAIN6("Different method in stack frame #%d for %s thread #%d (%s):\n"
"# GetStackTrace(): 0x%p\n"
"# GetFrameLocation(): 0x%p\n",
@@ -350,7 +351,7 @@
(void*)frameStack[j].method, (void*)qMethod);
nsk_jvmti_setFailStatus();
}
- if (frameStack[j].location != qLocation) {
+ if ((suspended == NSK_TRUE) && (frameStack[j].location != qLocation)) {
NSK_COMPLAIN6("Different location in stack frame #%d for %s thread #%d (%s):\n"
"# GetStackTrace(): %ld\n"
"# GetFrameLocation(): %ld\n",
--- a/test/jaxp/TEST.ROOT Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jaxp/TEST.ROOT Tue Dec 18 15:08:56 2018 -0500
@@ -23,7 +23,7 @@
groups=TEST.groups
# Minimum jtreg version
-requiredVersion=4.2 b12
+requiredVersion=4.2 b13
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them
--- a/test/jdk/TEST.ROOT Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/TEST.ROOT Tue Dec 18 15:08:56 2018 -0500
@@ -49,7 +49,7 @@
release.implementor
# Minimum jtreg version
-requiredVersion=4.2 b12
+requiredVersion=4.2 b13
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/im/InputContext/ReconnectTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+ /*
+ * @test
+ * @key headful
+ * @bug 8213183
+ * @summary verifies InputMethod reconnection
+ * @run main/manual ReconnectTest
+ */
+import java.awt.*;
+import java.awt.event.*;
+
+public class ReconnectTest {
+
+ private static void init() throws Exception {
+ String[] instructions
+ = {
+ "This test supports Linux and Japanese/Korean/Chinese",
+ "input method(IM). Under other environment, press Pass.",
+ "Test steps:",
+ "1.Turn on IM and input some Asian characters to TestWindow.",
+ "2.kill IM frontend by OS, and restart it.",
+ " e.g. for ibus, $ ibus-daemon -r --xim &",
+ "3.Change focus to this Instructions window and back to TestWindow.",
+ "4.Confirm IM can be activated."
+ };
+
+ Sysout.createDialog();
+ Sysout.printInstructions(instructions);
+ }
+
+ static Frame mainFrame;
+
+ public static void initTestWindow() {
+ mainFrame = new Frame();
+ mainFrame.setTitle("TestWindow");
+ mainFrame.setLayout(new BorderLayout());
+ Panel p0 = new Panel();
+ p0.setLayout(new FlowLayout());
+ mainFrame.add(p0, BorderLayout.CENTER);
+ TextArea text = new TextArea();
+ p0.add(text);
+
+ mainFrame.pack();
+ mainFrame.setLocation(700, 10);
+ mainFrame.setVisible(true);
+ }
+
+ public static void dispose() {
+ Sysout.dispose();
+ mainFrame.dispose();
+ }
+
+ /**
+ * ***************************************************
+ * Standard Test Machinery Section DO NOT modify anything in this section --
+ * it's a standard chunk of code which has all of the synchronisation
+ * necessary for the test harness. By keeping it the same in all tests, it
+ * is easier to read and understand someone else's test, as well as insuring
+ * that all tests behave correctly with the test harness. There is a section
+ * following this for test-defined classes
+ * ****************************************************
+ */
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+ private static Thread mainThread = null;
+ final private static int sleepTime = 300000;
+
+ public static void main(String args[]) throws Exception {
+ mainThread = Thread.currentThread();
+ try {
+ init();
+ initTestWindow();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ try {
+ mainThread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ dispose();
+ if (testGeneratedInterrupt && !theTestPassed) {
+ throw new Exception(failureMessage);
+ }
+ }
+ if (!testGeneratedInterrupt) {
+ dispose();
+ throw new RuntimeException("Timed out after " + sleepTime / 1000
+ + " seconds");
+ }
+ }
+
+ public static synchronized void pass() {
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }
+
+ public static synchronized void fail(String whyFailed) {
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }
+}
+
+// *********** End Standard Test Machinery Section **********
+/**
+ * **************************************************
+ * Standard Test Machinery DO NOT modify anything below -- it's a standard chunk
+ * of code whose purpose is to make user interaction uniform, and thereby make
+ * it simpler to read and understand someone else's test.
+ * **************************************************
+ */
+/**
+ * This is part of the standard test machinery. It creates a dialog (with the
+ * instructions), and is the interface for sending text messages to the user. To
+ * print the instructions, send an array of strings to Sysout.createDialog
+ * WithInstructions method. Put one line of instructions per array entry. To
+ * display a message for the tester to see, simply call Sysout.println with the
+ * string to be displayed. This mimics System.out.println but works within the
+ * test harness as well as standalone.
+ */
+class Sysout {
+
+ private static TestDialog dialog;
+ private static Frame frame;
+
+ public static void createDialog() {
+ frame = new Frame();
+ dialog = new TestDialog(frame, "Instructions");
+ String[] defInstr = {"Instructions will appear here. ", ""};
+ dialog.printInstructions(defInstr);
+ dialog.setVisible(true);
+ println("Any messages for the tester will display here.");
+ }
+
+ public static void printInstructions(String[] instructions) {
+ dialog.printInstructions(instructions);
+ }
+
+ public static void println(String messageIn) {
+ dialog.displayMessage(messageIn);
+ }
+
+ public static void dispose() {
+ dialog.dispose();
+ frame.dispose();
+ }
+}
+
+/**
+ * This is part of the standard test machinery. It provides a place for the test
+ * instructions to be displayed, and a place for interactive messages to the
+ * user to be displayed. To have the test instructions displayed, see Sysout. To
+ * have a message to the user be displayed, see Sysout. Do not call anything in
+ * this dialog directly.
+ */
+class TestDialog extends Dialog implements ActionListener {
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+ Panel buttonP;
+ Button failB;
+ Button passB;
+
+ // DO NOT call this directly, go through Sysout
+ public TestDialog(Frame frame, String name) {
+ super(frame, name);
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
+ add("North", instructionsText);
+
+ messageText = new TextArea("", 5, maxStringLength, scrollBoth);
+ add("Center", messageText);
+
+ buttonP = new Panel();
+ failB = new Button("Fail");
+ failB.setActionCommand("fail");
+ failB.addActionListener(this);
+ passB = new Button("Pass");
+ buttonP.add(passB);
+ buttonP.add(failB);
+ passB.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ ReconnectTest.pass();
+ }
+ });
+
+ add("South", buttonP);
+ pack();
+ setVisible(true);
+ }
+
+ // DO NOT call this directly, go through Sysout
+ public void printInstructions(String[] instructions) {
+ instructionsText.setText("");
+ String printStr, remainingStr;
+ for (int i = 0; i < instructions.length; i++) {
+ remainingStr = instructions[i];
+ while (remainingStr.length() > 0) {
+ if (remainingStr.length() >= maxStringLength) {
+ int posOfSpace = remainingStr.
+ lastIndexOf(' ', maxStringLength - 1);
+
+ if (posOfSpace <= 0) {
+ posOfSpace = maxStringLength - 1;
+ }
+
+ printStr = remainingStr.substring(0, posOfSpace + 1);
+ remainingStr = remainingStr.substring(posOfSpace + 1);
+ } else {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+ instructionsText.append(printStr + "\n");
+ }
+ }
+ }
+
+ public void displayMessage(String messageIn) {
+ messageText.append(messageIn + "\n");
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ if (e.getActionCommand() == "fail") {
+ ReconnectTest.fail("User Clicked Fail");
+ }
+ }
+}
--- a/test/jdk/java/lang/constant/ClassDescTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/java/lang/constant/ClassDescTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -244,6 +244,29 @@
testBadNestedClasses(ClassDesc.ofDescriptor(p.descriptor), "any");
testBadNestedClasses(ClassDesc.ofDescriptor(p.descriptor), "any", "other");
}
+
+ ClassDesc stringDesc = ClassDesc.ofDescriptor("Ljava/lang/String;");
+ ClassDesc stringArrDesc = stringDesc.arrayType(255);
+ try {
+ ClassDesc arrGreaterThan255 = stringArrDesc.arrayType();
+ fail("can't create an array type descriptor with more than 255 dimensions");
+ } catch (IllegalStateException e) {
+ // good
+ }
+ String descWith255ArrayDims = new String(new char[255]).replace('\0', '[');
+ try {
+ ClassDesc arrGreaterThan255 = ClassDesc.ofDescriptor(descWith255ArrayDims + "[Ljava/lang/String;");
+ fail("can't create an array type descriptor with more than 255 dimensions");
+ } catch (IllegalArgumentException e) {
+ // good
+ }
+ try {
+ ClassDesc arrWith255Dims = ClassDesc.ofDescriptor(descWith255ArrayDims + "Ljava/lang/String;");
+ arrWith255Dims.arrayType(1);
+ fail("can't create an array type descriptor with more than 255 dimensions");
+ } catch (IllegalArgumentException e) {
+ // good
+ }
}
private void testBadNestedClasses(ClassDesc cr, String firstNestedName, String... moreNestedNames) {
--- a/test/jdk/java/lang/module/ClassFileVersionsTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/java/lang/module/ClassFileVersionsTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -56,6 +56,7 @@
{ 54, 0, Set.of() }, // JDK 10
{ 55, 0, Set.of() }, // JDK 11
{ 56, 0, Set.of() }, // JDK 12
+ { 57, 0, Set.of() }, // JDK 13
};
}
@@ -79,7 +80,11 @@
{ 56, 0, Set.of(TRANSITIVE) },
{ 56, 0, Set.of(STATIC, TRANSITIVE) },
- { 57, 0, Set.of()}, // JDK 13
+ { 57, 0, Set.of(STATIC) }, // JDK 13
+ { 57, 0, Set.of(TRANSITIVE) },
+ { 57, 0, Set.of(STATIC, TRANSITIVE) },
+
+ { 58, 0, Set.of()}, // JDK 14
};
}
--- a/test/jdk/java/net/URL/RacyHandler.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/java/net/URL/RacyHandler.java Tue Dec 18 15:08:56 2018 -0500
@@ -32,6 +32,7 @@
* @test
* @bug 8213942
* @summary URLStreamHandler initialization race
+ * @modules java.base/java.net:open
* @run main/othervm RacyHandler
* @run main/othervm RacyHandler
* @run main/othervm RacyHandler
@@ -110,4 +111,4 @@
return null;
}
}
-}
\ No newline at end of file
+}
--- a/test/jdk/java/nio/file/DirectoryStream/Basic.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/java/nio/file/DirectoryStream/Basic.java Tue Dec 18 15:08:56 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -73,14 +73,18 @@
private PathMatcher matcher =
dir.getFileSystem().getPathMatcher("glob:f*");
public boolean accept(Path file) {
- return matcher.matches(file);
+ return matcher.matches(file.getFileName());
}
};
+
+ found = false;
try (DirectoryStream<Path> ds = newDirectoryStream(dir, filter)) {
for (Path entry: ds) {
- if (!entry.getFileName().equals(foo))
- throw new RuntimeException("entry not expected");
+ if (entry.getFileName().equals(foo))
+ found = true;
}
+ if (!found)
+ throw new RuntimeException(String.format("Error: entry: %s was not found", foo));
}
// check filtering: z* should not match any files
@@ -88,7 +92,7 @@
private PathMatcher matcher =
dir.getFileSystem().getPathMatcher("glob:z*");
public boolean accept(Path file) {
- return matcher.matches(file);
+ return matcher.matches(file.getFileName());
}
};
try (DirectoryStream<Path> ds = newDirectoryStream(dir, filter)) {
--- a/test/jdk/java/util/Locale/LocaleProvidersRun.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/java/util/Locale/LocaleProvidersRun.java Tue Dec 18 15:08:56 2018 -0500
@@ -156,6 +156,7 @@
launcher.addToolArg("-cp")
.addToolArg(Utils.TEST_CLASS_PATH)
.addToolArg("-Djava.locale.providers=" + prefList)
+ .addToolArg("--add-exports=java.base/sun.util.locale.provider=ALL-UNNAMED")
.addToolArg("LocaleProviders")
.addToolArg(methodName)
.addToolArg(param1)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/logging/DefaultConfigTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8211093
+ * @summary Check default configuration
+ * @build DefaultConfigTest
+ * @run main/othervm DefaultConfigTest
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+
+public class DefaultConfigTest {
+ static final java.io.PrintStream out = System.out;
+ public static void main(String arg[]) {
+ LogManager manager = LogManager.getLogManager();
+
+ if (!Set.of(Collections.list(manager.getLoggerNames()).toArray())
+ .equals(Set.of("", "global"))) {
+ throw new RuntimeException("Unexpected logger name in: "
+ + Collections.list(manager.getLoggerNames()));
+ }
+ Logger global = Logger.getGlobal();
+ Logger root = Logger.getLogger("");
+ Logger foo = Logger.getLogger("com.xyz.foo");
+ if (!Set.of(Collections.list(manager.getLoggerNames()).toArray())
+ .equals(Set.of("", "global", "com.xyz.foo"))) {
+ throw new RuntimeException("Unexpected logger name in: "
+ + Collections.list(manager.getLoggerNames()));
+ }
+ for (Logger l : List.of(global, foo)) {
+ if (l.getLevel() != null) {
+ throw new RuntimeException("Unexpected level "
+ + l.getLevel() + " for " + l.getName());
+ }
+ if (l.getHandlers().length != 0) {
+ throw new RuntimeException("Unexpected handlers "
+ + List.of(l.getHandlers()) + " for " + l.getName());
+ }
+ for (Level level : List.of(
+ Level.ALL, Level.FINEST, Level.FINER, Level.FINE, Level.CONFIG)) {
+ if (l.isLoggable(level)) {
+ throw new RuntimeException("Level "
+ + level + " should not be loggable for " + l.getName());
+ }
+ }
+ for (Level level : List.of(
+ Level.INFO, Level.WARNING, Level.SEVERE)) {
+ if (!l.isLoggable(level)) {
+ throw new RuntimeException("Level "
+ + level + " should be loggable for " + l.getName());
+ }
+ }
+ }
+ if (root.getLevel() != Level.INFO) {
+ throw new RuntimeException("Unexpected level "
+ + root.getLevel() + " for root logger");
+ }
+ if (root.getHandlers().length != 1) {
+ throw new RuntimeException("Unexpected handlers "
+ + List.of(root.getHandlers()) + " for root logger");
+ }
+ if (root.getHandlers()[0].getClass() != ConsoleHandler.class) {
+ throw new RuntimeException("Unexpected handlers "
+ + List.of(root.getHandlers()) + " for root logger");
+ }
+ if (root.getHandlers()[0].getLevel() != Level.INFO) {
+ throw new RuntimeException("Unexpected level "
+ + root.getHandlers()[0].getLevel() + " for handler "
+ + root.getHandlers()[0]);
+ }
+ out.println(List.of(root, global, foo).stream()
+ .map(Logger::getName)
+ .map(s -> String.format("\"%s\"", s))
+ .collect(Collectors.joining(", ",
+ "Default configuration checked for ",
+ ".")));
+ }
+}
--- a/test/jdk/jdk/internal/reflect/Reflection/Filtering.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/jdk/internal/reflect/Reflection/Filtering.java Tue Dec 18 15:08:56 2018 -0500
@@ -61,6 +61,8 @@
{ Lookup.class, "allowedModes" },
{ Method.class, "clazz" },
{ Method.class, "modifiers" },
+ { Module.class, "name" },
+ { Module.class, "loader" },
{ System.class, "security" },
};
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestFormatMissingValue.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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 jdk.jfr.api.metadata.annotations;
+
+import jdk.jfr.DataAmount;
+import jdk.jfr.Event;
+import jdk.jfr.Frequency;
+import jdk.jfr.Recording;
+import jdk.jfr.StackTrace;
+import jdk.jfr.consumer.RecordedEvent;
+import jdk.test.lib.Asserts;
+import jdk.test.lib.jfr.Events;
+
+/**
+ * @test
+ * @key jfr
+ * @summary Check that event values are properly formatted and sanity check
+ * that extreme values don't throws exceptions
+ * @requires vm.hasJFR
+ * @library /test/lib
+ * @run main/othervm jdk.jfr.api.metadata.annotations.TestFormatMissingValue
+ */
+public class TestFormatMissingValue {
+
+ @StackTrace(false)
+ static class MultiContentTypeEvent extends Event {
+ @DataAmount(DataAmount.BYTES)
+ @Frequency
+ long a = Long.MIN_VALUE;
+
+ @DataAmount(DataAmount.BYTES)
+ @Frequency
+ long b = Long.MAX_VALUE;
+
+ @DataAmount(DataAmount.BYTES)
+ @Frequency
+ int c = Integer.MIN_VALUE;
+
+ @DataAmount(DataAmount.BYTES)
+ @Frequency
+ int d = Integer.MAX_VALUE;
+
+ @DataAmount(DataAmount.BYTES)
+ @Frequency
+ double e = Double.NEGATIVE_INFINITY;
+
+ @DataAmount(DataAmount.BYTES)
+ @Frequency
+ double f = Double.POSITIVE_INFINITY;
+
+ @DataAmount(DataAmount.BYTES)
+ @Frequency
+ double g = Double.NaN;
+
+ @DataAmount(DataAmount.BYTES)
+ @Frequency
+ float h = Float.NEGATIVE_INFINITY;
+
+ @DataAmount(DataAmount.BYTES)
+ @Frequency
+ float i = Float.POSITIVE_INFINITY;
+
+ @DataAmount(DataAmount.BYTES)
+ @Frequency
+ float j = Float.NaN;
+ }
+
+ public static void main(String[] args) throws Exception {
+ try (Recording r = new Recording()) {
+ r.start();
+ MultiContentTypeEvent m = new MultiContentTypeEvent();
+ m.commit();
+ r.stop();
+ for (RecordedEvent e : Events.fromRecording(r)) {
+ String t = e.toString();
+ assertContains(t, "a = N/A");
+ assertContains(t, "c = N/A");
+ assertContains(t, "e = N/A");
+ assertContains(t, "g = N/A");
+ assertContains(t, "h = N/A");
+ assertContains(t, "j = N/A");
+
+ assertNotContains(t, "b = N/A");
+ assertNotContains(t, "d = N/A");
+ assertNotContains(t, "f = N/A");
+ assertNotContains(t, "i = N/A");
+ }
+ }
+ }
+
+ private static void assertContains(String t, String text) {
+ if (!t.contains(text)) {
+ Asserts.fail("Expected '" + t + "' to contain text '" + text + "'");
+ }
+ }
+
+ private static void assertNotContains(String t, String text) {
+ if (t.contains(text)) {
+ Asserts.fail("Found unexpected value '" + text + "' in text '" + t + "'");
+ }
+ }
+}
--- a/test/jdk/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,6 +25,13 @@
package jdk.jfr.event.runtime;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import jdk.jfr.Recording;
import jdk.jfr.consumer.RecordedEvent;
import jdk.test.lib.Asserts;
@@ -32,17 +39,6 @@
import jdk.test.lib.jfr.EventNames;
import jdk.test.lib.jfr.Events;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.time.Duration;
-import java.time.Instant;
-import java.util.List;
-import java.util.Map;
-
-import static java.util.stream.Collectors.averagingLong;
-import static java.util.stream.Collectors.groupingBy;
-
/**
* @test
* @key jfr
@@ -56,21 +52,17 @@
private static final long packetSendCount = 100;
public static void main(String[] args) throws Throwable {
- testSimple();
- }
- static void testSimple() throws Throwable {
-
- Instant start = Instant.now();
Recording recording = new Recording();
- recording.enable(EventNames.NetworkUtilization);
+ recording.enable(EventNames.NetworkUtilization).with("period", "endChunk");
recording.start();
DatagramSocket socket = new DatagramSocket();
String msg = "hello!";
byte[] buf = msg.getBytes();
-
- // Send a few packets both to the loopback address as well to an external
+ forceEndChunk();
+ // Send a few packets both to the loopback address as well to an
+ // external
DatagramPacket packet = new DatagramPacket(buf, buf.length, InetAddress.getLoopbackAddress(), 12345);
for (int i = 0; i < packetSendCount; ++i) {
socket.send(packet);
@@ -79,32 +71,38 @@
for (int i = 0; i < packetSendCount; ++i) {
socket.send(packet);
}
-
- // Now there should have been traffic on at least two different interfaces
+ forceEndChunk();
+ socket.close();
+ // Now there should have been traffic on at least two different
+ // interfaces
recording.stop();
- Duration runtime = Duration.between(start, Instant.now());
- List<RecordedEvent> events = Events.fromRecording(recording);
- // Calculate the average write rate for each interface
- Map<String, Double> writeRates = events.stream()
- .collect(groupingBy(e -> Events.assertField(e, "networkInterface").getValue(),
- averagingLong(e -> Events.assertField(e, "writeRate").getValue())));
-
- // Our test packets should have generated at least this much traffic per second
- long expectedTraffic = (buf.length * packetSendCount) / Math.max(1, runtime.toSeconds());
-
- // Count the number of interfaces that have seen at least our test traffic
- long interfacesWithTraffic = writeRates.values().stream()
- .filter(d -> d >= expectedTraffic)
- .count();
+ Set<String> networkInterfaces = new HashSet<>();
+ List<RecordedEvent> events = Events.fromRecording(recording);
+ Events.hasEvents(events);
+ for (RecordedEvent event : events) {
+ System.out.println(event);
+ Events.assertField(event, "writeRate").atLeast(0L).atMost(1000L * Integer.MAX_VALUE);
+ Events.assertField(event, "readRate").atLeast(0L).atMost(1000L * Integer.MAX_VALUE);
+ Events.assertField(event, "networkInterface").notNull();
+ if (event.getLong("writeRate") > 0) {
+ networkInterfaces.add(event.getString("networkInterface"));
+ }
+ }
if (Platform.isWindows() || Platform.isSolaris()) {
- // Windows and Solaris do not track statistics for the loopback interface
- Asserts.assertGreaterThanOrEqual(writeRates.size(), 1);
- Asserts.assertGreaterThanOrEqual(interfacesWithTraffic, Long.valueOf(1));
+ // Windows and Solaris do not track statistics for the loopback
+ // interface
+ Asserts.assertGreaterThanOrEqual(networkInterfaces.size(), 1);
} else {
- Asserts.assertGreaterThanOrEqual(writeRates.size(), 2);
- Asserts.assertGreaterThanOrEqual(interfacesWithTraffic, Long.valueOf(2));
+ Asserts.assertGreaterThanOrEqual(networkInterfaces.size(), 2);
}
}
+
+ private static void forceEndChunk() {
+ try(Recording r = new Recording()) {
+ r.start();
+ r.stop();
+ }
+ }
}
--- a/test/jdk/jdk/jfr/event/runtime/TestThreadParkEvent.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/jdk/jfr/event/runtime/TestThreadParkEvent.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,22 +25,25 @@
package jdk.jfr.event.runtime;
-import static jdk.test.lib.Asserts.assertFalse;
import static jdk.test.lib.Asserts.assertTrue;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.time.Duration;
+import java.time.Instant;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.LockSupport;
+import java.util.function.Consumer;
import jdk.jfr.Recording;
import jdk.jfr.consumer.RecordedEvent;
+import jdk.test.lib.Asserts;
import jdk.test.lib.jfr.EventNames;
import jdk.test.lib.jfr.Events;
import jdk.test.lib.management.ThreadMXBeanTool;
import jdk.test.lib.thread.TestThread;
-
/**
* @test
* @key jfr
@@ -58,12 +61,39 @@
}
public static void main(String[] args) throws Throwable {
+ testParkNoTimeout();
+ testParkTimeout();
+ testParkUntil();
+ }
+
+ private static void testParkNoTimeout() throws Exception {
+ RecordedEvent event = testPark(x -> LockSupport.park(x), Thread.State.WAITING);
+ Events.assertMissingValue(event, "timeout");
+ Events.assertMissingValue(event, "until");
+ }
+
+ private static void testParkTimeout() throws Exception {
+ Duration expected = Duration.ofNanos(1_234_567_890_123L);
+ RecordedEvent event = testPark(x -> LockSupport.parkNanos(x, expected.toNanos()), Thread.State.TIMED_WAITING);
+ Events.assertDuration(event, "timeout", expected);
+ Events.assertMissingValue(event, "until");
+ }
+
+ private static void testParkUntil() throws Exception {
+ long epochMillis = Instant.now().plusSeconds(1000000).toEpochMilli();
+ RecordedEvent event = testPark(x -> LockSupport.parkUntil(x, epochMillis), Thread.State.TIMED_WAITING);
+ Events.assertMissingValue(event, "timeout");
+ Events.assertInstant(event, "until", Instant.ofEpochMilli(epochMillis));
+ }
+
+ static RecordedEvent testPark(Consumer<Blocker> parkOperation, Thread.State threadState) throws Exception {
+
final CountDownLatch stop = new CountDownLatch(1);
final Blocker blocker = new Blocker();
TestThread parkThread = new TestThread(new Runnable() {
public void run() {
while (stop.getCount() > 0) {
- LockSupport.park(blocker);
+ parkOperation.accept(blocker);
}
}
});
@@ -73,7 +103,7 @@
try {
recording.start();
parkThread.start();
- ThreadMXBeanTool.waitUntilBlockingOnObject(parkThread, Thread.State.WAITING, blocker);
+ ThreadMXBeanTool.waitUntilBlockingOnObject(parkThread, threadState, blocker);
// sleep so we know the event is recorded
Thread.sleep(2 * THRESHOLD_MILLIS);
} finally {
@@ -82,22 +112,21 @@
parkThread.join();
recording.stop();
}
-
List<RecordedEvent> events = Events.fromRecording(recording);
Events.hasEvents(events);
- boolean isAnyFound = false;
+ RecordedEvent foundEvent = null;
for (RecordedEvent event : events) {
System.out.println("Event:" + event);
String klassName = Events.assertField(event, "parkedClass.name").notNull().getValue();
if (klassName.equals(blocker.getClass().getName().replace('.', '/'))) {
- assertFalse(isAnyFound, "Found more than 1 event");
- isAnyFound = true;
- Events.assertField(event, "timeout").equal(0L);
+ Asserts.assertNull(foundEvent , "Found more than 1 event");
Events.assertField(event, "address").notEqual(0L);
Events.assertEventThread(event, parkThread);
+ foundEvent = event;
}
}
- assertTrue(isAnyFound, "Correct event not found");
+ Asserts.assertNotNull(foundEvent, "Correct event not found");
+ return foundEvent;
}
}
--- a/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java Tue Dec 18 15:08:56 2018 -0500
@@ -38,6 +38,7 @@
* @bug 8148188
* @summary Enhance the security libraries to record events of interest
* @key jfr
+ * @requires vm.hasJFR
* @library /test/lib
* @run main/othervm jdk.jfr.event.security.TestSecurityPropertyModificationEvent
*/
--- a/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java Tue Dec 18 15:08:56 2018 -0500
@@ -36,6 +36,7 @@
* @bug 8148188
* @summary Enhance the security libraries to record events of interest
* @key jfr
+ * @requires vm.hasJFR
* @library /test/lib
* @run main/othervm jdk.jfr.event.security.TestTLSHandshakeEvent
*/
--- a/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java Tue Dec 18 15:08:56 2018 -0500
@@ -38,6 +38,7 @@
* @bug 8148188
* @summary Enhance the security libraries to record events of interest
* @key jfr
+ * @requires vm.hasJFR
* @library /test/lib
* @run main/othervm jdk.jfr.event.security.TestX509CertificateEvent
*/
--- a/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java Tue Dec 18 15:08:56 2018 -0500
@@ -40,6 +40,7 @@
* @bug 8148188
* @summary Enhance the security libraries to record events of interest
* @key jfr
+ * @requires vm.hasJFR
* @library /test/lib
* @modules jdk.jfr/jdk.jfr.events
* @run main/othervm jdk.jfr.event.security.TestX509ValidationEvent
--- a/test/jdk/jdk/jfr/jmx/security/TestEnoughPermission.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/jdk/jfr/jmx/security/TestEnoughPermission.java Tue Dec 18 15:08:56 2018 -0500
@@ -85,7 +85,7 @@
System.out.println("E");
bean.stopRecording(recId);
- final Path path = Paths.get(".", String.format("rec%d.jfr", recId));
+ final Path path = Paths.get(".", "rec" + recId + ".jfr");
bean.copyTo(recId, path.toString());
//EventSet events = EventSet.fromFile(path);
return recId;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/mscapi/KeyAlgorithms.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8213009
+ * @summary Make sure SunMSCAPI keys have correct algorithm names
+ * @requires os.family == "windows"
+ * @library /test/lib
+ * @modules jdk.crypto.mscapi
+ */
+
+import java.security.*;
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+
+public class KeyAlgorithms {
+
+ private static final String ALIAS = "8213009";
+ private static final String ALG = "RSA";
+
+ public static void main(String[] arg) throws Exception {
+
+ SecurityTools.keytool("-genkeypair",
+ "-storetype", "Windows-My",
+ "-keyalg", ALG,
+ "-alias", ALIAS,
+ "-dname", "cn=" + ALIAS,
+ "-noprompt").shouldHaveExitValue(0);
+
+ try {
+ test(loadKeysFromKeyStore());
+ } finally {
+ KeyStore ks = KeyStore.getInstance("Windows-MY");
+ ks.load(null, null);
+ ks.deleteEntry(ALIAS);
+ ks.store(null, null);
+ }
+
+ test(generateKeys());
+ }
+
+ static KeyPair loadKeysFromKeyStore() throws Exception {
+ KeyStore ks = KeyStore.getInstance("Windows-MY");
+ ks.load(null, null);
+ return new KeyPair(ks.getCertificate(ALIAS).getPublicKey(),
+ (PrivateKey) ks.getKey(ALIAS, null));
+ }
+
+ static KeyPair generateKeys() throws Exception {
+ KeyPairGenerator kpg = KeyPairGenerator.getInstance(ALG, "SunMSCAPI");
+ return kpg.generateKeyPair();
+ }
+
+ static void test(KeyPair kp) {
+ Asserts.assertEQ(kp.getPrivate().getAlgorithm(), ALG);
+ Asserts.assertEQ(kp.getPublic().getAlgorithm(), ALG);
+ }
+}
--- a/test/jdk/sun/security/mscapi/nonUniqueAliases/NonUniqueAliases.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/sun/security/mscapi/nonUniqueAliases/NonUniqueAliases.java Tue Dec 18 15:08:56 2018 -0500
@@ -23,11 +23,11 @@
/*
* @test
- * @ignore Uses certutil.exe that isn't guaranteed to be installed
* @bug 6483657 8154113
* @requires os.family == "windows"
* @library /test/lib
* @summary Test "keytool -list" displays correctly same named certificates
+ * @ignore Uses certutil.exe that isn't guaranteed to be installed
*/
import jdk.test.lib.process.ProcessTools;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/pkcs12/ParamsPreferences.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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 jdk.test.lib.SecurityTools;
+import sun.security.util.ObjectIdentifier;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+
+import static jdk.test.lib.security.DerUtils.*;
+import static sun.security.pkcs.ContentInfo.DATA_OID;
+import static sun.security.pkcs.ContentInfo.ENCRYPTED_DATA_OID;
+import static sun.security.x509.AlgorithmId.*;
+
+/*
+ * @test
+ * @bug 8076190
+ * @library /test/lib
+ * @modules java.base/sun.security.pkcs
+ * java.base/sun.security.x509
+ * java.base/sun.security.util
+ * @summary Checks the preferences order of pkcs12 params
+ */
+public class ParamsPreferences {
+
+ public static final void main(String[] args) throws Exception {
+ int c = 0;
+
+ // with storepass
+ test(c++, "-", "-",
+ pbeWithSHA1AndRC2_40_oid, 50000,
+ pbeWithSHA1AndDESede_oid, 50000,
+ SHA_oid, 100000);
+
+ // password-less with system property
+ test(c++, "keystore.pkcs12.certProtectionAlgorithm", "NONE",
+ "keystore.pkcs12.macAlgorithm", "NONE",
+ "-", "-",
+ null, 0,
+ pbeWithSHA1AndDESede_oid, 50000,
+ null, 0);
+
+ // password-less with security property
+ test(c++, "-",
+ "keystore.pkcs12.certProtectionAlgorithm", "NONE",
+ "keystore.pkcs12.macAlgorithm", "NONE",
+ "-",
+ null, 0,
+ pbeWithSHA1AndDESede_oid, 50000,
+ null, 0);
+
+ // back to with storepass by overriding security property with system property
+ test(c++, "keystore.pkcs12.certProtectionAlgorithm", "PBEWithSHA1AndDESede",
+ "keystore.pkcs12.macAlgorithm", "HmacPBESHA256",
+ "-",
+ "keystore.pkcs12.certProtectionAlgorithm", "NONE",
+ "keystore.pkcs12.macAlgorithm", "NONE",
+ "-",
+ pbeWithSHA1AndDESede_oid, 50000,
+ pbeWithSHA1AndDESede_oid, 50000,
+ SHA256_oid, 100000);
+
+ // back to with storepass by using "" to force hardcoded default
+ test(c++, "keystore.pkcs12.certProtectionAlgorithm", "",
+ "keystore.pkcs12.keyProtectionAlgorithm", "",
+ "keystore.pkcs12.macAlgorithm", "",
+ "-",
+ "keystore.pkcs12.certProtectionAlgorithm", "NONE",
+ "keystore.pkcs12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_40",
+ "keystore.pkcs12.macAlgorithm", "NONE",
+ "-",
+ pbeWithSHA1AndRC2_40_oid, 50000,
+ pbeWithSHA1AndDESede_oid, 50000,
+ SHA_oid, 100000);
+
+ // change everything with system property
+ test(c++, "keystore.pkcs12.certProtectionAlgorithm", "PBEWithSHA1AndDESede",
+ "keystore.pkcs12.certPbeIterationCount", 3000,
+ "keystore.pkcs12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_40",
+ "keystore.pkcs12.keyPbeIterationCount", 4000,
+ "keystore.pkcs12.macAlgorithm", "HmacPBESHA256",
+ "keystore.pkcs12.macIterationCount", 2000,
+ "-", "-",
+ pbeWithSHA1AndDESede_oid, 3000,
+ pbeWithSHA1AndRC2_40_oid, 4000,
+ SHA256_oid, 2000);
+
+ // change everything with security property
+ test(c++, "-",
+ "keystore.pkcs12.certProtectionAlgorithm", "PBEWithSHA1AndDESede",
+ "keystore.pkcs12.certPbeIterationCount", 3000,
+ "keystore.pkcs12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_40",
+ "keystore.pkcs12.keyPbeIterationCount", 4000,
+ "keystore.pkcs12.macAlgorithm", "HmacPBESHA256",
+ "keystore.pkcs12.macIterationCount", 2000,
+ "-",
+ pbeWithSHA1AndDESede_oid, 3000,
+ pbeWithSHA1AndRC2_40_oid, 4000,
+ SHA256_oid, 2000);
+
+ // override security property with system property
+ test(c++, "keystore.pkcs12.certProtectionAlgorithm", "PBEWithSHA1AndDESede",
+ "keystore.pkcs12.certPbeIterationCount", 13000,
+ "keystore.pkcs12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_40",
+ "keystore.pkcs12.keyPbeIterationCount", 14000,
+ "keystore.pkcs12.macAlgorithm", "HmacPBESHA256",
+ "keystore.pkcs12.macIterationCount", 12000,
+ "-",
+ "keystore.pkcs12.certProtectionAlgorithm", "PBEWithSHA1AndRC2_40",
+ "keystore.pkcs12.certPbeIterationCount", 3000,
+ "keystore.pkcs12.keyProtectionAlgorithm", "PBEWithSHA1AndDESede",
+ "keystore.pkcs12.keyPbeIterationCount", 4000,
+ "keystore.pkcs12.macAlgorithm", "HmacPBESHA1",
+ "keystore.pkcs12.macIterationCount", 2000,
+ "-",
+ pbeWithSHA1AndDESede_oid, 13000,
+ pbeWithSHA1AndRC2_40_oid, 14000,
+ SHA256_oid, 12000);
+
+ // check keyProtectionAlgorithm old behavior. Preferences of
+ // 4 different settings.
+
+ test(c++, "-",
+ "keystore.PKCS12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_128",
+ "-",
+ pbeWithSHA1AndRC2_40_oid, 50000,
+ pbeWithSHA1AndRC2_128_oid, 50000,
+ SHA_oid, 100000);
+ test(c++, "-",
+ "keystore.PKCS12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_128",
+ "keystore.pkcs12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_40",
+ "-",
+ pbeWithSHA1AndRC2_40_oid, 50000,
+ pbeWithSHA1AndRC2_40_oid, 50000,
+ SHA_oid, 100000);
+ test(c++,
+ "keystore.PKCS12.keyProtectionAlgorithm", "PBEWithSHA1AndRC4_128",
+ "-",
+ "keystore.PKCS12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_128",
+ "keystore.pkcs12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_40",
+ "-",
+ pbeWithSHA1AndRC2_40_oid, 50000,
+ pbeWithSHA1AndRC4_128_oid, 50000,
+ SHA_oid, 100000);
+ test(c++,
+ "keystore.PKCS12.keyProtectionAlgorithm", "PBEWithSHA1AndRC4_128",
+ "keystore.pkcs12.keyProtectionAlgorithm", "PBEWithSHA1AndRC4_40",
+ "-",
+ "keystore.PKCS12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_128",
+ "keystore.pkcs12.keyProtectionAlgorithm", "PBEWithSHA1AndRC2_40",
+ "-",
+ pbeWithSHA1AndRC2_40_oid, 50000,
+ pbeWithSHA1AndRC4_40_oid, 50000,
+ SHA_oid, 100000);
+ }
+
+ /**
+ * Run once.
+ *
+ * @param args an array containing system properties and values, "-",
+ * security properties and values, "-", expected certPbeAlg,
+ * certPbeIC, keyPbeAlg, keyPbeIc, macAlg, macIC.
+ */
+ static void test(int n, Object... args) throws Exception {
+ boolean isSysProp = true;
+ String cmd = "-keystore ks" + n + " -genkeypair -keyalg EC "
+ + "-alias a -dname CN=A -storepass changeit "
+ + "-J-Djava.security.properties=" + n + ".conf";
+ List<String> jsConf = new ArrayList<>();
+ for (int i = 0; i < args.length; i++) {
+ if (isSysProp) {
+ if (args[i].equals("-")) {
+ isSysProp = false;
+ } else {
+ cmd += " -J-D" + args[i] + "=" + args[++i];
+ }
+ } else {
+ if (args[i] == "-") {
+ Files.write(Path.of(n + ".conf"), jsConf);
+ System.out.println("--------- test starts ----------");
+ System.out.println(jsConf);
+ SecurityTools.keytool(cmd).shouldHaveExitValue(0);
+
+ byte[] data = Files.readAllBytes(Path.of("ks" + n));
+
+ // cert pbe alg + ic
+ if (args[i+1] == null) {
+ checkAlg(data, "110c10", DATA_OID);
+ } else {
+ checkAlg(data, "110c10", ENCRYPTED_DATA_OID);
+ checkAlg(data, "110c110110", (ObjectIdentifier)args[i+1]);
+ checkInt(data, "110c1101111", (int)args[i+2]);
+ }
+
+ // key pbe alg + ic
+ checkAlg(data, "110c010c01000", (ObjectIdentifier)args[i+3]);
+ checkInt(data, "110c010c010011", (int)args[i+4]);
+
+ // mac alg + ic
+ if (args[i+5] == null) {
+ shouldNotExist(data, "2");
+ } else {
+ checkAlg(data, "2000", (ObjectIdentifier)args[i+5]);
+ checkInt(data, "22", (int)args[i+6]);
+ }
+ } else {
+ jsConf.add(args[i] + "=" + args[++i]);
+ }
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/pkcs12/ParamsTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,434 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8076190
+ * @library /test/lib
+ * @modules java.base/sun.security.pkcs
+ * java.base/sun.security.x509
+ * java.base/sun.security.util
+ * @summary Customizing the generation of a PKCS12 keystore
+ */
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.KeyStore;
+import java.util.Base64;
+import java.util.Objects;
+
+import static jdk.test.lib.security.DerUtils.*;
+import static sun.security.x509.AlgorithmId.*;
+import static sun.security.pkcs.ContentInfo.*;
+
+public class ParamsTest {
+
+ public static void main(String[] args) throws Throwable {
+
+ // De-BASE64 textual files in ./params to `pwd`
+ Files.newDirectoryStream(Path.of(System.getProperty("test.src"), "params"))
+ .forEach(p -> {
+ try (InputStream is = Files.newInputStream(p);
+ OutputStream os = Files.newOutputStream(p.getFileName())){
+ Base64.getMimeDecoder().wrap(is).transferTo(os);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ });
+
+ byte[] data;
+
+ // openssl -> keytool interop check
+
+ // os2. no cert pbe, no mac.
+ check("os2", "a", null, "changeit", true, true, true);
+ check("os2", "a", "changeit", "changeit", true, true, true);
+ // You can even load it with a wrong storepass, controversial
+ check("os2", "a", "wrongpass", "changeit", true, true, true);
+
+ // os3. no cert pbe, has mac. just like JKS
+ check("os3", "a", null, "changeit", true, true, true);
+ check("os3", "a", "changeit", "changeit", true, true, true);
+ // Cannot load with a wrong storepass, same as JKS
+ check("os3", "a", "wrongpass", "-", IOException.class, "-", "-");
+
+ // os4. non default algs
+ check("os4", "a", "changeit", "changeit", true, true, true);
+ check("os4", "a", "wrongpass", "-", IOException.class, "-", "-");
+ // no storepass no cert
+ check("os4", "a", null, "changeit", true, false, true);
+
+ // os5. strong non default algs
+ check("os5", "a", "changeit", "changeit", true, true, true);
+ check("os5", "a", "wrongpass", "-", IOException.class, "-", "-");
+ // no storepass no cert
+ check("os5", "a", null, "changeit", true, false, true);
+
+ // keytool
+
+ // Current default pkcs12 setting
+ keytool("-importkeystore -srckeystore ks -srcstorepass changeit "
+ + "-destkeystore ksnormal -deststorepass changeit");
+ data = Files.readAllBytes(Path.of("ksnormal"));
+ checkInt(data, "22", 100000); // Mac ic
+ checkAlg(data, "2000", SHA_oid); // Mac alg
+ checkAlg(data, "110c010c01000", pbeWithSHA1AndDESede_oid); // key alg
+ checkInt(data, "110c010c010011", 50000); // key ic
+ checkAlg(data, "110c10", ENCRYPTED_DATA_OID);
+ checkAlg(data, "110c110110", pbeWithSHA1AndRC2_40_oid); // cert alg
+ checkInt(data, "110c1101111", 50000); // cert ic
+
+ check("ksnormal", "a", "changeit", "changeit", true, true, true);
+ check("ksnormal", "a", null, "changeit", true, false, true);
+ check("ksnormal", "a", "wrongpass", "-", IOException.class, "-", "-");
+
+ // Add a new entry with password-less settings, still has a storepass
+ keytool("-keystore ksnormal -genkeypair -storepass changeit -alias b -dname CN=b "
+ + "-J-Dkeystore.pkcs12.certProtectionAlgorithm=NONE "
+ + "-J-Dkeystore.pkcs12.macAlgorithm=NONE");
+ data = Files.readAllBytes(Path.of("ksnormal"));
+ checkInt(data, "22", 100000); // Mac ic
+ checkAlg(data, "2000", SHA_oid); // Mac alg
+ checkAlg(data, "110c010c01000", pbeWithSHA1AndDESede_oid); // key alg
+ checkInt(data, "110c010c010011", 50000); // key ic
+ checkAlg(data, "110c010c11000", pbeWithSHA1AndDESede_oid); // new key alg
+ checkInt(data, "110c010c110011", 50000); // new key ic
+ checkAlg(data, "110c10", ENCRYPTED_DATA_OID);
+ checkAlg(data, "110c110110", pbeWithSHA1AndRC2_40_oid); // cert alg
+ checkInt(data, "110c1101111", 50000); // cert ic
+ check("ksnormal", "b", null, "changeit", true, false, true);
+ check("ksnormal", "b", "changeit", "changeit", true, true, true);
+
+ // Different keypbe alg, no cert pbe and no mac
+ keytool("-importkeystore -srckeystore ks -srcstorepass changeit "
+ + "-destkeystore ksnopass -deststorepass changeit "
+ + "-J-Dkeystore.pkcs12.keyProtectionAlgorithm=PBEWithSHA1AndRC4_128 "
+ + "-J-Dkeystore.pkcs12.certProtectionAlgorithm=NONE "
+ + "-J-Dkeystore.pkcs12.macAlgorithm=NONE");
+ data = Files.readAllBytes(Path.of("ksnopass"));
+ shouldNotExist(data, "2"); // no Mac
+ checkAlg(data, "110c010c01000", pbeWithSHA1AndRC4_128_oid);
+ checkInt(data, "110c010c010011", 50000);
+ checkAlg(data, "110c10", DATA_OID);
+ check("ksnopass", "a", null, "changeit", true, true, true);
+ check("ksnopass", "a", "changeit", "changeit", true, true, true);
+ check("ksnopass", "a", "wrongpass", "changeit", true, true, true);
+
+ // Add a new entry with normal settings, still password-less
+ keytool("-keystore ksnopass -genkeypair -storepass changeit -alias b -dname CN=B");
+ data = Files.readAllBytes(Path.of("ksnopass"));
+ shouldNotExist(data, "2"); // no Mac
+ checkAlg(data, "110c010c01000", pbeWithSHA1AndRC4_128_oid);
+ checkInt(data, "110c010c010011", 50000);
+ checkAlg(data, "110c010c11000", pbeWithSHA1AndDESede_oid);
+ checkInt(data, "110c010c110011", 50000);
+ checkAlg(data, "110c10", DATA_OID);
+ check("ksnopass", "a", null, "changeit", true, true, true);
+ check("ksnopass", "b", null, "changeit", true, true, true);
+
+ keytool("-importkeystore -srckeystore ks -srcstorepass changeit "
+ + "-destkeystore ksnewic -deststorepass changeit "
+ + "-J-Dkeystore.pkcs12.macIterationCount=5555 "
+ + "-J-Dkeystore.pkcs12.certPbeIterationCount=6666 "
+ + "-J-Dkeystore.pkcs12.keyPbeIterationCount=7777");
+ data = Files.readAllBytes(Path.of("ksnewic"));
+ checkInt(data, "22", 5555); // Mac ic
+ checkAlg(data, "2000", SHA_oid); // Mac alg
+ checkAlg(data, "110c010c01000", pbeWithSHA1AndDESede_oid); // key alg
+ checkInt(data, "110c010c010011", 7777); // key ic
+ checkAlg(data, "110c110110", pbeWithSHA1AndRC2_40_oid); // cert alg
+ checkInt(data, "110c1101111", 6666); // cert ic
+
+ // keypbe alg cannot be NONE
+ keytool("-keystore ksnewic -genkeypair -storepass changeit -alias b -dname CN=B "
+ + "-J-Dkeystore.pkcs12.keyProtectionAlgorithm=NONE")
+ .shouldContain("NONE AlgorithmParameters not available")
+ .shouldHaveExitValue(1);
+
+ // new entry new keypbe alg (and default ic), else unchanged
+ keytool("-keystore ksnewic -genkeypair -storepass changeit -alias b -dname CN=B "
+ + "-J-Dkeystore.pkcs12.keyProtectionAlgorithm=PBEWithSHA1AndRC4_128");
+ data = Files.readAllBytes(Path.of("ksnewic"));
+ checkInt(data, "22", 5555); // Mac ic
+ checkAlg(data, "2000", SHA_oid); // Mac alg
+ checkAlg(data, "110c010c01000", pbeWithSHA1AndDESede_oid); // key alg
+ checkInt(data, "110c010c010011", 7777); // key ic
+ checkAlg(data, "110c010c11000", pbeWithSHA1AndRC4_128_oid); // new key alg
+ checkInt(data, "110c010c110011", 50000); // new key ic
+ checkAlg(data, "110c110110", pbeWithSHA1AndRC2_40_oid); // cert alg
+ checkInt(data, "110c1101111", 6666); // cert ic
+
+ // Check KeyStore loading multiple keystores
+ KeyStore ks = KeyStore.getInstance("pkcs12");
+ try (FileInputStream fis = new FileInputStream("ksnormal");
+ FileOutputStream fos = new FileOutputStream("ksnormaldup")) {
+ ks.load(fis, "changeit".toCharArray());
+ ks.store(fos, "changeit".toCharArray());
+ }
+ data = Files.readAllBytes(Path.of("ksnormaldup"));
+ checkInt(data, "22", 100000); // Mac ic
+ checkAlg(data, "2000", SHA_oid); // Mac alg
+ checkAlg(data, "110c010c01000", pbeWithSHA1AndDESede_oid); // key alg
+ checkInt(data, "110c010c010011", 50000); // key ic
+ checkAlg(data, "110c010c11000", pbeWithSHA1AndDESede_oid); // new key alg
+ checkInt(data, "110c010c110011", 50000); // new key ic
+ checkAlg(data, "110c10", ENCRYPTED_DATA_OID);
+ checkAlg(data, "110c110110", pbeWithSHA1AndRC2_40_oid); // cert alg
+ checkInt(data, "110c1101111", 50000); // cert ic
+
+ try (FileInputStream fis = new FileInputStream("ksnopass");
+ FileOutputStream fos = new FileOutputStream("ksnopassdup")) {
+ ks.load(fis, "changeit".toCharArray());
+ ks.store(fos, "changeit".toCharArray());
+ }
+ data = Files.readAllBytes(Path.of("ksnopassdup"));
+ shouldNotExist(data, "2"); // no Mac
+ checkAlg(data, "110c010c01000", pbeWithSHA1AndRC4_128_oid);
+ checkInt(data, "110c010c010011", 50000);
+ checkAlg(data, "110c010c11000", pbeWithSHA1AndDESede_oid);
+ checkInt(data, "110c010c110011", 50000);
+ checkAlg(data, "110c10", DATA_OID);
+
+ try (FileInputStream fis = new FileInputStream("ksnewic");
+ FileOutputStream fos = new FileOutputStream("ksnewicdup")) {
+ ks.load(fis, "changeit".toCharArray());
+ ks.store(fos, "changeit".toCharArray());
+ }
+ data = Files.readAllBytes(Path.of("ksnewicdup"));
+ checkInt(data, "22", 5555); // Mac ic
+ checkAlg(data, "2000", SHA_oid); // Mac alg
+ checkAlg(data, "110c010c01000", pbeWithSHA1AndDESede_oid); // key alg
+ checkInt(data, "110c010c010011", 7777); // key ic
+ checkAlg(data, "110c010c11000", pbeWithSHA1AndRC4_128_oid); // new key alg
+ checkInt(data, "110c010c110011", 50000); // new key ic
+ checkAlg(data, "110c110110", pbeWithSHA1AndRC2_40_oid); // cert alg
+ checkInt(data, "110c1101111", 6666); // cert ic
+
+ // Check keytool behavior
+
+ // ksnormal has password
+
+ keytool("-list -keystore ksnormal")
+ .shouldContain("WARNING WARNING WARNING")
+ .shouldContain("Certificate chain length: 0");
+
+ SecurityTools.setResponse("changeit");
+ keytool("-list -keystore ksnormal")
+ .shouldNotContain("WARNING WARNING WARNING")
+ .shouldContain("Certificate fingerprint");
+
+ // ksnopass is password-less
+
+ keytool("-list -keystore ksnopass")
+ .shouldNotContain("WARNING WARNING WARNING")
+ .shouldContain("Certificate fingerprint");
+
+ // -certreq prompts for keypass
+ SecurityTools.setResponse("changeit");
+ keytool("-certreq -alias a -keystore ksnopass")
+ .shouldContain("Enter key password for <a>")
+ .shouldContain("-----BEGIN NEW CERTIFICATE REQUEST-----")
+ .shouldHaveExitValue(0);
+
+ // -certreq -storepass works fine
+ keytool("-certreq -alias a -keystore ksnopass -storepass changeit")
+ .shouldNotContain("Enter key password for <a>")
+ .shouldContain("-----BEGIN NEW CERTIFICATE REQUEST-----")
+ .shouldHaveExitValue(0);
+
+ // -certreq -keypass also works fine
+ keytool("-certreq -alias a -keystore ksnopass -keypass changeit")
+ .shouldNotContain("Enter key password for <a>")
+ .shouldContain("-----BEGIN NEW CERTIFICATE REQUEST-----")
+ .shouldHaveExitValue(0);
+
+ // -importkeystore prompts for srckeypass
+ SecurityTools.setResponse("changeit", "changeit");
+ keytool("-importkeystore -srckeystore ksnopass "
+ + "-destkeystore jks3 -deststorepass changeit")
+ .shouldContain("Enter key password for <a>")
+ .shouldContain("Enter key password for <b>")
+ .shouldContain("2 entries successfully imported");
+
+ // ksnopass2 is ksnopass + 2 cert entries
+
+ ks = KeyStore.getInstance(new File("ksnopass"), (char[])null);
+ ks.setCertificateEntry("aa", ks.getCertificate("a"));
+ ks.setCertificateEntry("bb", ks.getCertificate("b"));
+ try (FileOutputStream fos = new FileOutputStream("ksnopass2")) {
+ ks.store(fos, null);
+ }
+
+ // -importkeystore prompts for srckeypass for private keys
+ // and no prompt for certs
+ SecurityTools.setResponse("changeit", "changeit");
+ keytool("-importkeystore -srckeystore ksnopass2 "
+ + "-destkeystore jks5 -deststorepass changeit")
+ .shouldContain("Enter key password for <a>")
+ .shouldContain("Enter key password for <b>")
+ .shouldNotContain("Enter key password for <aa>")
+ .shouldNotContain("Enter key password for <bb>")
+ .shouldContain("4 entries successfully imported");
+
+ // ksonlycert has only cert entries
+
+ ks.deleteEntry("a");
+ ks.deleteEntry("b");
+ try (FileOutputStream fos = new FileOutputStream("ksonlycert")) {
+ ks.store(fos, null);
+ }
+
+ // -importkeystore does not prompt at all
+ keytool("-importkeystore -srckeystore ksonlycert "
+ + "-destkeystore jks6 -deststorepass changeit")
+ .shouldNotContain("Enter key password for <aa>")
+ .shouldNotContain("Enter key password for <bb>")
+ .shouldContain("2 entries successfully imported");
+
+ // create a new password-less keystore
+ keytool("-keystore ksnopass -exportcert -alias a -file a.cert -rfc");
+
+ // Normally storepass is prompted for
+ keytool("-keystore kscert1 -importcert -alias a -file a.cert -noprompt")
+ .shouldContain("Enter keystore password:");
+ keytool("-keystore kscert2 -importcert -alias a -file a.cert -noprompt "
+ + "-J-Dkeystore.pkcs12.certProtectionAlgorithm=NONE")
+ .shouldContain("Enter keystore password:");
+ keytool("-keystore kscert3 -importcert -alias a -file a.cert -noprompt "
+ + "-J-Dkeystore.pkcs12.macAlgorithm=NONE")
+ .shouldContain("Enter keystore password:");
+ // ... but not if it's password-less
+ keytool("-keystore kscert4 -importcert -alias a -file a.cert -noprompt "
+ + "-J-Dkeystore.pkcs12.certProtectionAlgorithm=NONE "
+ + "-J-Dkeystore.pkcs12.macAlgorithm=NONE")
+ .shouldNotContain("Enter keystore password:");
+
+ // still prompt for keypass for genkeypair and certreq
+ SecurityTools.setResponse("changeit", "changeit");
+ keytool("-keystore ksnopassnew -genkeypair -alias a -dname CN=A "
+ + "-J-Dkeystore.pkcs12.certProtectionAlgorithm=NONE "
+ + "-J-Dkeystore.pkcs12.macAlgorithm=NONE")
+ .shouldNotContain("Enter keystore password:")
+ .shouldContain("Enter key password for <a>");
+ keytool("-keystore ksnopassnew -certreq -alias a")
+ .shouldNotContain("Enter keystore password:")
+ .shouldContain("Enter key password for <a>");
+ keytool("-keystore ksnopassnew -list -v -alias a")
+ .shouldNotContain("Enter keystore password:")
+ .shouldNotContain("Enter key password for <a>");
+
+ // params only read on demand
+
+ // keyPbeIterationCount is used by -genkeypair
+ keytool("-keystore ksgenbadkeyic -genkeypair -alias a -dname CN=A "
+ + "-storepass changeit "
+ + "-J-Dkeystore.pkcs12.keyPbeIterationCount=abc")
+ .shouldContain("keyPbeIterationCount is not a number: abc")
+ .shouldHaveExitValue(1);
+
+ keytool("-keystore ksnopassnew -exportcert -alias a -file a.cert");
+
+ // but not used by -importcert
+ keytool("-keystore ksimpbadkeyic -importcert -alias a -file a.cert "
+ + "-noprompt -storepass changeit "
+ + "-J-Dkeystore.pkcs12.keyPbeIterationCount=abc")
+ .shouldHaveExitValue(0);
+
+ // None is used by -list
+ keytool("-keystore ksnormal -storepass changeit -list "
+ + "-J-Dkeystore.pkcs12.keyPbeIterationCount=abc "
+ + "-J-Dkeystore.pkcs12.certPbeIterationCount=abc "
+ + "-J-Dkeystore.pkcs12.macIterationCount=abc")
+ .shouldHaveExitValue(0);
+ }
+
+ /**
+ * Check keystore loading and key/cert reading.
+ *
+ * @param keystore the file name of keystore
+ * @param alias the key/cert to read
+ * @param storePass store pass to try out, can be null
+ * @param keypass key pass to try, can not be null
+ * @param expectedLoad expected result of keystore loading, true if non
+ * null, false if null, exception class if exception
+ * @param expectedCert expected result of cert reading
+ * @param expectedKey expected result of key reading
+ */
+ private static void check(
+ String keystore,
+ String alias,
+ String storePass,
+ String keypass,
+ Object expectedLoad,
+ Object expectedCert,
+ Object expectedKey) {
+ KeyStore ks = null;
+ Object actualLoad, actualCert, actualKey;
+ String label = keystore + "-" + alias + "-" + storePass + "-" + keypass;
+ try {
+ ks = KeyStore.getInstance(new File(keystore),
+ storePass == null ? null : storePass.toCharArray());
+ actualLoad = ks != null;
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ actualLoad = e.getClass();
+ }
+ Asserts.assertEQ(expectedLoad, actualLoad, label + "-load");
+
+ // If not loaded correctly, skip cert/key reading
+ if (!Objects.equals(actualLoad, true)) {
+ return;
+ }
+
+ try {
+ actualCert = (ks.getCertificate(alias) != null);
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ actualCert = e.getClass();
+ }
+ Asserts.assertEQ(expectedCert, actualCert, label + "-cert");
+
+ try {
+ actualKey = (ks.getKey(alias, keypass.toCharArray()) != null);
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ actualKey = e.getClass();
+ }
+ Asserts.assertEQ(expectedKey, actualKey, label + "-key");
+ }
+
+ static OutputAnalyzer keytool(String s) throws Throwable {
+ return SecurityTools.keytool(s);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/pkcs12/params/README Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,54 @@
+1. Preparing data in this directory
+
+mkdir tmp
+cd tmp
+keytool -keystore ks -genkeypair -storepass changeit -alias a -dname CN=A
+openssl pkcs12 -in ks -nodes -out kandc -passin pass:changeit
+openssl pkcs12 -export -in kandc -out os2 -name a -passout pass:changeit \
+ -certpbe NONE -nomac
+openssl pkcs12 -export -in kandc -out os3 -name a -passout pass:changeit \
+ -certpbe NONE
+openssl pkcs12 -export -in kandc -out os4 -name a -passout pass:changeit \
+ -certpbe PBE-SHA1-RC4-128 -keypbe PBE-SHA1-RC4-128 -macalg SHA224
+openssl pkcs12 -export -in kandc -out os5 -name a -passout pass:changeit \
+ -certpbe AES-256-CBC -keypbe AES-256-CBC -macalg SHA512
+for a in *; do
+ openssl base64 -in $a -out ../$a
+done
+cd ..
+rm -rf tmp
+
+2. After running the test, we can go to the scratch directory and run the
+following commands to check keytool -> openssl interoperability.
+OpenSSL 1.1.0i is used here. Earlier versions might generate different info.
+
+(
+openssl pkcs12 -in ks2 -passin pass:changeit -info -nokeys -nocerts 2> t2 || exit 20
+grep "MAC:sha1 Iteration 100000" t2 || exit 21
+grep "Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 50000" t2 || exit 23
+grep "PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 50000" t2 || exit 24
+
+openssl pkcs12 -in ks22 -passin pass:changeit -info -nokeys -nocerts 2> t22 || exit 25
+diff t2 t22 || exit 26
+
+openssl pkcs12 -in ks3 -passin pass:changeit -info -nokeys -nocerts && exit 30
+
+openssl pkcs12 -in ks3 -passin pass:changeit -info -nokeys -nocerts -nomacver 2> t3 || exit 31
+grep "PKCS7 Encrypted data:" t3 && exit 33
+grep "Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 50000" t3 || exit 34
+grep "Shrouded Keybag: pbeWithSHA1And128BitRC4, Iteration 50000" t3 || exit 35
+
+openssl pkcs12 -in ks33 -passin pass:changeit -info -nokeys -nocerts -nomacver 2> t33 || exit 36
+diff t3 t33 || exit 37
+
+openssl pkcs12 -in ks4 -passin pass:changeit -info -nokeys -nocerts 2> t4 || exit 40
+grep "MAC:sha1 Iteration 5555" t4 || exit 41
+grep "Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 7777" t4 || exit 43
+grep "Shrouded Keybag: pbeWithSHA1And128BitRC4, Iteration 50000" t4 || exit 44
+grep "PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 6666" t4 || exit 45
+
+openssl pkcs12 -in ks44 -passin pass:changeit -info -nokeys -nocerts 2> t44 || exit 46
+diff t4 t44 || exit 47
+
+echo Succeed
+)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/pkcs12/params/kandc Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,55 @@
+QmFnIEF0dHJpYnV0ZXMKICAgIGZyaWVuZGx5TmFtZTogYQogICAgbG9jYWxLZXlJ
+RDogNTQgNjkgNkQgNjUgMjAgMzEgMzUgMzMgMzggMzEgMzMgMzQgMzAgMzUgMzkg
+MzQgMzMgMzUgCktleSBBdHRyaWJ1dGVzOiA8Tm8gQXR0cmlidXRlcz4KLS0tLS1C
+RUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUNYUUlCQURDQ0FqVUdCeXFHU000NEJB
+RXdnZ0lvQW9JQkFRQ1BlVFhadWFycHY2dnRpSHJQU1ZHMjh5N0YKbmp1dk54am82
+c1NXSHo3OU5nYm5RMUdweEJnek9iZ0o1OEt1SEZPYnAwZGJoZEFScmJpMGVZZDFT
+WVJwWEt3TwpqeFN6Tmdnb29pLzZKeEVLUFdLcGswVTBDYUQrYVd4R1dQaEwzU0NC
+bkRjSm9CQlhzWld0elFBalBicFVoTFlwCkg1MWtqdmlEUklaM2w1enNCTFEwcHF3
+dWRlbVlYZUk5c0NrdndSR01uL3FkZ1lIbk00MjNrcmN3MTdualNWa3YKYUFtWWNo
+VTVGZW85YTR0R1U4WXpSWStBT3pLa3d1RHljcEFsYms0L2lqc0lPS0hFVU9UaGpC
+b3BvMzNmWHFGRAoza3RtL3dTUVB0WFBGaVBoV05TSHhnanBmeUVjMkIzS0k4dHVP
+QWRsK0NMalFyNUlUQVYyT1RsZ0hOWm5BaDBBCnV2YVdwb1Y0OTkvZTUvcG55WGZI
+aGU4eXNqTzY1WURBdk5WcFhRS0NBUUFXcGx4WUlFaFFjRTUxQXFPWFZ3UU4KTk5v
+Nk5IakJWTlRrcGNBdEpDN2dUNWJtSGt2UWtFcTlySTgzN3JIZ256R0MwanlRUTh0
+a0w0Z0FRV0R0K2NvSgpzeUIycDV3eXBpZnlSejZSaDV1aXhPZEV2U0NCVkV5MVc0
+QXNObzBmcUQ3VWllbE9ENkJvampKQ2lseDR4SGpHCmpRVW50eHlhT3JzTEMrRXNS
+R2lXT2VmVHpuVGJFQnBscWl1SDlreG9KdHMreHk5TFZabURTN1R0c0M5OGtPbWsK
+bHRPbFhWTmI2L3hGMVBZWjlqODk3YnVIT1NYQzhpVGdkekVwYmFpSDdCNUhTUGgr
+KzEvZXQxU0VNV3NpTXQ3bApVOTJ2QWhFckRSOEMyakNYTWlUK0o2N2FpNTFMS1NM
+WnVvdmpudG5oQTZZOFVvRUx4b2kzNHUxREZ1SHZGOXZlCkJCOENIUUMzU0hOSm5u
+cjF0TG00aDdKR1RETU02cUJQc2N3cmdMcGZHOW9tCi0tLS0tRU5EIFBSSVZBVEUg
+S0VZLS0tLS0KQmFnIEF0dHJpYnV0ZXMKICAgIGZyaWVuZGx5TmFtZTogYQogICAg
+bG9jYWxLZXlJRDogNTQgNjkgNkQgNjUgMjAgMzEgMzUgMzMgMzggMzEgMzMgMzQg
+MzAgMzUgMzkgMzQgMzMgMzUgCnN1YmplY3Q9L0NOPUEKaXNzdWVyPS9DTj1BCi0t
+LS0tQkVHSU4gQ0VSVElGSUNBVEUtLS0tLQpNSUlFRXpDQ0E3K2dBd0lCQWdJRWJ1
+OFlOREFOQmdsZ2hrZ0JaUU1FQXdJRkFEQU1NUW93Q0FZRFZRUURFd0ZCCk1CNFhE
+VEU0TURreU9ERXhNamN6T1ZvWERURTRNVEl5TnpFeE1qY3pPVm93RERFS01BZ0dB
+MVVFQXhNQlFUQ0MKQTBJd2dnSTFCZ2NxaGtqT09BUUJNSUlDS0FLQ0FRRUFqM2sx
+MmJtcTZiK3I3WWg2ejBsUnR2TXV4WjQ3cnpjWQo2T3JFbGg4Ky9UWUc1ME5ScWNR
+WU16bTRDZWZDcmh4VG02ZEhXNFhRRWEyNHRIbUhkVW1FYVZ5c0RvOFVzellJCktL
+SXYraWNSQ2oxaXFaTkZOQW1nL21sc1JsajRTOTBnZ1p3M0NhQVFWN0dWcmMwQUl6
+MjZWSVMyS1IrZFpJNzQKZzBTR2Q1ZWM3QVMwTkthc0xuWHBtRjNpUGJBcEw4RVJq
+Si82bllHQjV6T050NUszTU5lNTQwbFpMMmdKbUhJVgpPUlhxUFd1TFJsUEdNMFdQ
+Z0RzeXBNTGc4bktRSlc1T1A0bzdDRGloeEZEazRZd2FLYU45MzE2aFE5NUxadjhF
+CmtEN1Z6eFlqNFZqVWg4WUk2WDhoSE5nZHlpUExiamdIWmZnaTQwSytTRXdGZGpr
+NVlCeldad0lkQUxyMmxxYUYKZVBmZjN1ZjZaOGwzeDRYdk1ySXp1dVdBd0x6VmFW
+MENnZ0VBRnFaY1dDQklVSEJPZFFLamwxY0VEVFRhT2pSNAp3VlRVNUtYQUxTUXU0
+RStXNWg1TDBKQkt2YXlQTis2eDRKOHhndEk4a0VQTFpDK0lBRUZnN2ZuS0NiTWdk
+cWVjCk1xWW44a2Mra1llYm9zVG5STDBnZ1ZSTXRWdUFMRGFOSDZnKzFJbnBUZytn
+YUk0eVFvcGNlTVI0eG8wRko3Y2MKbWpxN0N3dmhMRVJvbGpubjA4NTAyeEFhWmFv
+cmgvWk1hQ2JiUHNjdlMxV1pnMHUwN2JBdmZKRHBwSmJUcFYxVApXK3Y4UmRUMkdm
+WS9QZTI3aHprbHd2SWs0SGN4S1cyb2grd2VSMGo0ZnZ0ZjNyZFVoREZySWpMZTVW
+UGRyd0lSCkt3MGZBdG93bHpJay9pZXUyb3VkU3lraTJicUw0NTdaNFFPbVBGS0JD
+OGFJdCtMdFF4Ymg3eGZiM2dPQ0FRVUEKQW9JQkFEK0syd1RoV3VyRGpZTUNYeGZy
+dXJOK0drZFNFeXk5cCtkdkhJUDFrTWhybTcrRXV6LzExUVlGcGI4Vgpic0NhWWUx
+ME9qWkF1WjRXSmdTbkl5R0swb2JzbjlKWkZubUdDbGlxRkVoWGJwbnhyOGxhS3Iw
+dDRERytPMTF2CjVQRGh4aHd2b1VZb2ZwWTFEYjN0SHlxdytWM3RRWVA3K3RaNDRB
+eW1SdTNtbktZTVZzRHd2M0x1UEdaLzJmQ0MKY2lYVEJIU3VFbzdCUDdBbjdFYkZO
+K0JaQldlTlgvcjNOZm1nL0tmQjQ1OFNZMmhFYlplRW5kZUh4d204VFRORwpQaXdi
+Nkx5ZE5RS0VFS003cmVFTjkwTXVsUVJMZkhVVFBWZXB5dU9QK1ZySEI3WS9lVWhI
+K2RNeHp6d3pLOHJ6CjRYaEwxRFBhT1ZMdmxCSUR5VE5QZU4wV2V4bWpJVEFmTUIw
+R0ExVWREZ1FXQkJUQThWK01SSXRNU3Yyb283YjgKYzVlQ0tybzdxREFOQmdsZ2hr
+Z0JaUU1FQXdJRkFBTS9BREE4QWh3a0dVK2VVR0kvTFFVejMzTUk3cC9BVXd1WAo0
+SnZOVGUrUGhQZFZBaHdvUzdNMFIzbjRnSkkxU2FRdnoyTWhuR3Z1T3Q5UzZMdkRR
+NWRFCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/pkcs12/params/ks Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,45 @@
+MIIIQQIBAzCCB/oGCSqGSIb3DQEHAaCCB+sEggfnMIIH4zCCAv8GCSqGSIb3DQEH
+AaCCAvAEggLsMIIC6DCCAuQGCyqGSIb3DQEMCgECoIICmzCCApcwKQYKKoZIhvcN
+AQwBAzAbBBSZfQZ+F5Za9YLcGbyXsafOUX50XwIDAMNQBIICaBh7FmOBnDoFngWz
+pnK5+SzD16E8TNFxZneou1n2Nxq8MXMgfLjlVb9PSlARDU+Pj9FhRdjWqTEncKwn
+5owDYujiOSGmAHih64nFHoICs34o5LAKv9l8UhfE1qUgA4iA1VdakD31N8ZGR29O
+2tglXKrHE9n6f5k47mzqcPiNIgHH1KSWu143AInYTOjpEJD2YpBTzL0YxvnLbaY1
+v+PRokbHak8siO/MCNwwQBD5lJX7kVld4iMjeJvBX9pUwqfD4EDuvJo9QkHmy+GB
+UBAMRBsMHwV9E832dHxh+JYveg0TI8FACnLHpmbYpCs+K69A6yOAUqfUIseLUJR4
+XSd2HZODXyLHAimJK9AQGRpGWORiRu2E/XimLo2qhPKEOl2hbi+R95hb2h2wGgr1
+RhCsAFHac7cW4r/s1HacU0JCzWJKyV76LbNHDexlGj09B47VAAAfE7zlHmUIShEN
+zwQ6EUDxrK+h7wY2GS2fqcseqDvPXtxvbGjkAyfYE+6aT2g6vtd6PTrBSRt6Lzp6
+rUC0IrHXXpBb8qanvuAd+OPC4skp/hI/q7qCsKOUzRc5Xmm1FMUfJr6UeadSvpfw
+V9C28zEMPcW+KdS2W7f0uvebIgUU7xj8dg27XC+C7oPhLz/pIFQ4n449GQNUo57K
+WPmGeT/coO3jVk+E7uzXeFkwp2rGXQNWin44UUGGG0/S04YMRJknpRzw8sILD4d1
+N/iEazUOl35pua9+0OTFqNJzSemqO3kevgVXrsSzQCLeoB1dn4mpvqkPV87B5JOC
+t3fpDVSBrcFF43qeveQ65lpbcbOoucO/h16s8w8xNjARBgkqhkiG9w0BCRQxBB4C
+AGEwIQYJKoZIhvcNAQkVMRQEElRpbWUgMTUzODEzNDA1OTQzNTCCBNwGCSqGSIb3
+DQEHBqCCBM0wggTJAgEAMIIEwgYJKoZIhvcNAQcBMCkGCiqGSIb3DQEMAQYwGwQU
+tPIqPBD1WiaRd01W1t6/znB2PmkCAwDDUICCBIhvxfWroewV/5cO8r24YQkMVjvs
+2kgkLusWbreMScR/LE5lcLXHYAS3KMJJWfwBBKa3nvyuMiYPnuzTReSd7SxtCZtG
++EIyyf6mTUdqBTPkDduqDHqugzokHKFycsTi2YBam1ohyTOUoUOFnJeOyJ4FOVQ5
+TQOPUXgBW8s2jMm181+w0E3NXiEC+c+cPZUm2aQPLUxEYqTuJsMY6Uz+jv94hOIH
+eeZHwVBy8D/3pUB56L89JBRARpIsCP+BQIaTFyopXQ8i50gdT3a6KL8O9Zzjjij8
+VLjCpLdC9wR5yY4Js/cZyER/uxl8zBroheiye5U77rw4WQrSQhn/cBoTDR0llwlU
+K3IL4J22UjtTmIQlFAV8XWz7GZAVJkuJLEtuO6JjHSgO8NTnfN2T4oWaNAwdAK3S
+UrJVpk4yx0+B2UokxyY0Y3FErLzM7BMq/X9Rvhs9Zwwr+ZftqXEaiYHHSEPGNGZI
+Gh3P8F8EThCcyVe7yFK+0DCj3Y8jrZZLXh8e1M1wPWVay52JL1QApTfs0ucwlMLz
+19KUSm13ztuCBo47OrMU1ur6a1eQZkOvRmdMxKNLLrET3sBh7ZE6SbjijCtDfYdf
+k4+Q9VrO+04atyXg8Gy4vRZB/koe8oXCDgPYTTqLHNywTuhJq30Ev71D0GdiwPy7
+9urLh2ocm7neRIGsaYRXxa0U6IpT47wOYbUOz3y6Yf5yjoI3E0gWYZtuQVGRkatF
+p97mJExQ9aBy1l4hqmgU4bcqBepq2fdxhVueiZD84QZqfZ5H9pRzVPjHoqzIH8wm
+kmM78mlMqu8IPqny0I3zF6z+wapd0vpjpeaLItlUAJ2Eiz7d4BHKBeAPsZtPUQzr
+hPtM/ao5QjLHddLqh2lauJk0Og+4Uj1UftelM6ERZPN0JXEyh+DU9hs2czTnJKlZ
+BEB07/1WFPCrdj/eNe7K02Xs2kpJKiXjAWNxFNWtqDQY3U5/lAY8oY/dc6LG+iuO
+yDLXD4TSJZSNrOOHKmp4TXpuMRM2tbw9m0vrweegSB6GIzUIA1MOvgsjbSgWwmhy
+LoG6QriLhTXZQd+Uh6uqlCBrgXQ2K+RuIsZCZaZE64pUtK3Tl6ZwBe3POfxMCkjm
+YQ/ZJ7k0IOk9lQfA6InlfSDkS7B5WHev7Fqh96GI9sUSox13El9VvbNfFDZy5lem
+Ml8GTDLrlop5TRDeplHknettKqMQmpj2nopGvTn4EFSNFz8AZmEtOaptzkP5l3ar
+DRgPqhxclb/4QX7c67s1l/pcR16BbiH05rxVUTclg8rB0FCo14Hi5CQF0turk5QK
+ptM9kvz/VtDUpHArRz7NaFZdJuVC1IRq8dgmSi7MN7LaQ0mVIfeQ1ssHjLhIQMbA
+aE8Xwij9Q5OAoNcA8Ucctqgl12/9uKfZ5lKeZnVR4DyVhjnTJ9Ounv1unagBj/Jq
+6o4ibStuqfHhKhBtQkr4RXsrocJhgMhfhbUqgQRx0pWuODrpqQMuG6yTnw7ePPMt
+w29mceyPdU8EoYUUPCDZdpv3giurH5E22tnRDyU0Mm1Spbe/rDA+MCEwCQYFKw4D
+AhoFAAQUtavY6pX+J6lZHeGkx3Rlt6Hc8iEEFOUlujwYOLAzDd2fQcGdyL8MrGvo
+AgMBhqA=
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/pkcs12/params/os2 Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,42 @@
+MIIHrwIBAzCCB6gGCSqGSIb3DQEHAaCCB5kEggeVMIIHkTCCBJUGCSqGSIb3DQEH
+AaCCBIYEggSCMIIEfjCCBHoGCyqGSIb3DQEMCgEDoIIELzCCBCsGCiqGSIb3DQEJ
+FgGgggQbBIIEFzCCBBMwggO/oAMCAQICBG7vGDQwDQYJYIZIAWUDBAMCBQAwDDEK
+MAgGA1UEAxMBQTAeFw0xODA5MjgxMTI3MzlaFw0xODEyMjcxMTI3MzlaMAwxCjAI
+BgNVBAMTAUEwggNCMIICNQYHKoZIzjgEATCCAigCggEBAI95Ndm5qum/q+2Ies9J
+UbbzLsWeO683GOjqxJYfPv02BudDUanEGDM5uAnnwq4cU5unR1uF0BGtuLR5h3VJ
+hGlcrA6PFLM2CCiiL/onEQo9YqmTRTQJoP5pbEZY+EvdIIGcNwmgEFexla3NACM9
+ulSEtikfnWSO+INEhneXnOwEtDSmrC516Zhd4j2wKS/BEYyf+p2BgeczjbeStzDX
+ueNJWS9oCZhyFTkV6j1ri0ZTxjNFj4A7MqTC4PJykCVuTj+KOwg4ocRQ5OGMGimj
+fd9eoUPeS2b/BJA+1c8WI+FY1IfGCOl/IRzYHcojy244B2X4IuNCvkhMBXY5OWAc
+1mcCHQC69pamhXj3397n+mfJd8eF7zKyM7rlgMC81WldAoIBABamXFggSFBwTnUC
+o5dXBA002jo0eMFU1OSlwC0kLuBPluYeS9CQSr2sjzfuseCfMYLSPJBDy2QviABB
+YO35ygmzIHannDKmJ/JHPpGHm6LE50S9IIFUTLVbgCw2jR+oPtSJ6U4PoGiOMkKK
+XHjEeMaNBSe3HJo6uwsL4SxEaJY559POdNsQGmWqK4f2TGgm2z7HL0tVmYNLtO2w
+L3yQ6aSW06VdU1vr/EXU9hn2Pz3tu4c5JcLyJOB3MSltqIfsHkdI+H77X963VIQx
+ayIy3uVT3a8CESsNHwLaMJcyJP4nrtqLnUspItm6i+Oe2eEDpjxSgQvGiLfi7UMW
+4e8X294DggEFAAKCAQA/itsE4Vrqw42DAl8X67qzfhpHUhMsvafnbxyD9ZDIa5u/
+hLs/9dUGBaW/FW7AmmHtdDo2QLmeFiYEpyMhitKG7J/SWRZ5hgpYqhRIV26Z8a/J
+Wiq9LeAxvjtdb+Tw4cYcL6FGKH6WNQ297R8qsPld7UGD+/rWeOAMpkbt5pymDFbA
+8L9y7jxmf9nwgnIl0wR0rhKOwT+wJ+xGxTfgWQVnjV/69zX5oPynweOfEmNoRG2X
+hJ3Xh8cJvE0zRj4sG+i8nTUChBCjO63hDfdDLpUES3x1Ez1Xqcrjj/laxwe2P3lI
+R/nTMc88MyvK8+F4S9Qz2jlS75QSA8kzT3jdFnsZoyEwHzAdBgNVHQ4EFgQUwPFf
+jESLTEr9qKO2/HOXgiq6O6gwDQYJYIZIAWUDBAMCBQADPwAwPAIcJBlPnlBiPy0F
+M99zCO6fwFMLl+CbzU3vj4T3VQIcKEuzNEd5+ICSNUmkL89jIZxr7jrfUui7w0OX
+RDE4MBEGCSqGSIb3DQEJFDEEHgIAYTAjBgkqhkiG9w0BCRUxFgQU0essNYYOWMdT
+/A/ozvhbEmwKv2YwggL0BgkqhkiG9w0BBwGgggLlBIIC4TCCAt0wggLZBgsqhkiG
+9w0BDAoBAqCCAo4wggKKMBwGCiqGSIb3DQEMAQMwDgQI8K+MRZ3EoKQCAggABIIC
+aGUbReB6byOtQd7BAAym6y+S1O6URFnEjYs+aFVTmwRuRDE6d3xToxZUkOaVsUc5
+kR5P6ixifkd/S4yRl+t0Eqvn1yhTwR/ptTm/EL8a7RygPG3/wsSsXUCVEBvtTO3q
+G+iXUmLk5FjeiOpCbccOUNTZmPXgnSfw0YYrenjr5Z0MOk4BESe+/V8rvEG71fJ7
+KRE6m1b3E8ad3mz09BnccBFdJyY0xEjwD8KJLnUDVyaopYPnvi2Z7OunsyMWUgx8
+gftqGpk5IhskIEnvgQ9NNjL2JpytbG0nVkpgtBULcKCXtPEqqweY/6m5VFAhkikX
+urUiJr+svjRFqkXuv+oPJ+6o/Y4QTJSqHbavsXWEwAo+3IxyMhQwLMf/6iXfBiGL
+RIrLON3s6c0AcboGCtn1nfEcaXzNrTXkFpzJSFYGBHZVlXdyptDmsMXZbJlZAPFb
+2dIzx9yJHqS3AV560p30399VWSko7HmY7t+EbZH/vrdVD+Vzy2zPXFDtbu70j8C/
+RT21LAjjjrliIop/2Akhz3eOTZcEAoQNBLcNBXoIdo7HiX6KzpKvdW51lWWEcAWf
+zl878rJpmIdmvCc4HDkuzcpdvxk+q6pTn5Wh5K+X1ImTwWL+C+s4xHhiNAMzc4dK
+eMsmukiAW301uZkjU30vpJ2BjBwrRo+ej9s18ePviy65E9UYeforrPIkaM9lpwID
+AB17QgeVuciHiw/g7HmbAacWwoqZc41eipIxqPWHlqEGYeARm0x4zb47qWwcowSO
+AwlDuvRorpin25ZhiPesY1SJzFll5fAD0bxoQcry7S+2CetF7c8st3AxODARBgkq
+hkiG9w0BCRQxBB4CAGEwIwYJKoZIhvcNAQkVMRYEFNHrLDWGDljHU/wP6M74WxJs
+Cr9m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/pkcs12/params/os3 Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,43 @@
+MIIH4gIBAzCCB6gGCSqGSIb3DQEHAaCCB5kEggeVMIIHkTCCBJUGCSqGSIb3DQEH
+AaCCBIYEggSCMIIEfjCCBHoGCyqGSIb3DQEMCgEDoIIELzCCBCsGCiqGSIb3DQEJ
+FgGgggQbBIIEFzCCBBMwggO/oAMCAQICBG7vGDQwDQYJYIZIAWUDBAMCBQAwDDEK
+MAgGA1UEAxMBQTAeFw0xODA5MjgxMTI3MzlaFw0xODEyMjcxMTI3MzlaMAwxCjAI
+BgNVBAMTAUEwggNCMIICNQYHKoZIzjgEATCCAigCggEBAI95Ndm5qum/q+2Ies9J
+UbbzLsWeO683GOjqxJYfPv02BudDUanEGDM5uAnnwq4cU5unR1uF0BGtuLR5h3VJ
+hGlcrA6PFLM2CCiiL/onEQo9YqmTRTQJoP5pbEZY+EvdIIGcNwmgEFexla3NACM9
+ulSEtikfnWSO+INEhneXnOwEtDSmrC516Zhd4j2wKS/BEYyf+p2BgeczjbeStzDX
+ueNJWS9oCZhyFTkV6j1ri0ZTxjNFj4A7MqTC4PJykCVuTj+KOwg4ocRQ5OGMGimj
+fd9eoUPeS2b/BJA+1c8WI+FY1IfGCOl/IRzYHcojy244B2X4IuNCvkhMBXY5OWAc
+1mcCHQC69pamhXj3397n+mfJd8eF7zKyM7rlgMC81WldAoIBABamXFggSFBwTnUC
+o5dXBA002jo0eMFU1OSlwC0kLuBPluYeS9CQSr2sjzfuseCfMYLSPJBDy2QviABB
+YO35ygmzIHannDKmJ/JHPpGHm6LE50S9IIFUTLVbgCw2jR+oPtSJ6U4PoGiOMkKK
+XHjEeMaNBSe3HJo6uwsL4SxEaJY559POdNsQGmWqK4f2TGgm2z7HL0tVmYNLtO2w
+L3yQ6aSW06VdU1vr/EXU9hn2Pz3tu4c5JcLyJOB3MSltqIfsHkdI+H77X963VIQx
+ayIy3uVT3a8CESsNHwLaMJcyJP4nrtqLnUspItm6i+Oe2eEDpjxSgQvGiLfi7UMW
+4e8X294DggEFAAKCAQA/itsE4Vrqw42DAl8X67qzfhpHUhMsvafnbxyD9ZDIa5u/
+hLs/9dUGBaW/FW7AmmHtdDo2QLmeFiYEpyMhitKG7J/SWRZ5hgpYqhRIV26Z8a/J
+Wiq9LeAxvjtdb+Tw4cYcL6FGKH6WNQ297R8qsPld7UGD+/rWeOAMpkbt5pymDFbA
+8L9y7jxmf9nwgnIl0wR0rhKOwT+wJ+xGxTfgWQVnjV/69zX5oPynweOfEmNoRG2X
+hJ3Xh8cJvE0zRj4sG+i8nTUChBCjO63hDfdDLpUES3x1Ez1Xqcrjj/laxwe2P3lI
+R/nTMc88MyvK8+F4S9Qz2jlS75QSA8kzT3jdFnsZoyEwHzAdBgNVHQ4EFgQUwPFf
+jESLTEr9qKO2/HOXgiq6O6gwDQYJYIZIAWUDBAMCBQADPwAwPAIcJBlPnlBiPy0F
+M99zCO6fwFMLl+CbzU3vj4T3VQIcKEuzNEd5+ICSNUmkL89jIZxr7jrfUui7w0OX
+RDE4MBEGCSqGSIb3DQEJFDEEHgIAYTAjBgkqhkiG9w0BCRUxFgQU0essNYYOWMdT
+/A/ozvhbEmwKv2YwggL0BgkqhkiG9w0BBwGgggLlBIIC4TCCAt0wggLZBgsqhkiG
+9w0BDAoBAqCCAo4wggKKMBwGCiqGSIb3DQEMAQMwDgQIFvtCm+ogILcCAggABIIC
+aLbDb3DKmULPLHfwvcVdp3cbM1Bcj3T/keIzwnOzdMluj8wisUEQA/U1onSgp1eZ
+Hfk0TPcgd339Uevuh059GL5yFknH2VHhU6nO8Pz+OVpjab9nSBpWjv+PnlSAKWr6
+5ODx9t5TGPO5V7PBqtxDiU4YeBI6akUlroJz3lSH3dD8t3KBdi3GjnG0S4iBadrW
+BGV5izRPIbaDpISAscwDInXZ4HJhWbD14/mEOyKHwAmD+NwxMhAS97SRC7N/rAJD
+ACj0dQYb3MW4QqVgF2QBQmOYXq6CsrQvc8faQWpqgH2JYzquTu4vx7xFGuKlXSLU
++9hAo99NID6xYryebjMFe7sJFLXyMYLt9pWn5f72xR0PrH71EpTRQkZVIYUfnxkL
+iCFwNgWyPF7NYwieUKQ+JyPq3cllK+kuViiNwEvYO4TJp4XjYMXefXFlarX2llQz
+J/tu9LJu9eA9A528i7hvJ0ZFpYtZA40CWaJRlCKZqT9P/YQGiNOt31JxJtFyiEpl
+i/dh49clBpibQouRKSc/uTNePJ1IyaWkgE1SwmmEz+ZSFSlhxS4Ba0+2MsRKoirC
+8M6V0A16W4V2af9jVgRpIyRcRfYZBBij2Cu2k/UB/hrqxlYp3nehOC6PAVT40EwC
+HO5613cu2LSJDgxEtaNMcj5Zy6KkJ3vB2BxxfdHL6Dz3uLa+8BuEpfLUidccgCgm
+MQpxplgLVztIkq6HZy/koMGgv2ywV7LGLlVpKBHmKDO2yvYhr6J2rbNMsh5Bbq9i
+YiZVz7TdmqY4L8rEtEuwJA2SgHUV0FhpoD56WTfPZvfYgoHhHu1hBcQxODARBgkq
+hkiG9w0BCRQxBB4CAGEwIwYJKoZIhvcNAQkVMRYEFNHrLDWGDljHU/wP6M74WxJs
+Cr9mMDEwITAJBgUrDgMCGgUABBRQNcC69+RQUJu5I4ode2JYzXe2KAQI1mkwkuSh
+sUUCAggA
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/pkcs12/params/os4 Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,44 @@
+MIIIGwIBAzCCB9UGCSqGSIb3DQEHAaCCB8YEggfCMIIHvjCCBMkGCSqGSIb3DQEH
+BqCCBLowggS2AgEAMIIErwYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQEwDgQIkluN
+Qu+v+1gCAggAgIIEgr9xMS47pyB8kvlbU+/Uwh4pfbjeLm4h4FjR1GxKU0ouoct7
+cg/4S1AZfa2vjVCRxkdWLvf88eAtp96E1YVIdDT/3ZSY953eNA/xvNF2HWVJT18H
+jEOuNhmVHbuMIbfmG8sm6rwN2e3xnxuCDkYWvLNTiWOcoQTmLfJIqp5J2FLj2zwN
+0jApAepDE2NtEaq+edMU+3c3d7b0+n9BB32b5w1LaXzShuN2cpHOYJvkw+h32eyJ
+XrjlRB8J9/4XAzyz269UM9QWdxECqBeTfd1m8PhV/9xR9QOIcur0Flv/Cw0j3sos
+oMBibypXsV7GzGZKrUAIVAnhYsDB/yxxL/vPjZ8nCzl7iKc+wBNJiXIO04XNg00U
+bUBOSeoGs4ns909u09+qtwQf6fCiV8VwP/h5vIGB++Kv06O9CWt20lOv9KZPqZOR
+5H0ndbx60LoTsPT5FzOysOWqUNFx6wiggV9Txl38zax/VwOLA01Uq1jPDHEHQWIY
+M139MTL+5P43hDBy9TOyO8uzD3eUj3/+pvoyZb2wfV7NmN5WBgP/MDnm6Jk+eFMw
+6v4mXwKycIX6qsBNdTc4QAEgcHwv544eqxPiBuxerr5bySSodWjoziEtyzvgNx1f
+jGqQDn7VlZlDrn6rlJ0/iX0xv4M/PVngMUezfmW+zo4998NXlurXKbA2FG/U0mqt
+Ys0QGYkfoTFwHixYK4Mf7B4pwlHo3FCO+kjv+t1VZxZF/Pr8B1qflgeBJaiqH6oJ
+oh1L1vdOh93VowZFUvgmx27Fb3rIUhvGh1rzfhp5OmMaoXP97TwaHLsK2c/BDwJp
+cwmfaJByDcrlTAeBsNlzffD0o61ZAhYMZuGFEoyuIpm8qOcIW1dVrYe8tYP7ZTDA
+FUmmoymB+6cK8wW5V5BeRmSxU2DnkBDGriEzQTtepQLgzy7LtLU8rs1mIszwTiNj
+60MI6gX22taT0C8kpsH/xwKeKw+7tsyL8bk4N8zQ8h/osMdxtO0QVpxikQ3KAinj
+nurVqvcqq3n0EqHwRJ+NQMwuERbbDXcRDowQSWJc2HLn8odxL18dvOpu2IQlH2DA
+NtZpLqP7EZ36ebA6txlPdH2GUH7V9ZQwF+3t+NbMXrZLx93DAwdpzVDY9a96AFsE
+YHd3f3ReT8TzIwB1dOrvIOPO82cIy5/OIaDa9XelY2/dRVfU4cHpNhRZSLmsQfsQ
+yorPQi1baNT0GjoCDgynUvP2DWBdIyjZ442ysfNmO5MjmjYEA17ofBapc4xhsU5B
++XgyfVyfeDHNO+zMZvrdMPnXwu+A3ggaQorvQbAfV8JfVSZoyleKjTxNgx61KI3j
+dQsEtLQgvAbLsI+Ku7z86HVZ7PH69i3qHtJo8s8Nw4a9QvCCgpiMqw04EQawlZY1
+aCrOsHvElFB0klIlGpMPugJ1YVgSvXtMwLgLMlAr8mQW+10uKMtrVU5Iq6SAkRDe
+ff57iqXoKpNJVGsV9ZxrMT7Y5oECJvHLUWtqapsu7Xpp0/DUPcRxAfCj7ZBxEfVW
+sBBDmUia+TTVYT7TJPTzMIIC7QYJKoZIhvcNAQcBoIIC3gSCAtowggLWMIIC0gYL
+KoZIhvcNAQwKAQKgggKHMIICgzAcBgoqhkiG9w0BDAEBMA4ECLpLJ5EtNx41AgII
+AASCAmEutLb3vdtinkV4hEXRDnRPd19WXSTOFI5g3ZLc2liyiQ3fA/gvXQihmZjp
+spYf6kWBkI6+hx3AwM1Vg0FerAJAe9MnMZqZtu/pdqaxiPnbdm5lpB2FiLyrCvY+
+8cyISOPi9LRWZCsf24dUBVHJu4W+BULiZSwoakwLy7UxNclcBKrrIz3brm5UF2Xl
+CMqI3N+afaHDst2n1BjwX4InnU9p2FY5Em227hdoWWni+IR8fn0yUMz2ma/kgQ2/
+ntr3ursuq27kC3haWW47kitxK2fZIyjs03gQp2sH0u0ReDIt3EswvPWgjT+EkpjW
+NgXK7GyWVdjcJDciTnIBs/vvhkcZVuTgflYpFTbzRK1I1M2eXSjxmEKQ8vmA2wRr
+IFzrEcMOo5pTFnUxeOfpucV2j5uD8g8Uk9rxkOwaM1q9yipf5qd5MjJBKrqBuqaW
+3v9tKwCoJRTRWR+Y7SMjy2aB/Y2pRGMtmPOuUs4q81ket97Vp4R9ruIkIsEvVMg6
+hXWIhP7Or13f7Qr2Xh71Px7VJmMmfhBaXLEfJtD7kVmRAFzPK0QHYDCpLoka/7aZ
+AsrRP54XCkDTeTwhFkKLJW68a4s7+bLaHjaGgjb+62/J2CulVG6KDvlo3I2/yB8P
+0lWzWJdLJuRnPDPVZTB2HXKb/XJtw1MdcdvxvtzEbSM4naZ1YfYVXzT+zowq7kKk
+N0sgLv357q0HsylKT2Rvs94J0ackaiVaBQCHVReSfNPRwQ2IvjvEq3AML+vt06x7
+4lXiPtNsuAnkMA7whVWTdSZTvSPGxesWIS+3kTAybMPkum7KIL8xODARBgkqhkiG
+9w0BCRQxBB4CAGEwIwYJKoZIhvcNAQkVMRYEFNHrLDWGDljHU/wP6M74WxJsCr9m
+MD0wLTANBglghkgBZQMEAgQFAAQcG2U041U943EvoFbDQVXR7ZMuU8LZJ4EiaB6O
+owQIAiAhw9ZbovsCAggA
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/pkcs12/params/os5 Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,48 @@
+MIII0gIBAzCCCGgGCSqGSIb3DQEHAaCCCFkEgghVMIIIUTCCBRIGCSqGSIb3DQEH
+BqCCBQMwggT/AgEAMIIE+AYJKoZIhvcNAQcBMFcGCSqGSIb3DQEFDTBKMCkGCSqG
+SIb3DQEFDDAcBAgb15a0ITFWEQICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQME
+ASoEEC7w7N9MK45XaZg4OAPhmtWAggSQ2OAIm4D/rCA94AbcuQCpYxG8Td7v6cbY
+bnP9twj3Cvt5muXvMV32lMj/ucXPuICt5lXdBMhHVJ8jxJq3t8GBbJbIpmG/CzXv
+ImZa/Zt4TLBwKKibvaT6LHocCJAh3eRoHiXdje71KeVmu80d+ygl7w5/fnqc+FO6
+ypDx2OzcVTDMVnBdT9pD9eLCQQBxA8uvZFuY3C5GTONgE8WpvtqLHhjHLAff0T9N
+B6eNiFxqP3WVzobcNmOV0H/6Vn5YUcVk7kk5YtYBbeHo5mq7hkoMKtniQiGMd8Qh
+GYw6d+OPYBr+CDA/TsGApUxdqMNsdtyn83BEx/6y9BA4veWz54DU5o4PqnvV332V
+ZUa3cD+4r5yfRcM5AFCEOppvK5i/3aJllCsKn4yVzHpWn6vmL/qQCZU1epgONmzJ
+eCAOTPiDKkc5mJc4qj+ILIVuY+m+n/wNdWgrhr5zGzSGwHgaQMmnhCjF2BlAZL7m
+neIPDSqBImCVuA3MWPerkhW9SHbIiAXmIUN/DBI/fiPlryCSN/oMujLJgogADtks
+J4ml2zByChWcepayfpi+YVdIc+eNTjAqrW3iD26mnEqyWPjey+lFfvKmUffNnL46
+IMeN33WPjMLi0rmxqsPGLpK8rw81TE6qe8d4SXqgZfzV5uQFEOV/tGZ0QOuXgkc6
+YAsZlYz7QNdh9I7JhwTup/j4nPcgM5NJXvRCVq765MCzV/gdLeO2msuR/VlvIZon
+P9HTzqzOkCakT0nV/bdPAMGAhZt7iprgn1Gb/XiA9GK+ejeaZfRW4YJ6oqGI/5gS
+RNxdf9I5ThC9efFdPM+3WxKun4bSBjJZCBjAkRlse2nQt/ET51qAt8T1Uw0ON5ch
+NoHe/ZE9MNX5/9bt6T9w86Gh/Wfzq8K/93ywlbd7fNOJm/T8HH9yY1Lm3Hg4PgES
+feA3VL0JeTWnZu/ngLQ8JWRKKYjNg0BwejoKRZ3PEpnS1ZUxmjcJlgXGn2SWW99+
+j/dQgl80Tn/IJnAUBwxvDjmoWVvAGLglnNbruCWX/bjTg4cJyYVeSQ5fEHyi2pU/
++bcvVTK9HuWE7cT9rDP4rWPRaAi4UAB9AShx3jgh/g2Va8Tqpow1hqS2eSjm+JfQ
+Bk3Nh6dYDgqLW4OjCTVfRa4hzbNck5zcybY3JtC7jKjok31V87W1jPRveWgXYE0z
+AZlSRwgnzMujycpXplZ9JMz9QMB7toISVs+ArjN2CZRjLCWRAwLcoKQ7D1A5S8LU
+PYXk/y7ovmaSfyN1PYkaelnAuo2zI4YWDM/LL55het4Y8eCo0zFwLSxDrPz5jW8p
+A4S1Du5JJ7n52RYmI9+QxwymCUOkWScpIgI/aM6p4s3xfnqGMZUQy+O0qMsczSw0
+i9IVx/C8akDjK/gMlJePYqil/WPfEUl5qAkGn9eu2/kC4XNITiM9xNBDy1d+NvSO
+8CjBfDd3pOPqjqeM/dLO660ZZrsvt7LnevJQ+9pq9LeXIrcHpLJp2Oqq5o85lCn7
+/eoykT+ghu6L0OhYaIcDNMvxUAXJfVQQ0rMd+q/72VKdb2HGrB88CjCCAzcGCSqG
+SIb3DQEHAaCCAygEggMkMIIDIDCCAxwGCyqGSIb3DQEMCgECoIIC0TCCAs0wVwYJ
+KoZIhvcNAQUNMEowKQYJKoZIhvcNAQUMMBwECOnimmypiWZ5AgIIADAMBggqhkiG
+9w0CCQUAMB0GCWCGSAFlAwQBKgQQLT9O9V8VM45JpgROXv51VgSCAnAbjtRsnqGS
+hwCR6JP8T3ZpY1LUjZM7P/X0VcQ+Fq3cxHtY5Bf55+Ha8cQRGwnptlwnfgxILGIn
+1yseJSkKUTDTIlMpoFfDtLCU0lNWzwhYfbajUxIesYsgFYCYn94MgJ+Vb7MWbbW+
+KxhqSGWPDicCZ6dY2zNFUt4dnxJ1NYZGS4ZpfDmdh/bW29vT++Yi1H6Be1Qd+aMj
+a9+8Yb69AjnglujqOKTlzaXPb1DfnuteZKUZxqt/6TR1fh28KYxBJ6YvyDzkwhx/
+0ksy/+ItokRWZ9Bb2nmIiss352UtGEi2JOIN+QyOcvSCQCvPucW1DXg53dOhVvEZ
+Q1NNKvV9w8s8ao0GotqCK6lfu1fHo2yrp5dV3p03Xxzu1jeuZL27oSaHvW6on90s
+oV0djJUHHtYJOp1YWEOJOSqQsHsvPA4G9YMKx00Rl9P0aVSWTNqN96VjEzHOHyCX
+lzH5asHLbsTbnvhQHmq1J7Jm3RjncZ+oJOdcvkBoKUnYbqCHJiUOM7McRIEI0VkI
+0Endzm+U0z8jZxcpvAowgOf/sWC/ddr/1rNRE/BzVhmqvLfYOkIsvBwm6LpbiOgg
+fV0VUHZxTSk6uwYLfNQkJ7i/NQOCAo8MGIHAMi0e5/FAAE7mN2V2HfWCQOiXjsnD
+Twb9xztwa6u8tjCXLfW5sws958sxMMM23F61Q6aZcx0k+lc9VaiHgRUjiwKesZjn
+E3b/mKSFEIy/9dqC5SpmIctEmoQWcxNNntSzD6WkA0EP5pw0CoAzMSW2Mzp5D6kD
+/0pH6xjs9oaMmoq6SoTphNF9hsJJ/uXUSVtO8ZrKB0upHGl+Q5lwLeMxODARBgkq
+hkiG9w0BCRQxBB4CAGEwIwYJKoZIhvcNAQkVMRYEFNHrLDWGDljHU/wP6M74WxJs
+Cr9mMGEwUTANBglghkgBZQMEAgMFAARAjFxC6pnq5Gh874xeaWuQ+C9mmRbiqBaL
+MgfxIfJj3AFVFXGlm7xigHtZGFIrkXNC5croycYgTPMOczulADAOdgQIOFtoK+zm
+YOMCAggA
--- a/test/jdk/sun/security/tools/jarsigner/warnings/NoTimestampTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/NoTimestampTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -21,8 +21,13 @@
* questions.
*/
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.security.KeyStore;
+import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.Locale;
+
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.util.JarUtils;
@@ -61,16 +66,14 @@
Utils.createFiles(FIRST_FILE);
JarUtils.createJar(UNSIGNED_JARFILE, FIRST_FILE);
- // calculate certificate expiration date
- Date expirationDate = new Date(System.currentTimeMillis() + VALIDITY
- * 24 * 60 * 60 * 1000L);
-
// create key pair
createAlias(CA_KEY_ALIAS);
createAlias(KEY_ALIAS);
issueCert(KEY_ALIAS,
"-validity", Integer.toString(VALIDITY));
+ Date expirationDate = getCertExpirationDate();
+
// sign jar file
OutputAnalyzer analyzer = jarsigner(
"-J-Duser.timezone=" + timezone,
@@ -114,4 +117,12 @@
System.out.println("Test passed");
}
+ private static Date getCertExpirationDate() throws Exception {
+ KeyStore ks = KeyStore.getInstance("JKS");
+ try (InputStream in = new FileInputStream(KEYSTORE)) {
+ ks.load(in, PASSWORD.toCharArray());
+ }
+ X509Certificate cert = (X509Certificate) ks.getCertificate(KEY_ALIAS);
+ return cert.getNotAfter();
+ }
}
--- a/test/jdk/sun/security/tools/keytool/ProbingFailure.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/sun/security/tools/keytool/ProbingFailure.java Tue Dec 18 15:08:56 2018 -0500
@@ -62,7 +62,7 @@
kt("-list -keystore mks")
.shouldHaveExitValue(1)
- .shouldContain("This keystore does not support probing");
+ .shouldContain("Unrecognized keystore format");
// importkeystore
kt("-importkeystore -srckeystore mks -srcstoretype MYKS -destkeystore p12")
@@ -70,7 +70,7 @@
kt("-importkeystore -srckeystore mks -destkeystore p12a")
.shouldHaveExitValue(1)
- .shouldContain("This keystore does not support probing");
+ .shouldContain("Unrecognized keystore format");
// in-place importkeystore
kt("-importkeystore -srckeystore mks -srcstoretype MYKS -destkeystore mks -deststoretype myks")
--- a/test/jdk/tools/launcher/JliLaunchTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/jdk/tools/launcher/JliLaunchTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -49,10 +49,12 @@
Map<String, String> env = pb.environment();
if (Platform.isWindows()) {
// The DLL should be in JDK/bin
+ String libdir = Paths.get(Utils.TEST_JDK).resolve("bin").toAbsolutePath().toString();
+ env.compute("PATH", (k, v) -> (v == null) ? libdir : libdir + ";" + v);
} else {
String libdir = Paths.get(Utils.TEST_JDK).resolve("lib").toAbsolutePath().toString();
String LD_LIBRARY_PATH = Platform.isOSX() ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH";
- env.compute(LD_LIBRARY_PATH, (k, v) -> (k == null) ? libdir : v + ":" + libdir);
+ env.compute(LD_LIBRARY_PATH, (k, v) -> (v == null) ? libdir : libdir + ":" + v);
}
OutputAnalyzer outputf = new OutputAnalyzer(pb.start());
--- a/test/langtools/TEST.ROOT Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/TEST.ROOT Tue Dec 18 15:08:56 2018 -0500
@@ -15,7 +15,7 @@
groups=TEST.groups
# Minimum jtreg version
-requiredVersion=4.2 b12
+requiredVersion=4.2 b13
# Use new module options
useNewOptions=true
--- a/test/langtools/tools/javac/6330997/T6330997.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/6330997/T6330997.java Tue Dec 18 15:08:56 2018 -0500
@@ -32,8 +32,8 @@
* jdk.compiler/com.sun.tools.javac.main
* jdk.compiler/com.sun.tools.javac.util
* @clean T1 T2
- * @compile -source 11 -target 12 T1.java
- * @compile -source 11 -target 12 T2.java
+ * @compile -source 12 -target 13 T1.java
+ * @compile -source 12 -target 13 T2.java
* @run main/othervm T6330997
*/
--- a/test/langtools/tools/javac/ConditionalWithVoid.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/ConditionalWithVoid.java Tue Dec 18 15:08:56 2018 -0500
@@ -4,7 +4,7 @@
* @summary The compiler was allowing void types in its parsing of conditional expressions.
* @author tball
*
- * @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source 12 -XDrawDiagnostics ConditionalWithVoid.java
+ * @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source 13 -XDrawDiagnostics ConditionalWithVoid.java
*/
public class ConditionalWithVoid {
public void test(Object o, String s) {
--- a/test/langtools/tools/javac/RawStringLiteralLang.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/RawStringLiteralLang.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
/*
* @test
* @summary Unit tests for Raw String Literal language changes
- * @compile --enable-preview -source 12 -encoding utf8 RawStringLiteralLang.java
+ * @compile --enable-preview -source 13 -encoding utf8 RawStringLiteralLang.java
* @run main/othervm --enable-preview RawStringLiteralLang
*/
--- a/test/langtools/tools/javac/RawStringLiteralLangAPI.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/RawStringLiteralLangAPI.java Tue Dec 18 15:08:56 2018 -0500
@@ -130,7 +130,7 @@
new JavacTask(TOOLBOX)
.sources(code)
.classpath(".")
- .options("--enable-preview", "-source", "12")
+ .options("--enable-preview", "-source", "13")
.run();
String output = new JavaTask(TOOLBOX)
.vmOptions("--enable-preview")
@@ -153,7 +153,7 @@
String output = new JavacTask(TOOLBOX)
.sources(source)
.classpath(".")
- .options("--enable-preview", "-source", "12", "-encoding", "utf8")
+ .options("--enable-preview", "-source", "13", "-encoding", "utf8")
.run()
.writeAll()
.getOutput(Task.OutputKind.DIRECT);
@@ -170,7 +170,7 @@
String errors = new JavacTask(TOOLBOX)
.sources(source)
.classpath(".")
- .options("-XDrawDiagnostics", "--enable-preview", "-source", "12", "-encoding", "utf8")
+ .options("-XDrawDiagnostics", "--enable-preview", "-source", "13", "-encoding", "utf8")
.run(Task.Expect.FAIL)
.writeAll()
.getOutput(Task.OutputKind.DIRECT);
--- a/test/langtools/tools/javac/api/T6395981.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/api/T6395981.java Tue Dec 18 15:08:56 2018 -0500
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6395981 6458819 7025784 8028543 8028544 8193291 8193292 8193292
+ * @bug 6395981 6458819 7025784 8028543 8028544 8193291 8193292 8193292 8205393
* @summary JavaCompilerTool and Tool must specify version of JLS and JVMS
* @author Peter von der Ah\u00e9
* @modules java.compiler
@@ -31,7 +31,7 @@
* @run main/fail T6395981
* @run main/fail T6395981 RELEASE_3 RELEASE_5 RELEASE_6
* @run main/fail T6395981 RELEASE_0 RELEASE_1 RELEASE_2 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6
- * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 RELEASE_8 RELEASE_9 RELEASE_10 RELEASE_11 RELEASE_12
+ * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 RELEASE_8 RELEASE_9 RELEASE_10 RELEASE_11 RELEASE_12 RELEASE_13
*/
import java.util.EnumSet;
--- a/test/langtools/tools/javac/classfiles/ClassVersionChecker.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/classfiles/ClassVersionChecker.java Tue Dec 18 15:08:56 2018 -0500
@@ -47,7 +47,8 @@
NINE("9", 53),
TEN("10", 54),
ELEVEN("11", 55),
- TWELVE("12", 56);
+ TWELVE("12", 56),
+ THIRTEEN("13", 57);
private Version(String release, int classFileVer) {
this.release = release;
--- a/test/langtools/tools/javac/diags/examples/BreakAmbiguousTarget.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/BreakAmbiguousTarget.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.break.ambiguous.target
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class BreakAmbiguousTarget {
void m(int i, int j) {
--- a/test/langtools/tools/javac/diags/examples/BreakExprNotImmediate.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/BreakExprNotImmediate.java Tue Dec 18 15:08:56 2018 -0500
@@ -33,7 +33,7 @@
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// key: compiler.note.note
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
// run: backdoor
class BreakExprNotImmediate {
--- a/test/langtools/tools/javac/diags/examples/BreakMissingValue.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/BreakMissingValue.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.break.missing.value
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class BreakMissingValue {
int t(int i) {
--- a/test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.break.outside.switch.expression
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class BreakOutsideSwitchExpression {
int t(int i) {
--- a/test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.continue.outside.switch.expression
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class ContinueOutsideSwitchExpression {
int t(int i) {
--- a/test/langtools/tools/javac/diags/examples/IncompatibleTypesInSwitchExpression.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/IncompatibleTypesInSwitchExpression.java Tue Dec 18 15:08:56 2018 -0500
@@ -26,7 +26,7 @@
// key: compiler.misc.inconvertible.types
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class IncompatibleTypesInSwitchExpression {
--- a/test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java Tue Dec 18 15:08:56 2018 -0500
@@ -23,7 +23,7 @@
// key: compiler.misc.feature.multiple.case.labels
// key: compiler.warn.preview.feature.use.plural
-// options: --enable-preview -source 12 -Xlint:preview
+// options: --enable-preview -source 13 -Xlint:preview
class MultipleCaseLabels {
void m(int i) {
--- a/test/langtools/tools/javac/diags/examples/NotExhaustive.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/NotExhaustive.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.not.exhaustive
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class NotExhaustive {
int t(int i) {
--- a/test/langtools/tools/javac/diags/examples/PreviewFeatureUse.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/PreviewFeatureUse.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
//key: compiler.warn.preview.feature.use.plural
//key: compiler.misc.feature.diamond
//key: compiler.misc.feature.lambda
-//options: -Xlint:preview -XDforcePreview -source 12 --enable-preview
+//options: -Xlint:preview -XDforcePreview -source 13 --enable-preview
import java.util.ArrayList;
--- a/test/langtools/tools/javac/diags/examples/PreviewFilename.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/PreviewFilename.java Tue Dec 18 15:08:56 2018 -0500
@@ -23,7 +23,7 @@
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: -XDforcePreview -source 12 --enable-preview
+// options: -XDforcePreview -source 13 --enable-preview
import java.util.ArrayList;
import java.util.List;
--- a/test/langtools/tools/javac/diags/examples/PreviewFilenameAdditional.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/PreviewFilenameAdditional.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.note.preview.filename.additional
// key: compiler.warn.preview.feature.use
// key: compiler.misc.feature.diamond
-// options: -Xlint:preview -Xmaxwarns 1 -XDforcePreview -source 12 --enable-preview
+// options: -Xlint:preview -Xmaxwarns 1 -XDforcePreview -source 13 --enable-preview
import java.util.ArrayList;
--- a/test/langtools/tools/javac/diags/examples/PreviewPlural/PreviewPlural.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/PreviewPlural/PreviewPlural.java Tue Dec 18 15:08:56 2018 -0500
@@ -23,7 +23,7 @@
// key: compiler.note.preview.plural
// key: compiler.note.preview.recompile
-// options: -XDforcePreview -source 12 --enable-preview
+// options: -XDforcePreview -source 13 --enable-preview
import java.util.ArrayList;
--- a/test/langtools/tools/javac/diags/examples/RawStringLiteral.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/RawStringLiteral.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.unicode.backtick
// key: compiler.misc.feature.raw.string.literals
// key: compiler.warn.preview.feature.use.plural
-// options: --enable-preview -source 12 -Xlint:preview
+// options: --enable-preview -source 13 -Xlint:preview
class RawStringLiteral {
String m() {
--- a/test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.return.outside.switch.expression
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class ReturnOutsideSwitchExpression {
int t(int i) {
--- a/test/langtools/tools/javac/diags/examples/RuleCompletesNormally.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/RuleCompletesNormally.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.rule.completes.normally
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class RuleCompletesNormally {
public String convert(int i) {
--- a/test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.switch.case.unexpected.statement
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class ReturnOutsideSwitchExpression {
void t(int i) {
--- a/test/langtools/tools/javac/diags/examples/SwitchExpressionCompletesNormally.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionCompletesNormally.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.switch.expression.completes.normally
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class SwitchExpressionCompletesNormally {
public String convert(int i) {
--- a/test/langtools/tools/javac/diags/examples/SwitchExpressionEmpty.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionEmpty.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.switch.expression.empty
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class BreakOutsideSwitchExpression {
String t(E e) {
--- a/test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java Tue Dec 18 15:08:56 2018 -0500
@@ -26,7 +26,7 @@
// key: compiler.misc.switch.expression.target.cant.be.void
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class SwitchExpressionTargetCantBeVoid {
--- a/test/langtools/tools/javac/diags/examples/SwitchExpressions.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/SwitchExpressions.java Tue Dec 18 15:08:56 2018 -0500
@@ -23,7 +23,7 @@
// key: compiler.misc.feature.switch.expressions
// key: compiler.warn.preview.feature.use.plural
-// options: --enable-preview -source 12 -Xlint:preview
+// options: --enable-preview -source 13 -Xlint:preview
class SwitchExpressions {
int m(int i) {
--- a/test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java Tue Dec 18 15:08:56 2018 -0500
@@ -24,7 +24,7 @@
// key: compiler.err.switch.mixing.case.types
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
-// options: --enable-preview -source 12
+// options: --enable-preview -source 13
class SwitchMixingCaseTypes {
--- a/test/langtools/tools/javac/diags/examples/SwitchRules.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/diags/examples/SwitchRules.java Tue Dec 18 15:08:56 2018 -0500
@@ -23,7 +23,7 @@
// key: compiler.misc.feature.switch.rules
// key: compiler.warn.preview.feature.use.plural
-// options: --enable-preview -source 12 -Xlint:preview
+// options: --enable-preview -source 13 -Xlint:preview
class SwitchExpressions {
void m(int i) {
--- a/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -75,6 +75,8 @@
}
}
+ private static String[] PREVIEW_OPTIONS = {"--enable-preview", "-source", "13"};
+
private void program(String... constructs) {
String s = "class C { static boolean cond = false; static int x = 0; void m() { # } }";
for (String c : constructs)
@@ -84,7 +86,7 @@
private void assertOK(String... constructs) {
reset();
- addCompileOptions("--enable-preview", "-source", "12");
+ addCompileOptions(PREVIEW_OPTIONS);
program(constructs);
try {
compile();
@@ -97,7 +99,7 @@
private void assertOKWithWarning(String warning, String... constructs) {
reset();
- addCompileOptions("--enable-preview", "-source", "12");
+ addCompileOptions(PREVIEW_OPTIONS);
program(constructs);
try {
compile();
@@ -110,7 +112,7 @@
private void assertFail(String expectedDiag, String... constructs) {
reset();
- addCompileOptions("--enable-preview", "-source", "12");
+ addCompileOptions(PREVIEW_OPTIONS);
program(constructs);
try {
compile();
--- a/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Adding switch expressions
- * @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics --enable-preview -source 12 BadSwitchExpressionLambda.java
+ * @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics --enable-preview -source 13 BadSwitchExpressionLambda.java
*/
class BadSwitchExpressionLambda {
--- a/test/langtools/tools/javac/lib/JavacTestingAbstractProcessor.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/lib/JavacTestingAbstractProcessor.java Tue Dec 18 15:08:56 2018 -0500
@@ -110,7 +110,7 @@
* corresponding platform visitor type.
*/
- @SupportedSourceVersion(RELEASE_12)
+ @SupportedSourceVersion(RELEASE_13)
public static abstract class AbstractAnnotationValueVisitor<R, P> extends AbstractAnnotationValueVisitor9<R, P> {
/**
@@ -121,7 +121,7 @@
}
}
- @SupportedSourceVersion(RELEASE_12)
+ @SupportedSourceVersion(RELEASE_13)
public static abstract class AbstractElementVisitor<R, P> extends AbstractElementVisitor9<R, P> {
/**
* Constructor for concrete subclasses to call.
@@ -131,7 +131,7 @@
}
}
- @SupportedSourceVersion(RELEASE_12)
+ @SupportedSourceVersion(RELEASE_13)
public static abstract class AbstractTypeVisitor<R, P> extends AbstractTypeVisitor9<R, P> {
/**
* Constructor for concrete subclasses to call.
@@ -141,7 +141,7 @@
}
}
- @SupportedSourceVersion(RELEASE_12)
+ @SupportedSourceVersion(RELEASE_13)
public static class ElementKindVisitor<R, P> extends ElementKindVisitor9<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
@@ -162,7 +162,7 @@
}
}
- @SupportedSourceVersion(RELEASE_12)
+ @SupportedSourceVersion(RELEASE_13)
public static class ElementScanner<R, P> extends ElementScanner9<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
@@ -181,7 +181,7 @@
}
}
- @SupportedSourceVersion(RELEASE_12)
+ @SupportedSourceVersion(RELEASE_13)
public static class SimpleAnnotationValueVisitor<R, P> extends SimpleAnnotationValueVisitor9<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
@@ -202,7 +202,7 @@
}
}
- @SupportedSourceVersion(RELEASE_12)
+ @SupportedSourceVersion(RELEASE_13)
public static class SimpleElementVisitor<R, P> extends SimpleElementVisitor9<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
@@ -223,7 +223,7 @@
}
}
- @SupportedSourceVersion(RELEASE_12)
+ @SupportedSourceVersion(RELEASE_13)
public static class SimpleTypeVisitor<R, P> extends SimpleTypeVisitor9<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
@@ -244,7 +244,7 @@
}
}
- @SupportedSourceVersion(RELEASE_12)
+ @SupportedSourceVersion(RELEASE_13)
public static class TypeKindVisitor<R, P> extends TypeKindVisitor9<R, P> {
/**
* Constructor for concrete subclasses to call; uses {@code null}
--- a/test/langtools/tools/javac/parser/JavacParserTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/parser/JavacParserTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -1096,7 +1096,7 @@
String expectedErrors = "Test.java:1:178: compiler.err.switch.case.unexpected.statement\n";
StringWriter out = new StringWriter();
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(out, fm, null,
- Arrays.asList("-XDrawDiagnostics", "--enable-preview", "-source", "12"),
+ Arrays.asList("-XDrawDiagnostics", "--enable-preview", "-source", "13"),
null, Arrays.asList(new MyFileObject(code)));
CompilationUnitTree cut = ct.parse().iterator().next();
--- a/test/langtools/tools/javac/platform/CanHandleClassFilesTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/platform/CanHandleClassFilesTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -26,8 +26,11 @@
* @bug 8207954
* @summary Verify that CreateSymbols can handle classfiles from the current release.
* @library /tools/lib /tools/javac/lib
- * @modules jdk.compiler/com.sun.tools.javac.api
+ * @modules jdk.compiler/com.sun.tools.javac.api:+open
* jdk.compiler/com.sun.tools.javac.main
+ * jdk.compiler/com.sun.tools.javac.jvm:+open
+ * jdk.compiler/com.sun.tools.javac.util:+open
+ * jdk.jdeps/com.sun.tools.classfile:+open
* @build toolbox.ToolBox toolbox.JavacTask toolbox.Task
* @run main CanHandleClassFilesTest
*/
@@ -36,6 +39,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.stream.Stream;
import javax.tools.StandardLocation;
@@ -93,8 +97,16 @@
}
};
+ // open the non-exported packages needed by CreateSymbols to its module
+ Module targetModule = cl.getUnnamedModule();
+ Stream.of("jdk.compiler/com.sun.tools.javac.api",
+ "jdk.compiler/com.sun.tools.javac.jvm",
+ "jdk.compiler/com.sun.tools.javac.util",
+ "jdk.jdeps/com.sun.tools.classfile")
+ .forEach(p -> open(p, targetModule));
+
var createSymbolsClass = Class.forName("build.tools.symbolgenerator.CreateSymbols", false, cl);
- var main = createSymbolsClass.getDeclaredMethod("main", String[].class);
+ var main = createSymbolsClass.getMethod("main", String[].class);
var symbols = targetDir.resolve("symbols");
try (Writer w = Files.newBufferedWriter(symbols)) {}
@@ -112,4 +124,11 @@
}
}
+ void open(String moduleAndPackage, Module target) {
+ String[] s = moduleAndPackage.split("/");
+ var moduleName = s[0];
+ var packageName = s[1];
+ ModuleLayer.boot().findModule(moduleName).orElseThrow().addOpens(packageName, target);
+ }
+
}
--- a/test/langtools/tools/javac/preview/classReaderTest/Client.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/preview/classReaderTest/Client.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,9 +2,9 @@
* @test /nodynamiccopyright/
* @bug 8199194
* @summary smoke test for --enabled-preview classreader support
- * @compile -XDforcePreview --enable-preview -source 12 Bar.java
+ * @compile -XDforcePreview --enable-preview -source 13 Bar.java
* @compile/fail/ref=Client.nopreview.out -Xlint:preview -XDrawDiagnostics Client.java
- * @compile/fail/ref=Client.preview.out -Werror -Xlint:preview -XDrawDiagnostics --enable-preview -source 12 Client.java
+ * @compile/fail/ref=Client.preview.out -Werror -Xlint:preview -XDrawDiagnostics --enable-preview -source 13 Client.java
*/
public class Client {
--- a/test/langtools/tools/javac/preview/classReaderTest/Client.nopreview.out Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/preview/classReaderTest/Client.nopreview.out Tue Dec 18 15:08:56 2018 -0500
@@ -1,2 +1,2 @@
-- compiler.err.preview.feature.disabled.classfile: Bar.class, 12
+- compiler.err.preview.feature.disabled.classfile: Bar.class, 13
1 error
--- a/test/langtools/tools/javac/preview/classReaderTest/Client.preview.out Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/preview/classReaderTest/Client.preview.out Tue Dec 18 15:08:56 2018 -0500
@@ -1,4 +1,4 @@
-- compiler.warn.preview.feature.use.classfile: Bar.class, 12
+- compiler.warn.preview.feature.use.classfile: Bar.class, 13
- compiler.err.warnings.and.werror
1 error
1 warning
--- a/test/langtools/tools/javac/profiles/ProfileOptionTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/profiles/ProfileOptionTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -151,6 +151,7 @@
case JDK1_10:
case JDK1_11:
case JDK1_12:
+ case JDK1_13:
if (p == Profile.DEFAULT)
break;
if (ise == null)
--- a/test/langtools/tools/javac/switchexpr/BlockExpression.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/BlockExpression.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986
* @summary Verify rule cases with expression statements and throw statements work.
- * @compile --enable-preview -source 12 BlockExpression.java
+ * @compile --enable-preview -source 13 BlockExpression.java
* @run main/othervm --enable-preview BlockExpression
*/
--- a/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Verify the type of a conditional expression with nested switch expression is computed properly
- * @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics --enable-preview -source 12 BooleanNumericNonNumeric.java
+ * @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics --enable-preview -source 13 BooleanNumericNonNumeric.java
*/
public class BooleanNumericNonNumeric {
--- a/test/langtools/tools/javac/switchexpr/BreakTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/BreakTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -66,7 +66,7 @@
StringWriter out = new StringWriter();
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
- List.of("-XDdev", "--enable-preview", "-source", "12"), null,
+ List.of("-XDdev", "--enable-preview", "-source", "13"), null,
Arrays.asList(new MyFileObject(CODE)));
List<String> labels = new ArrayList<>();
new TreePathScanner<Void, Void>() {
--- a/test/langtools/tools/javac/switchexpr/CRT.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/CRT.java Tue Dec 18 15:08:56 2018 -0500
@@ -151,7 +151,7 @@
new JavacTask(tb)
.options("-Xjcov",
"--enable-preview",
- "-source", "12")
+ "-source", "13")
.outdir(classes)
.sources("public class Test {\n" +
code +
--- a/test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8214031
* @summary Verify that definite assignment when true works (legal code)
- * @compile --enable-preview --source 12 DefiniteAssignment1.java
+ * @compile --enable-preview --source 13 DefiniteAssignment1.java
* @run main/othervm --enable-preview DefiniteAssignment1
*/
public class DefiniteAssignment1 {
--- a/test/langtools/tools/javac/switchexpr/DefiniteAssignment2.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/DefiniteAssignment2.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8214031
* @summary Verify that definite assignment when true works (illegal code)
- * @compile/fail/ref=DefiniteAssignment2.out --enable-preview --source 12 -XDrawDiagnostics DefiniteAssignment2.java
+ * @compile/fail/ref=DefiniteAssignment2.out --enable-preview --source 13 -XDrawDiagnostics DefiniteAssignment2.java
*/
public class DefiniteAssignment2 {
--- a/test/langtools/tools/javac/switchexpr/EmptySwitch.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/EmptySwitch.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986
* @summary Verify than an empty switch expression is rejected.
- * @compile/fail/ref=EmptySwitch.out --enable-preview -source 12 -XDrawDiagnostics EmptySwitch.java
+ * @compile/fail/ref=EmptySwitch.out --enable-preview -source 13 -XDrawDiagnostics EmptySwitch.java
*/
public class EmptySwitch {
--- a/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986
* @summary Verify that an switch expression over enum can be exhaustive without default.
- * @compile --enable-preview -source 12 ExhaustiveEnumSwitch.java
+ * @compile --enable-preview -source 13 ExhaustiveEnumSwitch.java
* @compile ExhaustiveEnumSwitchExtra.java
* @run main/othervm --enable-preview ExhaustiveEnumSwitch
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java Tue Dec 18 15:08:56 2018 -0500
@@ -3,7 +3,7 @@
* @bug 8206986
* @summary Check expression switch works.
* @compile/fail/ref=ExpressionSwitch-old.out -source 9 -Xlint:-options -XDrawDiagnostics ExpressionSwitch.java
- * @compile --enable-preview -source 12 ExpressionSwitch.java
+ * @compile --enable-preview -source 13 ExpressionSwitch.java
* @run main/othervm --enable-preview ExpressionSwitch
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986
* @summary Verify behavior of various kinds of breaks.
- * @compile --enable-preview -source 12 ExpressionSwitchBreaks1.java
+ * @compile --enable-preview -source 13 ExpressionSwitchBreaks1.java
* @run main/othervm --enable-preview ExpressionSwitchBreaks1
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Check behavior for invalid breaks.
- * @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics --enable-preview -source 12 ExpressionSwitchBreaks2.java
+ * @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics --enable-preview -source 13 ExpressionSwitchBreaks2.java
*/
public class ExpressionSwitchBreaks2 {
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986 8214114 8214529
* @summary Verify various corner cases with nested switch expressions.
- * @compile --enable-preview -source 12 ExpressionSwitchBugs.java
+ * @compile --enable-preview -source 13 ExpressionSwitchBugs.java
* @run main/othervm --enable-preview ExpressionSwitchBugs
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugsInGen.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugsInGen.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8214031
* @summary Verify various corner cases with nested switch expressions.
- * @compile --enable-preview -source 12 ExpressionSwitchBugsInGen.java
+ * @compile --enable-preview -source 13 ExpressionSwitchBugsInGen.java
* @run main/othervm --enable-preview ExpressionSwitchBugsInGen
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986
* @summary Check switch expressions
- * @compile --enable-preview -source 12 ExpressionSwitchCodeFromJLS.java
+ * @compile --enable-preview -source 13 ExpressionSwitchCodeFromJLS.java
* @run main/othervm --enable-preview ExpressionSwitchCodeFromJLS
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986
* @summary Check definite (un)assignment for in switch expressions.
- * @compile --enable-preview -source 12 ExpressionSwitchDA.java
+ * @compile --enable-preview -source 13 ExpressionSwitchDA.java
* @run main/othervm --enable-preview ExpressionSwitchDA
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchEmbedding.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchEmbedding.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8214031 8214114
* @summary Verify switch expressions embedded in various statements work properly.
- * @compile --enable-preview -source 12 ExpressionSwitchEmbedding.java
+ * @compile --enable-preview -source 13 ExpressionSwitchEmbedding.java
* @run main/othervm --enable-preview ExpressionSwitchEmbedding
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986
* @summary Check fall through in switch expressions.
- * @compile --enable-preview -source 12 ExpressionSwitchFallThrough.java
+ * @compile --enable-preview -source 13 ExpressionSwitchFallThrough.java
* @run main/othervm --enable-preview ExpressionSwitchFallThrough
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986
* @summary Check fall through in switch expressions.
- * @compile --enable-preview -source 12 ExpressionSwitchFallThrough1.java
+ * @compile --enable-preview -source 13 ExpressionSwitchFallThrough1.java
* @run main/othervm --enable-preview ExpressionSwitchFallThrough1
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8212982
* @summary Verify a compile-time error is produced if switch expression does not provide a value
- * @compile/fail/ref=ExpressionSwitchFlow.out --enable-preview -source 12 -XDrawDiagnostics ExpressionSwitchFlow.java
+ * @compile/fail/ref=ExpressionSwitchFlow.out --enable-preview -source 13 -XDrawDiagnostics ExpressionSwitchFlow.java
*/
public class ExpressionSwitchFlow {
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986
* @summary Check switch expressions embedded in switch expressions.
- * @compile --enable-preview -source 12 ExpressionSwitchInExpressionSwitch.java
+ * @compile --enable-preview -source 13 ExpressionSwitchInExpressionSwitch.java
* @run main/othervm --enable-preview ExpressionSwitchInExpressionSwitch
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Check types inferred for switch expressions.
- * @compile/fail/ref=ExpressionSwitchInfer.out -XDrawDiagnostics --enable-preview -source 12 ExpressionSwitchInfer.java
+ * @compile/fail/ref=ExpressionSwitchInfer.out -XDrawDiagnostics --enable-preview -source 13 ExpressionSwitchInfer.java
*/
import java.util.ArrayList;
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8206986
* @summary Verify behavior when an intersection type is inferred for switch expression.
- * @compile --enable-preview -source 12 ExpressionSwitchIntersectionTypes.java
+ * @compile --enable-preview -source 13 ExpressionSwitchIntersectionTypes.java
* @run main/othervm --enable-preview ExpressionSwitchIntersectionTypes
*/
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Verify behavior of not exhaustive switch expressions.
- * @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics --enable-preview -source 12 ExpressionSwitchNotExhaustive.java
+ * @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics --enable-preview -source 13 ExpressionSwitchNotExhaustive.java
*/
public class ExpressionSwitchNotExhaustive {
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Verify reachability in switch expressions.
- * @compile/fail/ref=ExpressionSwitchUnreachable.out -XDrawDiagnostics --enable-preview -source 12 ExpressionSwitchUnreachable.java
+ * @compile/fail/ref=ExpressionSwitchUnreachable.out -XDrawDiagnostics --enable-preview -source 13 ExpressionSwitchUnreachable.java
*/
public class ExpressionSwitchUnreachable {
--- a/test/langtools/tools/javac/switchexpr/ParseIncomplete.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ParseIncomplete.java Tue Dec 18 15:08:56 2018 -0500
@@ -67,7 +67,7 @@
StringWriter out = new StringWriter();
try {
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
- List.of("-XDdev", "--enable-preview", "-source", "12"), null,
+ List.of("-XDdev", "--enable-preview", "-source", "13"), null,
Arrays.asList(new MyFileObject(code)));
ct.parse().iterator().next();
} catch (Throwable t) {
--- a/test/langtools/tools/javac/switchexpr/ParserRecovery.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/ParserRecovery.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Verify the parser handles broken input gracefully.
- * @compile/fail/ref=ParserRecovery.out -XDrawDiagnostics --enable-preview -source 12 ParserRecovery.java
+ * @compile/fail/ref=ParserRecovery.out -XDrawDiagnostics --enable-preview -source 13 ParserRecovery.java
*/
public class ParserRecovery {
--- a/test/langtools/tools/javac/switchexpr/SwitchExpressionIsNotAConstant.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/SwitchExpressionIsNotAConstant.java Tue Dec 18 15:08:56 2018 -0500
@@ -26,7 +26,7 @@
* @bug 8214113
* @summary Verify the switch expression's type does not have a constant attached,
* and so the switch expression is not elided.
- * @compile --enable-preview --source 12 SwitchExpressionIsNotAConstant.java
+ * @compile --enable-preview --source 13 SwitchExpressionIsNotAConstant.java
* @run main/othervm --enable-preview SwitchExpressionIsNotAConstant
*/
public class SwitchExpressionIsNotAConstant {
--- a/test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Verify that scopes in rule cases are isolated.
- * @compile/fail/ref=SwitchExpressionScopesIsolated.out -XDrawDiagnostics --enable-preview -source 12 SwitchExpressionScopesIsolated.java
+ * @compile/fail/ref=SwitchExpressionScopesIsolated.out -XDrawDiagnostics --enable-preview -source 13 SwitchExpressionScopesIsolated.java
*/
public class SwitchExpressionScopesIsolated {
--- a/test/langtools/tools/javac/switchexpr/SwitchExpressionSimpleVisitorTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/SwitchExpressionSimpleVisitorTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -89,7 +89,7 @@
StringWriter out = new StringWriter();
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
- List.of("--enable-preview", "-source", "12"), null,
+ List.of("--enable-preview", "-source", "13"), null,
Arrays.asList(new MyFileObject(code)));
return ct.parse().iterator().next();
}
--- a/test/langtools/tools/javac/switchexpr/TryCatch.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchexpr/TryCatch.java Tue Dec 18 15:08:56 2018 -0500
@@ -25,7 +25,7 @@
* @test
* @bug 8214114
* @summary Verify try-catch inside a switch expression works properly.
- * @compile --enable-preview -source 12 TryCatch.java
+ * @compile --enable-preview -source 13 TryCatch.java
* @run main/othervm --enable-preview TryCatch
*/
public class TryCatch {
--- a/test/langtools/tools/javac/switchextra/CaseTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchextra/CaseTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -136,7 +136,7 @@
StringWriter out = new StringWriter();
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
- List.of("-XDdev", "--enable-preview", "-source", "12"), null,
+ List.of("-XDdev", "--enable-preview", "-source", "13"), null,
Arrays.asList(new MyFileObject(code)));
return ct.parse().iterator().next();
}
--- a/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java Tue Dec 18 15:08:56 2018 -0500
@@ -3,7 +3,7 @@
* @bug 8206986
* @summary Verify cases with multiple labels work properly.
* @compile/fail/ref=MultipleLabelsExpression-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsExpression.java
- * @compile --enable-preview -source 12 MultipleLabelsExpression.java
+ * @compile --enable-preview -source 13 MultipleLabelsExpression.java
* @run main/othervm --enable-preview MultipleLabelsExpression
*/
--- a/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java Tue Dec 18 15:08:56 2018 -0500
@@ -3,7 +3,7 @@
* @bug 8206986
* @summary Verify cases with multiple labels work properly.
* @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
- * @compile --enable-preview -source 12 MultipleLabelsStatement.java
+ * @compile --enable-preview -source 13 MultipleLabelsStatement.java
* @run main/othervm --enable-preview MultipleLabelsStatement
*/
--- a/test/langtools/tools/javac/switchextra/RuleParsingTest.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchextra/RuleParsingTest.java Tue Dec 18 15:08:56 2018 -0500
@@ -94,7 +94,7 @@
StringWriter out = new StringWriter();
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
- List.of("--enable-preview", "-source", "12"), null,
+ List.of("--enable-preview", "-source", "13"), null,
Arrays.asList(new MyFileObject(code.toString())));
CompilationUnitTree cut = ct.parse().iterator().next();
Trees trees = Trees.instance(ct);
--- a/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.java Tue Dec 18 15:08:56 2018 -0500
@@ -3,7 +3,7 @@
* @bug 8206986
* @summary Verify reasonable errors are produced when neither ':' nor '->'
* is found are the expression of a case
- * @compile/fail/ref=SwitchArrowBrokenConstant.out -source 12 --enable-preview -Xlint:-preview -XDrawDiagnostics SwitchArrowBrokenConstant.java
+ * @compile/fail/ref=SwitchArrowBrokenConstant.out -source 13 --enable-preview -Xlint:-preview -XDrawDiagnostics SwitchArrowBrokenConstant.java
*/
public class SwitchArrowBrokenConstant {
--- a/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java Tue Dec 18 15:08:56 2018 -0500
@@ -3,7 +3,7 @@
* @bug 8206986
* @summary Verify rule cases work properly.
* @compile/fail/ref=SwitchStatementArrow-old.out -source 9 -Xlint:-options -XDrawDiagnostics SwitchStatementArrow.java
- * @compile --enable-preview -source 12 SwitchStatementArrow.java
+ * @compile --enable-preview -source 13 SwitchStatementArrow.java
* @run main/othervm --enable-preview SwitchStatementArrow
*/
--- a/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Verify that rule and ordinary cases cannot be mixed.
- * @compile/fail/ref=SwitchStatementBroken.out -XDrawDiagnostics --enable-preview -source 12 SwitchStatementBroken.java
+ * @compile/fail/ref=SwitchStatementBroken.out -XDrawDiagnostics --enable-preview -source 13 SwitchStatementBroken.java
*/
public class SwitchStatementBroken {
--- a/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Verify that not allowed types of statements cannot be used in rule case.
- * @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source 12 SwitchStatementBroken2.java
+ * @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source 13 SwitchStatementBroken2.java
*/
public class SwitchStatementBroken2 {
--- a/test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.java Tue Dec 18 15:08:56 2018 -0500
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Verify that scopes in rule cases are isolated.
- * @compile/fail/ref=SwitchStatementScopesIsolated.out -XDrawDiagnostics --enable-preview -source 12 SwitchStatementScopesIsolated.java
+ * @compile/fail/ref=SwitchStatementScopesIsolated.out -XDrawDiagnostics --enable-preview -source 13 SwitchStatementScopesIsolated.java
*/
public class SwitchStatementScopesIsolated {
--- a/test/langtools/tools/javac/versions/Versions.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/langtools/tools/javac/versions/Versions.java Tue Dec 18 15:08:56 2018 -0500
@@ -69,9 +69,9 @@
Set.of("1.2", "1.3", "1.4", "1.5", "1.6");
public static final Set<String> VALID_SOURCES =
- Set.of("1.7", "1.8", "1.9", "1.10", "11", "12");
+ Set.of("1.7", "1.8", "1.9", "1.10", "11", "12", "13");
- public static final String LATEST_MAJOR_VERSION = "56.0";
+ public static final String LATEST_MAJOR_VERSION = "57.0";
static enum SourceTarget {
SEVEN(true, "51.0", "7", Versions::checksrc17),
@@ -79,7 +79,8 @@
NINE(true, "53.0", "9", Versions::checksrc19),
TEN(true, "54.0", "10", Versions::checksrc110),
ELEVEN(false, "55.0", "11", Versions::checksrc111),
- TWELVE(false, "56.0", "12", Versions::checksrc112);
+ TWELVE(false, "56.0", "12", Versions::checksrc112),
+ THIRTEEN(false, "57.0", "13", Versions::checksrc113);
private final boolean dotOne;
private final String classFileVer;
@@ -293,6 +294,11 @@
checksrc111(args);
}
+ protected void checksrc113(String... args) {
+ printargs("checksrc113", args);
+ checksrc111(args);
+ }
+
protected void pass(String... args) {
printargs("pass", args);
--- a/test/lib/jdk/test/lib/jfr/Events.java Wed Dec 12 08:38:45 2018 -0500
+++ b/test/lib/jdk/test/lib/jfr/Events.java Tue Dec 18 15:08:56 2018 -0500
@@ -33,12 +33,16 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
+import java.time.Duration;
+import java.time.Instant;
import java.util.List;
import jdk.jfr.AnnotationElement;
import jdk.jfr.EventType;
import jdk.jfr.Recording;
import jdk.jfr.SettingDescriptor;
+import jdk.jfr.Timespan;
+import jdk.jfr.Timestamp;
import jdk.jfr.ValueDescriptor;
import jdk.jfr.consumer.RecordingFile;
import jdk.test.lib.Asserts;
@@ -183,6 +187,49 @@
assertThread(assertField(event, structName).notNull().getValue(), thread);
}
+ public static void assertDuration(RecordedEvent event, String name, Duration duration) {
+ assertEquals(event.getDuration(name), duration);
+ }
+
+ public static void assertInstant(RecordedEvent event, String name, Instant instant) {
+ assertEquals(event.getInstant(name), instant);
+ }
+
+ public static void assertMissingValue(RecordedEvent event, String name) {
+ ValueDescriptor v = event.getEventType().getField(name);
+ if (v.getAnnotation(Timespan.class) != null) {
+ Duration d = event.getDuration(name);
+ assertTrue(d.getSeconds() == Long.MIN_VALUE && d.getNano() == 0);
+ return;
+ }
+ if (v.getAnnotation(Timestamp.class) != null) {
+ Instant instant = event.getInstant(name);
+ assertTrue(instant.equals(Instant.MIN));
+ return;
+ }
+ if (v.getTypeName().equals("double")) {
+ double d = event.getDouble(name);
+ assertTrue(Double.isNaN(d) || d == Double.NEGATIVE_INFINITY);
+ return;
+ }
+ if (v.getTypeName().equals("float")) {
+ float f = event.getFloat(name);
+ assertTrue(Float.isNaN(f) || f == Float.NEGATIVE_INFINITY);
+ return;
+ }
+ if (v.getTypeName().equals("int")) {
+ int i = event.getInt(name);
+ assertTrue(i == Integer.MIN_VALUE);
+ return;
+ }
+ if (v.getTypeName().equals("long")) {
+ assertEquals(event.getLong(name), Long.MIN_VALUE);
+ return;
+ }
+ Object o = event.getValue(name);
+ Asserts.assertNull(o);
+ }
+
private static void assertThread(RecordedThread eventThread, Thread thread) {
assertNotNull(eventThread, "Thread in event was null");
assertEquals(eventThread.getJavaThreadId(), thread.getId(), "Wrong thread id");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/security/DerUtils.java Tue Dec 18 15:08:56 2018 -0500
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.test.lib.security;
+
+import jdk.test.lib.Asserts;
+import sun.security.util.DerInputStream;
+import sun.security.util.DerValue;
+import sun.security.util.ObjectIdentifier;
+
+import java.io.IOException;
+
+public class DerUtils {
+ /**
+ * Returns a DerValue (deep) inside another DerValue.
+ * <p>
+ * The location of the inner DerValue is expressed as a string, in which
+ * each character is a step from the outer DerValue into the inner one.
+ * If it's a number n, the n'th element (starting from 0) of a sequence
+ * is the next step. If it's 'c', the content of an OctetString parsed
+ * as a DerValue is the next step. Note that n cannot be bigger than 9.
+ * <p>
+ * Attention: do not reuse the return value. DerValue is mutable and
+ * reading it advances a pointer inside.
+ * <p>
+ * For example, here is a PKCS #12 file:
+ * <pre>
+ * 0000:0845 [] SEQUENCE
+ * 0004:0003 [0] INTEGER 3
+ * 0007:07FE [1] SEQUENCE
+ * 000B:000B [10] OID 1.2.840.113549.1.7.1 (data)
+ * 0016:07EF [11] cont [0]
+ * 001A:07EB [110] OCTET STRING
+ * ...
+ * </pre>
+ * and the content of OCTET string at offset 001A can be parsed as another
+ * DerValue which is:
+ * <pre>
+ * 0000:07E7 [] SEQUENCE
+ * 0004:0303 [0] SEQUENCE
+ * 0008:000B [00] OID 1.2.840.113549.1.7.1 (data)
+ * ....
+ * </pre>
+ * Then the OID is {@code innerDerValue(data, "110c00").getOID()}.
+ *
+ * @param data the outer DerValue. We choose byte[] instead of DerValue
+ * because DerValue is mutable and cannot be reused.
+ * @param location the location of the inner DerValue
+ * @return the inner DerValue, or null if no DerValue is at the location
+ * @throws IOException if an I/O error happens
+ */
+ public static DerValue innerDerValue(byte[] data, String location)
+ throws IOException {
+
+ DerValue v = new DerValue(data);
+ for (char step : location.toCharArray()) {
+ if (step == 'c') {
+ v = new DerValue(v.getOctetString());
+ } else {
+ DerInputStream ins = v.getData();
+ // skip n DerValue in the sequence
+ for (int i = 0; i < step - '0'; i++) {
+ ins.getDerValue();
+ }
+ if (ins.available() > 0) {
+ v = ins.getDerValue();
+ } else {
+ return null;
+ }
+ }
+ }
+ return v;
+ }
+
+ /**
+ * Ensures that the inner DerValue is the expected ObjectIdentifier.
+ */
+ public static void checkAlg(byte[] der, String location,
+ ObjectIdentifier expected) throws Exception {
+ Asserts.assertEQ(innerDerValue(der, location).getOID(), expected);
+ }
+
+ /**
+ * Ensures that the inner DerValue is the expected integer.
+ */
+ public static void checkInt(byte[] der, String location, int expected)
+ throws Exception {
+ Asserts.assertEQ(innerDerValue(der, location).getInteger(), expected);
+ }
+
+ /**
+ * Ensures that there is no inner DerValue at the specified location.
+ */
+ public static void shouldNotExist(byte[] der, String location)
+ throws Exception {
+ Asserts.assertTrue(innerDerValue(der, location) == null);
+ }
+}
--- a/test/nashorn/TEST.ROOT Wed Dec 12 08:38:45 2018 -0500
+++ b/test/nashorn/TEST.ROOT Tue Dec 18 15:08:56 2018 -0500
@@ -8,7 +8,7 @@
groups=TEST.groups
# Minimum jtreg version
-requiredVersion=4.2 b12
+requiredVersion=4.2 b13
# Use new module options
useNewOptions=true