--- a/.hgtags Sat Mar 09 12:52:30 2019 +0000
+++ b/.hgtags Sat Mar 09 12:54:20 2019 +0000
@@ -547,3 +547,4 @@
c081f3ea6b9300265a4a34e38f970b1e3ddaae9f jdk-13+9
b67884871b5fff79c5ef3eb8ac74dd48d71ea9b1 jdk-12+33
8e069f7b4fabfe05d9f500783e6d56cb0196d25c jdk-13+10
+21ea4076a275a0f498afa517e9ee1b94a9cf0255 jdk-13+11
--- a/doc/building.html Sat Mar 09 12:52:30 2019 +0000
+++ b/doc/building.html Sat Mar 09 12:54:20 2019 +0000
@@ -237,7 +237,7 @@
<p>For rpm-based distributions (Fedora, Red Hat, etc), try this:</p>
<pre><code>sudo yum groupinstall "Development Tools"</code></pre>
<h3 id="aix">AIX</h3>
-<p>The regular builds by SAP is using AIX version 7.1, but AIX 5.3 is also supported. See the <a href="http://cr.openjdk.java.net/~simonis/ppc-aix-port">OpenJDK PowerPC Port Status Page</a> for details.</p>
+<p>Please consult the AIX section of the <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a> OpenJDK Build Wiki page for details about which versions of AIX are supported.</p>
<h2 id="native-compiler-toolchain-requirements">Native Compiler (Toolchain) Requirements</h2>
<p>Large portions of the JDK consists of native code, that needs to be compiled to be able to run on the target platform. In theory, toolchain and operating system should be independent factors, but in practice there's more or less a one-to-one correlation between target operating system and toolchain.</p>
<table>
@@ -373,8 +373,7 @@
<p>If you have multiple versions of Visual Studio installed, <code>configure</code> will by default pick the latest. You can request a specific version to be used by setting <code>--with-toolchain-version</code>, e.g. <code>--with-toolchain-version=2015</code>.</p>
<p>If you get <code>LINK: fatal error LNK1123: failure during conversion to COFF: file invalid</code> when building using Visual Studio 2010, you have encountered <a href="http://support.microsoft.com/kb/2757355">KB2757355</a>, a bug triggered by a specific installation order. However, the solution suggested by the KB article does not always resolve the problem. See <a href="https://stackoverflow.com/questions/10888391">this stackoverflow discussion</a> for other suggestions.</p>
<h3 id="ibm-xl-cc">IBM XL C/C++</h3>
-<p>The regular builds by SAP is using version 12.1, described as <code>IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72) Version: 12.01.0000.0017</code>.</p>
-<p>See the <a href="http://cr.openjdk.java.net/~simonis/ppc-aix-port">OpenJDK PowerPC Port Status Page</a> for details.</p>
+<p>Please consult the AIX section of the <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a> OpenJDK Build Wiki page for details about which versions of XLC are supported.</p>
<h2 id="boot-jdk-requirements">Boot JDK Requirements</h2>
<p>Paradoxically, building the JDK requires a pre-existing JDK. This is called the "boot JDK". The boot JDK does not, however, have to be a JDK built directly from the source code available in the OpenJDK Community. If you are porting the JDK to a new platform, chances are that there already exists another JDK for that platform that is usable as boot JDK.</p>
<p>The rule of thumb is that the boot JDK for building JDK major version <em>N</em> should be a JDK of major version <em>N-1</em>, so for building JDK 9 a JDK 8 would be suitable as boot JDK. However, the JDK should be able to "build itself", so an up-to-date build of the current JDK source is an acceptable alternative. If you are following the <em>N-1</em> rule, make sure you've got the latest update version, since JDK 8 GA might not be able to build JDK 9 on all platforms.</p>
--- a/doc/building.md Sat Mar 09 12:52:30 2019 +0000
+++ b/doc/building.md Sat Mar 09 12:54:20 2019 +0000
@@ -295,9 +295,9 @@
### AIX
-The regular builds by SAP is using AIX version 7.1, but AIX 5.3 is also
-supported. See the [OpenJDK PowerPC Port Status Page](
-http://cr.openjdk.java.net/~simonis/ppc-aix-port) for details.
+Please consult the AIX section of the [Supported Build Platforms](
+https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms) OpenJDK
+Build Wiki page for details about which versions of AIX are supported.
## Native Compiler (Toolchain) Requirements
@@ -419,11 +419,10 @@
### IBM XL C/C++
-The regular builds by SAP is using version 12.1, described as `IBM XL C/C++ for
-AIX, V12.1 (5765-J02, 5725-C72) Version: 12.01.0000.0017`.
+Please consult the AIX section of the [Supported Build Platforms](
+https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms) OpenJDK
+Build Wiki page for details about which versions of XLC are supported.
-See the [OpenJDK PowerPC Port Status Page](
-http://cr.openjdk.java.net/~simonis/ppc-aix-port) for details.
## Boot JDK Requirements
--- a/doc/testing.html Sat Mar 09 12:52:30 2019 +0000
+++ b/doc/testing.html Sat Mar 09 12:54:20 2019 +0000
@@ -1,24 +1,19 @@
<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
+<html>
<head>
- <meta charset="utf-8" />
- <meta name="generator" content="pandoc" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
+ <meta charset="utf-8">
+ <meta name="generator" content="pandoc">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Testing the JDK</title>
- <style type="text/css">
- code{white-space: pre-wrap;}
- span.smallcaps{font-variant: small-caps;}
- span.underline{text-decoration: underline;}
- div.column{display: inline-block; vertical-align: top; width: 50%;}
- </style>
- <link rel="stylesheet" href="../make/data/docs-resources/resources/jdk-default.css" />
+ <style type="text/css">code{white-space: pre;}</style>
+ <link rel="stylesheet" href="../make/data/docs-resources/resources/jdk-default.css">
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
<style type="text/css">pre, code, tt { color: #1d6ae5; }</style>
</head>
<body>
-<header id="title-block-header">
+<header>
<h1 class="title">Testing the JDK</h1>
</header>
<nav id="TOC">
@@ -124,7 +119,7 @@
<h3 id="jtreg-keywords">JTReg keywords</h3>
<h4 id="jobs-1">JOBS</h4>
<p>The test concurrency (<code>-concurrency</code>).</p>
-<p>Defaults to TEST_JOBS (if set by <code>--with-test-jobs=</code>), otherwise it defaults to JOBS, except for Hotspot, where the default is <em>number of CPU cores/2</em>, but never more than 12.</p>
+<p>Defaults to TEST_JOBS (if set by <code>--with-test-jobs=</code>), otherwise it defaults to JOBS, except for Hotspot, where the default is <em>number of CPU cores/2</em> (for sparc, if more than 16 cpus, then <em>number of CPU cores/5</em>, otherwise <em>number of CPU cores/4</em>), but never more than <em>memory size in GB/2</em>.</p>
<h4 id="timeout_factor-1">TIMEOUT_FACTOR</h4>
<p>The timeout factor (<code>-timeoutFactor</code>).</p>
<p>Defaults to 4.</p>
--- a/doc/testing.md Sat Mar 09 12:52:30 2019 +0000
+++ b/doc/testing.md Sat Mar 09 12:54:20 2019 +0000
@@ -252,8 +252,9 @@
The test concurrency (`-concurrency`).
Defaults to TEST_JOBS (if set by `--with-test-jobs=`), otherwise it defaults to
-JOBS, except for Hotspot, where the default is *number of CPU cores/2*, but
-never more than 12.
+JOBS, except for Hotspot, where the default is *number of CPU cores/2* (for
+sparc, if more than 16 cpus, then *number of CPU cores/5*, otherwise *number of
+CPU cores/4*), but never more than *memory size in GB/2*.
#### TIMEOUT_FACTOR
The timeout factor (`-timeoutFactor`).
--- a/make/CreateJmods.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/CreateJmods.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
include $(SPEC)
include MakeBase.gmk
+include Execute.gmk
include Modules.gmk
ifeq ($(MODULE), )
@@ -37,7 +38,8 @@
################################################################################
JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
-JMODS_TEMPDIR := $(SUPPORT_OUTPUTDIR)/jmods
+JMODS_SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jmods
+JMOD_FILE := $(MODULE).jmod
LIBS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
@@ -152,26 +154,27 @@
# to avoid false incremental rebuilds.
ifeq ($(INTERIM_JMOD), true)
DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS))
+ INTERIM_MSG := interim$(SPACE)
endif
JMOD_FLAGS += --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}'
-# Create jmods in a temp dir and then move them into place to keep the
+# Create jmods in the support dir and then move them into place to keep the
# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
-$(JMODS_DIR)/$(MODULE).jmod: $(DEPS)
- $(call LogWarn, Creating $(patsubst $(OUTPUTDIR)/%, %, $@))
- $(call MakeDir, $(JMODS_DIR) $(JMODS_TEMPDIR))
- $(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@)
- $(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/jmods/$(MODULE).jmod, \
- $(JMOD) create \
- --module-version $(VERSION_SHORT) \
- --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
- --module-path $(JMODS_DIR) \
- $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@) \
- )
- $(MV) $(JMODS_TEMPDIR)/$(notdir $@) $@
+$(eval $(call SetupExecute, create_$(JMOD_FILE), \
+ WARN := Creating $(INTERIM_MSG)$(JMOD_FILE), \
+ DEPS := $(DEPS), \
+ OUTPUT_FILE := $(JMODS_DIR)/$(JMOD_FILE), \
+ SUPPORT_DIR := $(JMODS_SUPPORT_DIR), \
+ PRE_COMMAND := $(RM) $(JMODS_DIR)/$(JMOD_FILE) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \
+ COMMAND := $(JMOD) create --module-version $(VERSION_SHORT) \
+ --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
+ --module-path $(JMODS_DIR) $(JMOD_FLAGS) \
+ $(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \
+ POST_COMMAND := $(MV) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE) $(JMODS_DIR)/$(JMOD_FILE), \
+))
-TARGETS += $(JMODS_DIR)/$(MODULE).jmod
+TARGETS += $(create_$(JMOD_FILE))
################################################################################
--- a/make/Docs.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/Docs.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
include $(SPEC)
include MakeBase.gmk
+include Execute.gmk
include Modules.gmk
include ModuleTools.gmk
include ProcessMarkdown.gmk
@@ -195,10 +196,13 @@
# For each module needing a graph, create a png file from the dot file
# generated by the GenGraphs tool and store it in the target dir.
- $$($1_$2_PNG_TARGET): $$($1_GENGRAPHS_MARKER)
- $$(call MakeDir, $$(@D))
- $$(call ExecuteWithLog, $$($1_$2_DOT_SRC), \
- $$(DOT) -Tpng -o $$($1_$2_PNG_TARGET) $$($1_$2_DOT_SRC))
+ $$(eval $$(call SetupExecute, gengraphs_png_$1_$2, \
+ INFO := Running dot for module graphs for $2, \
+ DEPS := $$(gengraphs_$1_TARGET), \
+ OUTPUT_FILE := $$($1_$2_PNG_TARGET), \
+ SUPPORT_DIR := $$($1_GENGRAPHS_DIR), \
+ COMMAND := $$(DOT) -Tpng -o $$($1_$2_PNG_TARGET) $$($1_$2_DOT_SRC), \
+ ))
$1_MODULEGRAPH_TARGETS += $$($1_$2_PNG_TARGET)
endef
@@ -336,18 +340,18 @@
$1_SOURCE_DEPS := $$(call CacheFind, $$(wildcard $$(foreach module, \
$$($1_ALL_MODULES), $$(call FindModuleSrcDirs, $$(module)))))
- # Javadoc creates a lot of files but use index.html as a marker
- $$($1_TARGET_DIR)/index.html: $$(BUILD_TOOLS_JDK) $$($1_VARDEPS_FILE) \
- $$($1_SOURCE_DEPS) $$($1_OVERVIEW)
- $$(call LogWarn, Generating $1 javadoc for \
- $$(words $$($1_ALL_MODULES)) modules)
- $$(call LogInfo, Javadoc modules: $$($1_ALL_MODULES))
- $$(call MakeDir, $$($1_TARGET_DIR))
- $$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/docs/$1, \
- $$($1_JAVADOC_CMD) -d $$($1_TARGET_DIR) \
- $$($1_OPTIONS) $$($1_LOG_OPTION))
+ $$(eval $$(call SetupExecute, javadoc_$1, \
+ WARN := Generating $1 javadoc for $$(words $$($1_ALL_MODULES)) modules, \
+ INFO := Javadoc modules: $$($1_ALL_MODULES), \
+ DEPS := $$(BUILD_TOOLS_JDK) $$($1_VARDEPS_FILE) $$($1_SOURCE_DEPS) \
+ $$($1_OVERVIEW), \
+ OUTPUT_DIR := $$($1_TARGET_DIR), \
+ SUPPORT_DIR := $$(SUPPORT_OUTPUTDIR)/docs, \
+ COMMAND := $$($1_JAVADOC_CMD) -d $$($1_TARGET_DIR) $$($1_OPTIONS) \
+ $$($1_LOG_OPTION), \
+ ))
- $1_JAVADOC_TARGETS := $$($1_TARGET_DIR)/index.html
+ $1_JAVADOC_TARGETS := $$(javadoc_$1_TARGET)
ifeq ($$(ENABLE_FULL_DOCS), true)
# We have asked ModuleGraph to generate links to png files. Now we must
@@ -367,19 +371,18 @@
$$(TOPDIR)/make/jdk/src/classes/build/tools/jigsaw/javadoc-graphs.properties
$1_GENGRAPHS_DIR := $$(SUPPORT_OUTPUTDIR)/docs/$1-gengraphs
- $1_GENGRAPHS_MARKER := $$($1_GENGRAPHS_DIR)/_gengraphs_run.marker
- $$($1_GENGRAPHS_MARKER): $$(BUILD_JIGSAW_TOOLS) $$(GENGRAPHS_PROPS)
- $$(call LogInfo, Running gengraphs for $1 documentation)
- $$(call MakeDir, $$($1_GENGRAPHS_DIR))
- $$(call ExecuteWithLog, $$($1_GENGRAPHS_DIR)/gengraphs, \
- $$(TOOL_GENGRAPHS) --spec --output $$($1_GENGRAPHS_DIR) \
- --dot-attributes $$(GENGRAPHS_PROPS) && \
- $$(TOUCH) $$($1_GENGRAPHS_MARKER))
+ $$(eval $$(call SetupExecute, gengraphs_$1, \
+ INFO := Running gengraphs for $1 documentation, \
+ DEPS := $$(BUILD_JIGSAW_TOOLS) $$(GENGRAPHS_PROPS), \
+ OUTPUT_DIR := $$($1_GENGRAPHS_DIR), \
+ COMMAND := $$(TOOL_GENGRAPHS) --spec --output $$($1_GENGRAPHS_DIR) \
+ --dot-attributes $$(GENGRAPHS_PROPS), \
+ ))
# For each module needing a graph, create a png file from the dot file
# generated by the GenGraphs tool and store it in the target dir.
- # They will depend on $1_GENGRAPHS_MARKER, and will be added to $1.
+ # They will depend on gengraphs_$1_TARGET, and will be added to $1.
$$(foreach m, $$($1_MODULES_NEEDING_GRAPH), \
$$(eval $$(call setup_gengraph_dot_to_png,$1,$$m)) \
)
--- a/make/ExplodedImageOptimize.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/ExplodedImageOptimize.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -29,19 +29,21 @@
include $(SPEC)
include MakeBase.gmk
+include Execute.gmk
include $(TOPDIR)/make/ModuleTools.gmk
################################################################################
-PACKAGES_ATTRIBUTE_TARGET := $(JDK_OUTPUTDIR)/_packages_attribute.done
ALL_MODULEINFO_CLASSES := $(wildcard $(JDK_OUTPUTDIR)/modules/*/module-info.class)
-$(PACKAGES_ATTRIBUTE_TARGET): $(ALL_MODULEINFO_CLASSES) $(BUILD_JIGSAW_CLASSES)
- $(call LogInfo, Optimizing the exploded image)
- $(call ExecuteWithLog, $@, $(TOOL_ADD_PACKAGES_ATTRIBUTE) $(JDK_OUTPUTDIR))
- $(TOUCH) $@
+$(eval $(call SetupExecute, optimize_image, \
+ INFO := Optimizing the exploded image, \
+ DEPS := $(ALL_MODULEINFO_CLASSES) $(BUILD_JIGSAW_CLASSES), \
+ OUTPUT_DIR := $(JDK_OUTPUTDIR), \
+ COMMAND := $(TOOL_ADD_PACKAGES_ATTRIBUTE) $(JDK_OUTPUTDIR), \
+))
-TARGETS := $(PACKAGES_ATTRIBUTE_TARGET)
+TARGETS := $(optimize_image_TARGET)
################################################################################
--- a/make/Images.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/Images.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
# 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,9 +27,9 @@
include $(SPEC)
include MakeBase.gmk
+include Execute.gmk
include Modules.gmk
-TOOL_TARGETS :=
JDK_TARGETS :=
JRE_TARGETS :=
@@ -56,9 +56,6 @@
JMODS := $(wildcard $(IMAGES_OUTPUTDIR)/jmods/*.jmod)
-# Use this file inside the image as target for make rule
-JIMAGE_TARGET_FILE := release
-
JLINK_ORDER_RESOURCES := **module-info.class
JLINK_JLI_CLASSES :=
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
@@ -88,40 +85,57 @@
JLINK_JDK_EXTRA_OPTS := --keep-packaged-modules $(JDK_IMAGE_DIR)/jmods
endif
-$(JDK_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
- $(call DependOnVariable, JDK_MODULES_LIST) $(BASE_RELEASE_FILE)
- $(call LogWarn, Creating jdk image)
- $(RM) -r $(JDK_IMAGE_DIR)
- $(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jdk, \
- $(JLINK_TOOL) --add-modules $(JDK_MODULES_LIST) \
- $(JLINK_JDK_EXTRA_OPTS) \
- --output $(JDK_IMAGE_DIR) \
- )
- ifeq ($(BUILD_CDS_ARCHIVE), true)
- $(call LogWarn, Creating CDS archive for jdk image)
- $(FIXPATH) $(JDK_IMAGE_DIR)/bin/java \
- -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO)
- endif
- $(TOUCH) $@
+$(eval $(call SetupExecute, jlink_jdk, \
+ WARN := Creating jdk image, \
+ DEPS := $(JMODS) $(BASE_RELEASE_FILE) \
+ $(call DependOnVariable, JDK_MODULES_LIST), \
+ OUTPUT_DIR := $(JDK_IMAGE_DIR), \
+ SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jdk, \
+ PRE_COMMAND := $(RM) -r $(JDK_IMAGE_DIR), \
+ COMMAND := $(JLINK_TOOL) --add-modules $(JDK_MODULES_LIST) \
+ $(JLINK_JDK_EXTRA_OPTS) --output $(JDK_IMAGE_DIR), \
+))
+
+JLINK_JDK_TARGETS := $(jlink_jdk)
+
+$(eval $(call SetupExecute, jlink_jre, \
+ WARN := Creating legacy jre image, \
+ DEPS := $(JMODS) $(BASE_RELEASE_FILE) \
+ $(call DependOnVariable, JDK_MODULES_LIST), \
+ OUTPUT_DIR := $(JDK_IMAGE_DIR), \
+ SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jre, \
+ PRE_COMMAND := $(RM) -r $(JRE_IMAGE_DIR), \
+ COMMAND := $(JLINK_TOOL) --add-modules $(JRE_MODULES_LIST) \
+ $(JLINK_JRE_EXTRA_OPTS) --output $(JRE_IMAGE_DIR), \
+))
+
+JLINK_JRE_TARGETS := $(jlink_jre)
-$(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
- $(call DependOnVariable, JRE_MODULES_LIST) $(BASE_RELEASE_FILE)
- $(call LogWarn, Creating legacy jre image)
- $(RM) -r $(JRE_IMAGE_DIR)
- $(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre, \
- $(JLINK_TOOL) --add-modules $(JRE_MODULES_LIST) \
- $(JLINK_JRE_EXTRA_OPTS) \
- --output $(JRE_IMAGE_DIR) \
- )
- ifeq ($(BUILD_CDS_ARCHIVE), true)
- $(call LogWarn, Creating CDS archive for jre image)
- $(FIXPATH) $(JRE_IMAGE_DIR)/bin/java \
- -Xshare:dump -Xmx128M -Xms128M $(LOG_INFO)
- endif
- $(TOUCH) $@
+ifeq ($(BUILD_CDS_ARCHIVE), true)
+ CDS_ARCHIVE := lib/server/classes.jsa
+
+ $(eval $(call SetupExecute, gen_cds_archive_jdk, \
+ WARN := Creating CDS archive for jdk image, \
+ DEPS := $(jlink_jdk), \
+ OUTPUT_FILE := $(JDK_IMAGE_DIR)/$(CDS_ARCHIVE), \
+ SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jdk, \
+ COMMAND := $(FIXPATH) $(JDK_IMAGE_DIR)/bin/java -Xshare:dump \
+ -Xmx128M -Xms128M $(LOG_INFO), \
+ ))
-TOOL_JRE_TARGETS := $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
-TOOL_JDK_TARGETS := $(JDK_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
+ JDK_TARGETS += $(gen_cds_archive_jdk)
+
+ $(eval $(call SetupExecute, gen_cds_archive_jre, \
+ WARN := Creating CDS archive for jre image, \
+ DEPS := $(jlink_jre), \
+ OUTPUT_FILE := $(JRE_IMAGE_DIR)/$(CDS_ARCHIVE), \
+ SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jre, \
+ COMMAND := $(FIXPATH) $(JRE_IMAGE_DIR)/bin/java -Xshare:dump \
+ -Xmx128M -Xms128M $(LOG_INFO), \
+ ))
+
+ JDK_TARGETS += $(gen_cds_archive_jdk)
+endif
################################################################################
# src.zip
@@ -244,11 +258,11 @@
################################################################################
-$(JRE_TARGETS): $(TOOL_JRE_TARGETS)
-$(JDK_TARGETS): $(TOOL_JDK_TARGETS)
+$(JRE_TARGETS): $(JLINK_JRE_TARGETS)
+$(JDK_TARGETS): $(JLINK_JDK_TARGETS)
-jdk: $(TOOL_JDK_TARGETS) $(JDK_TARGETS)
-jre: $(TOOL_JRE_TARGETS) $(JRE_TARGETS)
+jdk: $(JLINK_JDK_TARGETS) $(JDK_TARGETS)
+jre: $(JLINK_JRE_TARGETS) $(JRE_TARGETS)
symbols: $(SYMBOLS_TARGETS)
all: jdk jre symbols
--- a/make/Main.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/Main.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -456,7 +456,7 @@
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
MODULE=$1 \
JMODS_DIR=$(INTERIM_JMODS_DIR) \
- JMODS_TEMPDIR=$(INTERIM_JMODS_DIR)/temp \
+ JMODS_SUPPORT_DIR=$(INTERIM_JMODS_DIR)/support \
INTERIM_JMOD=true \
)
endef
@@ -1120,7 +1120,8 @@
# file.
CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \
- images make-support test-make bundles buildjdk test-results test-support
+ images make-support test-make bundles buildjdk test-results test-support \
+ support/images
CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
CLEAN_SUPPORT_DIRS += demos
CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
@@ -1170,6 +1171,9 @@
clean-test: clean-test-results clean-test-support
+# When cleaning images, also clean the support/images directory.
+clean-images: clean-support/images
+
# Remove everything, including configure configuration. If the output
# directory was created by configure and now becomes empty, remove it as well.
dist-clean: clean
--- a/make/UpdateX11Wrappers.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/UpdateX11Wrappers.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
# 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,6 +29,7 @@
include $(SPEC)
include MakeBase.gmk
+include Execute.gmk
include NativeCompilation.gmk
include ToolsJdk.gmk
@@ -47,17 +48,21 @@
endif
X11WRAPPERS_OUTPUT := $(SUPPORT_OUTPUTDIR)/x11wrappers
+GENERATOR_SOURCE_FILE := $(X11WRAPPERS_OUTPUT)/src/data_generator.c
GENSRC_X11WRAPPERS_DATADIR := $(TOPDIR)/make/data/x11wrappergen
+WRAPPER_OUTPUT_FILE := $(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(BITS).txt
BITS := $(OPENJDK_TARGET_CPU_BITS)
# Generate the C code for the program that will output the offset file.
-$(X11WRAPPERS_OUTPUT)/src/data_generator.c: $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(BUILD_TOOLS_JDK)
- $(call LogInfo, Generating X11 wrapper data generator source code)
- $(call MakeDir, $(@D))
- $(call ExecuteWithLog, $@, \
- $(TOOL_WRAPPERGENERATOR) gen_c_source $@ $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(BITS))
+$(eval $(call SetupExecute, gensrc_generator, \
+ INFO := Generating X11 wrapper data generator source code, \
+ DEPS := $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(BUILD_TOOLS_JDK), \
+ OUTPUT_FILE := $(GENERATOR_SOURCE_FILE), \
+ COMMAND := $(TOOL_WRAPPERGENERATOR) gen_c_source $(GENERATOR_SOURCE_FILE) \
+ $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(BITS), \
+))
DATA_GENERATOR_INCLUDES := \
-I$(TOPDIR)/src/hotspot/share/include \
@@ -75,7 +80,7 @@
$(eval $(call SetupNativeCompilation, BUILD_DATA_GENERATOR, \
PROGRAM := data_generator, \
OUTPUT_DIR := $(X11WRAPPERS_OUTPUT)/bin, \
- EXTRA_FILES := $(X11WRAPPERS_OUTPUT)/src/data_generator.c, \
+ EXTRA_FILES := $(GENERATOR_SOURCE_FILE), \
CFLAGS := $(X_CFLAGS) $(DATA_GENERATOR_INCLUDES) $(CFLAGS_JDKEXE), \
LDFLAGS := $(LDFLAGS_JDKEXE), \
LIBS := $(X_LIBS), \
@@ -83,16 +88,19 @@
))
# Run the executable to create the data file.
-$(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(BITS).txt: $(BUILD_DATA_GENERATOR_TARGET)
- $(call LogInfo, Generating X11 wrapper data files)
- $(call MakeDir, $(@D))
- $(call ExecuteWithLog, $(X11WRAPPERS_OUTPUT)/generation, \
- $(BUILD_DATA_GENERATOR_TARGET) | $(SORT) > $@)
+$(eval $(call SetupExecute, run_wrappergen, \
+ INFO := Generating X11 wrapper data files, \
+ DEPS := $(BUILD_DATA_GENERATOR), \
+ OUTPUT_FILE := $(WRAPPER_OUTPUT_FILE), \
+ COMMAND := $(BUILD_DATA_GENERATOR_TARGET) | $(SORT) > $(WRAPPER_OUTPUT_FILE), \
+))
+
+wrapper-information: $(run_wrappergen)
$(ECHO) IMPORTANT: If you update the X11 wrapper data files, they most certainly
$(ECHO) need to be updated for both 32 and 64 bit platforms. You have now
$(ECHO) updated them for $(BITS) bit platforms only.
-TARGETS += $(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(BITS).txt
+TARGETS += $(run_wrappergen) wrapper-information
################################################################################
--- a/make/autoconf/configure Sat Mar 09 12:52:30 2019 +0000
+++ b/make/autoconf/configure Sat Mar 09 12:54:20 2019 +0000
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -78,9 +78,12 @@
APT_GET="`which apt-get 2> /dev/null | grep -v '^no apt-get in'`"
YUM="`which yum 2> /dev/null | grep -v '^no yum in'`"
BREW="`which brew 2> /dev/null | grep -v '^no brew in'`"
+ ZYPPER="`which zypper 2> /dev/null | grep -v '^no zypper in'`"
CYGWIN="`which cygpath 2> /dev/null | grep -v '^no cygpath in'`"
- if test "x$APT_GET" != x; then
+ if test "x$ZYPPER" != x; then
+ PKGHANDLER_COMMAND="sudo zypper install autoconf"
+ elif test "x$APT_GET" != x; then
PKGHANDLER_COMMAND="sudo apt-get install autoconf"
elif test "x$YUM" != x; then
PKGHANDLER_COMMAND="sudo yum install autoconf"
--- a/make/autoconf/help.m4 Sat Mar 09 12:52:30 2019 +0000
+++ b/make/autoconf/help.m4 Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
AC_DEFUN_ONCE([HELP_SETUP_DEPENDENCY_HELP],
[
- AC_CHECK_PROGS(PKGHANDLER, apt-get yum brew port pkgutil pkgadd)
+ AC_CHECK_PROGS(PKGHANDLER, zypper apt-get yum brew port pkgutil pkgadd)
])
AC_DEFUN([HELP_MSG_MISSING_DEPENDENCY],
@@ -54,6 +54,8 @@
pkgutil_help $MISSING_DEPENDENCY ;;
pkgadd)
pkgadd_help $MISSING_DEPENDENCY ;;
+ zypper)
+ zypper_help $MISSING_DEPENDENCY ;;
esac
if test "x$PKGHANDLER_COMMAND" != x; then
@@ -110,6 +112,25 @@
esac
}
+zypper_help() {
+ case $1 in
+ devkit)
+ PKGHANDLER_COMMAND="sudo zypper install gcc gcc-c++" ;;
+ alsa)
+ PKGHANDLER_COMMAND="sudo zypper install alsa-devel" ;;
+ cups)
+ PKGHANDLER_COMMAND="sudo zypper install cups-devel" ;;
+ fontconfig)
+ PKGHANDLER_COMMAND="sudo zypper install fontconfig-devel" ;;
+ freetype)
+ PKGHANDLER_COMMAND="sudo zypper install freetype-devel" ;;
+ x11)
+ PKGHANDLER_COMMAND="sudo zypper install libX11-devel libXext-devel libXrender-devel libXrandr-devel libXtst-devel libXt-devel libXi-devel" ;;
+ ccache)
+ PKGHANDLER_COMMAND="sudo zypper install ccache" ;;
+ esac
+}
+
yum_help() {
case $1 in
devkit)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make/common/Execute.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,198 @@
+#
+# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#
+
+ifeq (,$(_MAKEBASE_GMK))
+ $(error You must include MakeBase.gmk prior to including Execute.gmk)
+endif
+
+################################################################################
+#
+# Code for handling the SetupExecute macro.
+#
+################################################################################
+
+
+################################################################################
+# Setup make rules for executing an arbitrary command.
+#
+# Parameter 1 is the name of the rule. This name is used as variable prefix,
+# and the targets generated are listed in a variable by that name.
+#
+# You need to specify a COMMAND, the actual command line to execute. You are
+# strongly recommended to provide a INFO with the text to display for LOG=info
+# on what operation is performed. You can use DEPS to provide additional
+# dependencies for your command to run. You can optionally include a PRE_COMMAND
+# and a POST_COMMAND, intended for simple pre- and post-processing. The latter
+# might be e.g. a mv from a temporary file to the final destination, the former
+# e.g. a simple sed replacement on the input file. If the operations are
+# unrelated to the main COMMAND, this is not a suitable solution.
+#
+# If your command outputs a variety of files, or if it's really a single file
+# but you don't really care about the output from the perspective, you can just
+# supply an OUTPUT_DIR. You are supposed to make sure the command creates files
+# in this directory (which will be created for you if it does not exist), but
+# this can't be enforced by SetupExecute. Additional support files (like logs
+# and markers) are created in this directory. If you want support files in a
+# separate directory (e.g. if you're targeting an OUTPUT_DIR in the image
+# directly), you can specify a SUPPORT_DIR. If your command outputs only a
+# single file, you can get rid of the marker files (but not the log files) by
+# specifying OUTPUT_FILE. Note that if you specify an OUTPUT_FILE, support log
+# files will be placed in the same directory as the OUTPUT_FILE. If you do not
+# want that, use SUPPORT_DIR as well.
+#
+# After the call to SetupExecute, $1 will contain references to all generated
+# files (that make knows about), and $1_TARGET will contain a reference to the
+# final target (that is OUTPUT_FILE if it exists, or the $1_exec.marker file
+# otherwise).
+#
+# All the above keep functioning as expected even if PRE_COMMAND and
+# POST_COMMAND are given. One special case worth noting is that if OUTPUT_FILE
+# and POST_COMMAND is both given, the actual OUTPUT_FILE is considered to be a
+# result of running the POST_COMMAND.
+#
+# Remaining parameters are named arguments. These include:
+# COMMAND : The command to execute
+# PRE_COMMAND : A helper command to execute before COMMAND
+# POST_COMMAND: A helper command to execute after COMMAND
+# OUTPUT_DIR : The directory that will contain the result from the command
+# OUTPUT_FILE : Use this if the command results in a single output file
+# SUPPORT_DIR : Where to store generated support files
+# INFO : Message to display at LOG=info level when running command (optional)
+# WARN : Message to display at LOG=warn level when running command (optional)
+# DEPS : Dependencies for the execution to take place
+#
+
+# Setup make rules for copying files, with an option to do more complex
+SetupExecute = $(NamedParamsMacroTemplate)
+define SetupExecuteBody
+ ifeq ($$($1_COMMAND), )
+ $$(error COMMAND is missing in SetupExecute $1)
+ endif
+
+ ifneq ($$($1_OUTPUT_FILE), )
+ ifneq ($$($1_OUTPUT_DIR), )
+ $$(error Cannot specify both OUTPUT_DIR and OUTPUT_FILE in SetupExecute $1)
+ endif
+ # We need to know output dir since we will make sure it is created.
+ $1_OUTPUT_DIR := $$(patsubst %/,%, $$(dir $$($1_OUTPUT_FILE)))
+ ifeq ($$($1_SUPPORT_DIR), )
+ # If support dir is not given, use base dir of output file.
+ $1_SUPPORT_DIR := $$($1_OUTPUT_DIR)
+ endif
+ else ifneq ($$($1_OUTPUT_DIR), )
+ ifeq ($$($1_SUPPORT_DIR), )
+ # If support dir is not given, use output dir.
+ $1_SUPPORT_DIR := $$($1_OUTPUT_DIR)
+ endif
+ else
+ $$(error OUTPUT_DIR or OUTPUT_FILE is required in SetupExecute $1)
+ endif
+
+ $1_BASE := $$($1_SUPPORT_DIR)/_$1
+ $1_PRE_MARKER := $$($1_BASE)_pre.marker
+ $1_EXEC_MARKER := $$($1_BASE)_exec.marker
+ $1_POST_MARKER := $$($1_BASE)_post.marker
+
+ ifeq ($$($1_OUTPUT_FILE), )
+ # No specified output file, use markers everywhere
+ $1_EXEC_RESULT := $$($1_EXEC_MARKER)
+ ifeq ($$($1_POST_COMMAND), )
+ $1_FINAL_RESULT := $$($1_EXEC_MARKER)
+ else
+ $1_FINAL_RESULT := $$($1_POST_MARKER)
+ endif
+
+ else
+ # If we have a single output file, we don't need a separate marker
+
+ ifeq ($$($1_POST_COMMAND), )
+ $1_EXEC_RESULT := $$($1_OUTPUT_FILE)
+ $1_FINAL_RESULT := $$($1_EXEC_RESULT)
+ else
+ $1_EXEC_RESULT := $$($1_EXEC_MARKER)
+ $1_FINAL_RESULT := $$($1_OUTPUT_FILE)
+ endif
+
+ endif
+
+ ifeq ($$($1_INFO)$$($1_WARN), )
+ # If neither info nor warn is provided, add basic info text.
+ $1_INFO := Running commands for $1
+ endif
+
+ ifneq ($$($1_PRE_COMMAND), )
+
+ $$($1_PRE_MARKER): $$($1_DEPS)
+ ifneq ($$($1_WARN), )
+ $$(call LogWarn, $$($1_WARN))
+ endif
+ ifneq ($$($1_INFO), )
+ $$(call LogInfo, $$($1_INFO))
+ endif
+ $$(call MakeDir, $$($1_SUPPORT_DIR) $$($1_OUTPUT_DIR))
+ $$(call ExecuteWithLog, $$($1_BASE)_pre, \
+ $$($1_PRE_COMMAND))
+ $$(TOUCH) $$@
+
+ $$($1_EXEC_RESULT): $$($1_PRE_MARKER)
+ $$(call ExecuteWithLog, $$($1_BASE)_exec, \
+ $$($1_COMMAND))
+ ifeq ($$($1_EXEC_RESULT), $$($1_EXEC_MARKER))
+ $$(TOUCH) $$@
+ endif
+
+ $1 := $$($1_PRE_MARKER) $$($1_EXEC_RESULT)
+ else
+ $$($1_EXEC_RESULT): $$($1_DEPS)
+ ifneq ($$($1_WARN), )
+ $$(call LogWarn, $$($1_WARN))
+ endif
+ ifneq ($$($1_INFO), )
+ $$(call LogInfo, $$($1_INFO))
+ endif
+ $$(call MakeDir, $$(call EncodeSpace, $$($1_SUPPORT_DIR)) $$(call EncodeSpace, $$($1_OUTPUT_DIR)))
+ $$(call ExecuteWithLog, $$($1_BASE)_exec, \
+ $$($1_COMMAND))
+ ifeq ($$($1_EXEC_RESULT), $$($1_EXEC_MARKER))
+ $$(TOUCH) $$@
+ endif
+
+ $1 := $$($1_EXEC_RESULT)
+ endif
+
+ ifneq ($$($1_POST_COMMAND), )
+
+ $$($1_FINAL_RESULT): $$($1_EXEC_RESULT)
+ $$(call ExecuteWithLog, $$($1_BASE)_post, \
+ $$($1_POST_COMMAND))
+ $$(TOUCH) $$@
+
+ $1 += $$($1_FINAL_RESULT)
+ endif
+
+ # Export all our generated targets in $1, and the final target in $1_TARGET.
+ $1_TARGET := $$($1_FINAL_RESULT)
+
+endef
--- a/make/conf/jib-profiles.js Sat Mar 09 12:52:30 2019 +0000
+++ b/make/conf/jib-profiles.js Sat Mar 09 12:54:20 2019 +0000
@@ -940,10 +940,10 @@
var devkit_platform_revisions = {
linux_x64: "gcc7.3.0-OEL6.4+1.2",
- macosx_x64: "Xcode9.4-MacOSX10.13+1.0",
+ macosx_x64: "Xcode10.1-MacOSX10.14+1.0",
solaris_x64: "SS12u4-Solaris11u1+1.0",
solaris_sparcv9: "SS12u6-Solaris11u3+1.0",
- windows_x64: "VS2017-15.5.5+1.0",
+ windows_x64: "VS2017-15.9.6+1.0",
linux_aarch64: "gcc7.3.0-Fedora27+1.2",
linux_arm: "gcc7.3.0-Fedora27+1.2",
linux_ppc64le: "gcc7.3.0-Fedora27+1.0",
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make/devkit/createMacosxDevkit.sh Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,144 @@
+#!/bin/bash
+#
+# Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+# 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 script copies parts of an Xcode installation into a devkit suitable
+# for building OpenJDK and OracleJDK. The installation Xcode_X.X.xip needs
+# to be either installed or extracted using for example Archive Utility.
+# The easiest way to accomplish this is to right click the file in Finder
+# and choose "Open With -> Archive Utility", or possible typing
+# "open Xcode_9.2.xip" in a terminal.
+# erik.joelsson@oracle.com
+
+USAGE="$0 <Xcode.app>"
+
+if [ "$1" = "" ]; then
+ echo $USAGE
+ exit 1
+fi
+
+XCODE_APP="$1"
+XCODE_APP_DIR_NAME="${XCODE_APP##*/}"
+
+SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
+BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
+
+# Find the version of Xcode
+XCODE_VERSION="$($XCODE_APP/Contents/Developer/usr/bin/xcodebuild -version \
+ | awk '/Xcode/ { print $2 }' )"
+SDK_VERSION="$(ls $XCODE_APP/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
+ | grep [0-9] | sort -r | head -n1 | sed 's/\.sdk//')"
+
+DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-${SDK_VERSION}"
+DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
+
+echo "Xcode version: $XCODE_VERSION"
+echo "SDK version: $SDK_VERSION"
+echo "Creating devkit in $DEVKIT_ROOT"
+
+mkdir -p $DEVKIT_ROOT
+
+################################################################################
+# Copy the relevant parts of Xcode.app, removing things that are both big and
+# unecessary for our purposes, without building an impossibly long exclude list.
+#
+# Not including WatchSimulator.platform makes ibtool crashes in some situations.
+# It doesn't seem to matter which extra platform is included, but that is the
+# smallest one.
+
+EXCLUDE_DIRS=" \
+ Contents/_CodeSignature \
+ $XCODE_APP_DIR_NAME/Contents/Applications \
+ $XCODE_APP_DIR_NAME/Contents/Resources \
+ $XCODE_APP_DIR_NAME/Contents/Library \
+ $XCODE_APP_DIR_NAME/Contents/XPCServices \
+ $XCODE_APP_DIR_NAME/Contents/OtherFrameworks \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Documentation \
+ $XCODE_APP_DIR_NAME/Contents/Developer/usr/share \
+ $XCODE_APP_DIR_NAME/Contents/Developer/usr/libexec/git-core \
+ $XCODE_APP_DIR_NAME/Contents/Developer/usr/bin/git* \
+ $XCODE_APP_DIR_NAME/Contents/Developer/usr/bin/svn* \
+ $XCODE_APP_DIR_NAME/Contents/Developer/usr/lib/libgit* \
+ $XCODE_APP_DIR_NAME/Contents/Developer/usr/lib/libsvn* \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk/usr/share/man \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/share/man \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/usr \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift* \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift* \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/sourcekitd.framework \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec/swift* \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/swift* \
+ $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/arc \
+ Platforms/AppleTVSimulator.platform \
+ Platforms/iPhoneSimulator.platform \
+ $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/LLDB.framework \
+ $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/ModelIO.framework \
+ $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/XCSUI.framework \
+ $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/SceneKit.framework \
+ $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/XCBuild.framework \
+ $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/GPUTools.framework \
+ $(cd $XCODE_APP/.. && ls -d $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/* \
+ | grep -v MacOSX.platform | grep -v WatchSimulator.platform) \
+"
+
+for ex in $EXCLUDE_DIRS; do
+ EXCLUDE_ARGS+="--exclude=$ex "
+done
+
+echo "Copying Xcode.app..."
+echo rsync -rlH $INCLUDE_ARGS $EXCLUDE_ARGS "$XCODE_APP" $DEVKIT_ROOT/
+rsync -rlH $INCLUDE_ARGS $EXCLUDE_ARGS "$XCODE_APP" $DEVKIT_ROOT/
+
+################################################################################
+
+echo-info() {
+ echo "$1" >> $DEVKIT_ROOT/devkit.info
+}
+
+echo "Generating devkit.info..."
+rm -f $DEVKIT_ROOT/devkit.info
+echo-info "# This file describes to configure how to interpret the contents of this devkit"
+echo-info "DEVKIT_NAME=\"Xcode $XCODE_VERSION (devkit)\""
+echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\""
+echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$SDK_VERSION.sdk\""
+echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_TOOLCHAIN_PATH\""
+
+################################################################################
+# Copy this script
+
+echo "Copying this script..."
+cp $0 $DEVKIT_ROOT/
+
+################################################################################
+# Create bundle
+
+echo "Creating bundle..."
+GZIP=$(command -v pigz)
+if [ -z "$GZIP" ]; then
+ GZIP="gzip"
+fi
+(cd $DEVKIT_ROOT && tar c - . | $GZIP - > "$DEVKIT_BUNDLE")
--- a/make/devkit/createMacosxDevkit6.sh Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-
-# This script copies part of an Xcode installer into a devkit suitable
-# for building OpenJDK and OracleJDK. The installation .dmg files for Xcode
-# and the aux tools need to be available.
-# erik.joelsson@oracle.com
-
-USAGE="$0 <Xcode.dmg> <XQuartz.dmg> <gnu make binary> [<auxtools.dmg>]"
-
-if [ "$1" = "" ] || [ "$2" = "" ]; then
- echo $USAGE
- exit 1
-fi
-
-XCODE_DMG="$1"
-XQUARTZ_DMG="$2"
-GNU_MAKE="$3"
-AUXTOOLS_DMG="$4"
-
-SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
-BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
-
-# Mount XCODE_DMG
-if [ -e "/Volumes/Xcode" ]; then
- hdiutil detach /Volumes/Xcode
-fi
-hdiutil attach $XCODE_DMG
-
-# Find the version of Xcode
-XCODE_VERSION="$(/Volumes/Xcode/Xcode.app/Contents/Developer/usr/bin/xcodebuild -version \
- | awk '/Xcode/ { print $2 }' )"
-SDK_VERSION="MacOSX10.9"
-if [ ! -e "/Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk" ]; then
- echo "Expected SDK version not found: ${SDK_VERSION}"
- exit 1
-fi
-
-DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-${SDK_VERSION}"
-DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
-
-echo "Xcode version: $XCODE_VERSION"
-echo "Creating devkit in $DEVKIT_ROOT"
-
-################################################################################
-# Copy files to root
-mkdir -p $DEVKIT_ROOT
-if [ ! -d $DEVKIT_ROOT/Xcode.app ]; then
- echo "Copying Xcode.app..."
- cp -RH "/Volumes/Xcode/Xcode.app" $DEVKIT_ROOT/
-fi
-# Trim out some seemingly unneeded parts to save space.
-rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Applications
-rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/iPhone*
-rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Documentation
-rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/share/man
-( cd $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
- && rm -rf `ls | grep -v ${SDK_VERSION}` )
-rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk/usr/share/man
-
-hdiutil detach /Volumes/Xcode
-
-################################################################################
-# Copy Freetype into sysroot
-if [ -e "/Volumes/XQuartz-*" ]; then
- hdiutil detach /Volumes/XQuartz-*
-fi
-hdiutil attach $XQUARTZ_DMG
-
-echo "Copying freetype..."
-rm -rf /tmp/XQuartz
-pkgutil --expand /Volumes/XQuartz-*/XQuartz.pkg /tmp/XQuartz/
-rm -rf /tmp/x11
-mkdir /tmp/x11
-cd /tmp/x11
-cat /tmp/XQuartz/x11.pkg/Payload | gunzip -dc | cpio -i
-
-mkdir -p $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/include/
-mkdir -p $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/lib/
-cp -RH opt/X11/include/freetype2 \
- $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/include/
-cp -RH opt/X11/include/ft2build.h \
- $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/include/
-cp -RH opt/X11/lib/libfreetype.* \
- $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/lib/
-
-cd -
-
-hdiutil detach /Volumes/XQuartz-*
-
-################################################################################
-# Copy gnu make
-mkdir -p $DEVKIT_ROOT/bin
-cp $GNU_MAKE $DEVKIT_ROOT/bin
-
-################################################################################
-# Optionally copy PackageMaker
-
-if [ -e "$AUXTOOLS_DMG" ]; then
- if [ -e "/Volumes/Auxiliary Tools" ]; then
- hdiutil detach "/Volumes/Auxiliary Tools"
- fi
- hdiutil attach $AUXTOOLS_DMG
-
- echo "Copying PackageMaker.app..."
- cp -RH "/Volumes/Auxiliary Tools/PackageMaker.app" $DEVKIT_ROOT/
-
- hdiutil detach "/Volumes/Auxiliary Tools"
-fi
-
-################################################################################
-# Generate devkit.info
-
-echo-info() {
- echo "$1" >> $DEVKIT_ROOT/devkit.info
-}
-
-echo "Generating devkit.info..."
-rm -f $DEVKIT_ROOT/devkit.info
-echo-info "# This file describes to configure how to interpret the contents of this devkit"
-echo-info "# The parameters used to create this devkit were:"
-echo-info "# $*"
-echo-info "DEVKIT_NAME=\"Xcode $XCODE_VERSION (devkit)\""
-echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\""
-echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk\""
-echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_ROOT/bin:\$DEVKIT_ROOT/PackageMaker.app/Contents/MacOS:\$DEVKIT_TOOLCHAIN_PATH\""
-
-################################################################################
-# Copy this script
-
-echo "Copying this script..."
-cp $0 $DEVKIT_ROOT/
-
-################################################################################
-# Create bundle
-
-echo "Creating bundle..."
-(cd $DEVKIT_ROOT && tar c - . | gzip - > "$DEVKIT_BUNDLE")
--- a/make/devkit/createMacosxDevkit9.sh Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-
-# This script copies parts of an Xcode installation into a devkit suitable
-# for building OpenJDK and OracleJDK. The installation Xcode_X.X.xip needs
-# to be either installed or extracted using for example Archive Utility.
-# The easiest way to accomplish this is to right click the file in Finder
-# and choose "Open With -> Archive Utility", or possible typing
-# "open Xcode_9.2.xip" in a terminal.
-# erik.joelsson@oracle.com
-
-USAGE="$0 <Xcode.app>"
-
-if [ "$1" = "" ]; then
- echo $USAGE
- exit 1
-fi
-
-XCODE_APP="$1"
-XCODE_APP_DIR_NAME="${XCODE_APP##*/}"
-
-SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
-BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
-
-# Find the version of Xcode
-XCODE_VERSION="$($XCODE_APP/Contents/Developer/usr/bin/xcodebuild -version \
- | awk '/Xcode/ { print $2 }' )"
-SDK_VERSION="MacOSX10.13"
-if [ ! -e "$XCODE_APP/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk" ]; then
- echo "Expected SDK version not found: ${SDK_VERSION}"
- exit 1
-fi
-
-DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-${SDK_VERSION}"
-DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
-
-echo "Xcode version: $XCODE_VERSION"
-echo "Creating devkit in $DEVKIT_ROOT"
-
-mkdir -p $DEVKIT_ROOT
-
-################################################################################
-# Copy the relevant parts of Xcode.app, removing things that are both big and
-# unecessary for our purposes, without building an impossibly long exclude list.
-#
-# Not including WatchSimulator.platform makes ibtool crashes in some situations.
-# It doesn't seem to matter which extra platform is included, but that is the
-# smallest one.
-
-EXCLUDE_DIRS=" \
- Contents/_CodeSignature \
- $XCODE_APP_DIR_NAME/Contents/Applications \
- $XCODE_APP_DIR_NAME/Contents/Resources \
- $XCODE_APP_DIR_NAME/Contents/Library \
- $XCODE_APP_DIR_NAME/Contents/XPCServices \
- $XCODE_APP_DIR_NAME/Contents/OtherFrameworks \
- $XCODE_APP_DIR_NAME/Contents/Developer/Documentation \
- $XCODE_APP_DIR_NAME/Contents/Developer/usr/share \
- $XCODE_APP_DIR_NAME/Contents/Developer/usr/libexec/git-core \
- $XCODE_APP_DIR_NAME/Contents/Developer/usr/bin/git* \
- $XCODE_APP_DIR_NAME/Contents/Developer/usr/bin/svn* \
- $XCODE_APP_DIR_NAME/Contents/Developer/usr/lib/libgit* \
- $XCODE_APP_DIR_NAME/Contents/Developer/usr/lib/libsvn* \
- $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man \
- $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk/usr/share/man \
- $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/share/man \
- $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/usr \
- $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man \
- $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift* \
- $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift* \
- $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/sourcekitd.framework \
- $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec/swift* \
- $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/swift* \
- $XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/arc \
- Platforms/AppleTVSimulator.platform \
- Platforms/iPhoneSimulator.platform \
- $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/LLDB.framework \
- $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/ModelIO.framework \
- $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/XCSUI.framework \
- $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/SceneKit.framework \
- $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/XCBuild.framework \
- $XCODE_APP_DIR_NAME/Contents/SharedFrameworks/GPUTools.framework \
- $(cd $XCODE_APP/.. && ls -d $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/* \
- | grep -v MacOSX.platform | grep -v WatchSimulator.platform) \
-"
-
-for ex in $EXCLUDE_DIRS; do
- EXCLUDE_ARGS+="--exclude=$ex "
-done
-
-echo "Copying Xcode.app..."
-echo rsync -rlH $INCLUDE_ARGS $EXCLUDE_ARGS "$XCODE_APP" $DEVKIT_ROOT/
-rsync -rlH $INCLUDE_ARGS $EXCLUDE_ARGS "$XCODE_APP" $DEVKIT_ROOT/
-
-################################################################################
-
-echo-info() {
- echo "$1" >> $DEVKIT_ROOT/devkit.info
-}
-
-echo "Generating devkit.info..."
-rm -f $DEVKIT_ROOT/devkit.info
-echo-info "# This file describes to configure how to interpret the contents of this devkit"
-echo-info "DEVKIT_NAME=\"Xcode $XCODE_VERSION (devkit)\""
-echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\""
-echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$SDK_VERSION.sdk\""
-echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_TOOLCHAIN_PATH\""
-
-################################################################################
-# Copy this script
-
-echo "Copying this script..."
-cp $0 $DEVKIT_ROOT/
-
-################################################################################
-# Create bundle
-
-echo "Creating bundle..."
-GZIP=$(command -v pigz)
-if [ -z "$GZIP" ]; then
- GZIP="gzip"
-fi
-(cd $DEVKIT_ROOT && tar c - . | $GZIP - > "$DEVKIT_BUNDLE")
--- a/make/devkit/createWindowsDevkit2013.sh Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-
-# This script copies parts of a Visual Studio 2013 installation into a devkit
-# suitable for building OpenJDK and OracleJDK. Needs to run in Cygwin.
-# erik.joelsson@oracle.com
-
-VS_VERSION="2013"
-VS_VERSION_NUM="12.0"
-VS_VERSION_NUM_NODOT="120"
-SDK_VERSION="8.1"
-VS_VERSION_SP="SP4"
-
-SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
-BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
-DEVKIT_ROOT="${BUILD_DIR}/VS${VS_VERSION}${VS_VERSION_SP}-devkit"
-DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
-
-echo "Creating devkit in $DEVKIT_ROOT"
-
-MSVCR_DLL=Microsoft.VC${VS_VERSION_NUM_NODOT}.CRT/msvcr${VS_VERSION_NUM_NODOT}.dll
-MSVCP_DLL=Microsoft.VC${VS_VERSION_NUM_NODOT}.CRT/msvcp${VS_VERSION_NUM_NODOT}.dll
-
-################################################################################
-# Copy Visual Studio files
-
-eval VSNNNCOMNTOOLS="\"\${VS${VS_VERSION_NUM_NODOT}COMNTOOLS}\""
-VS_INSTALL_DIR="$(cygpath "$VSNNNCOMNTOOLS/../..")"
-echo "VS_INSTALL_DIR: $VS_INSTALL_DIR"
-
-if [ ! -d $DEVKIT_ROOT/VC ]; then
- echo "Copying VC..."
- mkdir -p $DEVKIT_ROOT/VC/bin
- cp -r "$VS_INSTALL_DIR/VC/bin/amd64" $DEVKIT_ROOT/VC/bin/
- cp "$VS_INSTALL_DIR/VC/bin/"*.* $DEVKIT_ROOT/VC/bin/
- cp -r "$VS_INSTALL_DIR/VC/bin/1033/" $DEVKIT_ROOT/VC/bin/
- mkdir -p $DEVKIT_ROOT/VC/lib
- cp -r "$VS_INSTALL_DIR/VC/lib/amd64" $DEVKIT_ROOT/VC/lib/
- cp "$VS_INSTALL_DIR/VC/lib/"*.* $DEVKIT_ROOT/VC/lib/
- cp -r "$VS_INSTALL_DIR/VC/include" $DEVKIT_ROOT/VC/
- mkdir -p $DEVKIT_ROOT/VC/atlmfc/lib
- cp -r "$VS_INSTALL_DIR/VC/atlmfc/include" $DEVKIT_ROOT/VC/atlmfc/
- cp -r "$VS_INSTALL_DIR/VC/atlmfc/lib/amd64" $DEVKIT_ROOT/VC/atlmfc/lib/
- cp "$VS_INSTALL_DIR/VC/atlmfc/lib/"*.* $DEVKIT_ROOT/VC/atlmfc/lib/
- mkdir -p $DEVKIT_ROOT/VC/redist
- cp -r "$VS_INSTALL_DIR/VC/redist/x64" $DEVKIT_ROOT/VC/redist/
- cp -r "$VS_INSTALL_DIR/VC/redist/x86" $DEVKIT_ROOT/VC/redist/
- # The redist runtime libs are needed to run the compiler but may not be
- # installed on the machine where the devkit will be used.
- cp $DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/
- cp $DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/
- cp $DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/amd64/
- cp $DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/amd64/
- # The msvcdis dll is needed to run some of the tools in VC/bin but is not
- # shipped in that directory. Copy it from the common dir.
- cp "$VS_INSTALL_DIR/Common7/IDE/msvcdis${VS_VERSION_NUM_NODOT}.dll" \
- $DEVKIT_ROOT/VC/bin/
-fi
-
-################################################################################
-# Copy SDK files
-
-PROGRAMFILES_X86="`env | sed -n 's/^ProgramFiles(x86)=//p'`"
-SDK_INSTALL_DIR="$(cygpath "$PROGRAMFILES_X86/Windows Kits/$SDK_VERSION")"
-echo "SDK_INSTALL_DIR: $SDK_INSTALL_DIR"
-
-if [ ! -d $DEVKIT_ROOT/$SDK_VERSION ]; then
- echo "Copying SDK..."
- mkdir -p $DEVKIT_ROOT/$SDK_VERSION/bin
- cp -r "$SDK_INSTALL_DIR/bin/x64" $DEVKIT_ROOT/$SDK_VERSION/bin/
- cp -r "$SDK_INSTALL_DIR/bin/x86" $DEVKIT_ROOT/$SDK_VERSION/bin/
- mkdir -p $DEVKIT_ROOT/$SDK_VERSION/lib
- cp -r "$SDK_INSTALL_DIR/lib/"winv*/um/x64 $DEVKIT_ROOT/$SDK_VERSION/lib/
- cp -r "$SDK_INSTALL_DIR/lib/"winv*/um/x86 $DEVKIT_ROOT/$SDK_VERSION/lib/
- cp -r "$SDK_INSTALL_DIR/include" $DEVKIT_ROOT/$SDK_VERSION/
-fi
-
-################################################################################
-# Generate devkit.info
-
-echo-info() {
- echo "$1" >> $DEVKIT_ROOT/devkit.info
-}
-
-echo "Generating devkit.info..."
-rm -f $DEVKIT_ROOT/devkit.info
-echo-info "# This file describes to configure how to interpret the contents of this devkit"
-echo-info "DEVKIT_NAME=\"Microsoft Visual Studio $VS_VERSION $VS_VERSION_SP (devkit)\""
-echo-info "DEVKIT_VS_VERSION=\"$VS_VERSION\""
-echo-info ""
-echo-info "DEVKIT_TOOLCHAIN_PATH_x86=\"\$DEVKIT_ROOT/VC/bin:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\""
-echo-info "DEVKIT_VS_INCLUDE_x86=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt\""
-echo-info "DEVKIT_VS_LIB_x86=\"\$DEVKIT_ROOT/VC/lib;\$DEVKIT_ROOT/VC/atlmfc/lib;\$DEVKIT_ROOT/$SDK_VERSION/lib/x86\""
-echo-info "DEVKIT_MSVCR_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL\""
-echo-info "DEVKIT_MSVCP_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL\""
-echo-info ""
-echo-info "DEVKIT_TOOLCHAIN_PATH_x86_64=\"\$DEVKIT_ROOT/VC/bin/amd64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\""
-echo-info "DEVKIT_VS_INCLUDE_x86_64=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt\""
-echo-info "DEVKIT_VS_LIB_x86_64=\"\$DEVKIT_ROOT/VC/lib/amd64;\$DEVKIT_ROOT/VC/atlmfc/lib/amd64;\$DEVKIT_ROOT/$SDK_VERSION/lib/x64\""
-echo-info "DEVKIT_MSVCR_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL\""
-echo-info "DEVKIT_MSVCP_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL\""
-
-################################################################################
-# Copy this script
-
-echo "Copying this script..."
-cp $0 $DEVKIT_ROOT/
-
-################################################################################
-# Create bundle
-
-echo "Creating bundle: $DEVKIT_BUNDLE"
-(cd "$DEVKIT_ROOT" && tar zcf "$DEVKIT_BUNDLE" .)
--- a/make/devkit/createWindowsDevkit2015.sh Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-
-# This script copies parts of a Visual Studio installation into a devkit
-# suitable for building OpenJDK and OracleJDK. Needs to run in Cygwin.
-# erik.joelsson@oracle.com
-
-VS_VERSION="2015"
-VS_VERSION_NUM="14.0"
-VS_VERSION_NUM_NODOT="140"
-SDK_VERSION="8.1"
-VS_VERSION_SP="update3"
-
-SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
-BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
-DEVKIT_ROOT="${BUILD_DIR}/VS${VS_VERSION}${VS_VERSION_SP}-devkit"
-DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
-
-echo "Creating devkit in $DEVKIT_ROOT"
-
-MSVCR_DLL=Microsoft.VC${VS_VERSION_NUM_NODOT}.CRT/vcruntime${VS_VERSION_NUM_NODOT}.dll
-MSVCP_DLL=Microsoft.VC${VS_VERSION_NUM_NODOT}.CRT/msvcp${VS_VERSION_NUM_NODOT}.dll
-
-################################################################################
-# Copy Visual Studio files
-
-eval VSNNNCOMNTOOLS="\"\${VS${VS_VERSION_NUM_NODOT}COMNTOOLS}\""
-VS_INSTALL_DIR="$(cygpath "$VSNNNCOMNTOOLS/../..")"
-echo "VS_INSTALL_DIR: $VS_INSTALL_DIR"
-
-if [ ! -d $DEVKIT_ROOT/VC ]; then
- echo "Copying VC..."
- mkdir -p $DEVKIT_ROOT/VC/bin
- cp -r "$VS_INSTALL_DIR/VC/bin/amd64" $DEVKIT_ROOT/VC/bin/
- cp "$VS_INSTALL_DIR/VC/bin/"*.* $DEVKIT_ROOT/VC/bin/
- cp -r "$VS_INSTALL_DIR/VC/bin/1033/" $DEVKIT_ROOT/VC/bin/
- mkdir -p $DEVKIT_ROOT/VC/lib
- cp -r "$VS_INSTALL_DIR/VC/lib/amd64" $DEVKIT_ROOT/VC/lib/
- cp "$VS_INSTALL_DIR/VC/lib/"*.* $DEVKIT_ROOT/VC/lib/
- cp -r "$VS_INSTALL_DIR/VC/include" $DEVKIT_ROOT/VC/
- mkdir -p $DEVKIT_ROOT/VC/atlmfc/lib
- cp -r "$VS_INSTALL_DIR/VC/atlmfc/include" $DEVKIT_ROOT/VC/atlmfc/
- cp -r "$VS_INSTALL_DIR/VC/atlmfc/lib/amd64" $DEVKIT_ROOT/VC/atlmfc/lib/
- cp "$VS_INSTALL_DIR/VC/atlmfc/lib/"*.* $DEVKIT_ROOT/VC/atlmfc/lib/
- mkdir -p $DEVKIT_ROOT/VC/redist
- cp -r "$VS_INSTALL_DIR/VC/redist/x64" $DEVKIT_ROOT/VC/redist/
- cp -r "$VS_INSTALL_DIR/VC/redist/x86" $DEVKIT_ROOT/VC/redist/
- # The redist runtime libs are needed to run the compiler but may not be
- # installed on the machine where the devkit will be used.
- cp $DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/
- cp $DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/
- cp $DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/amd64/
- cp $DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/amd64/
- # The msvcdis dll is needed to run some of the tools in VC/bin but is not
- # shipped in that directory. Copy it from the common dir.
- cp "$VS_INSTALL_DIR/Common7/IDE/msvcdis${VS_VERSION_NUM_NODOT}.dll" \
- $DEVKIT_ROOT/VC/bin/
-fi
-
-################################################################################
-# Copy SDK files
-
-PROGRAMFILES_X86="`env | sed -n 's/^ProgramFiles(x86)=//p'`"
-SDK_INSTALL_DIR="$(cygpath "$PROGRAMFILES_X86/Windows Kits/$SDK_VERSION")"
-echo "SDK_INSTALL_DIR: $SDK_INSTALL_DIR"
-
-if [ ! -d $DEVKIT_ROOT/$SDK_VERSION ]; then
- echo "Copying SDK..."
- mkdir -p $DEVKIT_ROOT/$SDK_VERSION/bin
- cp -r "$SDK_INSTALL_DIR/bin/x64" $DEVKIT_ROOT/$SDK_VERSION/bin/
- cp -r "$SDK_INSTALL_DIR/bin/x86" $DEVKIT_ROOT/$SDK_VERSION/bin/
- mkdir -p $DEVKIT_ROOT/$SDK_VERSION/lib
- cp -r "$SDK_INSTALL_DIR/lib/"winv*/um/x64 $DEVKIT_ROOT/$SDK_VERSION/lib/
- cp -r "$SDK_INSTALL_DIR/lib/"winv*/um/x86 $DEVKIT_ROOT/$SDK_VERSION/lib/
- cp -r "$SDK_INSTALL_DIR/include" $DEVKIT_ROOT/$SDK_VERSION/
- # In 2015, the new Universal CRT is delivered in the sdk 10 directory
- # so need to include that as well.
- mkdir -p $DEVKIT_ROOT/10/lib
- cp -r "$SDK_INSTALL_DIR/../10/lib/10.0.10240.0/ucrt" $DEVKIT_ROOT/10/lib/
- mkdir -p $DEVKIT_ROOT/10/include
- cp -r "$SDK_INSTALL_DIR/../10/include/10.0.10240.0/ucrt" $DEVKIT_ROOT/10/include/
-fi
-
-################################################################################
-# Generate devkit.info
-
-echo-info() {
- echo "$1" >> $DEVKIT_ROOT/devkit.info
-}
-
-echo "Generating devkit.info..."
-rm -f $DEVKIT_ROOT/devkit.info
-echo-info "# This file describes to configure how to interpret the contents of this devkit"
-echo-info "DEVKIT_NAME=\"Microsoft Visual Studio $VS_VERSION $VS_VERSION_SP (devkit)\""
-echo-info "DEVKIT_VS_VERSION=\"$VS_VERSION\""
-echo-info ""
-echo-info "DEVKIT_TOOLCHAIN_PATH_x86=\"\$DEVKIT_ROOT/VC/bin:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\""
-echo-info "DEVKIT_VS_INCLUDE_x86=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt;\$DEVKIT_ROOT/10/include/ucrt\""
-echo-info "DEVKIT_VS_LIB_x86=\"\$DEVKIT_ROOT/VC/lib;\$DEVKIT_ROOT/VC/atlmfc/lib;\$DEVKIT_ROOT/$SDK_VERSION/lib/x86;\$DEVKIT_ROOT/10/lib/ucrt/x86\""
-echo-info "DEVKIT_MSVCR_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL\""
-echo-info "DEVKIT_MSVCP_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL\""
-echo-info ""
-echo-info "DEVKIT_TOOLCHAIN_PATH_x86_64=\"\$DEVKIT_ROOT/VC/bin/amd64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\""
-echo-info "DEVKIT_VS_INCLUDE_x86_64=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt;\$DEVKIT_ROOT/10/include/ucrt\""
-echo-info "DEVKIT_VS_LIB_x86_64=\"\$DEVKIT_ROOT/VC/lib/amd64;\$DEVKIT_ROOT/VC/atlmfc/lib/amd64;\$DEVKIT_ROOT/$SDK_VERSION/lib/x64;\$DEVKIT_ROOT/10/lib/ucrt/x64\""
-echo-info "DEVKIT_MSVCR_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL\""
-echo-info "DEVKIT_MSVCP_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL\""
-
-################################################################################
-# Copy this script
-
-echo "Copying this script..."
-cp $0 $DEVKIT_ROOT/
-
-################################################################################
-# Create bundle
-
-echo "Creating bundle: $DEVKIT_BUNDLE"
-(cd "$DEVKIT_ROOT" && tar zcf "$DEVKIT_BUNDLE" .)
--- a/make/devkit/createWindowsDevkit2017.sh Sat Mar 09 12:52:30 2019 +0000
+++ b/make/devkit/createWindowsDevkit2017.sh Sat Mar 09 12:54:20 2019 +0000
@@ -107,34 +107,37 @@
################################################################################
# Copy Visual Studio files
-if [ ! -d $DEVKIT_ROOT/VC ]; then
- VC_SUBDIR="VC/Tools/MSVC/$MSVC_FULL_VERSION"
- REDIST_SUBDIR="VC/Redist/MSVC/$REDIST_FULL_VERSION"
- echo "Copying VC..."
- mkdir -p $DEVKIT_ROOT/VC/bin
- cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/bin/Hostx64/x64" $DEVKIT_ROOT/VC/bin/
- cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/bin/Hostx86/x86" $DEVKIT_ROOT/VC/bin/
- mkdir -p $DEVKIT_ROOT/VC/lib
- cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/lib/x64" $DEVKIT_ROOT/VC/lib/
- cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/lib/x86" $DEVKIT_ROOT/VC/lib/
- cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/include" $DEVKIT_ROOT/VC/
- mkdir -p $DEVKIT_ROOT/VC/atlmfc/lib
- cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/lib/x64" $DEVKIT_ROOT/VC/atlmfc/lib/
- cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/lib/x86" $DEVKIT_ROOT/VC/atlmfc/lib/
- cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/include" $DEVKIT_ROOT/VC/atlmfc/
- mkdir -p $DEVKIT_ROOT/VC/Auxiliary
- cp -r "$VS_INSTALL_DIR/VC/Auxiliary/Build" $DEVKIT_ROOT/VC/Auxiliary/
- mkdir -p $DEVKIT_ROOT/VC/redist
- cp -r "$VS_INSTALL_DIR/$REDIST_SUBDIR/x64" $DEVKIT_ROOT/VC/redist/
- cp -r "$VS_INSTALL_DIR/$REDIST_SUBDIR/x86" $DEVKIT_ROOT/VC/redist/
+TOOLS_VERSION="$(ls "$VS_INSTALL_DIR/VC/Tools/MSVC" | sort -r -n | head -n1)"
+echo "Found Tools version: $TOOLS_VERSION"
+VC_SUBDIR="VC/Tools/MSVC/$TOOLS_VERSION"
+REDIST_VERSION="$(ls "$VS_INSTALL_DIR/VC/Redist/MSVC" | sort -r -n | head -n1)"
+echo "Found Redist version: $REDIST_VERSION"
+REDIST_SUBDIR="VC/Redist/MSVC/$REDIST_VERSION"
+echo "Copying VC..."
+rm -rf $DEVKIT_ROOT/VC
+mkdir -p $DEVKIT_ROOT/VC/bin
+cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/bin/Hostx64/x64" $DEVKIT_ROOT/VC/bin/
+cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/bin/Hostx86/x86" $DEVKIT_ROOT/VC/bin/
+mkdir -p $DEVKIT_ROOT/VC/lib
+cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/lib/x64" $DEVKIT_ROOT/VC/lib/
+cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/lib/x86" $DEVKIT_ROOT/VC/lib/
+cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/include" $DEVKIT_ROOT/VC/
+mkdir -p $DEVKIT_ROOT/VC/atlmfc/lib
+cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/lib/x64" $DEVKIT_ROOT/VC/atlmfc/lib/
+cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/lib/x86" $DEVKIT_ROOT/VC/atlmfc/lib/
+cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/include" $DEVKIT_ROOT/VC/atlmfc/
+mkdir -p $DEVKIT_ROOT/VC/Auxiliary
+cp -r "$VS_INSTALL_DIR/VC/Auxiliary/Build" $DEVKIT_ROOT/VC/Auxiliary/
+mkdir -p $DEVKIT_ROOT/VC/redist
+cp -r "$VS_INSTALL_DIR/$REDIST_SUBDIR/x64" $DEVKIT_ROOT/VC/redist/
+cp -r "$VS_INSTALL_DIR/$REDIST_SUBDIR/x86" $DEVKIT_ROOT/VC/redist/
- # The redist runtime libs are needed to run the compiler but may not be
- # installed on the machine where the devkit will be used.
- cp $DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/x86
- cp $DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/x86
- cp $DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/x64
- cp $DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/x64
-fi
+# The redist runtime libs are needed to run the compiler but may not be
+# installed on the machine where the devkit will be used.
+cp $DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/x86
+cp $DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/x86
+cp $DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/x64
+cp $DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/x64
################################################################################
# Copy SDK files
@@ -142,21 +145,24 @@
SDK_INSTALL_DIR="$PROGRAMFILES_X86/Windows Kits/$SDK_VERSION"
echo "SDK_INSTALL_DIR: $SDK_INSTALL_DIR"
-if [ ! -d $DEVKIT_ROOT/$SDK_VERSION ]; then
- echo "Copying SDK..."
- mkdir -p $DEVKIT_ROOT/$SDK_VERSION/bin
- cp -r "$SDK_INSTALL_DIR/bin/$SDK_FULL_VERSION/x64" $DEVKIT_ROOT/$SDK_VERSION/bin/
- cp -r "$SDK_INSTALL_DIR/bin/$SDK_FULL_VERSION/x86" $DEVKIT_ROOT/$SDK_VERSION/bin/
- mkdir -p $DEVKIT_ROOT/$SDK_VERSION/lib
- cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/um/x64" $DEVKIT_ROOT/$SDK_VERSION/lib/
- cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/um/x86" $DEVKIT_ROOT/$SDK_VERSION/lib/
- cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/ucrt/x64" $DEVKIT_ROOT/$SDK_VERSION/lib/
- cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/ucrt/x86" $DEVKIT_ROOT/$SDK_VERSION/lib/
- mkdir -p $DEVKIT_ROOT/$SDK_VERSION/Redist
- cp -r "$SDK_INSTALL_DIR/Redist/ucrt" $DEVKIT_ROOT/$SDK_VERSION/Redist/
- mkdir -p $DEVKIT_ROOT/$SDK_VERSION/include
- cp -r "$SDK_INSTALL_DIR/include/$SDK_FULL_VERSION/"* $DEVKIT_ROOT/$SDK_VERSION/include/
-fi
+SDK_FULL_VERSION="$(ls "$SDK_INSTALL_DIR/bin" | sort -r -n | head -n1)"
+echo "Found SDK version: $SDK_FULL_VERSION"
+UCRT_VERSION="$(ls "$SDK_INSTALL_DIR/Redist" | grep $SDK_VERSION | sort -r -n | head -n1)"
+echo "Found UCRT version: $UCRT_VERSION"
+echo "Copying SDK..."
+rm -rf $DEVKIT_ROOT/$SDK_VERSION
+mkdir -p $DEVKIT_ROOT/$SDK_VERSION/bin
+cp -r "$SDK_INSTALL_DIR/bin/$SDK_FULL_VERSION/x64" $DEVKIT_ROOT/$SDK_VERSION/bin/
+cp -r "$SDK_INSTALL_DIR/bin/$SDK_FULL_VERSION/x86" $DEVKIT_ROOT/$SDK_VERSION/bin/
+mkdir -p $DEVKIT_ROOT/$SDK_VERSION/lib
+cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/um/x64" $DEVKIT_ROOT/$SDK_VERSION/lib/
+cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/um/x86" $DEVKIT_ROOT/$SDK_VERSION/lib/
+cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/ucrt/x64" $DEVKIT_ROOT/$SDK_VERSION/lib/
+cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/ucrt/x86" $DEVKIT_ROOT/$SDK_VERSION/lib/
+mkdir -p $DEVKIT_ROOT/$SDK_VERSION/Redist
+cp -r "$SDK_INSTALL_DIR/Redist/$UCRT_VERSION/ucrt" $DEVKIT_ROOT/$SDK_VERSION/Redist/
+mkdir -p $DEVKIT_ROOT/$SDK_VERSION/include
+cp -r "$SDK_INSTALL_DIR/include/$SDK_FULL_VERSION/"* $DEVKIT_ROOT/$SDK_VERSION/include/
################################################################################
# Generate devkit.info
@@ -184,6 +190,11 @@
echo-info "DEVKIT_MSVCR_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL\""
echo-info "DEVKIT_MSVCP_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL\""
echo-info "DEVKIT_UCRT_DLL_DIR_x86_64=\"\$DEVKIT_ROOT/10/Redist/ucrt/DLLs/x64\""
+echo-info ""
+echo-info "DEVKIT_TOOLS_VERSION=\"$TOOLS_VERSION\""
+echo-info "DEVKIT_REDIST_VERSION=\"$REDIST_VERSION\""
+echo-info "DEVKIT_SDK_VERSION=\"$SDK_FULL_VERSION\""
+echo-info "DEVKIT_UCRT_VERSION=\"$UCRT_VERSION\""
################################################################################
# Copy this script
--- a/make/gensrc/GensrcCommonJdk.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/gensrc/GensrcCommonJdk.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
include $(SPEC)
include MakeBase.gmk
+include Execute.gmk
include JavaCompilation.gmk
include NativeCompilation.gmk
include TextFileProcessing.gmk
--- a/make/gensrc/GensrcX11Wrappers.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/gensrc/GensrcX11Wrappers.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
# 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,27 +26,22 @@
# Generate java sources using the X11 offsets that are precalculated in files
# make/data/x11wrappergen/sizes-<address size>.txt.
-GENSRC_X11WRAPPERS_OUTPUT_TOP := $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop
-
-GENSRC_X11WRAPPERS_MARKER := $(GENSRC_X11WRAPPERS_OUTPUT_TOP)/_x11wrappers.marker
-
# Put the generated Java classes used to interface X11 from awt here.
-GENSRC_X11WRAPPERS_OUTPUTDIR := $(GENSRC_X11WRAPPERS_OUTPUT_TOP)/sun/awt/X11
+GENSRC_X11WRAPPERS_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/sun/awt/X11
# The pre-calculated offset file are stored here:
GENSRC_X11WRAPPERS_DATADIR := $(TOPDIR)/make/data/x11wrappergen
GENSRC_X11WRAPPERS_DATA := $(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(OPENJDK_TARGET_CPU_BITS).txt
# Run the tool on the offset files to generate several Java classes used in awt.
-$(GENSRC_X11WRAPPERS_MARKER): $(BUILD_TOOLS_JDK) $(GENSRC_X11WRAPPERS_DATA) \
- $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt
- $(call MakeDir, $(GENSRC_X11WRAPPERS_OUTPUTDIR))
- $(call LogInfo, Generating X11 wrapper source files)
- $(call ExecuteWithLog, $@, \
- $(TOOL_WRAPPERGENERATOR) gen_java $(GENSRC_X11WRAPPERS_OUTPUTDIR) \
- $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(GENSRC_X11WRAPPERS_DATA) \
- $(OPENJDK_TARGET_CPU_BITS))
- $(TOUCH) $@
+$(eval $(call SetupExecute, gen_x11wrappers, \
+ INFO := Generating X11 wrapper source files, \
+ DEPS := $(BUILD_TOOLS_JDK) $(GENSRC_X11WRAPPERS_DATA) \
+ $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt, \
+ OUTPUT_DIR := $(GENSRC_X11WRAPPERS_OUTPUTDIR), \
+ COMMAND := $(TOOL_WRAPPERGENERATOR) gen_java $(GENSRC_X11WRAPPERS_OUTPUTDIR) \
+ $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(GENSRC_X11WRAPPERS_DATA) \
+ $(OPENJDK_TARGET_CPU_BITS), \
+))
-
-GENSRC_JAVA_DESKTOP += $(GENSRC_X11WRAPPERS_MARKER)
+GENSRC_JAVA_DESKTOP += $(gen_x11wrappers_TARGET)
--- a/make/hotspot/gensrc/GenerateSources.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/hotspot/gensrc/GenerateSources.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
include $(SPEC)
include MakeBase.gmk
+include Execute.gmk
include JavaCompilation.gmk
include NativeCompilation.gmk
include TextFileProcessing.gmk
@@ -35,10 +36,10 @@
# The real work is done in these files
+include gensrc/GensrcJfr.gmk
include gensrc/GensrcAdlc.gmk
include gensrc/GensrcDtrace.gmk
include gensrc/GensrcJvmti.gmk
-include gensrc/GensrcJfr.gmk
$(eval $(call IncludeCustomExtension, hotspot/gensrc/GenerateSources.gmk))
--- a/make/hotspot/gensrc/GensrcAdlc.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/hotspot/gensrc/GensrcAdlc.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -166,18 +166,16 @@
##############################################################################
# Run the adlc tool on the single concatenated ad source file, and store the
# output in support/adlc for further processing.
- ADLC_RUN_MARKER := $(ADLC_SUPPORT_DIR)/_adlc_run.marker
-
- $(ADLC_RUN_MARKER): $(BUILD_ADLC) $(SINGLE_AD_SRCFILE)
- $(call LogInfo, Generating adlc files)
- $(call MakeDir, $(@D))
- $(call ExecuteWithLog, $(ADLC_SUPPORT_DIR)/adlc_run, \
- $(FIXPATH) $(ADLC_TOOL) $(ADLCFLAGS) $(SINGLE_AD_SRCFILE) \
- -c$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
- -h$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
- -a$(ADLC_SUPPORT_DIR)/dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
- -v$(ADLC_SUPPORT_DIR)/adGlobals_$(HOTSPOT_TARGET_CPU_ARCH).hpp)
- $(TOUCH) $@
+ $(eval $(call SetupExecute, adlc_run, \
+ INFO := Generating adlc files, \
+ DEPS := $(BUILD_ADLC) $(SINGLE_AD_SRCFILE), \
+ OUTPUT_DIR := $(ADLC_SUPPORT_DIR), \
+ COMMAND := $(FIXPATH) $(ADLC_TOOL) $(ADLCFLAGS) $(SINGLE_AD_SRCFILE) \
+ -c$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
+ -h$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
+ -a$(ADLC_SUPPORT_DIR)/dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
+ -v$(ADLC_SUPPORT_DIR)/adGlobals_$(HOTSPOT_TARGET_CPU_ARCH).hpp, \
+ ))
##############################################################################
# Finally copy the generated files from support/adlc into gensrc/adfiles,
@@ -197,7 +195,7 @@
dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
)
- $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles/%: $(ADLC_RUN_MARKER)
+ $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles/%: $(adlc_run_TARGET)
$(call LogInfo, Postprocessing adlc file $*)
$(call MakeDir, $(@D))
$(NAWK) \
@@ -206,6 +204,6 @@
{print}' \
< $(ADLC_SUPPORT_DIR)/$* > $@
- TARGETS := $(ADLC_GENERATED_FILES)
+ TARGETS += $(ADLC_GENERATED_FILES)
endif
--- a/make/hotspot/gensrc/GensrcDtrace.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/hotspot/gensrc/GensrcDtrace.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -64,9 +64,9 @@
include lib/JvmFeatures.gmk
include lib/JvmFlags.gmk
- # We cannot compile until the JVMTI and JFR gensrc has finished
+ # We cannot compile until the JVMTI and JFR gensrc has finished.
+ # JFR_FILES is defined in GensrcJfr.gmk.
JVMTI_H := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles/jvmti.h
- JFR_FILES := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jfrfiles/jfrEventClasses.hpp
$(eval $(call SetupNativeCompilation, BUILD_DTRACE_GEN_OFFSETS, \
NAME := dtraceGenOffsets, \
@@ -87,12 +87,14 @@
# Argument 1: Output filename
# Argument 2: dtrace-gen-offset tool command line option
define SetupDtraceOffsetsGeneration
- $1: $$(BUILD_DTRACE_GEN_OFFSETS)
- $$(call LogInfo, Generating dtrace $2 file $$(@F))
- $$(call MakeDir, $$(@D))
- $$(call ExecuteWithLog, $$@, ( $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $$@ ) )
+ $$(eval $$(call SetupExecute, dtrace_offset_$$(strip $2), \
+ INFO := Generating dtrace $2 file, \
+ DEPS := $$(BUILD_DTRACE_GEN_OFFSETS), \
+ OUTPUT_FILE := $1, \
+ COMMAND := ( $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $1 ), \
+ ))
- TARGETS += $1
+ TARGETS += $$(dtrace_offset_$$(strip $2)_TARGET)
endef
JVM_OFFSETS_H := $(DTRACE_GENSRC_DIR)/JvmOffsets.h
--- a/make/hotspot/gensrc/GensrcJfr.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/hotspot/gensrc/GensrcJfr.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -57,11 +57,12 @@
METADATA_XML := $(JFR_SRCDIR)/metadata.xml
METADATA_XSD := $(JFR_SRCDIR)/metadata.xsd
-$(JFR_OUTPUTDIR)/jfrEventClasses.hpp: $(METADATA_XML) $(METADATA_XSD) \
- $(BUILD_JFR_TOOLS)
- $(call LogInfo, Generating $(@F))
- $(call MakeDir, $(@D))
- $(call ExecuteWithLog, $@, $(TOOL_JFR_GEN) $(METADATA_XML) $(METADATA_XSD) $(JFR_OUTPUTDIR))
- test -f $@
+$(eval $(call SetupExecute, jfr_gen, \
+ INFO := Generating JFR header files, \
+ DEPS := $(METADATA_XML) $(METADATA_XSD) $(BUILD_JFR_TOOLS), \
+ OUTPUT_DIR := $(JFR_OUTPUTDIR), \
+ COMMAND := $(TOOL_JFR_GEN) $(METADATA_XML) $(METADATA_XSD) $(JFR_OUTPUTDIR), \
+))
-TARGETS += $(JFR_OUTPUTDIR)/jfrEventClasses.hpp
+JFR_FILES := $(jfr_gen_TARGET)
+TARGETS += $(JFR_FILES)
--- a/make/hotspot/gensrc/GensrcJvmti.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/hotspot/gensrc/GensrcJvmti.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
# 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,6 +28,7 @@
################################################################################
# Build tools needed for the JVMTI source code generation
+# FIXME: jvmtiGen.java should move to make/src, jvmtiEnvFill.java should be removed.
JVMTI_TOOLS_SRCDIR := $(TOPDIR)/src/hotspot/share/prims
JVMTI_TOOLS_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/tools/jvmti
@@ -64,16 +65,17 @@
# DEPS -- Additional dependencies
SetupXslTransform = $(NamedParamsMacroTemplate)
define SetupXslTransformBody
- $$($1_OUTPUT_DIR)/$1: $$($1_XML_FILE) $$($1_XSL_FILE) $$($1_DEPS) $$(BUILD_JVMTI_TOOLS)
- $$(call LogInfo, Generating $$(@F))
- $$(call MakeDir, $$(@D))
- $$(call ExecuteWithLog, $$@, $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) \
- -XSL $$($1_XSL_FILE) -OUT $$@ $$($1_ARGS))
- # jvmtiGen does not return error code properly on fail.
- # NOTE: We should really fix jvmtiGen.java instead.
- test -f $$@
+ $1_OUTPUT_FILE := $$($1_OUTPUT_DIR)/$1
- TARGETS += $$($1_OUTPUT_DIR)/$1
+ $$(eval $$(call SetupExecute, jvmti_gen_$1, \
+ INFO := Generating jvmti file $1, \
+ DEPS := $$($1_XML_FILE) $$($1_XSL_FILE) $$($1_DEPS) $$(BUILD_JVMTI_TOOLS), \
+ OUTPUT_FILE := $$($1_OUTPUT_FILE), \
+ COMMAND := $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) \
+ -XSL $$($1_XSL_FILE) -OUT $$($1_OUTPUT_FILE) $$($1_ARGS), \
+ ))
+
+ TARGETS += $$(jvmti_gen_$1_TARGET)
endef
################################################################################
--- a/make/hotspot/ide/CreateVSProject.gmk Sat Mar 09 12:52:30 2019 +0000
+++ b/make/hotspot/ide/CreateVSProject.gmk Sat Mar 09 12:54:20 2019 +0000
@@ -144,14 +144,16 @@
VCPROJ_VARDEPS_FILE := $(call DependOnVariable, VCPROJ_VARDEPS, \
$(VCPROJ_FILE).vardeps)
- $(VCPROJ_FILE): $(BUILD_PROJECT_CREATOR) $(VCPROJ_VARDEPS_FILE)
- $(call MakeDir, $(@D))
- $(call ExecuteWithLog, $@, \
- $(PROJECT_CREATOR_TOOL) $(PROJECT_CREATOR_CLASS) \
- $(PROJECT_CREATOR_ARGS) -projectFileName $(call FixPath, $@)) \
- $(LOG_INFO)
+ $(eval $(call SetupExecute, vcproj_file, \
+ INFO := Generating Visual Studio project file, \
+ DEPS := $(BUILD_PROJECT_CREATOR) $(VCPROJ_VARDEPS_FILE), \
+ OUTPUT_FILE := $(VCPROJ_FILE), \
+ COMMAND := $(PROJECT_CREATOR_TOOL) $(PROJECT_CREATOR_CLASS) \
+ $(PROJECT_CREATOR_ARGS) -projectFileName $(call FixPath, $(VCPROJ_FILE))) \
+ $(LOG_INFO), \
+ ))
- TARGETS += $(VCPROJ_FILE)
+ TARGETS += $(vcproj_file_TARGET)
all: $(TARGETS)
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, 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
@@ -373,15 +373,9 @@
Register last_java_fp,
address last_java_pc,
Register scratch) {
- if (last_java_pc != NULL) {
- adr(scratch, last_java_pc);
- } else {
- // FIXME: This is almost never correct. We should delete all
- // cases of set_last_Java_frame with last_java_pc=NULL and use the
- // correct return address instead.
- adr(scratch, pc());
- }
-
+ assert(last_java_pc != NULL, "must provide a valid PC");
+
+ adr(scratch, last_java_pc);
str(scratch, Address(rthread,
JavaThread::frame_anchor_offset()
+ JavaFrameAnchor::last_Java_pc_offset()));
@@ -398,7 +392,7 @@
} else {
InstructionMark im(this);
L.add_patch_at(code(), locator());
- set_last_Java_frame(last_java_sp, last_java_fp, (address)NULL, scratch);
+ set_last_Java_frame(last_java_sp, last_java_fp, pc() /* Patched later */, scratch);
}
}
--- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014, 2018, Red Hat Inc. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, 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
@@ -1782,14 +1782,11 @@
}
// Change state to native (we save the return address in the thread, since it might not
- // be pushed on the stack when we do a a stack traversal). It is enough that the pc()
- // points into the right code segment. It does not have to be the correct return pc.
+ // be pushed on the stack when we do a stack traversal).
// We use the same pc/oopMap repeatedly when we call out
- intptr_t the_pc = (intptr_t) __ pc();
- oop_maps->add_gc_map(the_pc - start, map);
-
- __ set_last_Java_frame(sp, noreg, (address)the_pc, rscratch1);
+ Label native_return;
+ __ set_last_Java_frame(sp, noreg, native_return, rscratch1);
Label dtrace_method_entry, dtrace_method_entry_done;
{
@@ -1922,6 +1919,11 @@
return_type);
}
+ __ bind(native_return);
+
+ intptr_t return_pc = (intptr_t) __ pc();
+ oop_maps->add_gc_map(return_pc - start, map);
+
// Unpack native results.
switch (ret_type) {
case T_BOOLEAN: __ c2bool(r0); break;
--- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, 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
@@ -4800,7 +4800,7 @@
// Set up last_Java_sp and last_Java_fp
address the_pc = __ pc();
- __ set_last_Java_frame(sp, rfp, (address)NULL, rscratch1);
+ __ set_last_Java_frame(sp, rfp, the_pc, rscratch1);
// Call runtime
if (arg1 != noreg) {
--- a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014, 2018, Red Hat Inc. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, 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
@@ -1351,9 +1351,11 @@
// pass JNIEnv
__ add(c_rarg0, rthread, in_bytes(JavaThread::jni_environment_offset()));
- // It is enough that the pc() points into the right code
- // segment. It does not have to be the correct return pc.
- __ set_last_Java_frame(esp, rfp, (address)NULL, rscratch1);
+ // Set the last Java PC in the frame anchor to be the return address from
+ // the call to the native method: this will allow the debugger to
+ // generate an accurate stack trace.
+ Label native_return;
+ __ set_last_Java_frame(esp, rfp, native_return, rscratch1);
// change thread state
#ifdef ASSERT
@@ -1374,6 +1376,7 @@
// Call the native method.
__ blrt(r10, rscratch1);
+ __ bind(native_return);
__ maybe_isb();
__ get_method(rmethod);
// result potentially in r0 or v0
--- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -219,6 +219,16 @@
}
}
+ // HiSilicon TSV110
+ if (_cpu == CPU_HISILICON && _model == 0xd01) {
+ if (FLAG_IS_DEFAULT(AvoidUnalignedAccesses)) {
+ FLAG_SET_DEFAULT(AvoidUnalignedAccesses, true);
+ }
+ if (FLAG_IS_DEFAULT(UseSIMDForMemoryOps)) {
+ FLAG_SET_DEFAULT(UseSIMDForMemoryOps, true);
+ }
+ }
+
// Cortex A53
if (_cpu == CPU_ARM && (_model == 0xd03 || _model2 == 0xd03)) {
_features |= CPU_A53MAC;
--- a/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -72,6 +72,7 @@
CPU_BROADCOM = 'B',
CPU_CAVIUM = 'C',
CPU_DEC = 'D',
+ CPU_HISILICON = 'H',
CPU_INFINEON = 'I',
CPU_MOTOROLA = 'M',
CPU_NVIDIA = 'N',
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2017, SAP SE. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -2378,23 +2378,28 @@
void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, Label* failure, Label* obj_is_null) {
- Register obj = op->object()->as_register();
+ const Register obj = op->object()->as_register(); // Needs to live in this register at safepoint (patching stub).
Register k_RInfo = op->tmp1()->as_register();
Register klass_RInfo = op->tmp2()->as_register();
Register Rtmp1 = op->tmp3()->as_register();
Register dst = op->result_opr()->as_register();
ciKlass* k = op->klass();
bool should_profile = op->should_profile();
- bool move_obj_to_dst = (op->code() == lir_checkcast);
// Attention: do_temp(opTypeCheck->_object) is not used, i.e. obj may be same as one of the temps.
- bool reg_conflict = (obj == k_RInfo || obj == klass_RInfo || obj == Rtmp1);
- bool restore_obj = move_obj_to_dst && reg_conflict;
+ bool reg_conflict = false;
+ if (obj == k_RInfo) {
+ k_RInfo = dst;
+ reg_conflict = true;
+ } else if (obj == klass_RInfo) {
+ klass_RInfo = dst;
+ reg_conflict = true;
+ } else if (obj == Rtmp1) {
+ Rtmp1 = dst;
+ reg_conflict = true;
+ }
+ assert_different_registers(obj, k_RInfo, klass_RInfo, Rtmp1);
__ cmpdi(CCR0, obj, 0);
- if (move_obj_to_dst || reg_conflict) {
- __ mr_if_needed(dst, obj);
- if (reg_conflict) { obj = dst; }
- }
ciMethodData* md = NULL;
ciProfileData* data = NULL;
@@ -2460,12 +2465,27 @@
} else {
// Call out-of-line instance of __ check_klass_subtype_slow_path(...):
address entry = Runtime1::entry_for(Runtime1::slow_subtype_check_id);
- //__ load_const_optimized(Rtmp1, entry, R0);
- __ calculate_address_from_global_toc(Rtmp1, entry, true, true, false);
- __ mtctr(Rtmp1);
+ // Stub needs fixed registers (tmp1-3).
+ Register original_k_RInfo = op->tmp1()->as_register();
+ Register original_klass_RInfo = op->tmp2()->as_register();
+ Register original_Rtmp1 = op->tmp3()->as_register();
+ bool keep_obj_alive = reg_conflict && (op->code() == lir_checkcast);
+ bool keep_klass_RInfo_alive = (obj == original_klass_RInfo) && should_profile;
+ if (keep_obj_alive && (obj != original_Rtmp1)) { __ mr(R0, obj); }
+ __ mr_if_needed(original_k_RInfo, k_RInfo);
+ __ mr_if_needed(original_klass_RInfo, klass_RInfo);
+ if (keep_obj_alive) { __ mr(dst, (obj == original_Rtmp1) ? obj : R0); }
+ //__ load_const_optimized(original_Rtmp1, entry, R0);
+ __ calculate_address_from_global_toc(original_Rtmp1, entry, true, true, false);
+ __ mtctr(original_Rtmp1);
__ bctrl(); // sets CR0
+ if (keep_obj_alive) {
+ if (keep_klass_RInfo_alive) { __ mr(R0, obj); }
+ __ mr(obj, dst);
+ }
if (should_profile) {
__ bne(CCR0, *failure_target);
+ if (keep_klass_RInfo_alive) { __ mr(klass_RInfo, keep_obj_alive ? R0 : obj); }
// Fall through to success case.
} else {
__ beq(CCR0, *success);
@@ -2493,11 +2513,6 @@
}
__ bind(*failure);
-
- if (restore_obj) {
- __ mr(op->object()->as_register(), dst);
- // Fall through to failure case.
- }
}
@@ -2590,10 +2605,11 @@
} else if (code == lir_checkcast) {
Label success, failure;
- emit_typecheck_helper(op, &success, /*fallthru*/&failure, &success); // Moves obj to dst.
+ emit_typecheck_helper(op, &success, /*fallthru*/&failure, &success);
__ b(*op->stub()->entry());
__ align(32, 12);
__ bind(success);
+ __ mr_if_needed(op->result_opr()->as_register(), op->object()->as_register());
} else if (code == lir_instanceof) {
Register dst = op->result_opr()->as_register();
Label success, failure, done;
--- a/src/hotspot/cpu/x86/assembler_x86.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/x86/assembler_x86.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -7765,9 +7765,43 @@
}
}
+void Assembler::vmaxss(XMMRegister dst, XMMRegister nds, XMMRegister src) {
+ assert(VM_Version::supports_avx(), "");
+ InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
+ int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
+ emit_int8(0x5F);
+ emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::vmaxsd(XMMRegister dst, XMMRegister nds, XMMRegister src) {
+ assert(VM_Version::supports_avx(), "");
+ InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
+ attributes.set_rex_vex_w_reverted();
+ int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
+ emit_int8(0x5F);
+ emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::vminss(XMMRegister dst, XMMRegister nds, XMMRegister src) {
+ assert(VM_Version::supports_avx(), "");
+ InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
+ int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
+ emit_int8(0x5D);
+ emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::vminsd(XMMRegister dst, XMMRegister nds, XMMRegister src) {
+ assert(VM_Version::supports_avx(), "");
+ InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);
+ attributes.set_rex_vex_w_reverted();
+ int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
+ emit_int8(0x5D);
+ emit_int8((unsigned char)(0xC0 | encode));
+}
+
void Assembler::cmppd(XMMRegister dst, XMMRegister nds, XMMRegister src, int cop, int vector_len) {
assert(VM_Version::supports_avx(), "");
- assert(!VM_Version::supports_evex(), "");
+ assert(vector_len <= AVX_256bit, "");
InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ true, /* 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)0xC2);
@@ -7777,7 +7811,7 @@
void Assembler::blendvpd(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len) {
assert(VM_Version::supports_avx(), "");
- assert(!VM_Version::supports_evex(), "");
+ assert(vector_len <= AVX_256bit, "");
InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ true);
int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src1->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int8((unsigned char)0x4B);
@@ -7788,7 +7822,7 @@
void Assembler::cmpps(XMMRegister dst, XMMRegister nds, XMMRegister src, int cop, int vector_len) {
assert(VM_Version::supports_avx(), "");
- assert(!VM_Version::supports_evex(), "");
+ assert(vector_len <= AVX_256bit, "");
InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ true);
int encode = simd_prefix_and_encode(dst, nds, src, VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes);
emit_int8((unsigned char)0xC2);
@@ -7798,7 +7832,7 @@
void Assembler::blendvps(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len) {
assert(VM_Version::supports_avx(), "");
- assert(!VM_Version::supports_evex(), "");
+ assert(vector_len <= AVX_256bit, "");
InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ true);
int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src1->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int8((unsigned char)0x4A);
--- a/src/hotspot/cpu/x86/assembler_x86.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/x86/assembler_x86.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -1934,6 +1934,11 @@
void vsubss(XMMRegister dst, XMMRegister nds, Address src);
void vsubss(XMMRegister dst, XMMRegister nds, XMMRegister src);
+ void vmaxss(XMMRegister dst, XMMRegister nds, XMMRegister src);
+ void vmaxsd(XMMRegister dst, XMMRegister nds, XMMRegister src);
+ void vminss(XMMRegister dst, XMMRegister nds, XMMRegister src);
+ void vminsd(XMMRegister dst, XMMRegister nds, XMMRegister src);
+
void shlxl(Register dst, Register src1, Register src2);
void shlxq(Register dst, Register src1, Register src2);
--- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -165,6 +165,7 @@
// Support optimal SSE move instructions.
void movflt(XMMRegister dst, XMMRegister src) {
+ if (dst-> encoding() == src->encoding()) return;
if (UseXmmRegToRegMoveAll) { movaps(dst, src); return; }
else { movss (dst, src); return; }
}
@@ -173,6 +174,7 @@
void movflt(Address dst, XMMRegister src) { movss(dst, src); }
void movdbl(XMMRegister dst, XMMRegister src) {
+ if (dst-> encoding() == src->encoding()) return;
if (UseXmmRegToRegMoveAll) { movapd(dst, src); return; }
else { movsd (dst, src); return; }
}
--- a/src/hotspot/cpu/x86/stubRoutines_x86.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/x86/stubRoutines_x86.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -33,7 +33,7 @@
enum platform_dependent_constants {
code_size1 = 20000 LP64_ONLY(+10000), // simply increase if too small (assembler will crash if too small)
- code_size2 = 35300 LP64_ONLY(+10000) // simply increase if too small (assembler will crash if too small)
+ code_size2 = 35300 LP64_ONLY(+11000) // simply increase if too small (assembler will crash if too small)
};
class x86 {
--- a/src/hotspot/cpu/x86/x86.ad Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/x86/x86.ad Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+// Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
@@ -1450,6 +1450,15 @@
if (UseSSE < 2)
ret_value = false;
break;
+#ifdef _LP64
+ case Op_MaxD:
+ case Op_MaxF:
+ case Op_MinD:
+ case Op_MinF:
+ if (UseAVX < 1) // enabled for AVX only
+ ret_value = false;
+ break;
+#endif
}
return ret_value; // Per default match rules are supported.
--- a/src/hotspot/cpu/x86/x86_64.ad Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/cpu/x86/x86_64.ad Sat Mar 09 12:54:20 2019 +0000
@@ -698,6 +698,87 @@
__ bind(done);
}
+// Math.min() # Math.max()
+// --------------------------
+// ucomis[s/d] #
+// ja -> b # a
+// jp -> NaN # NaN
+// jb -> a # b
+// je #
+// |-jz -> a | b # a & b
+// | -> a #
+void emit_fp_min_max(MacroAssembler& _masm, XMMRegister dst,
+ XMMRegister a, XMMRegister b,
+ XMMRegister xmmt, Register rt,
+ bool min, bool single) {
+
+ Label nan, zero, below, above, done;
+
+ if (single)
+ __ ucomiss(a, b);
+ else
+ __ ucomisd(a, b);
+
+ if (dst->encoding() != (min ? b : a)->encoding())
+ __ jccb(Assembler::above, above); // CF=0 & ZF=0
+ else
+ __ jccb(Assembler::above, done);
+
+ __ jccb(Assembler::parity, nan); // PF=1
+ __ jccb(Assembler::below, below); // CF=1
+
+ // equal
+ __ vpxor(xmmt, xmmt, xmmt, Assembler::AVX_128bit);
+ if (single) {
+ __ ucomiss(a, xmmt);
+ __ jccb(Assembler::equal, zero);
+
+ __ movflt(dst, a);
+ __ jmp(done);
+ }
+ else {
+ __ ucomisd(a, xmmt);
+ __ jccb(Assembler::equal, zero);
+
+ __ movdbl(dst, a);
+ __ jmp(done);
+ }
+
+ __ bind(zero);
+ if (min)
+ __ vpor(dst, a, b, Assembler::AVX_128bit);
+ else
+ __ vpand(dst, a, b, Assembler::AVX_128bit);
+
+ __ jmp(done);
+
+ __ bind(above);
+ if (single)
+ __ movflt(dst, min ? b : a);
+ else
+ __ movdbl(dst, min ? b : a);
+
+ __ jmp(done);
+
+ __ bind(nan);
+ if (single) {
+ __ movl(rt, 0x7fc00000); // Float.NaN
+ __ movdl(dst, rt);
+ }
+ else {
+ __ mov64(rt, 0x7ff8000000000000L); // Double.NaN
+ __ movdq(dst, rt);
+ }
+ __ jmp(done);
+
+ __ bind(below);
+ if (single)
+ __ movflt(dst, min ? a : b);
+ else
+ __ movdbl(dst, min ? a : b);
+
+ __ bind(done);
+}
//=============================================================================
const RegMask& MachConstantBaseNode::_out_RegMask = RegMask::Empty;
@@ -3548,6 +3629,15 @@
%}
// Float register operands
+operand legRegF() %{
+ constraint(ALLOC_IN_RC(float_reg_legacy));
+ match(RegF);
+
+ format %{ %}
+ interface(REG_INTER);
+%}
+
+// Float register operands
operand vlRegF() %{
constraint(ALLOC_IN_RC(float_reg_vl));
match(RegF);
@@ -3566,6 +3656,15 @@
%}
// Double register operands
+operand legRegD() %{
+ constraint(ALLOC_IN_RC(double_reg_legacy));
+ match(RegD);
+
+ format %{ %}
+ interface(REG_INTER);
+%}
+
+// Double register operands
operand vlRegD() %{
constraint(ALLOC_IN_RC(double_reg_vl));
match(RegD);
@@ -5304,6 +5403,16 @@
%}
// Load Float
+instruct MoveF2LEG(legRegF dst, regF src) %{
+ match(Set dst src);
+ format %{ "movss $dst,$src\t# if src != dst load float (4 bytes)" %}
+ ins_encode %{
+ __ movflt($dst$$XMMRegister, $src$$XMMRegister);
+ %}
+ ins_pipe( fpu_reg_reg );
+%}
+
+// Load Float
instruct MoveVL2F(regF dst, vlRegF src) %{
match(Set dst src);
format %{ "movss $dst,$src\t! load float (4 bytes)" %}
@@ -5313,6 +5422,16 @@
ins_pipe( fpu_reg_reg );
%}
+// Load Float
+instruct MoveLEG2F(regF dst, legRegF src) %{
+ match(Set dst src);
+ format %{ "movss $dst,$src\t# if src != dst load float (4 bytes)" %}
+ ins_encode %{
+ __ movflt($dst$$XMMRegister, $src$$XMMRegister);
+ %}
+ ins_pipe( fpu_reg_reg );
+%}
+
// Load Double
instruct loadD_partial(regD dst, memory mem)
%{
@@ -5351,6 +5470,16 @@
%}
// Load Double
+instruct MoveD2LEG(legRegD dst, regD src) %{
+ match(Set dst src);
+ format %{ "movsd $dst,$src\t# if src != dst load double (8 bytes)" %}
+ ins_encode %{
+ __ movdbl($dst$$XMMRegister, $src$$XMMRegister);
+ %}
+ ins_pipe( fpu_reg_reg );
+%}
+
+// Load Double
instruct MoveVL2D(regD dst, vlRegD src) %{
match(Set dst src);
format %{ "movsd $dst,$src\t! load double (8 bytes)" %}
@@ -5360,6 +5489,167 @@
ins_pipe( fpu_reg_reg );
%}
+// Load Double
+instruct MoveLEG2D(regD dst, legRegD src) %{
+ match(Set dst src);
+ format %{ "movsd $dst,$src\t# if src != dst load double (8 bytes)" %}
+ ins_encode %{
+ __ movdbl($dst$$XMMRegister, $src$$XMMRegister);
+ %}
+ ins_pipe( fpu_reg_reg );
+%}
+
+// Following pseudo code describes the algorithm for max[FD]:
+// Min algorithm is on similar lines
+// btmp = (b < +0.0) ? a : b
+// atmp = (b < +0.0) ? b : a
+// Tmp = Max_Float(atmp , btmp)
+// Res = (atmp == NaN) ? atmp : Tmp
+
+// max = java.lang.Math.max(float a, float b)
+instruct maxF_reg(legRegF dst, legRegF a, legRegF b, legRegF tmp, legRegF atmp, legRegF btmp) %{
+ predicate(UseAVX > 0 && !n->is_reduction());
+ match(Set dst (MaxF a b));
+ effect(USE a, USE b, TEMP tmp, TEMP atmp, TEMP btmp);
+ format %{
+ "blendvps $btmp,$b,$a,$b \n\t"
+ "blendvps $atmp,$a,$b,$b \n\t"
+ "vmaxss $tmp,$atmp,$btmp \n\t"
+ "cmpps.unordered $btmp,$atmp,$atmp \n\t"
+ "blendvps $dst,$tmp,$atmp,$btmp \n\t"
+ %}
+ ins_encode %{
+ int vector_len = Assembler::AVX_128bit;
+ __ blendvps($btmp$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, vector_len);
+ __ blendvps($atmp$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $b$$XMMRegister, vector_len);
+ __ vmaxss($tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister);
+ __ cmpps($btmp$$XMMRegister, $atmp$$XMMRegister, $atmp$$XMMRegister, Assembler::_false, vector_len);
+ __ blendvps($dst$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct maxF_reduction_reg(regF dst, regF a, regF b, regF xmmt, rRegI tmp, rFlagsReg cr) %{
+ predicate(UseAVX > 0 && n->is_reduction());
+ match(Set dst (MaxF a b));
+ effect(USE a, USE b, TEMP xmmt, TEMP tmp, KILL cr);
+
+ format %{ "$dst = max($a, $b)\t# intrinsic (float)" %}
+ ins_encode %{
+ emit_fp_min_max(_masm, $dst$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $xmmt$$XMMRegister, $tmp$$Register,
+ false /*min*/, true /*single*/);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+// max = java.lang.Math.max(double a, double b)
+instruct maxD_reg(legRegD dst, legRegD a, legRegD b, legRegD tmp, legRegD atmp, legRegD btmp) %{
+ predicate(UseAVX > 0 && !n->is_reduction());
+ match(Set dst (MaxD a b));
+ effect(USE a, USE b, TEMP atmp, TEMP btmp, TEMP tmp);
+ format %{
+ "blendvpd $btmp,$b,$a,$b \n\t"
+ "blendvpd $atmp,$a,$b,$b \n\t"
+ "vmaxsd $tmp,$atmp,$btmp \n\t"
+ "cmppd.unordered $btmp,$atmp,$atmp \n\t"
+ "blendvpd $dst,$tmp,$atmp,$btmp \n\t"
+ %}
+ ins_encode %{
+ int vector_len = Assembler::AVX_128bit;
+ __ blendvpd($btmp$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, vector_len);
+ __ blendvpd($atmp$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $b$$XMMRegister, vector_len);
+ __ vmaxsd($tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister);
+ __ cmppd($btmp$$XMMRegister, $atmp$$XMMRegister, $atmp$$XMMRegister, Assembler::_false, vector_len);
+ __ blendvpd($dst$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct maxD_reduction_reg(regD dst, regD a, regD b, regD xmmt, rRegL tmp, rFlagsReg cr) %{
+ predicate(UseAVX > 0 && n->is_reduction());
+ match(Set dst (MaxD a b));
+ effect(USE a, USE b, TEMP xmmt, TEMP tmp, KILL cr);
+
+ format %{ "$dst = max($a, $b)\t# intrinsic (double)" %}
+ ins_encode %{
+ emit_fp_min_max(_masm, $dst$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $xmmt$$XMMRegister, $tmp$$Register,
+ false /*min*/, false /*single*/);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+// min = java.lang.Math.min(float a, float b)
+instruct minF_reg(legRegF dst, legRegF a, legRegF b, legRegF tmp, legRegF atmp, legRegF btmp) %{
+ predicate(UseAVX > 0 && !n->is_reduction());
+ match(Set dst (MinF a b));
+ effect(USE a, USE b, TEMP tmp, TEMP atmp, TEMP btmp);
+ format %{
+ "blendvps $atmp,$a,$b,$a \n\t"
+ "blendvps $btmp,$b,$a,$a \n\t"
+ "vminss $tmp,$atmp,$btmp \n\t"
+ "cmpps.unordered $btmp,$atmp,$atmp \n\t"
+ "blendvps $dst,$tmp,$atmp,$btmp \n\t"
+ %}
+ ins_encode %{
+ int vector_len = Assembler::AVX_128bit;
+ __ blendvps($atmp$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, vector_len);
+ __ blendvps($btmp$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, $a$$XMMRegister, vector_len);
+ __ vminss($tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister);
+ __ cmpps($btmp$$XMMRegister, $atmp$$XMMRegister, $atmp$$XMMRegister, Assembler::_false, vector_len);
+ __ blendvps($dst$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct minF_reduction_reg(regF dst, regF a, regF b, regF xmmt, rRegI tmp, rFlagsReg cr) %{
+ predicate(UseAVX > 0 && n->is_reduction());
+ match(Set dst (MinF a b));
+ effect(USE a, USE b, TEMP xmmt, TEMP tmp, KILL cr);
+
+ format %{ "$dst = min($a, $b)\t# intrinsic (float)" %}
+ ins_encode %{
+ emit_fp_min_max(_masm, $dst$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $xmmt$$XMMRegister, $tmp$$Register,
+ true /*min*/, true /*single*/);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+// min = java.lang.Math.min(double a, double b)
+instruct minD_reg(legRegD dst, legRegD a, legRegD b, legRegD tmp, legRegD atmp, legRegD btmp) %{
+ predicate(UseAVX > 0 && !n->is_reduction());
+ match(Set dst (MinD a b));
+ effect(USE a, USE b, TEMP tmp, TEMP atmp, TEMP btmp);
+ format %{
+ "blendvpd $atmp,$a,$b,$a \n\t"
+ "blendvpd $btmp,$b,$a,$a \n\t"
+ "vminsd $tmp,$atmp,$btmp \n\t"
+ "cmppd.unordered $btmp,$atmp,$atmp \n\t"
+ "blendvpd $dst,$tmp,$atmp,$btmp \n\t"
+ %}
+ ins_encode %{
+ int vector_len = Assembler::AVX_128bit;
+ __ blendvpd($atmp$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, vector_len);
+ __ blendvpd($btmp$$XMMRegister, $b$$XMMRegister, $a$$XMMRegister, $a$$XMMRegister, vector_len);
+ __ vminsd($tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister);
+ __ cmppd($btmp$$XMMRegister, $atmp$$XMMRegister, $atmp$$XMMRegister, Assembler::_false, vector_len);
+ __ blendvpd($dst$$XMMRegister, $tmp$$XMMRegister, $atmp$$XMMRegister, $btmp$$XMMRegister, vector_len);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
+instruct minD_reduction_reg(regD dst, regD a, regD b, regD xmmt, rRegL tmp, rFlagsReg cr) %{
+ predicate(UseAVX > 0 && n->is_reduction());
+ match(Set dst (MinD a b));
+ effect(USE a, USE b, TEMP xmmt, TEMP tmp, KILL cr);
+
+ format %{ "$dst = min($a, $b)\t# intrinsic (double)" %}
+ ins_encode %{
+ emit_fp_min_max(_masm, $dst$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $xmmt$$XMMRegister, $tmp$$Register,
+ true /*min*/, false /*single*/);
+ %}
+ ins_pipe( pipe_slow );
+%}
+
// Load Effective Address
instruct leaP8(rRegP dst, indOffset8 mem)
%{
--- a/src/hotspot/os/linux/os_linux.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/os/linux/os_linux.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1856,10 +1856,9 @@
return true;
}
-#if defined(S390)
+#if defined(S390) || defined(PPC64)
// keywords_to_match - NULL terminated array of keywords
-static bool print_matching_lines_from_sysinfo_file(outputStream* st, const char* keywords_to_match[]) {
- const char* filename = "/proc/sysinfo";
+static bool print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]) {
char* line = NULL;
size_t length = 0;
FILE* fp = fopen(filename, "r");
@@ -2191,9 +2190,29 @@
// - whole "Box" (CPUs )
// - z/VM / KVM (VM<nn>); this is not available in an LPAR-only setup
const char* kw[] = { "LPAR", "CPUs", "VM", NULL };
-
- if (! print_matching_lines_from_sysinfo_file(st, kw)) {
- st->print_cr(" </proc/sysinfo Not Available>");
+ const char* info_file = "/proc/sysinfo";
+
+ if (!print_matching_lines_from_file(info_file, st, kw)) {
+ st->print_cr(" <%s Not Available>", info_file);
+ }
+#elif defined(PPC64)
+ const char* info_file = "/proc/ppc64/lparcfg";
+ const char* kw[] = { "system_type=", // qemu indicates PowerKVM
+ "partition_entitled_capacity=", // entitled processor capacity percentage
+ "partition_max_entitled_capacity=",
+ "capacity_weight=", // partition CPU weight
+ "partition_active_processors=",
+ "partition_potential_processors=",
+ "entitled_proc_capacity_available=",
+ "capped=", // 0 - uncapped, 1 - vcpus capped at entitled processor capacity percentage
+ "shared_processor_mode=", // (non)dedicated partition
+ "system_potential_processors=",
+ "pool=", // CPU-pool number
+ "pool_capacity=",
+ "NumLpars=", // on non-KVM machines, NumLpars is not found for full partition mode machines
+ NULL };
+ if (!print_matching_lines_from_file(info_file, st, kw)) {
+ st->print_cr(" <%s Not Available>", info_file);
}
#endif
}
--- a/src/hotspot/os/posix/os_posix.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/os/posix/os_posix.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -31,6 +31,7 @@
#include "runtime/interfaceSupport.inline.hpp"
#include "services/memTracker.hpp"
#include "utilities/align.hpp"
+#include "utilities/events.hpp"
#include "utilities/formatBuffer.hpp"
#include "utilities/macros.hpp"
#include "utilities/vmError.hpp"
@@ -1269,6 +1270,15 @@
return true;
}
+bool os::signal_sent_by_kill(const void* siginfo) {
+ const siginfo_t* const si = (const siginfo_t*)siginfo;
+ return si->si_code == SI_USER || si->si_code == SI_QUEUE
+#ifdef SI_TKILL
+ || si->si_code == SI_TKILL
+#endif
+ ;
+}
+
void os::print_siginfo(outputStream* os, const void* si0) {
const siginfo_t* const si = (const siginfo_t*) si0;
@@ -1299,7 +1309,7 @@
// so it depends on the context which member to use. For synchronous error signals,
// we print si_addr, unless the signal was sent by another process or thread, in
// which case we print out pid or tid of the sender.
- if (si->si_code == SI_USER || si->si_code == SI_QUEUE) {
+ if (signal_sent_by_kill(si)) {
const pid_t pid = si->si_pid;
os->print(", si_pid: %ld", (long) pid);
if (IS_VALID_PID(pid)) {
@@ -1325,6 +1335,25 @@
}
+bool os::signal_thread(Thread* thread, int sig, const char* reason) {
+ OSThread* osthread = thread->osthread();
+ if (osthread) {
+#if defined (SOLARIS)
+ // Note: we cannot use pthread_kill on Solaris - not because
+ // its missing, but because we do not have the pthread_t id.
+ int status = thr_kill(osthread->thread_id(), sig);
+#else
+ int status = pthread_kill(osthread->pthread_id(), sig);
+#endif
+ if (status == 0) {
+ Events::log(Thread::current(), "sent signal %d to Thread " INTPTR_FORMAT " because %s.",
+ sig, p2i(thread), reason);
+ return true;
+ }
+ }
+ return false;
+}
+
int os::Posix::unblock_thread_signal_mask(const sigset_t *set) {
return pthread_sigmask(SIG_UNBLOCK, set, NULL);
}
--- a/src/hotspot/os/windows/os_windows.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/os/windows/os_windows.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -923,13 +923,9 @@
}
jlong os::javaTimeMillis() {
- if (UseFakeTimers) {
- return fake_time++;
- } else {
- FILETIME wt;
- GetSystemTimeAsFileTime(&wt);
- return windows_to_java_time(wt);
- }
+ FILETIME wt;
+ GetSystemTimeAsFileTime(&wt);
+ return windows_to_java_time(wt);
}
void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
@@ -1801,6 +1797,11 @@
st->cr();
}
+bool os::signal_sent_by_kill(const void* siginfo) {
+ // TODO: Is this possible?
+ return false;
+}
+
void os::print_siginfo(outputStream *st, const void* siginfo) {
const EXCEPTION_RECORD* const er = (EXCEPTION_RECORD*)siginfo;
st->print("siginfo:");
@@ -1834,6 +1835,11 @@
st->cr();
}
+bool os::signal_thread(Thread* thread, int sig, const char* reason) {
+ // TODO: Can we kill thread?
+ return false;
+}
+
void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
// do nothing
}
--- a/src/hotspot/os_cpu/linux_aarch64/linux_aarch64.ad Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-//
-// Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
-// Copyright (c) 2014, 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.
-//
-//
-
-// AArch64 Linux Architecture Description File
-
-//----------OS-DEPENDENT ENCODING BLOCK----------------------------------------
-// This block specifies the encoding classes used by the compiler to
-// output byte streams. Encoding classes generate functions which are
-// called by Machine Instruction Nodes in order to generate the bit
-// encoding of the instruction. Operands specify their base encoding
-// interface with the interface keyword. There are currently
-// supported four interfaces, REG_INTER, CONST_INTER, MEMORY_INTER, &
-// COND_INTER. REG_INTER causes an operand to generate a function
-// which returns its register number when queried. CONST_INTER causes
-// an operand to generate a function which returns the value of the
-// constant when queried. MEMORY_INTER causes an operand to generate
-// four functions which return the Base Register, the Index Register,
-// the Scale Value, and the Offset Value of the operand when queried.
-// COND_INTER causes an operand to generate six functions which return
-// the encoding code (ie - encoding bits for the instruction)
-// associated with each basic boolean condition for a conditional
-// instruction. Instructions specify two basic values for encoding.
-// They use the ins_encode keyword to specify their encoding class
-// (which must be one of the class names specified in the encoding
-// block), and they use the opcode keyword to specify, in order, their
-// primary, secondary, and tertiary opcode. Only the opcode sections
-// which a particular instruction needs for encoding need to be
-// specified.
-encode %{
- // Build emit functions for each basic byte or larger field in the intel
- // encoding scheme (opcode, rm, sib, immediate), and call them from C++
- // code in the enc_class source block. Emit functions will live in the
- // main source block for now. In future, we can generalize this by
- // adding a syntax that specifies the sizes of fields in an order,
- // so that the adlc can build the emit functions automagically
-
- enc_class Java_To_Runtime(method meth) %{
- %}
-
-%}
-
-
-// Platform dependent source
-
-source %{
-
-%}
--- a/src/hotspot/os_cpu/linux_sparc/linux_sparc.ad Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-//
-// Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-// 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.
-//
-
-//
-//
-
-// SPARC Linux Architecture Description File
--- a/src/hotspot/share/asm/codeBuffer.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/asm/codeBuffer.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1029,26 +1029,10 @@
#ifndef PRODUCT
-void CodeSection::dump() {
- address ptr = start();
- for (csize_t step; ptr < end(); ptr += step) {
- step = end() - ptr;
- if (step > jintSize * 4) step = jintSize * 4;
- tty->print(INTPTR_FORMAT ": ", p2i(ptr));
- while (step > 0) {
- tty->print(" " PTR32_FORMAT, *(jint*)ptr);
- ptr += jintSize;
- }
- tty->cr();
- }
-}
-
-
void CodeSection::decode() {
Disassembler::decode(start(), end());
}
-
void CodeBuffer::block_comment(intptr_t offset, const char * comment) {
_code_strings.add_comment(offset, comment);
}
@@ -1205,26 +1189,6 @@
_decode_begin = insts_end();
}
-
-void CodeBuffer::skip_decode() {
- _decode_begin = insts_end();
-}
-
-
-void CodeBuffer::decode_all() {
- ttyLocker ttyl;
- for (int n = 0; n < (int)SECT_LIMIT; n++) {
- // dump contents of each section
- CodeSection* cs = code_section(n);
- tty->print_cr("! %s:", code_section_name(n));
- if (cs != consts())
- cs->decode();
- else
- cs->dump();
- }
-}
-
-
void CodeSection::print(const char* name) {
csize_t locs_size = locs_end() - locs_start();
tty->print_cr(" %7s.code = " PTR_FORMAT " : " PTR_FORMAT " : " PTR_FORMAT " (%d of %d)%s",
--- a/src/hotspot/share/asm/codeBuffer.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/asm/codeBuffer.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -240,7 +240,6 @@
#ifndef PRODUCT
void decode();
- void dump();
void print(const char* name);
#endif //PRODUCT
};
@@ -649,8 +648,6 @@
// Printing / Decoding
// decodes from decode_begin() to code_end() and sets decode_begin to end
void decode();
- void decode_all(); // decodes all the code
- void skip_decode(); // sets decode_begin to code_end();
void print();
#endif
--- a/src/hotspot/share/ci/ciEnv.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/ci/ciEnv.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -119,6 +119,9 @@
_system_dictionary_modification_counter = system_dictionary_modification_counter;
_num_inlined_bytecodes = 0;
assert(task == NULL || thread->task() == task, "sanity");
+ if (task != NULL) {
+ task->mark_started(os::elapsed_counter());
+ }
_task = task;
_log = NULL;
--- a/src/hotspot/share/ci/ciReplay.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/ci/ciReplay.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -274,15 +274,42 @@
// Parse a sequence of raw data encoded as bytes and return the
// resulting data.
char* parse_data(const char* tag, int& length) {
- if (!parse_tag_and_count(tag, length)) {
+ int read_size = 0;
+ if (!parse_tag_and_count(tag, read_size)) {
return NULL;
}
- char * result = NEW_RESOURCE_ARRAY(char, length);
- for (int i = 0; i < length; i++) {
+ int actual_size = sizeof(MethodData);
+ char *result = NEW_RESOURCE_ARRAY(char, actual_size);
+ int i = 0;
+ if (read_size != actual_size) {
+ tty->print_cr("Warning: ciMethodData parsing sees MethodData size %i in file, current is %i", read_size,
+ actual_size);
+ // Replay serializes the entire MethodData, but the data is at the end.
+ // If the MethodData instance size has changed, we can pad or truncate in the beginning
+ int padding = actual_size - read_size;
+ if (padding > 0) {
+ // pad missing data with zeros
+ tty->print_cr("- Padding MethodData");
+ for (; i < padding; i++) {
+ result[i] = 0;
+ }
+ } else if (padding < 0) {
+ // drop some data
+ tty->print_cr("- Truncating MethodData");
+ for (int j = 0; j < -padding; j++) {
+ int val = parse_int("data");
+ // discard val
+ }
+ }
+ }
+
+ assert(i < actual_size, "At least some data must remain to be copied");
+ for (; i < actual_size; i++) {
int val = parse_int("data");
result[i] = val;
}
+ length = actual_size;
return result;
}
--- a/src/hotspot/share/classfile/classFileParser.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/classfile/classFileParser.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -52,7 +52,7 @@
#include "oops/klass.inline.hpp"
#include "oops/klassVtable.hpp"
#include "oops/metadata.hpp"
-#include "oops/method.hpp"
+#include "oops/method.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/symbol.hpp"
#include "prims/jvmtiExport.hpp"
@@ -1974,46 +1974,6 @@
return localvariable_table_start;
}
-
-void ClassFileParser::parse_type_array(u2 array_length,
- u4 code_length,
- u4* const u1_index,
- u4* const u2_index,
- u1* const u1_array,
- u2* const u2_array,
- TRAPS) {
- const ClassFileStream* const cfs = _stream;
- u2 index = 0; // index in the array with long/double occupying two slots
- u4 i1 = *u1_index;
- u4 i2 = *u2_index + 1;
- for(int i = 0; i < array_length; i++) {
- const u1 tag = u1_array[i1++] = cfs->get_u1(CHECK);
- index++;
- if (tag == ITEM_Long || tag == ITEM_Double) {
- index++;
- } else if (tag == ITEM_Object) {
- const u2 class_index = u2_array[i2++] = cfs->get_u2(CHECK);
- guarantee_property(valid_klass_reference_at(class_index),
- "Bad class index %u in StackMap in class file %s",
- class_index, CHECK);
- } else if (tag == ITEM_Uninitialized) {
- const u2 offset = u2_array[i2++] = cfs->get_u2(CHECK);
- guarantee_property(
- offset < code_length,
- "Bad uninitialized type offset %u in StackMap in class file %s",
- offset, CHECK);
- } else {
- guarantee_property(
- tag <= (u1)ITEM_Uninitialized,
- "Unknown variable type %u in StackMap in class file %s",
- tag, CHECK);
- }
- }
- u2_array[*u2_index] = index;
- *u1_index = i1;
- *u2_index = i2;
-}
-
static const u1* parse_stackmap_table(const ClassFileStream* const cfs,
u4 code_attribute_length,
bool need_verify,
--- a/src/hotspot/share/classfile/classFileParser.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/classfile/classFileParser.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -68,8 +68,7 @@
//
enum Publicity {
INTERNAL,
- BROADCAST,
- NOF_PUBLICITY_LEVELS
+ BROADCAST
};
enum { LegalClass, LegalField, LegalMethod }; // used to verify unqualified names
@@ -270,14 +269,6 @@
u4 method_attribute_length,
TRAPS);
- void parse_type_array(u2 array_length,
- u4 code_length,
- u4* const u1_index,
- u4* const u2_index,
- u1* const u1_array,
- u2* const u2_array,
- TRAPS);
-
// Classfile attribute parsing
u2 parse_generic_signature_attribute(const ClassFileStream* const cfs, TRAPS);
void parse_classfile_sourcefile_attribute(const ClassFileStream* const cfs, TRAPS);
@@ -524,7 +515,6 @@
int itable_size() const { return _itable_size; }
u2 this_class_index() const { return _this_class_index; }
- u2 super_class_index() const { return _super_class_index; }
bool is_unsafe_anonymous() const { return _unsafe_anonymous_host != NULL; }
bool is_interface() const { return _access_flags.is_interface(); }
--- a/src/hotspot/share/classfile/classFileStream.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/classfile/classFileStream.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -30,7 +30,6 @@
#include "memory/resourceArea.hpp"
const bool ClassFileStream::verify = true;
-const bool ClassFileStream::no_verification = false;
void ClassFileStream::truncated_file_error(TRAPS) const {
THROW_MSG(vmSymbols::java_lang_ClassFormatError(), "Truncated class file");
@@ -73,69 +72,6 @@
need_verify());
}
-u1 ClassFileStream::get_u1(TRAPS) const {
- if (_need_verify) {
- guarantee_more(1, CHECK_0);
- } else {
- assert(1 <= _buffer_end - _current, "buffer overflow");
- }
- return *_current++;
-}
-
-u2 ClassFileStream::get_u2(TRAPS) const {
- if (_need_verify) {
- guarantee_more(2, CHECK_0);
- } else {
- assert(2 <= _buffer_end - _current, "buffer overflow");
- }
- const u1* tmp = _current;
- _current += 2;
- return Bytes::get_Java_u2((address)tmp);
-}
-
-u4 ClassFileStream::get_u4(TRAPS) const {
- if (_need_verify) {
- guarantee_more(4, CHECK_0);
- } else {
- assert(4 <= _buffer_end - _current, "buffer overflow");
- }
- const u1* tmp = _current;
- _current += 4;
- return Bytes::get_Java_u4((address)tmp);
-}
-
-u8 ClassFileStream::get_u8(TRAPS) const {
- if (_need_verify) {
- guarantee_more(8, CHECK_0);
- } else {
- assert(8 <= _buffer_end - _current, "buffer overflow");
- }
- const u1* tmp = _current;
- _current += 8;
- return Bytes::get_Java_u8((address)tmp);
-}
-
-void ClassFileStream::skip_u1(int length, TRAPS) const {
- if (_need_verify) {
- guarantee_more(length, CHECK);
- }
- _current += length;
-}
-
-void ClassFileStream::skip_u2(int length, TRAPS) const {
- if (_need_verify) {
- guarantee_more(length * 2, CHECK);
- }
- _current += length * 2;
-}
-
-void ClassFileStream::skip_u4(int length, TRAPS) const {
- if (_need_verify) {
- guarantee_more(length * 4, CHECK);
- }
- _current += length * 4;
-}
-
uint64_t ClassFileStream::compute_fingerprint() const {
int classfile_size = length();
int classfile_crc = ClassLoader::crc32(0, (const char*)buffer(), length());
--- a/src/hotspot/share/classfile/classFileStream.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/classfile/classFileStream.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -52,7 +52,6 @@
const char* const clone_source() const;
public:
- static const bool no_verification;
static const bool verify;
ClassFileStream(const u1* buffer,
@@ -92,21 +91,34 @@
}
// Read u1 from stream
- u1 get_u1(TRAPS) const;
u1 get_u1_fast() const {
return *_current++;
}
+ u1 get_u1(TRAPS) const {
+ if (_need_verify) {
+ guarantee_more(1, CHECK_0);
+ } else {
+ assert(1 <= _buffer_end - _current, "buffer overflow");
+ }
+ return get_u1_fast();
+ }
// Read u2 from stream
- u2 get_u2(TRAPS) const;
u2 get_u2_fast() const {
u2 res = Bytes::get_Java_u2((address)_current);
_current += 2;
return res;
}
+ u2 get_u2(TRAPS) const {
+ if (_need_verify) {
+ guarantee_more(2, CHECK_0);
+ } else {
+ assert(2 <= _buffer_end - _current, "buffer overflow");
+ }
+ return get_u2_fast();
+ }
// Read u4 from stream
- u4 get_u4(TRAPS) const;
u4 get_u4_fast() const {
u4 res = Bytes::get_Java_u4((address)_current);
_current += 4;
@@ -114,25 +126,27 @@
}
// Read u8 from stream
- u8 get_u8(TRAPS) const;
u8 get_u8_fast() const {
u8 res = Bytes::get_Java_u8((address)_current);
_current += 8;
return res;
}
- // Skip length u1 or u2 elements from stream
- void skip_u1(int length, TRAPS) const;
+ // Skip length elements from stream
+ void skip_u1(int length, TRAPS) const {
+ if (_need_verify) {
+ guarantee_more(length, CHECK);
+ }
+ skip_u1_fast(length);
+ }
void skip_u1_fast(int length) const {
_current += length;
}
- void skip_u2(int length, TRAPS) const;
void skip_u2_fast(int length) const {
_current += 2 * length;
}
- void skip_u4(int length, TRAPS) const;
void skip_u4_fast(int length) const {
_current += 4 * length;
}
--- a/src/hotspot/share/classfile/defaultMethods.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/classfile/defaultMethods.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -153,7 +153,7 @@
}
};
- bool _cancelled;
+ bool _visited_Object;
GrowableArray<Node*> _path;
Node* current_top() const { return _path.top(); }
@@ -161,22 +161,19 @@
void push(InstanceKlass* cls, void* data) {
assert(cls != NULL, "Requires a valid instance class");
Node* node = new Node(cls, data, has_super(cls));
+ if (cls == SystemDictionary::Object_klass()) {
+ _visited_Object = true;
+ }
_path.push(node);
}
void pop() { _path.pop(); }
- void reset_iteration() {
- _cancelled = false;
- _path.clear();
- }
- bool is_cancelled() const { return _cancelled; }
-
- // This code used to skip interface classes because their only
- // superclass was j.l.Object which would be also covered by class
- // superclass hierarchy walks. Now that the starting point can be
- // an interface, we must ensure we catch j.l.Object as the super.
- static bool has_super(InstanceKlass* cls) {
- return cls->super() != NULL;
+ // Since the starting point can be an interface, we must ensure we catch
+ // j.l.Object as the super once in those cases. The _visited_Object flag
+ // only ensures we don't then repeatedly enqueue Object for each interface
+ // in the class hierarchy.
+ bool has_super(InstanceKlass* cls) {
+ return cls->super() != NULL && (!_visited_Object || !cls->is_interface());
}
Node* node_at_depth(int i) const {
@@ -200,15 +197,11 @@
}
void* current_data() { return data_at_depth(0); }
- void cancel_iteration() { _cancelled = true; }
-
public:
void run(InstanceKlass* root) {
ALGO* algo = static_cast<ALGO*>(this);
- reset_iteration();
-
void* algo_data = algo->new_node_data(root);
push(root, algo_data);
bool top_needs_visit = true;
@@ -242,7 +235,7 @@
push(next, algo_data);
top_needs_visit = true;
}
- } while (!is_cancelled() && has_more_nodes());
+ } while (has_more_nodes());
}
};
@@ -444,15 +437,6 @@
}
}
- bool contains_signature(Symbol* query) {
- for (int i = 0; i < _members.length(); ++i) {
- if (query == _members.at(i).first->signature()) {
- return true;
- }
- }
- return false;
- }
-
void print_selected(outputStream* str, int indent) const {
assert(has_target(), "Should be called otherwise");
streamIndentor si(str, indent * 2);
@@ -521,22 +505,16 @@
}
protected:
- MethodFamily* _method_family;
+ MethodFamily _method_family;
public:
StatefulMethodFamily() {
- _method_family = new MethodFamily();
_qualification_state = QUALIFIED;
}
- StatefulMethodFamily(MethodFamily* mf) {
- _method_family = mf;
- _qualification_state = QUALIFIED;
- }
+ void set_target_if_empty(Method* m) { _method_family.set_target_if_empty(m); }
- void set_target_if_empty(Method* m) { _method_family->set_target_if_empty(m); }
-
- MethodFamily* get_method_family() { return _method_family; }
+ MethodFamily* get_method_family() { return &_method_family; }
StateRestorer* record_method_and_dq_further(Method* mo);
};
@@ -556,9 +534,9 @@
StateRestorer* StatefulMethodFamily::record_method_and_dq_further(Method* mo) {
StateRestorer* mark = new StateRestorer(this, _qualification_state);
if (_qualification_state == QUALIFIED) {
- _method_family->record_qualified_method(mo);
+ _method_family.record_qualified_method(mo);
} else {
- _method_family->record_disqualified_method(mo);
+ _method_family.record_disqualified_method(mo);
}
// Everything found "above"??? this method in the hierarchy walk is set to
// disqualified
@@ -606,13 +584,11 @@
return found;
}
-static GrowableArray<EmptyVtableSlot*>* find_empty_vtable_slots(
+static void find_empty_vtable_slots(GrowableArray<EmptyVtableSlot*>* slots,
InstanceKlass* klass, const GrowableArray<Method*>* mirandas, TRAPS) {
assert(klass != NULL, "Must be valid class");
- GrowableArray<EmptyVtableSlot*>* slots = new GrowableArray<EmptyVtableSlot*>();
-
// All miranda methods are obvious candidates
for (int i = 0; i < mirandas->length(); ++i) {
Method* m = mirandas->at(i);
@@ -632,9 +608,9 @@
// default method processing that occurred on behalf of our superclass,
// so it's a method we want to re-examine in this new context. That is,
// unless we have a real implementation of it in the current class.
- Method* impl = klass->lookup_method(m->name(), m->signature());
- if (impl == NULL || impl->is_overpass() || impl->is_static()) {
- if (!already_in_vtable_slots(slots, m)) {
+ if (!already_in_vtable_slots(slots, m)) {
+ Method *impl = klass->lookup_method(m->name(), m->signature());
+ if (impl == NULL || impl->is_overpass() || impl->is_static()) {
slots->append(new EmptyVtableSlot(m));
}
}
@@ -649,9 +625,9 @@
// default method processing that occurred on behalf of our superclass,
// so it's a method we want to re-examine in this new context. That is,
// unless we have a real implementation of it in the current class.
- Method* impl = klass->lookup_method(m->name(), m->signature());
- if (impl == NULL || impl->is_overpass() || impl->is_static()) {
- if (!already_in_vtable_slots(slots, m)) {
+ if (!already_in_vtable_slots(slots, m)) {
+ Method* impl = klass->lookup_method(m->name(), m->signature());
+ if (impl == NULL || impl->is_overpass() || impl->is_static()) {
slots->append(new EmptyVtableSlot(m));
}
}
@@ -672,8 +648,6 @@
ls.cr();
}
}
-
- return slots;
}
// Iterates over the superinterface type hierarchy looking for all methods
@@ -749,8 +723,7 @@
GrowableArray<EmptyVtableSlot*>* slots, InstanceKlass* klass, TRAPS);
static void generate_erased_defaults(
- InstanceKlass* klass, GrowableArray<EmptyVtableSlot*>* empty_slots,
- EmptyVtableSlot* slot, bool is_intf, TRAPS) {
+ InstanceKlass* klass, EmptyVtableSlot* slot, bool is_intf, TRAPS) {
// sets up a set of methods with the same exact erased signature
FindMethodsByErasedSig visitor(slot->name(), slot->signature(), is_intf);
@@ -784,6 +757,7 @@
void DefaultMethods::generate_default_methods(
InstanceKlass* klass, const GrowableArray<Method*>* mirandas, TRAPS) {
assert(klass != NULL, "invariant");
+ assert(klass != SystemDictionary::Object_klass(), "Shouldn't be called for Object");
// This resource mark is the bound for all memory allocation that takes
// place during default method processing. After this goes out of scope,
@@ -809,23 +783,25 @@
printer.run(klass);
}
- GrowableArray<EmptyVtableSlot*>* empty_slots =
- find_empty_vtable_slots(klass, mirandas, CHECK);
+ GrowableArray<EmptyVtableSlot*> empty_slots;
+ find_empty_vtable_slots(&empty_slots, klass, mirandas, CHECK);
- for (int i = 0; i < empty_slots->length(); ++i) {
- EmptyVtableSlot* slot = empty_slots->at(i);
- LogTarget(Debug, defaultmethods) lt;
- if (lt.is_enabled()) {
- LogStream ls(lt);
- streamIndentor si(&ls, 2);
- ls.indent().print("Looking for default methods for slot ");
- slot->print_on(&ls);
- ls.cr();
+ if (empty_slots.length() > 0) {
+ for (int i = 0; i < empty_slots.length(); ++i) {
+ EmptyVtableSlot* slot = empty_slots.at(i);
+ LogTarget(Debug, defaultmethods) lt;
+ if (lt.is_enabled()) {
+ LogStream ls(lt);
+ streamIndentor si(&ls, 2);
+ ls.indent().print("Looking for default methods for slot ");
+ slot->print_on(&ls);
+ ls.cr();
+ }
+ generate_erased_defaults(klass, slot, klass->is_interface(), CHECK);
}
- generate_erased_defaults(klass, empty_slots, slot, klass->is_interface(), CHECK);
+ log_debug(defaultmethods)("Creating defaults and overpasses...");
+ create_defaults_and_exceptions(&empty_slots, klass, CHECK);
}
- log_debug(defaultmethods)("Creating defaults and overpasses...");
- create_defaults_and_exceptions(empty_slots, klass, CHECK);
log_debug(defaultmethods)("Default method processing complete");
}
@@ -914,8 +890,7 @@
// throwing methods then the loader constraint checking logic for vtable and
// itable creation needs to be changed to check loader constraints for the
// overpass methods that do not throw exceptions.
-static void create_defaults_and_exceptions(
- GrowableArray<EmptyVtableSlot*>* slots,
+static void create_defaults_and_exceptions(GrowableArray<EmptyVtableSlot*>* slots,
InstanceKlass* klass, TRAPS) {
GrowableArray<Method*> overpasses;
@@ -979,7 +954,7 @@
}
}
-static void create_default_methods( InstanceKlass* klass,
+static void create_default_methods(InstanceKlass* klass,
GrowableArray<Method*>* new_methods, TRAPS) {
int new_size = new_methods->length();
--- a/src/hotspot/share/classfile/dictionary.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/classfile/dictionary.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -24,7 +24,7 @@
#include "precompiled.hpp"
#include "classfile/classLoaderData.inline.hpp"
-#include "classfile/dictionary.inline.hpp"
+#include "classfile/dictionary.hpp"
#include "classfile/protectionDomainCache.hpp"
#include "classfile/systemDictionary.hpp"
#include "logging/log.hpp"
@@ -35,6 +35,7 @@
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/orderAccess.hpp"
+#include "runtime/mutexLocker.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "utilities/hashtable.inline.hpp"
@@ -80,6 +81,8 @@
void Dictionary::free_entry(DictionaryEntry* entry) {
// avoid recursion when deleting linked list
// pd_set is accessed during a safepoint.
+ // This doesn't require a lock because nothing is reading this
+ // entry anymore. The ClassLoader is dead.
while (entry->pd_set() != NULL) {
ProtectionDomainEntry* to_delete = entry->pd_set();
entry->set_pd_set(to_delete->next());
@@ -146,11 +149,14 @@
}
bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
+ // Lock the pd_set list. This lock cannot safepoint since the caller holds
+ // a Dictionary entry, which can be moved if the Dictionary is resized.
+ MutexLockerEx ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
#ifdef ASSERT
if (oopDesc::equals(protection_domain, instance_klass()->protection_domain())) {
// Ensure this doesn't show up in the pd_set (invariant)
bool in_pd_set = false;
- for (ProtectionDomainEntry* current = pd_set_acquire();
+ for (ProtectionDomainEntry* current = pd_set();
current != NULL;
current = current->next()) {
if (oopDesc::equals(current->object_no_keepalive(), protection_domain)) {
@@ -170,7 +176,7 @@
return true;
}
- for (ProtectionDomainEntry* current = pd_set_acquire();
+ for (ProtectionDomainEntry* current = pd_set();
current != NULL;
current = current->next()) {
if (oopDesc::equals(current->object_no_keepalive(), protection_domain)) return true;
@@ -183,13 +189,12 @@
assert_locked_or_safepoint(SystemDictionary_lock);
if (!contains_protection_domain(protection_domain())) {
ProtectionDomainCacheEntry* entry = SystemDictionary::cache_get(protection_domain);
+ // The pd_set in the dictionary entry is protected by a low level lock.
+ // With concurrent PD table cleanup, these links could be broken.
+ MutexLockerEx ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
ProtectionDomainEntry* new_head =
new ProtectionDomainEntry(entry, pd_set());
- // Warning: Preserve store ordering. The SystemDictionary is read
- // without locks. The new ProtectionDomainEntry must be
- // complete before other threads can be allowed to see it
- // via a store to _pd_set.
- release_set_pd_set(new_head);
+ set_pd_set(new_head);
}
LogTarget(Trace, protectiondomain) lt;
if (lt.is_enabled()) {
@@ -348,6 +353,56 @@
return entry->is_valid_protection_domain(protection_domain);
}
+// During class loading we may have cached a protection domain that has
+// since been unreferenced, so this entry should be cleared.
+void Dictionary::clean_cached_protection_domains() {
+ assert_locked_or_safepoint(SystemDictionary_lock);
+
+ if (loader_data()->is_the_null_class_loader_data()) {
+ // Classes in the boot loader are not loaded with protection domains
+ return;
+ }
+
+ for (int index = 0; index < table_size(); index++) {
+ for (DictionaryEntry* probe = bucket(index);
+ probe != NULL;
+ probe = probe->next()) {
+ Klass* e = probe->instance_klass();
+
+ MutexLockerEx ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
+ ProtectionDomainEntry* current = probe->pd_set();
+ ProtectionDomainEntry* prev = NULL;
+ while (current != NULL) {
+ if (current->object_no_keepalive() == NULL) {
+ LogTarget(Debug, protectiondomain) lt;
+ if (lt.is_enabled()) {
+ ResourceMark rm;
+ // Print out trace information
+ LogStream ls(lt);
+ ls.print_cr("PD in set is not alive:");
+ ls.print("class loader: "); loader_data()->class_loader()->print_value_on(&ls);
+ ls.print(" loading: "); probe->instance_klass()->print_value_on(&ls);
+ ls.cr();
+ }
+ if (probe->pd_set() == current) {
+ probe->set_pd_set(current->next());
+ } else {
+ assert(prev != NULL, "should be set by alive entry");
+ prev->set_next(current->next());
+ }
+ ProtectionDomainEntry* to_delete = current;
+ current = current->next();
+ delete to_delete;
+ } else {
+ prev = current;
+ current = current->next();
+ }
+ }
+ }
+ }
+}
+
+
SymbolPropertyTable::SymbolPropertyTable(int table_size)
: Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry))
{
@@ -404,6 +459,25 @@
}
}
+void DictionaryEntry::verify_protection_domain_set() {
+ MutexLockerEx ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
+ for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint
+ current != NULL;
+ current = current->_next) {
+ guarantee(oopDesc::is_oop_or_null(current->_pd_cache->object_no_keepalive()), "Invalid oop");
+ }
+}
+
+void DictionaryEntry::print_count(outputStream *st) {
+ MutexLockerEx ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
+ int count = 0;
+ for (ProtectionDomainEntry* current = pd_set(); // accessed inside SD lock
+ current != NULL;
+ current = current->_next) {
+ count++;
+ }
+ st->print_cr("pd set count = #%d", count);
+}
// ----------------------------------------------------------------------------
--- a/src/hotspot/share/classfile/dictionary.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/classfile/dictionary.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -59,8 +59,6 @@
static bool does_any_dictionary_needs_resizing();
bool resize_if_needed();
- DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass);
-
void add_klass(unsigned int hash, Symbol* class_name, InstanceKlass* obj);
InstanceKlass* find_class(int index, unsigned int hash, Symbol* name);
@@ -70,7 +68,7 @@
void all_entries_do(KlassClosure* closure);
void classes_do(MetaspaceClosure* it);
- void unlink();
+ void clean_cached_protection_domains();
// Protection domains
InstanceKlass* find(unsigned int hash, Symbol* name, Handle protection_domain);
@@ -83,6 +81,10 @@
void print_on(outputStream* st) const;
void verify();
+
+ private:
+ DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass);
+
DictionaryEntry* bucket(int i) const {
return (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::bucket(i);
}
@@ -151,9 +153,6 @@
ProtectionDomainEntry* pd_set() const { return _pd_set; }
void set_pd_set(ProtectionDomainEntry* new_head) { _pd_set = new_head; }
- ProtectionDomainEntry* pd_set_acquire() const;
- void release_set_pd_set(ProtectionDomainEntry* new_head);
-
// Tells whether the initiating class' protection domain can access the klass in this entry
bool is_valid_protection_domain(Handle protection_domain) {
if (!ProtectionDomainVerification) return true;
@@ -164,29 +163,14 @@
: contains_protection_domain(protection_domain());
}
- void verify_protection_domain_set() {
- for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint
- current != NULL;
- current = current->_next) {
- guarantee(oopDesc::is_oop_or_null(current->_pd_cache->object_no_keepalive()), "Invalid oop");
- }
- }
+ void verify_protection_domain_set();
bool equals(const Symbol* class_name) const {
InstanceKlass* klass = (InstanceKlass*)literal();
return (klass->name() == class_name);
}
- void print_count(outputStream *st) {
- int count = 0;
- for (ProtectionDomainEntry* current = pd_set(); // accessed inside SD lock
- current != NULL;
- current = current->_next) {
- count++;
- }
- st->print_cr("pd set count = #%d", count);
- }
-
+ void print_count(outputStream *st);
void verify();
};
--- a/src/hotspot/share/classfile/dictionary.inline.hpp Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
- * 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_CLASSFILE_DICTIONARY_INLINE_HPP
-#define SHARE_CLASSFILE_DICTIONARY_INLINE_HPP
-
-#include "classfile/dictionary.hpp"
-#include "runtime/orderAccess.hpp"
-
-inline ProtectionDomainEntry* DictionaryEntry::pd_set_acquire() const {
- return OrderAccess::load_acquire(&_pd_set);
-}
-
-inline void DictionaryEntry::release_set_pd_set(ProtectionDomainEntry* new_head) {
- OrderAccess::release_store(&_pd_set, new_head);
-}
-
-#endif // SHARE_CLASSFILE_DICTIONARY_INLINE_HPP
--- a/src/hotspot/share/classfile/protectionDomainCache.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/classfile/protectionDomainCache.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
*/
#include "precompiled.hpp"
+#include "classfile/classLoaderDataGraph.hpp"
+#include "classfile/dictionary.hpp"
#include "classfile/protectionDomainCache.hpp"
#include "classfile/systemDictionary.hpp"
#include "logging/log.hpp"
@@ -54,7 +56,27 @@
Service_lock->notify_all();
}
+class CleanProtectionDomainEntries : public CLDClosure {
+ void do_cld(ClassLoaderData* data) {
+ Dictionary* dictionary = data->dictionary();
+ if (dictionary != NULL) {
+ dictionary->clean_cached_protection_domains();
+ }
+ }
+};
+
void ProtectionDomainCacheTable::unlink() {
+ {
+ // First clean cached pd lists in loaded CLDs
+ // It's unlikely, but some loaded classes in a dictionary might
+ // point to a protection_domain that has been unloaded.
+ // The dictionary pd_set points at entries in the ProtectionDomainCacheTable.
+ MutexLocker ml(ClassLoaderDataGraph_lock);
+ MutexLocker mldict(SystemDictionary_lock); // need both.
+ CleanProtectionDomainEntries clean;
+ ClassLoaderDataGraph::loaded_cld_do(&clean);
+ }
+
MutexLocker ml(SystemDictionary_lock);
int oops_removed = 0;
for (int i = 0; i < table_size(); ++i) {
--- a/src/hotspot/share/code/compressedStream.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/code/compressedStream.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -26,15 +26,6 @@
#include "code/compressedStream.hpp"
#include "utilities/ostream.hpp"
-// 32-bit one-to-one sign encoding taken from Pack200
-// converts leading sign bits into leading zeroes with trailing sign bit
-inline juint CompressedStream::encode_sign(jint value) {
- return (value << 1) ^ (value >> 31);
-}
-inline jint CompressedStream::decode_sign(juint value) {
- return (value >> 1) ^ -(jint)(value & 1);
-}
-
// 32-bit self-inverse encoding of float bits
// converts trailing zeroes (common in floats) to leading zeroes
inline juint CompressedStream::reverse_int(juint i) {
@@ -46,7 +37,6 @@
return i;
}
-
jint CompressedReadStream::read_signed_int() {
return decode_sign(read_int());
}
@@ -90,11 +80,6 @@
_size = _size * 2;
}
-void CompressedWriteStream::write_signed_int(jint value) {
- // this encoding, called SIGNED5, is taken from Pack200
- write_int(encode_sign(value));
-}
-
void CompressedWriteStream::write_float(jfloat value) {
juint f = jint_cast(value);
juint rf = reverse_int(f);
@@ -117,136 +102,3 @@
write_signed_int(low(value));
write_signed_int(high(value));
}
-
-
-/// The remaining details
-
-#ifndef PRODUCT
-// set this to trigger unit test
-void test_compressed_stream(int trace);
-bool test_compressed_stream_enabled = false;
-#endif
-
-void CompressedWriteStream::write_int_mb(jint value) {
- debug_only(int pos1 = position());
- juint sum = value;
- for (int i = 0; ; ) {
- if (sum < L || i == MAX_i) {
- // remainder is either a "low code" or the 5th byte
- assert(sum == (u_char)sum, "valid byte");
- write((u_char)sum);
- break;
- }
- sum -= L;
- int b_i = L + (sum % H); // this is a "high code"
- sum >>= lg_H; // extracted 6 bits
- write(b_i); ++i;
- }
-
-#ifndef PRODUCT
- if (test_compressed_stream_enabled) { // hack to enable this stress test
- test_compressed_stream_enabled = false;
- test_compressed_stream(0);
- }
-#endif
-}
-
-
-#ifndef PRODUCT
-/// a unit test (can be run by hand from a debugger)
-
-// Avoid a VS2005 compiler stack overflow w/ fastdebug build.
-// The following pragma optimize turns off optimization ONLY
-// for this block (a matching directive turns it back on later).
-// These directives can be removed once the MS VS.NET 2005
-// compiler stack overflow is fixed.
-#if defined(_MSC_VER) && _MSC_VER >=1400 && !defined(_WIN64)
-#pragma optimize("", off)
-#pragma warning(disable: 4748)
-#endif
-
-// generator for an "interesting" set of critical values
-enum { stretch_limit = (1<<16) * (64-16+1) };
-static jlong stretch(jint x, int bits) {
- // put x[high 4] into place
- jlong h = (jlong)((x >> (16-4))) << (bits - 4);
- // put x[low 12] into place, sign extended
- jlong l = ((jlong)x << (64-12)) >> (64-12);
- // move l upwards, maybe
- l <<= (x >> 16);
- return h ^ l;
-}
-
-PRAGMA_DIAG_PUSH
-PRAGMA_FORMAT_IGNORED // Someone needs to deal with this.
-void test_compressed_stream(int trace) {
- CompressedWriteStream bytes(stretch_limit * 100);
- jint n;
- int step = 0, fails = 0;
-#define CHECKXY(x, y, fmt) { \
- ++step; \
- int xlen = (pos = decode.position()) - lastpos; lastpos = pos; \
- if (trace > 0 && (step % trace) == 0) { \
- tty->print_cr("step %d, n=%08x: value=" fmt " (len=%d)", \
- step, n, x, xlen); } \
- if (x != y) { \
- tty->print_cr("step %d, n=%d: " fmt " != " fmt, step, n, x, y); \
- fails++; \
- } }
- for (n = 0; n < (1<<8); n++) {
- jbyte x = (jbyte)n;
- bytes.write_byte(x); ++step;
- }
- for (n = 0; n < stretch_limit; n++) {
- jint x = (jint)stretch(n, 32);
- bytes.write_int(x); ++step;
- bytes.write_signed_int(x); ++step;
- bytes.write_float(jfloat_cast(x)); ++step;
- }
- for (n = 0; n < stretch_limit; n++) {
- jlong x = stretch(n, 64);
- bytes.write_long(x); ++step;
- bytes.write_double(jdouble_cast(x)); ++step;
- }
- int length = bytes.position();
- if (trace != 0)
- tty->print_cr("set up test of %d stream values, size %d", step, length);
- step = 0;
- // now decode it all
- CompressedReadStream decode(bytes.buffer());
- int pos, lastpos = decode.position();
- for (n = 0; n < (1<<8); n++) {
- jbyte x = (jbyte)n;
- jbyte y = decode.read_byte();
- CHECKXY(x, y, "%db");
- }
- for (n = 0; n < stretch_limit; n++) {
- jint x = (jint)stretch(n, 32);
- jint y1 = decode.read_int();
- CHECKXY(x, y1, "%du");
- jint y2 = decode.read_signed_int();
- CHECKXY(x, y2, "%di");
- jint y3 = jint_cast(decode.read_float());
- CHECKXY(x, y3, "%df");
- }
- for (n = 0; n < stretch_limit; n++) {
- jlong x = stretch(n, 64);
- jlong y1 = decode.read_long();
- CHECKXY(x, y1, INT64_FORMAT "l");
- jlong y2 = jlong_cast(decode.read_double());
- CHECKXY(x, y2, INT64_FORMAT "d");
- }
- int length2 = decode.position();
- if (trace != 0)
- tty->print_cr("finished test of %d stream values, size %d", step, length2);
- guarantee(length == length2, "bad length");
- guarantee(fails == 0, "test failures");
-}
-PRAGMA_DIAG_POP
-
-#if defined(_MSC_VER) &&_MSC_VER >=1400 && !defined(_WIN64)
-#pragma warning(default: 4748)
-#pragma optimize("", on)
-#endif
-
-#endif // PRODUCT
--- a/src/hotspot/share/code/compressedStream.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/code/compressedStream.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -43,11 +43,11 @@
MAX_i = 4 // bytes are numbered in (0..4), max 5 bytes
};
- // these inlines are defined only in compressedStream.cpp
- static inline juint encode_sign(jint value); // for Pack200 SIGNED5
- static inline jint decode_sign(juint value); // for Pack200 SIGNED5
- static inline juint reverse_int(juint bits); // to trim trailing float 0's
-
+ // 32-bit one-to-one sign encoding taken from Pack200
+ // converts leading sign bits into leading zeroes with trailing sign bit
+ static juint encode_sign(jint value) { return (value << 1) ^ (value >> 31); }
+ static jint decode_sign(juint value) { return (value >> 1) ^ -(jint)(value & 1); }
+ static juint reverse_int(juint i); // to trim trailing float 0's
public:
CompressedStream(u_char* buffer, int position = 0) {
_buffer = buffer;
@@ -134,7 +134,22 @@
}
void grow();
- void write_int_mb(jint value); // UNSIGNED5 coding, 1-5 byte cases
+ // UNSIGNED5 coding, 1-5 byte cases
+ void write_int_mb(jint value) {
+ juint sum = value;
+ for (int i = 0; ; ) {
+ if (sum < L || i == MAX_i) {
+ // remainder is either a "low code" or the 5th byte
+ assert(sum == (u_char)sum, "valid byte");
+ write((u_char)sum);
+ break;
+ }
+ sum -= L;
+ int b_i = L + (sum % H); // this is a "high code"
+ sum >>= lg_H; // extracted 6 bits
+ write(b_i); ++i;
+ }
+ }
protected:
int _size;
@@ -151,7 +166,7 @@
void write_int(jint value) { if ((juint)value < L && !full())
store((u_char)value);
else write_int_mb(value); }
- void write_signed_int(jint value); // write_int(encode_sign(value))
+ void write_signed_int(jint value) { write_int(encode_sign(value)); }
void write_float(jfloat value); // write_int(reverse_int(jint_cast(v)))
void write_double(jdouble value); // write_int(reverse_int(<low,high>))
void write_long(jlong value); // write_signed_int(<low,high>)
--- a/src/hotspot/share/compiler/compileBroker.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/compiler/compileBroker.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -258,14 +258,14 @@
}
#endif
CompileLog* log = thread->log();
- if (log != NULL) task->log_task_start(log);
+ if (log != NULL && !task->is_unloaded()) task->log_task_start(log);
}
CompileTaskWrapper::~CompileTaskWrapper() {
CompilerThread* thread = CompilerThread::current();
CompileTask* task = thread->task();
CompileLog* log = thread->log();
- if (log != NULL) task->log_task_done(log);
+ if (log != NULL && !task->is_unloaded()) task->log_task_done(log);
thread->set_task(NULL);
task->set_code_handle(NULL);
thread->set_env(NULL);
@@ -444,6 +444,9 @@
{
NoSafepointVerifier nsv;
task = CompilationPolicy::policy()->select_task(this);
+ if (task != NULL) {
+ task = task->select_for_compilation();
+ }
}
if (task != NULL) {
@@ -455,7 +458,6 @@
remove(task);
purge_stale_tasks(); // may temporarily release MCQ lock
}
-
return task;
}
@@ -483,7 +485,7 @@
}
void CompileQueue::remove(CompileTask* task) {
- assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
+ assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
if (task->prev() != NULL) {
task->prev()->set_next(task->next());
} else {
@@ -534,7 +536,7 @@
char buf[2000];
int buflen = sizeof(buf);
- Threads::print_threads_compiling(st, buf, buflen);
+ Threads::print_threads_compiling(st, buf, buflen, /* short_form = */ true);
st->cr();
if (_c1_compile_queue != NULL) {
--- a/src/hotspot/share/compiler/compileTask.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/compiler/compileTask.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -63,28 +63,31 @@
/**
* Add a task to the free list.
*/
-
void CompileTask::free(CompileTask* task) {
- MutexLocker locker(CompileTaskAlloc_lock);
- if (!task->is_free()) {
- task->set_code(NULL);
- assert(!task->lock()->is_locked(), "Should not be locked when freed");
- JNIHandles::destroy_global(task->_method_holder);
- JNIHandles::destroy_global(task->_hot_method_holder);
+ MutexLocker locker(CompileTaskAlloc_lock);
+ if (!task->is_free()) {
+ task->set_code(NULL);
+ assert(!task->lock()->is_locked(), "Should not be locked when freed");
+ if ((task->_method_holder != NULL && JNIHandles::is_weak_global_handle(task->_method_holder)) ||
+ (task->_hot_method_holder != NULL && JNIHandles::is_weak_global_handle(task->_hot_method_holder))) {
+ JNIHandles::destroy_weak_global(task->_method_holder);
+ JNIHandles::destroy_weak_global(task->_hot_method_holder);
+ } else {
+ JNIHandles::destroy_global(task->_method_holder);
+ JNIHandles::destroy_global(task->_hot_method_holder);
+ }
+ if (task->_failure_reason_on_C_heap && task->_failure_reason != NULL) {
+ os::free((void*) task->_failure_reason);
+ }
+ task->_failure_reason = NULL;
+ task->_failure_reason_on_C_heap = false;
- if (task->_failure_reason_on_C_heap && task->_failure_reason != NULL) {
- os::free((void*) task->_failure_reason);
- }
- task->_failure_reason = NULL;
- task->_failure_reason_on_C_heap = false;
-
- task->set_is_free(true);
- task->set_next(_task_free_list);
- _task_free_list = task;
- }
+ task->set_is_free(true);
+ task->set_next(_task_free_list);
+ _task_free_list = task;
+ }
}
-
void CompileTask::initialize(int compile_id,
const methodHandle& method,
int osr_bci,
@@ -98,7 +101,7 @@
Thread* thread = Thread::current();
_compile_id = compile_id;
_method = method();
- _method_holder = JNIHandles::make_global(Handle(thread, method->method_holder()->klass_holder()));
+ _method_holder = JNIHandles::make_weak_global(Handle(thread, method->method_holder()->klass_holder()));
_osr_bci = osr_bci;
_is_blocking = is_blocking;
JVMCI_ONLY(_has_waiter = CompileBroker::compiler(comp_level)->is_jvmci();)
@@ -113,20 +116,20 @@
_hot_method = NULL;
_hot_method_holder = NULL;
_hot_count = hot_count;
- _time_queued = 0; // tidy
+ _time_queued = os::elapsed_counter();
+ _time_started = 0;
_compile_reason = compile_reason;
_failure_reason = NULL;
_failure_reason_on_C_heap = false;
if (LogCompilation) {
- _time_queued = os::elapsed_counter();
if (hot_method.not_null()) {
if (hot_method == method) {
_hot_method = _method;
} else {
_hot_method = hot_method();
// only add loader or mirror if different from _method_holder
- _hot_method_holder = JNIHandles::make_global(Handle(thread, hot_method->method_holder()->klass_holder()));
+ _hot_method_holder = JNIHandles::make_weak_global(Handle(thread, hot_method->method_holder()->klass_holder()));
}
}
}
@@ -141,6 +144,24 @@
return CompileBroker::compiler(_comp_level);
}
+// Replace weak handles by strong handles to avoid unloading during compilation.
+CompileTask* CompileTask::select_for_compilation() {
+ if (is_unloaded()) {
+ // Guard against concurrent class unloading
+ return NULL;
+ }
+ Thread* thread = Thread::current();
+ assert(_method->method_holder()->is_loader_alive(), "should be alive");
+ Handle method_holder(thread, _method->method_holder()->klass_holder());
+ JNIHandles::destroy_weak_global(_method_holder);
+ JNIHandles::destroy_weak_global(_hot_method_holder);
+ _method_holder = JNIHandles::make_global(method_holder);
+ if (_hot_method != NULL) {
+ _hot_method_holder = JNIHandles::make_global(Handle(thread, _hot_method->method_holder()->klass_holder()));
+ }
+ return this;
+}
+
// ------------------------------------------------------------------
// CompileTask::code/set_code
//
@@ -162,14 +183,22 @@
void CompileTask::mark_on_stack() {
// Mark these methods as something redefine classes cannot remove.
+ assert(!is_unloaded(), "unloaded method on the stack");
_method->set_on_stack(true);
if (_hot_method != NULL) {
_hot_method->set_on_stack(true);
}
}
+bool CompileTask::is_unloaded() const {
+ return _method_holder != NULL && JNIHandles::is_weak_global_handle(_method_holder) && JNIHandles::is_global_weak_cleared(_method_holder);
+}
+
// RedefineClasses support
void CompileTask::metadata_do(void f(Metadata*)) {
+ if (is_unloaded()) {
+ return;
+ }
f(method());
if (hot_method() != NULL && hot_method() != method()) {
f(hot_method());
@@ -206,10 +235,20 @@
// ------------------------------------------------------------------
// CompileTask::print_impl
void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
- bool is_osr_method, int osr_bci, bool is_blocking,
- const char* msg, bool short_form, bool cr) {
+ bool is_osr_method, int osr_bci, bool is_blocking,
+ const char* msg, bool short_form, bool cr,
+ jlong time_queued, jlong time_started) {
if (!short_form) {
- st->print("%7d ", (int) st->time_stamp().milliseconds()); // print timestamp
+ // Print current time
+ st->print("%7d ", (int)st->time_stamp().milliseconds());
+ if (Verbose && time_queued != 0) {
+ // Print time in queue and time being processed by compiler thread
+ jlong now = os::elapsed_counter();
+ st->print("%d ", (int)TimeHelper::counter_to_millis(now-time_queued));
+ if (time_started != 0) {
+ st->print("%d ", (int)TimeHelper::counter_to_millis(now-time_started));
+ }
+ }
}
// print compiler name if requested
if (CIPrintCompilerName) {
@@ -284,7 +323,7 @@
// CompileTask::print_compilation
void CompileTask::print(outputStream* st, const char* msg, bool short_form, bool cr) {
bool is_osr_method = osr_bci() != InvocationEntryBci;
- print_impl(st, method(), compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), msg, short_form, cr);
+ print_impl(st, is_unloaded() ? NULL : method(), compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), msg, short_form, cr, _time_queued, _time_started);
}
// ------------------------------------------------------------------
--- a/src/hotspot/share/compiler/compileTask.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/compiler/compileTask.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -98,7 +98,8 @@
CompileTask* _next, *_prev;
bool _is_free;
// Fields used for logging why the compilation was initiated:
- jlong _time_queued; // in units of os::elapsed_counter()
+ jlong _time_queued; // time when task was enqueued
+ jlong _time_started; // time when compilation started
Method* _hot_method; // which method actually triggered this task
jobject _hot_method_holder;
int _hot_count; // information about its invocation counter
@@ -156,11 +157,13 @@
void mark_complete() { _is_complete = true; }
void mark_success() { _is_success = true; }
+ void mark_started(jlong time) { _time_started = time; }
int comp_level() { return _comp_level;}
void set_comp_level(int comp_level) { _comp_level = comp_level;}
AbstractCompiler* compiler();
+ CompileTask* select_for_compilation();
int num_inlined_bytecodes() const { return _num_inlined_bytecodes; }
void set_num_inlined_bytecodes(int n) { _num_inlined_bytecodes = n; }
@@ -171,6 +174,7 @@
void set_prev(CompileTask* prev) { _prev = prev; }
bool is_free() const { return _is_free; }
void set_is_free(bool val) { _is_free = val; }
+ bool is_unloaded() const;
// RedefineClasses support
void metadata_do(void f(Metadata*));
@@ -179,7 +183,8 @@
private:
static void print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false,
- const char* msg = NULL, bool short_form = false, bool cr = true);
+ const char* msg = NULL, bool short_form = false, bool cr = true,
+ jlong time_queued = 0, jlong time_started = 0);
public:
void print(outputStream* st = tty, const char* msg = NULL, bool short_form = false, bool cr = true);
--- a/src/hotspot/share/gc/g1/g1Allocator.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1Allocator.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -369,7 +369,7 @@
} else {
hr->set_closed_archive();
}
- _g1h->g1_policy()->remset_tracker()->update_at_allocate(hr);
+ _g1h->policy()->remset_tracker()->update_at_allocate(hr);
_g1h->archive_set_add(hr);
_g1h->hr_printer()->alloc(hr);
_allocated_regions.append(hr);
--- a/src/hotspot/share/gc/g1/g1BarrierSet.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1BarrierSet.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -64,18 +64,7 @@
void G1BarrierSet::enqueue(oop pre_val) {
// Nulls should have been already filtered.
assert(oopDesc::is_oop(pre_val, true), "Error");
-
- G1SATBMarkQueueSet& queue_set = satb_mark_queue_set();
- if (!queue_set.is_active()) {
- return;
- }
- Thread* thr = Thread::current();
- if (thr->is_Java_thread()) {
- G1ThreadLocalData::satb_mark_queue(thr).enqueue(pre_val);
- } else {
- MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag);
- queue_set.shared_satb_queue()->enqueue(pre_val);
- }
+ G1ThreadLocalData::satb_mark_queue(Thread::current()).enqueue(pre_val);
}
template <class T> void
@@ -109,13 +98,7 @@
if (*byte != G1CardTable::dirty_card_val()) {
*byte = G1CardTable::dirty_card_val();
Thread* thr = Thread::current();
- if (thr->is_Java_thread()) {
- G1ThreadLocalData::dirty_card_queue(thr).enqueue(byte);
- } else {
- MutexLockerEx x(Shared_DirtyCardQ_lock,
- Mutex::_no_safepoint_check_flag);
- _dirty_card_queue_set.shared_dirty_card_queue()->enqueue(byte);
- }
+ G1ThreadLocalData::dirty_card_queue(thr).enqueue(byte);
}
}
@@ -125,34 +108,20 @@
}
volatile jbyte* byte = _card_table->byte_for(mr.start());
jbyte* last_byte = _card_table->byte_for(mr.last());
- Thread* thr = Thread::current();
- // skip all consecutive young cards
+ // skip initial young cards
for (; byte <= last_byte && *byte == G1CardTable::g1_young_card_val(); byte++);
if (byte <= last_byte) {
OrderAccess::storeload();
// Enqueue if necessary.
- if (thr->is_Java_thread()) {
- for (; byte <= last_byte; byte++) {
- if (*byte == G1CardTable::g1_young_card_val()) {
- continue;
- }
- if (*byte != G1CardTable::dirty_card_val()) {
- *byte = G1CardTable::dirty_card_val();
- G1ThreadLocalData::dirty_card_queue(thr).enqueue(byte);
- }
- }
- } else {
- MutexLockerEx x(Shared_DirtyCardQ_lock,
- Mutex::_no_safepoint_check_flag);
- for (; byte <= last_byte; byte++) {
- if (*byte == G1CardTable::g1_young_card_val()) {
- continue;
- }
- if (*byte != G1CardTable::dirty_card_val()) {
- *byte = G1CardTable::dirty_card_val();
- _dirty_card_queue_set.shared_dirty_card_queue()->enqueue(byte);
- }
+ Thread* thr = Thread::current();
+ G1DirtyCardQueue& queue = G1ThreadLocalData::dirty_card_queue(thr);
+ for (; byte <= last_byte; byte++) {
+ jbyte bv = *byte;
+ if ((bv != G1CardTable::g1_young_card_val()) &&
+ (bv != G1CardTable::dirty_card_val())) {
+ *byte = G1CardTable::dirty_card_val();
+ queue.enqueue(byte);
}
}
}
@@ -168,38 +137,40 @@
G1ThreadLocalData::destroy(thread);
}
-void G1BarrierSet::on_thread_attach(JavaThread* thread) {
- // This method initializes the SATB and dirty card queues before a
- // JavaThread is added to the Java thread list. Right now, we don't
- // have to do anything to the dirty card queue (it should have been
- // activated when the thread was created), but we have to activate
- // the SATB queue if the thread is created while a marking cycle is
- // in progress. The activation / de-activation of the SATB queues at
- // the beginning / end of a marking cycle is done during safepoints
- // so we have to make sure this method is called outside one to be
- // able to safely read the active field of the SATB queue set. Right
- // now, it is called just before the thread is added to the Java
- // thread list in the Threads::add() method. That method is holding
- // the Threads_lock which ensures we are outside a safepoint. We
- // cannot do the obvious and set the active field of the SATB queue
- // when the thread is created given that, in some cases, safepoints
- // might happen between the JavaThread constructor being called and the
- // thread being added to the Java thread list (an example of this is
- // when the structure for the DestroyJavaVM thread is created).
- assert(!SafepointSynchronize::is_at_safepoint(), "We should not be at a safepoint");
+void G1BarrierSet::on_thread_attach(Thread* thread) {
assert(!G1ThreadLocalData::satb_mark_queue(thread).is_active(), "SATB queue should not be active");
assert(G1ThreadLocalData::satb_mark_queue(thread).is_empty(), "SATB queue should be empty");
assert(G1ThreadLocalData::dirty_card_queue(thread).is_active(), "Dirty card queue should be active");
+ // Can't assert that the DCQ is empty. There is early execution on
+ // the main thread, before it gets added to the threads list, which
+ // is where this is called. That execution may enqueue dirty cards.
// If we are creating the thread during a marking cycle, we should
- // set the active field of the SATB queue to true.
- if (_satb_mark_queue_set.is_active()) {
- G1ThreadLocalData::satb_mark_queue(thread).set_active(true);
- }
+ // set the active field of the SATB queue to true. That involves
+ // copying the global is_active value to this thread's queue, which
+ // is done without any direct synchronization here.
+ //
+ // The activation and deactivation of the SATB queues occurs at the
+ // beginning / end of a marking cycle, and is done during
+ // safepoints. This function is called just before a thread is
+ // added to its corresponding threads list (for Java or non-Java
+ // threads, respectively).
+ //
+ // For Java threads, that's done while holding the Threads_lock,
+ // which ensures we're not at a safepoint, so reading the global
+ // is_active state is synchronized against update.
+ assert(!thread->is_Java_thread() || !SafepointSynchronize::is_at_safepoint(),
+ "Should not be at a safepoint");
+ // For non-Java threads, thread creation (and list addition) may,
+ // and indeed usually does, occur during a safepoint. But such
+ // creation isn't concurrent with updating the global SATB active
+ // state.
+ bool is_satb_active = _satb_mark_queue_set.is_active();
+ G1ThreadLocalData::satb_mark_queue(thread).set_active(is_satb_active);
}
-void G1BarrierSet::on_thread_detach(JavaThread* thread) {
- // Flush any deferred card marks, SATB buffers and dirty card queue buffers
+void G1BarrierSet::on_thread_detach(Thread* thread) {
+ // Flush any deferred card marks.
CardTableBarrierSet::on_thread_detach(thread);
G1ThreadLocalData::satb_mark_queue(thread).flush();
G1ThreadLocalData::dirty_card_queue(thread).flush();
--- a/src/hotspot/share/gc/g1/g1BarrierSet.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1BarrierSet.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -77,8 +77,8 @@
virtual void on_thread_create(Thread* thread);
virtual void on_thread_destroy(Thread* thread);
- virtual void on_thread_attach(JavaThread* thread);
- virtual void on_thread_detach(JavaThread* thread);
+ virtual void on_thread_attach(Thread* thread);
+ virtual void on_thread_detach(Thread* thread);
BufferNode::Allocator& satb_mark_queue_buffer_allocator();
BufferNode::Allocator& dirty_card_queue_buffer_allocator();
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -259,14 +259,14 @@
// that there is a single object that starts at the bottom of the
// first region.
first_hr->set_starts_humongous(obj_top, word_fill_size);
- _g1_policy->remset_tracker()->update_at_allocate(first_hr);
+ _policy->remset_tracker()->update_at_allocate(first_hr);
// Then, if there are any, we will set up the "continues
// humongous" regions.
HeapRegion* hr = NULL;
for (uint i = first + 1; i <= last; ++i) {
hr = region_at(i);
hr->set_continues_humongous(first_hr);
- _g1_policy->remset_tracker()->update_at_allocate(hr);
+ _policy->remset_tracker()->update_at_allocate(hr);
}
// Up to this point no concurrent thread would have been able to
@@ -356,7 +356,7 @@
word_size * HeapWordSize);
_hrm->expand_at(first, obj_regions, workers());
- g1_policy()->record_new_heap_size(num_regions());
+ policy()->record_new_heap_size(num_regions());
#ifdef ASSERT
for (uint i = first; i < first + obj_regions; ++i) {
@@ -440,7 +440,7 @@
// If the GCLocker is active and we are bound for a GC, try expanding young gen.
// This is different to when only GCLocker::needs_gc() is set: try to avoid
// waiting because the GCLocker is active to not wait too long.
- if (GCLocker::is_active_and_needs_gc() && g1_policy()->can_expand_young_list()) {
+ if (GCLocker::is_active_and_needs_gc() && policy()->can_expand_young_list()) {
// No need for an ergo message here, can_expand_young_list() does this when
// it returns true.
result = _allocator->attempt_allocation_force(word_size);
@@ -861,7 +861,7 @@
// the check before we do the actual allocation. The reason for doing it
// before the allocation is that we avoid having to keep track of the newly
// allocated memory while we do a GC.
- if (g1_policy()->need_to_start_conc_mark("concurrent humongous allocation",
+ if (policy()->need_to_start_conc_mark("concurrent humongous allocation",
word_size)) {
collect(GCCause::_g1_humongous_allocation);
}
@@ -885,7 +885,7 @@
result = humongous_obj_allocate(word_size);
if (result != NULL) {
size_t size_in_regions = humongous_obj_size_in_regions(word_size);
- g1_policy()->add_bytes_allocated_in_old_since_last_gc(size_in_regions * HeapRegion::GrainBytes);
+ policy()->add_bytes_allocated_in_old_since_last_gc(size_in_regions * HeapRegion::GrainBytes);
return result;
}
@@ -963,7 +963,7 @@
return _allocator->attempt_allocation_locked(word_size);
} else {
HeapWord* result = humongous_obj_allocate(word_size);
- if (result != NULL && g1_policy()->need_to_start_conc_mark("STW humongous allocation")) {
+ if (result != NULL && policy()->need_to_start_conc_mark("STW humongous allocation")) {
collector_state()->set_initiate_conc_mark_if_possible(true);
}
return result;
@@ -1363,7 +1363,7 @@
if (expanded_by > 0) {
size_t actual_expand_bytes = expanded_by * HeapRegion::GrainBytes;
assert(actual_expand_bytes <= aligned_expand_bytes, "post-condition");
- g1_policy()->record_new_heap_size(num_regions());
+ policy()->record_new_heap_size(num_regions());
} else {
log_debug(gc, ergo, heap)("Did not expand the heap (heap expansion operation failed)");
@@ -1392,7 +1392,7 @@
log_debug(gc, ergo, heap)("Shrink the heap. requested shrinking amount: " SIZE_FORMAT "B aligned shrinking amount: " SIZE_FORMAT "B attempted shrinking amount: " SIZE_FORMAT "B",
shrink_bytes, aligned_shrink_bytes, shrunk_bytes);
if (num_regions_removed > 0) {
- g1_policy()->record_new_heap_size(num_regions());
+ policy()->record_new_heap_size(num_regions());
} else {
log_debug(gc, ergo, heap)("Did not expand the heap (heap shrinking operation failed)");
}
@@ -1510,11 +1510,11 @@
_survivor(),
_gc_timer_stw(new (ResourceObj::C_HEAP, mtGC) STWGCTimer()),
_gc_tracer_stw(new (ResourceObj::C_HEAP, mtGC) G1NewTracer()),
- _g1_policy(G1Policy::create_policy(collector_policy, _gc_timer_stw)),
+ _policy(G1Policy::create_policy(collector_policy, _gc_timer_stw)),
_heap_sizing_policy(NULL),
- _collection_set(this, _g1_policy),
+ _collection_set(this, _policy),
_hot_card_cache(NULL),
- _g1_rem_set(NULL),
+ _rem_set(NULL),
_dirty_card_queue_set(false),
_cm(NULL),
_cm_thread(NULL),
@@ -1540,7 +1540,7 @@
_allocator = new G1Allocator(this);
- _heap_sizing_policy = G1HeapSizingPolicy::create(this, _g1_policy->analytics());
+ _heap_sizing_policy = G1HeapSizingPolicy::create(this, _policy->analytics());
_humongous_object_threshold_in_words = humongous_threshold_for(HeapRegion::GrainWords);
@@ -1637,7 +1637,7 @@
guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
size_t init_byte_size = collector_policy()->initial_heap_byte_size();
- size_t max_byte_size = g1_collector_policy()->heap_reserved_size_bytes();
+ size_t max_byte_size = _collector_policy->heap_reserved_size_bytes();
size_t heap_alignment = collector_policy()->heap_alignment();
// Ensure that the sizes are properly aligned.
@@ -1676,8 +1676,7 @@
SATB_Q_CBL_mon,
&bs->satb_mark_queue_buffer_allocator(),
G1SATBProcessCompletedThreshold,
- G1SATBBufferEnqueueingThresholdPercent,
- Shared_SATB_Q_lock);
+ G1SATBBufferEnqueueingThresholdPercent);
// process_completed_buffers_threshold and max_completed_buffers are updated
// later, based on the concurrent refinement object.
@@ -1738,7 +1737,7 @@
G1RegionToSpaceMapper* next_bitmap_storage =
create_aux_memory_mapper("Next Bitmap", bitmap_size, G1CMBitMap::heap_map_factor());
- _hrm = HeapRegionManager::create_manager(this, g1_collector_policy());
+ _hrm = HeapRegionManager::create_manager(this, _collector_policy);
_hrm->initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage);
_card_table->initialize(cardtable_storage);
@@ -1754,8 +1753,8 @@
// start within the first card.
guarantee(g1_rs.base() >= (char*)G1CardTable::card_size, "Java heap must not start within the first card.");
// Also create a G1 rem set.
- _g1_rem_set = new G1RemSet(this, _card_table, _hot_card_cache);
- _g1_rem_set->initialize(max_reserved_capacity(), max_regions());
+ _rem_set = new G1RemSet(this, _card_table, _hot_card_cache);
+ _rem_set->initialize(max_reserved_capacity(), max_regions());
size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
@@ -1799,7 +1798,7 @@
}
// Perform any initialization actions delegated to the policy.
- g1_policy()->init(this, &_collection_set);
+ policy()->init(this, &_collection_set);
jint ecode = initialize_concurrent_refinement();
if (ecode != JNI_OK) {
@@ -1939,10 +1938,6 @@
return _collector_policy;
}
-G1CollectorPolicy* G1CollectedHeap::g1_collector_policy() const {
- return _collector_policy;
-}
-
SoftRefPolicy* G1CollectedHeap::soft_ref_policy() {
return &_soft_ref_policy;
}
@@ -1966,7 +1961,7 @@
n_completed_buffers++;
}
assert(dcqs.completed_buffers_num() == 0, "Completed buffers exist!");
- g1_policy()->phase_times()->record_thread_work_item(G1GCPhaseTimes::UpdateRS, worker_i, n_completed_buffers, G1GCPhaseTimes::UpdateRSProcessedBuffers);
+ phase_times()->record_thread_work_item(G1GCPhaseTimes::UpdateRS, worker_i, n_completed_buffers, G1GCPhaseTimes::UpdateRSProcessedBuffers);
}
// Computes the sum of the storage used by the various regions.
@@ -2018,7 +2013,7 @@
}
bool G1CollectedHeap::should_upgrade_to_full_gc(GCCause::Cause cause) {
- if(g1_policy()->force_upgrade_to_full()) {
+ if(policy()->force_upgrade_to_full()) {
return true;
} else if (should_do_concurrent_full_gc(_gc_cause)) {
return false;
@@ -2113,15 +2108,21 @@
}
void G1CollectedHeap::collect(GCCause::Cause cause) {
+ try_collect(cause, true);
+}
+
+bool G1CollectedHeap::try_collect(GCCause::Cause cause, bool retry_on_gc_failure) {
assert_heap_not_locked();
- uint gc_count_before;
- uint old_marking_count_before;
- uint full_gc_count_before;
- bool retry_gc;
+ bool gc_succeeded;
+ bool should_retry_gc;
do {
- retry_gc = false;
+ should_retry_gc = false;
+
+ uint gc_count_before;
+ uint old_marking_count_before;
+ uint full_gc_count_before;
{
MutexLocker ml(Heap_lock);
@@ -2140,21 +2141,20 @@
gc_count_before,
cause,
true, /* should_initiate_conc_mark */
- g1_policy()->max_pause_time_ms());
+ policy()->max_pause_time_ms());
VMThread::execute(&op);
- if (!op.pause_succeeded()) {
+ gc_succeeded = op.gc_succeeded();
+ if (!gc_succeeded && retry_on_gc_failure) {
if (old_marking_count_before == _old_marking_cycles_started) {
- retry_gc = op.should_retry_gc();
+ should_retry_gc = op.should_retry_gc();
} else {
// A Full GC happened while we were trying to schedule the
- // initial-mark GC. No point in starting a new cycle given
+ // concurrent cycle. No point in starting a new cycle given
// that the whole heap was collected anyway.
}
- if (retry_gc) {
- if (GCLocker::is_active_and_needs_gc()) {
- GCLocker::stall_until_clear();
- }
+ if (should_retry_gc && GCLocker::is_active_and_needs_gc()) {
+ GCLocker::stall_until_clear();
}
}
} else {
@@ -2167,15 +2167,18 @@
gc_count_before,
cause,
false, /* should_initiate_conc_mark */
- g1_policy()->max_pause_time_ms());
+ policy()->max_pause_time_ms());
VMThread::execute(&op);
+ gc_succeeded = op.gc_succeeded();
} else {
// Schedule a Full GC.
VM_G1CollectFull op(gc_count_before, full_gc_count_before, cause);
VMThread::execute(&op);
+ gc_succeeded = op.gc_succeeded();
}
}
- } while (retry_gc);
+ } while (should_retry_gc);
+ return gc_succeeded;
}
bool G1CollectedHeap::is_in(const void* p) const {
@@ -2266,7 +2269,7 @@
}
size_t G1CollectedHeap::tlab_capacity(Thread* ignored) const {
- return (_g1_policy->young_list_target_length() - _survivor.length()) * HeapRegion::GrainBytes;
+ return (_policy->young_list_target_length() - _survivor.length()) * HeapRegion::GrainBytes;
}
size_t G1CollectedHeap::tlab_used(Thread* ignored) const {
@@ -2295,7 +2298,7 @@
// See the notes in GenCollectedHeap::millis_since_last_gc()
// for more information about the implementation.
jlong ret_val = (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) -
- _g1_policy->collection_pause_end_millis();
+ _policy->collection_pause_end_millis();
if (ret_val < 0) {
log_warning(gc)("millis_since_last_gc() would return : " JLONG_FORMAT
". returning zero instead.", ret_val);
@@ -2328,6 +2331,10 @@
return _cm_thread->request_concurrent_phase(phase);
}
+bool G1CollectedHeap::is_heterogeneous_heap() const {
+ return _collector_policy->is_heterogeneous_heap();
+}
+
class PrintRegionClosure: public HeapRegionClosure {
outputStream* _st;
public:
@@ -2437,7 +2444,7 @@
}
void G1CollectedHeap::print_tracing_info() const {
- g1_rem_set()->print_summary_info();
+ rem_set()->print_summary_info();
concurrent_mark()->print_summary_info();
}
@@ -2497,7 +2504,7 @@
size_t heap_used = Heap_lock->owned_by_self() ? used() : used_unlocked();
size_t eden_capacity_bytes =
- (g1_policy()->young_list_target_length() * HeapRegion::GrainBytes) - survivor_used_bytes;
+ (policy()->young_list_target_length() * HeapRegion::GrainBytes) - survivor_used_bytes;
VirtualSpaceSummary heap_summary = create_heap_space_summary();
return G1HeapSummary(heap_summary, heap_used, eden_used_bytes,
@@ -2531,7 +2538,7 @@
assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer");
// This summary needs to be printed before incrementing total collections.
- g1_rem_set()->print_periodic_summary_info("Before GC RS summary", total_collections());
+ rem_set()->print_periodic_summary_info("Before GC RS summary", total_collections());
// Update common counters.
increment_total_collections(full /* full gc */);
@@ -2542,7 +2549,7 @@
// Fill TLAB's and such
double start = os::elapsedTime();
ensure_parsability(true);
- g1_policy()->phase_times()->record_prepare_tlab_time_ms((os::elapsedTime() - start) * 1000.0);
+ phase_times()->record_prepare_tlab_time_ms((os::elapsedTime() - start) * 1000.0);
}
void G1CollectedHeap::gc_epilogue(bool full) {
@@ -2553,7 +2560,7 @@
}
// We are at the end of the GC. Total collections has already been increased.
- g1_rem_set()->print_periodic_summary_info("After GC RS summary", total_collections() - 1);
+ rem_set()->print_periodic_summary_info("After GC RS summary", total_collections() - 1);
// FIXME: what is this about?
// I'm ignoring the "fill_newgen()" call if "alloc_event_enabled"
@@ -2565,7 +2572,7 @@
double start = os::elapsedTime();
resize_all_tlabs();
- g1_policy()->phase_times()->record_resize_tlab_time_ms((os::elapsedTime() - start) * 1000.0);
+ phase_times()->record_resize_tlab_time_ms((os::elapsedTime() - start) * 1000.0);
MemoryService::track_memory_usage();
// We have just completed a GC. Update the soft reference
@@ -2582,11 +2589,11 @@
gc_count_before,
gc_cause,
false, /* should_initiate_conc_mark */
- g1_policy()->max_pause_time_ms());
+ policy()->max_pause_time_ms());
VMThread::execute(&op);
HeapWord* result = op.result();
- bool ret_succeeded = op.prologue_succeeded() && op.pause_succeeded();
+ bool ret_succeeded = op.prologue_succeeded() && op.gc_succeeded();
assert(result == NULL || ret_succeeded,
"the result should be NULL if the VM did not succeed");
*succeeded = ret_succeeded;
@@ -2604,16 +2611,20 @@
}
size_t G1CollectedHeap::pending_card_num() {
- size_t extra_cards = 0;
- for (JavaThreadIteratorWithHandle jtiwh; JavaThread *curr = jtiwh.next(); ) {
- G1DirtyCardQueue& dcq = G1ThreadLocalData::dirty_card_queue(curr);
- extra_cards += dcq.size();
- }
+ struct CountCardsClosure : public ThreadClosure {
+ size_t _cards;
+ CountCardsClosure() : _cards(0) {}
+ virtual void do_thread(Thread* t) {
+ _cards += G1ThreadLocalData::dirty_card_queue(t).size();
+ }
+ } count_from_threads;
+ Threads::threads_do(&count_from_threads);
+
G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set();
size_t buffer_size = dcqs.buffer_size();
size_t buffer_num = dcqs.completed_buffers_num();
- return buffer_size * buffer_num + extra_cards;
+ return buffer_size * buffer_num + count_from_threads._cards;
}
bool G1CollectedHeap::is_potential_eager_reclaim_candidate(HeapRegion* r) const {
@@ -2759,7 +2770,7 @@
void G1CollectedHeap::register_humongous_regions_with_cset() {
if (!G1EagerReclaimHumongousObjects) {
- g1_policy()->phase_times()->record_fast_reclaim_humongous_stats(0.0, 0, 0);
+ phase_times()->record_fast_reclaim_humongous_stats(0.0, 0, 0);
return;
}
double time = os::elapsed_counter();
@@ -2769,9 +2780,9 @@
heap_region_iterate(&cl);
time = ((double)(os::elapsed_counter() - time) / os::elapsed_frequency()) * 1000.0;
- g1_policy()->phase_times()->record_fast_reclaim_humongous_stats(time,
- cl.total_humongous(),
- cl.candidate_humongous());
+ phase_times()->record_fast_reclaim_humongous_stats(time,
+ cl.total_humongous(),
+ cl.candidate_humongous());
_has_humongous_reclaim_candidates = cl.candidate_humongous() > 0;
// Finally flush all remembered set entries to re-check into the global DCQS.
@@ -2841,7 +2852,7 @@
double scan_wait_end = os::elapsedTime();
wait_time_ms = (scan_wait_end - scan_wait_start) * 1000.0;
}
- g1_policy()->phase_times()->record_root_region_scan_wait_time(wait_time_ms);
+ phase_times()->record_root_region_scan_wait_time(wait_time_ms);
}
class G1PrintCollectionSetClosure : public HeapRegionClosure {
@@ -2862,7 +2873,7 @@
clear_cset_fast_test();
guarantee(_eden.length() == 0, "eden should have been cleared");
- g1_policy()->transfer_survivors_to_cset(survivor());
+ policy()->transfer_survivors_to_cset(survivor());
}
bool
@@ -2882,7 +2893,7 @@
SvcGCMarker sgcm(SvcGCMarker::MINOR);
ResourceMark rm;
- g1_policy()->note_gc_start();
+ policy()->note_gc_start();
wait_for_root_region_scanning();
@@ -2898,7 +2909,7 @@
// This call will decide whether this pause is an initial-mark
// pause. If it is, in_initial_mark_gc() will return true
// for the duration of this pause.
- g1_policy()->decide_on_conc_mark_initiation();
+ policy()->decide_on_conc_mark_initiation();
}
// We do not allow initial-mark to be piggy-backed on a mixed GC.
@@ -3010,13 +3021,13 @@
// the possible verification above.
double sample_start_time_sec = os::elapsedTime();
- g1_policy()->record_collection_pause_start(sample_start_time_sec);
+ policy()->record_collection_pause_start(sample_start_time_sec);
if (collector_state()->in_initial_mark_gc()) {
concurrent_mark()->pre_initial_mark();
}
- g1_policy()->finalize_collection_set(target_pause_time_ms, &_survivor);
+ policy()->finalize_collection_set(target_pause_time_ms, &_survivor);
evacuation_info.set_collectionset_regions(collection_set()->region_length());
@@ -3059,12 +3070,12 @@
double start = os::elapsedTime();
start_new_collection_set();
- g1_policy()->phase_times()->record_start_new_cset_time_ms((os::elapsedTime() - start) * 1000.0);
+ phase_times()->record_start_new_cset_time_ms((os::elapsedTime() - start) * 1000.0);
if (evacuation_failed()) {
double recalculate_used_start = os::elapsedTime();
set_used(recalculate_used());
- g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
+ phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
if (_archive_allocator != NULL) {
_archive_allocator->clear_used();
@@ -3077,7 +3088,7 @@
} else {
// The "used" of the the collection set have already been subtracted
// when they were freed. Add in the bytes evacuated.
- increase_used(g1_policy()->bytes_copied_during_gc());
+ increase_used(policy()->bytes_copied_during_gc());
}
if (collector_state()->in_initial_mark_gc()) {
@@ -3104,7 +3115,7 @@
if (!expand(expand_bytes, _workers, &expand_ms)) {
// We failed to expand the heap. Cannot do anything about it.
}
- g1_policy()->phase_times()->record_expand_heap_time(expand_ms);
+ phase_times()->record_expand_heap_time(expand_ms);
}
}
@@ -3117,11 +3128,11 @@
// investigate this in CR 7178365.
double sample_end_time_sec = os::elapsedTime();
double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS;
- size_t total_cards_scanned = g1_policy()->phase_times()->sum_thread_work_items(G1GCPhaseTimes::ScanRS, G1GCPhaseTimes::ScanRSScannedCards);
- g1_policy()->record_collection_pause_end(pause_time_ms, total_cards_scanned, heap_used_bytes_before_gc);
+ size_t total_cards_scanned = phase_times()->sum_thread_work_items(G1GCPhaseTimes::ScanRS, G1GCPhaseTimes::ScanRSScannedCards);
+ policy()->record_collection_pause_end(pause_time_ms, total_cards_scanned, heap_used_bytes_before_gc);
evacuation_info.set_collectionset_used_before(collection_set()->bytes_used_before());
- evacuation_info.set_bytes_copied(g1_policy()->bytes_copied_during_gc());
+ evacuation_info.set_bytes_copied(policy()->bytes_copied_during_gc());
if (VerifyRememberedSets) {
log_info(gc, verify)("[Verifying RemSets after GC]");
@@ -3150,7 +3161,7 @@
log_info(gc)("To-space exhausted");
}
- g1_policy()->print_phases();
+ policy()->print_phases();
heap_transition.print();
// It is not yet to safe to tell the concurrent mark to
@@ -3175,7 +3186,7 @@
g1mm()->update_sizes();
_gc_tracer_stw->report_evacuation_info(&evacuation_info);
- _gc_tracer_stw->report_tenuring_threshold(_g1_policy->tenuring_threshold());
+ _gc_tracer_stw->report_tenuring_threshold(_policy->tenuring_threshold());
_gc_timer_stw->register_gc_end();
_gc_tracer_stw->report_gc_end(_gc_timer_stw->gc_end(), _gc_timer_stw->time_partitions());
}
@@ -3209,7 +3220,7 @@
SharedRestorePreservedMarksTaskExecutor task_executor(workers());
_preserved_marks_set.restore(&task_executor);
- g1_policy()->phase_times()->record_evac_fail_remove_self_forwards((os::elapsedTime() - remove_self_forwards_start) * 1000.0);
+ phase_times()->record_evac_fail_remove_self_forwards((os::elapsedTime() - remove_self_forwards_start) * 1000.0);
}
void G1CollectedHeap::preserve_mark_during_evac_failure(uint worker_id, oop obj, markOop m) {
@@ -3267,7 +3278,7 @@
if (worker_id >= _n_workers) return; // no work needed this round
double start_sec = os::elapsedTime();
- _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerStart, worker_id, start_sec);
+ _g1h->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerStart, worker_id, start_sec);
{
ResourceMark rm;
@@ -3282,7 +3293,7 @@
_root_processor->evacuate_roots(pss, worker_id);
- _g1h->g1_rem_set()->oops_into_collection_set_do(pss, worker_id);
+ _g1h->rem_set()->oops_into_collection_set_do(pss, worker_id);
double strong_roots_sec = os::elapsedTime() - start_strong_roots_sec;
@@ -3297,7 +3308,7 @@
term_sec = evac.term_time();
double elapsed_sec = os::elapsedTime() - start;
- G1GCPhaseTimes* p = _g1h->g1_policy()->phase_times();
+ G1GCPhaseTimes* p = _g1h->phase_times();
p->add_time_secs(G1GCPhaseTimes::ObjCopy, worker_id, elapsed_sec - term_sec);
p->record_or_add_thread_work_item(G1GCPhaseTimes::ObjCopy,
@@ -3319,7 +3330,7 @@
// destructors are executed here and are included as part of the
// "GC Worker Time".
}
- _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerEnd, worker_id, os::elapsedTime());
+ _g1h->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerEnd, worker_id, os::elapsedTime());
}
};
@@ -3384,13 +3395,13 @@
_queue(queue), _g1h(g1h) { }
virtual void work(uint worker_id) {
- G1GCPhaseTimes* phase_times = _g1h->g1_policy()->phase_times();
- G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::RedirtyCards, worker_id);
+ G1GCPhaseTimes* p = _g1h->phase_times();
+ G1GCParPhaseTimesTracker x(p, G1GCPhaseTimes::RedirtyCards, worker_id);
RedirtyLoggedCardTableEntryClosure cl(_g1h);
_queue->par_apply_closure_to_all_completed_buffers(&cl);
- phase_times->record_thread_work_item(G1GCPhaseTimes::RedirtyCards, worker_id, cl.num_dirtied());
+ p->record_thread_work_item(G1GCPhaseTimes::RedirtyCards, worker_id, cl.num_dirtied());
}
};
@@ -3405,7 +3416,7 @@
dcq.merge_bufferlists(&dirty_card_queue_set());
assert(dirty_card_queue_set().completed_buffers_num() == 0, "All should be consumed");
- g1_policy()->phase_times()->record_redirty_logged_cards_time_ms((os::elapsedTime() - redirty_logged_cards_start) * 1000.0);
+ phase_times()->record_redirty_logged_cards_time_ms((os::elapsedTime() - redirty_logged_cards_start) * 1000.0);
}
// Weak Reference Processing support
@@ -3638,7 +3649,7 @@
// Setup the soft refs policy...
rp->setup_policy(false);
- ReferenceProcessorPhaseTimes* pt = g1_policy()->phase_times()->ref_phase_times();
+ ReferenceProcessorPhaseTimes* pt = phase_times()->ref_phase_times();
ReferenceProcessorStats stats;
if (!rp->processing_is_mt()) {
@@ -3674,7 +3685,7 @@
rp->verify_no_references_recorded();
double ref_proc_time = os::elapsedTime() - ref_proc_start;
- g1_policy()->phase_times()->record_ref_proc_time(ref_proc_time * 1000.0);
+ phase_times()->record_ref_proc_time(ref_proc_time * 1000.0);
}
void G1CollectedHeap::make_pending_list_reachable() {
@@ -3690,7 +3701,7 @@
void G1CollectedHeap::merge_per_thread_state_info(G1ParScanThreadStateSet* per_thread_states) {
double merge_pss_time_start = os::elapsedTime();
per_thread_states->flush();
- g1_policy()->phase_times()->record_merge_pss_time_ms((os::elapsedTime() - merge_pss_time_start) * 1000.0);
+ phase_times()->record_merge_pss_time_ms((os::elapsedTime() - merge_pss_time_start) * 1000.0);
}
void G1CollectedHeap::pre_evacuate_collection_set() {
@@ -3701,11 +3712,9 @@
_hot_card_cache->reset_hot_cache_claimed_index();
_hot_card_cache->set_use_cache(false);
- g1_rem_set()->prepare_for_oops_into_collection_set_do();
+ rem_set()->prepare_for_oops_into_collection_set_do();
_preserved_marks_set.assert_empty();
- G1GCPhaseTimes* phase_times = g1_policy()->phase_times();
-
// InitialMark needs claim bits to keep track of the marked-through CLDs.
if (collector_state()->in_initial_mark_gc()) {
double start_clear_claimed_marks = os::elapsedTime();
@@ -3713,7 +3722,7 @@
ClassLoaderDataGraph::clear_claimed_marks();
double recorded_clear_claimed_marks_time_ms = (os::elapsedTime() - start_clear_claimed_marks) * 1000.0;
- phase_times->record_clear_claimed_marks_time_ms(recorded_clear_claimed_marks_time_ms);
+ phase_times()->record_clear_claimed_marks_time_ms(recorded_clear_claimed_marks_time_ms);
}
}
@@ -3723,8 +3732,6 @@
assert(dirty_card_queue_set().completed_buffers_num() == 0, "Should be empty");
- G1GCPhaseTimes* phase_times = g1_policy()->phase_times();
-
double start_par_time_sec = os::elapsedTime();
double end_par_time_sec;
@@ -3744,11 +3751,11 @@
}
double par_time_ms = (end_par_time_sec - start_par_time_sec) * 1000.0;
- phase_times->record_par_time(par_time_ms);
+ phase_times()->record_par_time(par_time_ms);
double code_root_fixup_time_ms =
(os::elapsedTime() - end_par_time_sec) * 1000.0;
- phase_times->record_code_root_fixup_time(code_root_fixup_time_ms);
+ phase_times()->record_code_root_fixup_time(code_root_fixup_time_ms);
}
class G1EvacuateOptionalRegionTask : public AbstractGangTask {
@@ -3782,7 +3789,7 @@
pss->oops_into_optional_region(hr)->oops_do(&scan_opt_cl, root_cls->raw_strong_oops());
copy_time += trim_ticks(pss);
- G1ScanRSForRegionClosure scan_rs_cl(_g1h->g1_rem_set()->scan_state(), &obj_cl, pss, G1GCPhaseTimes::OptScanRS, worker_id);
+ G1ScanRSForRegionClosure scan_rs_cl(_g1h->rem_set()->scan_state(), &obj_cl, pss, G1GCPhaseTimes::OptScanRS, worker_id);
scan_rs_cl.do_heap_region(hr);
copy_time += trim_ticks(pss);
scanned += scan_rs_cl.cards_scanned();
@@ -3794,7 +3801,7 @@
}
Tickspan scan_time = (Ticks::now() - start) - copy_time;
- G1GCPhaseTimes* p = _g1h->g1_policy()->phase_times();
+ G1GCPhaseTimes* p = _g1h->phase_times();
p->record_or_add_time_secs(G1GCPhaseTimes::OptScanRS, worker_id, scan_time.seconds());
p->record_or_add_time_secs(G1GCPhaseTimes::OptObjCopy, worker_id, copy_time.seconds());
@@ -3810,7 +3817,7 @@
cl.do_void();
Tickspan evac_time = (Ticks::now() - start);
- G1GCPhaseTimes* p = _g1h->g1_policy()->phase_times();
+ G1GCPhaseTimes* p = _g1h->phase_times();
p->record_or_add_time_secs(G1GCPhaseTimes::OptObjCopy, worker_id, evac_time.seconds());
assert(pss->trim_ticks().seconds() == 0.0, "Unexpected partial trimming done during optional evacuation");
}
@@ -3859,8 +3866,7 @@
return;
}
- G1GCPhaseTimes* phase_times = g1_policy()->phase_times();
- const double gc_start_time_ms = phase_times->cur_collection_start_sec() * 1000.0;
+ const double gc_start_time_ms = phase_times()->cur_collection_start_sec() * 1000.0;
double start_time_sec = os::elapsedTime();
@@ -3873,7 +3879,7 @@
break;
}
- optional_cset.prepare_evacuation(time_left_ms * _g1_policy->optional_evacuation_fraction());
+ optional_cset.prepare_evacuation(time_left_ms * _policy->optional_evacuation_fraction());
if (optional_cset.prepare_failed()) {
log_trace(gc, ergo, cset)("Skipping %u optional regions, no regions can be evacuated in %.3fms", optional_cset.size(), time_left_ms);
break;
@@ -3887,13 +3893,13 @@
}
} while (!optional_cset.is_empty());
- phase_times->record_optional_evacuation((os::elapsedTime() - start_time_sec) * 1000.0);
+ phase_times()->record_optional_evacuation((os::elapsedTime() - start_time_sec) * 1000.0);
}
void G1CollectedHeap::post_evacuate_collection_set(G1EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
// Also cleans the card table from temporary duplicate detection information used
// during UpdateRS/ScanRS.
- g1_rem_set()->cleanup_after_oops_into_collection_set_do();
+ rem_set()->cleanup_after_oops_into_collection_set_do();
// Process any discovered reference objects - we have
// to do this _before_ we retire the GC alloc regions
@@ -3906,15 +3912,15 @@
G1KeepAliveClosure keep_alive(this);
WeakProcessor::weak_oops_do(workers(), &is_alive, &keep_alive,
- g1_policy()->phase_times()->weak_phase_times());
+ phase_times()->weak_phase_times());
if (G1StringDedup::is_enabled()) {
double string_dedup_time_ms = os::elapsedTime();
- string_dedup_cleaning(&is_alive, &keep_alive, g1_policy()->phase_times());
+ string_dedup_cleaning(&is_alive, &keep_alive, phase_times());
double string_cleanup_time_ms = (os::elapsedTime() - string_dedup_time_ms) * 1000.0;
- g1_policy()->phase_times()->record_string_deduplication_time(string_cleanup_time_ms);
+ phase_times()->record_string_deduplication_time(string_cleanup_time_ms);
}
if (evacuation_failed()) {
@@ -3944,13 +3950,13 @@
#if COMPILER2_OR_JVMCI
double start = os::elapsedTime();
DerivedPointerTable::update_pointers();
- g1_policy()->phase_times()->record_derived_pointer_table_update_time((os::elapsedTime() - start) * 1000.0);
+ phase_times()->record_derived_pointer_table_update_time((os::elapsedTime() - start) * 1000.0);
#endif
- g1_policy()->print_age_table();
+ policy()->print_age_table();
}
void G1CollectedHeap::record_obj_copy_mem_stats() {
- g1_policy()->add_bytes_allocated_in_old_since_last_gc(_old_evac_stats.allocated() * HeapWordSize);
+ policy()->add_bytes_allocated_in_old_since_last_gc(_old_evac_stats.allocated() * HeapWordSize);
_gc_tracer_stw->report_evacuation_statistics(create_g1_evac_summary(&_survivor_evac_stats),
create_g1_evac_summary(&_old_evac_stats));
@@ -3978,7 +3984,7 @@
_hot_card_cache->reset_card_counts(hr);
}
hr->hr_clear(skip_remset, true /* clear_space */, locked /* locked */);
- _g1_policy->remset_tracker()->update_at_free(hr);
+ _policy->remset_tracker()->update_at_free(hr);
free_list->add_ordered(hr);
}
@@ -4108,7 +4114,7 @@
g1h->prepend_to_freelist(&_local_free_list);
g1h->decrement_summary_bytes(_before_used_bytes);
- G1Policy* policy = g1h->g1_policy();
+ G1Policy* policy = g1h->policy();
policy->add_bytes_allocated_in_old_since_last_gc(_bytes_allocated_in_old_since_last_gc);
g1h->alloc_buffer_stats(InCSetState::Old)->add_failure_used_and_waste(_failure_used_words, _failure_waste_words);
@@ -4183,7 +4189,7 @@
void complete_work() {
_cl.complete_work();
- G1Policy* policy = G1CollectedHeap::heap()->g1_policy();
+ G1Policy* policy = G1CollectedHeap::heap()->policy();
policy->record_max_rs_lengths(_rs_lengths);
policy->cset_regions_freed();
}
@@ -4211,7 +4217,7 @@
static uint chunk_size() { return 32; }
virtual void work(uint worker_id) {
- G1GCPhaseTimes* timer = G1CollectedHeap::heap()->g1_policy()->phase_times();
+ G1GCPhaseTimes* timer = G1CollectedHeap::heap()->phase_times();
// Claim serial work.
if (_serial_work_claim == 0) {
@@ -4288,7 +4294,7 @@
_collection_set.region_length());
workers()->run_task(&cl, num_workers);
}
- g1_policy()->phase_times()->record_total_free_cset_time_ms((os::elapsedTime() - free_cset_start_time) * 1000.0);
+ phase_times()->record_total_free_cset_time_ms((os::elapsedTime() - free_cset_start_time) * 1000.0);
collection_set->clear();
}
@@ -4413,7 +4419,7 @@
if (!G1EagerReclaimHumongousObjects ||
(!_has_humongous_reclaim_candidates && !log_is_enabled(Debug, gc, humongous))) {
- g1_policy()->phase_times()->record_fast_reclaim_humongous_time_ms(0.0, 0);
+ phase_times()->record_fast_reclaim_humongous_time_ms(0.0, 0);
return;
}
@@ -4438,8 +4444,8 @@
prepend_to_freelist(&local_cleanup_list);
decrement_summary_bytes(cl.bytes_freed());
- g1_policy()->phase_times()->record_fast_reclaim_humongous_time_ms((os::elapsedTime() - start_time) * 1000.0,
- cl.humongous_objects_reclaimed());
+ phase_times()->record_fast_reclaim_humongous_time_ms((os::elapsedTime() - start_time) * 1000.0,
+ cl.humongous_objects_reclaimed());
}
class G1AbandonCollectionSetClosure : public HeapRegionClosure {
@@ -4466,7 +4472,7 @@
void G1CollectedHeap::set_region_short_lived_locked(HeapRegion* hr) {
_eden.add(hr);
- _g1_policy->set_region_eden(hr);
+ _policy->set_region_eden(hr);
}
#ifdef ASSERT
@@ -4636,7 +4642,7 @@
HeapRegion* G1CollectedHeap::new_mutator_alloc_region(size_t word_size,
bool force) {
assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
- bool should_allocate = g1_policy()->should_allocate_mutator_region();
+ bool should_allocate = policy()->should_allocate_mutator_region();
if (force || should_allocate) {
HeapRegion* new_alloc_region = new_region(word_size,
HeapRegionType::Eden,
@@ -4645,7 +4651,7 @@
set_region_short_lived_locked(new_alloc_region);
_hr_printer.alloc(new_alloc_region, !should_allocate);
_verifier->check_bitmaps("Mutator Region Allocation", new_alloc_region);
- _g1_policy->remset_tracker()->update_at_allocate(new_alloc_region);
+ _policy->remset_tracker()->update_at_allocate(new_alloc_region);
return new_alloc_region;
}
}
@@ -4672,7 +4678,7 @@
if (dest.is_old()) {
return true;
} else {
- return survivor_regions_count() < g1_policy()->max_survivor_regions();
+ return survivor_regions_count() < policy()->max_survivor_regions();
}
}
@@ -4703,7 +4709,7 @@
new_alloc_region->set_old();
_verifier->check_bitmaps("Old Region Allocation", new_alloc_region);
}
- _g1_policy->remset_tracker()->update_at_allocate(new_alloc_region);
+ _policy->remset_tracker()->update_at_allocate(new_alloc_region);
_hr_printer.alloc(new_alloc_region);
return new_alloc_region;
}
@@ -4713,7 +4719,7 @@
void G1CollectedHeap::retire_gc_alloc_region(HeapRegion* alloc_region,
size_t allocated_bytes,
InCSetState dest) {
- g1_policy()->record_bytes_copied_during_gc(allocated_bytes);
+ policy()->record_bytes_copied_during_gc(allocated_bytes);
if (dest.is_old()) {
old_set_add(alloc_region);
}
@@ -4818,7 +4824,7 @@
double purge_start = os::elapsedTime();
G1CodeRootSet::purge();
double purge_time_ms = (os::elapsedTime() - purge_start) * 1000.0;
- g1_policy()->phase_times()->record_strong_code_root_purge_time(purge_time_ms);
+ phase_times()->record_strong_code_root_purge_time(purge_time_ms);
}
class RebuildStrongCodeRootClosure: public CodeBlobClosure {
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -366,7 +366,7 @@
G1NewTracer* _gc_tracer_stw;
// The current policy object for the collector.
- G1Policy* _g1_policy;
+ G1Policy* _policy;
G1HeapSizingPolicy* _heap_sizing_policy;
G1CollectionSet _collection_set;
@@ -745,7 +745,7 @@
G1HotCardCache* _hot_card_cache;
// The g1 remembered set of the heap.
- G1RemSet* _g1_rem_set;
+ G1RemSet* _rem_set;
// A set of cards that cover the objects for which the Rsets should be updated
// concurrently after the collection.
@@ -950,7 +950,11 @@
G1CollectorState* collector_state() { return &_collector_state; }
// The current policy object for the collector.
- G1Policy* g1_policy() const { return _g1_policy; }
+ G1Policy* policy() const { return _policy; }
+ // The remembered set.
+ G1RemSet* rem_set() const { return _rem_set; }
+
+ inline G1GCPhaseTimes* phase_times() const;
HeapRegionManager* hrm() const { return _hrm; }
@@ -958,7 +962,6 @@
G1CollectionSet* collection_set() { return &_collection_set; }
virtual CollectorPolicy* collector_policy() const;
- virtual G1CollectorPolicy* g1_collector_policy() const;
virtual SoftRefPolicy* soft_ref_policy();
@@ -967,9 +970,6 @@
virtual GrowableArray<GCMemoryManager*> memory_managers();
virtual GrowableArray<MemoryPool*> memory_pools();
- // The rem set and barrier set.
- G1RemSet* g1_rem_set() const { return _g1_rem_set; }
-
// Try to minimize the remembered set.
void scrub_rem_set();
@@ -1061,6 +1061,11 @@
// "CollectedHeap" supports.
virtual void collect(GCCause::Cause cause);
+ // Perform a collection of the heap with the given cause; if the VM operation
+ // fails to execute for any reason, retry only if retry_on_gc_failure is set.
+ // Returns whether this collection actually executed.
+ bool try_collect(GCCause::Cause cause, bool retry_on_gc_failure);
+
// True iff an evacuation has failed in the most-recent collection.
bool evacuation_failed() { return _evacuation_failed; }
@@ -1361,6 +1366,7 @@
// WhiteBox testing support.
virtual bool supports_concurrent_phase_control() const;
virtual bool request_concurrent_phase(const char* phase);
+ bool is_heterogeneous_heap() const;
virtual WorkGang* get_safepoint_workers() { return _workers; }
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -28,11 +28,16 @@
#include "gc/g1/g1BarrierSet.hpp"
#include "gc/g1/g1CollectedHeap.hpp"
#include "gc/g1/g1CollectorState.hpp"
+#include "gc/g1/g1Policy.hpp"
#include "gc/g1/heapRegionManager.inline.hpp"
#include "gc/g1/heapRegionSet.inline.hpp"
#include "gc/shared/taskqueue.inline.hpp"
#include "runtime/orderAccess.hpp"
+G1GCPhaseTimes* G1CollectedHeap::phase_times() const {
+ return _policy->phase_times();
+}
+
G1EvacStats* G1CollectedHeap::alloc_buffer_stats(InCSetState dest) {
switch (dest.value()) {
case InCSetState::Young:
--- a/src/hotspot/share/gc/g1/g1CollectorPolicy.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1CollectorPolicy.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,6 @@
return _max_heap_byte_size;
}
-bool G1CollectorPolicy::is_hetero_heap() const {
+bool G1CollectorPolicy::is_heterogeneous_heap() const {
return false;
}
--- a/src/hotspot/share/gc/g1/g1CollectorPolicy.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1CollectorPolicy.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -39,6 +39,6 @@
public:
G1CollectorPolicy();
virtual size_t heap_reserved_size_bytes() const;
- virtual bool is_hetero_heap() const;
+ virtual bool is_heterogeneous_heap() const;
};
#endif // SHARE_GC_G1_G1COLLECTORPOLICY_HPP
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1013,7 +1013,7 @@
uint _num_regions_selected_for_rebuild; // The number of regions actually selected for rebuild.
void update_remset_before_rebuild(HeapRegion* hr) {
- G1RemSetTrackingPolicy* tracking_policy = _g1h->g1_policy()->remset_tracker();
+ G1RemSetTrackingPolicy* tracking_policy = _g1h->policy()->remset_tracker();
bool selected_for_rebuild;
if (hr->is_humongous()) {
@@ -1118,7 +1118,7 @@
G1UpdateRemSetTrackingAfterRebuild(G1CollectedHeap* g1h) : _g1h(g1h) { }
virtual bool do_heap_region(HeapRegion* r) {
- _g1h->g1_policy()->remset_tracker()->update_after_rebuild(r);
+ _g1h->policy()->remset_tracker()->update_after_rebuild(r);
return false;
}
};
@@ -1132,8 +1132,8 @@
return;
}
- G1Policy* g1p = _g1h->g1_policy();
- g1p->record_concurrent_mark_remark_start();
+ G1Policy* policy = _g1h->policy();
+ policy->record_concurrent_mark_remark_start();
double start = os::elapsedTime();
@@ -1220,7 +1220,7 @@
_remark_weak_ref_times.add((now - mark_work_end) * 1000.0);
_remark_times.add((now - start) * 1000.0);
- g1p->record_concurrent_mark_remark_end();
+ policy->record_concurrent_mark_remark_end();
}
class G1ReclaimEmptyRegionsTask : public AbstractGangTask {
@@ -1338,8 +1338,8 @@
return;
}
- G1Policy* g1p = _g1h->g1_policy();
- g1p->record_concurrent_mark_cleanup_start();
+ G1Policy* policy = _g1h->policy();
+ policy->record_concurrent_mark_cleanup_start();
double start = os::elapsedTime();
@@ -1369,7 +1369,7 @@
{
GCTraceTime(Debug, gc, phases) debug("Finalize Concurrent Mark Cleanup", _gc_timer_cm);
- _g1h->g1_policy()->record_concurrent_mark_cleanup_end();
+ policy->record_concurrent_mark_cleanup_end();
}
}
@@ -1774,23 +1774,18 @@
_thread_parity(Threads::thread_claim_parity()) {}
void do_thread(Thread* thread) {
- if (thread->is_Java_thread()) {
- if (thread->claim_oops_do(true, _thread_parity)) {
- JavaThread* jt = (JavaThread*)thread;
-
+ if (thread->claim_oops_do(true, _thread_parity)) {
+ SATBMarkQueue& queue = G1ThreadLocalData::satb_mark_queue(thread);
+ queue.apply_closure_and_empty(&_cm_satb_cl);
+ if (thread->is_Java_thread()) {
// In theory it should not be neccessary to explicitly walk the nmethods to find roots for concurrent marking
// however the liveness of oops reachable from nmethods have very complex lifecycles:
// * Alive if on the stack of an executing method
// * Weakly reachable otherwise
// Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be
// live by the SATB invariant but other oops recorded in nmethods may behave differently.
+ JavaThread* jt = (JavaThread*)thread;
jt->nmethods_do(&_code_cl);
-
- G1ThreadLocalData::satb_mark_queue(jt).apply_closure_and_empty(&_cm_satb_cl);
- }
- } else if (thread->is_VM_thread()) {
- if (thread->claim_oops_do(true, _thread_parity)) {
- G1BarrierSet::satb_mark_queue_set().shared_satb_queue()->apply_closure_and_empty(&_cm_satb_cl);
}
}
}
@@ -1993,7 +1988,7 @@
#endif // PRODUCT
void G1ConcurrentMark::rebuild_rem_set_concurrently() {
- _g1h->g1_rem_set()->rebuild_rem_set(this, _concurrent_workers, _worker_id_offset);
+ _g1h->rem_set()->rebuild_rem_set(this, _concurrent_workers, _worker_id_offset);
}
void G1ConcurrentMark::print_stats() {
@@ -2572,7 +2567,7 @@
// and do_marking_step() is not being called serially.
bool do_stealing = do_termination && !is_serial;
- double diff_prediction_ms = _g1h->g1_policy()->predictor().get_new_prediction(&_marking_step_diffs_ms);
+ double diff_prediction_ms = _g1h->policy()->predictor().get_new_prediction(&_marking_step_diffs_ms);
_time_target_ms = time_target_ms - diff_prediction_ms;
// set up the variables that are used in the work-based scheme to
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -194,7 +194,7 @@
assert(_top_at_rebuild_starts[region] == NULL,
"TARS for region %u has already been set to " PTR_FORMAT " should be NULL",
region, p2i(_top_at_rebuild_starts[region]));
- G1RemSetTrackingPolicy* tracker = _g1h->g1_policy()->remset_tracker();
+ G1RemSetTrackingPolicy* tracker = _g1h->policy()->remset_tracker();
if (tracker->needs_scan_for_rebuild(r)) {
_top_at_rebuild_starts[region] = r->top();
} else {
--- a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -243,7 +243,7 @@
_vtime_start = os::elapsedVTime();
G1CollectedHeap* g1h = G1CollectedHeap::heap();
- G1Policy* g1_policy = g1h->g1_policy();
+ G1Policy* policy = g1h->policy();
G1ConcPhaseManager cpmanager(G1ConcurrentPhase::IDLE, this);
@@ -322,7 +322,7 @@
double mark_end_time = os::elapsedVTime();
jlong mark_end = os::elapsed_counter();
_vtime_mark_accum += (mark_end_time - cycle_start);
- delay_to_keep_mmu(g1_policy, true /* remark */);
+ delay_to_keep_mmu(policy, true /* remark */);
if (_cm->has_aborted()) {
break;
}
@@ -361,7 +361,7 @@
_vtime_accum = (end_time - _vtime_start);
if (!_cm->has_aborted()) {
- delay_to_keep_mmu(g1_policy, false /* cleanup */);
+ delay_to_keep_mmu(policy, false /* cleanup */);
}
if (!_cm->has_aborted()) {
--- a/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -45,7 +45,7 @@
class G1RefineCardConcurrentlyClosure: public G1CardTableEntryClosure {
public:
bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
- G1CollectedHeap::heap()->g1_rem_set()->refine_card_concurrently(card_ptr, worker_i);
+ G1CollectedHeap::heap()->rem_set()->refine_card_concurrently(card_ptr, worker_i);
if (SuspendibleThreadSet::should_yield()) {
// Caller will actually yield.
@@ -99,7 +99,7 @@
}
}
-void G1DirtyCardQueueSet::handle_zero_index_for_thread(JavaThread* t) {
+void G1DirtyCardQueueSet::handle_zero_index_for_thread(Thread* t) {
G1ThreadLocalData::dirty_card_queue(t).handle_zero_index();
}
@@ -207,11 +207,16 @@
void G1DirtyCardQueueSet::abandon_logs() {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
abandon_completed_buffers();
+
// Since abandon is done only at safepoints, we can safely manipulate
// these queues.
- for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
- G1ThreadLocalData::dirty_card_queue(t).reset();
- }
+ struct AbandonThreadLogClosure : public ThreadClosure {
+ virtual void do_thread(Thread* t) {
+ G1ThreadLocalData::dirty_card_queue(t).reset();
+ }
+ } closure;
+ Threads::threads_do(&closure);
+
shared_dirty_card_queue()->reset();
}
@@ -228,9 +233,17 @@
assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
size_t old_limit = max_completed_buffers();
set_max_completed_buffers(MaxCompletedBuffersUnlimited);
- for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
- concatenate_log(G1ThreadLocalData::dirty_card_queue(t));
- }
+
+ class ConcatenateThreadLogClosure : public ThreadClosure {
+ G1DirtyCardQueueSet* _qset;
+ public:
+ ConcatenateThreadLogClosure(G1DirtyCardQueueSet* qset) : _qset(qset) {}
+ virtual void do_thread(Thread* t) {
+ _qset->concatenate_log(G1ThreadLocalData::dirty_card_queue(t));
+ }
+ } closure(this);
+ Threads::threads_do(&closure);
+
concatenate_log(_shared_dirty_card_queue);
set_max_completed_buffers(old_limit);
}
--- a/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -30,7 +30,7 @@
class G1DirtyCardQueueSet;
class G1FreeIdSet;
-class JavaThread;
+class Thread;
class Monitor;
// A closure class for processing card table entries. Note that we don't
@@ -128,7 +128,7 @@
// mutator threads to do card-processing work.
static uint num_par_ids();
- static void handle_zero_index_for_thread(JavaThread* t);
+ static void handle_zero_index_for_thread(Thread* t);
// Apply G1RefineCardConcurrentlyClosure to completed buffers until there are stop_at
// completed buffers remaining.
--- a/src/hotspot/share/gc/g1/g1FullCollector.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -138,7 +138,7 @@
}
void G1FullCollector::prepare_collection() {
- _heap->g1_policy()->record_full_collection_start();
+ _heap->policy()->record_full_collection_start();
_heap->print_heap_before_gc();
_heap->print_heap_regions();
@@ -192,7 +192,7 @@
_heap->prepare_heap_for_mutators();
- _heap->g1_policy()->record_full_collection_end();
+ _heap->policy()->record_full_collection_end();
_heap->gc_epilogue(true);
_heap->verify_after_full_collection();
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -385,7 +385,7 @@
trace_phase(_gc_par_phases[GCWorkerStart], false);
debug_phase(_gc_par_phases[ExtRootScan]);
- for (int i = ThreadRoots; i <= SATBFiltering; i++) {
+ for (int i = ExtRootScanSubPhasesStart; i <= ExtRootScanSubPhasesEnd; i++) {
trace_phase(_gc_par_phases[i]);
}
if (G1HotCardCache::default_use_cache()) {
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -81,6 +81,9 @@
GCParPhasesSentinel
};
+ static const GCParPhases ExtRootScanSubPhasesStart = ThreadRoots;
+ static const GCParPhases ExtRootScanSubPhasesEnd = SATBFiltering;
+
enum GCScanRSWorkItems {
ScanRSScannedCards,
ScanRSClaimedCards,
--- a/src/hotspot/share/gc/g1/g1HeapTransition.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1HeapTransition.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -88,8 +88,8 @@
void G1HeapTransition::print() {
Data after(_g1_heap);
- size_t eden_capacity_length_after_gc = _g1_heap->g1_policy()->young_list_target_length() - after._survivor_length;
- size_t survivor_capacity_length_before_gc = _g1_heap->g1_policy()->max_survivor_regions();
+ size_t eden_capacity_length_after_gc = _g1_heap->policy()->young_list_target_length() - after._survivor_length;
+ size_t survivor_capacity_length_before_gc = _g1_heap->policy()->max_survivor_regions();
DetailedUsage usage;
if (log_is_enabled(Trace, gc, heap)) {
--- a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -495,7 +495,7 @@
bool failures = rootsCl.failures() || codeRootsCl.failures();
- if (!_g1h->g1_policy()->collector_state()->in_full_gc()) {
+ if (!_g1h->policy()->collector_state()->in_full_gc()) {
// If we're verifying during a full GC then the region sets
// will have been torn down at the start of the GC. Therefore
// verifying the region sets will fail. So we only verify
@@ -630,14 +630,14 @@
void G1HeapVerifier::verify_before_gc(G1VerifyType type) {
if (VerifyBeforeGC) {
double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "Before GC");
- _g1h->g1_policy()->phase_times()->record_verify_before_time_ms(verify_time_ms);
+ _g1h->phase_times()->record_verify_before_time_ms(verify_time_ms);
}
}
void G1HeapVerifier::verify_after_gc(G1VerifyType type) {
if (VerifyAfterGC) {
double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "After GC");
- _g1h->g1_policy()->phase_times()->record_verify_after_time_ms(verify_time_ms);
+ _g1h->phase_times()->record_verify_after_time_ms(verify_time_ms);
}
}
--- a/src/hotspot/share/gc/g1/g1HeterogeneousCollectorPolicy.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1HeterogeneousCollectorPolicy.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -98,6 +98,6 @@
return 2 * _max_heap_byte_size;
}
-bool G1HeterogeneousCollectorPolicy::is_hetero_heap() const {
+bool G1HeterogeneousCollectorPolicy::is_heterogeneous_heap() const {
return true;
}
--- a/src/hotspot/share/gc/g1/g1HeterogeneousCollectorPolicy.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1HeterogeneousCollectorPolicy.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -41,7 +41,7 @@
public:
G1HeterogeneousCollectorPolicy() {}
virtual size_t heap_reserved_size_bytes() const;
- virtual bool is_hetero_heap() const;
+ virtual bool is_heterogeneous_heap() const;
static size_t reasonable_max_memory_for_young();
};
--- a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -234,7 +234,7 @@
uint eden_list_length = young_list_length - survivor_list_length;
// Max length includes any potential extensions to the young gen
// we'll do when the GC locker is active.
- uint young_list_max_length = _g1h->g1_policy()->young_list_max_length();
+ uint young_list_max_length = _g1h->policy()->young_list_max_length();
assert(young_list_max_length >= survivor_list_length, "invariant");
uint eden_list_max_length = young_list_max_length - survivor_list_length;
--- a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -48,7 +48,7 @@
_closures(NULL),
_plab_allocator(NULL),
_age_table(false),
- _tenuring_threshold(g1h->g1_policy()->tenuring_threshold()),
+ _tenuring_threshold(g1h->policy()->tenuring_threshold()),
_scanner(g1h, this),
_worker_id(worker_id),
_stack_trim_upper_threshold(GCDrainStackTargetSize * 2 + 1),
@@ -91,7 +91,7 @@
_dcq.flush();
// Update allocation statistics.
_plab_allocator->flush_and_retire_stats();
- _g1h->g1_policy()->record_age_table(&_age_table);
+ _g1h->policy()->record_age_table(&_age_table);
uint length = _g1h->collection_set()->young_region_length();
for (uint region_index = 0; region_index < length; region_index++) {
@@ -372,7 +372,7 @@
}
size_t used_memory = pss->oops_into_optional_region(hr)->used_memory();
- _g1h->g1_policy()->phase_times()->record_or_add_thread_work_item(G1GCPhaseTimes::OptScanRS, worker_index, used_memory, G1GCPhaseTimes::OptCSetUsedMemory);
+ _g1h->phase_times()->record_or_add_thread_work_item(G1GCPhaseTimes::OptScanRS, worker_index, used_memory, G1GCPhaseTimes::OptCSetUsedMemory);
}
}
--- a/src/hotspot/share/gc/g1/g1Policy.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1Policy.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -90,7 +90,7 @@
}
G1Policy* G1Policy::create_policy(G1CollectorPolicy* policy, STWGCTimer* gc_timer_stw) {
- if (policy->is_hetero_heap()) {
+ if (policy->is_heterogeneous_heap()) {
return new G1HeterogeneousHeapPolicy(policy, gc_timer_stw);
} else {
return new G1Policy(policy, gc_timer_stw);
--- a/src/hotspot/share/gc/g1/g1RemSet.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1RemSet.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -48,7 +48,6 @@
#include "runtime/os.hpp"
#include "utilities/align.hpp"
#include "utilities/globalDefinitions.hpp"
-#include "utilities/intHisto.hpp"
#include "utilities/stack.inline.hpp"
#include "utilities/ticks.hpp"
@@ -289,7 +288,7 @@
_g1h(g1h),
_num_conc_refined_cards(0),
_ct(ct),
- _g1p(_g1h->g1_policy()),
+ _g1p(_g1h->policy()),
_hot_card_cache(hot_card_cache) {
}
@@ -468,7 +467,7 @@
size_t _cards_skipped;
public:
G1RefineCardClosure(G1CollectedHeap* g1h, G1ScanObjsDuringUpdateRSClosure* update_rs_cl) :
- _g1rs(g1h->g1_rem_set()), _update_rs_cl(update_rs_cl), _cards_scanned(0), _cards_skipped(0)
+ _g1rs(g1h->rem_set()), _update_rs_cl(update_rs_cl), _cards_scanned(0), _cards_skipped(0)
{}
bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
@@ -531,7 +530,7 @@
}
void G1RemSet::cleanup_after_oops_into_collection_set_do() {
- G1GCPhaseTimes* phase_times = _g1h->g1_policy()->phase_times();
+ G1GCPhaseTimes* phase_times = _g1h->phase_times();
// Set all cards back to clean.
double start = os::elapsedTime();
--- a/src/hotspot/share/gc/g1/g1RootProcessor.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1RootProcessor.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -76,7 +76,7 @@
_n_workers_discovered_strong_classes(0) {}
void G1RootProcessor::evacuate_roots(G1ParScanThreadState* pss, uint worker_i) {
- G1GCPhaseTimes* phase_times = _g1h->g1_policy()->phase_times();
+ G1GCPhaseTimes* phase_times = _g1h->phase_times();
G1EvacPhaseTimesTracker timer(phase_times, pss, G1GCPhaseTimes::ExtRootScan, worker_i);
--- a/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* 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,21 +38,19 @@
Monitor* cbl_mon,
BufferNode::Allocator* allocator,
size_t process_completed_buffers_threshold,
- uint buffer_enqueue_threshold_percentage,
- Mutex* lock) {
+ uint buffer_enqueue_threshold_percentage) {
SATBMarkQueueSet::initialize(cbl_mon,
allocator,
process_completed_buffers_threshold,
- buffer_enqueue_threshold_percentage,
- lock);
+ buffer_enqueue_threshold_percentage);
_g1h = g1h;
}
-void G1SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
+void G1SATBMarkQueueSet::handle_zero_index_for_thread(Thread* t) {
G1ThreadLocalData::satb_mark_queue(t).handle_zero_index();
}
-SATBMarkQueue& G1SATBMarkQueueSet::satb_queue_for_thread(JavaThread* const t) const{
+SATBMarkQueue& G1SATBMarkQueueSet::satb_queue_for_thread(Thread* const t) const{
return G1ThreadLocalData::satb_mark_queue(t);
}
--- a/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -29,7 +29,7 @@
class G1CollectedHeap;
class Monitor;
-class JavaThread;
+class Thread;
class G1SATBMarkQueueSet : public SATBMarkQueueSet {
G1CollectedHeap* _g1h;
@@ -41,11 +41,10 @@
Monitor* cbl_mon,
BufferNode::Allocator* allocator,
size_t process_completed_buffers_threshold,
- uint buffer_enqueue_threshold_percentage,
- Mutex* lock);
+ uint buffer_enqueue_threshold_percentage);
- static void handle_zero_index_for_thread(JavaThread* t);
- virtual SATBMarkQueue& satb_queue_for_thread(JavaThread* const t) const;
+ static void handle_zero_index_for_thread(Thread* t);
+ virtual SATBMarkQueue& satb_queue_for_thread(Thread* const t) const;
virtual void filter(SATBMarkQueue* queue);
};
--- a/src/hotspot/share/gc/g1/g1VMOperations.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1VMOperations.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* 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,7 +36,7 @@
void VM_G1CollectFull::doit() {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
GCCauseSetter x(g1h, _gc_cause);
- g1h->do_full_collection(false /* clear_all_soft_refs */);
+ _gc_succeeded = g1h->do_full_collection(true /* explicit_gc */, false /* clear_all_soft_refs */);
}
VM_G1CollectForAllocation::VM_G1CollectForAllocation(size_t word_size,
@@ -45,7 +45,7 @@
bool should_initiate_conc_mark,
double target_pause_time_ms) :
VM_CollectForAllocation(word_size, gc_count_before, gc_cause),
- _pause_succeeded(false),
+ _gc_succeeded(false),
_should_initiate_conc_mark(should_initiate_conc_mark),
_should_retry_gc(false),
_target_pause_time_ms(target_pause_time_ms),
@@ -85,7 +85,7 @@
if (_result != NULL) {
// If we can successfully allocate before we actually do the
// pause then we will consider this pause successful.
- _pause_succeeded = true;
+ _gc_succeeded = true;
return;
}
}
@@ -100,7 +100,7 @@
// At this point we are supposed to start a concurrent cycle. We
// will do so if one is not already in progress.
- bool res = g1h->g1_policy()->force_initial_mark_if_outside_cycle(_gc_cause);
+ bool res = g1h->policy()->force_initial_mark_if_outside_cycle(_gc_cause);
// The above routine returns true if we were able to force the
// next GC pause to be an initial mark; it returns false if a
@@ -130,13 +130,13 @@
}
// Try a partial collection of some kind.
- _pause_succeeded = g1h->do_collection_pause_at_safepoint(_target_pause_time_ms);
+ _gc_succeeded = g1h->do_collection_pause_at_safepoint(_target_pause_time_ms);
- if (_pause_succeeded) {
+ if (_gc_succeeded) {
if (_word_size > 0) {
// An allocation had been requested. Do it, eventually trying a stronger
// kind of GC.
- _result = g1h->satisfy_failed_allocation(_word_size, &_pause_succeeded);
+ _result = g1h->satisfy_failed_allocation(_word_size, &_gc_succeeded);
} else {
bool should_upgrade_to_full = g1h->should_upgrade_to_full_gc(_gc_cause);
@@ -145,11 +145,11 @@
// information on how much memory has been asked for. In case there are
// absolutely no regions left to allocate into, do a maximally compacting full GC.
log_info(gc, ergo)("Attempting maximally compacting collection");
- _pause_succeeded = g1h->do_full_collection(false, /* explicit gc */
+ _gc_succeeded = g1h->do_full_collection(false, /* explicit gc */
true /* clear_all_soft_refs */);
}
}
- guarantee(_pause_succeeded, "Elevated collections during the safepoint must always succeed.");
+ guarantee(_gc_succeeded, "Elevated collections during the safepoint must always succeed.");
} else {
assert(_result == NULL, "invariant");
// The only reason for the pause to not be successful is that, the GC locker is
--- a/src/hotspot/share/gc/g1/g1VMOperations.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1VMOperations.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -35,22 +35,26 @@
// - VM_G1CollectFull
class VM_G1CollectFull : public VM_GC_Operation {
+ bool _gc_succeeded;
+
public:
VM_G1CollectFull(uint gc_count_before,
uint full_gc_count_before,
GCCause::Cause cause) :
- VM_GC_Operation(gc_count_before, cause, full_gc_count_before, true) { }
+ VM_GC_Operation(gc_count_before, cause, full_gc_count_before, true),
+ _gc_succeeded(false) { }
virtual VMOp_Type type() const { return VMOp_G1CollectFull; }
virtual void doit();
+ bool gc_succeeded() { return _gc_succeeded; }
};
class VM_G1CollectForAllocation : public VM_CollectForAllocation {
- bool _pause_succeeded;
+ bool _gc_succeeded;
- bool _should_initiate_conc_mark;
- bool _should_retry_gc;
- double _target_pause_time_ms;
- uint _old_marking_cycles_completed_before;
+ bool _should_initiate_conc_mark;
+ bool _should_retry_gc;
+ double _target_pause_time_ms;
+ uint _old_marking_cycles_completed_before;
public:
VM_G1CollectForAllocation(size_t word_size,
@@ -63,7 +67,7 @@
virtual void doit();
virtual void doit_epilogue();
bool should_retry_gc() const { return _should_retry_gc; }
- bool pause_succeeded() { return _pause_succeeded; }
+ bool gc_succeeded() { return _gc_succeeded; }
};
// Concurrent G1 stop-the-world operations such as remark and cleanup.
--- a/src/hotspot/share/gc/g1/g1YoungGenSizer.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1YoungGenSizer.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -131,7 +131,7 @@
}
G1YoungGenSizer* G1YoungGenSizer::create_gen_sizer(G1CollectorPolicy* policy) {
- if (policy->is_hetero_heap()) {
+ if (policy->is_heterogeneous_heap()) {
return new G1HeterogeneousHeapYoungGenSizer();
} else {
return new G1YoungGenSizer();
--- a/src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -89,7 +89,10 @@
if ((os::elapsedTime() - _last_periodic_gc_attempt_s) > (G1PeriodicGCInterval / 1000.0)) {
log_debug(gc, periodic)("Checking for periodic GC.");
if (should_start_periodic_gc()) {
- Universe::heap()->collect(GCCause::_g1_periodic_collection);
+ if (!G1CollectedHeap::heap()->try_collect(GCCause::_g1_periodic_collection,
+ false /* retry_on_vmop_failure */)) {
+ log_debug(gc, periodic)("GC request denied. Skipping.");
+ }
}
_last_periodic_gc_attempt_s = os::elapsedTime();
}
@@ -160,16 +163,16 @@
void G1YoungRemSetSamplingThread::sample_young_list_rs_lengths() {
SuspendibleThreadSetJoiner sts;
G1CollectedHeap* g1h = G1CollectedHeap::heap();
- G1Policy* g1p = g1h->g1_policy();
+ G1Policy* policy = g1h->policy();
- if (g1p->adaptive_young_list_length()) {
+ if (policy->adaptive_young_list_length()) {
G1YoungRemSetSamplingClosure cl(&sts);
G1CollectionSet* g1cs = g1h->collection_set();
g1cs->iterate(&cl);
if (cl.is_complete()) {
- g1p->revise_young_list_target_length_if_necessary(cl.sampled_rs_lengths());
+ policy->revise_young_list_target_length_if_necessary(cl.sampled_rs_lengths());
}
}
}
--- a/src/hotspot/share/gc/g1/heapRegion.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/heapRegion.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -144,13 +144,13 @@
// GC efficiency is the ratio of how much space would be
// reclaimed over how long we predict it would take to reclaim it.
G1CollectedHeap* g1h = G1CollectedHeap::heap();
- G1Policy* g1p = g1h->g1_policy();
+ G1Policy* policy = g1h->policy();
// Retrieve a prediction of the elapsed time for this region for
// a mixed gc because the region will only be evacuated during a
// mixed gc.
double region_elapsed_time_ms =
- g1p->predict_region_elapsed_time_ms(this, false /* for_young_gc */);
+ policy->predict_region_elapsed_time_ms(this, false /* for_young_gc */);
_gc_efficiency = (double) reclaimable_bytes() / region_elapsed_time_ms;
}
--- a/src/hotspot/share/gc/g1/heapRegionManager.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/g1/heapRegionManager.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -69,7 +69,7 @@
{ }
HeapRegionManager* HeapRegionManager::create_manager(G1CollectedHeap* heap, G1CollectorPolicy* policy) {
- if (policy->is_hetero_heap()) {
+ if (policy->is_heterogeneous_heap()) {
return new HeterogeneousHeapRegionManager((uint)(policy->max_heap_byte_size() / HeapRegion::GrainBytes) /*heap size as num of regions*/);
}
return new HeapRegionManager();
--- a/src/hotspot/share/gc/shared/barrierSet.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shared/barrierSet.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -130,8 +130,8 @@
virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) {}
virtual void on_thread_create(Thread* thread) {}
virtual void on_thread_destroy(Thread* thread) {}
- virtual void on_thread_attach(JavaThread* thread) {}
- virtual void on_thread_detach(JavaThread* thread) {}
+ virtual void on_thread_attach(Thread* thread) {}
+ virtual void on_thread_detach(Thread* thread) {}
virtual void make_parsable(JavaThread* thread) {}
#ifdef CHECK_UNHANDLED_OOPS
--- a/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -194,11 +194,13 @@
#endif
}
-void CardTableBarrierSet::on_thread_detach(JavaThread* thread) {
+void CardTableBarrierSet::on_thread_detach(Thread* thread) {
// The deferred store barriers must all have been flushed to the
// card-table (or other remembered set structure) before GC starts
// processing the card-table (or other remembered set).
- flush_deferred_card_mark_barrier(thread);
+ if (thread->is_Java_thread()) { // Only relevant for Java threads.
+ flush_deferred_card_mark_barrier((JavaThread*)thread);
+ }
}
bool CardTableBarrierSet::card_mark_must_follow_store() const {
--- a/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -102,7 +102,7 @@
virtual bool card_mark_must_follow_store() const;
virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj);
- virtual void on_thread_detach(JavaThread* thread);
+ virtual void on_thread_detach(Thread* thread);
virtual void make_parsable(JavaThread* thread) { flush_deferred_card_mark_barrier(thread); }
--- a/src/hotspot/share/gc/shared/gcVMOperations.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shared/gcVMOperations.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -201,16 +201,16 @@
#if INCLUDE_G1GC
if (UseG1GC && ClassUnloadingWithConcurrentMark) {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
- g1h->g1_policy()->collector_state()->set_initiate_conc_mark_if_possible(true);
+ g1h->policy()->collector_state()->set_initiate_conc_mark_if_possible(true);
GCCauseSetter x(g1h, _gc_cause);
// At this point we are supposed to start a concurrent cycle. We
// will do so if one is not already in progress.
- bool should_start = g1h->g1_policy()->force_initial_mark_if_outside_cycle(_gc_cause);
+ bool should_start = g1h->policy()->force_initial_mark_if_outside_cycle(_gc_cause);
if (should_start) {
- double pause_target = g1h->g1_policy()->max_pause_time_ms();
+ double pause_target = g1h->policy()->max_pause_time_ms();
g1h->do_collection_pause_at_safepoint(pause_target);
}
return true;
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -557,8 +557,6 @@
return; // GC is disabled (e.g. JNI GetXXXCritical operation)
}
- GCIdMark gc_id_mark;
-
const bool do_clear_all_soft_refs = clear_all_soft_refs ||
soft_ref_policy()->should_clear_all_soft_refs();
@@ -566,103 +564,114 @@
const size_t metadata_prev_used = MetaspaceUtils::used_bytes();
- print_heap_before_gc();
+
+ FlagSetting fl(_is_gc_active, true);
- {
- FlagSetting fl(_is_gc_active, true);
+ bool complete = full && (max_generation == OldGen);
+ bool old_collects_young = complete && !ScavengeBeforeFullGC;
+ bool do_young_collection = !old_collects_young && _young_gen->should_collect(full, size, is_tlab);
- bool complete = full && (max_generation == OldGen);
- bool old_collects_young = complete && !ScavengeBeforeFullGC;
- bool do_young_collection = !old_collects_young && _young_gen->should_collect(full, size, is_tlab);
+ size_t young_prev_used = _young_gen->used();
+ size_t old_prev_used = _old_gen->used();
- FormatBuffer<> gc_string("%s", "Pause ");
- if (do_young_collection) {
- gc_string.append("Young");
- } else {
- gc_string.append("Full");
+ bool run_verification = total_collections() >= VerifyGCStartAt;
+ bool prepared_for_verification = false;
+ bool do_full_collection = false;
+
+ if (do_young_collection) {
+ GCIdMark gc_id_mark;
+ GCTraceCPUTime tcpu;
+ GCTraceTime(Info, gc) t("Pause Young", NULL, gc_cause(), true);
+
+ print_heap_before_gc();
+
+ if (run_verification && VerifyGCLevel <= 0 && VerifyBeforeGC) {
+ prepare_for_verify();
+ prepared_for_verification = true;
}
- GCTraceCPUTime tcpu;
- GCTraceTime(Info, gc) t(gc_string, NULL, gc_cause(), true);
-
gc_prologue(complete);
increment_total_collections(complete);
- size_t young_prev_used = _young_gen->used();
- size_t old_prev_used = _old_gen->used();
-
- bool run_verification = total_collections() >= VerifyGCStartAt;
+ collect_generation(_young_gen,
+ full,
+ size,
+ is_tlab,
+ run_verification && VerifyGCLevel <= 0,
+ do_clear_all_soft_refs,
+ false);
- bool prepared_for_verification = false;
- bool collected_old = false;
-
- if (do_young_collection) {
- if (run_verification && VerifyGCLevel <= 0 && VerifyBeforeGC) {
- prepare_for_verify();
- prepared_for_verification = true;
- }
+ if (size > 0 && (!is_tlab || _young_gen->supports_tlab_allocation()) &&
+ size * HeapWordSize <= _young_gen->unsafe_max_alloc_nogc()) {
+ // Allocation request was met by young GC.
+ size = 0;
+ }
- collect_generation(_young_gen,
- full,
- size,
- is_tlab,
- run_verification && VerifyGCLevel <= 0,
- do_clear_all_soft_refs,
- false);
+ // Ask if young collection is enough. If so, do the final steps for young collection,
+ // and fallthrough to the end.
+ do_full_collection = should_do_full_collection(size, full, is_tlab, max_generation);
+ if (!do_full_collection) {
+ // Adjust generation sizes.
+ _young_gen->compute_new_size();
- if (size > 0 && (!is_tlab || _young_gen->supports_tlab_allocation()) &&
- size * HeapWordSize <= _young_gen->unsafe_max_alloc_nogc()) {
- // Allocation request was met by young GC.
- size = 0;
- }
+ print_heap_change(young_prev_used, old_prev_used);
+ MetaspaceUtils::print_metaspace_change(metadata_prev_used);
+
+ // Track memory usage and detect low memory after GC finishes
+ MemoryService::track_memory_usage();
+
+ gc_epilogue(complete);
}
- bool must_restore_marks_for_biased_locking = false;
+ print_heap_after_gc();
- if (max_generation == OldGen && _old_gen->should_collect(full, size, is_tlab)) {
- if (!complete) {
- // The full_collections increment was missed above.
- increment_total_full_collections();
- }
-
- if (!prepared_for_verification && run_verification &&
- VerifyGCLevel <= 1 && VerifyBeforeGC) {
- prepare_for_verify();
- }
+ } else {
+ // No young collection, ask if we need to perform Full collection.
+ do_full_collection = should_do_full_collection(size, full, is_tlab, max_generation);
+ }
- if (do_young_collection) {
- // We did a young GC. Need a new GC id for the old GC.
- GCIdMark gc_id_mark;
- GCTraceTime(Info, gc) t("Pause Full", NULL, gc_cause(), true);
- collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true);
- } else {
- // No young GC done. Use the same GC id as was set up earlier in this method.
- collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true);
- }
+ if (do_full_collection) {
+ GCIdMark gc_id_mark;
+ GCTraceCPUTime tcpu;
+ GCTraceTime(Info, gc) t("Pause Full", NULL, gc_cause(), true);
+
+ print_heap_before_gc();
- must_restore_marks_for_biased_locking = true;
- collected_old = true;
+ if (!prepared_for_verification && run_verification &&
+ VerifyGCLevel <= 1 && VerifyBeforeGC) {
+ prepare_for_verify();
+ }
+
+ if (!do_young_collection) {
+ gc_prologue(complete);
+ increment_total_collections(complete);
}
- // Update "complete" boolean wrt what actually transpired --
- // for instance, a promotion failure could have led to
- // a whole heap collection.
- complete = complete || collected_old;
+ // Accounting quirk: total full collections would be incremented when "complete"
+ // is set, by calling increment_total_collections above. However, we also need to
+ // account Full collections that had "complete" unset.
+ if (!complete) {
+ increment_total_full_collections();
+ }
+
+ collect_generation(_old_gen,
+ full,
+ size,
+ is_tlab,
+ run_verification && VerifyGCLevel <= 1,
+ do_clear_all_soft_refs,
+ true);
// Adjust generation sizes.
- if (collected_old) {
- _old_gen->compute_new_size();
- }
+ _old_gen->compute_new_size();
_young_gen->compute_new_size();
- if (complete) {
- // Delete metaspaces for unloaded class loaders and clean up loader_data graph
- ClassLoaderDataGraph::purge();
- MetaspaceUtils::verify_metrics();
- // Resize the metaspace capacity after full collections
- MetaspaceGC::compute_new_size();
- update_full_collections_completed();
- }
+ // Delete metaspaces for unloaded class loaders and clean up loader_data graph
+ ClassLoaderDataGraph::purge();
+ MetaspaceUtils::verify_metrics();
+ // Resize the metaspace capacity after full collections
+ MetaspaceGC::compute_new_size();
+ update_full_collections_completed();
print_heap_change(young_prev_used, old_prev_used);
MetaspaceUtils::print_metaspace_change(metadata_prev_used);
@@ -670,20 +679,25 @@
// Track memory usage and detect low memory after GC finishes
MemoryService::track_memory_usage();
- gc_epilogue(complete);
+ // Need to tell the epilogue code we are done with Full GC, regardless what was
+ // the initial value for "complete" flag.
+ gc_epilogue(true);
- if (must_restore_marks_for_biased_locking) {
- BiasedLocking::restore_marks();
- }
+ BiasedLocking::restore_marks();
+
+ print_heap_after_gc();
}
- print_heap_after_gc();
-
#ifdef TRACESPINNING
ParallelTaskTerminator::print_termination_counts();
#endif
}
+bool GenCollectedHeap::should_do_full_collection(size_t size, bool full, bool is_tlab,
+ GenCollectedHeap::GenerationType max_gen) const {
+ return max_gen == OldGen && _old_gen->should_collect(full, size, is_tlab);
+}
+
void GenCollectedHeap::register_nmethod(nmethod* nm) {
CodeCache::register_scavenge_root_nmethod(nm);
}
--- a/src/hotspot/share/gc/shared/genCollectedHeap.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -497,6 +497,10 @@
// Save the tops of the spaces in all generations
void record_gen_tops_before_GC() PRODUCT_RETURN;
+
+ // Return true if we need to perform full collection.
+ bool should_do_full_collection(size_t size, bool full,
+ bool is_tlab, GenerationType max_gen) const;
};
#endif // SHARE_GC_SHARED_GENCOLLECTEDHEAP_HPP
--- a/src/hotspot/share/gc/shared/satbMarkQueue.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shared/satbMarkQueue.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
// created during a cycle and its SATB queue needs to be activated
// before the thread starts running, we'll need to set its active
// field to true. This must be done in the collector-specific
- // BarrierSet::on_thread_attach() implementation.
+ // BarrierSet thread attachment protocol.
PtrQueue(qset, permanent, false /* active */)
{ }
@@ -57,9 +57,6 @@
// use the buffer as-is, instead of enqueueing and replacing it.
bool SATBMarkQueue::should_enqueue_buffer() {
- assert(_lock == NULL || _lock->owned_by_self(),
- "we should have taken the lock before calling this");
-
// This method should only be called if there is a non-NULL buffer
// that is full.
assert(index() == 0, "pre-condition");
@@ -107,18 +104,15 @@
SATBMarkQueueSet::SATBMarkQueueSet() :
PtrQueueSet(),
- _shared_satb_queue(this, true /* permanent */),
_buffer_enqueue_threshold(0)
{}
void SATBMarkQueueSet::initialize(Monitor* cbl_mon,
BufferNode::Allocator* allocator,
size_t process_completed_buffers_threshold,
- uint buffer_enqueue_threshold_percentage,
- Mutex* lock) {
+ uint buffer_enqueue_threshold_percentage) {
PtrQueueSet::initialize(cbl_mon, allocator);
set_process_completed_buffers_threshold(process_completed_buffers_threshold);
- _shared_satb_queue.set_lock(lock);
assert(buffer_size() != 0, "buffer size not initialized");
// Minimum threshold of 1 ensures enqueuing of completely full buffers.
size_t size = buffer_size();
@@ -131,32 +125,43 @@
log_error(gc, verify)("Expected SATB active state: %s", expected_active ? "ACTIVE" : "INACTIVE");
log_error(gc, verify)("Actual SATB active states:");
log_error(gc, verify)(" Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
- for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
- log_error(gc, verify)(" Thread \"%s\" queue: %s", t->name(), satb_queue_for_thread(t).is_active() ? "ACTIVE" : "INACTIVE");
- }
- log_error(gc, verify)(" Shared queue: %s", shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
+
+ class DumpThreadStateClosure : public ThreadClosure {
+ SATBMarkQueueSet* _qset;
+ public:
+ DumpThreadStateClosure(SATBMarkQueueSet* qset) : _qset(qset) {}
+ virtual void do_thread(Thread* t) {
+ SATBMarkQueue& queue = _qset->satb_queue_for_thread(t);
+ log_error(gc, verify)(" Thread \"%s\" queue: %s",
+ t->name(),
+ queue.is_active() ? "ACTIVE" : "INACTIVE");
+ }
+ } closure(this);
+ Threads::threads_do(&closure);
}
void SATBMarkQueueSet::verify_active_states(bool expected_active) {
// Verify queue set state
if (is_active() != expected_active) {
dump_active_states(expected_active);
- guarantee(false, "SATB queue set has an unexpected active state");
+ fatal("SATB queue set has an unexpected active state");
}
// Verify thread queue states
- for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
- if (satb_queue_for_thread(t).is_active() != expected_active) {
- dump_active_states(expected_active);
- guarantee(false, "Thread SATB queue has an unexpected active state");
+ class VerifyThreadStatesClosure : public ThreadClosure {
+ SATBMarkQueueSet* _qset;
+ bool _expected_active;
+ public:
+ VerifyThreadStatesClosure(SATBMarkQueueSet* qset, bool expected_active) :
+ _qset(qset), _expected_active(expected_active) {}
+ virtual void do_thread(Thread* t) {
+ if (_qset->satb_queue_for_thread(t).is_active() != _expected_active) {
+ _qset->dump_active_states(_expected_active);
+ fatal("Thread SATB queue has an unexpected active state");
+ }
}
- }
-
- // Verify shared queue state
- if (shared_satb_queue()->is_active() != expected_active) {
- dump_active_states(expected_active);
- guarantee(false, "Shared SATB queue has an unexpected active state");
- }
+ } closure(this, expected_active);
+ Threads::threads_do(&closure);
}
#endif // ASSERT
@@ -166,17 +171,30 @@
verify_active_states(expected_active);
#endif // ASSERT
_all_active = active;
- for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
- satb_queue_for_thread(t).set_active(active);
- }
- shared_satb_queue()->set_active(active);
+
+ class SetThreadActiveClosure : public ThreadClosure {
+ SATBMarkQueueSet* _qset;
+ bool _active;
+ public:
+ SetThreadActiveClosure(SATBMarkQueueSet* qset, bool active) :
+ _qset(qset), _active(active) {}
+ virtual void do_thread(Thread* t) {
+ _qset->satb_queue_for_thread(t).set_active(_active);
+ }
+ } closure(this, active);
+ Threads::threads_do(&closure);
}
void SATBMarkQueueSet::filter_thread_buffers() {
- for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
- satb_queue_for_thread(t).filter();
- }
- shared_satb_queue()->filter();
+ class FilterThreadBufferClosure : public ThreadClosure {
+ SATBMarkQueueSet* _qset;
+ public:
+ FilterThreadBufferClosure(SATBMarkQueueSet* qset) : _qset(qset) {}
+ virtual void do_thread(Thread* t) {
+ _qset->satb_queue_for_thread(t).filter();
+ }
+ } closure(this);
+ Threads::threads_do(&closure);
}
bool SATBMarkQueueSet::apply_closure_to_completed_buffer(SATBBufferClosure* cl) {
@@ -216,23 +234,36 @@
i += 1;
}
- for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
- os::snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Thread: %s", t->name());
- satb_queue_for_thread(t).print(buffer);
- }
+ class PrintThreadClosure : public ThreadClosure {
+ SATBMarkQueueSet* _qset;
+ char* _buffer;
- shared_satb_queue()->print("Shared");
+ public:
+ PrintThreadClosure(SATBMarkQueueSet* qset, char* buffer) :
+ _qset(qset), _buffer(buffer) {}
+
+ virtual void do_thread(Thread* t) {
+ os::snprintf(_buffer, SATB_PRINTER_BUFFER_SIZE, "Thread: %s", t->name());
+ _qset->satb_queue_for_thread(t).print(_buffer);
+ }
+ } closure(this, buffer);
+ Threads::threads_do(&closure);
tty->cr();
}
#endif // PRODUCT
void SATBMarkQueueSet::abandon_partial_marking() {
+ assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
abandon_completed_buffers();
- assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
- // So we can safely manipulate these queues.
- for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
- satb_queue_for_thread(t).reset();
- }
- shared_satb_queue()->reset();
+
+ class AbandonThreadQueueClosure : public ThreadClosure {
+ SATBMarkQueueSet* _qset;
+ public:
+ AbandonThreadQueueClosure(SATBMarkQueueSet* qset) : _qset(qset) {}
+ virtual void do_thread(Thread* t) {
+ _qset->satb_queue_for_thread(t).reset();
+ }
+ } closure(this);
+ Threads::threads_do(&closure);
}
--- a/src/hotspot/share/gc/shared/satbMarkQueue.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shared/satbMarkQueue.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -28,7 +28,7 @@
#include "gc/shared/ptrQueue.hpp"
#include "memory/allocation.hpp"
-class JavaThread;
+class Thread;
class Monitor;
class SATBMarkQueueSet;
@@ -92,7 +92,6 @@
};
class SATBMarkQueueSet: public PtrQueueSet {
- SATBMarkQueue _shared_satb_queue;
size_t _buffer_enqueue_threshold;
#ifdef ASSERT
@@ -112,11 +111,10 @@
void initialize(Monitor* cbl_mon,
BufferNode::Allocator* allocator,
size_t process_completed_buffers_threshold,
- uint buffer_enqueue_threshold_percentage,
- Mutex* lock);
+ uint buffer_enqueue_threshold_percentage);
public:
- virtual SATBMarkQueue& satb_queue_for_thread(JavaThread* const t) const = 0;
+ virtual SATBMarkQueue& satb_queue_for_thread(Thread* const t) const = 0;
// Apply "set_active(active)" to all SATB queues in the set. It should be
// called only with the world stopped. The method will assert that the
@@ -141,8 +139,6 @@
void print_all(const char* msg);
#endif // PRODUCT
- SATBMarkQueue* shared_satb_queue() { return &_shared_satb_queue; }
-
// If a marking is being abandoned, reset any unprocessed log buffers.
void abandon_partial_marking();
};
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved.
*
* 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
@@ -337,13 +337,7 @@
// filtering here helps to avoid wasteful SATB queueing work to begin with.
if (!_heap->requires_marking<false>(obj)) return;
- Thread* thr = Thread::current();
- if (thr->is_Java_thread()) {
- ShenandoahThreadLocalData::satb_mark_queue(thr).enqueue(obj);
- } else {
- MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag);
- _satb_mark_queue_set.shared_satb_queue()->enqueue(obj);
- }
+ ShenandoahThreadLocalData::satb_mark_queue(Thread::current()).enqueue(obj);
}
void ShenandoahBarrierSet::on_thread_create(Thread* thread) {
@@ -356,21 +350,26 @@
ShenandoahThreadLocalData::destroy(thread);
}
-void ShenandoahBarrierSet::on_thread_attach(JavaThread* thread) {
- assert(!SafepointSynchronize::is_at_safepoint(), "We should not be at a safepoint");
- assert(!ShenandoahThreadLocalData::satb_mark_queue(thread).is_active(), "SATB queue should not be active");
- assert(ShenandoahThreadLocalData::satb_mark_queue(thread).is_empty(), "SATB queue should be empty");
- if (ShenandoahBarrierSet::satb_mark_queue_set().is_active()) {
- ShenandoahThreadLocalData::satb_mark_queue(thread).set_active(true);
+void ShenandoahBarrierSet::on_thread_attach(Thread *thread) {
+ assert(!thread->is_Java_thread() || !SafepointSynchronize::is_at_safepoint(),
+ "We should not be at a safepoint");
+ SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread);
+ assert(!queue.is_active(), "SATB queue should not be active");
+ assert( queue.is_empty(), "SATB queue should be empty");
+ queue.set_active(_satb_mark_queue_set.is_active());
+ if (thread->is_Java_thread()) {
+ ShenandoahThreadLocalData::set_gc_state(thread, _heap->gc_state());
+ ShenandoahThreadLocalData::initialize_gclab(thread);
}
- ShenandoahThreadLocalData::set_gc_state(thread, _heap->gc_state());
- ShenandoahThreadLocalData::initialize_gclab(thread);
}
-void ShenandoahBarrierSet::on_thread_detach(JavaThread* thread) {
- ShenandoahThreadLocalData::satb_mark_queue(thread).flush();
- PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
- if (gclab != NULL) {
- gclab->retire();
+void ShenandoahBarrierSet::on_thread_detach(Thread *thread) {
+ SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread);
+ queue.flush();
+ if (thread->is_Java_thread()) {
+ PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
+ if (gclab != NULL) {
+ gclab->retire();
+ }
}
}
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved.
*
* 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
@@ -84,8 +84,8 @@
virtual void on_thread_create(Thread* thread);
virtual void on_thread_destroy(Thread* thread);
- virtual void on_thread_attach(JavaThread* thread);
- virtual void on_thread_detach(JavaThread* thread);
+ virtual void on_thread_attach(Thread* thread);
+ virtual void on_thread_detach(Thread* thread);
virtual oop read_barrier(oop src);
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -227,15 +227,8 @@
_thread_parity(Threads::thread_claim_parity()) {}
void do_thread(Thread* thread) {
- if (thread->is_Java_thread()) {
- if (thread->claim_oops_do(true, _thread_parity)) {
- JavaThread* jt = (JavaThread*)thread;
- ShenandoahThreadLocalData::satb_mark_queue(jt).apply_closure_and_empty(_satb_cl);
- }
- } else if (thread->is_VM_thread()) {
- if (thread->claim_oops_do(true, _thread_parity)) {
- ShenandoahBarrierSet::satb_mark_queue_set().shared_satb_queue()->apply_closure_and_empty(_satb_cl);
- }
+ if (thread->claim_oops_do(true, _thread_parity)) {
+ ShenandoahThreadLocalData::satb_mark_queue(thread).apply_closure_and_empty(_satb_cl);
}
}
};
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -180,9 +180,8 @@
// belong into a shared location.
ShenandoahBarrierSet::satb_mark_queue_set().initialize(this,
SATB_Q_CBL_mon,
- 20 /*G1SATBProcessCompletedThreshold */,
- 60 /* G1SATBBufferEnqueueingThresholdPercent */,
- Shared_SATB_Q_lock);
+ 20 /* G1SATBProcessCompletedThreshold */,
+ 60 /* G1SATBBufferEnqueueingThresholdPercent */);
// Reserve space for prev and next bitmap.
size_t bitmap_page_size = UseLargePages ? (size_t)os::large_page_size() : (size_t)os::vm_page_size();
@@ -479,12 +478,12 @@
}
}
-class ShenandoahInitGCLABClosure : public ThreadClosure {
+class ShenandoahInitWorkerGCLABClosure : public ThreadClosure {
public:
void do_thread(Thread* thread) {
- if (thread != NULL && (thread->is_Java_thread() || thread->is_Worker_thread())) {
- ShenandoahThreadLocalData::initialize_gclab(thread);
- }
+ assert(thread != NULL, "Sanity");
+ assert(thread->is_Worker_thread(), "Only worker thread expected");
+ ShenandoahThreadLocalData::initialize_gclab(thread);
}
};
@@ -492,10 +491,8 @@
CollectedHeap::post_initialize();
MutexLocker ml(Threads_lock);
- ShenandoahInitGCLABClosure init_gclabs;
- Threads::threads_do(&init_gclabs);
+ ShenandoahInitWorkerGCLABClosure init_gclabs;
_workers->threads_do(&init_gclabs);
- _safepoint_workers->threads_do(&init_gclabs);
// gclab can not be initialized early during VM startup, as it can not determinate its max_size.
// Now, we will let WorkGang to initialize gclab when new worker is created.
@@ -1027,7 +1024,6 @@
cl.do_thread(t);
}
workers()->threads_do(&cl);
- _safepoint_workers->threads_do(&cl);
}
void ShenandoahHeap::resize_tlabs() {
@@ -1113,7 +1109,6 @@
cl.do_thread(t);
}
workers()->threads_do(&cl);
- _safepoint_workers->threads_do(&cl);
}
void ShenandoahHeap::collect(GCCause::Cause cause) {
--- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -299,4 +299,9 @@
}
out->print_cr("%23s: " SIZE_FORMAT_W(12) SIZE_FORMAT_W(12) " ms", "Total", total_count, total_sum);
out->cr();
+ out->print_cr("Pacing delays are measured from entering the pacing code till exiting it. Therefore,");
+ out->print_cr("observed pacing delays may be higher than the threshold when paced thread spent more");
+ out->print_cr("time in the pacing code. It usually happens when thread is de-scheduled while paced,");
+ out->print_cr("OS takes longer to unblock the thread, or JVM experiences an STW pause.");
+ out->cr();
}
--- a/src/hotspot/share/gc/shenandoah/shenandoahSATBMarkQueueSet.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahSATBMarkQueueSet.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -35,17 +35,15 @@
void ShenandoahSATBMarkQueueSet::initialize(ShenandoahHeap* const heap,
Monitor* cbl_mon,
int process_completed_threshold,
- uint buffer_enqueue_threshold_percentage,
- Mutex* lock) {
+ uint buffer_enqueue_threshold_percentage) {
SATBMarkQueueSet::initialize(cbl_mon,
&_satb_mark_queue_buffer_allocator,
process_completed_threshold,
- buffer_enqueue_threshold_percentage,
- lock);
+ buffer_enqueue_threshold_percentage);
_heap = heap;
}
-SATBMarkQueue& ShenandoahSATBMarkQueueSet::satb_queue_for_thread(JavaThread* const t) const {
+SATBMarkQueue& ShenandoahSATBMarkQueueSet::satb_queue_for_thread(Thread* const t) const {
return ShenandoahThreadLocalData::satb_mark_queue(t);
}
--- a/src/hotspot/share/gc/shenandoah/shenandoahSATBMarkQueueSet.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahSATBMarkQueueSet.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
*
* 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
@@ -45,10 +45,9 @@
void initialize(ShenandoahHeap* const heap,
Monitor* cbl_mon,
int process_completed_threshold,
- uint buffer_enqueue_threshold_percentage,
- Mutex* lock);
+ uint buffer_enqueue_threshold_percentage);
- virtual SATBMarkQueue& satb_queue_for_thread(JavaThread* const t) const;
+ virtual SATBMarkQueue& satb_queue_for_thread(Thread* const t) const;
virtual void filter(SATBMarkQueue* queue);
};
--- a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
*
* 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
@@ -122,6 +122,7 @@
static void initialize_gclab(Thread* thread) {
assert (thread->is_Java_thread() || thread->is_Worker_thread(), "Only Java and GC worker threads are allowed to get GCLABs");
+ assert(data(thread)->_gclab == NULL, "Only initialize once");
data(thread)->_gclab = new PLAB(PLAB::min_size());
data(thread)->_gclab_size = 0;
}
--- a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -127,12 +127,7 @@
_satb_cl(satb_cl) {}
void do_thread(Thread* thread) {
- if (thread->is_Java_thread()) {
- JavaThread* jt = (JavaThread*)thread;
- ShenandoahThreadLocalData::satb_mark_queue(jt).apply_closure_and_empty(_satb_cl);
- } else if (thread->is_VM_thread()) {
- ShenandoahBarrierSet::satb_mark_queue_set().shared_satb_queue()->apply_closure_and_empty(_satb_cl);
- }
+ ShenandoahThreadLocalData::satb_mark_queue(thread).apply_closure_and_empty(_satb_cl);
}
};
--- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2017, 2019, Red Hat, Inc. All rights reserved.
*
* 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
@@ -44,13 +44,14 @@
assert(!ShenandoahGCPhase::is_valid_phase(ShenandoahGCPhase::current_phase()),
"No current GC phase");
+ _heap->set_gc_cause(cause);
_timer->register_gc_start();
_tracer->report_gc_start(cause, _timer->gc_start());
_heap->trace_heap(GCWhen::BeforeGC, _tracer);
_heap->shenandoah_policy()->record_cycle_start();
_heap->heuristics()->record_cycle_start();
- _trace_cycle.initialize(_heap->cycle_memory_manager(), _heap->gc_cause(),
+ _trace_cycle.initialize(_heap->cycle_memory_manager(), cause,
/* allMemoryPoolsAffected */ true,
/* recordGCBeginTime = */ true,
/* recordPreGCUsage = */ true,
@@ -69,6 +70,7 @@
_tracer->report_gc_end(_timer->gc_end(), _timer->time_partitions());
assert(!ShenandoahGCPhase::is_valid_phase(ShenandoahGCPhase::current_phase()),
"No current GC phase");
+ _heap->set_gc_cause(GCCause::_no_gc);
}
ShenandoahGCPauseMark::ShenandoahGCPauseMark(uint gc_id, SvcGCMarker::reason_type type) :
--- a/src/hotspot/share/gc/z/zBarrierSet.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/z/zBarrierSet.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -86,12 +86,12 @@
ZThreadLocalData::destroy(thread);
}
-void ZBarrierSet::on_thread_attach(JavaThread* thread) {
+void ZBarrierSet::on_thread_attach(Thread* thread) {
// Set thread local address bad mask
ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask);
}
-void ZBarrierSet::on_thread_detach(JavaThread* thread) {
+void ZBarrierSet::on_thread_detach(Thread* thread) {
// Flush and free any remaining mark stacks
ZHeap::heap()->mark_flush_and_free(thread);
}
--- a/src/hotspot/share/gc/z/zBarrierSet.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/gc/z/zBarrierSet.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,8 +37,8 @@
virtual void on_thread_create(Thread* thread);
virtual void on_thread_destroy(Thread* thread);
- virtual void on_thread_attach(JavaThread* thread);
- virtual void on_thread_detach(JavaThread* thread);
+ virtual void on_thread_attach(Thread* thread);
+ virtual void on_thread_detach(Thread* thread);
virtual void print_on(outputStream* st) const {}
--- a/src/hotspot/share/interpreter/interpreterRuntime.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -920,19 +920,23 @@
info.call_kind() == CallInfo::vtable_call, "");
}
#endif
- // Get sender or sender's unsafe_anonymous_host, and only set cpCache entry to resolved if
- // it is not an interface. The receiver for invokespecial calls within interface
- // methods must be checked for every call.
- InstanceKlass* sender = pool->pool_holder();
- sender = sender->is_unsafe_anonymous() ? sender->unsafe_anonymous_host() : sender;
switch (info.call_kind()) {
- case CallInfo::direct_call:
+ case CallInfo::direct_call: {
+ // Get sender or sender's unsafe_anonymous_host, and only set cpCache entry to resolved if
+ // it is not an interface. The receiver for invokespecial calls within interface
+ // methods must be checked for every call.
+ InstanceKlass* pool_holder = pool->pool_holder();
+ InstanceKlass* sender = pool_holder->is_unsafe_anonymous() ?
+ pool_holder->unsafe_anonymous_host() : pool_holder;
+
cp_cache_entry->set_direct_call(
bytecode,
info.resolved_method(),
- sender->is_interface());
+ sender->is_interface(),
+ pool_holder);
break;
+ }
case CallInfo::vtable_call:
cp_cache_entry->set_vtable_call(
bytecode,
--- a/src/hotspot/share/memory/metaspace.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/memory/metaspace.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -440,7 +440,6 @@
if (chunk_manager == NULL) {
return 0;
}
- chunk_manager->slow_verify();
return chunk_manager->free_chunks_total_words();
}
@@ -793,6 +792,13 @@
out->print_cr("Number of times virtual space nodes were expanded: " UINTX_FORMAT ".", g_internal_statistics.num_committed_space_expanded);
out->print_cr("Number of deallocations: " UINTX_FORMAT " (" UINTX_FORMAT " external).", g_internal_statistics.num_deallocs, g_internal_statistics.num_external_deallocs);
out->print_cr("Allocations from deallocated blocks: " UINTX_FORMAT ".", g_internal_statistics.num_allocs_from_deallocated_blocks);
+ out->print_cr("Number of chunks added to freelist: " UINTX_FORMAT ".",
+ g_internal_statistics.num_chunks_added_to_freelist);
+ out->print_cr("Number of chunks removed from freelist: " UINTX_FORMAT ".",
+ g_internal_statistics.num_chunks_removed_from_freelist);
+ out->print_cr("Number of chunk merges: " UINTX_FORMAT ", split-ups: " UINTX_FORMAT ".",
+ g_internal_statistics.num_chunk_merges, g_internal_statistics.num_chunk_splits);
+
out->cr();
#endif
@@ -844,10 +850,12 @@
}
void MetaspaceUtils::verify_free_chunks() {
- Metaspace::chunk_manager_metadata()->verify();
+#ifdef ASSERT
+ Metaspace::chunk_manager_metadata()->verify(false);
if (Metaspace::using_class_space()) {
- Metaspace::chunk_manager_class()->verify();
+ Metaspace::chunk_manager_class()->verify(false);
}
+#endif
}
void MetaspaceUtils::verify_metrics() {
--- a/src/hotspot/share/memory/metaspace/chunkManager.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/memory/metaspace/chunkManager.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -29,6 +29,7 @@
#include "memory/freeList.inline.hpp"
#include "memory/metaspace/chunkManager.hpp"
#include "memory/metaspace/metachunk.hpp"
+#include "memory/metaspace/metaDebug.hpp"
#include "memory/metaspace/metaspaceCommon.hpp"
#include "memory/metaspace/metaspaceStatistics.hpp"
#include "memory/metaspace/occupancyMap.hpp"
@@ -140,15 +141,21 @@
_free_chunks_count -= num_chunks_removed;
_free_chunks_count ++;
- // VirtualSpaceNode::container_count does not have to be modified:
+ // VirtualSpaceNode::chunk_count does not have to be modified:
// it means "number of active (non-free) chunks", so merging free chunks
// should not affect that count.
// At the end of a chunk merge, run verification tests.
- if (VerifyMetaspace) {
- DEBUG_ONLY(this->locked_verify());
- DEBUG_ONLY(vsn->verify());
- }
+#ifdef ASSERT
+
+ EVERY_NTH(VerifyMetaspaceInterval)
+ locked_verify(true);
+ vsn->verify(true);
+ END_EVERY_NTH
+
+ g_internal_statistics.num_chunk_merges ++;
+
+#endif
return true;
}
@@ -189,14 +196,6 @@
return num_removed;
}
-size_t ChunkManager::free_chunks_total_words() {
- return _free_chunks_total;
-}
-
-size_t ChunkManager::free_chunks_total_bytes() {
- return free_chunks_total_words() * BytesPerWord;
-}
-
// Update internal accounting after a chunk was added
void ChunkManager::account_for_added_chunk(const Metachunk* c) {
assert_lock_strong(MetaspaceExpand_lock);
@@ -216,19 +215,6 @@
_free_chunks_total -= c->word_size();
}
-size_t ChunkManager::free_chunks_count() {
-#ifdef ASSERT
- if (!UseConcMarkSweepGC && !MetaspaceExpand_lock->is_locked()) {
- MutexLockerEx cl(MetaspaceExpand_lock,
- Mutex::_no_safepoint_check_flag);
- // This lock is only needed in debug because the verification
- // of the _free_chunks_totals walks the list of free chunks
- slow_locked_verify_free_chunks_count();
- }
-#endif
- return _free_chunks_count;
-}
-
ChunkIndex ChunkManager::list_index(size_t size) {
return get_chunk_type_by_size(size, is_class());
}
@@ -239,43 +225,48 @@
return get_size_for_nonhumongous_chunktype(index, is_class());
}
-void ChunkManager::locked_verify_free_chunks_total() {
- assert_lock_strong(MetaspaceExpand_lock);
- assert(sum_free_chunks() == _free_chunks_total,
- "_free_chunks_total " SIZE_FORMAT " is not the"
- " same as sum " SIZE_FORMAT, _free_chunks_total,
- sum_free_chunks());
+#ifdef ASSERT
+void ChunkManager::verify(bool slow) const {
+ MutexLockerEx cl(MetaspaceExpand_lock,
+ Mutex::_no_safepoint_check_flag);
+ locked_verify(slow);
}
-void ChunkManager::locked_verify_free_chunks_count() {
- assert_lock_strong(MetaspaceExpand_lock);
- assert(sum_free_chunks_count() == _free_chunks_count,
- "_free_chunks_count " SIZE_FORMAT " is not the"
- " same as sum " SIZE_FORMAT, _free_chunks_count,
- sum_free_chunks_count());
-}
+void ChunkManager::locked_verify(bool slow) const {
+ log_trace(gc, metaspace, freelist)("verifying %s chunkmanager (%s).",
+ (is_class() ? "class space" : "metaspace"), (slow ? "slow" : "quick"));
-void ChunkManager::verify() {
- MutexLockerEx cl(MetaspaceExpand_lock,
- Mutex::_no_safepoint_check_flag);
- locked_verify();
-}
+ assert_lock_strong(MetaspaceExpand_lock);
-void ChunkManager::locked_verify() {
- locked_verify_free_chunks_count();
- locked_verify_free_chunks_total();
+ size_t chunks_counted = 0;
+ size_t wordsize_chunks_counted = 0;
for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) {
- ChunkList* list = free_chunks(i);
+ const ChunkList* list = _free_chunks + i;
if (list != NULL) {
Metachunk* chunk = list->head();
while (chunk) {
- DEBUG_ONLY(do_verify_chunk(chunk);)
+ if (slow) {
+ do_verify_chunk(chunk);
+ }
assert(chunk->is_tagged_free(), "Chunk should be tagged as free.");
+ chunks_counted ++;
+ wordsize_chunks_counted += chunk->size();
chunk = chunk->next();
}
}
}
+
+ chunks_counted += humongous_dictionary()->total_free_blocks();
+ wordsize_chunks_counted += humongous_dictionary()->total_size();
+
+ assert(chunks_counted == _free_chunks_count && wordsize_chunks_counted == _free_chunks_total,
+ "freelist accounting mismatch: "
+ "we think: " SIZE_FORMAT " chunks, total " SIZE_FORMAT " words, "
+ "reality: " SIZE_FORMAT " chunks, total " SIZE_FORMAT " words.",
+ _free_chunks_count, _free_chunks_total,
+ chunks_counted, wordsize_chunks_counted);
}
+#endif // ASSERT
void ChunkManager::locked_print_free_chunks(outputStream* st) {
assert_lock_strong(MetaspaceExpand_lock);
@@ -283,51 +274,12 @@
_free_chunks_total, _free_chunks_count);
}
-void ChunkManager::locked_print_sum_free_chunks(outputStream* st) {
- assert_lock_strong(MetaspaceExpand_lock);
- st->print_cr("Sum free chunk total " SIZE_FORMAT " count " SIZE_FORMAT,
- sum_free_chunks(), sum_free_chunks_count());
-}
-
ChunkList* ChunkManager::free_chunks(ChunkIndex index) {
assert(index == SpecializedIndex || index == SmallIndex || index == MediumIndex,
"Bad index: %d", (int)index);
-
return &_free_chunks[index];
}
-// These methods that sum the free chunk lists are used in printing
-// methods that are used in product builds.
-size_t ChunkManager::sum_free_chunks() {
- assert_lock_strong(MetaspaceExpand_lock);
- size_t result = 0;
- for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) {
- ChunkList* list = free_chunks(i);
-
- if (list == NULL) {
- continue;
- }
-
- result = result + list->count() * list->size();
- }
- result = result + humongous_dictionary()->total_size();
- return result;
-}
-
-size_t ChunkManager::sum_free_chunks_count() {
- assert_lock_strong(MetaspaceExpand_lock);
- size_t count = 0;
- for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) {
- ChunkList* list = free_chunks(i);
- if (list == NULL) {
- continue;
- }
- count = count + list->count();
- }
- count = count + humongous_dictionary()->total_free_blocks();
- return count;
-}
-
ChunkList* ChunkManager::find_free_chunks_list(size_t word_size) {
ChunkIndex index = list_index(word_size);
assert(index < HumongousIndex, "No humongous list");
@@ -427,14 +379,18 @@
}
+ // Note: at this point, the VirtualSpaceNode is invalid since we split a chunk and
+ // did not yet hand out part of that split; so, vsn->verify_free_chunks_are_ideally_merged()
+ // would assert. Instead, do all verifications in the caller.
+
+ DEBUG_ONLY(g_internal_statistics.num_chunk_splits ++);
+
return target_chunk;
}
Metachunk* ChunkManager::free_chunks_get(size_t word_size) {
assert_lock_strong(MetaspaceExpand_lock);
- slow_locked_verify();
-
Metachunk* chunk = NULL;
bool we_did_split_a_chunk = false;
@@ -524,14 +480,19 @@
// Run some verifications (some more if we did a chunk split)
#ifdef ASSERT
- if (VerifyMetaspace) {
- locked_verify();
+
+ EVERY_NTH(VerifyMetaspaceInterval)
+ // Be extra verify-y when chunk split happened.
+ locked_verify(true);
VirtualSpaceNode* const vsn = chunk->container();
- vsn->verify();
+ vsn->verify(true);
if (we_did_split_a_chunk) {
vsn->verify_free_chunks_are_ideally_merged();
}
- }
+ END_EVERY_NTH
+
+ g_internal_statistics.num_chunks_removed_from_freelist ++;
+
#endif
return chunk;
@@ -539,7 +500,6 @@
Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) {
assert_lock_strong(MetaspaceExpand_lock);
- slow_locked_verify();
// Take from the beginning of the list
Metachunk* chunk = free_chunks_get(word_size);
@@ -570,9 +530,17 @@
}
void ChunkManager::return_single_chunk(Metachunk* chunk) {
+
+#ifdef ASSERT
+ EVERY_NTH(VerifyMetaspaceInterval)
+ this->locked_verify(false);
+ do_verify_chunk(chunk);
+ END_EVERY_NTH
+#endif
+
const ChunkIndex index = chunk->get_chunk_type();
assert_lock_strong(MetaspaceExpand_lock);
- DEBUG_ONLY(do_verify_chunk(chunk);)
+ DEBUG_ONLY(g_internal_statistics.num_chunks_added_to_freelist ++;)
assert(chunk != NULL, "Expected chunk.");
assert(chunk->container() != NULL, "Container should have been set.");
assert(chunk->is_tagged_free() == false, "Chunk should be in use.");
@@ -583,6 +551,9 @@
// keeps tree node pointers in the chunk payload area which mangle will overwrite.
DEBUG_ONLY(chunk->mangle(badMetaWordVal);)
+ // may need node for verification later after chunk may have been merged away.
+ DEBUG_ONLY(VirtualSpaceNode* vsn = chunk->container(); )
+
if (index != HumongousIndex) {
// Return non-humongous chunk to freelist.
ChunkList* list = free_chunks(index);
@@ -618,6 +589,16 @@
}
}
+ // From here on do not access chunk anymore, it may have been merged with another chunk.
+
+#ifdef ASSERT
+ EVERY_NTH(VerifyMetaspaceInterval)
+ this->locked_verify(true);
+ vsn->verify(true);
+ vsn->verify_free_chunks_are_ideally_merged();
+ END_EVERY_NTH
+#endif
+
}
void ChunkManager::return_chunk_list(Metachunk* chunks) {
--- a/src/hotspot/share/memory/metaspace/chunkManager.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/memory/metaspace/chunkManager.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -33,7 +33,7 @@
#include "memory/metaspaceChunkFreeListSummary.hpp"
#include "utilities/globalDefinitions.hpp"
-class ChunkManagerTest;
+class ChunkManagerTestAccessor;
namespace metaspace {
@@ -42,7 +42,7 @@
// Manages the global free lists of chunks.
class ChunkManager : public CHeapObj<mtInternal> {
- friend class ::ChunkManagerTest;
+ friend class ::ChunkManagerTestAccessor;
// Free list of chunks of different sizes.
// SpecializedChunk
@@ -63,9 +63,8 @@
ChunkTreeDictionary _humongous_dictionary;
// Returns the humongous chunk dictionary.
- ChunkTreeDictionary* humongous_dictionary() {
- return &_humongous_dictionary;
- }
+ ChunkTreeDictionary* humongous_dictionary() { return &_humongous_dictionary; }
+ const ChunkTreeDictionary* humongous_dictionary() const { return &_humongous_dictionary; }
// Size, in metaspace words, of all chunks managed by this ChunkManager
size_t _free_chunks_total;
@@ -76,22 +75,6 @@
void account_for_added_chunk(const Metachunk* c);
void account_for_removed_chunk(const Metachunk* c);
- size_t sum_free_chunks();
- size_t sum_free_chunks_count();
-
- void locked_verify_free_chunks_total();
- void slow_locked_verify_free_chunks_total() {
- if (VerifyMetaspace) {
- locked_verify_free_chunks_total();
- }
- }
- void locked_verify_free_chunks_count();
- void slow_locked_verify_free_chunks_count() {
- if (VerifyMetaspace) {
- locked_verify_free_chunks_count();
- }
- }
-
// Given a pointer to a chunk, attempts to merge it with neighboring
// free chunks to form a bigger chunk. Returns true if successful.
bool attempt_to_coalesce_around_chunk(Metachunk* chunk, ChunkIndex target_chunk_type);
@@ -147,11 +130,11 @@
void return_chunk_list(Metachunk* chunk);
// Total of the space in the free chunks list
- size_t free_chunks_total_words();
- size_t free_chunks_total_bytes();
+ size_t free_chunks_total_words() const { return _free_chunks_total; }
+ size_t free_chunks_total_bytes() const { return free_chunks_total_words() * BytesPerWord; }
// Number of chunks in the free chunks list
- size_t free_chunks_count();
+ size_t free_chunks_count() const { return _free_chunks_count; }
// Remove from a list by size. Selects list based on size of chunk.
Metachunk* free_chunks_get(size_t chunk_word_size);
@@ -195,22 +178,14 @@
size_free_chunks_in_bytes(HumongousIndex));
}
+#ifdef ASSERT
// Debug support
- void verify();
- void slow_verify() {
- if (VerifyMetaspace) {
- verify();
- }
- }
- void locked_verify();
- void slow_locked_verify() {
- if (VerifyMetaspace) {
- locked_verify();
- }
- }
+ // Verify free list integrity. slow=true: verify chunk-internal integrity too.
+ void verify(bool slow) const;
+ void locked_verify(bool slow) const;
+#endif
void locked_print_free_chunks(outputStream* st);
- void locked_print_sum_free_chunks(outputStream* st);
// Fill in current statistic values to the given statistics object.
void collect_statistics(ChunkManagerStatistics* out) const;
--- a/src/hotspot/share/memory/metaspace/metaDebug.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/memory/metaspace/metaDebug.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -41,6 +41,17 @@
#endif
};
+#ifdef ASSERT
+#define EVERY_NTH(n) \
+{ static int counter_ = 0; \
+ if (n > 0) { \
+ counter_ ++; \
+ if (counter_ > n) { \
+ counter_ = 0; \
+
+#define END_EVERY_NTH } } }
+#endif // ASSERT
+
} // namespace metaspace
#endif // SHARE_MEMORY_METASPACE_METADEBUG_HPP
--- a/src/hotspot/share/memory/metaspace/metaspaceCommon.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/memory/metaspace/metaspaceCommon.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -25,6 +25,7 @@
#ifndef SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP
#define SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP
+#include "utilities/align.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
@@ -85,6 +86,14 @@
uintx num_external_deallocs;
// Number of times an allocation was satisfied from deallocated blocks.
uintx num_allocs_from_deallocated_blocks;
+ // Number of times a chunk was added to the freelist
+ uintx num_chunks_added_to_freelist;
+ // Number of times a chunk was removed from the freelist
+ uintx num_chunks_removed_from_freelist;
+ // Number of chunk merges
+ uintx num_chunk_merges;
+ // Number of chunk splits
+ uintx num_chunk_splits;
};
extern internal_statistics_t g_internal_statistics;
#endif
@@ -111,6 +120,16 @@
// Returns a descriptive name for a chunk type.
const char* chunk_size_name(ChunkIndex index);
+// Verify chunk sizes.
+inline bool is_valid_chunksize(bool is_class, size_t size) {
+ const size_t reasonable_maximum_humongous_chunk_size = 1 * G;
+ return is_aligned(size, sizeof(MetaWord)) &&
+ size < reasonable_maximum_humongous_chunk_size &&
+ is_class ?
+ (size == ClassSpecializedChunk || size == ClassSmallChunk || size >= ClassMediumChunk) :
+ (size == SpecializedChunk || size == SmallChunk || size >= MediumChunk);
+}
+
// Verify chunk type.
inline bool is_valid_chunktype(ChunkIndex index) {
return index == SpecializedIndex || index == SmallIndex ||
--- a/src/hotspot/share/memory/metaspace/spaceManager.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/memory/metaspace/spaceManager.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -287,8 +287,6 @@
MutexLockerEx fcl(MetaspaceExpand_lock,
Mutex::_no_safepoint_check_flag);
- chunk_manager()->slow_locked_verify();
-
account_for_spacemanager_death();
Log(gc, metaspace, freelist) log;
@@ -313,7 +311,11 @@
_current_chunk = NULL;
#endif
- chunk_manager()->slow_locked_verify();
+#ifdef ASSERT
+ EVERY_NTH(VerifyMetaspaceInterval)
+ chunk_manager()->locked_verify(true);
+ END_EVERY_NTH
+#endif
if (_block_freelists != NULL) {
delete _block_freelists;
@@ -405,8 +407,6 @@
BlockFreelist* fl = block_freelists();
MetaWord* p = NULL;
- DEBUG_ONLY(if (VerifyMetaspace) verify_metrics_locked());
-
// Allocation from the dictionary is expensive in the sense that
// the dictionary has to be searched for a size. Don't allocate
// from the dictionary until it starts to get fat. Is this
@@ -422,6 +422,12 @@
p = allocate_work(raw_word_size);
}
+#ifdef ASSERT
+ EVERY_NTH(VerifyMetaspaceInterval)
+ verify_metrics_locked();
+ END_EVERY_NTH
+#endif
+
return p;
}
--- a/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -97,7 +97,7 @@
VirtualSpaceNode* next_vsl = prev_vsl;
while (next_vsl != NULL) {
VirtualSpaceNode* vsl = next_vsl;
- DEBUG_ONLY(vsl->verify_container_count();)
+ DEBUG_ONLY(vsl->verify(false);)
next_vsl = vsl->next();
// Don't free the current virtual space since it will likely
// be needed soon.
--- a/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -29,6 +29,7 @@
#include "memory/metaspace/metachunk.hpp"
#include "memory/metaspace.hpp"
#include "memory/metaspace/chunkManager.hpp"
+#include "memory/metaspace/metaDebug.hpp"
#include "memory/metaspace/metaspaceCommon.hpp"
#include "memory/metaspace/occupancyMap.hpp"
#include "memory/metaspace/virtualSpaceNode.hpp"
@@ -73,8 +74,9 @@
}
void VirtualSpaceNode::purge(ChunkManager* chunk_manager) {
- DEBUG_ONLY(this->verify();)
- Metachunk* chunk = first_chunk();
+ // When a node is purged, lets give it a thorough examination.
+ DEBUG_ONLY(verify(true);)
+ Metachunk* chunk = first_chunk();
Metachunk* invalid_chunk = (Metachunk*) top();
while (chunk < invalid_chunk ) {
assert(chunk->is_tagged_free(), "Should be tagged free");
@@ -171,49 +173,39 @@
#ifdef ASSERT
-uintx VirtualSpaceNode::container_count_slow() {
- uintx count = 0;
- Metachunk* chunk = first_chunk();
- Metachunk* invalid_chunk = (Metachunk*) top();
- while (chunk < invalid_chunk ) {
- MetaWord* next = ((MetaWord*)chunk) + chunk->word_size();
- do_verify_chunk(chunk);
- // Don't count the chunks on the free lists. Those are
- // still part of the VirtualSpaceNode but not currently
- // counted.
- if (!chunk->is_tagged_free()) {
- count++;
- }
- chunk = (Metachunk*) next;
- }
- return count;
-}
-#endif
-#ifdef ASSERT
// Verify counters, all chunks in this list node and the occupancy map.
-void VirtualSpaceNode::verify() {
+void VirtualSpaceNode::verify(bool slow) {
+ log_trace(gc, metaspace, freelist)("verifying %s virtual space node (%s).",
+ (is_class() ? "class space" : "metaspace"), (slow ? "slow" : "quick"));
+ // Fast mode: just verify chunk counters and basic geometry
+ // Slow mode: verify chunks and occupancy map
uintx num_in_use_chunks = 0;
Metachunk* chunk = first_chunk();
Metachunk* invalid_chunk = (Metachunk*) top();
// Iterate the chunks in this node and verify each chunk.
while (chunk < invalid_chunk ) {
- DEBUG_ONLY(do_verify_chunk(chunk);)
- if (!chunk->is_tagged_free()) {
- num_in_use_chunks ++;
- }
- MetaWord* next = ((MetaWord*)chunk) + chunk->word_size();
+ if (slow) {
+ do_verify_chunk(chunk);
+ }
+ if (!chunk->is_tagged_free()) {
+ num_in_use_chunks ++;
+ }
+ const size_t s = chunk->word_size();
+ // Prevent endless loop on invalid chunk size.
+ assert(is_valid_chunksize(is_class(), s), "Invalid chunk size: " SIZE_FORMAT ".", s);
+ MetaWord* next = ((MetaWord*)chunk) + s;
chunk = (Metachunk*) next;
}
assert(_container_count == num_in_use_chunks, "Container count mismatch (real: " UINTX_FORMAT
", counter: " UINTX_FORMAT ".", num_in_use_chunks, _container_count);
// Also verify the occupancy map.
- occupancy_map()->verify(this->bottom(), this->top());
+ if (slow) {
+ occupancy_map()->verify(bottom(), top());
+ }
}
-#endif // ASSERT
-#ifdef ASSERT
// Verify that all free chunks in this node are ideally merged
// (there not should be multiple small chunks where a large chunk could exist.)
void VirtualSpaceNode::verify_free_chunks_are_ideally_merged() {
@@ -224,23 +216,31 @@
const size_t size_small = (is_class() ? ClassSmallChunk : SmallChunk) * BytesPerWord;
int num_free_chunks_since_last_med_boundary = -1;
int num_free_chunks_since_last_small_boundary = -1;
- while (chunk < invalid_chunk ) {
+ bool error = false;
+ char err[256];
+ while (!error && chunk < invalid_chunk ) {
// Test for missed chunk merge opportunities: count number of free chunks since last chunk boundary.
// Reset the counter when encountering a non-free chunk.
if (chunk->get_chunk_type() != HumongousIndex) {
if (chunk->is_tagged_free()) {
// Count successive free, non-humongous chunks.
if (is_aligned(chunk, size_small)) {
- assert(num_free_chunks_since_last_small_boundary <= 1,
- "Missed chunk merge opportunity at " PTR_FORMAT " for chunk size " SIZE_FORMAT_HEX ".", p2i(chunk) - size_small, size_small);
- num_free_chunks_since_last_small_boundary = 0;
+ if (num_free_chunks_since_last_small_boundary > 0) {
+ error = true;
+ jio_snprintf(err, sizeof(err), "Missed chunk merge opportunity to merge a small chunk preceding " PTR_FORMAT ".", p2i(chunk));
+ } else {
+ num_free_chunks_since_last_small_boundary = 0;
+ }
} else if (num_free_chunks_since_last_small_boundary != -1) {
num_free_chunks_since_last_small_boundary ++;
}
if (is_aligned(chunk, size_med)) {
- assert(num_free_chunks_since_last_med_boundary <= 1,
- "Missed chunk merge opportunity at " PTR_FORMAT " for chunk size " SIZE_FORMAT_HEX ".", p2i(chunk) - size_med, size_med);
- num_free_chunks_since_last_med_boundary = 0;
+ if (num_free_chunks_since_last_med_boundary > 0) {
+ error = true;
+ jio_snprintf(err, sizeof(err), "Missed chunk merge opportunity to merge a medium chunk preceding " PTR_FORMAT ".", p2i(chunk));
+ } else {
+ num_free_chunks_since_last_med_boundary = 0;
+ }
} else if (num_free_chunks_since_last_med_boundary != -1) {
num_free_chunks_since_last_med_boundary ++;
}
@@ -255,6 +255,11 @@
num_free_chunks_since_last_small_boundary = -1;
}
+ if (error) {
+ print_map(tty, is_class());
+ fatal("%s", err);
+ }
+
MetaWord* next = ((MetaWord*)chunk) + chunk->word_size();
chunk = (Metachunk*) next;
}
@@ -271,14 +276,6 @@
_container_count--;
}
-#ifdef ASSERT
-void VirtualSpaceNode::verify_container_count() {
- assert(_container_count == container_count_slow(),
- "Inconsistency in container_count _container_count " UINTX_FORMAT
- " container_count_slow() " UINTX_FORMAT, _container_count, container_count_slow());
-}
-#endif
-
VirtualSpaceNode::~VirtualSpaceNode() {
_rs.release();
if (_occupancy_map != NULL) {
@@ -309,7 +306,7 @@
assert(target_top > top(), "Sanity");
// Padding chunks are added to the freelist.
- ChunkManager* const chunk_manager = Metaspace::get_chunk_manager(this->is_class());
+ ChunkManager* const chunk_manager = Metaspace::get_chunk_manager(is_class());
// shorthands
const size_t spec_word_size = chunk_manager->specialized_chunk_word_size();
@@ -378,7 +375,7 @@
// chunks. These chunks are created and added to the freelist.
// The chunk manager to which we will give our padding chunks.
- ChunkManager* const chunk_manager = Metaspace::get_chunk_manager(this->is_class());
+ ChunkManager* const chunk_manager = Metaspace::get_chunk_manager(is_class());
// shorthands
const size_t spec_word_size = chunk_manager->specialized_chunk_word_size();
@@ -450,12 +447,13 @@
inc_container_count();
- if (VerifyMetaspace) {
- DEBUG_ONLY(chunk_manager->locked_verify());
- DEBUG_ONLY(this->verify());
- }
-
- DEBUG_ONLY(do_verify_chunk(result));
+#ifdef ASSERT
+ EVERY_NTH(VerifyMetaspaceInterval)
+ chunk_manager->locked_verify(true);
+ verify(true);
+ END_EVERY_NTH
+ do_verify_chunk(result);
+#endif
result->inc_use_count();
@@ -558,8 +556,13 @@
#endif // ASSERT
void VirtualSpaceNode::retire(ChunkManager* chunk_manager) {
- DEBUG_ONLY(verify_container_count();)
- assert(this->is_class() == chunk_manager->is_class(), "Wrong ChunkManager?");
+ assert(is_class() == chunk_manager->is_class(), "Wrong ChunkManager?");
+#ifdef ASSERT
+ verify(false);
+ EVERY_NTH(VerifyMetaspaceInterval)
+ verify(true);
+ END_EVERY_NTH
+#endif
for (int i = (int)MediumIndex; i >= (int)ZeroIndex; --i) {
ChunkIndex index = (ChunkIndex)i;
size_t chunk_size = chunk_manager->size_by_index(index);
@@ -577,7 +580,6 @@
}
chunk_manager->return_single_chunk(chunk);
}
- DEBUG_ONLY(verify_container_count();)
}
assert(free_words_in_vs() == 0, "should be empty now");
}
--- a/src/hotspot/share/memory/metaspace/virtualSpaceNode.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/memory/metaspace/virtualSpaceNode.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -115,10 +115,6 @@
uintx container_count() { return _container_count; }
void inc_container_count();
void dec_container_count();
-#ifdef ASSERT
- uintx container_count_slow();
- void verify_container_count();
-#endif
// used and capacity in this single entry in the list
size_t used_words_in_vs() const;
@@ -152,10 +148,10 @@
// Debug support
DEBUG_ONLY(void mangle();)
- // Verify counters, all chunks in this list node and the occupancy map.
- DEBUG_ONLY(void verify();)
+ // Verify counters and basic structure. Slow mode: verify all chunks in depth and occupancy map.
+ DEBUG_ONLY(void verify(bool slow);)
// Verify that all free chunks in this node are ideally merged
- // (there not should be multiple small chunks where a large chunk could exist.)
+ // (there should not be multiple small chunks where a large chunk could exist.)
DEBUG_ONLY(void verify_free_chunks_are_ideally_merged();)
};
--- a/src/hotspot/share/oops/cpCache.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/oops/cpCache.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -168,7 +168,8 @@
void ConstantPoolCacheEntry::set_direct_or_vtable_call(Bytecodes::Code invoke_code,
const methodHandle& method,
int vtable_index,
- bool sender_is_interface) {
+ bool sender_is_interface,
+ InstanceKlass* pool_holder) {
bool is_vtable_call = (vtable_index >= 0); // FIXME: split this method on this boolean
assert(method->interpreter_entry() != NULL, "should have been set at this point");
assert(!method->is_obsolete(), "attempt to write obsolete method to cpCache");
@@ -263,9 +264,17 @@
}
// Don't mark invokestatic to method as resolved if the holder class has not yet completed
// initialization. An invokestatic must only proceed if the class is initialized, but if
- // we resolve it before then that class initialization check is skipped.
- if (invoke_code == Bytecodes::_invokestatic && !method->method_holder()->is_initialized()) {
- do_resolve = false;
+ // we resolve it before then that class initialization check is skipped. However if the call
+ // is from the same class we can resolve as we must be executing with <clinit> on our call stack.
+ if (invoke_code == Bytecodes::_invokestatic) {
+ if (!method->method_holder()->is_initialized() &&
+ method->method_holder() != pool_holder) {
+ do_resolve = false;
+ } else {
+ assert(method->method_holder()->is_initialized() ||
+ method->method_holder()->is_reentrant_initialization(Thread::current()),
+ "invalid class initialization state for invoke_static");
+ }
}
if (do_resolve) {
set_bytecode_1(invoke_code);
@@ -310,17 +319,17 @@
}
void ConstantPoolCacheEntry::set_direct_call(Bytecodes::Code invoke_code, const methodHandle& method,
- bool sender_is_interface) {
+ bool sender_is_interface, InstanceKlass* pool_holder) {
int index = Method::nonvirtual_vtable_index;
// index < 0; FIXME: inline and customize set_direct_or_vtable_call
- set_direct_or_vtable_call(invoke_code, method, index, sender_is_interface);
+ set_direct_or_vtable_call(invoke_code, method, index, sender_is_interface, pool_holder);
}
void ConstantPoolCacheEntry::set_vtable_call(Bytecodes::Code invoke_code, const methodHandle& method, int index) {
// either the method is a miranda or its holder should accept the given index
assert(method->method_holder()->is_interface() || method->method_holder()->verify_vtable_index(index), "");
// index >= 0; FIXME: inline and customize set_direct_or_vtable_call
- set_direct_or_vtable_call(invoke_code, method, index, false);
+ set_direct_or_vtable_call(invoke_code, method, index, false, NULL /* not used */);
}
void ConstantPoolCacheEntry::set_itable_call(Bytecodes::Code invoke_code,
--- a/src/hotspot/share/oops/cpCache.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/oops/cpCache.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -230,14 +230,16 @@
Bytecodes::Code invoke_code, // the bytecode used for invoking the method
const methodHandle& method, // the method/prototype if any (NULL, otherwise)
int vtable_index, // the vtable index if any, else negative
- bool sender_is_interface
+ bool sender_is_interface, // 'logical' sender (may be host of VMAC)
+ InstanceKlass* pool_holder // class from which the call is made
);
public:
void set_direct_call( // sets entry to exact concrete method entry
Bytecodes::Code invoke_code, // the bytecode used for invoking the method
const methodHandle& method, // the method to call
- bool sender_is_interface
+ bool sender_is_interface, // 'logical' sender (may be host of VMAC)
+ InstanceKlass* pool_holder // class from which the call is made
);
void set_vtable_call( // sets entry to vtable index
--- a/src/hotspot/share/oops/method.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/oops/method.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1684,35 +1684,11 @@
while (s.next() >= 0) BytecodeTracer::trace(mh, s.bcp(), st);
}
-
-// Simple compression of line number tables. We use a regular compressed stream, except that we compress deltas
-// between (bci,line) pairs since they are smaller. If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
-// we save it as one byte, otherwise we write a 0xFF escape character and use regular compression. 0x0 is used
-// as end-of-stream terminator.
-
-void CompressedLineNumberWriteStream::write_pair_regular(int bci_delta, int line_delta) {
- // bci and line number does not compress into single byte.
- // Write out escape character and use regular compression for bci and line number.
- write_byte((jubyte)0xFF);
- write_signed_int(bci_delta);
- write_signed_int(line_delta);
-}
-
-// See comment in method.hpp which explains why this exists.
-#if defined(_M_AMD64) && _MSC_VER >= 1400
-#pragma optimize("", off)
-void CompressedLineNumberWriteStream::write_pair(int bci, int line) {
- write_pair_inline(bci, line);
-}
-#pragma optimize("", on)
-#endif
-
CompressedLineNumberReadStream::CompressedLineNumberReadStream(u_char* buffer) : CompressedReadStream(buffer) {
_bci = 0;
_line = 0;
};
-
bool CompressedLineNumberReadStream::read_pair() {
jubyte next = read_byte();
// Check for terminator
--- a/src/hotspot/share/oops/method.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/oops/method.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -1022,36 +1022,12 @@
// Write (bci, line number) pair to stream
void write_pair_regular(int bci_delta, int line_delta);
- inline void write_pair_inline(int bci, int line) {
- int bci_delta = bci - _bci;
- int line_delta = line - _line;
- _bci = bci;
- _line = line;
- // Skip (0,0) deltas - they do not add information and conflict with terminator.
- if (bci_delta == 0 && line_delta == 0) return;
- // Check if bci is 5-bit and line number 3-bit unsigned.
- if (((bci_delta & ~0x1F) == 0) && ((line_delta & ~0x7) == 0)) {
- // Compress into single byte.
- jubyte value = ((jubyte) bci_delta << 3) | (jubyte) line_delta;
- // Check that value doesn't match escape character.
- if (value != 0xFF) {
- write_byte(value);
- return;
- }
- }
- write_pair_regular(bci_delta, line_delta);
- }
+ // If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
+ // we save it as one byte, otherwise we write a 0xFF escape character
+ // and use regular compression. 0x0 is used as end-of-stream terminator.
+ void write_pair_inline(int bci, int line);
-// Windows AMD64 + Apr 2005 PSDK with /O2 generates bad code for write_pair.
-// Disabling optimization doesn't work for methods in header files
-// so we force it to call through the non-optimized version in the .cpp.
-// It's gross, but it's the only way we can ensure that all callers are
-// fixed. _MSC_VER is defined by the windows compiler
-#if defined(_M_AMD64) && _MSC_VER >= 1400
void write_pair(int bci, int line);
-#else
- void write_pair(int bci, int line) { write_pair_inline(bci, line); }
-#endif
// Write end-of-stream marker
void write_terminator() { write_byte(0); }
--- a/src/hotspot/share/oops/method.inline.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/oops/method.inline.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -48,6 +48,39 @@
return OrderAccess::load_acquire(&_code);
}
+// Write (bci, line number) pair to stream
+inline void CompressedLineNumberWriteStream::write_pair_regular(int bci_delta, int line_delta) {
+ // bci and line number does not compress into single byte.
+ // Write out escape character and use regular compression for bci and line number.
+ write_byte((jubyte)0xFF);
+ write_signed_int(bci_delta);
+ write_signed_int(line_delta);
+}
+
+inline void CompressedLineNumberWriteStream::write_pair_inline(int bci, int line) {
+ int bci_delta = bci - _bci;
+ int line_delta = line - _line;
+ _bci = bci;
+ _line = line;
+ // Skip (0,0) deltas - they do not add information and conflict with terminator.
+ if (bci_delta == 0 && line_delta == 0) return;
+ // Check if bci is 5-bit and line number 3-bit unsigned.
+ if (((bci_delta & ~0x1F) == 0) && ((line_delta & ~0x7) == 0)) {
+ // Compress into single byte.
+ jubyte value = ((jubyte) bci_delta << 3) | (jubyte) line_delta;
+ // Check that value doesn't match escape character.
+ if (value != 0xFF) {
+ write_byte(value);
+ return;
+ }
+ }
+ write_pair_regular(bci_delta, line_delta);
+}
+
+inline void CompressedLineNumberWriteStream::write_pair(int bci, int line) {
+ write_pair_inline(bci, line);
+}
+
inline bool Method::has_compiled_code() const { return code() != NULL; }
#endif // SHARE_OOPS_METHOD_INLINE_HPP
--- a/src/hotspot/share/opto/chaitin.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/opto/chaitin.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -114,9 +114,9 @@
_msize_valid=1;
if (_is_vector) {
assert(!_fat_proj, "sanity");
- _mask.verify_sets(_num_regs);
+ assert(_mask.is_aligned_sets(_num_regs), "mask is not aligned, adjacent sets");
} else if (_num_regs == 2 && !_fat_proj) {
- _mask.verify_pairs();
+ assert(_mask.is_aligned_pairs(), "mask is not aligned, adjacent pairs");
}
#endif
}
--- a/src/hotspot/share/opto/indexSet.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/opto/indexSet.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -50,72 +50,6 @@
int IndexSet::_serial_count = 1;
#endif
-// What is the first set bit in a 5 bit integer?
-const uint8_t IndexSetIterator::_first_bit[32] = {
- 0, 0, 1, 0,
- 2, 0, 1, 0,
- 3, 0, 1, 0,
- 2, 0, 1, 0,
- 4, 0, 1, 0,
- 2, 0, 1, 0,
- 3, 0, 1, 0,
- 2, 0, 1, 0
-};
-
-// What is the second set bit in a 5 bit integer?
-const uint8_t IndexSetIterator::_second_bit[32] = {
- 5, 5, 5, 1,
- 5, 2, 2, 1,
- 5, 3, 3, 1,
- 3, 2, 2, 1,
- 5, 4, 4, 1,
- 4, 2, 2, 1,
- 4, 3, 3, 1,
- 3, 2, 2, 1
-};
-
-// I tried implementing the IndexSetIterator with a window_size of 8 and
-// didn't seem to get a noticeable speedup. I am leaving in the tables
-// in case we want to switch back.
-
-/*const byte IndexSetIterator::_first_bit[256] = {
- 8, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
-};
-
-const byte IndexSetIterator::_second_bit[256] = {
- 8, 8, 8, 1, 8, 2, 2, 1, 8, 3, 3, 1, 3, 2, 2, 1,
- 8, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1,
- 8, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1,
- 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1,
- 8, 6, 6, 1, 6, 2, 2, 1, 6, 3, 3, 1, 3, 2, 2, 1,
- 6, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1,
- 6, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1,
- 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1,
- 8, 7, 7, 1, 7, 2, 2, 1, 7, 3, 3, 1, 3, 2, 2, 1,
- 7, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1,
- 7, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1,
- 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1,
- 7, 6, 6, 1, 6, 2, 2, 1, 6, 3, 3, 1, 3, 2, 2, 1,
- 6, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1,
- 6, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1,
- 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1
-};*/
-
//---------------------------- IndexSet::populate_free_list() -----------------------------
// Populate the free BitBlock list with a batch of BitBlocks. The BitBlocks
// are 32 bit aligned.
--- a/src/hotspot/share/opto/indexSet.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/opto/indexSet.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -29,6 +29,7 @@
#include "memory/resourceArea.hpp"
#include "opto/compile.hpp"
#include "opto/regmask.hpp"
+#include "utilities/count_trailing_zeros.hpp"
// This file defines the IndexSet class, a set of sparse integer indices.
// This data structure is used by the compiler in its liveness analysis and
@@ -396,19 +397,6 @@
class IndexSetIterator {
friend class IndexSet;
- public:
-
- // We walk over the bits in a word in chunks of size window_size.
- enum { window_size = 5,
- window_mask = right_n_bits(window_size),
- table_size = (1 << window_size) };
-
- // For an integer of length window_size, what is the first set bit?
- static const uint8_t _first_bit[table_size];
-
- // For an integer of length window_size, what is the second set bit?
- static const uint8_t _second_bit[table_size];
-
private:
// The current word we are inspecting
uint32_t _current;
@@ -440,7 +428,6 @@
// element in the set.
uint advance_and_next();
-
public:
// If an iterator is built from a constant set then empty blocks
@@ -452,16 +439,11 @@
uint next() {
uint current = _current;
if (current != 0) {
- uint value = _value;
- while (mask_bits(current,window_mask) == 0) {
- current >>= window_size;
- value += window_size;
- }
-
- uint advance = _second_bit[mask_bits(current,window_mask)];
- _current = current >> advance;
- _value = value + advance;
- return value + _first_bit[mask_bits(current,window_mask)];
+ uint advance = count_trailing_zeros(current);
+ assert(((current >> advance) & 0x1) == 1, "sanity");
+ _current = (current >> advance) - 1;
+ _value += advance;
+ return _value;
} else {
return advance_and_next();
}
--- a/src/hotspot/share/opto/library_call.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/opto/library_call.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -6609,6 +6609,40 @@
//------------------------------inline_fp_min_max------------------------------
bool LibraryCallKit::inline_fp_min_max(vmIntrinsics::ID id) {
+/* DISABLED BECAUSE METHOD DATA ISN'T COLLECTED PER CALL-SITE, SEE JDK-8015416.
+
+ // The intrinsic should be used only when the API branches aren't predictable,
+ // the last one performing the most important comparison. The following heuristic
+ // uses the branch statistics to eventually bail out if necessary.
+
+ ciMethodData *md = callee()->method_data();
+
+ if ( md != NULL && md->is_mature() && md->invocation_count() > 0 ) {
+ ciCallProfile cp = caller()->call_profile_at_bci(bci());
+
+ if ( ((double)cp.count()) / ((double)md->invocation_count()) < 0.8 ) {
+ // Bail out if the call-site didn't contribute enough to the statistics.
+ return false;
+ }
+
+ uint taken = 0, not_taken = 0;
+
+ for (ciProfileData *p = md->first_data(); md->is_valid(p); p = md->next_data(p)) {
+ if (p->is_BranchData()) {
+ taken = ((ciBranchData*)p)->taken();
+ not_taken = ((ciBranchData*)p)->not_taken();
+ }
+ }
+
+ double balance = (((double)taken) - ((double)not_taken)) / ((double)md->invocation_count());
+ balance = balance < 0 ? -balance : balance;
+ if ( balance > 0.2 ) {
+ // Bail out if the most important branch is predictable enough.
+ return false;
+ }
+ }
+*/
+
Node *a = NULL;
Node *b = NULL;
Node *n = NULL;
--- a/src/hotspot/share/opto/loopTransform.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/opto/loopTransform.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -2039,7 +2039,8 @@
if (n_ctrl != NULL && loop->is_member(get_loop(n_ctrl))) {
// Now test it to see if it fits the standard pattern for a reduction operator.
int opc = def_node->Opcode();
- if (opc != ReductionNode::opcode(opc, def_node->bottom_type()->basic_type())) {
+ if (opc != ReductionNode::opcode(opc, def_node->bottom_type()->basic_type())
+ || opc == Op_MinD || opc == Op_MinF || opc == Op_MaxD || opc == Op_MaxF) {
if (!def_node->is_reduction()) { // Not marked yet
// To be a reduction, the arithmetic node must have the phi as input and provide a def to it
bool ok = false;
--- a/src/hotspot/share/opto/output.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/opto/output.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1556,6 +1556,8 @@
}
if (method() != NULL) {
method()->print_metadata();
+ } else if (stub_name() != NULL) {
+ tty->print_cr("Generating RuntimeStub - %s", stub_name());
}
dump_asm(node_offsets, node_offset_limit);
if (xtty != NULL) {
--- a/src/hotspot/share/opto/regmask.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/opto/regmask.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -82,69 +82,62 @@
return 1;
}
-//------------------------------ClearToPairs-----------------------------------
// Clear out partial bits; leave only bit pairs
void RegMask::clear_to_pairs() {
- for( int i = 0; i < RM_SIZE; i++ ) {
+ assert(valid_watermarks(), "sanity");
+ for (int i = _lwm; i <= _hwm; i++) {
int bits = _A[i];
bits &= ((bits & 0x55555555)<<1); // 1 hi-bit set for each pair
bits |= (bits>>1); // Smear 1 hi-bit into a pair
_A[i] = bits;
}
- verify_pairs();
+ assert(is_aligned_pairs(), "mask is not aligned, adjacent pairs");
}
-//------------------------------is_aligned_pairs-------------------------------
+bool RegMask::is_misaligned_pair() const {
+ return Size() == 2 && !is_aligned_pairs();
+}
+
bool RegMask::is_aligned_pairs() const {
// Assert that the register mask contains only bit pairs.
- for( int i = 0; i < RM_SIZE; i++ ) {
+ assert(valid_watermarks(), "sanity");
+ for (int i = _lwm; i <= _hwm; i++) {
int bits = _A[i];
- while( bits ) { // Check bits for pairing
+ while (bits) { // Check bits for pairing
int bit = bits & -bits; // Extract low bit
// Low bit is not odd means its mis-aligned.
- if( (bit & 0x55555555) == 0 ) return false;
+ if ((bit & 0x55555555) == 0) return false;
bits -= bit; // Remove bit from mask
// Check for aligned adjacent bit
- if( (bits & (bit<<1)) == 0 ) return false;
+ if ((bits & (bit<<1)) == 0) return false;
bits -= (bit<<1); // Remove other halve of pair
}
}
return true;
}
-//------------------------------is_bound1--------------------------------------
// Return TRUE if the mask contains a single bit
-int RegMask::is_bound1() const {
- if( is_AllStack() ) return false;
- int bit = -1; // Set to hold the one bit allowed
- for( int i = 0; i < RM_SIZE; i++ ) {
- if( _A[i] ) { // Found some bits
- if( bit != -1 ) return false; // Already had bits, so fail
- bit = _A[i] & -_A[i]; // Extract 1 bit from mask
- if( bit != _A[i] ) return false; // Found many bits, so fail
- }
- }
- // True for both the empty mask and for a single bit
- return true;
+bool RegMask::is_bound1() const {
+ if (is_AllStack()) return false;
+ return Size() == 1;
}
-//------------------------------is_bound2--------------------------------------
// Return TRUE if the mask contains an adjacent pair of bits and no other bits.
-int RegMask::is_bound_pair() const {
- if( is_AllStack() ) return false;
-
+bool RegMask::is_bound_pair() const {
+ if (is_AllStack()) return false;
int bit = -1; // Set to hold the one bit allowed
- for( int i = 0; i < RM_SIZE; i++ ) {
- if( _A[i] ) { // Found some bits
- if( bit != -1 ) return false; // Already had bits, so fail
- bit = _A[i] & -(_A[i]); // Extract 1 bit from mask
- if( (bit << 1) != 0 ) { // Bit pair stays in same word?
- if( (bit | (bit<<1)) != _A[i] )
- return false; // Require adjacent bit pair and no more bits
- } else { // Else its a split-pair case
- if( bit != _A[i] ) return false; // Found many bits, so fail
- i++; // Skip iteration forward
- if( i >= RM_SIZE || _A[i] != 1 )
+ assert(valid_watermarks(), "sanity");
+ for (int i = _lwm; i <= _hwm; i++) {
+ if (_A[i]) { // Found some bits
+ if (bit != -1) return false; // Already had bits, so fail
+ bit = _A[i] & -(_A[i]); // Extract 1 bit from mask
+ if ((bit << 1) != 0) { // Bit pair stays in same word?
+ if ((bit | (bit<<1)) != _A[i])
+ return false; // Require adjacent bit pair and no more bits
+ } else { // Else its a split-pair case
+ if(bit != _A[i]) return false; // Found many bits, so fail
+ i++; // Skip iteration forward
+ if (i > _hwm || _A[i] != 1)
return false; // Require 1 lo bit in next word
}
}
@@ -153,32 +146,43 @@
return true;
}
+// Test for a single adjacent set of ideal register's size.
+bool RegMask::is_bound(uint ireg) const {
+ if (is_vector(ireg)) {
+ if (is_bound_set(num_registers(ireg)))
+ return true;
+ } else if (is_bound1() || is_bound_pair()) {
+ return true;
+ }
+ return false;
+}
+
// only indicies of power 2 are accessed, so index 3 is only filled in for storage.
static int low_bits[5] = { 0x55555555, 0x11111111, 0x01010101, 0x00000000, 0x00010001 };
-//------------------------------find_first_set---------------------------------
+
// Find the lowest-numbered register set in the mask. Return the
// HIGHEST register number in the set, or BAD if no sets.
// Works also for size 1.
OptoReg::Name RegMask::find_first_set(const int size) const {
- verify_sets(size);
- for (int i = 0; i < RM_SIZE; i++) {
+ assert(is_aligned_sets(size), "mask is not aligned, adjacent sets");
+ assert(valid_watermarks(), "sanity");
+ for (int i = _lwm; i <= _hwm; i++) {
if (_A[i]) { // Found some bits
- int bit = _A[i] & -_A[i]; // Extract low bit
// Convert to bit number, return hi bit in pair
- return OptoReg::Name((i<<_LogWordBits)+find_lowest_bit(bit)+(size-1));
+ return OptoReg::Name((i<<_LogWordBits) + find_lowest_bit(_A[i]) + (size - 1));
}
}
return OptoReg::Bad;
}
-//------------------------------clear_to_sets----------------------------------
// Clear out partial bits; leave only aligned adjacent bit pairs
void RegMask::clear_to_sets(const int size) {
if (size == 1) return;
assert(2 <= size && size <= 16, "update low bits table");
assert(is_power_of_2(size), "sanity");
+ assert(valid_watermarks(), "sanity");
int low_bits_mask = low_bits[size>>2];
- for (int i = 0; i < RM_SIZE; i++) {
+ for (int i = _lwm; i <= _hwm; i++) {
int bits = _A[i];
int sets = (bits & low_bits_mask);
for (int j = 1; j < size; j++) {
@@ -196,17 +200,17 @@
}
_A[i] = sets;
}
- verify_sets(size);
+ assert(is_aligned_sets(size), "mask is not aligned, adjacent sets");
}
-//------------------------------smear_to_sets----------------------------------
// Smear out partial bits to aligned adjacent bit sets
void RegMask::smear_to_sets(const int size) {
if (size == 1) return;
assert(2 <= size && size <= 16, "update low bits table");
assert(is_power_of_2(size), "sanity");
+ assert(valid_watermarks(), "sanity");
int low_bits_mask = low_bits[size>>2];
- for (int i = 0; i < RM_SIZE; i++) {
+ for (int i = _lwm; i <= _hwm; i++) {
int bits = _A[i];
int sets = 0;
for (int j = 0; j < size; j++) {
@@ -225,17 +229,17 @@
}
_A[i] = sets;
}
- verify_sets(size);
+ assert(is_aligned_sets(size), "mask is not aligned, adjacent sets");
}
-//------------------------------is_aligned_set--------------------------------
+// Assert that the register mask contains only bit sets.
bool RegMask::is_aligned_sets(const int size) const {
if (size == 1) return true;
assert(2 <= size && size <= 16, "update low bits table");
assert(is_power_of_2(size), "sanity");
int low_bits_mask = low_bits[size>>2];
- // Assert that the register mask contains only bit sets.
- for (int i = 0; i < RM_SIZE; i++) {
+ assert(valid_watermarks(), "sanity");
+ for (int i = _lwm; i <= _hwm; i++) {
int bits = _A[i];
while (bits) { // Check bits for pairing
int bit = bits & -bits; // Extract low bit
@@ -252,14 +256,14 @@
return true;
}
-//------------------------------is_bound_set-----------------------------------
// Return TRUE if the mask contains one adjacent set of bits and no other bits.
// Works also for size 1.
int RegMask::is_bound_set(const int size) const {
- if( is_AllStack() ) return false;
+ if (is_AllStack()) return false;
assert(1 <= size && size <= 16, "update low bits table");
+ assert(valid_watermarks(), "sanity");
int bit = -1; // Set to hold the one bit allowed
- for (int i = 0; i < RM_SIZE; i++) {
+ for (int i = _lwm; i <= _hwm; i++) {
if (_A[i] ) { // Found some bits
if (bit != -1)
return false; // Already had bits, so fail
@@ -279,7 +283,7 @@
int set = bit>>clear_bit_size;
set = set & -set; // Remove sign extension.
set = (((set << size) - 1) >> shift_back_size);
- if (i >= RM_SIZE || _A[i] != set)
+ if (i > _hwm || _A[i] != set)
return false; // Require expected low bits in next word
}
}
@@ -288,31 +292,29 @@
return true;
}
-//------------------------------is_UP------------------------------------------
// UP means register only, Register plus stack, or stack only is DOWN
bool RegMask::is_UP() const {
// Quick common case check for DOWN (any stack slot is legal)
- if( is_AllStack() )
+ if (is_AllStack())
return false;
// Slower check for any stack bits set (also DOWN)
- if( overlap(Matcher::STACK_ONLY_mask) )
+ if (overlap(Matcher::STACK_ONLY_mask))
return false;
// Not DOWN, so must be UP
return true;
}
-//------------------------------Size-------------------------------------------
// Compute size of register mask in bits
uint RegMask::Size() const {
uint sum = 0;
- for (int i = 0; i < RM_SIZE; i++) {
+ assert(valid_watermarks(), "sanity");
+ for (int i = _lwm; i <= _hwm; i++) {
sum += population_count(_A[i]);
}
return sum;
}
#ifndef PRODUCT
-//------------------------------print------------------------------------------
void RegMask::dump(outputStream *st) const {
st->print("[");
RegMask rm = *this; // Structure copy into local temp
--- a/src/hotspot/share/opto/regmask.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/opto/regmask.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -30,22 +30,6 @@
#include "utilities/count_leading_zeros.hpp"
#include "utilities/count_trailing_zeros.hpp"
-// Some fun naming (textual) substitutions:
-//
-// RegMask::get_low_elem() ==> RegMask::find_first_elem()
-// RegMask::Special ==> RegMask::Empty
-// RegMask::_flags ==> RegMask::is_AllStack()
-// RegMask::operator<<=() ==> RegMask::Insert()
-// RegMask::operator>>=() ==> RegMask::Remove()
-// RegMask::Union() ==> RegMask::OR
-// RegMask::Inter() ==> RegMask::AND
-//
-// OptoRegister::RegName ==> OptoReg::Name
-//
-// OptoReg::stack0() ==> _last_Mach_Reg or ZERO in core version
-//
-// numregs in chaitin ==> proper degree in chaitin
-
//-------------Non-zero bit search methods used by RegMask---------------------
// Find lowest 1, undefined if empty/0
static int find_lowest_bit(uint32_t mask) {
@@ -78,6 +62,12 @@
// is something like 90+ parameters.
int _A[RM_SIZE];
};
+ // The low and high water marks represents the lowest and highest word
+ // that might contain set register mask bits, respectively. We guarantee
+ // that there are no bits in words outside this range, but any word at
+ // and between the two marks can still be 0.
+ int _lwm;
+ int _hwm;
enum {
_WordBits = BitsPerInt,
@@ -85,7 +75,7 @@
_RM_SIZE = RM_SIZE // local constant, imported, then hidden by #undef
};
-public:
+ public:
enum { CHUNK_SIZE = RM_SIZE*_WordBits };
// SlotsPerLong is 2, since slots are 32 bits and longs are 64 bits.
@@ -113,28 +103,41 @@
# define BODY(I) int a##I,
FORALL_BODY
# undef BODY
- int dummy = 0 ) {
+ int dummy = 0) {
# define BODY(I) _A[I] = a##I;
FORALL_BODY
# undef BODY
+ _lwm = 0;
+ _hwm = RM_SIZE - 1;
+ while (_hwm > 0 && _A[_hwm] == 0) _hwm--;
+ while ((_lwm < _hwm) && _A[_lwm] == 0) _lwm++;
+ assert(valid_watermarks(), "post-condition");
}
// Handy copying constructor
- RegMask( RegMask *rm ) {
-# define BODY(I) _A[I] = rm->_A[I];
- FORALL_BODY
-# undef BODY
+ RegMask(RegMask *rm) {
+ _hwm = rm->_hwm;
+ _lwm = rm->_lwm;
+ for (int i = 0; i < RM_SIZE; i++) {
+ _A[i] = rm->_A[i];
+ }
+ assert(valid_watermarks(), "post-condition");
}
// Construct an empty mask
- RegMask( ) { Clear(); }
+ RegMask() {
+ Clear();
+ }
// Construct a mask with a single bit
- RegMask( OptoReg::Name reg ) { Clear(); Insert(reg); }
+ RegMask(OptoReg::Name reg) {
+ Clear();
+ Insert(reg);
+ }
// Check for register being in mask
- int Member( OptoReg::Name reg ) const {
- assert( reg < CHUNK_SIZE, "" );
+ int Member(OptoReg::Name reg) const {
+ assert(reg < CHUNK_SIZE, "");
return _A[reg>>_LogWordBits] & (1<<(reg&(_WordBits-1)));
}
@@ -152,56 +155,69 @@
void set_AllStack() { Insert(OptoReg::Name(CHUNK_SIZE-1)); }
// Test for being a not-empty mask.
- int is_NotEmpty( ) const {
+ int is_NotEmpty() const {
+ assert(valid_watermarks(), "sanity");
int tmp = 0;
-# define BODY(I) tmp |= _A[I];
- FORALL_BODY
-# undef BODY
+ for (int i = _lwm; i <= _hwm; i++) {
+ tmp |= _A[i];
+ }
return tmp;
}
// Find lowest-numbered register from mask, or BAD if mask is empty.
OptoReg::Name find_first_elem() const {
- int base, bits;
-# define BODY(I) if( (bits = _A[I]) != 0 ) base = I<<_LogWordBits; else
- FORALL_BODY
-# undef BODY
- { base = OptoReg::Bad; bits = 1<<0; }
- return OptoReg::Name(base + find_lowest_bit(bits));
+ assert(valid_watermarks(), "sanity");
+ for (int i = _lwm; i <= _hwm; i++) {
+ int bits = _A[i];
+ if (bits) {
+ return OptoReg::Name((i<<_LogWordBits) + find_lowest_bit(bits));
+ }
+ }
+ return OptoReg::Name(OptoReg::Bad);
}
+
// Get highest-numbered register from mask, or BAD if mask is empty.
OptoReg::Name find_last_elem() const {
- int base, bits;
-# define BODY(I) if( (bits = _A[RM_SIZE-1-I]) != 0 ) base = (RM_SIZE-1-I)<<_LogWordBits; else
- FORALL_BODY
-# undef BODY
- { base = OptoReg::Bad; bits = 1<<0; }
- return OptoReg::Name(base + find_highest_bit(bits));
+ assert(valid_watermarks(), "sanity");
+ for (int i = _hwm; i >= _lwm; i--) {
+ int bits = _A[i];
+ if (bits) {
+ return OptoReg::Name((i<<_LogWordBits) + find_highest_bit(bits));
+ }
+ }
+ return OptoReg::Name(OptoReg::Bad);
}
// Clear out partial bits; leave only aligned adjacent bit pairs.
void clear_to_pairs();
- // Verify that the mask contains only aligned adjacent bit pairs
- void verify_pairs() const { assert( is_aligned_pairs(), "mask is not aligned, adjacent pairs" ); }
+
+#ifdef ASSERT
+ // Verify watermarks are sane, i.e., within bounds and that no
+ // register words below or above the watermarks have bits set.
+ bool valid_watermarks() const {
+ assert(_hwm >= 0 && _hwm < RM_SIZE, "_hwm out of range: %d", _hwm);
+ assert(_lwm >= 0 && _lwm < RM_SIZE, "_lwm out of range: %d", _lwm);
+ for (int i = 0; i < _lwm; i++) {
+ assert(_A[i] == 0, "_lwm too high: %d regs at: %d", _lwm, i);
+ }
+ for (int i = _hwm + 1; i < RM_SIZE; i++) {
+ assert(_A[i] == 0, "_hwm too low: %d regs at: %d", _hwm, i);
+ }
+ return true;
+ }
+#endif // !ASSERT
+
// Test that the mask contains only aligned adjacent bit pairs
bool is_aligned_pairs() const;
// mask is a pair of misaligned registers
- bool is_misaligned_pair() const { return Size()==2 && !is_aligned_pairs(); }
+ bool is_misaligned_pair() const;
// Test for single register
- int is_bound1() const;
+ bool is_bound1() const;
// Test for a single adjacent pair
- int is_bound_pair() const;
+ bool is_bound_pair() const;
// Test for a single adjacent set of ideal register's size.
- int is_bound(uint ireg) const {
- if (is_vector(ireg)) {
- if (is_bound_set(num_registers(ireg)))
- return true;
- } else if (is_bound1() || is_bound_pair()) {
- return true;
- }
- return false;
- }
+ bool is_bound(uint ireg) const;
// Find the lowest-numbered register set in the mask. Return the
// HIGHEST register number in the set, or BAD if no sets.
@@ -212,8 +228,6 @@
void clear_to_sets(const int size);
// Smear out partial bits to aligned adjacent bit sets.
void smear_to_sets(const int size);
- // Verify that the mask contains only aligned adjacent bit sets
- void verify_sets(int size) const { assert(is_aligned_sets(size), "mask is not aligned, adjacent sets"); }
// Test that the mask contains only aligned adjacent bit sets
bool is_aligned_sets(const int size) const;
@@ -224,12 +238,15 @@
static int num_registers(uint ireg);
// Fast overlap test. Non-zero if any registers in common.
- int overlap( const RegMask &rm ) const {
- return
-# define BODY(I) (_A[I] & rm._A[I]) |
- FORALL_BODY
-# undef BODY
- 0 ;
+ int overlap(const RegMask &rm) const {
+ assert(valid_watermarks() && rm.valid_watermarks(), "sanity");
+ int hwm = MIN2(_hwm, rm._hwm);
+ int lwm = MAX2(_lwm, rm._lwm);
+ int result = 0;
+ for (int i = lwm; i <= hwm; i++) {
+ result |= _A[i] & rm._A[i];
+ }
+ return result;
}
// Special test for register pressure based splitting
@@ -237,50 +254,72 @@
bool is_UP() const;
// Clear a register mask
- void Clear( ) {
-# define BODY(I) _A[I] = 0;
- FORALL_BODY
-# undef BODY
+ void Clear() {
+ _lwm = RM_SIZE - 1;
+ _hwm = 0;
+ memset(_A, 0, sizeof(int)*RM_SIZE);
+ assert(valid_watermarks(), "sanity");
}
// Fill a register mask with 1's
- void Set_All( ) {
-# define BODY(I) _A[I] = -1;
- FORALL_BODY
-# undef BODY
+ void Set_All() {
+ _lwm = 0;
+ _hwm = RM_SIZE - 1;
+ memset(_A, 0xFF, sizeof(int)*RM_SIZE);
+ assert(valid_watermarks(), "sanity");
}
// Insert register into mask
- void Insert( OptoReg::Name reg ) {
- assert( reg < CHUNK_SIZE, "" );
- _A[reg>>_LogWordBits] |= (1<<(reg&(_WordBits-1)));
+ void Insert(OptoReg::Name reg) {
+ assert(reg < CHUNK_SIZE, "sanity");
+ assert(valid_watermarks(), "pre-condition");
+ int index = reg>>_LogWordBits;
+ if (index > _hwm) _hwm = index;
+ if (index < _lwm) _lwm = index;
+ _A[index] |= (1<<(reg&(_WordBits-1)));
+ assert(valid_watermarks(), "post-condition");
}
// Remove register from mask
- void Remove( OptoReg::Name reg ) {
- assert( reg < CHUNK_SIZE, "" );
+ void Remove(OptoReg::Name reg) {
+ assert(reg < CHUNK_SIZE, "");
_A[reg>>_LogWordBits] &= ~(1<<(reg&(_WordBits-1)));
}
// OR 'rm' into 'this'
- void OR( const RegMask &rm ) {
-# define BODY(I) this->_A[I] |= rm._A[I];
- FORALL_BODY
-# undef BODY
+ void OR(const RegMask &rm) {
+ assert(valid_watermarks() && rm.valid_watermarks(), "sanity");
+ // OR widens the live range
+ if (_lwm > rm._lwm) _lwm = rm._lwm;
+ if (_hwm < rm._hwm) _hwm = rm._hwm;
+ for (int i = _lwm; i <= _hwm; i++) {
+ _A[i] |= rm._A[i];
+ }
+ assert(valid_watermarks(), "sanity");
}
// AND 'rm' into 'this'
- void AND( const RegMask &rm ) {
-# define BODY(I) this->_A[I] &= rm._A[I];
- FORALL_BODY
-# undef BODY
+ void AND(const RegMask &rm) {
+ assert(valid_watermarks() && rm.valid_watermarks(), "sanity");
+ // Do not evaluate words outside the current watermark range, as they are
+ // already zero and an &= would not change that
+ for (int i = _lwm; i <= _hwm; i++) {
+ _A[i] &= rm._A[i];
+ }
+ // Narrow the watermarks if &rm spans a narrower range.
+ // Update after to ensure non-overlapping words are zeroed out.
+ if (_lwm < rm._lwm) _lwm = rm._lwm;
+ if (_hwm > rm._hwm) _hwm = rm._hwm;
}
// Subtract 'rm' from 'this'
- void SUBTRACT( const RegMask &rm ) {
-# define BODY(I) _A[I] &= ~rm._A[I];
- FORALL_BODY
-# undef BODY
+ void SUBTRACT(const RegMask &rm) {
+ assert(valid_watermarks() && rm.valid_watermarks(), "sanity");
+ int hwm = MIN2(_hwm, rm._hwm);
+ int lwm = MAX2(_lwm, rm._lwm);
+ for (int i = lwm; i <= hwm; i++) {
+ _A[i] &= ~rm._A[i];
+ }
}
// Compute size of register mask: number of bits
--- a/src/hotspot/share/opto/split_if.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/opto/split_if.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -523,7 +523,9 @@
}
_igvn.remove_dead_node(new_iff);
// Lazy replace IDOM info with the region's dominator
- lazy_replace( iff, region_dom );
+ lazy_replace(iff, region_dom);
+ lazy_update(region, region_dom); // idom must be update before handle_uses
+ region->set_req(0, NULL); // Break the self-cycle. Required for lazy_update to work on region
// Now make the original merge point go dead, by handling all its uses.
small_cache region_cache;
@@ -566,13 +568,8 @@
--k;
} // End of while merge point has phis
- assert(region->outcnt() == 1, "Only self reference should remain"); // Just Self on the Region
- region->set_req(0, NULL); // Break the self-cycle
+ _igvn.remove_dead_node(region);
- // Any leftover bits in the splitting block must not have depended on local
- // Phi inputs (these have already been split-up). Hence it's safe to hoist
- // these guys to the dominating point.
- lazy_replace( region, region_dom );
#ifndef PRODUCT
if( VerifyLoopOptimizations ) verify();
#endif
--- a/src/hotspot/share/opto/superword.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/opto/superword.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1209,9 +1209,47 @@
bool SuperWord::isomorphic(Node* s1, Node* s2) {
if (s1->Opcode() != s2->Opcode()) return false;
if (s1->req() != s2->req()) return false;
- if (s1->in(0) != s2->in(0)) return false;
if (!same_velt_type(s1, s2)) return false;
- return true;
+ Node* s1_ctrl = s1->in(0);
+ Node* s2_ctrl = s2->in(0);
+ // If the control nodes are equivalent, no further checks are required to test for isomorphism.
+ if (s1_ctrl == s2_ctrl) {
+ return true;
+ } else {
+ bool s1_ctrl_inv = ((s1_ctrl == NULL) ? true : lpt()->is_invariant(s1_ctrl));
+ bool s2_ctrl_inv = ((s2_ctrl == NULL) ? true : lpt()->is_invariant(s2_ctrl));
+ // If the control nodes are not invariant for the loop, fail isomorphism test.
+ if (!s1_ctrl_inv || !s2_ctrl_inv) {
+ return false;
+ }
+ if(s1_ctrl != NULL && s2_ctrl != NULL) {
+ if (s1_ctrl->is_Proj()) {
+ s1_ctrl = s1_ctrl->in(0);
+ assert(lpt()->is_invariant(s1_ctrl), "must be invariant");
+ }
+ if (s2_ctrl->is_Proj()) {
+ s2_ctrl = s2_ctrl->in(0);
+ assert(lpt()->is_invariant(s2_ctrl), "must be invariant");
+ }
+ if (!s1_ctrl->is_RangeCheck() || !s2_ctrl->is_RangeCheck()) {
+ return false;
+ }
+ }
+ // Control nodes are invariant. However, we have no way of checking whether they resolve
+ // in an equivalent manner. But, we know that invariant range checks are guaranteed to
+ // throw before the loop (if they would have thrown). Thus, the loop would not have been reached.
+ // Therefore, if the control nodes for both are range checks, we accept them to be isomorphic.
+ for (DUIterator_Fast imax, i = s1->fast_outs(imax); i < imax; i++) {
+ Node* t1 = s1->fast_out(i);
+ for (DUIterator_Fast jmax, j = s2->fast_outs(jmax); j < jmax; j++) {
+ Node* t2 = s2->fast_out(j);
+ if (VectorNode::is_muladds2i(t1) && VectorNode::is_muladds2i(t2)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
}
//------------------------------independent---------------------------
--- a/src/hotspot/share/prims/evmCompat.cpp Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
- * 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 "utilities/debug.hpp"
-
-// This file contains definitions for functions that exist
-// in the ExactVM, but not in HotSpot. They are stubbed out
-// here to prevent linker errors when attempting to use HotSpot
-// with the ExactVM jdk.
-
-extern "C" void JVM_Process_DestroyProcess(void);
-extern "C" void JVM_Process_ForkAndExec(void);
-extern "C" void JVM_Process_WaitForProcessExit(void);
-extern "C" void gc(void);
-
-void JVM_Process_DestroyProcess(void) {
- ShouldNotReachHere();
-}
-
-void JVM_Process_ForkAndExec(void) {
- ShouldNotReachHere();
-}
-
-void JVM_Process_WaitForProcessExit(void) {
- ShouldNotReachHere();
-}
-
-void gc(void) {
- ShouldNotReachHere();
-}
--- a/src/hotspot/share/prims/whitebox.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/prims/whitebox.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -483,7 +483,7 @@
#if INCLUDE_G1GC
if (UseG1GC) {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
- if (g1h->g1_collector_policy()->is_hetero_heap()) {
+ if (g1h->is_heterogeneous_heap()) {
uint start_region = HeterogeneousHeapRegionManager::manager()->start_index_of_dram();
return (jlong)(g1h->base() + start_region * HeapRegion::GrainBytes);
} else {
@@ -509,7 +509,7 @@
#if INCLUDE_G1GC
if (UseG1GC) {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
- if (g1h->g1_collector_policy()->is_hetero_heap()) {
+ if (g1h->is_heterogeneous_heap()) {
uint end_region = HeterogeneousHeapRegionManager::manager()->end_index_of_dram();
return (jlong)(g1h->base() + (end_region + 1) * HeapRegion::GrainBytes - 1);
} else {
@@ -535,7 +535,7 @@
#if INCLUDE_G1GC
if (UseG1GC) {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
- if (g1h->g1_collector_policy()->is_hetero_heap()) {
+ if (g1h->is_heterogeneous_heap()) {
uint start_region = HeterogeneousHeapRegionManager::manager()->start_index_of_nvdimm();
return (jlong)(g1h->base() + start_region * HeapRegion::GrainBytes);
} else {
@@ -561,7 +561,7 @@
#if INCLUDE_G1GC
if (UseG1GC) {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
- if (g1h->g1_collector_policy()->is_hetero_heap()) {
+ if (g1h->is_heterogeneous_heap()) {
uint end_region = HeterogeneousHeapRegionManager::manager()->start_index_of_nvdimm();
return (jlong)(g1h->base() + (end_region + 1) * HeapRegion::GrainBytes - 1);
} else {
--- a/src/hotspot/share/runtime/arguments.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/arguments.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -530,6 +530,7 @@
{ "UseMembar", JDK_Version::jdk(10), JDK_Version::jdk(12), JDK_Version::undefined() },
{ "CompilationPolicyChoice", JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::undefined() },
{ "FailOverToOldVerifier", JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::undefined() },
+ { "ThreadLocalHandshakes", JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::jdk(15) },
// --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
{ "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
--- a/src/hotspot/share/runtime/compilationPolicy.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/compilationPolicy.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -176,6 +176,14 @@
}
CompileTask* CompilationPolicy::select_task_helper(CompileQueue* compile_queue) {
+ // Remove unloaded methods from the queue
+ for (CompileTask* task = compile_queue->first(); task != NULL; ) {
+ CompileTask* next = task->next();
+ if (task->is_unloaded()) {
+ compile_queue->remove_and_mark_stale(task);
+ }
+ task = next;
+ }
#if INCLUDE_JVMCI
if (UseJVMCICompiler && !BackgroundCompilation) {
/*
--- a/src/hotspot/share/runtime/globals.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/globals.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -367,7 +367,7 @@
"Print out every time compilation is longer than " \
"a given threshold") \
\
- develop(bool, SafepointALot, false, \
+ diagnostic(bool, SafepointALot, false, \
"Generate a lot of safepoints. This works with " \
"GuaranteedSafepointInterval") \
\
@@ -651,9 +651,6 @@
develop(bool, BreakAtWarning, false, \
"Execute breakpoint upon encountering VM warning") \
\
- develop(bool, UseFakeTimers, false, \
- "Tell whether the VM should use system time or a fake timer") \
- \
product(ccstr, NativeMemoryTracking, "off", \
"Native memory tracking options") \
\
@@ -2525,8 +2522,9 @@
"File of size Xmx is pre-allocated for performance reason, so" \
"we need that much space available") \
\
- develop(bool, VerifyMetaspace, false, \
- "Verify metaspace on chunk movements.") \
+ develop(int, VerifyMetaspaceInterval, DEBUG_ONLY(500) NOT_DEBUG(0), \
+ "Run periodic metaspace verifications (0 - none, " \
+ "1 - always, >1 every nth interval)") \
\
diagnostic(bool, ShowRegistersOnAssert, true, \
"On internal errors, include registers in error report.") \
--- a/src/hotspot/share/runtime/handshake.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/handshake.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -288,13 +288,14 @@
assert(Thread::current() == thread, "should call from thread");
assert(!thread->is_terminated(), "should not be a terminated thread");
- CautiouslyPreserveExceptionMark pem(thread);
ThreadInVMForHandshake tivm(thread);
if (!_semaphore.trywait()) {
_semaphore.wait_with_safepoint_check(thread);
}
HandshakeOperation* op = OrderAccess::load_acquire(&_operation);
if (op != NULL) {
+ HandleMark hm(thread);
+ CautiouslyPreserveExceptionMark pem(thread);
// Disarm before execute the operation
clear_handshake(thread);
op->do_handshake(thread);
--- a/src/hotspot/share/runtime/mutexLocker.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/mutexLocker.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -39,6 +39,7 @@
Mutex* Patching_lock = NULL;
Monitor* SystemDictionary_lock = NULL;
+Mutex* ProtectionDomainSet_lock = NULL;
Mutex* SharedDictionary_lock = NULL;
Mutex* Module_lock = NULL;
Mutex* CompiledIC_lock = NULL;
@@ -79,7 +80,6 @@
Monitor* STS_lock = NULL;
Monitor* FullGCCount_lock = NULL;
Monitor* SATB_Q_CBL_mon = NULL;
-Mutex* Shared_SATB_Q_lock = NULL;
Monitor* DirtyCardQ_CBL_mon = NULL;
Mutex* Shared_DirtyCardQ_lock = NULL;
Mutex* MarkStackFreeList_lock = NULL;
@@ -215,7 +215,6 @@
}
if (UseG1GC) {
def(SATB_Q_CBL_mon , PaddedMonitor, access, true, Monitor::_safepoint_check_never);
- def(Shared_SATB_Q_lock , PaddedMutex , access + 1, true, Monitor::_safepoint_check_never);
def(DirtyCardQ_CBL_mon , PaddedMonitor, access, true, Monitor::_safepoint_check_never);
def(Shared_DirtyCardQ_lock , PaddedMutex , access + 1, true, Monitor::_safepoint_check_never);
@@ -234,7 +233,6 @@
}
if (UseShenandoahGC) {
def(SATB_Q_CBL_mon , PaddedMonitor, access, true, Monitor::_safepoint_check_never);
- def(Shared_SATB_Q_lock , PaddedMutex , access + 1, true, Monitor::_safepoint_check_never);
def(StringDedupQueue_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_never);
def(StringDedupTable_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
@@ -254,6 +252,7 @@
def(JmethodIdCreation_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // used for creating jmethodIDs.
def(SystemDictionary_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_always); // lookups done by VM thread
+ def(ProtectionDomainSet_lock , PaddedMutex , leaf-1, true, Monitor::_safepoint_check_never);
def(SharedDictionary_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // lookups done by VM thread
def(Module_lock , PaddedMutex , leaf+2, true, Monitor::_safepoint_check_always);
def(InlineCacheBuffer_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
--- a/src/hotspot/share/runtime/mutexLocker.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/mutexLocker.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -33,6 +33,7 @@
extern Mutex* Patching_lock; // a lock used to guard code patching of compiled code
extern Monitor* SystemDictionary_lock; // a lock on the system dictionary
+extern Mutex* ProtectionDomainSet_lock; // a lock on the pd_set list in the system dictionary
extern Mutex* SharedDictionary_lock; // a lock on the CDS shared dictionary
extern Mutex* Module_lock; // a lock on module and package related data structures
extern Mutex* CompiledIC_lock; // a lock used to guard compiled IC patching and access
@@ -77,10 +78,6 @@
extern Monitor* FullGCCount_lock; // in support of "concurrent" full gc
extern Monitor* SATB_Q_CBL_mon; // Protects SATB Q
// completed buffer queue.
-extern Mutex* Shared_SATB_Q_lock; // Lock protecting SATB
- // queue shared by
- // non-Java threads.
-
extern Monitor* DirtyCardQ_CBL_mon; // Protects dirty card Q
// completed buffer queue.
extern Mutex* Shared_DirtyCardQ_lock; // Lock protecting dirty card
--- a/src/hotspot/share/runtime/os.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/os.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -873,6 +873,8 @@
void os::print_hex_dump(outputStream* st, address start, address end, int unitsize) {
assert(unitsize == 1 || unitsize == 2 || unitsize == 4 || unitsize == 8, "just checking");
+ start = align_down(start, unitsize);
+
int cols = 0;
int cols_per_line = 0;
switch (unitsize) {
--- a/src/hotspot/share/runtime/os.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/os.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -463,6 +463,9 @@
static void pd_start_thread(Thread* thread);
static void start_thread(Thread* thread);
+ // Returns true if successful.
+ static bool signal_thread(Thread* thread, int sig, const char* reason);
+
static void free_thread(OSThread* osthread);
// thread id on Linux/64bit is 64bit, on Windows and Solaris, it's 32bit
@@ -637,6 +640,7 @@
static void print_environment_variables(outputStream* st, const char** env_list);
static void print_context(outputStream* st, const void* context);
static void print_register_info(outputStream* st, const void* context);
+ static bool signal_sent_by_kill(const void* siginfo);
static void print_siginfo(outputStream* st, const void* siginfo);
static void print_signal_handlers(outputStream* st, char* buf, size_t buflen);
static void print_date_and_time(outputStream* st, char* buf, size_t buflen);
--- a/src/hotspot/share/runtime/relocator.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/relocator.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -28,6 +28,7 @@
#include "memory/metadataFactory.hpp"
#include "memory/oopFactory.hpp"
#include "memory/universe.hpp"
+#include "oops/method.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/relocator.hpp"
--- a/src/hotspot/share/runtime/safepoint.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/safepoint.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -902,6 +902,16 @@
// To debug the long safepoint, specify both AbortVMOnSafepointTimeout &
// ShowMessageBoxOnError.
if (AbortVMOnSafepointTimeout) {
+ // Send the blocking thread a signal to terminate and write an error file.
+ for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur_thread = jtiwh.next(); ) {
+ if (cur_thread->safepoint_state()->is_running()) {
+ if (!os::signal_thread(cur_thread, SIGILL, "blocking a safepoint")) {
+ break; // Could not send signal. Report fatal error.
+ }
+ // Give cur_thread a chance to report the error and terminate the VM.
+ os::sleep(Thread::current(), 3000, false);
+ }
+ }
fatal("Safepoint sync time longer than " INTX_FORMAT "ms detected when executing %s.",
SafepointTimeoutDelay, VMThread::vm_operation()->name());
}
@@ -1121,6 +1131,7 @@
jlong SafepointTracing::_last_safepoint_sync_time_ns = 0;
jlong SafepointTracing::_last_safepoint_cleanup_time_ns = 0;
jlong SafepointTracing::_last_safepoint_end_time_ns = 0;
+jlong SafepointTracing::_last_safepoint_end_time_epoch_ms = 0;
jlong SafepointTracing::_last_app_time_ns = 0;
int SafepointTracing::_nof_threads = 0;
int SafepointTracing::_nof_running = 0;
@@ -1133,6 +1144,8 @@
void SafepointTracing::init() {
// Application start
_last_safepoint_end_time_ns = os::javaTimeNanos();
+ // amount of time since epoch
+ _last_safepoint_end_time_epoch_ms = os::javaTimeMillis();
}
// Helper method to print the header.
@@ -1232,6 +1245,8 @@
void SafepointTracing::end() {
_last_safepoint_end_time_ns = os::javaTimeNanos();
+ // amount of time since epoch
+ _last_safepoint_end_time_epoch_ms = os::javaTimeMillis();
if (_max_sync_time < (_last_safepoint_sync_time_ns - _last_safepoint_begin_time_ns)) {
_max_sync_time = _last_safepoint_sync_time_ns - _last_safepoint_begin_time_ns;
--- a/src/hotspot/share/runtime/safepoint.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/safepoint.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -240,6 +240,8 @@
static jlong _last_safepoint_sync_time_ns;
static jlong _last_safepoint_cleanup_time_ns;
static jlong _last_safepoint_end_time_ns;
+ // amount of ms since epoch
+ static jlong _last_safepoint_end_time_epoch_ms;
// Relative
static jlong _last_app_time_ns;
@@ -268,8 +270,8 @@
return (os::javaTimeNanos() - _last_safepoint_end_time_ns) / (NANOUNITS / MILLIUNITS);
}
- static jlong end_of_last_safepoint_ms() {
- return _last_safepoint_end_time_ns / (NANOUNITS / MILLIUNITS);
+ static jlong end_of_last_safepoint_epoch_ms() {
+ return _last_safepoint_end_time_epoch_ms;
}
static jlong start_of_safepoint() {
--- a/src/hotspot/share/runtime/sharedRuntime.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1376,12 +1376,18 @@
}
#endif
- // Do not patch call site for static call when the class is not
- // fully initialized.
- if (invoke_code == Bytecodes::_invokestatic &&
- !callee_method->method_holder()->is_initialized()) {
- assert(callee_method->method_holder()->is_linked(), "must be");
- return callee_method;
+ // Do not patch call site for static call to another class
+ // when the class is not fully initialized.
+ if (invoke_code == Bytecodes::_invokestatic) {
+ if (!callee_method->method_holder()->is_initialized() &&
+ callee_method->method_holder() != caller_nm->method()->method_holder()) {
+ assert(callee_method->method_holder()->is_linked(), "must be");
+ return callee_method;
+ } else {
+ assert(callee_method->method_holder()->is_initialized() ||
+ callee_method->method_holder()->is_reentrant_initialization(thread),
+ "invalid class initialization state for invoke_static");
+ }
}
// JSR 292 key invariant:
--- a/src/hotspot/share/runtime/thread.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/thread.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1311,7 +1311,9 @@
}
void NonJavaThread::pre_run() {
+ // Initialize BarrierSet-related data before adding to list.
assert(BarrierSet::barrier_set() != NULL, "invariant");
+ BarrierSet::barrier_set()->on_thread_attach(this);
add_to_the_list();
// This is slightly odd in that NamedThread is a subclass, but
@@ -1322,6 +1324,8 @@
void NonJavaThread::post_run() {
JFR_ONLY(Jfr::on_thread_exit(this);)
+ // Clean up BarrierSet data before removing from list.
+ BarrierSet::barrier_set()->on_thread_detach(this);
remove_from_the_list();
// Ensure thread-local-storage is cleared before termination.
Thread::clear_thread_current();
@@ -4769,7 +4773,7 @@
print_threads_compiling(st, buf, buflen);
}
-void Threads::print_threads_compiling(outputStream* st, char* buf, int buflen) {
+void Threads::print_threads_compiling(outputStream* st, char* buf, int buflen, bool short_form) {
ALL_JAVA_THREADS(thread) {
if (thread->is_Compiler_thread()) {
CompilerThread* ct = (CompilerThread*) thread;
@@ -4782,7 +4786,7 @@
if (task != NULL) {
thread->print_name_on_error(st, buf, buflen);
st->print(" ");
- task->print(st, NULL, true, true);
+ task->print(st, NULL, short_form, true);
}
}
}
--- a/src/hotspot/share/runtime/thread.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/thread.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -2298,7 +2298,7 @@
static void print_on_error(outputStream* st, Thread* current, char* buf, int buflen);
static void print_on_error(Thread* this_thread, outputStream* st, Thread* current, char* buf,
int buflen, bool* found_current);
- static void print_threads_compiling(outputStream* st, char* buf, int buflen);
+ static void print_threads_compiling(outputStream* st, char* buf, int buflen, bool short_form = false);
// Get Java threads that are waiting to enter a monitor.
static GrowableArray<JavaThread*>* get_pending_threads(ThreadsList * t_list,
--- a/src/hotspot/share/runtime/tieredThresholdPolicy.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/runtime/tieredThresholdPolicy.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -295,28 +295,24 @@
for (CompileTask* task = compile_queue->first(); task != NULL;) {
CompileTask* next_task = task->next();
Method* method = task->method();
+ // If a method was unloaded or has been stale for some time, remove it from the queue.
+ // Blocking tasks and tasks submitted from whitebox API don't become stale
+ if (task->is_unloaded() || (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method))) {
+ if (!task->is_unloaded()) {
+ if (PrintTieredEvents) {
+ print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel) task->comp_level());
+ }
+ method->clear_queued_for_compilation();
+ }
+ compile_queue->remove_and_mark_stale(task);
+ task = next_task;
+ continue;
+ }
update_rate(t, method);
- if (max_task == NULL) {
+ if (max_task == NULL || compare_methods(method, max_method)) {
+ // Select a method with the highest rate
max_task = task;
max_method = method;
- } else {
- // If a method has been stale for some time, remove it from the queue.
- // Blocking tasks and tasks submitted from whitebox API don't become stale
- if (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
- if (PrintTieredEvents) {
- print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
- }
- compile_queue->remove_and_mark_stale(task);
- method->clear_queued_for_compilation();
- task = next_task;
- continue;
- }
-
- // Select a method with a higher rate
- if (compare_methods(method, max_method)) {
- max_task = task;
- max_method = method;
- }
}
if (task->is_blocking()) {
@@ -479,7 +475,7 @@
// We don't update the rate if we've just came out of a safepoint.
// delta_s is the time since last safepoint in milliseconds.
- jlong delta_s = t - SafepointTracing::end_of_last_safepoint_ms();
+ jlong delta_s = t - SafepointTracing::end_of_last_safepoint_epoch_ms();
jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement
// How many events were there since the last time?
int event_count = m->invocation_count() + m->backedge_count();
@@ -501,10 +497,10 @@
}
}
-// Check if this method has been stale from a given number of milliseconds.
+// Check if this method has been stale for a given number of milliseconds.
// See select_task().
bool TieredThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) {
- jlong delta_s = t - SafepointTracing::end_of_last_safepoint_ms();
+ jlong delta_s = t - SafepointTracing::end_of_last_safepoint_epoch_ms();
jlong delta_t = t - m->prev_time();
if (delta_t > timeout && delta_s > timeout) {
int event_count = m->invocation_count() + m->backedge_count();
--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp Sat Mar 09 12:54:20 2019 +0000
@@ -269,6 +269,9 @@
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55382 and
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53017
//
-#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned(x+0)))
+// GCC versions older than 4.6.4 would fail even with "+0", and needs additional
+// cast to typeof(x) to work around the similar bug.
+//
+#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned((typeof(x))x+0)))
#endif // SHARE_UTILITIES_GLOBALDEFINITIONS_GCC_HPP
--- a/src/hotspot/share/utilities/intHisto.cpp Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 "utilities/intHisto.hpp"
-
-IntHistogram::IntHistogram(int est, int max) : _max(max), _tot(0) {
- assert(0 <= est && est <= max, "Preconditions");
- _elements = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<int>(est, true);
- guarantee(_elements != NULL, "alloc failure");
-}
-
-void IntHistogram::add_entry(int outcome) {
- if (outcome > _max) outcome = _max;
- int new_count = _elements->at_grow(outcome) + 1;
- _elements->at_put(outcome, new_count);
- _tot++;
-}
-
-int IntHistogram::entries_for_outcome(int outcome) {
- return _elements->at_grow(outcome);
-}
-
-void IntHistogram::print_on(outputStream* st) const {
- double tot_d = (double)_tot;
- st->print_cr("Outcome # of occurrences %% of occurrences");
- st->print_cr("-----------------------------------------------");
- for (int i=0; i < _elements->length()-2; i++) {
- int cnt = _elements->at(i);
- if (cnt != 0) {
- st->print_cr("%7d %10d %8.4f",
- i, cnt, (double)cnt/tot_d);
- }
- }
- // Does it have any max entries?
- if (_elements->length()-1 == _max) {
- int cnt = _elements->at(_max);
- st->print_cr(">= %4d %10d %8.4f",
- _max, cnt, (double)cnt/tot_d);
- }
- st->print_cr("-----------------------------------------------");
- st->print_cr(" All %10d %8.4f", _tot, 1.0);
-}
--- a/src/hotspot/share/utilities/intHisto.hpp Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
- * 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_UTILITIES_INTHISTO_HPP
-#define SHARE_UTILITIES_INTHISTO_HPP
-
-#include "memory/allocation.hpp"
-#include "utilities/growableArray.hpp"
-
-// This class implements a simple histogram.
-
-// A histogram summarizes a series of "measurements", each of which is
-// assumed (required in this implementation) to have an outcome that is a
-// non-negative integer. The histogram efficiently maps measurement outcomes
-// to the number of measurements had that outcome.
-
-// To print the results, invoke print() on your Histogram*.
-
-// Note: there is already an existing "Histogram" class, in file
-// histogram.{hpp,cpp}, but to my mind that's not a histogram, it's a table
-// mapping strings to counts. To be a histogram (IMHO) it needs to map
-// numbers (in fact, integers) to number of occurrences of that number.
-
-// ysr: (i am not sure i agree with the above note.) i suspect we want to have a
-// histogram template that will map an arbitrary type (with a defined order
-// relation) to a count.
-
-
-class IntHistogram : public CHeapObj<mtInternal> {
- protected:
- int _max;
- int _tot;
- GrowableArray<int>* _elements;
-
-public:
- // Create a new, empty table. "est" is an estimate of the maximum outcome
- // that will be added, and "max" is an outcome such that all outcomes at
- // least that large will be bundled with it.
- IntHistogram(int est, int max);
- // Add a measurement with the given outcome to the sequence.
- void add_entry(int outcome);
- // Return the number of entries recorded so far with the given outcome.
- int entries_for_outcome(int outcome);
- // Return the total number of entries recorded so far.
- int total_entries() { return _tot; }
- // Return the number of entries recorded so far with the given outcome as
- // a fraction of the total number recorded so far.
- double fraction_for_outcome(int outcome) {
- return
- (double)entries_for_outcome(outcome)/
- (double)total_entries();
- }
- // Print the histogram on the given output stream.
- void print_on(outputStream* st) const;
-};
-
-#endif // SHARE_UTILITIES_INTHISTO_HPP
--- a/src/hotspot/share/utilities/vmError.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/src/hotspot/share/utilities/vmError.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -522,6 +522,9 @@
st->print("%s", buf);
st->print(" (0x%x)", _id); // signal number
st->print(" at pc=" PTR_FORMAT, p2i(_pc));
+ if (_siginfo != NULL && os::signal_sent_by_kill(_siginfo)) {
+ st->print(" (sent by kill)");
+ }
} else {
if (should_report_bug(_id)) {
st->print("Internal Error");
--- a/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java Sat Mar 09 12:54:20 2019 +0000
@@ -19,7 +19,6 @@
* 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.
*/
--- a/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java Sat Mar 09 12:54:20 2019 +0000
@@ -399,7 +399,6 @@
if (len > TRIGGERLEN) {
int i = 0;
int tlen; // incremental lengths
- // 96bit CTR x86 intrinsic
final int plen = AES_BLOCK_SIZE * 6;
// arbitrary formula to aid intrinsic without reaching buffer end
final int count = len / 1024;
@@ -419,11 +418,11 @@
gctrPAndC.doFinal(in, inOfs, ilen, out, outOfs);
processed += ilen;
- int lastLen = len % AES_BLOCK_SIZE;
+ int lastLen = ilen % AES_BLOCK_SIZE;
if (lastLen != 0) {
- ghashAllToS.update(ct, ctOfs, len - lastLen);
+ ghashAllToS.update(ct, ctOfs, ilen - lastLen);
ghashAllToS.update(
- expandToOneBlock(ct, (ctOfs + len - lastLen), lastLen));
+ expandToOneBlock(ct, (ctOfs + ilen - lastLen), lastLen));
} else {
ghashAllToS.update(ct, ctOfs, ilen);
}
--- a/src/java.base/share/classes/com/sun/net/ssl/HostnameVerifier.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.HostnameVerifier
- */
-
-package com.sun.net.ssl;
-
-/**
- * HostnameVerifier provides a callback mechanism so that
- * implementers of this interface can supply a policy for
- * handling the case where the host to connect to and
- * the server name from the certificate mismatch.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.HostnameVerifier} and
- * {@link javax.net.ssl.CertificateHostnameVerifier}.
- */
-@Deprecated(since="1.4")
-public interface HostnameVerifier {
- /**
- * Verify that the hostname from the URL is an acceptable
- * match with the value from the common name entry in the
- * server certificate's distinguished name.
- *
- * @param urlHostname the host name of the URL
- * @param certHostname the common name entry from the certificate
- * @return true if the certificate host name is acceptable
- */
- public boolean verify(String urlHostname, String certHostname);
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/HttpsURLConnection.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,203 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.HttpsURLConnection
- */
-
-package com.sun.net.ssl;
-
-import java.net.URL;
-import java.net.HttpURLConnection;
-import java.io.IOException;
-import java.security.cert.Certificate;
-import javax.net.SocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.SSLPeerUnverifiedException;
-
-/**
- * HTTP URL connection with support for HTTPS-specific features. See
- * <A HREF="http://www.w3.org/pub/WWW/Protocols/"> the spec </A> for
- * details.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.HttpsURLConnection}.
- */
-@Deprecated(since="1.4")
-public abstract
-class HttpsURLConnection extends HttpURLConnection
-{
- /*
- * Initialize an HTTPS URLConnection ... could check that the URL
- * is an "https" URL, and that the handler is also an HTTPS one,
- * but that's established by other code in this package.
- * @param url the URL
- */
- public HttpsURLConnection(URL url) throws IOException {
- super(url);
- }
-
- /**
- * Returns the cipher suite in use on this connection.
- * @return the cipher suite
- */
- public abstract String getCipherSuite();
-
- /**
- * Returns the server's X.509 certificate chain, or null if
- * the server did not authenticate.
- * <P>
- * Note: The returned value may not be a valid certificate chain
- * and should not be relied on for trust decisions.
- *
- * @return the server certificate chain
- */
- public abstract Certificate[] getServerCertificates()
- throws SSLPeerUnverifiedException;
-
- /**
- * HostnameVerifier provides a callback mechanism so that
- * implementers of this interface can supply a policy for
- * handling the case where the host to connect to and
- * the server name from the certificate mismatch.
- *
- * The default implementation will deny such connections.
- */
- private static HostnameVerifier defaultHostnameVerifier =
- new HostnameVerifier() {
- public boolean verify(String urlHostname, String certHostname) {
- return false;
- }
- };
-
- protected HostnameVerifier hostnameVerifier = defaultHostnameVerifier;
-
- /**
- * Sets the default HostnameVerifier inherited when an instance
- * of this class is created.
- * @param v the default host name verifier
- */
- public static void setDefaultHostnameVerifier(HostnameVerifier v) {
- if (v == null) {
- throw new IllegalArgumentException(
- "no default HostnameVerifier specified");
- }
-
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new SSLPermission("setHostnameVerifier"));
- }
- defaultHostnameVerifier = v;
- }
-
- /**
- * Gets the default HostnameVerifier.
- * @return the default host name verifier
- */
- public static HostnameVerifier getDefaultHostnameVerifier() {
- return defaultHostnameVerifier;
- }
-
- /**
- * Sets the HostnameVerifier.
- * @param v the host name verifier
- */
- public void setHostnameVerifier(HostnameVerifier v) {
- if (v == null) {
- throw new IllegalArgumentException(
- "no HostnameVerifier specified");
- }
-
- hostnameVerifier = v;
- }
-
- /**
- * Gets the HostnameVerifier.
- * @return the host name verifier
- */
- public HostnameVerifier getHostnameVerifier() {
- return hostnameVerifier;
- }
-
- private static SSLSocketFactory defaultSSLSocketFactory = null;
-
- private SSLSocketFactory sslSocketFactory = getDefaultSSLSocketFactory();
-
- /**
- * Sets the default SSL socket factory inherited when an instance
- * of this class is created.
- * @param sf the default SSL socket factory
- */
- public static void setDefaultSSLSocketFactory(SSLSocketFactory sf) {
- if (sf == null) {
- throw new IllegalArgumentException(
- "no default SSLSocketFactory specified");
- }
-
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkSetFactory();
- }
- defaultSSLSocketFactory = sf;
- }
-
- /**
- * Gets the default SSL socket factory.
- * @return the default SSL socket factory
- */
- public static SSLSocketFactory getDefaultSSLSocketFactory() {
- if (defaultSSLSocketFactory == null) {
- defaultSSLSocketFactory =
- (SSLSocketFactory)SSLSocketFactory.getDefault();
- }
- return defaultSSLSocketFactory;
- }
-
- /**
- * Sets the SSL socket factory.
- * @param sf the SSL socket factory
- */
- public void setSSLSocketFactory(SSLSocketFactory sf) {
- if (sf == null) {
- throw new IllegalArgumentException(
- "no SSLSocketFactory specified");
- }
-
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkSetFactory();
- }
-
- sslSocketFactory = sf;
- }
-
- /**
- * Gets the SSL socket factory.
- * @return the SSL socket factory
- */
- public SSLSocketFactory getSSLSocketFactory() {
- return sslSocketFactory;
- }
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/KeyManager.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.KeyManager
- */
-
-package com.sun.net.ssl;
-
-/**
- * Base interface for JSSE key managers. These manage the
- * key material which is used to authenticate to the peer
- * of a secure socket.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.KeyManager}.
- */
-@Deprecated(since="1.4")
-public interface KeyManager {
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactory.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,220 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.KeyManagerFactory
- */
-
-package com.sun.net.ssl;
-
-import java.security.*;
-
-/**
- * This class acts as a factory for key managers based on a
- * source of key material. Each key manager manages a specific
- * type of key material for use by secure sockets. The key
- * material is based on a KeyStore and/or provider specific sources.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.KeyManagerFactory}.
- */
-@Deprecated(since="1.4")
-public class KeyManagerFactory {
- // The provider
- private Provider provider;
-
- // The provider implementation (delegate)
- private KeyManagerFactorySpi factorySpi;
-
- // The name of the key management algorithm.
- private String algorithm;
-
- /**
- * <p>The default KeyManager can be changed by setting the value of the
- * {@code sun.ssl.keymanager.type} security property to the desired name.
- *
- * @return the default type as specified by the
- * {@code sun.ssl.keymanager.type} security property, or an
- * implementation-specific default if no such property exists.
- *
- * @see java.security.Security security properties
- */
- public static final String getDefaultAlgorithm() {
- String type;
- type = AccessController.doPrivileged(new PrivilegedAction<>() {
- public String run() {
- return Security.getProperty("sun.ssl.keymanager.type");
- }
- });
- if (type == null) {
- type = "SunX509";
- }
- return type;
-
- }
-
- /**
- * Creates a KeyManagerFactory object.
- *
- * @param factorySpi the delegate
- * @param provider the provider
- * @param algorithm the algorithm
- */
- protected KeyManagerFactory(KeyManagerFactorySpi factorySpi,
- Provider provider, String algorithm) {
- this.factorySpi = factorySpi;
- this.provider = provider;
- this.algorithm = algorithm;
- }
-
- /**
- * Returns the algorithm name of this <code>KeyManagerFactory</code> object.
- *
- * <p>This is the same name that was specified in one of the
- * <code>getInstance</code> calls that created this
- * <code>KeyManagerFactory</code> object.
- *
- * @return the algorithm name of this <code>KeyManagerFactory</code> object.
- */
- public final String getAlgorithm() {
- return this.algorithm;
- }
-
- /**
- * Generates a <code>KeyManagerFactory</code> object that implements the
- * specified key management algorithm.
- * If the default provider package provides an implementation of the
- * requested key management algorithm, an instance of
- * <code>KeyManagerFactory</code> containing that implementation is
- * returned. If the algorithm is not available in the default provider
- * package, other provider packages are searched.
- *
- * @param algorithm the standard name of the requested
- * algorithm.
- *
- * @return the new <code>KeyManagerFactory</code> object
- *
- * @exception NoSuchAlgorithmException if the specified algorithm is not
- * available in the default provider package or any of the other provider
- * packages that were searched.
- */
- public static final KeyManagerFactory getInstance(String algorithm)
- throws NoSuchAlgorithmException
- {
- try {
- Object[] objs = SSLSecurity.getImpl(algorithm, "KeyManagerFactory",
- (String) null);
- return new KeyManagerFactory((KeyManagerFactorySpi)objs[0],
- (Provider)objs[1],
- algorithm);
- } catch (NoSuchProviderException e) {
- throw new NoSuchAlgorithmException(algorithm + " not found");
- }
- }
-
- /**
- * Generates a <code>KeyManagerFactory</code> object for the specified
- * key management algorithm from the specified provider.
- *
- * @param algorithm the standard name of the requested
- * algorithm.
- * @param provider the name of the provider
- *
- * @return the new <code>KeyManagerFactory</code> object
- *
- * @exception NoSuchAlgorithmException if the specified algorithm is not
- * available from the specified provider.
- * @exception NoSuchProviderException if the specified provider has not
- * been configured.
- */
- public static final KeyManagerFactory getInstance(String algorithm,
- String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- if (provider == null || provider.isEmpty())
- throw new IllegalArgumentException("missing provider");
- Object[] objs = SSLSecurity.getImpl(algorithm, "KeyManagerFactory",
- provider);
- return new KeyManagerFactory((KeyManagerFactorySpi)objs[0],
- (Provider)objs[1], algorithm);
- }
-
- /**
- * Generates a <code>KeyManagerFactory</code> object for the specified
- * key management algorithm from the specified provider.
- *
- * @param algorithm the standard name of the requested
- * algorithm.
- * @param provider an instance of the provider
- *
- * @return the new <code>KeyManagerFactory</code> object
- *
- * @exception NoSuchAlgorithmException if the specified algorithm is not
- * available from the specified provider.
- */
- public static final KeyManagerFactory getInstance(String algorithm,
- Provider provider)
- throws NoSuchAlgorithmException
- {
- if (provider == null)
- throw new IllegalArgumentException("missing provider");
- Object[] objs = SSLSecurity.getImpl(algorithm, "KeyManagerFactory",
- provider);
- return new KeyManagerFactory((KeyManagerFactorySpi)objs[0],
- (Provider)objs[1], algorithm);
- }
-
- /**
- * Returns the provider of this <code>KeyManagerFactory</code> object.
- *
- * @return the provider of this <code>KeyManagerFactory</code> object
- */
- public final Provider getProvider() {
- return this.provider;
- }
-
-
- /**
- * Initializes this factory with a source of key material. The
- * provider may also include a provider-specific source
- * of key material.
- *
- * @param ks the key store or null
- * @param password the password for recovering keys
- */
- public void init(KeyStore ks, char[] password)
- throws KeyStoreException, NoSuchAlgorithmException,
- UnrecoverableKeyException {
- factorySpi.engineInit(ks, password);
- }
-
- /**
- * Returns one key manager for each type of key material.
- * @return the key managers
- */
- public KeyManager[] getKeyManagers() {
- return factorySpi.engineGetKeyManagers();
- }
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactorySpi.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.KeyManagerFactorySpi
- */
-
-package com.sun.net.ssl;
-
-import java.security.*;
-
-/**
- * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
- * for the <code>KeyManagerFactory</code> class.
- *
- * <p> All the abstract methods in this class must be implemented by each
- * cryptographic service provider who wishes to supply the implementation
- * of a particular key manager factory.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.KeyManagerFactorySpi}.
- */
-@Deprecated(since="1.4")
-public abstract class KeyManagerFactorySpi {
- /**
- * Initializes this factory with a source of key material. The
- * provider may also include a provider-specific source
- * of key material.
- *
- * @param ks the key store or null
- * @param password the password for recovering keys
- */
- protected abstract void engineInit(KeyStore ks, char[] password)
- throws KeyStoreException, NoSuchAlgorithmException,
- UnrecoverableKeyException;
-
- /**
- * Returns one trust manager for each type of trust material.
- * @return the key managers
- */
- protected abstract KeyManager[] engineGetKeyManagers();
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/SSLContext.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,201 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.SSLContext
- */
-
-package com.sun.net.ssl;
-
-import java.security.*;
-import java.util.*;
-import javax.net.ssl.*;
-
-import sun.security.ssl.SSLSocketFactoryImpl;
-import sun.security.ssl.SSLServerSocketFactoryImpl;
-
-/**
- * Instances of this class represent a secure socket protocol
- * implementation which acts as a factory for secure socket
- * factories. This class is initialized with an optional set of
- * key and trust managers and source of secure random bytes.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.SSLContext}.
- */
-@Deprecated(since="1.4")
-public class SSLContext {
- private Provider provider;
-
- private SSLContextSpi contextSpi;
-
- private String protocol;
-
- /**
- * Creates an SSLContext object.
- *
- * @param contextSpi the delegate
- * @param provider the provider
- * @param protocol the protocol
- */
- protected SSLContext(SSLContextSpi contextSpi, Provider provider,
- String protocol) {
- this.contextSpi = contextSpi;
- this.provider = provider;
- this.protocol = protocol;
- }
-
- /**
- * Generates a <code>SSLContext</code> object that implements the
- * specified secure socket protocol.
- *
- * @param protocol the standard name of the requested protocol.
- *
- * @return the new <code>SSLContext</code> object
- *
- * @exception NoSuchAlgorithmException if the specified protocol is not
- * available in the default provider package or any of the other provider
- * packages that were searched.
- */
- public static SSLContext getInstance(String protocol)
- throws NoSuchAlgorithmException
- {
- try {
- Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext",
- (String) null);
- return new SSLContext((SSLContextSpi)objs[0], (Provider)objs[1],
- protocol);
- } catch (NoSuchProviderException e) {
- throw new NoSuchAlgorithmException(protocol + " not found");
- }
- }
-
- /**
- * Generates a <code>SSLContext</code> object that implements the
- * specified secure socket protocol.
- *
- * @param protocol the standard name of the requested protocol.
- * @param provider the name of the provider
- *
- * @return the new <code>SSLContext</code> object
- *
- * @exception NoSuchAlgorithmException if the specified protocol is not
- * available from the specified provider.
- * @exception NoSuchProviderException if the specified provider has not
- * been configured.
- */
- public static SSLContext getInstance(String protocol, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- if (provider == null || provider.isEmpty())
- throw new IllegalArgumentException("missing provider");
- Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext",
- provider);
- return new SSLContext((SSLContextSpi)objs[0], (Provider)objs[1],
- protocol);
- }
-
- /**
- * Generates a <code>SSLContext</code> object that implements the
- * specified secure socket protocol.
- *
- * @param protocol the standard name of the requested protocol.
- * @param provider an instance of the provider
- *
- * @return the new <code>SSLContext</code> object
- *
- * @exception NoSuchAlgorithmException if the specified protocol is not
- * available from the specified provider.
- */
- public static SSLContext getInstance(String protocol, Provider provider)
- throws NoSuchAlgorithmException
- {
- if (provider == null)
- throw new IllegalArgumentException("missing provider");
- Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext",
- provider);
- return new SSLContext((SSLContextSpi)objs[0], (Provider)objs[1],
- protocol);
- }
-
- /**
- * Returns the protocol name of this <code>SSLContext</code> object.
- *
- * <p>This is the same name that was specified in one of the
- * <code>getInstance</code> calls that created this
- * <code>SSLContext</code> object.
- *
- * @return the protocol name of this <code>SSLContext</code> object.
- */
- public final String getProtocol() {
- return this.protocol;
- }
-
- /**
- * Returns the provider of this <code>SSLContext</code> object.
- *
- * @return the provider of this <code>SSLContext</code> object
- */
- public final Provider getProvider() {
- return this.provider;
- }
-
- /**
- * Initializes this context. Either of the first two parameters
- * may be null in which case the installed security providers will
- * be searched for the highest priority implementation of the
- * appropriate factory. Likewise, the secure random parameter may
- * be null in which case the default implementation will be used.
- *
- * @param km the sources of authentication keys or null
- * @param tm the sources of peer authentication trust decisions or null
- * @param random the source of randomness for this generator or null
- */
- public final void init(KeyManager[] km, TrustManager[] tm,
- SecureRandom random)
- throws KeyManagementException {
- contextSpi.engineInit(km, tm, random);
- }
-
- /**
- * Returns a <code>SocketFactory</code> object for this
- * context.
- *
- * @return the factory
- */
- public final SSLSocketFactory getSocketFactory() {
- return contextSpi.engineGetSocketFactory();
- }
-
- /**
- * Returns a <code>ServerSocketFactory</code> object for
- * this context.
- *
- * @return the factory
- */
- public final SSLServerSocketFactory getServerSocketFactory() {
- return contextSpi.engineGetServerSocketFactory();
- }
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/SSLContextSpi.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.SSLContextSpi
- */
-
-package com.sun.net.ssl;
-
-import java.util.*;
-import java.security.*;
-import javax.net.ssl.*;
-
-/**
- * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
- * for the <code>SSLContext</code> class.
- *
- * <p> All the abstract methods in this class must be implemented by each
- * cryptographic service provider who wishes to supply the implementation
- * of a particular SSL context.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.SSLContextSpi}.
- */
-@Deprecated(since="1.4")
-public abstract class SSLContextSpi {
- /**
- * Initializes this context.
- *
- * @param ah the sources of authentication keys
- * @param th the sources of peer authentication trust decisions
- * @param sr the source of randomness for this generator
- */
- protected abstract void engineInit(KeyManager[] ah, TrustManager[] th,
- SecureRandom sr) throws KeyManagementException;
-
- /**
- * Returns a <code>SocketFactory</code> object for this
- * context.
- *
- * @return the factory
- */
- protected abstract SSLSocketFactory engineGetSocketFactory();
-
- /**
- * Returns a <code>ServerSocketFactory</code> object for
- * this context.
- *
- * @return the factory
- */
- protected abstract SSLServerSocketFactory engineGetServerSocketFactory();
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/SSLPermission.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.SSLPermission
- */
-
-package com.sun.net.ssl;
-
-import java.security.*;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.StringTokenizer;
-import java.security.Permissions;
-import java.lang.SecurityManager;
-
-/**
- * This class is for various network permissions.
- * An SSLPermission contains a name (also referred to as a "target name") but
- * no actions list; you either have the named permission
- * or you don't.
- * <P>
- * The target name is the name of the network permission (see below). The naming
- * convention follows the hierarchical property naming convention.
- * Also, an asterisk
- * may appear at the end of the name, following a ".", or by itself, to
- * signify a wildcard match. For example: "foo.*" and "*" signify a wildcard
- * match, while "*foo" and "a*b" do not.
- * <P>
- * The following table lists all the possible SSLPermission target names,
- * and for each provides a description of what the permission allows
- * and a discussion of the risks of granting code the permission.
- *
- * <table border=1 cellpadding=5>
- * <tr>
- * <th>Permission Target Name</th>
- * <th>What the Permission Allows</th>
- * <th>Risks of Allowing this Permission</th>
- * </tr>
- *
- * <tr>
- * <td>setHostnameVerifier</td>
- * <td>The ability to set a callback which can decide whether to
- * allow a mismatch between the host being connected to by
- * an HttpsURLConnection and the common name field in
- * server certificate.
- * </td>
- * <td>Malicious
- * code can set a verifier that monitors host names visited by
- * HttpsURLConnection requests or that allows server certificates
- * with invalid common names.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>getSSLSessionContext</td>
- * <td>The ability to get the SSLSessionContext of an SSLSession.
- * </td>
- * <td>Malicious code may monitor sessions which have been established
- * with SSL peers or might invalidate sessions to slow down performance.
- * </td>
- * </tr>
- *
- * </table>
- *
- * @see java.security.BasicPermission
- * @see java.security.Permission
- * @see java.security.Permissions
- * @see java.security.PermissionCollection
- * @see java.lang.SecurityManager
- *
- *
- * @author Marianne Mueller
- * @author Roland Schemers
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.SSLPermission}.
- */
-@Deprecated(since="1.4")
-public final class SSLPermission extends BasicPermission {
-
- private static final long serialVersionUID = -2583684302506167542L;
-
- /**
- * Creates a new SSLPermission with the specified name.
- * The name is the symbolic name of the SSLPermission, such as
- * "setDefaultAuthenticator", etc. An asterisk
- * may appear at the end of the name, following a ".", or by itself, to
- * signify a wildcard match.
- *
- * @param name the name of the SSLPermission.
- */
-
- public SSLPermission(String name)
- {
- super(name);
- }
-
- /**
- * Creates a new SSLPermission object with the specified name.
- * The name is the symbolic name of the SSLPermission, and the
- * actions String is currently unused and should be null. This
- * constructor exists for use by the <code>Policy</code> object
- * to instantiate new Permission objects.
- *
- * @param name the name of the SSLPermission.
- * @param actions should be null.
- */
-
- public SSLPermission(String name, String actions)
- {
- super(name, actions);
- }
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/SSLSecurity.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,699 +0,0 @@
-/*
- * Copyright (c) 2000, 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.SSLSecurity,
- * but was heavily modified to allow com.sun.* users to
- * access providers written using the javax.sun.* APIs.
- */
-
-package com.sun.net.ssl;
-
-import java.util.*;
-import java.io.*;
-import java.security.*;
-import java.security.Provider.Service;
-import java.net.Socket;
-
-import sun.security.jca.*;
-
-/**
- * This class instantiates implementations of JSSE engine classes from
- * providers registered with the java.security.Security object.
- *
- * @author Jan Luehe
- * @author Jeff Nisewanger
- * @author Brad Wetmore
- */
-
-final class SSLSecurity {
-
- /*
- * Don't let anyone instantiate this.
- */
- private SSLSecurity() {
- }
-
-
- // ProviderList.getService() is not accessible now, implement our own loop
- private static Service getService(String type, String alg) {
- ProviderList list = Providers.getProviderList();
- for (Provider p : list.providers()) {
- Service s = p.getService(type, alg);
- if (s != null) {
- return s;
- }
- }
- return null;
- }
-
- /**
- * The body of the driver for the getImpl method.
- */
- private static Object[] getImpl1(String algName, String engineType,
- Service service) throws NoSuchAlgorithmException
- {
- Provider provider = service.getProvider();
- String className = service.getClassName();
- Class<?> implClass;
- try {
- ClassLoader cl = provider.getClass().getClassLoader();
- if (cl == null) {
- // system class
- implClass = Class.forName(className);
- } else {
- implClass = cl.loadClass(className);
- }
- } catch (ClassNotFoundException e) {
- throw new NoSuchAlgorithmException("Class " + className +
- " configured for " +
- engineType +
- " not found: " +
- e.getMessage());
- } catch (SecurityException e) {
- throw new NoSuchAlgorithmException("Class " + className +
- " configured for " +
- engineType +
- " cannot be accessed: " +
- e.getMessage());
- }
-
- /*
- * JSSE 1.0, 1.0.1, and 1.0.2 used the com.sun.net.ssl API as the
- * API was being developed. As JSSE was folded into the main
- * release, it was decided to promote the com.sun.net.ssl API to
- * be javax.net.ssl. It is desired to keep binary compatibility
- * with vendors of JSSE implementation written using the
- * com.sun.net.sll API, so we do this magic to handle everything.
- *
- * API used Implementation used Supported?
- * ======== =================== ==========
- * com.sun javax Yes
- * com.sun com.sun Yes
- * javax javax Yes
- * javax com.sun Not Currently
- *
- * Make sure the implementation class is a subclass of the
- * corresponding engine class.
- *
- * In wrapping these classes, there's no way to know how to
- * wrap all possible classes that extend the TrustManager/KeyManager.
- * We only wrap the x509 variants.
- */
-
- try { // catch instantiation errors
-
- /*
- * (The following Class.forName()s should alway work, because
- * this class and all the SPI classes in javax.crypto are
- * loaded by the same class loader.) That is, unless they
- * give us a SPI class that doesn't exist, say SSLFoo,
- * or someone has removed classes from the java.base module.
- */
-
- Class<?> typeClassJavax;
- Class<?> typeClassCom;
- Object obj = null;
-
- /*
- * Odds are more likely that we have a javax variant, try this
- * first.
- */
- if (((typeClassJavax = Class.forName("javax.net.ssl." +
- engineType + "Spi")) != null) &&
- (checkSuperclass(implClass, typeClassJavax))) {
-
- if (engineType.equals("SSLContext")) {
- obj = new SSLContextSpiWrapper(algName, provider);
- } else if (engineType.equals("TrustManagerFactory")) {
- obj = new TrustManagerFactorySpiWrapper(algName, provider);
- } else if (engineType.equals("KeyManagerFactory")) {
- obj = new KeyManagerFactorySpiWrapper(algName, provider);
- } else {
- /*
- * We should throw an error if we get
- * something totally unexpected. Don't ever
- * expect to see this one...
- */
- throw new IllegalStateException(
- "Class " + implClass.getName() +
- " unknown engineType wrapper:" + engineType);
- }
-
- } else if (((typeClassCom = Class.forName("com.sun.net.ssl." +
- engineType + "Spi")) != null) &&
- (checkSuperclass(implClass, typeClassCom))) {
- obj = service.newInstance(null);
- }
-
- if (obj != null) {
- return new Object[] { obj, provider };
- } else {
- throw new NoSuchAlgorithmException(
- "Couldn't locate correct object or wrapper: " +
- engineType + " " + algName);
- }
-
- } catch (ClassNotFoundException e) {
- IllegalStateException exc = new IllegalStateException(
- "Engine Class Not Found for " + engineType);
- exc.initCause(e);
- throw exc;
- }
- }
-
- /**
- * Returns an array of objects: the first object in the array is
- * an instance of an implementation of the requested algorithm
- * and type, and the second object in the array identifies the provider
- * of that implementation.
- * The <code>provName</code> argument can be null, in which case all
- * configured providers will be searched in order of preference.
- */
- static Object[] getImpl(String algName, String engineType, String provName)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- Service service;
- if (provName != null) {
- ProviderList list = Providers.getProviderList();
- Provider prov = list.getProvider(provName);
- if (prov == null) {
- throw new NoSuchProviderException("No such provider: " +
- provName);
- }
- service = prov.getService(engineType, algName);
- } else {
- service = getService(engineType, algName);
- }
- if (service == null) {
- throw new NoSuchAlgorithmException("Algorithm " + algName
- + " not available");
- }
- return getImpl1(algName, engineType, service);
- }
-
-
- /**
- * Returns an array of objects: the first object in the array is
- * an instance of an implementation of the requested algorithm
- * and type, and the second object in the array identifies the provider
- * of that implementation.
- * The <code>prov</code> argument can be null, in which case all
- * configured providers will be searched in order of preference.
- */
- static Object[] getImpl(String algName, String engineType, Provider prov)
- throws NoSuchAlgorithmException
- {
- Service service = prov.getService(engineType, algName);
- if (service == null) {
- throw new NoSuchAlgorithmException("No such algorithm: " +
- algName);
- }
- return getImpl1(algName, engineType, service);
- }
-
- /*
- * Checks whether one class is the superclass of another
- */
- private static boolean checkSuperclass(Class<?> subclass, Class<?> superclass) {
- if ((subclass == null) || (superclass == null))
- return false;
-
- while (!subclass.equals(superclass)) {
- subclass = subclass.getSuperclass();
- if (subclass == null) {
- return false;
- }
- }
- return true;
- }
-
- /*
- * Return at most the first "resize" elements of an array.
- *
- * Didn't want to use java.util.Arrays, as PJava may not have it.
- */
- static Object[] truncateArray(Object[] oldArray, Object[] newArray) {
-
- for (int i = 0; i < newArray.length; i++) {
- newArray[i] = oldArray[i];
- }
-
- return newArray;
- }
-
-}
-
-
-/*
- * =================================================================
- * The remainder of this file is for the wrapper and wrapper-support
- * classes. When SSLSecurity finds something which extends the
- * javax.net.ssl.*Spi, we need to go grab a real instance of the
- * thing that the Spi supports, and wrap into a com.sun.net.ssl.*Spi
- * object. This also mean that anything going down into the SPI
- * needs to be wrapped, as well as anything coming back up.
- */
-@SuppressWarnings("deprecation")
-final class SSLContextSpiWrapper extends SSLContextSpi {
-
- private javax.net.ssl.SSLContext theSSLContext;
-
- SSLContextSpiWrapper(String algName, Provider prov) throws
- NoSuchAlgorithmException {
- theSSLContext = javax.net.ssl.SSLContext.getInstance(algName, prov);
- }
-
- @SuppressWarnings("deprecation")
- protected void engineInit(KeyManager[] kma, TrustManager[] tma,
- SecureRandom sr) throws KeyManagementException {
-
- // Keep track of the actual number of array elements copied
- int dst;
- int src;
- javax.net.ssl.KeyManager[] kmaw;
- javax.net.ssl.TrustManager[] tmaw;
-
- // Convert com.sun.net.ssl.kma to a javax.net.ssl.kma
- // wrapper if need be.
- if (kma != null) {
- kmaw = new javax.net.ssl.KeyManager[kma.length];
- for (src = 0, dst = 0; src < kma.length; ) {
- /*
- * These key managers may implement both javax
- * and com.sun interfaces, so if they do
- * javax, there's no need to wrap them.
- */
- if (!(kma[src] instanceof javax.net.ssl.KeyManager)) {
- /*
- * Do we know how to convert them? If not, oh well...
- * We'll have to drop them on the floor in this
- * case, cause we don't know how to handle them.
- * This will be pretty rare, but put here for
- * completeness.
- */
- if (kma[src] instanceof X509KeyManager) {
- kmaw[dst] = (javax.net.ssl.KeyManager)
- new X509KeyManagerJavaxWrapper(
- (X509KeyManager)kma[src]);
- dst++;
- }
- } else {
- // We can convert directly, since they implement.
- kmaw[dst] = (javax.net.ssl.KeyManager)kma[src];
- dst++;
- }
- src++;
- }
-
- /*
- * If dst != src, there were more items in the original array
- * than in the new array. Compress the new elements to avoid
- * any problems down the road.
- */
- if (dst != src) {
- kmaw = (javax.net.ssl.KeyManager [])
- SSLSecurity.truncateArray(kmaw,
- new javax.net.ssl.KeyManager [dst]);
- }
- } else {
- kmaw = null;
- }
-
- // Now do the same thing with the TrustManagers.
- if (tma != null) {
- tmaw = new javax.net.ssl.TrustManager[tma.length];
-
- for (src = 0, dst = 0; src < tma.length; ) {
- /*
- * These key managers may implement both...see above...
- */
- if (!(tma[src] instanceof javax.net.ssl.TrustManager)) {
- // Do we know how to convert them?
- if (tma[src] instanceof X509TrustManager) {
- tmaw[dst] = (javax.net.ssl.TrustManager)
- new X509TrustManagerJavaxWrapper(
- (X509TrustManager)tma[src]);
- dst++;
- }
- } else {
- tmaw[dst] = (javax.net.ssl.TrustManager)tma[src];
- dst++;
- }
- src++;
- }
-
- if (dst != src) {
- tmaw = (javax.net.ssl.TrustManager [])
- SSLSecurity.truncateArray(tmaw,
- new javax.net.ssl.TrustManager [dst]);
- }
- } else {
- tmaw = null;
- }
-
- theSSLContext.init(kmaw, tmaw, sr);
- }
-
- protected javax.net.ssl.SSLSocketFactory
- engineGetSocketFactory() {
- return theSSLContext.getSocketFactory();
- }
-
- protected javax.net.ssl.SSLServerSocketFactory
- engineGetServerSocketFactory() {
- return theSSLContext.getServerSocketFactory();
- }
-
-}
-
-@SuppressWarnings("deprecation")
-final class TrustManagerFactorySpiWrapper extends TrustManagerFactorySpi {
-
- private javax.net.ssl.TrustManagerFactory theTrustManagerFactory;
-
- TrustManagerFactorySpiWrapper(String algName, Provider prov) throws
- NoSuchAlgorithmException {
- theTrustManagerFactory =
- javax.net.ssl.TrustManagerFactory.getInstance(algName, prov);
- }
-
- protected void engineInit(KeyStore ks) throws KeyStoreException {
- theTrustManagerFactory.init(ks);
- }
-
- protected TrustManager[] engineGetTrustManagers() {
-
- int dst;
- int src;
-
- javax.net.ssl.TrustManager[] tma =
- theTrustManagerFactory.getTrustManagers();
-
- TrustManager[] tmaw = new TrustManager[tma.length];
-
- for (src = 0, dst = 0; src < tma.length; ) {
- if (!(tma[src] instanceof com.sun.net.ssl.TrustManager)) {
- // We only know how to wrap X509TrustManagers, as
- // TrustManagers don't have any methods to wrap.
- if (tma[src] instanceof javax.net.ssl.X509TrustManager) {
- tmaw[dst] = (TrustManager)
- new X509TrustManagerComSunWrapper(
- (javax.net.ssl.X509TrustManager)tma[src]);
- dst++;
- }
- } else {
- tmaw[dst] = (TrustManager)tma[src];
- dst++;
- }
- src++;
- }
-
- if (dst != src) {
- tmaw = (TrustManager [])
- SSLSecurity.truncateArray(tmaw, new TrustManager [dst]);
- }
-
- return tmaw;
- }
-
-}
-
-@SuppressWarnings("deprecation")
-final class KeyManagerFactorySpiWrapper extends KeyManagerFactorySpi {
-
- private javax.net.ssl.KeyManagerFactory theKeyManagerFactory;
-
- KeyManagerFactorySpiWrapper(String algName, Provider prov) throws
- NoSuchAlgorithmException {
- theKeyManagerFactory =
- javax.net.ssl.KeyManagerFactory.getInstance(algName, prov);
- }
-
- protected void engineInit(KeyStore ks, char[] password)
- throws KeyStoreException, NoSuchAlgorithmException,
- UnrecoverableKeyException {
- theKeyManagerFactory.init(ks, password);
- }
-
- protected KeyManager[] engineGetKeyManagers() {
-
- int dst;
- int src;
-
- javax.net.ssl.KeyManager[] kma =
- theKeyManagerFactory.getKeyManagers();
-
- KeyManager[] kmaw = new KeyManager[kma.length];
-
- for (src = 0, dst = 0; src < kma.length; ) {
- if (!(kma[src] instanceof com.sun.net.ssl.KeyManager)) {
- // We only know how to wrap X509KeyManagers, as
- // KeyManagers don't have any methods to wrap.
- if (kma[src] instanceof javax.net.ssl.X509KeyManager) {
- kmaw[dst] = (KeyManager)
- new X509KeyManagerComSunWrapper(
- (javax.net.ssl.X509KeyManager)kma[src]);
- dst++;
- }
- } else {
- kmaw[dst] = (KeyManager)kma[src];
- dst++;
- }
- src++;
- }
-
- if (dst != src) {
- kmaw = (KeyManager [])
- SSLSecurity.truncateArray(kmaw, new KeyManager [dst]);
- }
-
- return kmaw;
- }
-
-}
-
-// =================================
-
-@SuppressWarnings("deprecation")
-final class X509KeyManagerJavaxWrapper implements
- javax.net.ssl.X509KeyManager {
-
- private X509KeyManager theX509KeyManager;
-
- X509KeyManagerJavaxWrapper(X509KeyManager obj) {
- theX509KeyManager = obj;
- }
-
- public String[] getClientAliases(String keyType, Principal[] issuers) {
- return theX509KeyManager.getClientAliases(keyType, issuers);
- }
-
- public String chooseClientAlias(String[] keyTypes, Principal[] issuers,
- Socket socket) {
- String retval;
-
- if (keyTypes == null) {
- return null;
- }
-
- /*
- * Scan the list, look for something we can pass back.
- */
- for (int i = 0; i < keyTypes.length; i++) {
- if ((retval = theX509KeyManager.chooseClientAlias(keyTypes[i],
- issuers)) != null)
- return retval;
- }
- return null;
-
- }
-
- /*
- * JSSE 1.0.x was only socket based, but it's possible someone might
- * want to install a really old provider. We should at least
- * try to be nice.
- */
- public String chooseEngineClientAlias(
- String[] keyTypes, Principal[] issuers,
- javax.net.ssl.SSLEngine engine) {
- String retval;
-
- if (keyTypes == null) {
- return null;
- }
-
- /*
- * Scan the list, look for something we can pass back.
- */
- for (int i = 0; i < keyTypes.length; i++) {
- if ((retval = theX509KeyManager.chooseClientAlias(keyTypes[i],
- issuers)) != null)
- return retval;
- }
-
- return null;
- }
-
- public String[] getServerAliases(String keyType, Principal[] issuers) {
- return theX509KeyManager.getServerAliases(keyType, issuers);
- }
-
- public String chooseServerAlias(String keyType, Principal[] issuers,
- Socket socket) {
-
- if (keyType == null) {
- return null;
- }
- return theX509KeyManager.chooseServerAlias(keyType, issuers);
- }
-
- /*
- * JSSE 1.0.x was only socket based, but it's possible someone might
- * want to install a really old provider. We should at least
- * try to be nice.
- */
- public String chooseEngineServerAlias(
- String keyType, Principal[] issuers,
- javax.net.ssl.SSLEngine engine) {
-
- if (keyType == null) {
- return null;
- }
- return theX509KeyManager.chooseServerAlias(keyType, issuers);
- }
-
- public java.security.cert.X509Certificate[]
- getCertificateChain(String alias) {
- return theX509KeyManager.getCertificateChain(alias);
- }
-
- public PrivateKey getPrivateKey(String alias) {
- return theX509KeyManager.getPrivateKey(alias);
- }
-}
-
-@SuppressWarnings("deprecation")
-final class X509TrustManagerJavaxWrapper implements
- javax.net.ssl.X509TrustManager {
-
- private X509TrustManager theX509TrustManager;
-
- X509TrustManagerJavaxWrapper(X509TrustManager obj) {
- theX509TrustManager = obj;
- }
-
- public void checkClientTrusted(
- java.security.cert.X509Certificate[] chain, String authType)
- throws java.security.cert.CertificateException {
- if (!theX509TrustManager.isClientTrusted(chain)) {
- throw new java.security.cert.CertificateException(
- "Untrusted Client Certificate Chain");
- }
- }
-
- public void checkServerTrusted(
- java.security.cert.X509Certificate[] chain, String authType)
- throws java.security.cert.CertificateException {
- if (!theX509TrustManager.isServerTrusted(chain)) {
- throw new java.security.cert.CertificateException(
- "Untrusted Server Certificate Chain");
- }
- }
-
- public java.security.cert.X509Certificate[] getAcceptedIssuers() {
- return theX509TrustManager.getAcceptedIssuers();
- }
-}
-
-@SuppressWarnings("deprecation")
-final class X509KeyManagerComSunWrapper implements X509KeyManager {
-
- private javax.net.ssl.X509KeyManager theX509KeyManager;
-
- X509KeyManagerComSunWrapper(javax.net.ssl.X509KeyManager obj) {
- theX509KeyManager = obj;
- }
-
- public String[] getClientAliases(String keyType, Principal[] issuers) {
- return theX509KeyManager.getClientAliases(keyType, issuers);
- }
-
- public String chooseClientAlias(String keyType, Principal[] issuers) {
- String [] keyTypes = new String [] { keyType };
- return theX509KeyManager.chooseClientAlias(keyTypes, issuers, null);
- }
-
- public String[] getServerAliases(String keyType, Principal[] issuers) {
- return theX509KeyManager.getServerAliases(keyType, issuers);
- }
-
- public String chooseServerAlias(String keyType, Principal[] issuers) {
- return theX509KeyManager.chooseServerAlias(keyType, issuers, null);
- }
-
- public java.security.cert.X509Certificate[]
- getCertificateChain(String alias) {
- return theX509KeyManager.getCertificateChain(alias);
- }
-
- public PrivateKey getPrivateKey(String alias) {
- return theX509KeyManager.getPrivateKey(alias);
- }
-}
-
-@SuppressWarnings("deprecation")
-final class X509TrustManagerComSunWrapper implements X509TrustManager {
-
- private javax.net.ssl.X509TrustManager theX509TrustManager;
-
- X509TrustManagerComSunWrapper(javax.net.ssl.X509TrustManager obj) {
- theX509TrustManager = obj;
- }
-
- public boolean isClientTrusted(
- java.security.cert.X509Certificate[] chain) {
- try {
- theX509TrustManager.checkClientTrusted(chain, "UNKNOWN");
- return true;
- } catch (java.security.cert.CertificateException e) {
- return false;
- }
- }
-
- public boolean isServerTrusted(
- java.security.cert.X509Certificate[] chain) {
- try {
- theX509TrustManager.checkServerTrusted(chain, "UNKNOWN");
- return true;
- } catch (java.security.cert.CertificateException e) {
- return false;
- }
- }
-
- public java.security.cert.X509Certificate[] getAcceptedIssuers() {
- return theX509TrustManager.getAcceptedIssuers();
- }
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/TrustManager.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.TrustManager
- */
-
-package com.sun.net.ssl;
-
-/**
- * Base interface for JSSE trust managers which manage
- * authentication trust decisions for different types of
- * authentication material.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.TrustManager}.
- */
-@Deprecated(since="1.4")
-public interface TrustManager {
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,220 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.TrustManagerFactory
- */
-
-package com.sun.net.ssl;
-
-import java.security.*;
-
-/**
- * This class acts as a factory for trust managers based on a
- * source of trust material. Each trust manager manages a specific
- * type of trust material for use by secure sockets. The trust
- * material is based on a KeyStore and/or provider specific sources.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.TrustManagerFactory}.
- */
-@Deprecated(since="1.4")
-public class TrustManagerFactory {
- // The provider
- private Provider provider;
-
- // The provider implementation (delegate)
- private TrustManagerFactorySpi factorySpi;
-
- // The name of the trust management algorithm.
- private String algorithm;
-
- /**
- * <p>The default TrustManager can be changed by setting the value of the
- * {@code sun.ssl.trustmanager.type} security property to the desired name.
- *
- * @return the default type as specified by the
- * {@code sun.ssl.trustmanager.type} security property, or an
- * implementation-specific default if no such property exists.
- *
- * @see java.security.Security security properties
- */
- public static final String getDefaultAlgorithm() {
- String type;
- type = AccessController.doPrivileged(new PrivilegedAction<>() {
- public String run() {
- return Security.getProperty("sun.ssl.trustmanager.type");
- }
- });
- if (type == null) {
- type = "SunX509";
- }
- return type;
-
- }
-
- /**
- * Creates a TrustManagerFactory object.
- *
- * @param factorySpi the delegate
- * @param provider the provider
- * @param algorithm the algorithm
- */
- protected TrustManagerFactory(TrustManagerFactorySpi factorySpi,
- Provider provider, String algorithm) {
- this.factorySpi = factorySpi;
- this.provider = provider;
- this.algorithm = algorithm;
- }
-
- /**
- * Returns the algorithm name of this <code>TrustManagerFactory</code>
- * object.
- *
- * <p>This is the same name that was specified in one of the
- * <code>getInstance</code> calls that created this
- * <code>TrustManagerFactory</code> object.
- *
- * @return the algorithm name of this <code>TrustManagerFactory</code>
- * object.
- */
- public final String getAlgorithm() {
- return this.algorithm;
- }
-
- /**
- * Generates a <code>TrustManagerFactory</code> object that implements the
- * specified trust management algorithm.
- * If the default provider package provides an implementation of the
- * requested trust management algorithm, an instance of
- * <code>TrustManagerFactory</code> containing that implementation is
- * returned. If the algorithm is not available in the default provider
- * package, other provider packages are searched.
- *
- * @param algorithm the standard name of the requested trust management
- * algorithm.
- *
- * @return the new <code>TrustManagerFactory</code> object
- *
- * @exception NoSuchAlgorithmException if the specified algorithm is not
- * available in the default provider package or any of the other provider
- * packages that were searched.
- */
- public static final TrustManagerFactory getInstance(String algorithm)
- throws NoSuchAlgorithmException
- {
- try {
- Object[] objs = SSLSecurity.getImpl(algorithm,
- "TrustManagerFactory", (String) null);
- return new TrustManagerFactory((TrustManagerFactorySpi)objs[0],
- (Provider)objs[1],
- algorithm);
- } catch (NoSuchProviderException e) {
- throw new NoSuchAlgorithmException(algorithm + " not found");
- }
- }
-
- /**
- * Generates a <code>TrustManagerFactory</code> object for the specified
- * trust management algorithm from the specified provider.
- *
- * @param algorithm the standard name of the requested trust management
- * algorithm.
- * @param provider the name of the provider
- *
- * @return the new <code>TrustManagerFactory</code> object
- *
- * @exception NoSuchAlgorithmException if the specified algorithm is not
- * available from the specified provider.
- * @exception NoSuchProviderException if the specified provider has not
- * been configured.
- */
- public static final TrustManagerFactory getInstance(String algorithm,
- String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- if (provider == null || provider.isEmpty())
- throw new IllegalArgumentException("missing provider");
- Object[] objs = SSLSecurity.getImpl(algorithm, "TrustManagerFactory",
- provider);
- return new TrustManagerFactory((TrustManagerFactorySpi)objs[0],
- (Provider)objs[1], algorithm);
- }
-
- /**
- * Generates a <code>TrustManagerFactory</code> object for the specified
- * trust management algorithm from the specified provider.
- *
- * @param algorithm the standard name of the requested trust management
- * algorithm.
- * @param provider an instance of the provider
- *
- * @return the new <code>TrustManagerFactory</code> object
- *
- * @exception NoSuchAlgorithmException if the specified algorithm is not
- * available from the specified provider.
- */
- public static final TrustManagerFactory getInstance(String algorithm,
- Provider provider)
- throws NoSuchAlgorithmException
- {
- if (provider == null)
- throw new IllegalArgumentException("missing provider");
- Object[] objs = SSLSecurity.getImpl(algorithm, "TrustManagerFactory",
- provider);
- return new TrustManagerFactory((TrustManagerFactorySpi)objs[0],
- (Provider)objs[1], algorithm);
- }
-
- /**
- * Returns the provider of this <code>TrustManagerFactory</code> object.
- *
- * @return the provider of this <code>TrustManagerFactory</code> object
- */
- public final Provider getProvider() {
- return this.provider;
- }
-
-
- /**
- * Initializes this factory with a source of certificate
- * authorities and related trust material. The
- * provider may also include a provider-specific source
- * of key material.
- *
- * @param ks the key store or null
- */
- public void init(KeyStore ks) throws KeyStoreException {
- factorySpi.engineInit(ks);
- }
-
- /**
- * Returns one trust manager for each type of trust material.
- * @return the trust managers
- */
- public TrustManager[] getTrustManagers() {
- return factorySpi.engineGetTrustManagers();
- }
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactorySpi.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.TrustManagerFactorySpi
- */
-
-package com.sun.net.ssl;
-
-import java.security.*;
-
-/**
- * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
- * for the <code>TrustManagerFactory</code> class.
- *
- * <p> All the abstract methods in this class must be implemented by each
- * cryptographic service provider who wishes to supply the implementation
- * of a particular trust manager factory.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.TrustManagerFactorySpi}.
- */
-@Deprecated(since="1.4")
-public abstract class TrustManagerFactorySpi {
- /**
- * Initializes this factory with a source of certificate
- * authorities and related trust material. The
- * provider may also include a provider-specific source
- * of key material.
- *
- * @param ks the key store or null
- */
- protected abstract void engineInit(KeyStore ks) throws KeyStoreException;
-
- /**
- * Returns one trust manager for each type of trust material.
- * @return the trust managers
- */
- protected abstract TrustManager[] engineGetTrustManagers();
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/X509KeyManager.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.X509KeyManager
- */
-
-package com.sun.net.ssl;
-
-import java.security.KeyManagementException;
-import java.security.PrivateKey;
-import java.security.Principal;
-import java.security.cert.X509Certificate;
-
-/**
- * Instances of this interface manage which X509 certificate-based
- * key pairs are used to authenticate the local side of a secure
- * socket. The individual entries are identified by unique alias names.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.X509KeyManager}.
- */
-@Deprecated(since="1.4")
-public interface X509KeyManager extends KeyManager {
- /**
- * Get the matching aliases for authenticating the client side of a secure
- * socket given the public key type and the list of
- * certificate issuer authorities recognized by the peer (if any).
- *
- * @param keyType the key algorithm type name
- * @param issuers the list of acceptable CA issuer subject names
- * @return the matching alias names
- */
- public String[] getClientAliases(String keyType, Principal[] issuers);
-
- /**
- * Choose an alias to authenticate the client side of a secure
- * socket given the public key type and the list of
- * certificate issuer authorities recognized by the peer (if any).
- *
- * @param keyType the key algorithm type name
- * @param issuers the list of acceptable CA issuer subject names
- * @return the alias name for the desired key
- */
- public String chooseClientAlias(String keyType, Principal[] issuers);
-
- /**
- * Get the matching aliases for authenticating the server side of a secure
- * socket given the public key type and the list of
- * certificate issuer authorities recognized by the peer (if any).
- *
- * @param keyType the key algorithm type name
- * @param issuers the list of acceptable CA issuer subject names
- * @return the matching alias names
- */
- public String[] getServerAliases(String keyType, Principal[] issuers);
-
- /**
- * Choose an alias to authenticate the server side of a secure
- * socket given the public key type and the list of
- * certificate issuer authorities recognized by the peer (if any).
- *
- * @param keyType the key algorithm type name
- * @param issuers the list of acceptable CA issuer subject names
- * @return the alias name for the desired key
- */
- public String chooseServerAlias(String keyType, Principal[] issuers);
-
- /**
- * 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)
- */
- public X509Certificate[] getCertificateChain(String alias);
-
- /*
- * Returns the key associated with the given alias.
- *
- * @param alias the alias name
- *
- * @return the requested key
- */
- public PrivateKey getPrivateKey(String alias);
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/X509TrustManager.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * NOTE: this file was copied from javax.net.ssl.X509TrustManager
- */
-
-package com.sun.net.ssl;
-
-import java.security.cert.X509Certificate;
-
-/**
- * Instance of this interface manage which X509 certificates
- * may be used to authenticate the remote side of a secure
- * socket. Decisions may be based on trusted certificate
- * authorities, certificate revocation lists, online
- * status checking or other means.
- *
- * @deprecated As of JDK 1.4, this implementation-specific class was
- * replaced by {@link javax.net.ssl.X509TrustManager}.
- */
-@Deprecated(since="1.4")
-public interface X509TrustManager extends TrustManager {
- /**
- * Given the partial or complete certificate chain
- * provided by the peer, build a certificate path
- * to a trusted root and return true if it can be
- * validated and is trusted for client SSL authentication.
- *
- * @param chain the peer certificate chain
- */
- public boolean isClientTrusted(X509Certificate[] chain);
-
- /**
- * Given the partial or complete certificate chain
- * provided by the peer, build a certificate path
- * to a trusted root and return true if it can be
- * validated and is trusted for server SSL authentication.
- *
- * @param chain the peer certificate chain
- */
- public boolean isServerTrusted(X509Certificate[] chain);
-
- /**
- * Return an array of certificate authority certificates
- * which are trusted for authenticating peers.
- *
- * @return the acceptable CA issuer certificates
- */
- public X509Certificate[] getAcceptedIssuers();
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/internal/ssl/Provider.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
- * 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.net.ssl.internal.ssl;
-
-import sun.security.ssl.SunJSSE;
-
-/**
- * Main class for the SunJSSE provider. The actual code was moved to the
- * class sun.security.ssl.SunJSSE, but for backward compatibility we
- * continue to use this class as the main Provider class.
- */
-@Deprecated(since="9")
-public final class Provider extends SunJSSE {
-
- private static final long serialVersionUID = 3231825739635378733L;
-
- // standard constructor
- public Provider() {
- super();
- }
-
- /**
- * Installs the JSSE provider.
- */
- public static synchronized void install() {
- /* nop. Remove this method in the future. */
- }
-
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/internal/ssl/X509ExtendedTrustManager.java Sat Mar 09 12:52:30 2019 +0000
+++ /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 com.sun.net.ssl.internal.ssl;
-
-import javax.net.ssl.X509TrustManager;
-
-import java.security.cert.X509Certificate;
-import java.security.cert.CertificateException;
-
-/**
- * Instance of this class is an extension of <code>X509TrustManager</code>.
- * <p>
- * Note that this class is referenced by the Deploy workspace. Any updates
- * must make sure that they do not cause any breakage there.
- * <p>
- * It takes the responsiblity of checking the peer identity with its
- * principal declared in the cerificate.
- * <p>
- * The class provides an alternative to <code>HostnameVerifer</code>.
- * If application customizes its <code>HostnameVerifer</code> for
- * <code>HttpsURLConnection</code>, the peer identity will be checked
- * by the customized <code>HostnameVerifer</code>; otherwise, it will
- * be checked by the extended trust manager.
- * <p>
- * RFC2830 defines the server identification specification for "LDAP"
- * algorithm. RFC2818 defines both the server identification and the
- * client identification specification for "HTTPS" algorithm.
- *
- * @see X509TrustManager
- * @see HostnameVerifier
- *
- * @since 1.6
- * @author Xuelei Fan
- */
-@Deprecated(since="9")
-public abstract class X509ExtendedTrustManager implements X509TrustManager {
- /**
- * Constructor used by subclasses only.
- */
- protected X509ExtendedTrustManager() {
- }
-
- /**
- * Given the partial or complete certificate chain provided by the
- * peer, check its identity and build a certificate path to a trusted
- * root, return if it can be validated and is trusted for client SSL
- * authentication based on the authentication type.
- * <p>
- * The authentication type is determined by the actual certificate
- * used. For instance, if RSAPublicKey is used, the authType
- * should be "RSA". Checking is case-sensitive.
- * <p>
- * The algorithm parameter specifies the client identification protocol
- * to use. If the algorithm and the peer hostname are available, the
- * peer hostname is checked against the peer's identity presented in
- * the X509 certificate, in order to prevent masquerade attacks.
- *
- * @param chain the peer certificate chain
- * @param authType the authentication type based on the client certificate
- * @param hostname the peer hostname
- * @param algorithm the identification algorithm
- * @throws IllegalArgumentException if null or zero-length chain
- * is passed in for the chain parameter or if null or zero-length
- * string is passed in for the authType parameter
- * @throws CertificateException if the certificate chain is not trusted
- * by this TrustManager.
- */
- public abstract void checkClientTrusted(X509Certificate[] chain,
- String authType, String hostname, String algorithm)
- throws CertificateException;
-
- /**
- * Given the partial or complete certificate chain provided by the
- * peer, check its identity and build a certificate path to a trusted
- * root, return if it can be validated and is trusted for server SSL
- * authentication based on the authentication type.
- * <p>
- * The authentication type is the key exchange algorithm portion
- * of the cipher suites represented as a String, such as "RSA",
- * "DHE_DSS". Checking is case-sensitive.
- * <p>
- * The algorithm parameter specifies the server identification protocol
- * to use. If the algorithm and the peer hostname are available, the
- * peer hostname is checked against the peer's identity presented in
- * the X509 certificate, in order to prevent masquerade attacks.
- *
- * @param chain the peer certificate chain
- * @param authType the key exchange algorithm used
- * @param hostname the peer hostname
- * @param algorithm the identification algorithm
- * @throws IllegalArgumentException if null or zero-length chain
- * is passed in for the chain parameter or if null or zero-length
- * string is passed in for the authType parameter
- * @throws CertificateException if the certificate chain is not trusted
- * by this TrustManager.
- */
- public abstract void checkServerTrusted(X509Certificate[] chain,
- String authType, String hostname, String algorithm)
- throws CertificateException;
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/DelegateHttpsURLConnection.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.net.ssl.internal.www.protocol.https;
-
-import java.net.URL;
-import java.net.Proxy;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Iterator;
-
-import java.security.Principal;
-import java.security.cert.*;
-
-import javax.security.auth.x500.X500Principal;
-
-import sun.security.util.HostnameChecker;
-import sun.security.util.DerValue;
-import sun.security.x509.X500Name;
-
-import sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection;
-
-/**
- * This class was introduced to provide an additional level of
- * abstraction between javax.net.ssl.HttpURLConnection and
- * com.sun.net.ssl.HttpURLConnection objects. <p>
- *
- * javax.net.ssl.HttpURLConnection is used in the new sun.net version
- * of protocol implementation (this one)
- * com.sun.net.ssl.HttpURLConnection is used in the com.sun version.
- *
- */
-@Deprecated(since="9")
-@SuppressWarnings("deprecation") // HttpsURLConnection is deprecated
-public class DelegateHttpsURLConnection extends AbstractDelegateHttpsURLConnection {
-
- // we need a reference to the HttpsURLConnection to get
- // the properties set there
- // we also need it to be public so that it can be referenced
- // from sun.net.www.protocol.http.HttpURLConnection
- // this is for ResponseCache.put(URI, URLConnection)
- // second parameter needs to be cast to javax.net.ssl.HttpsURLConnection
- // instead of AbstractDelegateHttpsURLConnection
-
- public com.sun.net.ssl.HttpsURLConnection httpsURLConnection;
-
- DelegateHttpsURLConnection(URL url,
- sun.net.www.protocol.http.Handler handler,
- com.sun.net.ssl.HttpsURLConnection httpsURLConnection)
- throws IOException {
- this(url, null, handler, httpsURLConnection);
- }
-
- DelegateHttpsURLConnection(URL url, Proxy p,
- sun.net.www.protocol.http.Handler handler,
- com.sun.net.ssl.HttpsURLConnection httpsURLConnection)
- throws IOException {
- super(url, p, handler);
- this.httpsURLConnection = httpsURLConnection;
- }
-
- protected javax.net.ssl.SSLSocketFactory getSSLSocketFactory() {
- return httpsURLConnection.getSSLSocketFactory();
- }
-
- protected javax.net.ssl.HostnameVerifier getHostnameVerifier() {
- // note: getHostnameVerifier() never returns null
- return new VerifierWrapper(httpsURLConnection.getHostnameVerifier());
- }
-
- /*
- * Called by layered delegator's finalize() method to handle closing
- * the underlying object.
- */
- protected void dispose() throws Throwable {
- super.finalize();
- }
-}
-
-class VerifierWrapper implements javax.net.ssl.HostnameVerifier {
- @SuppressWarnings("deprecation")
- private com.sun.net.ssl.HostnameVerifier verifier;
-
- @SuppressWarnings("deprecation")
- VerifierWrapper(com.sun.net.ssl.HostnameVerifier verifier) {
- this.verifier = verifier;
- }
-
- /*
- * In com.sun.net.ssl.HostnameVerifier the method is defined
- * as verify(String urlHostname, String certHostname).
- * This means we need to extract the hostname from the X.509 certificate
- * in this wrapper.
- */
- public boolean verify(String hostname, javax.net.ssl.SSLSession session) {
- try {
- Certificate[] serverChain = session.getPeerCertificates();
- if ((serverChain == null) || (serverChain.length == 0)) {
- return false;
- }
- if (serverChain[0] instanceof X509Certificate == false) {
- return false;
- }
- X509Certificate serverCert = (X509Certificate)serverChain[0];
- String serverName = getServername(serverCert);
- if (serverName == null) {
- return false;
- }
- return verifier.verify(hostname, serverName);
- } catch (javax.net.ssl.SSLPeerUnverifiedException e) {
- return false;
- }
- }
-
- /*
- * Extract the name of the SSL server from the certificate.
- *
- * Note this code is essentially a subset of the hostname extraction
- * code in HostnameChecker.
- */
- private static String getServername(X509Certificate peerCert) {
- try {
- // compare to subjectAltNames if dnsName is present
- Collection<List<?>> subjAltNames = peerCert.getSubjectAlternativeNames();
- if (subjAltNames != null) {
- for (Iterator<List<?>> itr = subjAltNames.iterator(); itr.hasNext(); ) {
- List<?> next = itr.next();
- if (((Integer)next.get(0)).intValue() == 2) {
- // compare dNSName with host in url
- String dnsName = ((String)next.get(1));
- return dnsName;
- }
- }
- }
-
- // else check against common name in the subject field
- X500Name subject = HostnameChecker.getSubjectX500Name(peerCert);
-
- DerValue derValue = subject.findMostSpecificAttribute
- (X500Name.commonName_oid);
- if (derValue != null) {
- try {
- String name = derValue.getAsString();
- return name;
- } catch (IOException e) {
- // ignore
- }
- }
- } catch (java.security.cert.CertificateException e) {
- // ignore
- }
- return null;
- }
-
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/Handler.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.net.ssl.internal.www.protocol.https;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.Proxy;
-
-/**
- * This class exists for compatibility with previous JSSE releases
- * only. The HTTPS implementation can now be found in
- * sun.net.www.protocol.https.
- *
- */
-@Deprecated(since="9")
-public class Handler extends sun.net.www.protocol.https.Handler {
-
- public Handler() {
- super();
- }
-
- public Handler(String proxy, int port) {
- super(proxy, port);
- }
-
- protected java.net.URLConnection openConnection(URL u) throws IOException {
- return openConnection(u, (Proxy)null);
- }
-
- protected java.net.URLConnection openConnection(URL u, Proxy p) throws IOException {
- return new HttpsURLConnectionOldImpl(u, p, this);
- }
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnectionOldImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,506 +0,0 @@
-/*
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * NOTE: This class lives in the package sun.net.www.protocol.https.
- * There is a copy in com.sun.net.ssl.internal.www.protocol.https for JSSE
- * 1.0.2 compatibility. It is 100% identical except the package and extends
- * lines. Any changes should be made to be class in sun.net.* and then copied
- * to com.sun.net.*.
- */
-
-// For both copies of the file, uncomment one line and comment the other
-// package sun.net.www.protocol.https;
-package com.sun.net.ssl.internal.www.protocol.https;
-
-import java.net.URL;
-import java.net.Proxy;
-import java.net.ProtocolException;
-import java.net.MalformedURLException;
-import java.io.*;
-import java.net.Authenticator;
-import javax.net.ssl.*;
-import java.security.Permission;
-import java.util.Map;
-import java.util.List;
-import sun.net.www.http.HttpClient;
-
-/**
- * A class to represent an HTTP connection to a remote object.
- *
- * Ideally, this class should subclass and inherit the http handler
- * implementation, but it can't do so because that class have the
- * wrong Java Type. Thus it uses the delegate (aka, the
- * Adapter/Wrapper design pattern) to reuse code from the http
- * handler.
- *
- * Since it would use a delegate to access
- * sun.net.www.protocol.http.HttpURLConnection functionalities, it
- * needs to implement all public methods in it's super class and all
- * the way to Object.
- *
- */
-
-// For both copies of the file, uncomment one line and comment the other
-// public class HttpsURLConnectionImpl
-// extends javax.net.ssl.HttpsURLConnection {
-@Deprecated(since="9")
-@SuppressWarnings("deprecation") // HttpsURLConnection is deprecated
-public class HttpsURLConnectionOldImpl
- extends com.sun.net.ssl.HttpsURLConnection {
-
- private DelegateHttpsURLConnection delegate;
-
-// For both copies of the file, uncomment one line and comment the other
-// HttpsURLConnectionImpl(URL u, Handler handler) throws IOException {
- HttpsURLConnectionOldImpl(URL u, Handler handler) throws IOException {
- this(u, null, handler);
- }
-
- static URL checkURL(URL u) throws IOException {
- if (u != null) {
- if (u.toExternalForm().indexOf('\n') > -1) {
- throw new MalformedURLException("Illegal character in URL");
- }
- }
- return u;
- }
-// For both copies of the file, uncomment one line and comment the other
-// HttpsURLConnectionImpl(URL u, Handler handler) throws IOException {
- HttpsURLConnectionOldImpl(URL u, Proxy p, Handler handler) throws IOException {
- super(checkURL(u));
- delegate = new DelegateHttpsURLConnection(url, p, handler, this);
- }
-
- /**
- * Create a new HttpClient object, bypassing the cache of
- * HTTP client objects/connections.
- *
- * @param url the URL being accessed
- */
- protected void setNewClient(URL url) throws IOException {
- delegate.setNewClient(url, false);
- }
-
- /**
- * Obtain a HttpClient object. Use the cached copy if specified.
- *
- * @param url the URL being accessed
- * @param useCache whether the cached connection should be used
- * if present
- */
- protected void setNewClient(URL url, boolean useCache)
- throws IOException {
- delegate.setNewClient(url, useCache);
- }
-
- /**
- * Create a new HttpClient object, set up so that it uses
- * per-instance proxying to the given HTTP proxy. This
- * bypasses the cache of HTTP client objects/connections.
- *
- * @param url the URL being accessed
- * @param proxyHost the proxy host to use
- * @param proxyPort the proxy port to use
- */
- protected void setProxiedClient(URL url, String proxyHost, int proxyPort)
- throws IOException {
- delegate.setProxiedClient(url, proxyHost, proxyPort);
- }
-
- /**
- * Obtain a HttpClient object, set up so that it uses per-instance
- * proxying to the given HTTP proxy. Use the cached copy of HTTP
- * client objects/connections if specified.
- *
- * @param url the URL being accessed
- * @param proxyHost the proxy host to use
- * @param proxyPort the proxy port to use
- * @param useCache whether the cached connection should be used
- * if present
- */
- protected void setProxiedClient(URL url, String proxyHost, int proxyPort,
- boolean useCache) throws IOException {
- delegate.setProxiedClient(url, proxyHost, proxyPort, useCache);
- }
-
- /**
- * Implements the HTTP protocol handler's "connect" method,
- * establishing an SSL connection to the server as necessary.
- */
- public void connect() throws IOException {
- delegate.connect();
- }
-
- /**
- * Used by subclass to access "connected" variable. Since we are
- * delegating the actual implementation to "delegate", we need to
- * delegate the access of "connected" as well.
- */
- protected boolean isConnected() {
- return delegate.isConnected();
- }
-
- /**
- * Used by subclass to access "connected" variable. Since we are
- * delegating the actual implementation to "delegate", we need to
- * delegate the access of "connected" as well.
- */
- protected void setConnected(boolean conn) {
- delegate.setConnected(conn);
- }
-
- /**
- * Returns the cipher suite in use on this connection.
- */
- public String getCipherSuite() {
- return delegate.getCipherSuite();
- }
-
- /**
- * Returns the certificate chain the client sent to the
- * server, or null if the client did not authenticate.
- */
- public java.security.cert.Certificate []
- getLocalCertificates() {
- return delegate.getLocalCertificates();
- }
-
- /**
- * Returns the server's certificate chain, or throws
- * SSLPeerUnverified Exception if
- * the server did not authenticate.
- */
- public java.security.cert.Certificate []
- getServerCertificates() throws SSLPeerUnverifiedException {
- return delegate.getServerCertificates();
- }
-
- /*
- * Allowable input/output sequences:
- * [interpreted as POST/PUT]
- * - get output, [write output,] get input, [read input]
- * - get output, [write output]
- * [interpreted as GET]
- * - get input, [read input]
- * Disallowed:
- * - get input, [read input,] get output, [write output]
- */
-
- public synchronized OutputStream getOutputStream() throws IOException {
- return delegate.getOutputStream();
- }
-
- public synchronized InputStream getInputStream() throws IOException {
- return delegate.getInputStream();
- }
-
- public InputStream getErrorStream() {
- return delegate.getErrorStream();
- }
-
- /**
- * Disconnect from the server.
- */
- public void disconnect() {
- delegate.disconnect();
- }
-
- public boolean usingProxy() {
- return delegate.usingProxy();
- }
-
- /**
- * Returns an unmodifiable Map of the header fields.
- * The Map keys are Strings that represent the
- * response-header field names. Each Map value is an
- * unmodifiable List of Strings that represents
- * the corresponding field values.
- *
- * @return a Map of header fields
- * @since 1.4
- */
- public Map<String,List<String>> getHeaderFields() {
- return delegate.getHeaderFields();
- }
-
- /**
- * Gets a header field by name. Returns null if not known.
- * @param name the name of the header field
- */
- public String getHeaderField(String name) {
- return delegate.getHeaderField(name);
- }
-
- /**
- * Gets a header field by index. Returns null if not known.
- * @param n the index of the header field
- */
- public String getHeaderField(int n) {
- return delegate.getHeaderField(n);
- }
-
- /**
- * Gets a header field by index. Returns null if not known.
- * @param n the index of the header field
- */
- public String getHeaderFieldKey(int n) {
- return delegate.getHeaderFieldKey(n);
- }
-
- /**
- * Sets request property. If a property with the key already
- * exists, overwrite its value with the new value.
- * @param value the value to be set
- */
- public void setRequestProperty(String key, String value) {
- delegate.setRequestProperty(key, value);
- }
-
- /**
- * Adds a general request property specified by a
- * key-value pair. This method will not overwrite
- * existing values associated with the same key.
- *
- * @param key the keyword by which the request is known
- * (e.g., "<code>accept</code>").
- * @param value the value associated with it.
- * @see #getRequestProperties(java.lang.String)
- * @since 1.4
- */
- public void addRequestProperty(String key, String value) {
- delegate.addRequestProperty(key, value);
- }
-
- /**
- * Overwrite super class method
- */
- public int getResponseCode() throws IOException {
- return delegate.getResponseCode();
- }
-
- public String getRequestProperty(String key) {
- return delegate.getRequestProperty(key);
- }
-
- /**
- * Returns an unmodifiable Map of general request
- * properties for this connection. The Map keys
- * are Strings that represent the request-header
- * field names. Each Map value is a unmodifiable List
- * of Strings that represents the corresponding
- * field values.
- *
- * @return a Map of the general request properties for this connection.
- * @throws IllegalStateException if already connected
- * @since 1.4
- */
- public Map<String,List<String>> getRequestProperties() {
- return delegate.getRequestProperties();
- }
-
- /*
- * We support JDK 1.2.x so we can't count on these from JDK 1.3.
- * We override and supply our own version.
- */
- public void setInstanceFollowRedirects(boolean shouldFollow) {
- delegate.setInstanceFollowRedirects(shouldFollow);
- }
-
- public boolean getInstanceFollowRedirects() {
- return delegate.getInstanceFollowRedirects();
- }
-
- public void setRequestMethod(String method) throws ProtocolException {
- delegate.setRequestMethod(method);
- }
-
- public String getRequestMethod() {
- return delegate.getRequestMethod();
- }
-
- public String getResponseMessage() throws IOException {
- return delegate.getResponseMessage();
- }
-
- public long getHeaderFieldDate(String name, long Default) {
- return delegate.getHeaderFieldDate(name, Default);
- }
-
- public Permission getPermission() throws IOException {
- return delegate.getPermission();
- }
-
- public URL getURL() {
- return delegate.getURL();
- }
-
- public int getContentLength() {
- return delegate.getContentLength();
- }
-
- public long getContentLengthLong() {
- return delegate.getContentLengthLong();
- }
-
- public String getContentType() {
- return delegate.getContentType();
- }
-
- public String getContentEncoding() {
- return delegate.getContentEncoding();
- }
-
- public long getExpiration() {
- return delegate.getExpiration();
- }
-
- public long getDate() {
- return delegate.getDate();
- }
-
- public long getLastModified() {
- return delegate.getLastModified();
- }
-
- public int getHeaderFieldInt(String name, int Default) {
- return delegate.getHeaderFieldInt(name, Default);
- }
-
- public long getHeaderFieldLong(String name, long Default) {
- return delegate.getHeaderFieldLong(name, Default);
- }
-
- public Object getContent() throws IOException {
- return delegate.getContent();
- }
-
- @SuppressWarnings("rawtypes")
- public Object getContent(Class[] classes) throws IOException {
- return delegate.getContent(classes);
- }
-
- public String toString() {
- return delegate.toString();
- }
-
- public void setDoInput(boolean doinput) {
- delegate.setDoInput(doinput);
- }
-
- public boolean getDoInput() {
- return delegate.getDoInput();
- }
-
- public void setDoOutput(boolean dooutput) {
- delegate.setDoOutput(dooutput);
- }
-
- public boolean getDoOutput() {
- return delegate.getDoOutput();
- }
-
- public void setAllowUserInteraction(boolean allowuserinteraction) {
- delegate.setAllowUserInteraction(allowuserinteraction);
- }
-
- public boolean getAllowUserInteraction() {
- return delegate.getAllowUserInteraction();
- }
-
- public void setUseCaches(boolean usecaches) {
- delegate.setUseCaches(usecaches);
- }
-
- public boolean getUseCaches() {
- return delegate.getUseCaches();
- }
-
- public void setIfModifiedSince(long ifmodifiedsince) {
- delegate.setIfModifiedSince(ifmodifiedsince);
- }
-
- public long getIfModifiedSince() {
- return delegate.getIfModifiedSince();
- }
-
- public boolean getDefaultUseCaches() {
- return delegate.getDefaultUseCaches();
- }
-
- public void setDefaultUseCaches(boolean defaultusecaches) {
- delegate.setDefaultUseCaches(defaultusecaches);
- }
-
- /*
- * finalize (dispose) the delegated object. Otherwise
- * sun.net.www.protocol.http.HttpURLConnection's finalize()
- * would have to be made public.
- */
- protected void finalize() throws Throwable {
- delegate.dispose();
- }
-
- public boolean equals(Object obj) {
- return delegate.equals(obj);
- }
-
- public int hashCode() {
- return delegate.hashCode();
- }
-
- public void setConnectTimeout(int timeout) {
- delegate.setConnectTimeout(timeout);
- }
-
- public int getConnectTimeout() {
- return delegate.getConnectTimeout();
- }
-
- public void setReadTimeout(int timeout) {
- delegate.setReadTimeout(timeout);
- }
-
- public int getReadTimeout() {
- return delegate.getReadTimeout();
- }
-
- public void setFixedLengthStreamingMode (int contentLength) {
- delegate.setFixedLengthStreamingMode(contentLength);
- }
-
- public void setFixedLengthStreamingMode(long contentLength) {
- delegate.setFixedLengthStreamingMode(contentLength);
- }
-
- public void setChunkedStreamingMode (int chunklen) {
- delegate.setChunkedStreamingMode(chunklen);
- }
-
- @Override
- public void setAuthenticator(Authenticator auth) {
- delegate.setAuthenticator(auth);
- }
-}
--- a/src/java.base/share/classes/com/sun/net/ssl/package-info.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * 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 classes related to creating and configuring secure socket
- * factories. These classes are used with the Sun reference
- * implementation of the Java Secure Socket Extension (JSSE).
- */
-package com.sun.net.ssl;
--- a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java Sat Mar 09 12:54:20 2019 +0000
@@ -93,13 +93,16 @@
/**
* Creates an AbstractStringBuilder with the specified coder and with
- * the initial capacity equal to the smaller of (capacity + addition)
+ * the initial capacity equal to the smaller of (length + addition)
* and Integer.MAX_VALUE.
*/
- AbstractStringBuilder(byte coder, int capacity, int addition) {
+ AbstractStringBuilder(byte coder, int length, int addition) {
+ if (length < 0) {
+ throw new NegativeArraySizeException("Negative length: " + length);
+ }
this.coder = coder;
- capacity = (capacity < Integer.MAX_VALUE - addition)
- ? capacity + addition : Integer.MAX_VALUE;
+ int capacity = (length < Integer.MAX_VALUE - addition)
+ ? length + addition : Integer.MAX_VALUE;
value = (coder == LATIN1)
? new byte[capacity] : StringUTF16.newBytesFor(capacity);
}
--- a/src/java.base/share/classes/java/lang/StringBuffer.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/lang/StringBuffer.java Sat Mar 09 12:54:20 2019 +0000
@@ -157,10 +157,6 @@
* as the specified {@code CharSequence}. The initial capacity of
* the string buffer is {@code 16} plus the length of the
* {@code CharSequence} argument.
- * <p>
- * If the length of the specified {@code CharSequence} is
- * less than or equal to zero, then an empty buffer of capacity
- * {@code 16} is returned.
*
* @param seq the sequence to copy.
* @since 1.5
--- a/src/java.base/share/classes/java/nio/Buffer.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/nio/Buffer.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -134,8 +134,9 @@
* it already contains: It leaves the limit unchanged and sets the position
* to zero. </p></li>
*
- * <li><p> {@link #slice} creates a subsequence of a buffer: It leaves the
- * limit and the position unchanged. </p></li>
+ * <li><p> The {@link #slice} and {@link #slice(int,int) slice(index,length)}
+ * methods create a subsequence of a buffer: They leave the limit and the
+ * position unchanged. </p></li>
*
* <li><p> {@link #duplicate} creates a shallow copy of a buffer: It leaves
* the limit and the position unchanged. </p></li>
@@ -600,6 +601,39 @@
public abstract Buffer slice();
/**
+ * Creates a new buffer whose content is a shared subsequence of
+ * this buffer's content.
+ *
+ * <p> The content of the new buffer will start at position {@code index}
+ * in this buffer, and will contain {@code length} elements. Changes to
+ * this buffer's content will be visible in the new buffer, and vice versa;
+ * the two buffers' position, limit, and mark values will be independent.
+ *
+ * <p> The new buffer's position will be zero, its capacity and its limit
+ * will be {@code length}, its mark will be undefined. The new buffer will
+ * be direct if, and only if, this buffer is direct, and it will be
+ * read-only if, and only if, this buffer is read-only. </p>
+ *
+ * @param index
+ * The position in this buffer at which the content of the new
+ * buffer will start; must be non-negative and no larger than
+ * {@link #limit() limit()}
+ *
+ * @param length
+ * The number of elements the new buffer will contain; must be
+ * non-negative and no larger than {@code limit() - index}
+ *
+ * @return The new buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If {@code index} is negative or greater than {@code limit()},
+ * {@code length} is negative, or {@code length > limit() - index}
+ *
+ * @since 13
+ */
+ public abstract Buffer slice(int index, int length);
+
+ /**
* Creates a new buffer that shares this buffer's content.
*
* <p> The content of the new buffer will be that of this buffer. Changes
--- a/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* 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,9 +27,9 @@
package java.nio;
+import java.util.Objects;
import jdk.internal.misc.Unsafe;
-
class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
extends {#if[ro]?ByteBufferAs}$Type$Buffer{#if[ro]?$BO$}
{
@@ -85,6 +85,18 @@
return new ByteBufferAs$Type$Buffer$RW$$BO$(bb, -1, 0, rem, rem, addr);
}
+ @Override
+ public $Type$Buffer slice(int index, int length) {
+ Objects.checkIndex(index, limit() + 1);
+ Objects.checkIndex(length, limit() - index + 1);
+ return new ByteBufferAs$Type$Buffer$RW$$BO$(bb,
+ -1,
+ 0,
+ length,
+ length,
+ byteOffset(index));
+ }
+
public $Type$Buffer duplicate() {
return new ByteBufferAs$Type$Buffer$RW$$BO$(bb,
this.markValue(),
--- a/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template Sat Mar 09 12:54:20 2019 +0000
@@ -218,14 +218,17 @@
return new Direct$Type$Buffer$RW$$BO$(this, -1, 0, rem, rem, off);
}
-#if[byte]
- public $Type$Buffer slice(int pos, int lim) {
- assert (pos >= 0);
- assert (pos <= lim);
- int rem = lim - pos;
- return new Direct$Type$Buffer$RW$$BO$(this, -1, 0, rem, rem, pos);
+ @Override
+ public $Type$Buffer slice(int index, int length) {
+ Objects.checkIndex(index, limit() + 1);
+ Objects.checkIndex(length, limit() - index + 1);
+ return new Direct$Type$Buffer$RW$$BO$(this,
+ -1,
+ 0,
+ length,
+ length,
+ index);
}
-#end[byte]
public $Type$Buffer duplicate() {
return new Direct$Type$Buffer$RW$$BO$(this,
--- a/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template Sat Mar 09 12:54:20 2019 +0000
@@ -27,6 +27,8 @@
package java.nio;
+import java.util.Objects;
+
/**
#if[rw]
* A read/write Heap$Type$Buffer.
@@ -38,8 +40,6 @@
#end[rw]
*/
-import java.util.Objects;
-
class Heap$Type$Buffer$RW$
extends {#if[ro]?Heap}$Type$Buffer
{
@@ -112,19 +112,17 @@
this.position() + offset);
}
-#if[byte]
- $Type$Buffer slice(int pos, int lim) {
- assert (pos >= 0);
- assert (pos <= lim);
- int rem = lim - pos;
+ @Override
+ public $Type$Buffer slice(int index, int length) {
+ Objects.checkIndex(index, limit() + 1);
+ Objects.checkIndex(length, limit() - index + 1);
return new Heap$Type$Buffer$RW$(hb,
-1,
0,
- rem,
- rem,
- pos + offset);
+ length,
+ length,
+ index + offset);
}
-#end[byte]
public $Type$Buffer duplicate() {
return new Heap$Type$Buffer$RW$(hb,
--- a/src/java.base/share/classes/java/nio/StringCharBuffer.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/nio/StringCharBuffer.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
package java.nio;
+import java.util.Objects;
// ## If the sequence is a string, use reflection to share its array
@@ -51,6 +52,18 @@
offset + this.position());
}
+ @Override
+ public CharBuffer slice(int index, int length) {
+ Objects.checkIndex(index, limit() + 1);
+ Objects.checkIndex(length, limit() - index + 1);
+ return new StringCharBuffer(str,
+ -1,
+ 0,
+ length,
+ length,
+ offset + index);
+ }
+
private StringCharBuffer(CharSequence s,
int mark,
int pos,
--- a/src/java.base/share/classes/java/nio/X-Buffer.java.template Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template Sat Mar 09 12:54:20 2019 +0000
@@ -547,6 +547,46 @@
public abstract $Type$Buffer slice();
/**
+ * Creates a new $type$ buffer whose content is a shared subsequence of
+ * this buffer's content.
+ *
+ * <p> The content of the new buffer will start at position {@code index}
+ * in this buffer, and will contain {@code length} elements. Changes to
+ * this buffer's content will be visible in the new buffer, and vice versa;
+ * the two buffers' position, limit, and mark values will be independent.
+ *
+ * <p> The new buffer's position will be zero, its capacity and its limit
+ * will be {@code length}, its mark will be undefined, and its byte order
+ * will be
+#if[byte]
+ * {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}.
+#else[byte]
+ * identical to that of this buffer.
+#end[byte]
+ * The new buffer will be direct if, and only if, this buffer is direct,
+ * and it will be read-only if, and only if, this buffer is read-only. </p>
+ *
+ * @param index
+ * The position in this buffer at which the content of the new
+ * buffer will start; must be non-negative and no larger than
+ * {@link #limit() limit()}
+ *
+ * @param length
+ * The number of elements the new buffer will contain; must be
+ * non-negative and no larger than {@code limit() - index}
+ *
+ * @return The new buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If {@code index} is negative or greater than {@code limit()},
+ * {@code length} is negative, or {@code length > limit() - index}
+ *
+ * @since 13
+ */
+ @Override
+ public abstract $Type$Buffer slice(int index, int length);
+
+ /**
* Creates a new $type$ buffer that shares this buffer's content.
*
* <p> The content of the new buffer will be that of this buffer. Changes
@@ -1950,11 +1990,9 @@
aligned_pos = aligned_lim = pos;
}
- return slice(aligned_pos, aligned_lim);
+ return slice(aligned_pos, aligned_lim - aligned_pos);
}
- abstract ByteBuffer slice(int pos, int lim);
-
// #BIN
//
// Binary-data access methods for short, char, int, long, float,
--- a/src/java.base/share/classes/java/security/Security.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/security/Security.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -201,7 +201,7 @@
private static void initializeStatic() {
props.put("security.provider.1", "sun.security.provider.Sun");
props.put("security.provider.2", "sun.security.rsa.SunRsaSign");
- props.put("security.provider.3", "com.sun.net.ssl.internal.ssl.Provider");
+ props.put("security.provider.3", "sun.security.ssl.SunJSSE");
props.put("security.provider.4", "com.sun.crypto.provider.SunJCE");
props.put("security.provider.5", "sun.security.jgss.SunProvider");
props.put("security.provider.6", "com.sun.security.sasl.Provider");
--- a/src/java.base/share/classes/java/security/Signature.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/security/Signature.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -285,7 +285,6 @@
signatureInfo.put("sun.security.rsa.RSASignature$SHA384withRSA", TRUE);
signatureInfo.put("sun.security.rsa.RSASignature$SHA512withRSA", TRUE);
signatureInfo.put("sun.security.rsa.RSAPSSSignature", TRUE);
- signatureInfo.put("com.sun.net.ssl.internal.ssl.RSASignature", TRUE);
signatureInfo.put("sun.security.pkcs11.P11Signature", TRUE);
}
--- a/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1022,9 +1022,11 @@
String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field,
fieldValue, style, locale);
- // If the ERA value is null, then
+ // If the ERA value is null or empty, then
// try to get its name or abbreviation from the Era instance.
- if (name == null && field == ERA && fieldValue < eras.length) {
+ if ((name == null || name.isEmpty()) &&
+ field == ERA &&
+ fieldValue < eras.length) {
Era era = eras[fieldValue];
name = (style == SHORT) ? era.getAbbreviation() : era.getName();
}
--- a/src/java.base/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -71,10 +71,6 @@
* Create a new HttpClient object, bypassing the cache of
* HTTP client objects/connections.
*
- * Note: this method is changed from protected to public because
- * the com.sun.ssl.internal.www.protocol.https handler reuses this
- * class for its actual implemantation
- *
* @param url the URL being accessed
*/
public void setNewClient (URL url)
@@ -85,10 +81,6 @@
/**
* Obtain a HttpClient object. Use the cached copy if specified.
*
- * Note: this method is changed from protected to public because
- * the com.sun.ssl.internal.www.protocol.https handler reuses this
- * class for its actual implemantation
- *
* @param url the URL being accessed
* @param useCache whether the cached connection should be used
* if present
@@ -107,10 +99,6 @@
* per-instance proxying to the given HTTP proxy. This
* bypasses the cache of HTTP client objects/connections.
*
- * Note: this method is changed from protected to public because
- * the com.sun.ssl.internal.www.protocol.https handler reuses this
- * class for its actual implemantation
- *
* @param url the URL being accessed
* @param proxyHost the proxy host to use
* @param proxyPort the proxy port to use
@@ -125,10 +113,6 @@
* proxying to the given HTTP proxy. Use the cached copy of HTTP
* client objects/connections if specified.
*
- * Note: this method is changed from protected to public because
- * the com.sun.ssl.internal.www.protocol.https handler reuses this
- * class for its actual implemantation
- *
* @param url the URL being accessed
* @param proxyHost the proxy host to use
* @param proxyPort the proxy port to use
--- a/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,17 +23,7 @@
* questions.
*/
-/*
- * NOTE: This class lives in the package sun.net.www.protocol.https.
- * There is a copy in com.sun.net.ssl.internal.www.protocol.https for JSSE
- * 1.0.2 compatibility. It is 100% identical except the package and extends
- * lines. Any changes should be made to be class in sun.net.* and then copied
- * to com.sun.net.*.
- */
-
-// For both copies of the file, uncomment one line and comment the other
package sun.net.www.protocol.https;
-// package com.sun.net.ssl.internal.www.protocol.https;
import java.net.URL;
import java.net.Proxy;
@@ -64,21 +54,13 @@
* the way to Object.
*
*/
-
-// For both copies of the file, uncomment one line and comment the
-// other. The differences between the two copies are introduced for
-// plugin, and it is marked as such.
public class HttpsURLConnectionImpl
extends javax.net.ssl.HttpsURLConnection {
-// public class HttpsURLConnectionOldImpl
-// extends com.sun.net.ssl.HttpsURLConnection {
// NOTE: made protected for plugin so that subclass can set it.
protected DelegateHttpsURLConnection delegate;
-// For both copies of the file, uncomment one line and comment the other
HttpsURLConnectionImpl(URL u, Handler handler) throws IOException {
-// HttpsURLConnectionOldImpl(URL u, Handler handler) throws IOException {
this(u, null, handler);
}
@@ -90,9 +72,8 @@
}
return u;
}
-// For both copies of the file, uncomment one line and comment the other
+
HttpsURLConnectionImpl(URL u, Proxy p, Handler handler) throws IOException {
-// HttpsURLConnectionOldImpl(URL u, Proxy p, Handler handler) throws IOException {
super(checkURL(u));
delegate = new DelegateHttpsURLConnection(url, p, handler, this);
}
--- a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -178,8 +178,12 @@
p = new sun.security.rsa.SunRsaSign();
} else if (provName.equals("SunJCE") || provName.equals("com.sun.crypto.provider.SunJCE")) {
p = new com.sun.crypto.provider.SunJCE();
- } else if (provName.equals("SunJSSE") || provName.equals("com.sun.net.ssl.internal.ssl.Provider")) {
- p = new com.sun.net.ssl.internal.ssl.Provider();
+ } else if (provName.equals("SunJSSE") ||
+ provName.equals("com.sun.net.ssl.internal.ssl.Provider")) {
+ // com.sun.net.ssl.internal.ssl.Provider is the legacy SunJSSE
+ // provider implementation. For compatibility, let's continue to
+ // support the legacy name for a while.
+ p = new sun.security.ssl.SunJSSE();
} else if (provName.equals("Apple") || provName.equals("apple.security.AppleProvider")) {
// need to use reflection since this class only exists on MacOsx
p = AccessController.doPrivileged(new PrivilegedAction<Provider>() {
--- a/src/java.base/share/classes/sun/security/provider/PolicyFile.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/sun/security/provider/PolicyFile.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URI;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.security.*;
@@ -37,7 +38,6 @@
import java.security.cert.X509Certificate;
import javax.security.auth.Subject;
import javax.security.auth.x500.X500Principal;
-import java.io.FilePermission;
import java.net.SocketPermission;
import java.net.NetPermission;
import java.util.concurrent.ConcurrentHashMap;
@@ -273,23 +273,6 @@
private static Set<URL> badPolicyURLs =
Collections.newSetFromMap(new ConcurrentHashMap<URL,Boolean>());
- // The default.policy file
- private static final URL DEFAULT_POLICY_URL =
- AccessController.doPrivileged(new PrivilegedAction<>() {
- @Override
- public URL run() {
- String sep = File.separator;
- try {
- return Path.of(StaticProperty.javaHome(),
- "lib", "security",
- "default.policy").toUri().toURL();
- } catch (MalformedURLException mue) {
- // should not happen
- throw new Error("Malformed default.policy URL: " + mue);
- }
- }
- });
-
/**
* Initializes the Policy object and reads the default policy
* configuration file(s) into the Policy object.
@@ -349,13 +332,10 @@
private void initPolicyFile(final PolicyInfo newInfo, final URL url) {
// always load default.policy
- if (debug != null) {
- debug.println("reading " + DEFAULT_POLICY_URL);
- }
AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Void run() {
- init(DEFAULT_POLICY_URL, newInfo, true);
+ initDefaultPolicy(newInfo);
return null;
}
});
@@ -373,7 +353,7 @@
AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Void run() {
- if (init(url, newInfo, false) == false) {
+ if (init(url, newInfo) == false) {
// use static policy if all else fails
initStaticPolicy(newInfo);
}
@@ -429,7 +409,7 @@
if (debug != null) {
debug.println("reading "+policyURL);
}
- if (init(policyURL, newInfo, false)) {
+ if (init(policyURL, newInfo)) {
loaded_policy = true;
}
} catch (Exception e) {
@@ -472,7 +452,7 @@
if (debug != null) {
debug.println("reading " + policy_url);
}
- if (init(policy_url, newInfo, false)) {
+ if (init(policy_url, newInfo)) {
loaded_policy = true;
}
} catch (Exception e) {
@@ -492,11 +472,34 @@
return loadedPolicy;
}
+ private void initDefaultPolicy(PolicyInfo newInfo) {
+ Path defaultPolicy = Path.of(StaticProperty.javaHome(),
+ "lib",
+ "security",
+ "default.policy");
+ if (debug != null) {
+ debug.println("reading " + defaultPolicy);
+ }
+ try (BufferedReader br = Files.newBufferedReader(defaultPolicy)) {
+
+ PolicyParser pp = new PolicyParser(expandProperties);
+ pp.read(br);
+
+ Enumeration<PolicyParser.GrantEntry> enum_ = pp.grantElements();
+ while (enum_.hasMoreElements()) {
+ PolicyParser.GrantEntry ge = enum_.nextElement();
+ addGrantEntry(ge, null, newInfo);
+ }
+ } catch (Exception e) {
+ throw new InternalError("Failed to load default.policy", e);
+ }
+ }
+
/**
* Reads a policy configuration into the Policy object using a
* Reader object.
*/
- private boolean init(URL policy, PolicyInfo newInfo, boolean defPolicy) {
+ private boolean init(URL policy, PolicyInfo newInfo) {
// skip parsing policy file if it has been previously parsed and
// has syntax errors
@@ -537,9 +540,6 @@
}
return true;
} catch (PolicyParser.ParsingException pe) {
- if (defPolicy) {
- throw new InternalError("Failed to load default.policy", pe);
- }
// record bad policy file to avoid later reparsing it
badPolicyURLs.add(policy);
Object[] source = {policy, pe.getNonlocalizedMessage()};
@@ -549,9 +549,6 @@
pe.printStackTrace();
}
} catch (Exception e) {
- if (defPolicy) {
- throw new InternalError("Failed to load default.policy", e);
- }
if (debug != null) {
debug.println("error parsing "+policy);
debug.println(e.toString());
--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
* 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/java.base/share/classes/sun/security/ssl/SunJSSE.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/sun/security/ssl/SunJSSE.java Sat Mar 09 12:54:20 2019 +0000
@@ -58,7 +58,7 @@
* FIPS mode.
*
*/
-public abstract class SunJSSE extends java.security.Provider {
+public class SunJSSE extends java.security.Provider {
private static final long serialVersionUID = 3231825739635378733L;
@@ -66,9 +66,8 @@
"(PKCS12, SunX509/PKIX key/trust factories, " +
"SSLv3/TLSv1/TLSv1.1/TLSv1.2/TLSv1.3/DTLSv1.0/DTLSv1.2)";
- protected SunJSSE() {
+ public SunJSSE() {
super("SunJSSE", PROVIDER_VER, info);
- subclassCheck();
registerAlgorithms();
}
@@ -136,12 +135,4 @@
ps("KeyStore", "PKCS12",
"sun.security.pkcs12.PKCS12KeyStore", null, null);
}
-
- // com.sun.net.ssl.internal.ssl.Provider has been deprecated since JDK 9
- @SuppressWarnings("deprecation")
- private void subclassCheck() {
- if (getClass() != com.sun.net.ssl.internal.ssl.Provider.class) {
- throw new AssertionError("Illegal subclass: " + getClass());
- }
- }
}
--- a/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -73,31 +73,28 @@
@Override
protected String[] getDisplayNameArray(String id, Locale locale) {
- String tzid = TimeZoneNameUtility.canonicalTZID(id).orElse(id);
- String[] namesSuper = super.getDisplayNameArray(tzid, locale);
+ // Use English for the ROOT locale
+ locale = locale.equals(Locale.ROOT) ? Locale.ENGLISH : locale;
+ String[] namesSuper = super.getDisplayNameArray(id, locale);
- if (Objects.nonNull(namesSuper)) {
+ if (namesSuper == null) {
+ // try canonical id instead
+ namesSuper = super.getDisplayNameArray(
+ TimeZoneNameUtility.canonicalTZID(id).orElse(id),
+ locale);
+ }
+
+ if (namesSuper != null) {
// CLDR's resource bundle has an translated entry for this id.
// Fix up names if needed, either missing or no-inheritance
namesSuper[INDEX_TZID] = id;
- // Check if standard long name exists. If not, try to retrieve the name
- // from language only locale resources. E.g., "Europe/London"
- // for en-GB only contains DST names
- if (!exists(namesSuper, INDEX_STD_LONG) && !locale.getCountry().isEmpty()) {
- String[] names =
- getDisplayNameArray(id, Locale.forLanguageTag(locale.getLanguage()));
- if (exists(names, INDEX_STD_LONG)) {
- namesSuper[INDEX_STD_LONG] = names[INDEX_STD_LONG];
- }
- }
-
for(int i = INDEX_STD_LONG; i < namesSuper.length; i++) { // index 0 is the 'id' itself
switch (namesSuper[i]) {
case "":
// Fill in empty elements
deriveFallbackName(namesSuper, i, locale,
- namesSuper[INDEX_DST_LONG].isEmpty());
+ !exists(namesSuper, INDEX_DST_LONG));
break;
case NO_INHERITANCE_MARKER:
// CLDR's "no inheritance marker"
@@ -141,16 +138,19 @@
// Derive fallback time zone name according to LDML's logic
private void deriveFallbackNames(String[] names, Locale locale) {
+ boolean noDST = !exists(names, INDEX_DST_LONG);
for (int i = INDEX_STD_LONG; i <= INDEX_GEN_SHORT; i++) {
- deriveFallbackName(names, i, locale, false);
+ deriveFallbackName(names, i, locale, noDST);
}
}
private void deriveFallbackName(String[] names, int index, Locale locale, boolean noDST) {
+ String id = names[INDEX_TZID];
+
if (exists(names, index)) {
if (names[index].equals(NO_INHERITANCE_MARKER)) {
// CLDR's "no inheritance marker"
- names[index] = toGMTFormat(names[INDEX_TZID],
+ names[index] = toGMTFormat(id,
index == INDEX_DST_LONG || index == INDEX_DST_SHORT,
index % 2 != 0, locale);
}
@@ -160,8 +160,8 @@
// Check if COMPAT can substitute the name
if (LocaleProviderAdapter.getAdapterPreference().contains(Type.JRE)) {
String[] compatNames = (String[])LocaleProviderAdapter.forJRE()
- .getLocaleResources(locale)
- .getTimeZoneNames(names[INDEX_TZID]);
+ .getLocaleResources(mapChineseLocale(locale))
+ .getTimeZoneNames(id);
if (compatNames != null) {
for (int i = INDEX_STD_LONG; i <= INDEX_GEN_SHORT; i++) {
// Assumes COMPAT has no empty slots
@@ -184,9 +184,8 @@
}
// last resort
- String id = names[INDEX_TZID].toUpperCase(Locale.ROOT);
- if (!id.startsWith("UT")) {
- names[index] = toGMTFormat(names[INDEX_TZID],
+ if (!id.toUpperCase(Locale.ROOT).startsWith("UT")) {
+ names[index] = toGMTFormat(id,
index == INDEX_DST_LONG || index == INDEX_DST_SHORT,
index % 2 != 0,
locale);
@@ -290,4 +289,33 @@
String.format(l, hourFormat, offset / 60, offset % 60));
}
}
+
+ // Mapping CLDR's Simplified/Traditional Chinese resources
+ // to COMPAT's zh-CN/TW
+ private Locale mapChineseLocale(Locale locale) {
+ if (locale.getLanguage() == "zh") {
+ switch (locale.getScript()) {
+ case "Hans":
+ return Locale.CHINA;
+ case "Hant":
+ return Locale.TAIWAN;
+ case "":
+ // no script, guess from country code.
+ switch (locale.getCountry()) {
+ case "":
+ case "CN":
+ case "SG":
+ return Locale.CHINA;
+ case "HK":
+ case "MO":
+ case "TW":
+ return Locale.TAIWAN;
+ }
+ break;
+ }
+ }
+
+ // no need to map
+ return locale;
+ }
}
--- a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import sun.security.action.GetPropertyAction;
-import sun.util.calendar.ZoneInfo;
import sun.util.resources.LocaleData;
import sun.util.resources.OpenListResourceBundle;
import sun.util.resources.ParallelListResourceBundle;
@@ -271,17 +270,31 @@
if (Objects.isNull(data) || Objects.isNull(val = data.get())) {
TimeZoneNamesBundle tznb = localeData.getTimeZoneNames(locale);
- if (tznb.containsKey(key)) {
- if (key.startsWith(TZNB_EXCITY_PREFIX)) {
+ if (key.startsWith(TZNB_EXCITY_PREFIX)) {
+ if (tznb.containsKey(key)) {
val = tznb.getString(key);
assert val instanceof String;
trace("tznb: %s key: %s, val: %s\n", tznb, key, val);
+ }
+ } else {
+ String[] names = null;
+ if (tznb.containsKey(key)) {
+ names = tznb.getStringArray(key);
} else {
- String[] names = tznb.getStringArray(key);
+ var tz = TimeZoneNameUtility.canonicalTZID(key).orElse(key);
+ if (tznb.containsKey(tz)) {
+ names = tznb.getStringArray(tz);
+ }
+ }
+
+ if (names != null) {
+ names[0] = key;
trace("tznb: %s key: %s, names: %s, %s, %s, %s, %s, %s, %s\n", tznb, key,
names[0], names[1], names[2], names[3], names[4], names[5], names[6]);
val = names;
}
+ }
+ if (val != null) {
cache.put(cacheKey,
new ResourceReference(cacheKey, val, referenceQueue));
}
@@ -321,8 +334,6 @@
}
if (type == LocaleProviderAdapter.Type.CLDR) {
- // Add aliases data for CLDR
- Map<String, String> aliases = ZoneInfo.getAliasTable();
// Note: TimeZoneNamesBundle creates a String[] on each getStringArray call.
// Add timezones which are not present in this keyset,
@@ -335,9 +346,10 @@
if (keyset.contains(tzid)) {
val = rb.getStringArray(tzid);
} else {
- String tz = aliases.get(tzid);
- if (keyset.contains(tz)) {
- val = rb.getStringArray(tz);
+ var canonID = TimeZoneNameUtility.canonicalTZID(tzid)
+ .orElse(tzid);
+ if (keyset.contains(canonID)) {
+ val = rb.getStringArray(canonID);
}
}
val[0] = tzid;
--- a/src/java.base/unix/native/libjli/java_md_solinux.c Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.base/unix/native/libjli/java_md_solinux.c Sat Mar 09 12:54:20 2019 +0000
@@ -303,6 +303,9 @@
#ifdef SETENV_REQUIRED
jboolean mustsetenv = JNI_FALSE;
+#ifdef __solaris__
+ char *llp64 = NULL; /* existing LD_LIBRARY_PATH_64 setting */
+#endif // __solaris__
char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */
char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
char* newpath = NULL; /* path on new LD_LIBRARY_PATH */
@@ -367,7 +370,12 @@
* any.
*/
+#ifdef __solaris__
+ llp64 = getenv("LD_LIBRARY_PATH_64");
+ runpath = (llp64 == NULL) ? getenv(LD_LIBRARY_PATH) : llp64;
+#else
runpath = getenv(LD_LIBRARY_PATH);
+#endif /* __solaris__ */
/* runpath contains current effective LD_LIBRARY_PATH setting */
{ /* New scope to declare local variable */
@@ -440,6 +448,14 @@
* once at startup, so we have to re-exec the current executable
* to get the changed environment variable to have an effect.
*/
+#ifdef __solaris__
+ /*
+ * new LD_LIBRARY_PATH took over for LD_LIBRARY_PATH_64
+ */
+ if (llp64 != NULL) {
+ UnsetEnv("LD_LIBRARY_PATH_64");
+ }
+#endif // __solaris__
newenvp = environ;
}
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java Sat Mar 09 12:54:20 2019 +0000
@@ -148,7 +148,8 @@
* @return String with Base64 encoding
*/
public static final String encode(BigInteger big) {
- return encode(getBytes(big, big.bitLength()));
+ byte[] bytes = XMLUtils.getBytes(big, big.bitLength());
+ return XMLUtils.encodeToString(bytes);
}
/**
@@ -214,9 +215,9 @@
* @return a decoded BigInteger
* @throws Base64DecodingException
*/
- public static BigInteger decodeBigIntegerFromString(String base64str)
- throws Base64DecodingException {
- return new BigInteger(1, Base64.decode(base64str));
+ public static final BigInteger decodeBigIntegerFromText(Text text)
+ throws Base64DecodingException {
+ return new BigInteger(1, Base64.decode(text.getData()));
}
/**
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java Sat Mar 09 12:54:20 2019 +0000
@@ -28,6 +28,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -443,6 +444,25 @@
}
}
+ public static String encodeToString(byte[] bytes) {
+ if (ignoreLineBreaks) {
+ return Base64.getEncoder().encodeToString(bytes);
+ }
+ return Base64.getMimeEncoder().encodeToString(bytes);
+ }
+
+ public static byte[] decode(String encodedString) {
+ return Base64.getMimeDecoder().decode(encodedString);
+ }
+
+ public static byte[] decode(byte[] encodedBytes) {
+ return Base64.getMimeDecoder().decode(encodedBytes);
+ }
+
+ public static boolean isIgnoreLineBreaks() {
+ return ignoreLineBreaks;
+ }
+
/**
* Method convertNodelistToSet
*
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/AbstractDOMSignatureMethod.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/AbstractDOMSignatureMethod.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,19 +29,23 @@
import java.security.SignatureException;
import java.security.spec.AlgorithmParameterSpec;
import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.SignatureMethod;
+import javax.xml.crypto.dsig.SignedInfo;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.XMLSignatureException;
import javax.xml.crypto.dsig.XMLSignContext;
import javax.xml.crypto.dsig.XMLValidateContext;
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* An abstract class representing a SignatureMethod. Subclasses implement
* a specific XML DSig signature algorithm.
*/
-abstract class AbstractDOMSignatureMethod extends BaseStructure
+abstract class AbstractDOMSignatureMethod extends DOMStructure
implements SignatureMethod {
// denotes the type of signature algorithm
@@ -65,7 +69,7 @@
* as the passed in signature is improperly encoded
* @throws XMLSignatureException if an unexpected error occurs
*/
- abstract boolean verify(Key key, DOMSignedInfo si, byte[] sig,
+ abstract boolean verify(Key key, SignedInfo si, byte[] sig,
XMLValidateContext context)
throws InvalidKeyException, SignatureException, XMLSignatureException;
@@ -83,7 +87,7 @@
* the wrong type, or parameters are missing, etc
* @throws XMLSignatureException if an unexpected error occurs
*/
- abstract byte[] sign(Key key, DOMSignedInfo si, XMLSignContext context)
+ abstract byte[] sign(Key key, SignedInfo si, XMLSignContext context)
throws InvalidKeyException, XMLSignatureException;
/**
@@ -101,16 +105,21 @@
* This method invokes the {@link #marshalParams marshalParams}
* method to marshal any algorithm-specific parameters.
*/
- public void marshal(XmlWriter xwriter, String dsPrefix)
+ @Override
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
throws MarshalException
{
- xwriter.writeStartElement(dsPrefix, "SignatureMethod", XMLSignature.XMLNS);
- xwriter.writeAttribute("", "", "Algorithm", getAlgorithm());
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+
+ Element smElem = DOMUtils.createElement(ownerDoc, "SignatureMethod",
+ XMLSignature.XMLNS, dsPrefix);
+ DOMUtils.setAttribute(smElem, "Algorithm", getAlgorithm());
if (getParameterSpec() != null) {
- marshalParams(xwriter, dsPrefix);
+ marshalParams(smElem, dsPrefix);
}
- xwriter.writeEndElement(); // "SignatureMethod"
+
+ parent.appendChild(smElem);
}
/**
@@ -123,7 +132,7 @@
* @param paramsPrefix the algorithm parameters prefix to use
* @throws MarshalException if the parameters cannot be marshalled
*/
- void marshalParams(XmlWriter xwriter, String paramsPrefix)
+ void marshalParams(Element parent, String paramsPrefix)
throws MarshalException
{
throw new MarshalException("no parameters should " +
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java Sat Mar 09 12:54:20 2019 +0000
@@ -69,7 +69,6 @@
return params;
}
- @Override
public void init(XMLStructure parent, XMLCryptoContext context)
throws InvalidAlgorithmParameterException
{
@@ -88,7 +87,6 @@
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
- @Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java Sat Mar 09 12:54:20 2019 +0000
@@ -45,7 +45,6 @@
this.xi = xi;
}
- @Override
public XMLSignatureInput getXMLSignatureInput() {
return xi;
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java Sat Mar 09 12:54:20 2019 +0000
@@ -67,7 +67,6 @@
return params;
}
- @Override
public void init(XMLStructure parent, XMLCryptoContext context)
throws InvalidAlgorithmParameterException
{
@@ -86,7 +85,6 @@
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
- @Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
@@ -105,7 +103,6 @@
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
- @Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException
{
@@ -115,7 +112,6 @@
return transformIt(data, xc, null);
}
- @Override
public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
throws TransformException
{
@@ -206,7 +202,6 @@
}
}
- @Override
public final boolean isFeatureSupported(String feature) {
if (feature == null) {
throw new NullPointerException();
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/BaseStructure.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jcp.xml.dsig.internal.dom;
-
-import javax.xml.crypto.XMLStructure;
-
-import org.w3c.dom.Node;
-
-public abstract class BaseStructure implements XMLStructure {
-
- /**
- * Just return the text of the immediate child of a node.
- *
- * @param node
- * @return the text of a Node
- */
- public static String textOfNode(Node node) {
- return node.getFirstChild().getNodeValue();
- }
-
- public final boolean isFeatureSupported(String feature) {
- if (feature == null) {
- throw new NullPointerException();
- } else {
- return false;
- }
- }
-
-}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java Sat Mar 09 12:54:20 2019 +0000
@@ -48,7 +48,6 @@
public static final String C14N_11_WITH_COMMENTS
= "http://www.w3.org/2006/12/xml-c14n11#WithComments";
- @Override
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException {
if (params != null) {
@@ -57,7 +56,6 @@
}
}
- @Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException {
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java Sat Mar 09 12:54:20 2019 +0000
@@ -44,7 +44,6 @@
*/
public final class DOMCanonicalXMLC14NMethod extends ApacheCanonicalizer {
- @Override
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException {
if (params != null) {
@@ -53,7 +52,6 @@
}
}
- @Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ */
+/*
+ * $Id$
+ */
+package org.jcp.xml.dsig.internal.dom;
+
+import java.math.BigInteger;
+import javax.xml.crypto.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
+
+import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+/**
+ * A DOM-based representation of the XML <code>CryptoBinary</code> simple type
+ * as defined in the W3C specification for XML-Signature Syntax and Processing.
+ * The XML Schema Definition is defined as:
+ *
+ * <xmp>
+ * <simpleType name="CryptoBinary">
+ * <restriction base = "base64Binary">
+ * </restriction>
+ * </simpleType>
+ * </xmp>
+ *
+ * @author Sean Mullan
+ */
+public final class DOMCryptoBinary extends DOMStructure {
+
+ private final BigInteger bigNum;
+ private final String value;
+
+ /**
+ * Create a <code>DOMCryptoBinary</code> instance from the specified
+ * <code>BigInteger</code>
+ *
+ * @param bigNum the arbitrary-length integer
+ * @throws NullPointerException if <code>bigNum</code> is <code>null</code>
+ */
+ public DOMCryptoBinary(BigInteger bigNum) {
+ if (bigNum == null) {
+ throw new NullPointerException("bigNum is null");
+ }
+ this.bigNum = bigNum;
+ // convert to bitstring
+ byte[] bytes = XMLUtils.getBytes(bigNum, bigNum.bitLength());
+ value = XMLUtils.encodeToString(bytes);
+ }
+
+ /**
+ * Creates a <code>DOMCryptoBinary</code> from a node.
+ *
+ * @param cbNode a CryptoBinary text node
+ * @throws MarshalException if value cannot be decoded (invalid format)
+ */
+ public DOMCryptoBinary(Node cbNode) throws MarshalException {
+ value = cbNode.getNodeValue();
+ try {
+ bigNum = new BigInteger(1, XMLUtils.decode(((Text) cbNode).getData()));
+ } catch (Exception ex) {
+ throw new MarshalException(ex);
+ }
+ }
+
+ /**
+ * Returns the <code>BigInteger</code> that this object contains.
+ *
+ * @return the <code>BigInteger</code> that this object contains
+ */
+ public BigInteger getBigNum() {
+ return bigNum;
+ }
+
+ @Override
+ public void marshal(Node parent, String prefix, DOMCryptoContext context)
+ throws MarshalException {
+ parent.appendChild
+ (DOMUtils.getOwnerDocument(parent).createTextNode(value));
+ }
+}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,18 +29,21 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
import java.security.InvalidAlgorithmParameterException;
import java.security.spec.AlgorithmParameterSpec;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* DOM-based abstract implementation of DigestMethod.
*
*/
-public abstract class DOMDigestMethod extends BaseStructure
+public abstract class DOMDigestMethod extends DOMStructure
implements DigestMethod {
static final String SHA224 =
@@ -147,7 +150,6 @@
}
}
- @Override
public final AlgorithmParameterSpec getParameterSpec() {
return params;
}
@@ -175,17 +177,21 @@
* This method invokes the abstract {@link #marshalParams marshalParams}
* method to marshal any algorithm-specific parameters.
*/
- public static void marshal(XmlWriter xwriter, DigestMethod digest, String prefix)
+ @Override
+ public void marshal(Node parent, String prefix, DOMCryptoContext context)
throws MarshalException
{
- xwriter.writeStartElement(prefix, "DigestMethod", XMLSignature.XMLNS);
- xwriter.writeAttribute("", "", "Algorithm", digest.getAlgorithm());
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+
+ Element dmElem = DOMUtils.createElement(ownerDoc, "DigestMethod",
+ XMLSignature.XMLNS, prefix);
+ DOMUtils.setAttribute(dmElem, "Algorithm", getAlgorithm());
- // this is totally over-engineered - nothing implements marshalParams.
- if (digest.getParameterSpec() != null && digest instanceof DOMDigestMethod) {
- ( (DOMDigestMethod) digest).marshalParams(xwriter, prefix);
+ if (params != null) {
+ marshalParams(dmElem, prefix);
}
- xwriter.writeEndElement(); // "DigestMethod"
+
+ parent.appendChild(dmElem);
}
@Override
@@ -226,7 +232,7 @@
* @param the namespace prefix to use
* @throws MarshalException if the parameters cannot be marshalled
*/
- void marshalParams(XmlWriter xwriter, String prefix)
+ void marshalParams(Element parent, String prefix)
throws MarshalException
{
throw new MarshalException("no parameters should " +
@@ -248,11 +254,9 @@
SHA1(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return DigestMethod.SHA1;
}
- @Override
String getMessageDigestAlgorithm() {
return "SHA-1";
}
@@ -284,11 +288,9 @@
SHA256(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return DigestMethod.SHA256;
}
- @Override
String getMessageDigestAlgorithm() {
return "SHA-256";
}
@@ -302,11 +304,9 @@
SHA384(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return SHA384;
}
- @Override
String getMessageDigestAlgorithm() {
return "SHA-384";
}
@@ -320,11 +320,9 @@
SHA512(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return DigestMethod.SHA512;
}
- @Override
String getMessageDigestAlgorithm() {
return "SHA-512";
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java Sat Mar 09 12:54:20 2019 +0000
@@ -38,7 +38,6 @@
*/
public final class DOMEnvelopedTransform extends ApacheTransform {
- @Override
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException {
if (params != null) {
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java Sat Mar 09 12:54:20 2019 +0000
@@ -50,7 +50,6 @@
*/
public final class DOMExcC14NMethod extends ApacheCanonicalizer {
- @Override
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException
{
@@ -63,7 +62,6 @@
}
}
- @Override
public void init(XMLStructure parent, XMLCryptoContext context)
throws InvalidAlgorithmParameterException
{
@@ -109,12 +107,20 @@
return;
}
- XmlWriterToTree xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), transformElem);
-
- String prefix =
- DOMUtils.getNSPrefix(context, CanonicalizationMethod.EXCLUSIVE);
- xwriter.writeStartElement(prefix, "InclusiveNamespaces", CanonicalizationMethod.EXCLUSIVE);
- xwriter.writeNamespace(prefix, CanonicalizationMethod.EXCLUSIVE);
+ String prefix = DOMUtils.getNSPrefix(context,
+ CanonicalizationMethod.EXCLUSIVE);
+ Element eElem = DOMUtils.createElement(ownerDoc,
+ "InclusiveNamespaces",
+ CanonicalizationMethod.EXCLUSIVE,
+ prefix);
+ if (prefix == null || prefix.length() == 0) {
+ eElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
+ CanonicalizationMethod.EXCLUSIVE);
+ } else {
+ eElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
+ "xmlns:" + prefix,
+ CanonicalizationMethod.EXCLUSIVE);
+ }
ExcC14NParameterSpec params = (ExcC14NParameterSpec)spec;
StringBuilder prefixListAttr = new StringBuilder("");
@@ -125,16 +131,15 @@
prefixListAttr.append(" ");
}
}
- xwriter.writeAttribute("", "", "PrefixList", prefixListAttr.toString());
+ DOMUtils.setAttribute(eElem, "PrefixList", prefixListAttr.toString());
this.inclusiveNamespaces = prefixListAttr.toString();
- xwriter.writeEndElement(); // "InclusiveNamespaces"
+ transformElem.appendChild(eElem);
}
public String getParamsNSURI() {
return CanonicalizationMethod.EXCLUSIVE;
}
- @Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException
{
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java Sat Mar 09 12:54:20 2019 +0000
@@ -42,6 +42,7 @@
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.jcp.xml.dsig.internal.MacOutputStream;
@@ -117,30 +118,32 @@
}
}
- @Override
public final AlgorithmParameterSpec getParameterSpec() {
return params;
}
- @Override
SignatureMethodParameterSpec unmarshalParams(Element paramsElem)
throws MarshalException
{
- outputLength = Integer.parseInt(textOfNode(paramsElem));
+ outputLength = Integer.parseInt(paramsElem.getFirstChild().getNodeValue());
outputLengthSet = true;
LOG.debug("unmarshalled outputLength: {}", outputLength);
return new HMACParameterSpec(outputLength);
}
- @Override
- void marshalParams(XmlWriter xwriter, String prefix)
+ void marshalParams(Element parent, String prefix)
throws MarshalException
{
- xwriter.writeTextElement(prefix, "HMACOutputLength", XMLSignature.XMLNS, String.valueOf(outputLength));
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+ Element hmacElem = DOMUtils.createElement(ownerDoc, "HMACOutputLength",
+ XMLSignature.XMLNS, prefix);
+ hmacElem.appendChild(ownerDoc.createTextNode
+ (String.valueOf(outputLength)));
+
+ parent.appendChild(hmacElem);
}
- @Override
- boolean verify(Key key, DOMSignedInfo si, byte[] sig,
+ boolean verify(Key key, SignedInfo si, byte[] sig,
XMLValidateContext context)
throws InvalidKeyException, SignatureException, XMLSignatureException
{
@@ -162,14 +165,13 @@
("HMACOutputLength must not be less than " + getDigestLength());
}
hmac.init(key);
- si.canonicalize(context, new MacOutputStream(hmac));
+ ((DOMSignedInfo)si).canonicalize(context, new MacOutputStream(hmac));
byte[] result = hmac.doFinal();
return MessageDigest.isEqual(sig, result);
}
- @Override
- byte[] sign(Key key, DOMSignedInfo si, XMLSignContext context)
+ byte[] sign(Key key, SignedInfo si, XMLSignContext context)
throws InvalidKeyException, XMLSignatureException
{
if (key == null || si == null) {
@@ -190,11 +192,10 @@
("HMACOutputLength must not be less than " + getDigestLength());
}
hmac.init(key);
- si.canonicalize(context, new MacOutputStream(hmac));
+ ((DOMSignedInfo)si).canonicalize(context, new MacOutputStream(hmac));
return hmac.doFinal();
}
- @Override
boolean paramsEqual(AlgorithmParameterSpec spec) {
if (getParameterSpec() == spec) {
return true;
@@ -207,7 +208,6 @@
return outputLength == ospec.getOutputLength();
}
- @Override
Type getAlgorithmType() {
return Type.HMAC;
}
@@ -225,15 +225,12 @@
SHA1(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return SignatureMethod.HMAC_SHA1;
}
- @Override
String getJCAAlgorithm() {
return "HmacSHA1";
}
- @Override
int getDigestLength() {
return 160;
}
@@ -269,15 +266,12 @@
SHA256(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return HMAC_SHA256;
}
- @Override
String getJCAAlgorithm() {
return "HmacSHA256";
}
- @Override
int getDigestLength() {
return 256;
}
@@ -291,15 +285,12 @@
SHA384(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return HMAC_SHA384;
}
- @Override
String getJCAAlgorithm() {
return "HmacSHA384";
}
- @Override
int getDigestLength() {
return 384;
}
@@ -313,15 +304,12 @@
SHA512(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return HMAC_SHA512;
}
- @Override
String getJCAAlgorithm() {
return "HmacSHA512";
}
- @Override
int getDigestLength() {
return 512;
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java Sat Mar 09 12:54:20 2019 +0000
@@ -36,10 +36,13 @@
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.XMLCryptoContext;
import javax.xml.crypto.XMLStructure;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.dom.DOMSignContext;
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -47,7 +50,7 @@
* DOM-based implementation of KeyInfo.
*
*/
-public final class DOMKeyInfo extends BaseStructure implements KeyInfo {
+public final class DOMKeyInfo extends DOMStructure implements KeyInfo {
private final String id;
private final List<XMLStructure> keyInfoTypes;
@@ -101,7 +104,14 @@
Provider provider)
throws MarshalException
{
- id = DOMUtils.getIdAttributeValue(kiElem, "Id");
+ // get Id attribute, if specified
+ Attr attr = kiElem.getAttributeNodeNS(null, "Id");
+ if (attr != null) {
+ id = attr.getValue();
+ kiElem.setIdAttributeNode(attr, true);
+ } else {
+ id = null;
+ }
// get all children nodes
List<XMLStructure> content = new ArrayList<>();
@@ -134,17 +144,14 @@
keyInfoTypes = Collections.unmodifiableList(content);
}
- @Override
public String getId() {
return id;
}
- @Override
public List<XMLStructure> getContent() {
return keyInfoTypes;
}
- @Override
public void marshal(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
@@ -155,44 +162,62 @@
throw new ClassCastException("parent must be of type DOMStructure");
}
- internalMarshal( (javax.xml.crypto.dom.DOMStructure) parent, context);
- }
-
- private void internalMarshal(javax.xml.crypto.dom.DOMStructure parent, XMLCryptoContext context)
- throws MarshalException {
- Node pNode = parent.getNode();
+ Node pNode = ((javax.xml.crypto.dom.DOMStructure)parent).getNode();
String dsPrefix = DOMUtils.getSignaturePrefix(context);
+ Element kiElem = DOMUtils.createElement
+ (DOMUtils.getOwnerDocument(pNode), "KeyInfo",
+ XMLSignature.XMLNS, dsPrefix);
+ if (dsPrefix == null || dsPrefix.length() == 0) {
+ kiElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
+ "xmlns", XMLSignature.XMLNS);
+ } else {
+ kiElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
+ "xmlns:" + dsPrefix, XMLSignature.XMLNS);
+ }
Node nextSibling = null;
if (context instanceof DOMSignContext) {
nextSibling = ((DOMSignContext)context).getNextSibling();
}
-
- XmlWriterToTree xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), pNode, nextSibling);
- marshalInternal(xwriter, this, dsPrefix, context, true);
+ marshal(pNode, kiElem, nextSibling, dsPrefix, (DOMCryptoContext)context);
}
- public static void marshal(XmlWriter xwriter, KeyInfo ki, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- marshalInternal(xwriter, ki, dsPrefix, context, false);
+ @Override
+ public void marshal(Node parent, String dsPrefix,
+ DOMCryptoContext context)
+ throws MarshalException
+ {
+ marshal(parent, null, dsPrefix, context);
}
- private static void marshalInternal(XmlWriter xwriter, KeyInfo ki,
- String dsPrefix, XMLCryptoContext context, boolean declareNamespace) throws MarshalException {
+ public void marshal(Node parent, Node nextSibling, String dsPrefix,
+ DOMCryptoContext context)
+ throws MarshalException
+ {
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+ Element kiElem = DOMUtils.createElement(ownerDoc, "KeyInfo",
+ XMLSignature.XMLNS, dsPrefix);
+ marshal(parent, kiElem, nextSibling, dsPrefix, context);
+ }
- xwriter.writeStartElement(dsPrefix, "KeyInfo", XMLSignature.XMLNS);
- if (declareNamespace) {
- xwriter.writeNamespace(dsPrefix, XMLSignature.XMLNS);
+ private void marshal(Node parent, Element kiElem, Node nextSibling,
+ String dsPrefix, DOMCryptoContext context)
+ throws MarshalException
+ {
+ // create and append KeyInfoType elements
+ for (XMLStructure kiType : keyInfoTypes) {
+ if (kiType instanceof DOMStructure) {
+ ((DOMStructure)kiType).marshal(kiElem, dsPrefix, context);
+ } else {
+ DOMUtils.appendChild(kiElem,
+ ((javax.xml.crypto.dom.DOMStructure)kiType).getNode());
+ }
}
- xwriter.writeIdAttribute("", "", "Id", ki.getId());
- // create and append KeyInfoType elements
- List<XMLStructure> keyInfoTypes = getContent(ki);
- for (XMLStructure kiType : keyInfoTypes) {
- xwriter.marshalStructure(kiType, dsPrefix, context);
- }
+ // append id attribute
+ DOMUtils.setAttributeID(kiElem, "Id", id);
- xwriter.writeEndElement(); // "KeyInfo"
+ parent.insertBefore(kiElem, nextSibling);
}
@Override
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java Sat Mar 09 12:54:20 2019 +0000
@@ -31,15 +31,24 @@
import java.math.BigInteger;
import java.security.KeyException;
import java.security.PublicKey;
+import java.security.interfaces.ECPublicKey;
import java.security.interfaces.DSAPublicKey;
-import java.security.interfaces.ECPublicKey;
import java.security.interfaces.RSAPublicKey;
import java.util.List;
-import javax.xml.crypto.*;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.URIDereferencer;
+import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.XMLSignature;
-import javax.xml.crypto.dsig.keyinfo.*;
+import javax.xml.crypto.dsig.keyinfo.KeyInfo;
+import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
+import javax.xml.crypto.dsig.keyinfo.KeyName;
+import javax.xml.crypto.dsig.keyinfo.KeyValue;
+import javax.xml.crypto.dsig.keyinfo.PGPData;
+import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
+import javax.xml.crypto.dsig.keyinfo.X509Data;
+import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -53,24 +62,20 @@
public DOMKeyInfoFactory() { }
- @Override
@SuppressWarnings("rawtypes")
public KeyInfo newKeyInfo(List content) {
return newKeyInfo(content, null);
}
- @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public KeyInfo newKeyInfo(List content, String id) {
return new DOMKeyInfo(content, id);
}
- @Override
public KeyName newKeyName(String name) {
return new DOMKeyName(name);
}
- @Override
public KeyValue newKeyValue(PublicKey key) throws KeyException {
String algorithm = key.getAlgorithm();
if ("DSA".equals(algorithm)) {
@@ -84,30 +89,25 @@
}
}
- @Override
public PGPData newPGPData(byte[] keyId) {
return newPGPData(keyId, null, null);
}
- @Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public PGPData newPGPData(byte[] keyId, byte[] keyPacket, List other) {
return new DOMPGPData(keyId, keyPacket, other);
}
- @Override
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public PGPData newPGPData(byte[] keyPacket, List other) {
return new DOMPGPData(keyPacket, other);
}
- @Override
public RetrievalMethod newRetrievalMethod(String uri) {
return newRetrievalMethod(uri, null, null);
}
- @Override
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public RetrievalMethod newRetrievalMethod(String uri, String type,
List transforms) {
if (uri == null) {
@@ -116,8 +116,7 @@
return new DOMRetrievalMethod(uri, type, transforms);
}
- @Override
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings({ "rawtypes" })
public X509Data newX509Data(List content) {
return new DOMX509Data(content);
}
@@ -128,7 +127,6 @@
return new DOMX509IssuerSerial(issuerName, serialNumber);
}
- @Override
public boolean isFeatureSupported(String feature) {
if (feature == null) {
throw new NullPointerException();
@@ -137,7 +135,6 @@
}
}
- @Override
public URIDereferencer getURIDereferencer() {
return DOMURIDereferencer.INSTANCE;
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java Sat Mar 09 12:54:20 2019 +0000
@@ -28,15 +28,20 @@
*/
package org.jcp.xml.dsig.internal.dom;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dom.DOMCryptoContext;
+import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.keyinfo.KeyName;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* DOM-based implementation of KeyName.
*
*/
-public final class DOMKeyName extends BaseStructure implements KeyName {
+public final class DOMKeyName extends DOMStructure implements KeyName {
private final String name;
@@ -59,12 +64,23 @@
* @param knElem a KeyName element
*/
public DOMKeyName(Element knElem) {
- name = textOfNode(knElem);
+ name = knElem.getFirstChild().getNodeValue();
+ }
+
+ public String getName() {
+ return name;
}
@Override
- public String getName() {
- return name;
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
+ throws MarshalException
+ {
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+ // prepend namespace prefix, if necessary
+ Element knElem = DOMUtils.createElement(ownerDoc, "KeyName",
+ XMLSignature.XMLNS, dsPrefix);
+ knElem.appendChild(ownerDoc.createTextNode(name));
+ parent.appendChild(knElem);
}
@Override
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,6 +29,7 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dsig.keyinfo.KeyValue;
@@ -53,16 +54,17 @@
import java.security.spec.KeySpec;
import java.security.spec.RSAPublicKeySpec;
import java.util.Arrays;
-import java.util.Base64;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* DOM-based implementation of KeyValue.
*
*/
-public abstract class DOMKeyValue<K extends PublicKey> extends BaseStructure implements KeyValue {
+public abstract class DOMKeyValue<K extends PublicKey> extends DOMStructure implements KeyValue {
private static final String XMLDSIG_11_XMLNS
= "http://www.w3.org/2009/xmldsig11#";
@@ -102,7 +104,6 @@
}
}
- @Override
public PublicKey getPublicKey() throws KeyException {
if (publicKey == null) {
throw new KeyException("can't convert KeyValue to PublicKey");
@@ -111,17 +112,22 @@
}
}
- public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context)
+ @Override
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
throws MarshalException
{
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+
// create KeyValue element
- xwriter.writeStartElement(dsPrefix, "KeyValue", XMLSignature.XMLNS);
- marshalPublicKey(xwriter, publicKey, dsPrefix, context);
- xwriter.writeEndElement(); // "KeyValue"
+ Element kvElem = DOMUtils.createElement(ownerDoc, "KeyValue",
+ XMLSignature.XMLNS, dsPrefix);
+ marshalPublicKey(kvElem, ownerDoc, dsPrefix, context);
+
+ parent.appendChild(kvElem);
}
- abstract void marshalPublicKey(XmlWriter xwriter, K key, String dsPrefix,
- XMLCryptoContext context) throws MarshalException;
+ abstract void marshalPublicKey(Node parent, Document doc, String dsPrefix,
+ DOMCryptoContext context) throws MarshalException;
abstract K unmarshalKeyValue(Element kvtElem)
throws MarshalException;
@@ -162,25 +168,13 @@
public static BigInteger decode(Element elem) throws MarshalException {
try {
- String base64str = BaseStructure.textOfNode(elem);
- return new BigInteger(1, Base64.getMimeDecoder().decode(base64str));
+ String base64str = elem.getFirstChild().getNodeValue();
+ return new BigInteger(1, XMLUtils.decode(base64str));
} catch (Exception ex) {
throw new MarshalException(ex);
}
}
- public static void writeBase64BigIntegerElement(
- XmlWriter xwriter, String prefix, String localName, String namespaceURI, BigInteger value
- ) {
- byte[] bytes = XMLUtils.getBytes(value, value.bitLength());
- xwriter.writeTextElement(prefix, localName, namespaceURI, Base64.getMimeEncoder().encodeToString(bytes));
- }
-
- public static void marshal(XmlWriter xwriter, BigInteger bigNum) {
- byte[] bytes = XMLUtils.getBytes(bigNum, bigNum.bitLength());
- xwriter.writeCharacters(Base64.getMimeEncoder().encodeToString(bytes));
- }
-
@Override
public int hashCode() {
int result = 17;
@@ -193,25 +187,36 @@
static final class RSA extends DOMKeyValue<RSAPublicKey> {
// RSAKeyValue CryptoBinaries
+ private DOMCryptoBinary modulus, exponent;
private KeyFactory rsakf;
RSA(RSAPublicKey key) throws KeyException {
super(key);
+ RSAPublicKey rkey = key;
+ exponent = new DOMCryptoBinary(rkey.getPublicExponent());
+ modulus = new DOMCryptoBinary(rkey.getModulus());
}
RSA(Element elem) throws MarshalException {
super(elem);
}
- @Override
- void marshalPublicKey(XmlWriter xwriter, RSAPublicKey publicKey, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- xwriter.writeStartElement(dsPrefix, "RSAKeyValue", XMLSignature.XMLNS);
-
- writeBase64BigIntegerElement(xwriter, dsPrefix, "Modulus", XMLSignature.XMLNS, publicKey.getModulus());
- writeBase64BigIntegerElement(xwriter, dsPrefix, "Exponent", XMLSignature.XMLNS, publicKey.getPublicExponent());
-
- xwriter.writeEndElement(); // "RSAKeyValue"
+ void marshalPublicKey(Node parent, Document doc, String dsPrefix,
+ DOMCryptoContext context) throws MarshalException {
+ Element rsaElem = DOMUtils.createElement(doc, "RSAKeyValue",
+ XMLSignature.XMLNS,
+ dsPrefix);
+ Element modulusElem = DOMUtils.createElement(doc, "Modulus",
+ XMLSignature.XMLNS,
+ dsPrefix);
+ Element exponentElem = DOMUtils.createElement(doc, "Exponent",
+ XMLSignature.XMLNS,
+ dsPrefix);
+ modulus.marshal(modulusElem, dsPrefix, context);
+ exponent.marshal(exponentElem, dsPrefix, context);
+ rsaElem.appendChild(modulusElem);
+ rsaElem.appendChild(exponentElem);
+ parent.appendChild(rsaElem);
}
@Override
@@ -241,10 +246,17 @@
static final class DSA extends DOMKeyValue<DSAPublicKey> {
// DSAKeyValue CryptoBinaries
+ private DOMCryptoBinary p, q, g, y; //, seed, pgen;
private KeyFactory dsakf;
DSA(DSAPublicKey key) throws KeyException {
super(key);
+ DSAPublicKey dkey = key;
+ DSAParams params = dkey.getParams();
+ p = new DOMCryptoBinary(params.getP());
+ q = new DOMCryptoBinary(params.getQ());
+ g = new DOMCryptoBinary(params.getG());
+ y = new DOMCryptoBinary(dkey.getY());
}
DSA(Element elem) throws MarshalException {
@@ -252,21 +264,31 @@
}
@Override
- void marshalPublicKey(XmlWriter xwriter, DSAPublicKey publicKey, String dsPrefix,
- XMLCryptoContext context)
+ void marshalPublicKey(Node parent, Document doc, String dsPrefix,
+ DOMCryptoContext context)
throws MarshalException
{
- DSAParams params = publicKey.getParams();
-
- xwriter.writeStartElement(dsPrefix, "DSAKeyValue", XMLSignature.XMLNS);
-
+ Element dsaElem = DOMUtils.createElement(doc, "DSAKeyValue",
+ XMLSignature.XMLNS,
+ dsPrefix);
// parameters J, Seed & PgenCounter are not included
- writeBase64BigIntegerElement(xwriter, dsPrefix, "P", XMLSignature.XMLNS, params.getP());
- writeBase64BigIntegerElement(xwriter, dsPrefix, "Q", XMLSignature.XMLNS, params.getQ());
- writeBase64BigIntegerElement(xwriter, dsPrefix, "G", XMLSignature.XMLNS, params.getG());
- writeBase64BigIntegerElement(xwriter, dsPrefix, "Y", XMLSignature.XMLNS, publicKey.getY() );
-
- xwriter.writeEndElement(); // "DSAKeyValue"
+ Element pElem = DOMUtils.createElement(doc, "P", XMLSignature.XMLNS,
+ dsPrefix);
+ Element qElem = DOMUtils.createElement(doc, "Q", XMLSignature.XMLNS,
+ dsPrefix);
+ Element gElem = DOMUtils.createElement(doc, "G", XMLSignature.XMLNS,
+ dsPrefix);
+ Element yElem = DOMUtils.createElement(doc, "Y", XMLSignature.XMLNS,
+ dsPrefix);
+ p.marshal(pElem, dsPrefix, context);
+ q.marshal(qElem, dsPrefix, context);
+ g.marshal(gElem, dsPrefix, context);
+ y.marshal(yElem, dsPrefix, context);
+ dsaElem.appendChild(pElem);
+ dsaElem.appendChild(qElem);
+ dsaElem.appendChild(gElem);
+ dsaElem.appendChild(yElem);
+ parent.appendChild(dsaElem);
}
@Override
@@ -316,8 +338,7 @@
}
static final class EC extends DOMKeyValue<ECPublicKey> {
-
- // ECKeyValue CryptoBinaries
+ // ECKeyValue CryptoBinaries
private byte[] ecPublicKey;
private KeyFactory eckf;
private ECParameterSpec ecParams;
@@ -460,27 +481,35 @@
}
@Override
- void marshalPublicKey(XmlWriter xwriter, ECPublicKey publicKey, String dsPrefix,
- XMLCryptoContext context)
+ void marshalPublicKey(Node parent, Document doc, String dsPrefix,
+ DOMCryptoContext context)
throws MarshalException
{
String prefix = DOMUtils.getNSPrefix(context, XMLDSIG_11_XMLNS);
- xwriter.writeStartElement(prefix, "ECKeyValue", XMLDSIG_11_XMLNS);
-
- xwriter.writeStartElement(prefix, "NamedCurve", XMLDSIG_11_XMLNS);
- xwriter.writeNamespace(prefix, XMLDSIG_11_XMLNS);
+ Element ecKeyValueElem = DOMUtils.createElement(doc, "ECKeyValue",
+ XMLDSIG_11_XMLNS,
+ prefix);
+ Element namedCurveElem = DOMUtils.createElement(doc, "NamedCurve",
+ XMLDSIG_11_XMLNS,
+ prefix);
+ Element publicKeyElem = DOMUtils.createElement(doc, "PublicKey",
+ XMLDSIG_11_XMLNS,
+ prefix);
String oid = getCurveOid(ecParams);
if (oid == null) {
throw new MarshalException("Invalid ECParameterSpec");
}
- xwriter.writeAttribute("", "", "URI", "urn:oid:" + oid);
- xwriter.writeEndElement();
-
- xwriter.writeStartElement(prefix, "PublicKey", XMLDSIG_11_XMLNS);
- String encoded = Base64.getMimeEncoder().encodeToString(ecPublicKey);
- xwriter.writeCharacters(encoded);
- xwriter.writeEndElement(); // "PublicKey"
- xwriter.writeEndElement(); // "ECKeyValue"
+ DOMUtils.setAttribute(namedCurveElem, "URI", "urn:oid:" + oid);
+ String qname = (prefix == null || prefix.length() == 0)
+ ? "xmlns" : "xmlns:" + prefix;
+ namedCurveElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
+ qname, XMLDSIG_11_XMLNS);
+ ecKeyValueElem.appendChild(namedCurveElem);
+ String encoded = XMLUtils.encodeToString(ecPublicKey);
+ publicKeyElem.appendChild
+ (DOMUtils.getOwnerDocument(publicKeyElem).createTextNode(encoded));
+ ecKeyValueElem.appendChild(publicKeyElem);
+ parent.appendChild(ecKeyValueElem);
}
@Override
@@ -526,7 +555,7 @@
try {
String content = XMLUtils.getFullTextChildrenFromElement(curElem);
- ecPoint = decodePoint(Base64.getMimeDecoder().decode(content),
+ ecPoint = decodePoint(XMLUtils.decode(content),
ecParams.getCurve());
} catch (IOException ioe) {
throw new MarshalException("Invalid EC Point", ioe);
@@ -574,21 +603,23 @@
}
static final class Unknown extends DOMKeyValue<PublicKey> {
- private XMLStructure externalPublicKey;
+ private javax.xml.crypto.dom.DOMStructure externalPublicKey;
Unknown(Element elem) throws MarshalException {
super(elem);
}
+
@Override
PublicKey unmarshalKeyValue(Element kvElem) throws MarshalException {
externalPublicKey = new javax.xml.crypto.dom.DOMStructure(kvElem);
return null;
}
+
@Override
- void marshalPublicKey(XmlWriter xwriter, PublicKey publicKey, String dsPrefix,
- XMLCryptoContext context)
+ void marshalPublicKey(Node parent, Document doc, String dsPrefix,
+ DOMCryptoContext context)
throws MarshalException
{
- xwriter.marshalStructure(externalPublicKey, dsPrefix, context);
+ parent.appendChild(externalPublicKey.getNode());
}
}
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,18 +29,21 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import java.security.Provider;
import java.util.*;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* DOM-based implementation of Manifest.
*
*/
-public final class DOMManifest extends BaseStructure implements Manifest {
+public final class DOMManifest extends DOMStructure implements Manifest {
private final List<Reference> references;
private final String id;
@@ -58,7 +61,7 @@
* @throws ClassCastException if {@code references} contains any
* entries that are not of type {@link Reference}
*/
- public DOMManifest(List<DOMReference> references, String id) {
+ public DOMManifest(List<? extends Reference> references, String id) {
if (references == null) {
throw new NullPointerException("references cannot be null");
}
@@ -114,7 +117,6 @@
this.references = Collections.unmodifiableList(refs);
}
- @Override
public String getId() {
return id;
}
@@ -129,18 +131,21 @@
return references;
}
- public static void marshal(XmlWriter xwriter, Manifest manif, String dsPrefix, XMLCryptoContext context)
- throws MarshalException {
- xwriter.writeStartElement(dsPrefix, "Manifest", XMLSignature.XMLNS);
- xwriter.writeIdAttribute("", "", "Id", manif.getId());
+ @Override
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
+ throws MarshalException
+ {
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+ Element manElem = DOMUtils.createElement(ownerDoc, "Manifest",
+ XMLSignature.XMLNS, dsPrefix);
+
+ DOMUtils.setAttributeID(manElem, "Id", id);
// add references
- @SuppressWarnings("unchecked")
- List<Reference> references = manif.getReferences();
for (Reference ref : references) {
- ((DOMReference)ref).marshal(xwriter, dsPrefix, context);
+ ((DOMReference)ref).marshal(manElem, dsPrefix, context);
}
- xwriter.writeEndElement(); // "Manifest"
+ parent.appendChild(manElem);
}
@Override
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java Sat Mar 09 12:54:20 2019 +0000
@@ -31,9 +31,11 @@
import java.util.*;
import javax.xml.crypto.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.keyinfo.PGPData;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -43,7 +45,7 @@
* DOM-based implementation of PGPData.
*
*/
-public final class DOMPGPData extends BaseStructure implements PGPData {
+public final class DOMPGPData extends DOMStructure implements PGPData {
private final byte[] keyId;
private final byte[] keyPacket;
@@ -156,10 +158,10 @@
String namespace = childElem.getNamespaceURI();
if ("PGPKeyID".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
String content = XMLUtils.getFullTextChildrenFromElement(childElem);
- pgpKeyId = Base64.getMimeDecoder().decode(content);
+ pgpKeyId = XMLUtils.decode(content);
} else if ("PGPKeyPacket".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
String content = XMLUtils.getFullTextChildrenFromElement(childElem);
- pgpKeyPacket = Base64.getMimeDecoder().decode(content);
+ pgpKeyPacket = XMLUtils.decode(content);
} else {
other.add
(new javax.xml.crypto.dom.DOMStructure(childElem));
@@ -172,21 +174,56 @@
this.externalElements = Collections.unmodifiableList(other);
}
- @Override
public byte[] getKeyId() {
return keyId == null ? null : keyId.clone();
}
- @Override
public byte[] getKeyPacket() {
return keyPacket == null ? null : keyPacket.clone();
}
- @Override
public List<XMLStructure> getExternalElements() {
return externalElements;
}
+ @Override
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
+ throws MarshalException
+ {
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+ Element pdElem = DOMUtils.createElement(ownerDoc, "PGPData",
+ XMLSignature.XMLNS, dsPrefix);
+
+ // create and append PGPKeyID element
+ if (keyId != null) {
+ Element keyIdElem = DOMUtils.createElement(ownerDoc, "PGPKeyID",
+ XMLSignature.XMLNS,
+ dsPrefix);
+ keyIdElem.appendChild
+ (ownerDoc.createTextNode(XMLUtils.encodeToString(keyId)));
+ pdElem.appendChild(keyIdElem);
+ }
+
+ // create and append PGPKeyPacket element
+ if (keyPacket != null) {
+ Element keyPktElem = DOMUtils.createElement(ownerDoc,
+ "PGPKeyPacket",
+ XMLSignature.XMLNS,
+ dsPrefix);
+ keyPktElem.appendChild
+ (ownerDoc.createTextNode(XMLUtils.encodeToString(keyPacket)));
+ pdElem.appendChild(keyPktElem);
+ }
+
+ // create and append any elements
+ for (XMLStructure extElem : externalElements) {
+ DOMUtils.appendChild(pdElem, ((javax.xml.crypto.dom.DOMStructure)
+ extElem).getNode());
+ }
+
+ parent.appendChild(pdElem);
+ }
+
/**
* We assume packets use the new format packet syntax, as specified in
* section 4 of RFC 2440.
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java Sat Mar 09 12:54:20 2019 +0000
@@ -37,6 +37,7 @@
import javax.xml.crypto.*;
import javax.xml.crypto.dsig.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dom.DOMURIReference;
import java.io.*;
@@ -46,6 +47,7 @@
import java.util.*;
import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -54,6 +56,7 @@
import org.jcp.xml.dsig.internal.DigesterOutputStream;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream;
+import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
/**
* DOM-based implementation of Reference.
@@ -242,7 +245,7 @@
// unmarshal DigestValue
Element dvElem = DOMUtils.getNextSiblingElement(dmElem, "DigestValue", XMLSignature.XMLNS);
String content = XMLUtils.getFullTextChildrenFromElement(dvElem);
- this.digestValue = Base64.getMimeDecoder().decode(content);
+ this.digestValue = XMLUtils.decode(content);
// check for extra elements
if (DOMUtils.getNextSiblingElement(dvElem) != null) {
@@ -252,7 +255,14 @@
// unmarshal attributes
this.uri = DOMUtils.getAttributeValue(refElem, "URI");
- this.id = DOMUtils.getIdAttributeValue(refElem, "Id");
+
+ Attr attr = refElem.getAttributeNodeNS(null, "Id");
+ if (attr != null) {
+ this.id = attr.getValue();
+ refElem.setIdAttributeNode(attr, true);
+ } else {
+ this.id = null;
+ }
this.type = DOMUtils.getAttributeValue(refElem, "Type");
this.here = refElem.getAttributeNodeNS(null, "URI");
@@ -263,76 +273,80 @@
this.provider = provider;
}
- @Override
public DigestMethod getDigestMethod() {
return digestMethod;
}
- @Override
public String getId() {
return id;
}
- @Override
public String getURI() {
return uri;
}
- @Override
public String getType() {
return type;
}
- @Override
public List<Transform> getTransforms() {
return Collections.unmodifiableList(allTransforms);
}
- @Override
public byte[] getDigestValue() {
return digestValue == null ? null : digestValue.clone();
}
- @Override
public byte[] getCalculatedDigestValue() {
return calcDigestValue == null ? null
: calcDigestValue.clone();
}
@Override
- public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context)
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
throws MarshalException
{
LOG.debug("Marshalling Reference");
- xwriter.writeStartElement(dsPrefix, "Reference", XMLSignature.XMLNS);
- XMLStructure refStruct = xwriter.getCurrentNodeAsStructure();
- refElem = (Element) ((javax.xml.crypto.dom.DOMStructure) refStruct).getNode();
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+ refElem = DOMUtils.createElement(ownerDoc, "Reference",
+ XMLSignature.XMLNS, dsPrefix);
// set attributes
- xwriter.writeIdAttribute("", "", "Id", id);
- here = xwriter.writeAttribute("", "", "URI", uri);
- xwriter.writeAttribute("", "", "Type", type);
+ DOMUtils.setAttributeID(refElem, "Id", id);
+ DOMUtils.setAttribute(refElem, "URI", uri);
+ DOMUtils.setAttribute(refElem, "Type", type);
// create and append Transforms element
if (!allTransforms.isEmpty()) {
- xwriter.writeStartElement(dsPrefix, "Transforms", XMLSignature.XMLNS);
+ Element transformsElem = DOMUtils.createElement(ownerDoc,
+ "Transforms",
+ XMLSignature.XMLNS,
+ dsPrefix);
+ refElem.appendChild(transformsElem);
for (Transform transform : allTransforms) {
- xwriter.marshalStructure(transform, dsPrefix, context);
+ ((DOMStructure)transform).marshal(transformsElem,
+ dsPrefix, context);
}
- xwriter.writeEndElement(); // "Transforms"
}
// create and append DigestMethod element
- DOMDigestMethod.marshal(xwriter, digestMethod, dsPrefix);
+ ((DOMDigestMethod)digestMethod).marshal(refElem, dsPrefix, context);
// create and append DigestValue element
LOG.debug("Adding digestValueElem");
- xwriter.writeStartElement(dsPrefix, "DigestValue", XMLSignature.XMLNS);
+ Element digestValueElem = DOMUtils.createElement(ownerDoc,
+ "DigestValue",
+ XMLSignature.XMLNS,
+ dsPrefix);
if (digestValue != null) {
- xwriter.writeCharacters(Base64.getMimeEncoder().encodeToString(digestValue));
+ digestValueElem.appendChild
+ (ownerDoc.createTextNode(XMLUtils.encodeToString(digestValue)));
+
}
- xwriter.writeEndElement(); // "DigestValue"
- xwriter.writeEndElement(); // "Reference"
+ refElem.appendChild(digestValueElem);
+
+ parent.appendChild(refElem);
+ here = refElem.getAttributeNodeNS(null, "URI");
}
public void digest(XMLSignContext signContext)
@@ -347,7 +361,7 @@
digestValue = transform(data, signContext);
// insert digestValue into DigestValue element
- String encodedDV = Base64.getMimeEncoder().encodeToString(digestValue);
+ String encodedDV = XMLUtils.encodeToString(digestValue);
LOG.debug("Reference object uri = {}", uri);
Element digestElem = DOMUtils.getLastChildElement(refElem);
if (digestElem == null) {
@@ -361,7 +375,6 @@
LOG.debug("Reference digesting completed");
}
- @Override
public boolean validate(XMLValidateContext validateContext)
throws XMLSignatureException
{
@@ -375,8 +388,8 @@
calcDigestValue = transform(data, validateContext);
if (LOG.isDebugEnabled()) {
- LOG.debug("Expected digest: " + Base64.getMimeEncoder().encodeToString(digestValue));
- LOG.debug("Actual digest: " + Base64.getMimeEncoder().encodeToString(calcDigestValue));
+ LOG.debug("Expected digest: " + XMLUtils.encodeToString(digestValue));
+ LOG.debug("Actual digest: " + XMLUtils.encodeToString(calcDigestValue));
}
validationStatus = Arrays.equals(digestValue, calcDigestValue);
@@ -384,12 +397,10 @@
return validationStatus;
}
- @Override
public Data getDereferencedData() {
return derefData;
}
- @Override
public InputStream getDigestInputStream() {
return dis;
}
@@ -516,8 +527,8 @@
} else {
transformsElem = DOMUtils.getFirstChildElement(refElem);
}
- XmlWriter xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), transformsElem);
- t.marshal(xwriter, dsPrefix, context);
+ t.marshal(transformsElem, dsPrefix,
+ (DOMCryptoContext)context);
allTransforms.add(t);
xi.updateOutputStream(os, true);
} else {
@@ -550,7 +561,6 @@
}
}
- @Override
public Node getHere() {
return here;
}
@@ -614,7 +624,6 @@
try {
final Set<Node> s = xsi.getNodeSet();
return new NodeSetData<Node>() {
- @Override
public Iterator<Node> iterator() { return s.iterator(); }
};
} catch (Exception e) {
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java Sat Mar 09 12:54:20 2019 +0000
@@ -52,6 +52,7 @@
import javax.xml.crypto.URIReferenceException;
import javax.xml.crypto.XMLCryptoContext;
import javax.xml.crypto.XMLStructure;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dom.DOMURIReference;
import javax.xml.crypto.dsig.Transform;
import javax.xml.crypto.dsig.XMLSignature;
@@ -179,50 +180,53 @@
}
}
- @Override
public String getURI() {
return uri;
}
- @Override
public String getType() {
return type;
}
- @Override
public List<Transform> getTransforms() {
return transforms;
}
@Override
- public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context)
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
throws MarshalException
{
- xwriter.writeStartElement(dsPrefix, "RetrievalMethod", XMLSignature.XMLNS);
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+ Element rmElem = DOMUtils.createElement(ownerDoc, "RetrievalMethod",
+ XMLSignature.XMLNS, dsPrefix);
- // TODO - see whether it is important to capture the "here" attribute as part of the
- // marshalling - do any of the tests fail?
// add URI and Type attributes
- here = xwriter.writeAttribute("", "", "URI", uri);
- xwriter.writeAttribute("", "", "Type", type);
+ DOMUtils.setAttribute(rmElem, "URI", uri);
+ DOMUtils.setAttribute(rmElem, "Type", type);
// add Transforms elements
if (!transforms.isEmpty()) {
- xwriter.writeStartElement(dsPrefix, "Transforms", XMLSignature.XMLNS);
+ Element transformsElem = DOMUtils.createElement(ownerDoc,
+ "Transforms",
+ XMLSignature.XMLNS,
+ dsPrefix);
+ rmElem.appendChild(transformsElem);
for (Transform transform : transforms) {
- ((DOMTransform)transform).marshal(xwriter, dsPrefix, context);
+ ((DOMTransform)transform).marshal(transformsElem,
+ dsPrefix, context);
}
- xwriter.writeEndElement(); // "Transforms"
}
- xwriter.writeEndElement(); // "RetrievalMethod"
+
+ parent.appendChild(rmElem);
+
+ // save here node
+ here = rmElem.getAttributeNodeNS(null, "URI");
}
- @Override
public Node getHere() {
return here;
}
- @Override
public Data dereference(XMLCryptoContext context)
throws URIReferenceException
{
@@ -244,7 +248,7 @@
// pass dereferenced data through Transforms
try {
for (Transform transform : transforms) {
- data = transform.transform(data, context);
+ data = ((DOMTransform)transform).transform(data, context);
}
} catch (Exception e) {
throw new URIReferenceException(e);
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java Sat Mar 09 12:54:20 2019 +0000
@@ -224,7 +224,6 @@
}
}
- @Override
public final AlgorithmParameterSpec getParameterSpec() {
return params;
}
@@ -246,8 +245,7 @@
: Signature.getInstance(getJCAAlgorithm(), p);
}
- @Override
- boolean verify(Key key, DOMSignedInfo si, byte[] sig,
+ boolean verify(Key key, SignedInfo si, byte[] sig,
XMLValidateContext context)
throws InvalidKeyException, SignatureException, XMLSignatureException
{
@@ -276,7 +274,7 @@
byte[] s;
try (SignerOutputStream outputStream = new SignerOutputStream(signature)) {
- si.canonicalize(context, outputStream);
+ ((DOMSignedInfo)si).canonicalize(context, outputStream);
// Do any necessary format conversions
s = preVerifyFormat(key, sig);
} catch (IOException ioe) {
@@ -314,8 +312,7 @@
}
}
- @Override
- byte[] sign(Key key, DOMSignedInfo si, XMLSignContext context)
+ byte[] sign(Key key, SignedInfo si, XMLSignContext context)
throws InvalidKeyException, XMLSignatureException
{
if (key == null || si == null) {
@@ -341,7 +338,7 @@
LOG.debug("JCA Algorithm: {}", getJCAAlgorithm());
try (SignerOutputStream outputStream = new SignerOutputStream(signature)) {
- si.canonicalize(context, outputStream);
+ ((DOMSignedInfo)si).canonicalize(context, outputStream);
// Return signature with any necessary format conversions
return postSignFormat(key, signature.sign());
} catch (SignatureException | IOException ex){
@@ -570,15 +567,12 @@
SHA224withRSA(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return RSA_SHA224;
}
- @Override
String getJCAAlgorithm() {
return "SHA224withRSA";
}
- @Override
Type getAlgorithmType() {
return Type.RSA;
}
@@ -592,15 +586,12 @@
SHA256withRSA(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return RSA_SHA256;
}
- @Override
String getJCAAlgorithm() {
return "SHA256withRSA";
}
- @Override
Type getAlgorithmType() {
return Type.RSA;
}
@@ -614,15 +605,12 @@
SHA384withRSA(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return RSA_SHA384;
}
- @Override
String getJCAAlgorithm() {
return "SHA384withRSA";
}
- @Override
Type getAlgorithmType() {
return Type.RSA;
}
@@ -636,15 +624,12 @@
SHA512withRSA(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return RSA_SHA512;
}
- @Override
String getJCAAlgorithm() {
return "SHA512withRSA";
}
- @Override
Type getAlgorithmType() {
return Type.RSA;
}
@@ -857,18 +842,15 @@
SHA1withDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return SignatureMethod.DSA_SHA1;
}
- @Override
String getJCAAlgorithm() {
return "SHA1withDSAinP1363Format";
}
String getJCAFallbackAlgorithm() {
return "SHA1withDSA";
}
- @Override
Type getAlgorithmType() {
return Type.DSA;
}
@@ -904,18 +886,15 @@
SHA1withECDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return ECDSA_SHA1;
}
- @Override
String getJCAAlgorithm() {
return "SHA1withECDSAinP1363Format";
}
String getJCAFallbackAlgorithm() {
return "SHA1withECDSA";
}
- @Override
Type getAlgorithmType() {
return Type.ECDSA;
}
@@ -954,18 +933,15 @@
SHA256withECDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return ECDSA_SHA256;
}
- @Override
String getJCAAlgorithm() {
return "SHA256withECDSAinP1363Format";
}
String getJCAFallbackAlgorithm() {
return "SHA256withECDSA";
}
- @Override
Type getAlgorithmType() {
return Type.ECDSA;
}
@@ -979,18 +955,15 @@
SHA384withECDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return ECDSA_SHA384;
}
- @Override
String getJCAAlgorithm() {
return "SHA384withECDSAinP1363Format";
}
String getJCAFallbackAlgorithm() {
return "SHA384withECDSA";
}
- @Override
Type getAlgorithmType() {
return Type.ECDSA;
}
@@ -1004,18 +977,15 @@
SHA512withECDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
- @Override
public String getAlgorithm() {
return ECDSA_SHA512;
}
- @Override
String getJCAAlgorithm() {
return "SHA512withECDSAinP1363Format";
}
String getJCAFallbackAlgorithm() {
return "SHA512withECDSA";
}
- @Override
Type getAlgorithmType() {
return Type.ECDSA;
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,10 +29,13 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import java.util.*;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -40,7 +43,7 @@
* DOM-based implementation of SignatureProperties.
*
*/
-public final class DOMSignatureProperties extends BaseStructure
+public final class DOMSignatureProperties extends DOMStructure
implements SignatureProperties {
private final String id;
@@ -58,7 +61,7 @@
* @throws IllegalArgumentException if {@code properties} is empty
* @throws NullPointerException if {@code properties}
*/
- public DOMSignatureProperties(List<DOMSignatureProperty> properties,
+ public DOMSignatureProperties(List<? extends SignatureProperty> properties,
String id)
{
if (properties == null) {
@@ -88,7 +91,13 @@
throws MarshalException
{
// unmarshal attributes
- id = DOMUtils.getIdAttributeValue(propsElem, "Id");
+ Attr attr = propsElem.getAttributeNodeNS(null, "Id");
+ if (attr != null) {
+ id = attr.getValue();
+ propsElem.setIdAttributeNode(attr, true);
+ } else {
+ id = null;
+ }
List<SignatureProperty> newProperties = new ArrayList<>();
Node firstChild = propsElem.getFirstChild();
@@ -111,32 +120,34 @@
}
}
- @Override
public List<SignatureProperty> getProperties() {
return properties;
}
- @Override
public String getId() {
return id;
}
- public static void marshal(XmlWriter xwriter, SignatureProperties sigProps, String dsPrefix, XMLCryptoContext context)
+ @Override
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
throws MarshalException
{
- xwriter.writeStartElement(dsPrefix, "SignatureProperties", XMLSignature.XMLNS);
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+ Element propsElem = DOMUtils.createElement(ownerDoc,
+ "SignatureProperties",
+ XMLSignature.XMLNS,
+ dsPrefix);
// set attributes
- xwriter.writeIdAttribute("", "", "Id", sigProps.getId());
+ DOMUtils.setAttributeID(propsElem, "Id", id);
// create and append any properties
- @SuppressWarnings("unchecked")
- List<SignatureProperty> properties = sigProps.getProperties();
for (SignatureProperty property : properties) {
- DOMSignatureProperty.marshal(xwriter, property, dsPrefix, context);
+ ((DOMSignatureProperty)property).marshal(propsElem, dsPrefix,
+ context);
}
- xwriter.writeEndElement(); // "SignatureProperties"
+ parent.appendChild(propsElem);
}
@Override
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,10 +29,13 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import java.util.*;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -40,7 +43,7 @@
* DOM-based implementation of SignatureProperty.
*
*/
-public final class DOMSignatureProperty extends BaseStructure
+public final class DOMSignatureProperty extends DOMStructure
implements SignatureProperty {
private final String id;
@@ -96,7 +99,13 @@
if (target == null) {
throw new MarshalException("target cannot be null");
}
- id = DOMUtils.getIdAttributeValue(propElem, "Id");
+ Attr attr = propElem.getAttributeNodeNS(null, "Id");
+ if (attr != null) {
+ id = attr.getValue();
+ propElem.setIdAttributeNode(attr, true);
+ } else {
+ id = null;
+ }
List<XMLStructure> newContent = new ArrayList<>();
Node firstChild = propElem.getFirstChild();
@@ -111,37 +120,37 @@
}
}
- @Override
public List<XMLStructure> getContent() {
return content;
}
- @Override
public String getId() {
return id;
}
- @Override
public String getTarget() {
return target;
}
- public static void marshal(XmlWriter xwriter, SignatureProperty sigProp, String dsPrefix, XMLCryptoContext context)
+ @Override
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
throws MarshalException
{
- xwriter.writeStartElement(dsPrefix, "SignatureProperty", XMLSignature.XMLNS);
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+ Element propElem = DOMUtils.createElement(ownerDoc, "SignatureProperty",
+ XMLSignature.XMLNS, dsPrefix);
// set attributes
- xwriter.writeIdAttribute("", "", "Id", sigProp.getId());
- xwriter.writeAttribute("", "", "Target", sigProp.getTarget());
+ DOMUtils.setAttributeID(propElem, "Id", id);
+ DOMUtils.setAttribute(propElem, "Target", target);
// create and append any elements and mixed content
- List<XMLStructure> content = getContent(sigProp);
for (XMLStructure property : content) {
- xwriter.marshalStructure(property, dsPrefix, context);
+ DOMUtils.appendChild(propElem,
+ ((javax.xml.crypto.dom.DOMStructure)property).getNode());
}
- xwriter.writeEndElement(); // "SignatureProperty"
+ parent.appendChild(propElem);
}
@Override
@@ -176,10 +185,6 @@
return result;
}
- @SuppressWarnings("unchecked")
- private static List<XMLStructure> getContent(SignatureProperty prop) {
- return prop.getContent();
- }
private boolean equalsContent(List<XMLStructure> otherContent) {
int osize = otherContent.size();
if (content.size() != osize) {
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,6 +29,7 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import java.io.ByteArrayInputStream;
@@ -39,8 +40,11 @@
import java.security.Provider;
import java.util.*;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream;
+import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
/**
* DOM-based implementation of SignedInfo.
@@ -55,6 +59,7 @@
private CanonicalizationMethod canonicalizationMethod;
private SignatureMethod signatureMethod;
private String id;
+ private Document ownerDoc;
private Element localSiElem;
private InputStream canonData;
@@ -123,6 +128,7 @@
public DOMSignedInfo(Element siElem, XMLCryptoContext context, Provider provider)
throws MarshalException {
localSiElem = siElem;
+ ownerDoc = siElem.getOwnerDocument();
// get Id attribute, if specified
id = DOMUtils.getAttributeValue(siElem, "Id");
@@ -175,27 +181,22 @@
references = Collections.unmodifiableList(refList);
}
- @Override
public CanonicalizationMethod getCanonicalizationMethod() {
return canonicalizationMethod;
}
- @Override
public SignatureMethod getSignatureMethod() {
return signatureMethod;
}
- @Override
public String getId() {
return id;
}
- @Override
public List<Reference> getReferences() {
return references;
}
- @Override
public InputStream getCanonicalizedData() {
return canonData;
}
@@ -223,7 +224,7 @@
sb.append((char)signedInfoBytes[i]);
}
LOG.debug(sb.toString());
- LOG.debug("Data to be signed/verified:" + Base64.getMimeEncoder().encodeToString(signedInfoBytes));
+ LOG.debug("Data to be signed/verified:" + XMLUtils.encodeToString(signedInfoBytes));
}
this.canonData = new ByteArrayInputStream(signedInfoBytes);
@@ -236,32 +237,31 @@
}
@Override
- public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context)
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
throws MarshalException
{
- xwriter.writeStartElement(dsPrefix, "SignedInfo", XMLSignature.XMLNS);
- XMLStructure siStruct = xwriter.getCurrentNodeAsStructure();
- localSiElem = (Element) ((javax.xml.crypto.dom.DOMStructure) siStruct).getNode();
-
- // append Id attribute
- xwriter.writeIdAttribute("", "", "Id", id);
+ ownerDoc = DOMUtils.getOwnerDocument(parent);
+ Element siElem = DOMUtils.createElement(ownerDoc, "SignedInfo",
+ XMLSignature.XMLNS, dsPrefix);
// create and append CanonicalizationMethod element
DOMCanonicalizationMethod dcm =
(DOMCanonicalizationMethod)canonicalizationMethod;
- dcm.marshal(xwriter, dsPrefix, context);
+ dcm.marshal(siElem, dsPrefix, context);
// create and append SignatureMethod element
- ((AbstractDOMSignatureMethod)signatureMethod).marshal(xwriter, dsPrefix);
+ ((DOMStructure)signatureMethod).marshal(siElem, dsPrefix, context);
// create and append Reference elements
for (Reference reference : references) {
- // TODO - either suppress warning here, or figure out how to get rid of the cast.
- DOMReference domRef = (DOMReference)reference;
- domRef.marshal(xwriter, dsPrefix, context);
+ ((DOMReference)reference).marshal(siElem, dsPrefix, context);
}
- xwriter.writeEndElement(); // "SignedInfo"
+ // append Id attribute
+ DOMUtils.setAttributeID(siElem, "Id", id);
+
+ parent.appendChild(siElem);
+ localSiElem = siElem;
}
@Override
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,13 +29,24 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.MarshalException;
-import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.XMLStructure;
+import javax.xml.crypto.dom.DOMCryptoContext;
+import org.w3c.dom.Node;
/**
* DOM-based abstract implementation of XMLStructure.
*
*/
-public abstract class DOMStructure extends BaseStructure {
+public abstract class DOMStructure implements XMLStructure {
- public abstract void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context) throws MarshalException;
+ public final boolean isFeatureSupported(String feature) {
+ if (feature == null) {
+ throw new NullPointerException();
+ } else {
+ return false;
+ }
+ }
+
+ public abstract void marshal(Node parent, String dsPrefix,
+ DOMCryptoContext context) throws MarshalException;
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java Sat Mar 09 12:54:20 2019 +0000
@@ -82,7 +82,6 @@
this.withComments = !excludeComments;
}
- @Override
public boolean hasNext() {
if (nodeSet == null) {
nodeSet = dereferenceSameDocumentURI(root);
@@ -91,7 +90,6 @@
return li.hasNext();
}
- @Override
public Node next() {
if (nodeSet == null) {
nodeSet = dereferenceSameDocumentURI(root);
@@ -104,7 +102,6 @@
}
}
- @Override
public void remove() {
throw new UnsupportedOperationException();
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java Sat Mar 09 12:54:20 2019 +0000
@@ -37,12 +37,14 @@
import javax.xml.crypto.Data;
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.Transform;
import javax.xml.crypto.dsig.TransformException;
import javax.xml.crypto.dsig.TransformService;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.dom.DOMSignContext;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -50,7 +52,7 @@
* DOM-based abstract implementation of Transform.
*
*/
-public class DOMTransform extends BaseStructure implements Transform {
+public class DOMTransform extends DOMStructure implements Transform {
protected TransformService spi;
@@ -74,6 +76,7 @@
throws MarshalException
{
String algorithm = DOMUtils.getAttributeValue(transElem, "Algorithm");
+
if (provider == null) {
try {
spi = TransformService.getInstance(algorithm, "DOM");
@@ -98,12 +101,10 @@
}
}
- @Override
public final AlgorithmParameterSpec getParameterSpec() {
return spi.getParameterSpec();
}
- @Override
public final String getAlgorithm() {
return spi.getAlgorithm();
}
@@ -111,18 +112,29 @@
/**
* This method marshals any algorithm-specific parameters.
*/
- public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context)
+ @Override
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
throws MarshalException
{
- String parentLocalName = xwriter.getCurrentLocalName();
- String localName = "Transforms".equals(parentLocalName) ? "Transform" : "CanonicalizationMethod";
- xwriter.writeStartElement(dsPrefix, localName, XMLSignature.XMLNS);
- xwriter.writeAttribute("", "", "Algorithm", getAlgorithm());
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
- javax.xml.crypto.XMLStructure xmlStruct = xwriter.getCurrentNodeAsStructure();
- spi.marshalParams(xmlStruct, context);
+ Element transformElem = null;
+ if (parent.getLocalName().equals("Transforms")) {
+ transformElem = DOMUtils.createElement(ownerDoc, "Transform",
+ XMLSignature.XMLNS,
+ dsPrefix);
+ } else {
+ transformElem = DOMUtils.createElement(ownerDoc,
+ "CanonicalizationMethod",
+ XMLSignature.XMLNS,
+ dsPrefix);
+ }
+ DOMUtils.setAttribute(transformElem, "Algorithm", getAlgorithm());
- xwriter.writeEndElement(); // "Transforms" or "CanonicalizationMethod"
+ spi.marshalParams(new javax.xml.crypto.dom.DOMStructure(transformElem),
+ context);
+
+ parent.appendChild(transformElem);
}
/**
@@ -136,7 +148,6 @@
* @throws XMLSignatureException if an unexpected error occurs while
* executing the transform
*/
- @Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException
{
@@ -156,7 +167,6 @@
* @throws XMLSignatureException if an unexpected error occurs while
* executing the transform
*/
- @Override
public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
throws TransformException
{
@@ -210,9 +220,8 @@
Data transform(Data data, XMLCryptoContext xc, DOMSignContext context)
throws MarshalException, TransformException
{
- Node parent = context.getParent();
- XmlWriter xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), parent);
- marshal(xwriter, DOMUtils.getSignaturePrefix(context), context);
+ marshal(context.getParent(),
+ DOMUtils.getSignaturePrefix(context), context);
return transform(data, xc);
}
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java Sat Mar 09 12:54:20 2019 +0000
@@ -54,7 +54,6 @@
Init.init();
}
- @Override
public Data dereference(URIReference uriRef, XMLCryptoContext context)
throws URIReferenceException {
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java Sat Mar 09 12:54:20 2019 +0000
@@ -92,7 +92,9 @@
public static Element createElement(Document doc, String tag,
String nsURI, String prefix)
{
- return doc.createElementNS(nsURI, getQNameString(prefix, tag));
+ String qName = (prefix == null || prefix.length() == 0)
+ ? tag : prefix + ":" + tag;
+ return doc.createElementNS(nsURI, qName);
}
/**
@@ -335,25 +337,20 @@
this.nl = nl;
}
- @Override
public int size() { return nl.getLength(); }
- @Override
public Iterator<Node> iterator() {
return new Iterator<Node>() {
private int index;
- @Override
public void remove() {
throw new UnsupportedOperationException();
}
- @Override
public Node next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
return nl.item(index++);
}
- @Override
public boolean hasNext() {
return index < nl.getLength();
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java Sat Mar 09 12:54:20 2019 +0000
@@ -34,10 +34,13 @@
import java.util.*;
import javax.xml.crypto.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dsig.keyinfo.X509Data;
+import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
import javax.security.auth.x500.X500Principal;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -48,7 +51,7 @@
*
*/
//@@@ check for illegal combinations of data violating MUSTs in W3c spec
-public final class DOMX509Data extends BaseStructure implements X509Data {
+public final class DOMX509Data extends DOMStructure implements X509Data {
private final List<Object> content;
private CertificateFactory cf;
@@ -113,7 +116,7 @@
newContent.add(childElem.getFirstChild().getNodeValue());
} else if ("X509SKI".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
String content = XMLUtils.getFullTextChildrenFromElement(childElem);
- newContent.add(Base64.getMimeDecoder().decode(content));
+ newContent.add(XMLUtils.decode(content));
} else if ("X509CRL".equals(localName) && XMLSignature.XMLNS.equals(namespace)) {
newContent.add(unmarshalX509CRL(childElem));
} else {
@@ -125,68 +128,89 @@
this.content = Collections.unmodifiableList(newContent);
}
- @Override
public List<Object> getContent() {
return content;
}
- public static void marshal(XmlWriter xwriter, X509Data x509Data, String dsPrefix, XMLCryptoContext context)
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
throws MarshalException
{
- xwriter.writeStartElement(dsPrefix, "X509Data", XMLSignature.XMLNS);
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+ Element xdElem = DOMUtils.createElement(ownerDoc, "X509Data",
+ XMLSignature.XMLNS, dsPrefix);
- List<?> content = x509Data.getContent();
// append children and preserve order
for (int i = 0, size = content.size(); i < size; i++) {
Object object = content.get(i);
if (object instanceof X509Certificate) {
- marshalCert(xwriter, (X509Certificate) object, dsPrefix);
+ marshalCert((X509Certificate)object,xdElem,ownerDoc,dsPrefix);
} else if (object instanceof XMLStructure) {
- xwriter.marshalStructure((XMLStructure) object, dsPrefix, context);
+ if (object instanceof X509IssuerSerial) {
+ ((DOMX509IssuerSerial)object).marshal
+ (xdElem, dsPrefix, context);
+ } else {
+ javax.xml.crypto.dom.DOMStructure domContent =
+ (javax.xml.crypto.dom.DOMStructure)object;
+ DOMUtils.appendChild(xdElem, domContent.getNode());
+ }
} else if (object instanceof byte[]) {
- marshalSKI(xwriter, (byte[]) object, dsPrefix);
+ marshalSKI((byte[])object, xdElem, ownerDoc, dsPrefix);
} else if (object instanceof String) {
- marshalSubjectName(xwriter, (String) object, dsPrefix);
+ marshalSubjectName((String)object, xdElem, ownerDoc,dsPrefix);
} else if (object instanceof X509CRL) {
- marshalCRL(xwriter, (X509CRL) object, dsPrefix);
+ marshalCRL((X509CRL)object, xdElem, ownerDoc, dsPrefix);
}
}
- xwriter.writeEndElement(); // "X509Data"
+
+ parent.appendChild(xdElem);
}
- private static void marshalSKI(XmlWriter xwriter, byte[] skid, String dsPrefix)
+ private void marshalSKI(byte[] skid, Node parent, Document doc,
+ String dsPrefix)
{
- xwriter.writeTextElement(dsPrefix, "X509SKI", XMLSignature.XMLNS,
- Base64.getMimeEncoder().encodeToString(skid));
+ Element skidElem = DOMUtils.createElement(doc, "X509SKI",
+ XMLSignature.XMLNS, dsPrefix);
+ skidElem.appendChild(doc.createTextNode(XMLUtils.encodeToString(skid)));
+ parent.appendChild(skidElem);
}
- private static void marshalSubjectName(XmlWriter xwriter, String name, String dsPrefix)
+ private void marshalSubjectName(String name, Node parent, Document doc,
+ String dsPrefix)
{
- xwriter.writeTextElement(dsPrefix, "X509SubjectName", XMLSignature.XMLNS, name);
+ Element snElem = DOMUtils.createElement(doc, "X509SubjectName",
+ XMLSignature.XMLNS, dsPrefix);
+ snElem.appendChild(doc.createTextNode(name));
+ parent.appendChild(snElem);
}
- private static void marshalCert(XmlWriter xwriter, X509Certificate cert, String dsPrefix)
+ private void marshalCert(X509Certificate cert, Node parent, Document doc,
+ String dsPrefix)
throws MarshalException
{
+ Element certElem = DOMUtils.createElement(doc, "X509Certificate",
+ XMLSignature.XMLNS, dsPrefix);
try {
- byte[] encoded = cert.getEncoded();
- xwriter.writeTextElement(dsPrefix, "X509Certificate", XMLSignature.XMLNS,
- Base64.getMimeEncoder().encodeToString(encoded));
+ certElem.appendChild(doc.createTextNode
+ (XMLUtils.encodeToString(cert.getEncoded())));
} catch (CertificateEncodingException e) {
throw new MarshalException("Error encoding X509Certificate", e);
}
+ parent.appendChild(certElem);
}
- private static void marshalCRL(XmlWriter xwriter, X509CRL crl, String dsPrefix)
+ private void marshalCRL(X509CRL crl, Node parent, Document doc,
+ String dsPrefix)
throws MarshalException
{
+ Element crlElem = DOMUtils.createElement(doc, "X509CRL",
+ XMLSignature.XMLNS, dsPrefix);
try {
- byte[] encoded = crl.getEncoded();
- xwriter.writeTextElement(dsPrefix, "X509CRL", XMLSignature.XMLNS,
- Base64.getMimeEncoder().encodeToString(encoded));
+ crlElem.appendChild(doc.createTextNode
+ (XMLUtils.encodeToString(crl.getEncoded())));
} catch (CRLException e) {
throw new MarshalException("Error encoding X509CRL", e);
}
+ parent.appendChild(crlElem);
}
private X509Certificate unmarshalX509Certificate(Element elem)
@@ -218,7 +242,7 @@
cf = CertificateFactory.getInstance("X.509");
}
String content = XMLUtils.getFullTextChildrenFromElement(elem);
- return new ByteArrayInputStream(Base64.getMimeDecoder().decode(content));
+ return new ByteArrayInputStream(XMLUtils.decode(content));
} catch (CertificateException e) {
throw new MarshalException("Cannot create CertificateFactory", e);
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,20 +29,22 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
import java.math.BigInteger;
import javax.security.auth.x500.X500Principal;
-
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* DOM-based implementation of X509IssuerSerial.
*
*/
-public final class DOMX509IssuerSerial extends BaseStructure
+public final class DOMX509IssuerSerial extends DOMStructure
implements X509IssuerSerial {
private final String issuerName;
@@ -89,17 +91,34 @@
serialNumber = new BigInteger(sNElem.getFirstChild().getNodeValue());
}
- @Override
public String getIssuerName() {
return issuerName;
}
- @Override
public BigInteger getSerialNumber() {
return serialNumber;
}
@Override
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
+ throws MarshalException
+ {
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+
+ Element isElem = DOMUtils.createElement(ownerDoc, "X509IssuerSerial",
+ XMLSignature.XMLNS, dsPrefix);
+ Element inElem = DOMUtils.createElement(ownerDoc, "X509IssuerName",
+ XMLSignature.XMLNS, dsPrefix);
+ Element snElem = DOMUtils.createElement(ownerDoc, "X509SerialNumber",
+ XMLSignature.XMLNS, dsPrefix);
+ inElem.appendChild(ownerDoc.createTextNode(issuerName));
+ snElem.appendChild(ownerDoc.createTextNode(serialNumber.toString()));
+ isElem.appendChild(inElem);
+ isElem.appendChild(snElem);
+ parent.appendChild(isElem);
+ }
+
+ @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,12 +29,14 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.*;
+import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import java.security.Provider;
import java.util.*;
import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -43,12 +45,13 @@
* DOM-based implementation of XMLObject.
*
*/
-public final class DOMXMLObject extends BaseStructure implements XMLObject {
+public final class DOMXMLObject extends DOMStructure implements XMLObject {
private final String id;
private final String mimeType;
private final String encoding;
private final List<XMLStructure> content;
+ private Element objectElem;
/**
* Creates an {@code XMLObject} from the specified parameters.
@@ -142,51 +145,56 @@
} else {
this.content = Collections.unmodifiableList(newContent);
}
+ this.objectElem = objElem;
}
- @Override
public List<XMLStructure> getContent() {
return content;
}
- @Override
public String getId() {
return id;
}
- @Override
public String getMimeType() {
return mimeType;
}
- @Override
public String getEncoding() {
return encoding;
}
- public static void marshal(XmlWriter xwriter, XMLObject xmlObj, String dsPrefix, XMLCryptoContext context)
+ @Override
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
throws MarshalException {
- xwriter.writeStartElement(dsPrefix, "Object", XMLSignature.XMLNS);
+ Document ownerDoc = DOMUtils.getOwnerDocument(parent);
+
+ Element objElem = objectElem != null ? objectElem : null;
+ if (objElem == null) {
+ objElem = DOMUtils.createElement(ownerDoc, "Object",
+ XMLSignature.XMLNS, dsPrefix);
- // set attributes
- xwriter.writeIdAttribute("", "", "Id", xmlObj.getId());
- xwriter.writeAttribute("", "", "MimeType", xmlObj.getMimeType());
- xwriter.writeAttribute("", "", "Encoding", xmlObj.getEncoding());
+ // set attributes
+ DOMUtils.setAttributeID(objElem, "Id", id);
+ DOMUtils.setAttribute(objElem, "MimeType", mimeType);
+ DOMUtils.setAttribute(objElem, "Encoding", encoding);
- // create and append any elements and mixed content, if necessary
- @SuppressWarnings("unchecked")
- List<XMLStructure> content = xmlObj.getContent();
- for (XMLStructure object : content) {
- xwriter.marshalStructure(object, dsPrefix, context);
+ // create and append any elements and mixed content, if necessary
+ for (XMLStructure object : content) {
+ if (object instanceof DOMStructure) {
+ ((DOMStructure)object).marshal(objElem, dsPrefix, context);
+ } else {
+ javax.xml.crypto.dom.DOMStructure domObject =
+ (javax.xml.crypto.dom.DOMStructure)object;
+ DOMUtils.appendChild(objElem, domObject.getNode());
+ }
+ }
}
- xwriter.writeEndElement(); // "Object"
+
+ parent.appendChild(objElem);
}
@SuppressWarnings("unchecked")
- public static List<XMLStructure> getXmlObjectContent(XMLObject xo) {
- return xo.getContent();
- }
-
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -208,7 +216,7 @@
: mimeType.equals(oxo.getMimeType());
return idsEqual && encodingsEqual && mimeTypesEqual &&
- equalsContent(getXmlObjectContent(oxo));
+ equalsContent(oxo.getContent());
}
@Override
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java Sat Mar 09 12:54:20 2019 +0000
@@ -36,6 +36,7 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.*;
+import javax.xml.crypto.dom.*;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dsig.dom.DOMSignContext;
import javax.xml.crypto.dsig.dom.DOMValidateContext;
@@ -46,11 +47,12 @@
import java.security.Provider;
import java.util.Collections;
import java.util.ArrayList;
-import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -70,6 +72,9 @@
private KeyInfo ki;
private List<XMLObject> objects;
private SignedInfo si;
+ private Document ownerDoc = null;
+ private Element localSigElem = null;
+ private Element sigElem = null;
private boolean validationStatus;
private boolean validated = false;
private KeySelectorResult ksr;
@@ -127,7 +132,8 @@
Provider provider)
throws MarshalException
{
- Element localSigElem = sigElem;
+ localSigElem = sigElem;
+ ownerDoc = localSigElem.getOwnerDocument();
// get Id attribute, if specified
id = DOMUtils.getAttributeValue(localSigElem, "Id");
@@ -171,69 +177,74 @@
}
}
- @Override
public String getId() {
return id;
}
- @Override
public KeyInfo getKeyInfo() {
return ki;
}
- @Override
public SignedInfo getSignedInfo() {
return si;
}
- @Override
public List<XMLObject> getObjects() {
return objects;
}
- @Override
public SignatureValue getSignatureValue() {
return sv;
}
- @Override
public KeySelectorResult getKeySelectorResult() {
return ksr;
}
@Override
- public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context)
+ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
+ throws MarshalException
+ {
+ marshal(parent, null, dsPrefix, context);
+ }
+
+ public void marshal(Node parent, Node nextSibling, String dsPrefix,
+ DOMCryptoContext context)
throws MarshalException
{
- // rationalize the prefix.
- String prefix = dsPrefix;
- if (prefix == null) {
- prefix = "";
+ ownerDoc = DOMUtils.getOwnerDocument(parent);
+ sigElem = DOMUtils.createElement(ownerDoc, "Signature",
+ XMLSignature.XMLNS, dsPrefix);
+
+ // append xmlns attribute
+ if (dsPrefix == null || dsPrefix.length() == 0) {
+ sigElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
+ XMLSignature.XMLNS);
+ } else {
+ sigElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" +
+ dsPrefix, XMLSignature.XMLNS);
}
- xwriter.writeStartElement(prefix, "Signature", XMLSignature.XMLNS);
-
- xwriter.writeNamespace(prefix, XMLSignature.XMLNS);
-
- // append Id attribute
- xwriter.writeIdAttribute("", "", "Id", id);
// create and append SignedInfo element
- ((DOMSignedInfo) si).marshal(xwriter, prefix, context);
+ ((DOMSignedInfo)si).marshal(sigElem, dsPrefix, context);
// create and append SignatureValue element
- ((DOMSignatureValue) sv).marshal(xwriter, prefix, context);
+ ((DOMSignatureValue)sv).marshal(sigElem, dsPrefix, context);
// create and append KeyInfo element if necessary
if (ki != null) {
- DOMKeyInfo.marshal(xwriter, ki, prefix, context);
+ ((DOMKeyInfo)ki).marshal(sigElem, null, dsPrefix, context);
}
// create and append Object elements if necessary
- for (XMLObject xmlObj : objects) {
- DOMXMLObject.marshal(xwriter, xmlObj, prefix, context);
+ for (int i = 0, size = objects.size(); i < size; i++) {
+ ((DOMXMLObject)objects.get(i)).marshal(sigElem, dsPrefix, context);
}
- xwriter.writeEndElement(); // "Signature"
+ // append Id attribute
+ DOMUtils.setAttributeID(sigElem, "Id", id);
+
+ parent.insertBefore(sigElem, nextSibling);
}
@Override
@@ -262,7 +273,8 @@
}
// validate all References
- List<Reference> refs = DOMSignedInfo.getSignedInfoReferences(this.si);
+ @SuppressWarnings("unchecked")
+ List<Reference> refs = this.si.getReferences();
boolean validateRefs = true;
for (int i = 0, size = refs.size(); validateRefs && i < size; i++) {
Reference ref = refs.get(i);
@@ -284,14 +296,16 @@
{
for (int i=0, size=objects.size(); validateMans && i < size; i++) {
XMLObject xo = objects.get(i);
- List<XMLStructure> content = DOMXMLObject.getXmlObjectContent(xo);
+ @SuppressWarnings("unchecked")
+ List<XMLStructure> content = xo.getContent();
int csize = content.size();
for (int j = 0; validateMans && j < csize; j++) {
XMLStructure xs = content.get(j);
if (xs instanceof Manifest) {
LOG.debug("validating manifest");
Manifest man = (Manifest)xs;
- List<Reference> manRefs = DOMManifest.getManifestReferences(man);
+ @SuppressWarnings("unchecked")
+ List<Reference> manRefs = man.getReferences();
int rsize = manRefs.size();
for (int k = 0; validateMans && k < rsize; k++) {
Reference ref = manRefs.get(k);
@@ -319,13 +333,8 @@
throw new NullPointerException("signContext cannot be null");
}
DOMSignContext context = (DOMSignContext)signContext;
- Node nextSibling = context.getNextSibling();
-
- XmlWriterToTree xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), context.getParent(), nextSibling);
- marshal(xwriter,
- DOMUtils.getSignaturePrefix(signContext), signContext);
-
- Element sigElem = xwriter.getCreatedElement();
+ marshal(context.getParent(), context.getNextSibling(),
+ DOMUtils.getSignaturePrefix(context), context);
// generate references and signature value
List<Reference> allReferences = new ArrayList<>();
@@ -335,18 +344,21 @@
signatureIdMap = new HashMap<>();
signatureIdMap.put(id, this);
signatureIdMap.put(si.getId(), si);
- List<Reference> refs = DOMSignedInfo.getSignedInfoReferences(si);
+ @SuppressWarnings("unchecked")
+ List<Reference> refs = si.getReferences();
for (Reference ref : refs) {
signatureIdMap.put(ref.getId(), ref);
}
for (XMLObject obj : objects) {
signatureIdMap.put(obj.getId(), obj);
- List<XMLStructure> content = DOMXMLObject.getXmlObjectContent(obj);
+ @SuppressWarnings("unchecked")
+ List<XMLStructure> content = obj.getContent();
for (XMLStructure xs : content) {
if (xs instanceof Manifest) {
Manifest man = (Manifest)xs;
signatureIdMap.put(man.getId(), man);
- List<Reference> manRefs = DOMManifest.getManifestReferences(man);
+ @SuppressWarnings("unchecked")
+ List<Reference> manRefs = man.getReferences();
for (Reference ref : manRefs) {
allReferences.add(ref);
signatureIdMap.put(ref.getId(), ref);
@@ -389,14 +401,14 @@
// calculate signature value
try {
- Element sigValue = (Element) sigElem.getElementsByTagNameNS(XMLSignature.XMLNS, "SignatureValue").item(0);
- xwriter.resetToNewParent(sigValue);
byte[] val = ((AbstractDOMSignatureMethod)
- si.getSignatureMethod()).sign(signingKey, (DOMSignedInfo) si, signContext);
- ((DOMSignatureValue)sv).setValue(xwriter, val);
+ si.getSignatureMethod()).sign(signingKey, si, signContext);
+ ((DOMSignatureValue)sv).setValue(val);
} catch (InvalidKeyException ike) {
throw new XMLSignatureException(ike);
}
+
+ this.localSigElem = sigElem;
}
@Override
@@ -484,6 +496,7 @@
private String id;
private byte[] value;
private String valueBase64;
+ private Element sigValueElem;
private boolean validated = false;
private boolean validationStatus;
@@ -496,17 +509,22 @@
{
// base64 decode signatureValue
String content = XMLUtils.getFullTextChildrenFromElement(sigValueElem);
- value = Base64.getMimeDecoder().decode(content);
+ value = XMLUtils.decode(content);
- id = DOMUtils.getIdAttributeValue(sigValueElem, "Id");
+ Attr attr = sigValueElem.getAttributeNodeNS(null, "Id");
+ if (attr != null) {
+ id = attr.getValue();
+ sigValueElem.setIdAttributeNode(attr, true);
+ } else {
+ id = null;
+ }
+ this.sigValueElem = sigValueElem;
}
- @Override
public String getId() {
return id;
}
- @Override
public byte[] getValue() {
return (value == null) ? null : value.clone();
}
@@ -552,7 +570,7 @@
// canonicalize SignedInfo and verify signature
try {
validationStatus = ((AbstractDOMSignatureMethod)sm).verify
- (validationKey, (DOMSignedInfo) si, value, validateContext);
+ (validationKey, si, value, validateContext);
} catch (Exception e) {
throw new XMLSignatureException(e);
}
@@ -590,29 +608,25 @@
return result;
}
- @Override
- public void marshal(XmlWriter xwriter, String dsPrefix,
- XMLCryptoContext context)
+ public void marshal(Node parent, String dsPrefix,
+ DOMCryptoContext context)
throws MarshalException
{
- // create SignatureValue element
- xwriter.writeStartElement(dsPrefix, "SignatureValue", XMLSignature.XMLNS);
+ sigValueElem = DOMUtils.createElement(ownerDoc, "SignatureValue",
+ XMLSignature.XMLNS, dsPrefix);
+ if (valueBase64 != null) {
+ sigValueElem.appendChild(ownerDoc.createTextNode(valueBase64));
+ }
// append Id attribute, if specified
- xwriter.writeIdAttribute("", "", "Id", id);
- if (valueBase64 != null) {
- xwriter.writeCharacters(valueBase64);
- }
-
- xwriter.writeEndElement(); // "SignatureValue"
+ DOMUtils.setAttributeID(sigValueElem, "Id", id);
+ parent.appendChild(sigValueElem);
}
- void setValue(XmlWriter xwriter, byte[] value) {
+ void setValue(byte[] value) {
this.value = value;
- valueBase64 = Base64.getMimeEncoder().encodeToString(value);
- if (xwriter != null) {
- xwriter.writeCharacters(valueBase64);
- }
+ valueBase64 = XMLUtils.encodeToString(value);
+ sigValueElem.appendChild(ownerDoc.createTextNode(valueBase64));
}
}
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java Sat Mar 09 12:54:20 2019 +0000
@@ -54,24 +54,20 @@
*/
public DOMXMLSignatureFactory() {}
- @Override
public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki) {
return new DOMXMLSignature(si, ki, null, null, null);
}
- @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki,
List objects, String id, String signatureValueId) {
return new DOMXMLSignature(si, ki, objects, id, signatureValueId);
}
- @Override
public Reference newReference(String uri, DigestMethod dm) {
return newReference(uri, dm, null, null, null);
}
- @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Reference newReference(String uri, DigestMethod dm, List transforms,
String type, String id) {
@@ -96,7 +92,6 @@
(uri, type, dm, appliedTransforms, result, transforms, id, getProvider());
}
- @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Reference newReference(String uri, DigestMethod dm, List transforms,
String type, String id, byte[] digestValue) {
@@ -107,14 +102,12 @@
(uri, type, dm, null, null, transforms, id, digestValue, getProvider());
}
- @Override
@SuppressWarnings({ "rawtypes" })
public SignedInfo newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm, List references) {
return newSignedInfo(cm, sm, references, null);
}
- @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public SignedInfo newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm, List references, String id) {
@@ -122,39 +115,33 @@
}
// Object factory methods
- @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public XMLObject newXMLObject(List content, String id, String mimeType,
String encoding) {
return new DOMXMLObject(content, id, mimeType, encoding);
}
- @Override
@SuppressWarnings({ "rawtypes" })
public Manifest newManifest(List references) {
return newManifest(references, null);
}
- @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Manifest newManifest(List references, String id) {
return new DOMManifest(references, id);
}
- @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public SignatureProperties newSignatureProperties(List props, String id) {
return new DOMSignatureProperties(props, id);
}
- @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public SignatureProperty newSignatureProperty
(List info, String target, String id) {
return new DOMSignatureProperty(info, target, id);
}
- @Override
public XMLSignature unmarshalXMLSignature(XMLValidateContext context)
throws MarshalException {
@@ -164,7 +151,6 @@
return unmarshal(((DOMValidateContext) context).getNode(), context);
}
- @Override
public XMLSignature unmarshalXMLSignature(XMLStructure xmlStructure)
throws MarshalException {
@@ -212,7 +198,6 @@
}
}
- @Override
public boolean isFeatureSupported(String feature) {
if (feature == null) {
throw new NullPointerException();
@@ -221,7 +206,6 @@
}
}
- @Override
public DigestMethod newDigestMethod(String algorithm,
DigestMethodParameterSpec params) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException {
@@ -255,7 +239,6 @@
}
}
- @Override
public SignatureMethod newSignatureMethod(String algorithm,
SignatureMethodParameterSpec params) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException {
@@ -321,7 +304,6 @@
}
}
- @Override
public Transform newTransform(String algorithm,
TransformParameterSpec params) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException {
@@ -341,7 +323,6 @@
return new DOMTransform(spi);
}
- @Override
public Transform newTransform(String algorithm,
XMLStructure params) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException {
@@ -364,7 +345,6 @@
return new DOMTransform(spi);
}
- @Override
public CanonicalizationMethod newCanonicalizationMethod(String algorithm,
C14NMethodParameterSpec params) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException {
@@ -383,7 +363,6 @@
return new DOMCanonicalizationMethod(spi);
}
- @Override
public CanonicalizationMethod newCanonicalizationMethod(String algorithm,
XMLStructure params) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException {
@@ -406,7 +385,6 @@
return new DOMCanonicalizationMethod(spi);
}
- @Override
public URIDereferencer getURIDereferencer() {
return DOMURIDereferencer.INSTANCE;
}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java Sat Mar 09 12:54:20 2019 +0000
@@ -57,7 +57,6 @@
*/
public final class DOMXPathFilter2Transform extends ApacheTransform {
- @Override
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException
{
@@ -70,7 +69,6 @@
this.params = params;
}
- @Override
public void init(XMLStructure parent, XMLCryptoContext context)
throws InvalidAlgorithmParameterException
{
@@ -126,7 +124,6 @@
this.params = new XPathFilter2ParameterSpec(list);
}
- @Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java Sat Mar 09 12:54:20 2019 +0000
@@ -60,7 +60,6 @@
this.params = params;
}
- @Override
public void init(XMLStructure parent, XMLCryptoContext context)
throws InvalidAlgorithmParameterException
{
@@ -89,7 +88,6 @@
}
}
- @Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java Sat Mar 09 12:54:20 2019 +0000
@@ -55,7 +55,6 @@
this.params = params;
}
- @Override
public void init(XMLStructure parent, XMLCryptoContext context)
throws InvalidAlgorithmParameterException {
@@ -68,7 +67,6 @@
(new javax.xml.crypto.dom.DOMStructure(sheet));
}
- @Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException {
super.marshalParams(parent, context);
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Marshaller.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,353 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jcp.xml.dsig.internal.dom;
-
-import java.util.ArrayList;
-import java.util.Base64;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.crypto.MarshalException;
-import javax.xml.crypto.XMLCryptoContext;
-import javax.xml.crypto.XMLStructure;
-import javax.xml.crypto.dsig.DigestMethod;
-import javax.xml.crypto.dsig.Manifest;
-import javax.xml.crypto.dsig.SignatureProperties;
-import javax.xml.crypto.dsig.SignatureProperty;
-import javax.xml.crypto.dsig.XMLSignature;
-import javax.xml.crypto.dsig.keyinfo.KeyInfo;
-import javax.xml.crypto.dsig.keyinfo.KeyName;
-import javax.xml.crypto.dsig.keyinfo.KeyValue;
-import javax.xml.crypto.dsig.keyinfo.PGPData;
-import javax.xml.crypto.dsig.keyinfo.X509Data;
-import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * Defines the individual marshallers for each of the different javax.xml.crypto structures.
- */
-class Marshaller {
-
- private Marshaller() {
- // complete
- }
-
- public static List<XmlWriter.ToMarshal<? extends XMLStructure>> getMarshallers() {
- return MARSHALLERS;
- }
-
- /**
- * Marshals a {@link KeyName}.
- *
- * @param xwriter
- * @param keyName
- * @param dsPrefix
- */
- public static void marshalKeyName(XmlWriter xwriter, KeyName keyName, String dsPrefix) {
- xwriter.writeTextElement(dsPrefix, "KeyName", XMLSignature.XMLNS, keyName.getName());
- }
-
- /**
- * Marshals a {@link PGPData}
- *
- * @param xwriter
- * @param pgpData
- * @param dsPrefix
- * @param context
- * @throws MarshalException
- */
- public static void marshalPGPData(XmlWriter xwriter, PGPData pgpData, String dsPrefix, XMLCryptoContext context)
- throws MarshalException {
- xwriter.writeStartElement(dsPrefix, "PGPData", XMLSignature.XMLNS);
-
- // create and append PGPKeyID element
- byte[] keyId = pgpData.getKeyId();
- if (keyId != null) {
- xwriter.writeTextElement(dsPrefix, "PGPKeyID", XMLSignature.XMLNS,
- Base64.getMimeEncoder().encodeToString(keyId));
- }
-
- // create and append PGPKeyPacket element
- byte[] keyPacket = pgpData.getKeyPacket();
- if (keyPacket != null) {
- xwriter.writeTextElement(dsPrefix, "XMLSignature.XMLNS", XMLSignature.XMLNS,
- Base64.getMimeEncoder().encodeToString(keyPacket));
- }
-
- // create and append any elements
- @SuppressWarnings("unchecked")
- List<XMLStructure> externalElements = pgpData.getExternalElements();
- for (XMLStructure externalItem : externalElements) {
- xwriter.marshalStructure(externalItem, dsPrefix, context);
- }
-
- xwriter.writeEndElement(); // "PGPData"
- }
-
- /**
- * Marshals an {@link X509IssuerSerial}
- *
- * @param xwriter
- * @param issuerSerial
- * @param dsPrefix
- */
- public static void marshalX509IssuerSerial(XmlWriter xwriter, X509IssuerSerial issuerSerial, String dsPrefix) {
- xwriter.writeStartElement(dsPrefix, "X509IssuerSerial", XMLSignature.XMLNS);
- xwriter.writeTextElement(dsPrefix, "X509IssuerName", XMLSignature.XMLNS,
- issuerSerial.getIssuerName());
-
- xwriter.writeTextElement(dsPrefix, "X509SerialNumber", XMLSignature.XMLNS,
- issuerSerial.getSerialNumber().toString());
-
- xwriter.writeEndElement(); // "X509IssuerSerial"
- }
-
- private static XmlWriter.ToMarshal<KeyName> Marshal_KeyName = new XmlWriter.ToMarshal<KeyName>(KeyName.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, KeyName toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- Marshaller.marshalKeyName(xwriter, toMarshal, dsPrefix);
- }
- };
-
- private static XmlWriter.ToMarshal<KeyInfo> Marshal_KeyInfo = new XmlWriter.ToMarshal<KeyInfo>(KeyInfo.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, KeyInfo toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- DOMKeyInfo.marshal(xwriter, toMarshal, dsPrefix, context);
- }
- };
-
- private static XmlWriter.ToMarshal<KeyValue> Marshal_KeyValue = new XmlWriter.ToMarshal<KeyValue>(KeyValue.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, KeyValue toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- // Since DOMKeyValue allows for deserializing unrecognized keys, and that
- // capability isn't available via the KeyValue interface, this must continue
- // to cast to DOMKeyValue.
- DOMKeyValue<?> dkv = (DOMKeyValue<?>) toMarshal;
- dkv.marshal( xwriter, dsPrefix, context);
- }
- };
-
- private static XmlWriter.ToMarshal<X509IssuerSerial> Marshal_X509IssuerSerial =
- new XmlWriter.ToMarshal<X509IssuerSerial>(X509IssuerSerial.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, X509IssuerSerial toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- Marshaller.marshalX509IssuerSerial( xwriter, toMarshal, dsPrefix);
- }
- };
-
- private static XmlWriter.ToMarshal<X509Data> Marshal_X509Data =
- new XmlWriter.ToMarshal<X509Data>(X509Data.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, X509Data toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- DOMX509Data.marshal( xwriter, toMarshal, dsPrefix, context);
- }
- };
-
- private static XmlWriter.ToMarshal<DigestMethod> Marshal_DigestMethod =
- new XmlWriter.ToMarshal<DigestMethod>(DigestMethod.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, DigestMethod toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- DOMDigestMethod.marshal( xwriter, toMarshal, dsPrefix);
- }
- };
-
- private static XmlWriter.ToMarshal<PGPData> Marshal_PGPData =
- new XmlWriter.ToMarshal<PGPData>(PGPData.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, PGPData toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- Marshaller.marshalPGPData( xwriter, toMarshal, dsPrefix, context);
- }
- };
-
- private static XmlWriter.ToMarshal<SignatureProperty> Marshal_SignatureProperty =
- new XmlWriter.ToMarshal<SignatureProperty>(SignatureProperty.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, SignatureProperty toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- DOMSignatureProperty.marshal(xwriter, toMarshal, dsPrefix, context);
- }
- };
-
- private static XmlWriter.ToMarshal<SignatureProperties> Marshal_SignatureProperties =
- new XmlWriter.ToMarshal<SignatureProperties>(SignatureProperties.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, SignatureProperties toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- DOMSignatureProperties.marshal(xwriter, toMarshal, dsPrefix, context);
- }
- };
-
- private static XmlWriter.ToMarshal<DOMSignatureMethod> Marshal_DOMSignatureMethod =
- new XmlWriter.ToMarshal<DOMSignatureMethod>(DOMSignatureMethod.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, DOMSignatureMethod toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- toMarshal.marshal(xwriter, dsPrefix);
- }
- };
-
- private static XmlWriter.ToMarshal<DOMTransform> Marshal_DOMTransform =
- new XmlWriter.ToMarshal<DOMTransform>(DOMTransform.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, DOMTransform toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- toMarshal.marshal(xwriter, dsPrefix, context);
- }
- };
-
- private static XmlWriter.ToMarshal<Manifest> Marshal_Manifest =
- new XmlWriter.ToMarshal<Manifest>(Manifest.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, Manifest toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- DOMManifest.marshal(xwriter, toMarshal, dsPrefix, context);
- }
- };
-
- private static XmlWriter.ToMarshal<DOMStructure> Marshal_DOMStructure =
- new XmlWriter.ToMarshal<DOMStructure>(DOMStructure.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, DOMStructure toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- toMarshal.marshal(xwriter, dsPrefix, context);
- }
- };
-
- private static XmlWriter.ToMarshal<javax.xml.crypto.dom.DOMStructure> Marshal_JavaXDOMStructure =
- new XmlWriter.ToMarshal<javax.xml.crypto.dom.DOMStructure>(javax.xml.crypto.dom.DOMStructure.class) {
- @Override
- public void marshalObject(XmlWriter xwriter, javax.xml.crypto.dom.DOMStructure toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException {
- marshalGenericNode(xwriter, toMarshal);
- }
- };
-
- private static final List<XmlWriter.ToMarshal<? extends XMLStructure>> MARSHALLERS =
- new ArrayList<XmlWriter.ToMarshal<? extends XMLStructure>>();
-
- static {
- MARSHALLERS.add(Marshal_KeyName);
- MARSHALLERS.add(Marshal_KeyInfo);
- MARSHALLERS.add(Marshal_KeyValue);
- MARSHALLERS.add(Marshal_X509IssuerSerial);
- MARSHALLERS.add(Marshal_X509Data);
- MARSHALLERS.add(Marshal_DigestMethod);
- MARSHALLERS.add(Marshal_PGPData);
- MARSHALLERS.add(Marshal_SignatureProperty);
- MARSHALLERS.add(Marshal_SignatureProperties);
- MARSHALLERS.add(Marshal_DOMSignatureMethod);
- MARSHALLERS.add(Marshal_DOMTransform);
- MARSHALLERS.add(Marshal_Manifest);
- MARSHALLERS.add(Marshal_DOMStructure);
- MARSHALLERS.add(Marshal_JavaXDOMStructure);
- }
-
- private static void marshalGenericNode(XmlWriter xwriter, javax.xml.crypto.dom.DOMStructure xmlStruct) {
- Node node = xmlStruct.getNode();
-
- // if it is a namespace, make a copy.
- if (DOMUtils.isNamespace(node)) {
- xwriter.writeNamespace(node.getLocalName(), node.getTextContent());
- }
- else if (Node.ATTRIBUTE_NODE == node.getNodeType() ) {
- sendAttributeToWriter(xwriter, (Attr) node);
- }
- else {
- marshalGenericNode(xwriter, node);
- }
- }
-
- private static void marshalGenericNode(XmlWriter xwriter, Node node) {
-
- short nodeType = node.getNodeType();
- if (DOMUtils.isNamespace(node)) {
- xwriter.writeNamespace(node.getLocalName(), node.getTextContent());
- }
- else if (nodeType == Node.ATTRIBUTE_NODE) {
- // if it is an attribute, make a copy.
- sendAttributeToWriter(xwriter, (Attr) node);
- }
- else {
- switch (nodeType) {
- case Node.ELEMENT_NODE:
- xwriter.writeStartElement(node.getPrefix(), node.getLocalName(), node.getNamespaceURI());
-
- // emit all the namespaces and attributes.
- NamedNodeMap nnm = node.getAttributes();
- for (int idx = 0 ; idx < nnm.getLength() ; idx++) {
- Attr attr = (Attr) nnm.item(idx);
- // is this a namespace node?
- if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(node.getNamespaceURI())) {
- xwriter.writeNamespace(attr.getLocalName(), attr.getValue());
- }
- else {
- // nope - standard attribute.
- sendAttributeToWriter(xwriter, attr);
- }
- }
- // now loop through all the children.
- for (Node child = node.getFirstChild() ; child != null ; child = child.getNextSibling()) {
- marshalGenericNode(xwriter, child);
- }
- xwriter.writeEndElement();
- break;
- case Node.COMMENT_NODE:
- xwriter.writeComment(node.getTextContent());
- break;
- case Node.TEXT_NODE:
- xwriter.writeCharacters(node.getTextContent());
- break;
- default:
- // unhandled - don't care to deal with processing instructions.
- break;
- }
- }
- }
-
- private static void sendAttributeToWriter(XmlWriter xwriter, Attr attr) {
- if (attr.isId()) {
- xwriter.writeIdAttribute(attr.getPrefix(), attr.getNamespaceURI(),
- attr.getLocalName(), attr.getTextContent());
- }
- else {
- if (attr.getNamespaceURI() == null && attr.getLocalName() == null) {
- // Level 1 DOM attribute
- xwriter.writeAttribute(null, null, attr.getName(), attr.getTextContent());
- } else {
- xwriter.writeAttribute(attr.getPrefix(), attr.getNamespaceURI(), attr.getLocalName(),
- attr.getTextContent());
- }
- }
- }
-
-}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XmlWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jcp.xml.dsig.internal.dom;
-
-import javax.xml.crypto.MarshalException;
-import javax.xml.crypto.XMLCryptoContext;
-import javax.xml.crypto.XMLStructure;
-
-import org.w3c.dom.Attr;
-
-/**
- * This interface is used to construct XML via a sequence of API calls.
- *
- * <p>This is written to be similar to javax.xml.stream.XMLStreamWriter, but
- * has slightly different requirements. Specifically, we need to be able to create
- * an "ID" type attribute, and get the current node.
- * </p>
- */
-public interface XmlWriter {
-
- /**
- * Utility class that brings together the class, and the method for marshaling an
- * instance of said class.
- *
- * @param <CLZ>
- */
- abstract static class ToMarshal<CLZ extends XMLStructure> { //NOPMD
- public final Class<CLZ> clazzToMatch;
-
- public ToMarshal(Class<CLZ> clazzToMatch) {
- this.clazzToMatch = clazzToMatch;
- }
-
- public abstract void marshalObject(XmlWriter xwriter, CLZ toMarshal, String dsPrefix,
- XMLCryptoContext context) throws MarshalException;
- }
-
- /**
- *
- * @param prefix What prefix to use?
- * @param localName What local name to use?
- * @param namespaceURI What namespace URI?
- *
- * See also {@link javax.xml.stream.XMLStreamWriter#writeStartElement(String, String, String)}
- */
- void writeStartElement(String prefix, String localName, String namespaceURI);
-
- /**
- * See also {@link javax.xml.stream.XMLStreamWriter#writeEndElement()}
- */
- void writeEndElement();
-
- /**
- * Convenience method that writes both a start and end tag, with text contents as
- * provided.
- *
- * @param prefix
- * @param localName
- * @param namespaceURI
- * @param value
- */
- void writeTextElement(String prefix, String localName, String namespaceURI, String value);
-
- void writeNamespace(String prefix, String namespaceURI);
-
- void writeCharacters(String text);
-
- void writeComment(String text);
-
- Attr writeAttribute(String prefix, String namespaceURI, String localName, String value);
-
- void writeIdAttribute(String prefix, String namespaceURI, String localName, String value);
-
- /**
- * Get the local name of the current element.
- * @return the local name of the current element.
- */
- String getCurrentLocalName();
-
- XMLStructure getCurrentNodeAsStructure();
-
- /**
- * This method marshals a structure, and relies on implementation specific details for how
- * an instance of a particular class maps to the method that actually does the marshaling.
- *
- * @param toMarshal The object to be marshaled.
- * @param dsPrefix The digital signature prefix.
- * @param context The context for marshaling.
- * @throws MarshalException Thrown if something goes wrong during the marshaling.
- */
- void marshalStructure(XMLStructure toMarshal, String dsPrefix, XMLCryptoContext context) throws MarshalException;
-}
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XmlWriterToTree.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,208 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jcp.xml.dsig.internal.dom;
-
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.crypto.MarshalException;
-import javax.xml.crypto.XMLCryptoContext;
-import javax.xml.crypto.XMLStructure;
-import javax.xml.crypto.dom.DOMStructure;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-/**
- * Manifestation of XmlWriter interface designed to write to a tree.
- */
-public class XmlWriterToTree implements XmlWriter {
-
- private Document factory;
-
- private Element createdElement;
-
- private Node nextSibling;
-
- private Node currentNode;
-
- private List<XmlWriter.ToMarshal<? extends XMLStructure>> m_marshallers;
-
- public XmlWriterToTree(List<XmlWriter.ToMarshal<? extends XMLStructure>> marshallers, Node parent) {
- m_marshallers = marshallers;
- factory = parent instanceof Document ? (Document)parent : parent.getOwnerDocument();
- currentNode = parent;
- }
-
- /**
- * Reset to a new parent so that the writer can be re-used.
- * @param newParent
- */
- public void resetToNewParent(Node newParent) {
- currentNode = newParent;
- createdElement = null;
- }
-
- /**
- * Get the root element created with this writer.
- * @return the root element created with this writer.
- */
- public Element getCreatedElement() {
- return createdElement;
- }
-
- /**
- * In cases where the serialization is supposed to precede a specific
- * element, we add an extra parameter to capture that. Only affects the
- * first element insertion (obviously?).
- *
- * @param marshallers
- * @param parent
- * @param nextSibling The first element created will be created *before* this element.
- */
- public XmlWriterToTree(List<XmlWriter.ToMarshal<? extends XMLStructure>> marshallers, Node parent, Node nextSibling) {
- this(marshallers, parent);
- this.nextSibling = nextSibling;
- }
-
- @Override
- public void writeStartElement(String prefix, String localName, String namespaceURI) {
- if ("".equals(namespaceURI)) {
- // Map global namespace from StAX to DOM
- namespaceURI = null;
- }
-
- Element newElem = factory.createElementNS(namespaceURI, DOMUtils.getQNameString(prefix, localName));
- if (nextSibling != null) {
- newElem = (Element)nextSibling.getParentNode().insertBefore(newElem, nextSibling);
- }
- else {
- newElem = (Element)currentNode.appendChild(newElem);
- }
- nextSibling = null;
- currentNode = newElem;
-
- if (createdElement == null) {
- createdElement = newElem;
- }
- }
-
- @Override
- public void writeEndElement() {
- currentNode = currentNode.getParentNode();
- }
-
-
- @Override
- public void writeTextElement(String prefix, String localName, String namespaceURI, String value) {
- writeStartElement(prefix, localName, namespaceURI);
- writeCharacters(value);
- writeEndElement();
- }
-
- @Override
- public void writeNamespace(String prefix, String namespaceURI) {
- if ("".equals(prefix) || prefix == null) {
- writeAttribute(null, XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns", namespaceURI);
- }
- else {
- writeAttribute("xmlns", XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix, namespaceURI);
- }
- }
-
- @Override
- public void writeCharacters(String text) {
- Text textNode = factory.createTextNode(text);
- currentNode.appendChild(textNode);
- }
-
-
- @Override
- public void writeComment(String text) {
- Comment commentNode = factory.createComment(text);
- currentNode.appendChild(commentNode);
- }
-
- @Override
- public Attr writeAttribute(String prefix, String namespaceURI, String localName, String value) {
-
- Attr result = null;
- if (value != null) {
- if ("".equals(namespaceURI)) {
- // Map global namespace from StAX to DOM
- namespaceURI = null;
- }
-
- result = factory.createAttributeNS(namespaceURI, DOMUtils.getQNameString(prefix, localName));
- result.setTextContent(value);
- if (! (currentNode instanceof Element)) {
- throw new IllegalStateException(
- "Attempting to add an attribute to something other than an element node. Node is "
- + currentNode.toString());
- }
- ( (Element)currentNode).setAttributeNodeNS(result);
- }
- return result;
- }
-
- @Override
- public void writeIdAttribute(String prefix, String namespaceURI, String localName, String value) {
- if (value == null) {
- return;
- }
- Attr newAttr = writeAttribute(prefix, namespaceURI, localName, value);
- ( (Element)currentNode).setIdAttributeNode(newAttr, true);
- }
-
-
- @Override
- public String getCurrentLocalName() {
- return currentNode.getLocalName();
- }
-
- @Override
- public XMLStructure getCurrentNodeAsStructure() {
- return new DOMStructure(currentNode);
- }
-
- @Override
- public void marshalStructure(XMLStructure toMarshal, String dsPrefix, XMLCryptoContext context) throws MarshalException {
-
- // look for the first isInstance match, and marshal to that.
- for (int idx = 0 ; idx < m_marshallers.size() ; idx++) {
- @SuppressWarnings("unchecked")
- XmlWriter.ToMarshal<XMLStructure> marshaller = (ToMarshal<XMLStructure>) m_marshallers.get(idx);
- if (marshaller.clazzToMatch.isInstance(toMarshal)) {
- marshaller.marshalObject(this, toMarshal, dsPrefix, context);
- return;
- }
- }
- throw new IllegalArgumentException("Unable to marshal unexpected object of class " + toMarshal.getClass().toString());
- }
-
-
-}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -504,12 +504,8 @@
module.completer = sym -> completeModule((ModuleSymbol) sym);
} else {
Assert.check(rootModules.isEmpty());
- String moduleOverride = singleModuleOverride(trees);
- if (moduleOverride != null) {
- module = moduleFinder.findModule(names.fromString(moduleOverride));
- } else {
- module = defaultModule;
- }
+ Assert.checkNonNull(c);
+ module = c.packge().modle;
rootModules.add(module);
}
@@ -1796,6 +1792,7 @@
public void newRound() {
allModules = null;
rootModules = null;
+ defaultModule = null;
warnedMissing.clear();
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Sat Mar 09 12:54:20 2019 +0000
@@ -1174,7 +1174,7 @@
protected void read(Symbol sym, int attrLen) {
ClassSymbol c = (ClassSymbol) sym;
Name n = readName(nextChar());
- c.sourcefile = new SourceFileObject(n, c.flatname);
+ c.sourcefile = new SourceFileObject(n);
// If the class is a toplevel class, originating from a Java source file,
// but the class name does not match the file name, then it is
// an auxiliary class.
@@ -2950,11 +2950,9 @@
/** The file's name.
*/
private final Name name;
- private final Name flatname;
- public SourceFileObject(Name name, Name flatname) {
+ public SourceFileObject(Name name) {
this.name = name;
- this.flatname = flatname;
}
@Override @DefinedBy(Api.COMPILER)
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015, Red Hat Inc.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, Red Hat Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -223,7 +223,13 @@
}
}
- setValues(sp, fp, null);
+ // We found a PC in the frame anchor. Check that it's plausible, and
+ // if it is, use it.
+ if (vm.isJavaPCDbg(pc)) {
+ setValues(sp, fp, pc);
+ } else {
+ setValues(sp, fp, null);
+ }
return true;
}
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015, Red Hat Inc.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, Red Hat Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -136,7 +136,15 @@
this.raw_sp = raw_sp;
this.raw_unextendedSP = raw_sp;
this.raw_fp = raw_fp;
- this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
+
+ // We cannot assume SP[-1] always contains a valid return PC (e.g. if
+ // the callee is a C/C++ compiled frame). If the PC is not known to
+ // Java then this.pc is null.
+ Address savedPC = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
+ if (VM.getVM().isJavaPCDbg(savedPC)) {
+ this.pc = savedPC;
+ }
+
adjustUnextendedSP();
// Frame must be fully constructed before this call
--- a/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved.
+ * 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
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
import java.util.zip.*;
import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
@@ -38,7 +37,6 @@
import javax.lang.model.util.SimpleElementVisitor9;
import com.sun.source.doctree.DocTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -170,7 +168,7 @@
String unicode = uc.toString();
contentTree.addContent(getMarkerAnchorForIndex(unicode));
Content headContent = new StringContent(unicode);
- Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, false,
+ Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, false,
HtmlStyle.title, headContent);
contentTree.addContent(heading);
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* 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,12 +40,10 @@
import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.Links;
-import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
import jdk.javadoc.internal.doclets.toolkit.Resources;
@@ -376,18 +374,6 @@
}
/**
- * Get the header for the section.
- *
- * @param member the member being documented.
- * @return a header content for the section.
- */
- protected Content getHead(Element member) {
- Content memberContent = new StringContent(name(member));
- Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent);
- return heading;
- }
-
- /**
* Return true if the given <code>ProgramElement</code> is inherited
* by the class that is being documented.
*
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -33,7 +33,6 @@
import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -222,7 +221,7 @@
* @param modules the modules to be documented
* @param text string which will be used as the heading
* @param tableSummary summary for the table
- * @param header the document tree to which the navgational links will be added
+ * @param header the document tree to which the navigational links will be added
* @param main the document tree to which the modules list will be added
*/
protected void addIndexContents(Collection<ModuleElement> modules, String text,
@@ -268,7 +267,7 @@
protected void addConfigurationTitle(Content body) {
if (configuration.doctitle.length() > 0) {
Content title = new RawHtml(configuration.doctitle);
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, title);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
body.addContent(div);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,7 +29,6 @@
import javax.lang.model.element.PackageElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -180,7 +179,7 @@
protected void addConfigurationTitle(Content body) {
if (configuration.doctitle.length() > 0) {
Content title = new RawHtml(configuration.doctitle);
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, title);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
body.addContent(div);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* 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 javax.lang.model.element.TypeElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -117,7 +116,7 @@
if (!sset.isEmpty()) {
TypeElement firstTypeElement = sset.first();
Content headingContent = contents.getContent(heading);
- Content sectionHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
+ Content sectionHeading = HtmlTree.HEADING(Headings.CONTENT_HEADING, true,
headingContent);
HtmlTree htmlTree = HtmlTree.SECTION(sectionHeading);
addLevelInfo(!utils.isInterface(firstTypeElement) ? firstTypeElement : null,
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,7 +29,6 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -112,7 +111,7 @@
String label = resources.getText("doclet.All_Classes");
Content body = getBody(false, getWindowTitle(label));
Content htmlTree = HtmlTree.MAIN();
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
HtmlStyle.bar, contents.allClassesLabel);
htmlTree.addContent(heading);
Content ul = new HtmlTree(HtmlTag.UL);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -32,7 +32,6 @@
import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -148,7 +147,7 @@
}
}
Content titleContent = contents.allClassesLabel;
- Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, titleContent);
Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading);
content.addContent(headerDiv);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -27,7 +27,6 @@
import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -94,7 +93,7 @@
div.setStyle(HtmlStyle.allPackagesContainer);
addPackages(div);
Content titleContent = contents.allPackagesLabel;
- Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, titleContent);
Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading);
mainTree.addContent(headerDiv);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,6 @@
import javax.lang.model.type.TypeMirror;
import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -72,7 +71,7 @@
public Content getMemberSummaryHeader(TypeElement typeElement,
Content memberSummaryTree) {
memberSummaryTree.addContent(
- HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY);
+ MarkerComments.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, typeElement, memberTree);
return memberTree;
@@ -96,7 +95,7 @@
* {@inheritDoc}
*/
public void addAnnotationFieldDetailsMarker(Content memberDetails) {
- memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_DETAILS);
+ memberDetails.addContent(MarkerComments.START_OF_ANNOTATION_TYPE_FIELD_DETAILS);
}
/**
@@ -107,7 +106,7 @@
if (!writer.printedAnnotationFieldHeading) {
memberDetailsTree.addContent(links.createAnchor(
SectionName.ANNOTATION_TYPE_FIELD_DETAIL));
- Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING,
contents.fieldDetailsLabel);
memberDetailsTree.addContent(heading);
writer.printedAnnotationFieldHeading = true;
@@ -121,7 +120,7 @@
Content annotationDetailsTree) {
annotationDetailsTree.addContent(links.createAnchor(name(member)));
Content annotationDocTree = writer.getMemberTreeHeader();
- Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING);
heading.addContent(name(member));
annotationDocTree.addContent(heading);
return annotationDocTree;
@@ -188,7 +187,7 @@
* {@inheritDoc}
*/
public void addSummaryLabel(Content memberTree) {
- Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING,
contents.fieldSummaryLabel);
memberTree.addContent(label);
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,9 +33,7 @@
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeOptionalMemberWriter;
import jdk.javadoc.internal.doclets.toolkit.Content;
@@ -75,7 +73,7 @@
public Content getMemberSummaryHeader(TypeElement typeElement,
Content memberSummaryTree) {
memberSummaryTree.addContent(
- HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY);
+ MarkerComments.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, typeElement, memberTree);
return memberTree;
@@ -112,7 +110,7 @@
*/
@Override
public void addSummaryLabel(Content memberTree) {
- Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING,
contents.annotateTypeOptionalMemberSummaryLabel);
memberTree.addContent(label);
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,11 +33,9 @@
import javax.lang.model.type.TypeMirror;
import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter;
import jdk.javadoc.internal.doclets.toolkit.Content;
@@ -75,7 +73,7 @@
public Content getMemberSummaryHeader(TypeElement typeElement,
Content memberSummaryTree) {
memberSummaryTree.addContent(
- HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY);
+ MarkerComments.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, typeElement, memberTree);
return memberTree;
@@ -99,7 +97,7 @@
* {@inheritDoc}
*/
public void addAnnotationDetailsMarker(Content memberDetails) {
- memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS);
+ memberDetails.addContent(MarkerComments.START_OF_ANNOTATION_TYPE_DETAILS);
}
/**
@@ -110,7 +108,7 @@
if (!writer.printedAnnotationHeading) {
memberDetailsTree.addContent(links.createAnchor(
SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL));
- Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING,
contents.annotationTypeDetailsLabel);
memberDetailsTree.addContent(heading);
writer.printedAnnotationHeading = true;
@@ -126,7 +124,7 @@
annotationDetailsTree.addContent(links.createAnchor(
simpleName + utils.signature((ExecutableElement) member)));
Content annotationDocTree = writer.getMemberTreeHeader();
- Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING);
heading.addContent(simpleName);
annotationDocTree.addContent(heading);
return annotationDocTree;
@@ -193,7 +191,7 @@
* {@inheritDoc}
*/
public void addSummaryLabel(Content memberTree) {
- Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING,
contents.annotateTypeRequiredMemberSummaryLabel);
memberTree.addContent(label);
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -32,7 +32,6 @@
import javax.lang.model.element.TypeElement;
import com.sun.source.doctree.DocTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -95,7 +94,7 @@
navBar.setUserHeader(getUserHeaderFooter(true));
htmlTree.addContent(navBar.getContent(true));
bodyTree.addContent(htmlTree);
- bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
+ bodyTree.addContent(MarkerComments.START_OF_CLASS_DATA);
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.header);
if (configuration.showModules) {
@@ -118,7 +117,7 @@
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_HEADER, annotationType);
Content headerContent = new StringContent(header);
- Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, headerContent);
heading.addContent(getTypeParameterLinks(linkInfo));
div.addContent(heading);
@@ -139,7 +138,7 @@
*/
@Override
public void addFooter(Content contentTree) {
- contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
+ contentTree.addContent(MarkerComments.END_OF_CLASS_DATA);
Content htmlTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
htmlTree.addContent(navBar.getContent(false));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -42,7 +42,6 @@
import javax.tools.Diagnostic;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -325,7 +324,7 @@
getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
typeElement)),
getPackageLink(pkg, utils.getPackageName(pkg)));
- Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
+ Content heading = HtmlTree.HEADING(Headings.TypeUse.SUMMARY_HEADING, link);
htmlTree.addContent(heading);
addClassUse(pkg, htmlTree);
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
@@ -452,7 +451,7 @@
headContent.addContent(contents.getContent("doclet.ClassUse_Title", cltype));
headContent.addContent(new HtmlTree(HtmlTag.BR));
headContent.addContent(clname);
- Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
true, HtmlStyle.title, headContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
mainTree.addContent(div);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -36,7 +36,6 @@
import javax.lang.model.util.SimpleElementVisitor8;
import com.sun.source.doctree.DocTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -116,7 +115,7 @@
navBar.setUserHeader(getUserHeaderFooter(true));
htmlTree.addContent(navBar.getContent(true));
bodyTree.addContent(htmlTree);
- bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
+ bodyTree.addContent(MarkerComments.START_OF_CLASS_DATA);
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.header);
if (configuration.showModules) {
@@ -143,7 +142,7 @@
//Let's not link to ourselves in the header.
linkInfo.linkToSelf = false;
Content headerContent = new StringContent(header);
- Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, headerContent);
heading.addContent(getTypeParameterLinks(linkInfo));
div.addContent(heading);
@@ -164,7 +163,7 @@
*/
@Override
public void addFooter(Content contentTree) {
- contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
+ contentTree.addContent(MarkerComments.END_OF_CLASS_DATA);
Content htmlTree = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
htmlTree.addContent(navBar.getContent(false));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -36,7 +36,6 @@
import javax.lang.model.element.VariableElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -152,11 +151,11 @@
@Override
public void addContentsList(Content contentTree, Content contentListTree) {
Content titleContent = contents.constantsSummaryTitle;
- Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, titleContent);
Content div = HtmlTree.DIV(HtmlStyle.header, pHeading);
Content headingContent = contents.contentsHeading;
- Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
+ Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, true,
headingContent);
HtmlTree section = HtmlTree.SECTION(heading);
section.addContent(contentListTree);
@@ -192,7 +191,7 @@
pkgNameContent = getPackageLabel(parsedPackageName);
}
Content headingContent = new StringContent(".*");
- Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
+ Content heading = HtmlTree.HEADING(Headings.ConstantsSummary.PACKAGE_HEADING, true,
pkgNameContent);
heading.addContent(headingContent);
summaryTree = HtmlTree.SECTION(heading);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -98,7 +97,7 @@
@Override
public Content getMemberSummaryHeader(TypeElement typeElement,
Content memberSummaryTree) {
- memberSummaryTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_SUMMARY);
+ memberSummaryTree.addContent(MarkerComments.START_OF_CONSTRUCTOR_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, typeElement, memberTree);
return memberTree;
@@ -118,11 +117,11 @@
@Override
public Content getConstructorDetailsTreeHeader(TypeElement typeElement,
Content memberDetailsTree) {
- memberDetailsTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_DETAILS);
+ memberDetailsTree.addContent(MarkerComments.START_OF_CONSTRUCTOR_DETAILS);
Content constructorDetailsTree = writer.getMemberTreeHeader();
constructorDetailsTree.addContent(links.createAnchor(
SectionName.CONSTRUCTOR_DETAIL));
- Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING,
contents.constructorDetailsLabel);
constructorDetailsTree.addContent(heading);
return constructorDetailsTree;
@@ -140,7 +139,7 @@
}
constructorDetailsTree.addContent(links.createAnchor(writer.getAnchor(constructor)));
Content constructorDocTree = writer.getMemberTreeHeader();
- Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING);
heading.addContent(name(constructor));
constructorDocTree.addContent(heading);
return constructorDocTree;
@@ -223,7 +222,7 @@
*/
@Override
public void addSummaryLabel(Content memberTree) {
- Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING,
contents.constructorSummaryLabel);
memberTree.addContent(label);
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -38,7 +38,6 @@
import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -336,11 +335,11 @@
*/
public Content getContentsList(DeprecatedAPIListBuilder deprapi) {
Content headContent = contents.deprecatedAPI;
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, headContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
Content headingContent = contents.contentsHeading;
- div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
+ div.addContent(HtmlTree.HEADING(Headings.CONTENT_HEADING, true,
headingContent));
Content ul = new HtmlTree(HtmlTag.UL);
for (DeprElementKind kind : DeprElementKind.values()) {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,11 +33,9 @@
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.EnumConstantWriter;
@@ -71,7 +69,7 @@
@Override
public Content getMemberSummaryHeader(TypeElement typeElement,
Content memberSummaryTree) {
- memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY);
+ memberSummaryTree.addContent(MarkerComments.START_OF_ENUM_CONSTANT_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, typeElement, memberTree);
return memberTree;
@@ -91,11 +89,11 @@
@Override
public Content getEnumConstantsDetailsTreeHeader(TypeElement typeElement,
Content memberDetailsTree) {
- memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS);
+ memberDetailsTree.addContent(MarkerComments.START_OF_ENUM_CONSTANT_DETAILS);
Content enumConstantsDetailsTree = writer.getMemberTreeHeader();
enumConstantsDetailsTree.addContent(links.createAnchor(
SectionName.ENUM_CONSTANT_DETAIL));
- Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING,
contents.enumConstantDetailLabel);
enumConstantsDetailsTree.addContent(heading);
return enumConstantsDetailsTree;
@@ -109,7 +107,7 @@
Content enumConstantsDetailsTree) {
enumConstantsDetailsTree.addContent(links.createAnchor(name(enumConstant)));
Content enumConstantsTree = writer.getMemberTreeHeader();
- Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING);
heading.addContent(name(enumConstant));
enumConstantsTree.addContent(heading);
return enumConstantsTree;
@@ -182,7 +180,7 @@
*/
@Override
public void addSummaryLabel(Content memberTree) {
- Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING,
contents.enumConstantSummary);
memberTree.addContent(label);
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,11 +35,9 @@
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.FieldWriter;
@@ -75,7 +73,7 @@
@Override
public Content getMemberSummaryHeader(TypeElement typeElement,
Content memberSummaryTree) {
- memberSummaryTree.addContent(HtmlConstants.START_OF_FIELD_SUMMARY);
+ memberSummaryTree.addContent(MarkerComments.START_OF_FIELD_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, typeElement, memberTree);
return memberTree;
@@ -94,11 +92,11 @@
*/
@Override
public Content getFieldDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) {
- memberDetailsTree.addContent(HtmlConstants.START_OF_FIELD_DETAILS);
+ memberDetailsTree.addContent(MarkerComments.START_OF_FIELD_DETAILS);
Content fieldDetailsTree = writer.getMemberTreeHeader();
fieldDetailsTree.addContent(links.createAnchor(
SectionName.FIELD_DETAIL));
- Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING,
contents.fieldDetailsLabel);
fieldDetailsTree.addContent(heading);
return fieldDetailsTree;
@@ -111,7 +109,7 @@
public Content getFieldDocTreeHeader(VariableElement field, Content fieldDetailsTree) {
fieldDetailsTree.addContent(links.createAnchor(name(field)));
Content fieldTree = writer.getMemberTreeHeader();
- Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING);
heading.addContent(name(field));
fieldTree.addContent(heading);
return fieldTree;
@@ -186,7 +184,7 @@
*/
@Override
public void addSummaryLabel(Content memberTree) {
- Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING,
contents.fieldSummaryLabel);
memberTree.addContent(label);
}
@@ -247,7 +245,7 @@
? resources.getText("doclet.Fields_Inherited_From_Class")
: resources.getText("doclet.Fields_Inherited_From_Interface"));
}
- Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
+ Content labelHeading = HtmlTree.HEADING(Headings.TypeDeclaration.INHERITED_SUMMARY_HEADING,
label);
labelHeading.addContent(Contents.SPACE);
labelHeading.addContent(classLink);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -96,6 +96,7 @@
protected void generateFrameFile() throws DocFileIOException {
Content frame = getFrameDetails();
HtmlTree body = new HtmlTree(HtmlTag.BODY);
+ body.addAttr(HtmlAttr.CLASS, "frames");
body.addAttr(HtmlAttr.ONLOAD, "loadFrames()");
String topFilePath = configuration.topFile.getPath();
Script script = new Script(
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Headings.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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.javadoc.internal.doclets.formats.html;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+
+/**
+ * Aliases for HTML heading tags (H1..H6) for different kinds of pages.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+class Headings {
+ /**
+ * Standard top-level heading for the page title for all pages.
+ */
+ static final HtmlTag PAGE_TITLE_HEADING = HtmlTag.H1;
+
+ /**
+ * Standard second-level heading for sundry pages that do
+ * not have their own page group.
+ */
+ static final HtmlTag CONTENT_HEADING = HtmlTag.H2;
+
+ /**
+ * Headings for the page for a module declaration.
+ */
+ static class ModuleDeclaration {
+ static final HtmlTag SUMMARY_HEADING = HtmlTag.H2;
+ }
+
+ /**
+ * Headings for the page for a type declaration.
+ * This includes classes, interfaces, enums and annotation types.
+ */
+ static class TypeDeclaration {
+ /**
+ * Heading for the different summary lists:
+ * Field Summary, Constructor Summary, Method Summary, etc.
+ */
+ static final HtmlTag SUMMARY_HEADING = HtmlTag.H2;
+
+ /**
+ * Subheading within a summary for the inherited elements:
+ * inherited methods, etc
+ */
+ static final HtmlTag INHERITED_SUMMARY_HEADING = HtmlTag.H3;
+
+ /**
+ * Heading for the different detail lists:
+ * Field Details, Constructor Details, Method Details, etc.
+ */
+ static final HtmlTag DETAILS_HEADING = HtmlTag.H2;
+
+ /**
+ * Subheading with a Details list for an individual element.
+ */
+ static final HtmlTag MEMBER_HEADING = HtmlTag.H3;
+ }
+
+ /**
+ * Headings for the Constants Summary page.
+ */
+ static class ConstantsSummary {
+ static final HtmlTag PACKAGE_HEADING = HtmlTag.H2;
+ }
+
+ /**
+ * Headings for the Serialized Form page.
+ */
+ static class SerializedForm {
+ /**
+ * Heading for the package name, preceding a list of types.
+ */
+ static final HtmlTag PACKAGE_HEADING = HtmlTag.H2;
+
+ /**
+ * Heading for a type name within a package.
+ */
+ static final HtmlTag CLASS_HEADING = HtmlTag.H3;
+
+ /**
+ * Subheading for info within a type.
+ */
+ static final HtmlTag CLASS_SUBHEADING = HtmlTag.H4;
+
+ /**
+ * Heading for an individual member element within a type.
+ */
+ static final HtmlTag MEMBER_HEADING = HtmlTag.H5;
+ }
+
+ /**
+ * Headings for a type Use page.
+ */
+ static class TypeUse {
+ static final HtmlTag SUMMARY_HEADING = HtmlTag.H2;
+ }
+
+ /**
+ * Headings for index frames pages.
+ */
+ static class IndexFrames {
+ /** Heading for a list of module names in an index frame. */
+ static final HtmlTag MODULE_HEADING = HtmlTag.H2;
+ /** Heading for a list of package names in an index frame. */
+ static final HtmlTag PACKAGE_HEADING = HtmlTag.H2;
+ }
+}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -25,7 +25,6 @@
package jdk.javadoc.internal.doclets.formats.html;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -113,7 +112,7 @@
*/
protected void addHelpFileContents(Content contentTree) {
// Heading
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false, HtmlStyle.title,
contents.getContent("doclet.help.main_heading"));
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
Content intro = HtmlTree.DIV(HtmlStyle.subTitle,
@@ -126,7 +125,7 @@
// Overview
if (configuration.createoverview) {
- Content overviewHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content overviewHeading = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.overviewLabel);
htmlTree = HtmlTree.SECTION(overviewHeading);
String overviewKey = configuration.showModules
@@ -143,7 +142,7 @@
// Module
if (configuration.showModules) {
- Content moduleHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content moduleHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.moduleLabel);
htmlTree = HtmlTree.SECTION(moduleHead);
Content moduleIntro = contents.getContent("doclet.help.module.intro");
@@ -158,7 +157,7 @@
}
// Package
- Content packageHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content packageHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.packageLabel);
htmlTree = HtmlTree.SECTION(packageHead);
Content packageIntro = contents.getContent("doclet.help.package.intro");
@@ -175,7 +174,7 @@
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
// Class/interface
- Content classHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content classHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.class_interface.head"));
htmlTree = HtmlTree.SECTION(classHead);
Content classIntro = contents.getContent("doclet.help.class_interface.intro");
@@ -210,7 +209,7 @@
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
// Annotation Types
- Content aHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content aHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.annotationType);
htmlTree = HtmlTree.SECTION(aHead);
Content aIntro = contents.getContent("doclet.help.annotation_type.intro");
@@ -226,7 +225,7 @@
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
// Enums
- Content enumHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, contents.enum_);
+ Content enumHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.enum_);
htmlTree = HtmlTree.SECTION(enumHead);
Content eIntro = contents.getContent("doclet.help.enum.intro");
Content enumPara = HtmlTree.P(eIntro);
@@ -241,7 +240,7 @@
// Class Use
if (configuration.classuse) {
- Content useHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content useHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.use.head"));
htmlTree = HtmlTree.SECTION(useHead);
Content useBody = contents.getContent("doclet.help.use.body");
@@ -252,7 +251,7 @@
// Tree
if (configuration.createtree) {
- Content treeHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content treeHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.tree.head"));
htmlTree = HtmlTree.SECTION(treeHead);
Content treeIntro = contents.getContent("doclet.help.tree.intro",
@@ -270,7 +269,7 @@
// Deprecated
if (!(configuration.nodeprecatedlist || configuration.nodeprecated)) {
- Content dHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content dHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.deprecatedAPI);
htmlTree = HtmlTree.SECTION(dHead);
Content deprBody = contents.getContent("doclet.help.deprecated.body",
@@ -291,7 +290,7 @@
indexlink = links.createLink(DocPaths.INDEX_ALL,
resources.getText("doclet.Index"));
}
- Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content indexHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.index.head"));
htmlTree = HtmlTree.SECTION(indexHead);
Content indexBody = contents.getContent("doclet.help.index.body", indexlink);
@@ -302,7 +301,7 @@
// Frames
if (configuration.frames) {
- Content frameHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content frameHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.frames.head"));
htmlTree = HtmlTree.SECTION(frameHead);
Content framesBody = contents.getContent("doclet.help.frames.body");
@@ -313,7 +312,7 @@
}
// Serialized Form
- Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content sHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.serializedForm);
htmlTree = HtmlTree.SECTION(sHead);
Content serialBody = contents.getContent("doclet.help.serial_form.body");
@@ -322,7 +321,7 @@
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
// Constant Field Values
- Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content constHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.constantsSummaryTitle);
htmlTree = HtmlTree.SECTION(constHead);
Content constantsBody = contents.getContent("doclet.help.constants.body",
@@ -333,7 +332,7 @@
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
// Search
- Content searchHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content searchHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.search.head"));
htmlTree = HtmlTree.SECTION(searchHead);
Content searchBody = contents.getContent("doclet.help.search.body");
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,11 +41,9 @@
import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
-import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.Messages;
import jdk.javadoc.internal.doclets.toolkit.Resources;
@@ -83,6 +81,11 @@
public class HtmlConfiguration extends BaseConfiguration {
/**
+ * Default charset for HTML.
+ */
+ public static final String HTML_DEFAULT_CHARSET = "utf-8";
+
+ /**
* Argument for command line option "-header".
*/
public String header = "";
@@ -762,7 +765,7 @@
protected boolean finishOptionSettings0() throws DocletException {
if (docencoding == null) {
if (charset == null) {
- docencoding = charset = (encoding == null) ? HtmlConstants.HTML_DEFAULT_CHARSET : encoding;
+ docencoding = charset = (encoding == null) ? HTML_DEFAULT_CHARSET : encoding;
} else {
docencoding = charset;
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -26,6 +26,7 @@
package jdk.javadoc.internal.doclets.formats.html;
import jdk.javadoc.internal.doclets.formats.html.markup.Head;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader;
import java.util.*;
@@ -2197,6 +2198,8 @@
*/
public HtmlTree getBody(boolean includeScript, String title) {
HtmlTree body = new HtmlTree(HtmlTag.BODY);
+ body.addAttr(HtmlAttr.CLASS, getBodyClass());
+
// Set window title string which is later printed
this.winTitle = title;
// Don't print windowtitle script for overview-frame, allclasses-frame
@@ -2210,6 +2213,15 @@
return body;
}
+ public String getBodyClass() {
+ return getClass().getSimpleName()
+ .replaceAll("(Writer)?(Impl)?$", "")
+ .replaceAll("AnnotationType", "Class")
+ .replaceAll("(.)([A-Z])", "$1-$2")
+ .replaceAll("(?i)^(module|package|class)$", "$1-declaration")
+ .toLowerCase(Locale.US);
+ }
+
Script getMainBodyScript() {
return mainBodyScript;
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -108,8 +107,7 @@
li.setStyle(HtmlStyle.blockList);
if (serializableFieldsTree.isValid()) {
Content headingContent = new StringContent(heading);
- Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
- headingContent);
+ Content serialHeading = HtmlTree.HEADING(Headings.SerializedForm.CLASS_SUBHEADING, headingContent);
li.addContent(serialHeading);
li.addContent(serializableFieldsTree);
}
@@ -120,7 +118,7 @@
public void addMemberHeader(TypeElement fieldType, String fieldTypeStr,
String fieldDimensions, String fieldName, Content contentTree) {
Content nameContent = new StringContent(fieldName);
- Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent);
+ Content heading = HtmlTree.HEADING(Headings.SerializedForm.MEMBER_HEADING, nameContent);
contentTree.addContent(heading);
Content pre = new HtmlTree(HtmlTag.PRE);
if (fieldType == null) {
@@ -138,7 +136,7 @@
@Override
public void addMemberHeader(TypeMirror fieldType, String fieldName, Content contentTree) {
Content nameContent = new StringContent(fieldName);
- Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent);
+ Content heading = HtmlTree.HEADING(HtmlTag.H5, nameContent);
contentTree.addContent(heading);
Content pre = new HtmlTree(HtmlTag.PRE);
Content fieldContent = writer.getLink(new LinkInfoImpl(
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* 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 javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -95,8 +94,7 @@
*/
public Content getSerializableMethods(String heading, Content serializableMethodContent) {
Content headingContent = new StringContent(heading);
- Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
- headingContent);
+ Content serialHeading = HtmlTree.HEADING(Headings.SerializedForm.CLASS_SUBHEADING, headingContent);
Content li = HtmlTree.LI(HtmlStyle.blockList, serialHeading);
li.addContent(serializableMethodContent);
return li;
@@ -120,7 +118,9 @@
* @param methodsContentTree the content tree to which the member header will be added
*/
public void addMemberHeader(ExecutableElement member, Content methodsContentTree) {
- methodsContentTree.addContent(getHead(member));
+ Content memberContent = new StringContent(name(member));
+ Content heading = HtmlTree.HEADING(Headings.SerializedForm.MEMBER_HEADING, memberContent);
+ methodsContentTree.addContent(heading);
methodsContentTree.addContent(getSignature(member));
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -107,7 +107,8 @@
bodyContent.addContent(HtmlTree.P(HtmlTree.A(targetPath, new StringContent(targetPath))));
- Content body = new HtmlTree(HtmlTag.BODY);
+ Content body = new HtmlTree(HtmlTag.BODY)
+ .addAttr(HtmlAttr.CLASS, "index-redirect");
HtmlTree main = HtmlTree.MAIN(bodyContent);
body.addContent(main);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MarkerComments.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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.javadoc.internal.doclets.formats.html;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.Comment;
+
+/**
+ * Marker comments to identify regions in the generated files.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ *
+ * @author Bhavesh Patel
+ */
+public class MarkerComments {
+
+ /**
+ * Marker to identify start of top navigation bar.
+ */
+ public static final Comment START_OF_TOP_NAVBAR =
+ new Comment("========= START OF TOP NAVBAR =======");
+
+ /**
+ * Marker to identify start of bottom navigation bar.
+ */
+ public static final Comment START_OF_BOTTOM_NAVBAR =
+ new Comment("======= START OF BOTTOM NAVBAR ======");
+
+ /**
+ * Marker to identify end of top navigation bar.
+ */
+ public static final Comment END_OF_TOP_NAVBAR =
+ new Comment("========= END OF TOP NAVBAR =========");
+
+ /**
+ * Marker to identify end of bottom navigation bar.
+ */
+ public static final Comment END_OF_BOTTOM_NAVBAR =
+ new Comment("======== END OF BOTTOM NAVBAR =======");
+
+ /**
+ * Marker to identify start of module description.
+ */
+ public static final Comment START_OF_MODULE_DESCRIPTION =
+ new Comment("============ MODULE DESCRIPTION ===========");
+
+ /**
+ * Marker to identify start of modules summary.
+ */
+ public static final Comment START_OF_MODULES_SUMMARY =
+ new Comment("============ MODULES SUMMARY ===========");
+
+ /**
+ * Marker to identify start of packages summary.
+ */
+ public static final Comment START_OF_PACKAGES_SUMMARY =
+ new Comment("============ PACKAGES SUMMARY ===========");
+
+ /**
+ * Marker to identify start of services summary.
+ */
+ public static final Comment START_OF_SERVICES_SUMMARY =
+ new Comment("============ SERVICES SUMMARY ===========");
+
+ /**
+ * Marker to identify start of class data.
+ */
+ public static final Comment START_OF_CLASS_DATA =
+ new Comment("======== START OF CLASS DATA ========");
+
+ /**
+ * Marker to identify end of class data.
+ */
+ public static final Comment END_OF_CLASS_DATA =
+ new Comment("========= END OF CLASS DATA =========");
+
+ /**
+ * Marker to identify start of nested class summary.
+ */
+ public static final Comment START_OF_NESTED_CLASS_SUMMARY =
+ new Comment("======== NESTED CLASS SUMMARY ========");
+
+ /**
+ * Marker to identify start of annotation type optional member summary.
+ */
+ public static final Comment START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY =
+ new Comment("=========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY ===========");
+
+ /**
+ * Marker to identify start of annotation type required member summary.
+ */
+ public static final Comment START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY =
+ new Comment("=========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY ===========");
+
+ /**
+ * Marker to identify start of annotation type required member summary.
+ */
+ public static final Comment START_OF_ANNOTATION_TYPE_FIELD_SUMMARY =
+ new Comment("=========== ANNOTATION TYPE FIELD SUMMARY ===========");
+
+ /**
+ * Marker to identify start of constructor summary.
+ */
+ public static final Comment START_OF_CONSTRUCTOR_SUMMARY =
+ new Comment("======== CONSTRUCTOR SUMMARY ========");
+
+ /**
+ * Marker to identify start of enum constants summary.
+ */
+ public static final Comment START_OF_ENUM_CONSTANT_SUMMARY =
+ new Comment("=========== ENUM CONSTANT SUMMARY ===========");
+
+ /**
+ * Marker to identify start of field summary.
+ */
+ public static final Comment START_OF_FIELD_SUMMARY =
+ new Comment("=========== FIELD SUMMARY ===========");
+
+ /**
+ * Marker to identify start of properties summary.
+ */
+ public static final Comment START_OF_PROPERTY_SUMMARY =
+ new Comment("=========== PROPERTY SUMMARY ===========");
+
+ /**
+ * Marker to identify start of method summary.
+ */
+ public static final Comment START_OF_METHOD_SUMMARY =
+ new Comment("========== METHOD SUMMARY ===========");
+
+ /**
+ * Marker to identify start of annotation type details.
+ */
+ public static final Comment START_OF_ANNOTATION_TYPE_DETAILS =
+ new Comment("============ ANNOTATION TYPE MEMBER DETAIL ===========");
+
+ /**
+ * Marker to identify start of annotation type field details.
+ */
+ public static final Comment START_OF_ANNOTATION_TYPE_FIELD_DETAILS =
+ new Comment("============ ANNOTATION TYPE FIELD DETAIL ===========");
+
+ /**
+ * Marker to identify start of method details.
+ */
+ public static final Comment START_OF_METHOD_DETAILS =
+ new Comment("============ METHOD DETAIL ==========");
+
+ /**
+ * Marker to identify start of field details.
+ */
+ public static final Comment START_OF_FIELD_DETAILS =
+ new Comment("============ FIELD DETAIL ===========");
+
+ /**
+ * Marker to identify start of property details.
+ */
+ public static final Comment START_OF_PROPERTY_DETAILS =
+ new Comment("============ PROPERTY DETAIL ===========");
+
+ /**
+ * Marker to identify start of constructor details.
+ */
+ public static final Comment START_OF_CONSTRUCTOR_DETAILS =
+ new Comment("========= CONSTRUCTOR DETAIL ========");
+
+ /**
+ * Marker to identify start of enum constants details.
+ */
+ public static final Comment START_OF_ENUM_CONSTANT_DETAILS =
+ new Comment("============ ENUM CONSTANT DETAIL ===========");
+
+}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* 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,7 +36,6 @@
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -87,7 +86,7 @@
*/
@Override
public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) {
- memberSummaryTree.addContent(HtmlConstants.START_OF_METHOD_SUMMARY);
+ memberSummaryTree.addContent(MarkerComments.START_OF_METHOD_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, typeElement, memberTree);
return memberTree;
@@ -106,10 +105,10 @@
*/
@Override
public Content getMethodDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) {
- memberDetailsTree.addContent(HtmlConstants.START_OF_METHOD_DETAILS);
+ memberDetailsTree.addContent(MarkerComments.START_OF_METHOD_DETAILS);
Content methodDetailsTree = writer.getMemberTreeHeader();
methodDetailsTree.addContent(links.createAnchor(SectionName.METHOD_DETAIL));
- Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING,
contents.methodDetailLabel);
methodDetailsTree.addContent(heading);
return methodDetailsTree;
@@ -126,7 +125,7 @@
}
methodDetailsTree.addContent(links.createAnchor(writer.getAnchor(method)));
Content methodDocTree = writer.getMemberTreeHeader();
- Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING);
heading.addContent(name(method));
methodDocTree.addContent(heading);
return methodDocTree;
@@ -229,7 +228,7 @@
*/
@Override
public void addSummaryLabel(Content memberTree) {
- Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING,
contents.methodSummary);
memberTree.addContent(label);
}
@@ -295,7 +294,7 @@
? resources.getText("doclet.Methods_Inherited_From_Class")
: resources.getText("doclet.Methods_Inherited_From_Interface"));
}
- Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
+ Content labelHeading = HtmlTree.HEADING(Headings.TypeDeclaration.INHERITED_SUMMARY_HEADING,
label);
labelHeading.addContent(Contents.SPACE);
labelHeading.addContent(classLink);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -32,7 +32,6 @@
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.ElementFilter;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -101,7 +100,7 @@
DocPath moduleSummary = configuration.useModuleDirectories
? DocPaths.DOT_DOT.resolve(configuration.docPaths.moduleSummary(moduleElement))
: configuration.docPaths.moduleSummary(moduleElement);
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.bar,
mdlgen.links.createLink(moduleSummary, mdlLabel, "", "classFrame"));
htmlTree.addContent(heading);
HtmlTree div = new HtmlTree(HtmlTag.DIV);
@@ -171,7 +170,7 @@
continue;
}
if (!printedHeader) {
- Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING,
true, labelContent);
htmlTree.addContent(heading);
printedHeader = true;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -32,7 +32,6 @@
import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -57,6 +56,12 @@
* @author Bhavesh Patel
*/
public class ModuleIndexFrameWriter extends AbstractModuleIndexWriter {
+ /**
+ * The heading (h1 or h2) to use for the module list,
+ * set by addNavigationBarHeader depending on whether or not there
+ * is an additional initial heading.
+ */
+ private HtmlTag moduleListHeading;
/**
* Construct the ModuleIndexFrameWriter object.
@@ -83,8 +88,9 @@
/**
* {@inheritDoc}
*/
+ @Override
protected void addModulesList(Content main) {
- Content heading = HtmlTree.HEADING(HtmlConstants.MODULE_HEADING, true,
+ Content heading = HtmlTree.HEADING(moduleListHeading, true,
contents.modulesLabel);
HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
HtmlTree ul = new HtmlTree(HtmlTag.UL);
@@ -125,15 +131,16 @@
* {@inheritDoc}
*/
protected void addNavigationBarHeader(Content header) {
- Content headerContent;
- if (configuration.packagesheader.length() > 0) {
- headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
+ String headerContent = !configuration.packagesheader.isEmpty() ? configuration.packagesheader
+ : configuration.header;
+ if (!headerContent.isEmpty()) {
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
+ HtmlStyle.bar, new RawHtml(replaceDocRootDir(headerContent)));
+ header.addContent(heading);
+ moduleListHeading = Headings.IndexFrames.MODULE_HEADING;
} else {
- headerContent = new RawHtml(replaceDocRootDir(configuration.header));
+ moduleListHeading = Headings.PAGE_TITLE_HEADING;
}
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
- HtmlStyle.bar, headerContent);
- header.addContent(heading);
}
/**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -33,7 +33,6 @@
import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -57,6 +56,12 @@
* @author Bhavesh Patel
*/
public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter {
+ /**
+ * The heading (h1 or h2) to use for the module packages list,
+ * set by addNavigationBarHeader depending on whether or not there
+ * is an additional initial heading.
+ */
+ private HtmlTag modulePackagesListHeading;
/**
* Construct the ModulePackageIndexFrameWriter object.
@@ -89,7 +94,7 @@
protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
String tableSummary, Content main, ModuleElement mdle) {
Content profNameContent = new StringContent(mdle.getQualifiedName().toString());
- Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
+ Content heading = HtmlTree.HEADING(modulePackagesListHeading, true,
getTargetModuleLink("classFrame", profNameContent, mdle));
heading.addContent(Contents.SPACE);
heading.addContent(contents.packagesLabel);
@@ -112,7 +117,7 @@
protected void addModulePackagesList(Set<ModuleElement> modules, String text,
String tableSummary, Content body, ModuleElement mdle) {
Content moduleNameContent = new StringContent(mdle.getQualifiedName().toString());
- Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
+ Content heading = HtmlTree.HEADING(modulePackagesListHeading, true,
getTargetModuleLink("classFrame", moduleNameContent, mdle));
heading.addContent(Contents.SPACE);
heading.addContent(contents.packagesLabel);
@@ -157,15 +162,16 @@
* {@inheritDoc}
*/
protected void addNavigationBarHeader(Content header) {
- Content headerContent;
- if (configuration.packagesheader.length() > 0) {
- headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
+ String headerContent = !configuration.packagesheader.isEmpty() ? configuration.packagesheader
+ : configuration.header;
+ if (!headerContent.isEmpty()) {
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
+ HtmlStyle.bar, new RawHtml(replaceDocRootDir(headerContent)));
+ header.addContent(heading);
+ modulePackagesListHeading = Headings.IndexFrames.PACKAGE_HEADING;
} else {
- headerContent = new RawHtml(replaceDocRootDir(configuration.header));
+ modulePackagesListHeading = Headings.PAGE_TITLE_HEADING;
}
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
- HtmlStyle.bar, headerContent);
- header.addContent(heading);
}
/**
@@ -177,6 +183,7 @@
/**
* Do nothing as there is no modules list on this page.
*/
+ @Override
protected void addModulesList(Content body) {
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -46,7 +46,6 @@
import com.sun.source.doctree.DocTree;
import jdk.javadoc.doclet.DocletEnvironment.ModuleMode;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -213,7 +212,7 @@
div.addContent(annotationContent);
Content label = mdle.isOpen() && (configuration.docEnv.getModuleMode() == ModuleMode.ALL)
? contents.openModuleLabel : contents.moduleLabel;
- Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ Content tHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, label);
tHeading.addContent(Contents.SPACE);
Content moduleHead = new RawHtml(heading);
@@ -461,7 +460,7 @@
Content htmltree) {
htmltree.addContent(startMarker);
htmltree.addContent(links.createAnchor(markerAnchor));
- htmltree.addContent(HtmlTree.HEADING(HtmlTag.H3, heading));
+ htmltree.addContent(HtmlTree.HEADING(Headings.ModuleDeclaration.SUMMARY_HEADING, heading));
}
/**
@@ -509,7 +508,7 @@
contents.descriptionLabel);
HtmlTree li = new HtmlTree(HtmlTag.LI);
li.setStyle(HtmlStyle.blockList);
- addSummaryHeader(HtmlConstants.START_OF_MODULES_SUMMARY, SectionName.MODULES,
+ addSummaryHeader(MarkerComments.START_OF_MODULES_SUMMARY, SectionName.MODULES,
contents.navModules, li);
if (display(requires)) {
String text = resources.getText("doclet.Requires_Summary");
@@ -561,7 +560,7 @@
|| display(indirectPackages) || display(indirectOpenPackages)) {
HtmlTree li = new HtmlTree(HtmlTag.LI);
li.setStyle(HtmlStyle.blockList);
- addSummaryHeader(HtmlConstants.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES,
+ addSummaryHeader(MarkerComments.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES,
contents.navPackages, li);
if (display(packages)) {
addPackageSummary(li);
@@ -740,7 +739,7 @@
if (haveProvides || haveUses) {
HtmlTree li = new HtmlTree(HtmlTag.LI);
li.setStyle(HtmlStyle.blockList);
- addSummaryHeader(HtmlConstants.START_OF_SERVICES_SUMMARY, SectionName.SERVICES,
+ addSummaryHeader(MarkerComments.START_OF_SERVICES_SUMMARY, SectionName.SERVICES,
contents.navServices, li);
TableHeader usesProvidesTableHeader =
new TableHeader(contents.typeLabel, contents.descriptionLabel);
@@ -869,7 +868,7 @@
if (!utils.getFullBody(mdle).isEmpty()) {
Content tree = HtmlTree.SECTION();
addDeprecationInfo(tree);
- tree.addContent(HtmlConstants.START_OF_MODULE_DESCRIPTION);
+ tree.addContent(MarkerComments.START_OF_MODULE_DESCRIPTION);
tree.addContent(links.createAnchor(SectionName.MODULE_DESCRIPTION));
addInlineComment(mdle, tree);
moduleContentTree.addContent(tree);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,8 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Navigation;
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
@@ -72,7 +70,7 @@
@Override
public Content getMemberSummaryHeader(TypeElement typeElement,
Content memberSummaryTree) {
- memberSummaryTree.addContent(HtmlConstants.START_OF_NESTED_CLASS_SUMMARY);
+ memberSummaryTree.addContent(MarkerComments.START_OF_NESTED_CLASS_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, typeElement, memberTree);
return memberTree;
@@ -91,7 +89,7 @@
*/
@Override
public void addSummaryLabel(Content memberTree) {
- Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING,
contents.nestedClassSummary);
memberTree.addContent(label);
}
@@ -155,8 +153,7 @@
? resources.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Interface")
: resources.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
}
- Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
- label);
+ Content labelHeading = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, label);
labelHeading.addContent(Contents.SPACE);
labelHeading.addContent(classLink);
inheritedTree.addContent(labelHeading);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -30,7 +30,6 @@
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -102,7 +101,7 @@
HtmlTree body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
Content pkgNameContent = new StringContent(pkgName);
HtmlTree htmlTree = HtmlTree.MAIN();
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.bar,
packgen.getTargetPackageLink(packageElement, "classFrame", pkgNameContent));
htmlTree.addContent(heading);
HtmlTree div = new HtmlTree(HtmlTag.DIV);
@@ -177,7 +176,7 @@
continue;
}
if (!printedHeader) {
- Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING,
true, labelContent);
htmlTree.addContent(heading);
printedHeader = true;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -27,7 +27,6 @@
import javax.lang.model.element.PackageElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -52,6 +51,12 @@
* @author Atul M Dambalkar
*/
public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
+ /**
+ * The heading (h1 or h2) to use for the module list,
+ * set by addNavigationBarHeader depending on whether or not there
+ * is an additional initial heading.
+ */
+ private HtmlTag packageListHeading;
/**
* Construct the PackageIndexFrameWriter object.
@@ -79,7 +84,7 @@
*/
@Override
protected void addPackagesList(Content main) {
- Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
+ Content heading = HtmlTree.HEADING(packageListHeading, true,
contents.packagesLabel);
HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
HtmlTree ul = new HtmlTree(HtmlTag.UL);
@@ -130,9 +135,14 @@
} else {
headerContent = new RawHtml(replaceDocRootDir(configuration.header));
}
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
- HtmlStyle.bar, headerContent);
- header.addContent(heading);
+ if (!headerContent.isEmpty()) {
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
+ HtmlStyle.bar, headerContent);
+ header.addContent(heading);
+ packageListHeading = Headings.IndexFrames.PACKAGE_HEADING;
+ } else {
+ packageListHeading = Headings.PAGE_TITLE_HEADING;
+ }
}
/**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -27,7 +27,6 @@
import javax.lang.model.element.PackageElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -101,7 +100,7 @@
HtmlTree mainTree = HtmlTree.MAIN();
Content headContent = contents.getContent("doclet.Hierarchy_For_Package",
utils.getPackageName(packageElement));
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false,
HtmlStyle.title, headContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
if (configuration.packages.size() > 1) {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -34,7 +34,6 @@
import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -251,7 +250,7 @@
headContent.addContent(contents.getContent("doclet.ClassUse_Title", packageText));
headContent.addContent(new HtmlTree(HtmlTag.BR));
headContent.addContent(name);
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, headContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
mainTree.addContent(div);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -36,7 +36,6 @@
import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -129,7 +128,7 @@
Content annotationContent = new HtmlTree(HtmlTag.P);
addAnnotationInfo(packageElement, annotationContent);
div.addContent(annotationContent);
- Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ Content tHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, contents.packageLabel);
tHeading.addContent(Contents.SPACE);
Content packageHead = new StringContent(heading);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,6 @@
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -68,7 +67,7 @@
*/
@Override
public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) {
- memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY);
+ memberSummaryTree.addContent(MarkerComments.START_OF_PROPERTY_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, typeElement, memberTree);
return memberTree;
@@ -88,10 +87,10 @@
@Override
public Content getPropertyDetailsTreeHeader(TypeElement typeElement,
Content memberDetailsTree) {
- memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS);
+ memberDetailsTree.addContent(MarkerComments.START_OF_PROPERTY_DETAILS);
Content propertyDetailsTree = writer.getMemberTreeHeader();
propertyDetailsTree.addContent(links.createAnchor(SectionName.PROPERTY_DETAIL));
- Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING,
contents.propertyDetailsLabel);
propertyDetailsTree.addContent(heading);
return propertyDetailsTree;
@@ -105,7 +104,7 @@
Content propertyDetailsTree) {
propertyDetailsTree.addContent(links.createAnchor(name(property)));
Content propertyDocTree = writer.getMemberTreeHeader();
- Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING);
heading.addContent(utils.getPropertyLabel(name(property)));
propertyDocTree.addContent(heading);
return propertyDocTree;
@@ -200,7 +199,7 @@
*/
@Override
public void addSummaryLabel(Content memberTree) {
- Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING,
contents.propertySummaryLabel);
memberTree.addContent(label);
}
@@ -261,7 +260,7 @@
? resources.getText("doclet.Properties_Inherited_From_Class")
: resources.getText("doclet.Properties_Inherited_From_Interface"));
}
- Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
+ Content labelHeading = HtmlTree.HEADING(Headings.TypeDeclaration.INHERITED_SUMMARY_HEADING,
label);
labelHeading.addContent(Contents.SPACE);
labelHeading.addContent(classLink);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,7 +29,6 @@
import javax.lang.model.element.TypeElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -42,7 +41,7 @@
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
/**
- * Generate the Serialized Form Information Page.
+ * Generates the Serialized Form Information Page, <i>serialized-form.html</i>.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
@@ -86,7 +85,7 @@
htmlTree.addContent(navBar.getContent(true));
bodyTree.addContent(htmlTree);
Content h1Content = new StringContent(header);
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
HtmlStyle.title, h1Content);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
mainTree.addContent(div);
@@ -120,7 +119,7 @@
* @return a content tree for the package header
*/
public Content getPackageHeader(String packageName) {
- Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
+ Content heading = HtmlTree.HEADING(Headings.SerializedForm.PACKAGE_HEADING, true,
contents.packageLabel);
heading.addContent(Contents.SPACE);
heading.addContent(packageName);
@@ -173,8 +172,7 @@
contents.getContent(
"doclet.Class_0_extends_implements_serializable", classLink,
superClassLink);
- li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
- className));
+ li.addContent(HtmlTree.HEADING(Headings.SerializedForm.CLASS_HEADING, className));
return li;
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -93,11 +93,15 @@
protected void generateIndexFile() throws DocFileIOException {
String title = resources.getText("doclet.Window_Single_Index");
HtmlTree body = getBody(true, getWindowTitle(title));
- HtmlTree htmlTree = HtmlTree.HEADER();
- addTop(htmlTree);
+ HtmlTree header = HtmlTree.HEADER();
+ addTop(header);
navBar.setUserHeader(getUserHeaderFooter(true));
- htmlTree.addContent(navBar.getContent(true));
- body.addContent(htmlTree);
+ header.addContent(navBar.getContent(true));
+ body.addContent(header);
+ HtmlTree main = HtmlTree.MAIN();
+ main.addContent(HtmlTree.DIV(HtmlStyle.header,
+ HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
+ contents.getContent("doclet.Index"))));
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
divTree.setStyle(HtmlStyle.contentContainer);
elements = new TreeSet<>(indexbuilder.getIndexMap().keySet());
@@ -114,12 +118,13 @@
}
}
addLinksForIndexes(divTree);
- body.addContent(HtmlTree.MAIN(divTree));
- htmlTree = HtmlTree.FOOTER();
+ main.addContent(divTree);
+ body.addContent(main);
+ HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
- htmlTree.addContent(navBar.getContent(false));
- addBottom(htmlTree);
- body.addContent(htmlTree);
+ footer.addContent(navBar.getContent(false));
+ addBottom(footer);
+ body.addContent(footer);
createSearchIndexFiles();
printHtmlDocument(null, "index", body);
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java Sat Mar 09 12:54:20 2019 +0000
@@ -37,6 +37,7 @@
import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.internal.doclets.formats.html.markup.DocType;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -264,7 +265,7 @@
* @return the header content for the HTML file
*/
private static Content getHeader() {
- return new HtmlTree(HtmlTag.BODY);
+ return new HtmlTree(HtmlTag.BODY).addAttr(HtmlAttr.CLASS, "source");
}
/**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -126,6 +126,10 @@
navBar.setUserHeader(getUserHeaderFooter(true));
header.addContent(navBar.getContent(true));
body.addContent(header);
+ HtmlTree main = HtmlTree.MAIN();
+ main.addContent(HtmlTree.DIV(HtmlStyle.header,
+ HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
+ contents.getContent("doclet.Index"))));
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
divTree.setStyle(HtmlStyle.contentContainer);
addLinksForIndexes(divTree);
@@ -138,7 +142,8 @@
configuration.tagSearchIndexMap.get(unicode), divTree);
}
addLinksForIndexes(divTree);
- body.addContent(HtmlTree.MAIN(divTree));
+ main.addContent(divTree);
+ body.addContent(main);
HtmlTree footer = HtmlTree.FOOTER();
navBar.setUserFooter(getUserHeaderFooter(false));
footer.addContent(navBar.getContent(false));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java Sat Mar 09 12:54:20 2019 +0000
@@ -29,7 +29,6 @@
import javax.lang.model.element.PackageElement;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -108,7 +107,7 @@
public void generateTreeFile() throws DocFileIOException {
HtmlTree body = getTreeHeader();
Content headContent = contents.hierarchyForAllPackages;
- Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
+ Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false,
HtmlStyle.title, headContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
addPackageTreeLinks(div);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlConstants.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,252 +0,0 @@
-/*
- * Copyright (c) 2010, 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 jdk.javadoc.internal.doclets.formats.html.markup;
-
-import jdk.javadoc.internal.doclets.toolkit.Content;
-
-/**
- * Stores constants for Html Doclet.
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.</b>
- *
- * @author Bhavesh Patel
- */
-public class HtmlConstants {
-
- /**
- * Marker to identify start of top navigation bar.
- */
- public static final Content START_OF_TOP_NAVBAR =
- new Comment("========= START OF TOP NAVBAR =======");
-
- /**
- * Marker to identify start of bottom navigation bar.
- */
- public static final Content START_OF_BOTTOM_NAVBAR =
- new Comment("======= START OF BOTTOM NAVBAR ======");
-
- /**
- * Marker to identify end of top navigation bar.
- */
- public static final Content END_OF_TOP_NAVBAR =
- new Comment("========= END OF TOP NAVBAR =========");
-
- /**
- * Marker to identify end of bottom navigation bar.
- */
- public static final Content END_OF_BOTTOM_NAVBAR =
- new Comment("======== END OF BOTTOM NAVBAR =======");
-
- /**
- * Marker to identify start of module description.
- */
- public static final Content START_OF_MODULE_DESCRIPTION =
- new Comment("============ MODULE DESCRIPTION ===========");
-
- /**
- * Marker to identify start of modules summary.
- */
- public static final Content START_OF_MODULES_SUMMARY =
- new Comment("============ MODULES SUMMARY ===========");
-
- /**
- * Marker to identify start of packages summary.
- */
- public static final Content START_OF_PACKAGES_SUMMARY =
- new Comment("============ PACKAGES SUMMARY ===========");
-
- /**
- * Marker to identify start of services summary.
- */
- public static final Content START_OF_SERVICES_SUMMARY =
- new Comment("============ SERVICES SUMMARY ===========");
-
- /**
- * Marker to identify start of class data.
- */
- public static final Content START_OF_CLASS_DATA =
- new Comment("======== START OF CLASS DATA ========");
-
- /**
- * Marker to identify end of class data.
- */
- public static final Content END_OF_CLASS_DATA =
- new Comment("========= END OF CLASS DATA =========");
-
- /**
- * Marker to identify start of nested class summary.
- */
- public static final Content START_OF_NESTED_CLASS_SUMMARY =
- new Comment("======== NESTED CLASS SUMMARY ========");
-
- /**
- * Marker to identify start of annotation type optional member summary.
- */
- public static final Content START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY =
- new Comment("=========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY ===========");
-
- /**
- * Marker to identify start of annotation type required member summary.
- */
- public static final Content START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY =
- new Comment("=========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY ===========");
-
- /**
- * Marker to identify start of annotation type required member summary.
- */
- public static final Content START_OF_ANNOTATION_TYPE_FIELD_SUMMARY =
- new Comment("=========== ANNOTATION TYPE FIELD SUMMARY ===========");
-
- /**
- * Marker to identify start of constructor summary.
- */
- public static final Content START_OF_CONSTRUCTOR_SUMMARY =
- new Comment("======== CONSTRUCTOR SUMMARY ========");
-
- /**
- * Marker to identify start of enum constants summary.
- */
- public static final Content START_OF_ENUM_CONSTANT_SUMMARY =
- new Comment("=========== ENUM CONSTANT SUMMARY ===========");
-
- /**
- * Marker to identify start of field summary.
- */
- public static final Content START_OF_FIELD_SUMMARY =
- new Comment("=========== FIELD SUMMARY ===========");
-
- /**
- * Marker to identify start of properties summary.
- */
- public static final Content START_OF_PROPERTY_SUMMARY =
- new Comment("=========== PROPERTY SUMMARY ===========");
-
- /**
- * Marker to identify start of method summary.
- */
- public static final Content START_OF_METHOD_SUMMARY =
- new Comment("========== METHOD SUMMARY ===========");
-
- /**
- * Marker to identify start of annotation type details.
- */
- public static final Content START_OF_ANNOTATION_TYPE_DETAILS =
- new Comment("============ ANNOTATION TYPE MEMBER DETAIL ===========");
-
- /**
- * Marker to identify start of annotation type field details.
- */
- public static final Content START_OF_ANNOTATION_TYPE_FIELD_DETAILS =
- new Comment("============ ANNOTATION TYPE FIELD DETAIL ===========");
-
- /**
- * Marker to identify start of method details.
- */
- public static final Content START_OF_METHOD_DETAILS =
- new Comment("============ METHOD DETAIL ==========");
-
- /**
- * Marker to identify start of field details.
- */
- public static final Content START_OF_FIELD_DETAILS =
- new Comment("============ FIELD DETAIL ===========");
-
- /**
- * Marker to identify start of property details.
- */
- public static final Content START_OF_PROPERTY_DETAILS =
- new Comment("============ PROPERTY DETAIL ===========");
-
- /**
- * Marker to identify start of constructor details.
- */
- public static final Content START_OF_CONSTRUCTOR_DETAILS =
- new Comment("========= CONSTRUCTOR DETAIL ========");
-
- /**
- * Marker to identify start of enum constants details.
- */
- public static final Content START_OF_ENUM_CONSTANT_DETAILS =
- new Comment("============ ENUM CONSTANT DETAIL ===========");
-
- /**
- * Html tag for the page title heading.
- */
- public static final HtmlTag TITLE_HEADING = HtmlTag.H1;
-
- /**
- * Html tag for the class page title heading.
- */
- public static final HtmlTag CLASS_PAGE_HEADING = HtmlTag.H2;
-
- /**
- * Html tag for the content heading.
- */
- public static final HtmlTag CONTENT_HEADING = HtmlTag.H2;
-
- /**
- * Html tag for the package name heading.
- */
- public static final HtmlTag PACKAGE_HEADING = HtmlTag.H2;
-
- /**
- * Html tag for the module name heading.
- */
- public static final HtmlTag MODULE_HEADING = HtmlTag.H2;
-
- /**
- * Html tag for the member summary heading.
- */
- public static final HtmlTag SUMMARY_HEADING = HtmlTag.H3;
-
- /**
- * Html tag for the inherited member summary heading.
- */
- public static final HtmlTag INHERITED_SUMMARY_HEADING = HtmlTag.H3;
-
- /**
- * Html tag for the member details heading.
- */
- public static final HtmlTag DETAILS_HEADING = HtmlTag.H3;
-
- /**
- * Html tag for the serialized member heading.
- */
- public static final HtmlTag SERIALIZED_MEMBER_HEADING = HtmlTag.H3;
-
- /**
- * Html tag for the member heading.
- */
- public static final HtmlTag MEMBER_HEADING = HtmlTag.H4;
-
- /**
- * Default charset for HTML.
- */
- public static final String HTML_DEFAULT_CHARSET = "utf-8";
-}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,7 @@
import jdk.javadoc.internal.doclets.formats.html.AbstractMemberWriter;
import jdk.javadoc.internal.doclets.formats.html.Contents;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
+import jdk.javadoc.internal.doclets.formats.html.MarkerComments;
import jdk.javadoc.internal.doclets.formats.html.SectionName;
import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder;
@@ -106,8 +107,8 @@
}
enum Position {
- BOTTOM(HtmlConstants.START_OF_BOTTOM_NAVBAR, HtmlConstants.END_OF_BOTTOM_NAVBAR),
- TOP(HtmlConstants.START_OF_TOP_NAVBAR, HtmlConstants.END_OF_TOP_NAVBAR);
+ BOTTOM(MarkerComments.START_OF_BOTTOM_NAVBAR, MarkerComments.END_OF_BOTTOM_NAVBAR),
+ TOP(MarkerComments.START_OF_TOP_NAVBAR, MarkerComments.END_OF_TOP_NAVBAR);
final Content startOfNav;
final Content endOfNav;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -304,8 +304,8 @@
Content noCustomizationMsg = methodWriter.getNoCustomizationMsg(
resources.getText("doclet.Serializable_no_customization"));
classContentTree.addContent(methodWriter.getSerializableMethods(
- resources.getText("doclet.Serialized_Form_methods"),
- noCustomizationMsg));
+ resources.getText("doclet.Serialized_Form_methods"),
+ noCustomizationMsg));
}
}
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Sat Mar 09 12:54:20 2019 +0000
@@ -296,25 +296,32 @@
/*
* Styles for headings.
*/
-div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
+div.details ul.blockList ul.blockList ul.blockList li.blockList h3,
+div.details ul.blockList ul.blockList ul.blockListLast li.blockList h3,
+div.serializedFormContainer ul.blockList ul.blockList ul.blockList li.blockList h4 {
background-color:#dee3e9;
border:1px solid #d0d9e0;
margin:0 0 6px -8px;
padding:7px 5px;
}
-ul.blockList ul.blockList ul.blockList li.blockList h3 {
+div.details h2,
+div.summary h2 {
+ font-style: italic;
+}
+div.details h3,
+div.summary h3 {
+ font-style: normal;
+}
+ul.blockList ul.blockList ul.blockList li.blockList h2 {
background-color:#dee3e9;
border:1px solid #d0d9e0;
margin:0 0 6px -8px;
padding:7px 5px;
}
-ul.blockList ul.blockList li.blockList h3 {
+ul.blockList ul.blockList li.blockList h2 {
padding:0;
margin:15px 0;
}
-ul.blockList li.blockList h2 {
- padding:0px 0 20px 0;
-}
/*
* Styles for page layout containers.
*/
@@ -597,7 +604,8 @@
.docSummary {
padding:0;
}
-ul.blockList ul.blockList ul.blockList li.blockList h3 {
+ul.blockList ul.blockList ul.blockList li.blockList h3,
+ul.blockList ul.blockList ul.blockListLast li.blockList h3 {
font-style:normal;
}
div.block {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java Sat Mar 09 12:54:20 2019 +0000
@@ -197,9 +197,11 @@
}
// Parse the files in the packages and subpackages to be documented
- ListBuffer<JCCompilationUnit> packageTrees = new ListBuffer<>();
- parse(etable.getFilesToParse(), packageTrees, false);
- modules.enter(packageTrees.toList(), null);
+ ListBuffer<JCCompilationUnit> allTrees = new ListBuffer<>();
+ allTrees.addAll(classTrees);
+ parse(etable.getFilesToParse(), allTrees, false);
+ modules.newRound();
+ modules.initModules(allTrees.toList());
if (messager.hasErrors()) {
return null;
@@ -207,7 +209,7 @@
// Enter symbols for all files
toolEnv.notice("main.Building_tree");
- javadocEnter.main(classTrees.toList().appendList(packageTrees));
+ javadocEnter.main(allTrees.toList());
if (messager.hasErrors()) {
return null;
--- a/src/jdk.javadoc/share/legal/jszip.md Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.javadoc/share/legal/jszip.md Sat Mar 09 12:54:20 2019 +0000
@@ -23,4 +23,36 @@
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************
+
+The JSZip JavaScript Library v3.1.5 also includes pako
+
+pako includes the following license:
+
+
+(The MIT License)
+
+Copyright (C) 2014-2017 by Vitaly Puzrin and Andrei Tuputcyn
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+******************************************
+
</pre>
--- a/src/jdk.jdwp.agent/share/native/libjdwp/log_messages.c Sat Mar 09 12:52:30 2019 +0000
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/log_messages.c Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,12 @@
#define MAXLEN_MESSAGE 256
#define MAXLEN_EXEC (MAXLEN_FILENAME*2+MAXLEN_INTEGER+16)
+#define TIMESTAMP_SIZE (MAXLEN_TIMESTAMP+1)
+#define MAXLEN_DT 19 // "DD.MM.YYYY HH:MM:SS"
+#define MAXLEN_MS 5 // ".mmm "
+#define DT_SIZE (MAXLEN_DT+1)
+#define TZ_SIZE (TIMESTAMP_SIZE-MAXLEN_DT-MAXLEN_MS)
+
static MUTEX_T my_mutex = MUTEX_INIT;
/* Static variables (should be protected with mutex) */
@@ -52,12 +58,14 @@
static PID_T processPid;
static int open_count;
-/* Ascii id of current native thread. */
+/*
+ * "DD.MM.YYYY HH:MM:SS.mmm <TZ>"
+ */
static void
get_time_stamp(char *tbuf, size_t ltbuf)
{
- char timestamp_prefix[MAXLEN_TIMESTAMP+1];
- char timestamp_postfix[MAXLEN_TIMESTAMP+1];
+ char timestamp_date_time[DT_SIZE];
+ char timestamp_timezone[TZ_SIZE];
unsigned millisecs = 0;
time_t t = 0;
@@ -65,15 +73,14 @@
if ( time(&t) == (time_t)(-1) ) {
t = 0;
}
- /* Break this up so that the format strings are string literals
- and we avoid a compiler warning. */
- (void)strftime(timestamp_prefix, sizeof(timestamp_prefix),
+
+ (void)strftime(timestamp_date_time, DT_SIZE,
"%d.%m.%Y %T", localtime(&t));
- (void)strftime(timestamp_postfix, sizeof(timestamp_postfix),
+ (void)strftime(timestamp_timezone, TZ_SIZE,
"%Z", localtime(&t));
(void)snprintf(tbuf, ltbuf,
- "%s.%.3d %s", timestamp_prefix,
- (int)(millisecs), timestamp_postfix);
+ "%s.%.3d %s", timestamp_date_time,
+ (int)(millisecs), timestamp_timezone);
}
/* Get basename of filename */
--- a/test/hotspot/gtest/memory/test_virtualSpaceNode.cpp Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,277 +0,0 @@
-/*
- * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
- * 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 "memory/metaspace/virtualSpaceList.hpp"
-#include "memory/metaspace/chunkManager.hpp"
-#include "runtime/mutexLocker.hpp"
-#include "utilities/formatBuffer.hpp"
-#include "unittest.hpp"
-
-// include as last, or otherwise we pull in an incompatible "assert" macro
-#include <vector>
-
-using namespace metaspace;
-
-namespace {
- static void chunk_up(size_t words_left, size_t& num_medium_chunks,
- size_t& num_small_chunks,
- size_t& num_specialized_chunks) {
- num_medium_chunks = words_left / MediumChunk;
- words_left = words_left % MediumChunk;
-
- num_small_chunks = words_left / SmallChunk;
- words_left = words_left % SmallChunk;
- // how many specialized chunks can we get?
- num_specialized_chunks = words_left / SpecializedChunk;
- ASSERT_EQ(0UL, words_left % SpecializedChunk) << "should be nothing left"
- << ", words_left = " << words_left
- << ", SpecializedChunk = " << SpecializedChunk;
- }
- static const size_t vsn_test_size_words = MediumChunk * 4;
- static const size_t vsn_test_size_bytes = vsn_test_size_words * BytesPerWord;
- class MetachunkRemover {
- Metachunk* const _m;
- ChunkManager* const _c;
- public:
- MetachunkRemover(Metachunk* m, ChunkManager* c) : _m(m), _c(c) { }
- ~MetachunkRemover() { _c->remove_chunk(_m); }
- };
-}
-
-class ChunkManagerTest {
- public:
- static size_t sum_free_chunks(ChunkManager* cm) {
- return cm->sum_free_chunks();
- }
- static size_t sum_free_chunks_count(ChunkManager* cm) {
- return cm->sum_free_chunks_count();
- }
- static ChunkList* free_chunks(ChunkManager* cm, ChunkIndex i) {
- return cm->free_chunks(i);
- }
-};
-
-// removes all the chunks added to the ChunkManager since creation of ChunkManagerRestorer
-class ChunkManagerRestorer {
- metaspace::ChunkManager* const _cm;
- std::vector<metaspace::Metachunk*>* _free_chunks[metaspace::NumberOfFreeLists];
- int _count_pre_existing;
-public:
- ChunkManagerRestorer(metaspace::ChunkManager* cm) : _cm(cm), _count_pre_existing(0) {
- _cm->locked_verify();
- for (metaspace::ChunkIndex i = metaspace::ZeroIndex; i < metaspace::NumberOfFreeLists; i = next_chunk_index(i)) {
- metaspace::ChunkList* l = ChunkManagerTest::free_chunks(_cm, i);
- _count_pre_existing += l->count();
- std::vector<metaspace::Metachunk*> *v = new std::vector<metaspace::Metachunk*>(l->count());
- metaspace::Metachunk* c = l->head();
- while (c) {
- v->push_back(c);
- c = c->next();
- }
- _free_chunks[i] = v;
- }
- }
- ~ChunkManagerRestorer() {
- _cm->locked_verify();
- for (metaspace::ChunkIndex i = metaspace::ZeroIndex; i < metaspace::NumberOfFreeLists; i = next_chunk_index(i)) {
- metaspace::ChunkList* l = ChunkManagerTest::free_chunks(_cm, i);
- std::vector<metaspace::Metachunk*> *v = _free_chunks[i];
- ssize_t count = l->count();
- for (ssize_t j = 0; j < count; j++) {
- metaspace::Metachunk* c = l->head();
- while (c) {
- bool found = false;
- for (size_t k = 0; k < v->size() && !found; k++) {
- found = (c == v->at(k));
- }
- if (found) {
- c = c->next();
- } else {
- _cm->remove_chunk(c);
- break;
- }
- }
- }
- delete _free_chunks[i];
- _free_chunks[i] = NULL;
- }
- int count_after_cleanup = 0;
- for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) {
- ChunkList* l = ChunkManagerTest::free_chunks(_cm, i);
- count_after_cleanup += l->count();
- }
- EXPECT_EQ(_count_pre_existing, count_after_cleanup);
- _cm->locked_verify();
- }
-};
-
-TEST_VM(VirtualSpaceNodeTest, sanity) {
- // The chunk sizes must be multiples of eachother, or this will fail
- STATIC_ASSERT(MediumChunk % SmallChunk == 0);
- STATIC_ASSERT(SmallChunk % SpecializedChunk == 0);
-
- // just in case STATIC_ASSERT doesn't work
- EXPECT_EQ(0, MediumChunk % SmallChunk);
- EXPECT_EQ(0, SmallChunk % SpecializedChunk);
-}
-
-TEST_VM(VirtualSpaceNodeTest, four_pages_vsn_is_committed_some_is_used_by_chunks) {
- const size_t page_chunks = 4 * (size_t)os::vm_page_size() / BytesPerWord;
- if (page_chunks >= MediumChunk) {
- SUCCEED() << "SKIP: This doesn't work for systems with vm_page_size >= 16K";
- return;
- }
- MutexLockerEx ml(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
- ChunkManager cm(false);
- VirtualSpaceNode vsn(false, vsn_test_size_bytes);
- ChunkManagerRestorer c(Metaspace::get_chunk_manager(false));
-
- vsn.initialize();
- EXPECT_TRUE(vsn.expand_by(page_chunks, page_chunks));
- vsn.get_chunk_vs(SmallChunk);
- vsn.get_chunk_vs(SpecializedChunk);
- vsn.retire(&cm);
-
- // committed - used = words left to retire
- const size_t words_left = page_chunks - SmallChunk - SpecializedChunk;
- size_t num_medium_chunks, num_small_chunks, num_spec_chunks;
- chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks);
-
- EXPECT_EQ(0UL, num_medium_chunks) << "should not get any medium chunks";
- // DISABLED: checks started to fail after 8198423
- // EXPECT_EQ((num_small_chunks + num_spec_chunks), ChunkManagerTest::sum_free_chunks_count(&cm)) << "should be space for 3 chunks";
- // EXPECT_EQ(words_left, ChunkManagerTest::sum_free_chunks(&cm)) << "sizes should add up";
-}
-
-TEST_VM(VirtualSpaceNodeTest, half_vsn_is_committed_humongous_chunk_is_used) {
- MutexLockerEx ml(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
- ChunkManager cm(false);
- VirtualSpaceNode vsn(false, vsn_test_size_bytes);
- ChunkManagerRestorer c(Metaspace::get_chunk_manager(false));
-
- vsn.initialize();
- EXPECT_TRUE(vsn.expand_by(MediumChunk * 2, MediumChunk * 2));
- // Humongous chunks will be aligned up to MediumChunk + SpecializedChunk
- vsn.get_chunk_vs(MediumChunk + SpecializedChunk);
- vsn.retire(&cm);
-
- const size_t words_left = MediumChunk * 2 - (MediumChunk + SpecializedChunk);
- size_t num_medium_chunks, num_small_chunks, num_spec_chunks;
- ASSERT_NO_FATAL_FAILURE(chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks));
-
- EXPECT_EQ(0UL, num_medium_chunks) << "should not get any medium chunks";
- // DISABLED: checks started to fail after 8198423
- // EXPECT_EQ((num_small_chunks + num_spec_chunks), ChunkManagerTest::sum_free_chunks_count(&cm)) << "should be space for 3 chunks";
- // EXPECT_EQ(words_left, ChunkManagerTest::sum_free_chunks(&cm)) << "sizes should add up";
-}
-
-TEST_VM(VirtualSpaceNodeTest, all_vsn_is_committed_half_is_used_by_chunks) {
- MutexLockerEx ml(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
- ChunkManager cm(false);
- VirtualSpaceNode vsn(false, vsn_test_size_bytes);
- ChunkManagerRestorer c(Metaspace::get_chunk_manager(false));
-
- vsn.initialize();
- EXPECT_TRUE(vsn.expand_by(vsn_test_size_words, vsn_test_size_words));
- vsn.get_chunk_vs(MediumChunk);
- vsn.get_chunk_vs(MediumChunk);
- vsn.retire(&cm);
-
- // DISABLED: checks started to fail after 8198423
- // EXPECT_EQ(2UL, ChunkManagerTest::sum_free_chunks_count(&cm)) << "should have been memory left for 2 chunks";
- // EXPECT_EQ(2UL * MediumChunk, ChunkManagerTest::sum_free_chunks(&cm)) << "sizes should add up";
-}
-
-TEST_VM(VirtualSpaceNodeTest, no_committed_memory) {
- MutexLockerEx ml(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
- ChunkManager cm(false);
- VirtualSpaceNode vsn(false, vsn_test_size_bytes);
- ChunkManagerRestorer c(Metaspace::get_chunk_manager(false));
-
- vsn.initialize();
- vsn.retire(&cm);
-
- ASSERT_EQ(0UL, ChunkManagerTest::sum_free_chunks_count(&cm)) << "did not commit any memory in the VSN";
-}
-
-TEST_VM(VirtualSpaceNodeTest, is_available_positive) {
- // Reserve some memory.
- VirtualSpaceNode vsn(false, os::vm_allocation_granularity());
- ASSERT_TRUE(vsn.initialize()) << "Failed to setup VirtualSpaceNode";
-
- // Commit some memory.
- size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord;
- ASSERT_TRUE(vsn.expand_by(commit_word_size, commit_word_size))
- << "Failed to commit, commit_word_size = " << commit_word_size;
-
- SCOPED_TRACE(err_msg("VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")",
- p2i(vsn.bottom()), p2i(vsn.end())).buffer());
-
- // Check that is_available accepts the committed size.
- EXPECT_TRUE(vsn.is_available(commit_word_size)) << " commit_word_size = " << commit_word_size;
-
- // Check that is_available accepts half the committed size.
- size_t expand_word_size = commit_word_size / 2;
- EXPECT_TRUE(vsn.is_available(expand_word_size)) << " expand_word_size = " << expand_word_size;
-}
-
-TEST_VM(VirtualSpaceNodeTest, is_available_negative) {
- // Reserve some memory.
- VirtualSpaceNode vsn(false, os::vm_allocation_granularity());
- ASSERT_TRUE(vsn.initialize()) << "Failed to setup VirtualSpaceNode";
-
- // Commit some memory.
- size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord;
- ASSERT_TRUE(vsn.expand_by(commit_word_size, commit_word_size))
- << "Failed to commit, commit_word_size = " << commit_word_size;
-
- SCOPED_TRACE(err_msg("VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")",
- p2i(vsn.bottom()), p2i(vsn.end())).buffer());
-
- // Check that is_available doesn't accept a too large size.
- size_t two_times_commit_word_size = commit_word_size * 2;
- EXPECT_FALSE(vsn.is_available(two_times_commit_word_size)) << " two_times_commit_word_size = " << two_times_commit_word_size;
-}
-
-TEST_VM(VirtualSpaceNodeTest, is_available_overflow) {
- // Reserve some memory.
- VirtualSpaceNode vsn(false, os::vm_allocation_granularity());
- ASSERT_TRUE(vsn.initialize()) << "Failed to setup VirtualSpaceNode";
-
- // Commit some memory.
- size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord;
- ASSERT_TRUE(vsn.expand_by(commit_word_size, commit_word_size))
- << "Failed to commit, commit_word_size = " << commit_word_size;
-
- SCOPED_TRACE(err_msg("VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")",
- p2i(vsn.bottom()), p2i(vsn.end())).buffer());
-
- // Calculate a size that will overflow the virtual space size.
- void* virtual_space_max = (void*)(uintptr_t)-1;
- size_t bottom_to_max = pointer_delta(virtual_space_max, vsn.bottom(), 1);
- size_t overflow_size = bottom_to_max + BytesPerWord;
- size_t overflow_word_size = overflow_size / BytesPerWord;
-
- EXPECT_FALSE(vsn.is_available(overflow_word_size)) << " overflow_word_size = " << overflow_word_size;
-}
--- a/test/hotspot/gtest/runtime/test_os.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/gtest/runtime/test_os.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -153,28 +153,81 @@
}
#endif
-TEST(os, test_print_hex_dump) {
+static void do_test_print_hex_dump(address addr, size_t len, int unitsize, const char* expected) {
+ char buf[256];
+ buf[0] = '\0';
+ stringStream ss(buf, sizeof(buf));
+ os::print_hex_dump(&ss, addr, addr + len, unitsize);
+// tty->print_cr("expected: %s", expected);
+// tty->print_cr("result: %s", buf);
+ ASSERT_NE(strstr(buf, expected), (char*)NULL);
+}
+
+TEST_VM(os, test_print_hex_dump) {
+ const char* pattern [4] = {
+#ifdef VM_LITTLE_ENDIAN
+ "00 01 02 03 04 05 06 07",
+ "0100 0302 0504 0706",
+ "03020100 07060504",
+ "0706050403020100"
+#else
+ "00 01 02 03 04 05 06 07",
+ "0001 0203 0405 0607",
+ "00010203 04050607",
+ "0001020304050607"
+#endif
+ };
+
+ const char* pattern_not_readable [4] = {
+ "?? ?? ?? ?? ?? ?? ?? ??",
+ "???? ???? ???? ????",
+ "???????? ????????",
+ "????????????????"
+ };
+
+ // On AIX, zero page is readable.
+ address unreadable =
+#ifdef AIX
+ (address) 0xFFFFFFFFFFFF0000ULL;
+#else
+ (address) 0
+#endif
+ ;
+
ResourceMark rm;
- stringStream ss;
+ char buf[64];
+ stringStream ss(buf, sizeof(buf));
outputStream* out = &ss;
// outputStream* out = tty; // enable for printout
- // Test dumping unreadable memory does not fail
- os::print_hex_dump(out, (address)0, (address)100, 1);
- os::print_hex_dump(out, (address)0, (address)100, 2);
- os::print_hex_dump(out, (address)0, (address)100, 4);
- os::print_hex_dump(out, (address)0, (address)100, 8);
+ // Test dumping unreadable memory
+ // Exclude test for Windows for now, since it needs SEH handling to work which cannot be
+ // guaranteed when we call directly into VM code. (see JDK-8220220)
+#ifndef _WIN32
+ do_test_print_hex_dump(unreadable, 100, 1, pattern_not_readable[0]);
+ do_test_print_hex_dump(unreadable, 100, 2, pattern_not_readable[1]);
+ do_test_print_hex_dump(unreadable, 100, 4, pattern_not_readable[2]);
+ do_test_print_hex_dump(unreadable, 100, 8, pattern_not_readable[3]);
+#endif
- // Test dumping readable memory does not fail
- char arr[100];
+ // Test dumping readable memory
+ address arr = (address)os::malloc(100, mtInternal);
for (int c = 0; c < 100; c++) {
arr[c] = c;
}
- address addr = (address)&arr;
- os::print_hex_dump(out, addr, addr + 100, 1);
- os::print_hex_dump(out, addr, addr + 100, 2);
- os::print_hex_dump(out, addr, addr + 100, 4);
- os::print_hex_dump(out, addr, addr + 100, 8);
+
+ // properly aligned
+ do_test_print_hex_dump(arr, 100, 1, pattern[0]);
+ do_test_print_hex_dump(arr, 100, 2, pattern[1]);
+ do_test_print_hex_dump(arr, 100, 4, pattern[2]);
+ do_test_print_hex_dump(arr, 100, 8, pattern[3]);
+
+ // Not properly aligned. Should automatically down-align by unitsize
+ do_test_print_hex_dump(arr + 1, 100, 2, pattern[1]);
+ do_test_print_hex_dump(arr + 1, 100, 4, pattern[2]);
+ do_test_print_hex_dump(arr + 1, 100, 8, pattern[3]);
+
+ os::free(arr);
}
//////////////////////////////////////////////////////////////////////////////
--- a/test/hotspot/jtreg/ProblemList.txt Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/ProblemList.txt Sat Mar 09 12:54:20 2019 +0000
@@ -157,8 +157,6 @@
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005/TestDescription.java 8153598 generic-all
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestDescription.java 8060733 generic-all
-vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended002/TestDescription.java 4903717 generic-all
-vmTestbase/nsk/jdi/ThreadReference/resume/resume001/TestDescription.java 8072701 generic-all
vmTestbase/nsk/jdi/ThreadReference/stop/stop001/TestDescription.java 7034630 generic-all
vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001/TestDescription.java 8013728 generic-all
vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003/TestDescription.java 8066993 generic-all
--- a/test/hotspot/jtreg/TEST.groups Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/TEST.groups Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -265,6 +265,7 @@
-runtime/7158988/FieldMonitor.java \
-runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \
-runtime/CommandLine/PrintGCApplicationConcurrentTime.java \
+ -runtime/CompressedOops/UseCompressedOops.java \
-runtime/ConstantPool/IntfMethod.java \
-runtime/ErrorHandling/CreateCoredumpOnCrash.java \
-runtime/ErrorHandling/ErrorHandler.java \
@@ -346,6 +347,7 @@
runtime/ \
serviceability/ \
-runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \
+ -runtime/CompressedOops/UseCompressedOops.java \
-runtime/Thread/TestThreadDumpMonitorContention.java \
-runtime/containers/ \
-:tier1_runtime \
--- a/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java Sat Mar 09 12:54:20 2019 +0000
@@ -294,7 +294,7 @@
try {
String cmd = ProcessTools.getCommandLine(ProcessTools.createJavaProcessBuilder(true, args));
return new String[]{"sh", "-c", prefix
- + (Platform.isWindows() ? cmd.replace('\\', '/').replace(";", "\\;") : cmd)};
+ + (Platform.isWindows() ? cmd.replace('\\', '/').replace(";", "\\;").replace("|", "\\|") : cmd)};
} catch(Throwable t) {
throw new Error("Can't create process builder: " + t, t);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 TestOverloadCompileQueues
+ * @bug 8163511
+ * @summary Test overloading the C1 and C2 compile queues with tasks.
+ * @run main/othervm -XX:-TieredCompilation -XX:CompileThreshold=2 -XX:CICompilerCount=1
+ * compiler.classUnloading.methodUnloading.TestOverloadCompileQueues
+ * @run main/othervm -XX:TieredCompileTaskTimeout=1000 -XX:CompileThresholdScaling=0.001 -XX:CICompilerCount=2
+ * compiler.classUnloading.methodUnloading.TestOverloadCompileQueues
+ */
+
+package compiler.classUnloading.methodUnloading;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+public class TestOverloadCompileQueues {
+ public static final int ITERS = 500; // Increase for longer stress testing
+
+ // Some methods to fill up the compile queue
+ public static void test0() { }
+ public static void test1() { }
+ public static void test2() { }
+ public static void test3() { }
+ public static void test4() { }
+ public static void test5() { }
+ public static void test6() { }
+ public static void test7() { }
+ public static void test8() { }
+ public static void test9() { }
+ public static void test10() { }
+ public static void test11() { }
+ public static void test12() { }
+ public static void test13() { }
+ public static void test14() { }
+ public static void test15() { }
+ public static void test16() { }
+ public static void test17() { }
+ public static void test18() { }
+ public static void test19() { }
+
+ public static void main(String[] args) throws Throwable {
+ Class<?> thisClass = TestOverloadCompileQueues.class;
+ ClassLoader defaultLoader = thisClass.getClassLoader();
+ URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation();
+
+ for (int i = 0; i < ITERS; ++i) {
+ // Load test class with own class loader
+ URLClassLoader myLoader = URLClassLoader.newInstance(new URL[] {classesDir}, defaultLoader.getParent());
+ Class<?> testClass = Class.forName(thisClass.getCanonicalName(), true, myLoader);
+
+ // Execute all test methods to trigger compilation and fill up compile queue
+ for (int j = 1; j < 20; ++j) {
+ Method method = testClass.getDeclaredMethod("test" + j);
+ method.invoke(null);
+ method.invoke(null);
+ }
+
+ // Unload dead classes from ealier iterations
+ System.gc();
+ }
+ }
+}
--- a/test/hotspot/jtreg/compiler/codegen/aes/TestCipherBlockChainingEncrypt.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/compiler/codegen/aes/TestCipherBlockChainingEncrypt.java Sat Mar 09 12:54:20 2019 +0000
@@ -25,7 +25,12 @@
* @test
* @bug 8209951
* @summary SIGBUS in com.sun.crypto.provider.CipherBlockChaining
- * @run main/othervm/timeout=300 -Xbatch
+ * @library /test/lib /
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
+ *
+ * @run main/othervm -Xbatch
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
* compiler.codegen.aes.TestCipherBlockChainingEncrypt
*/
@@ -40,6 +45,10 @@
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
+import compiler.whitebox.CompilerWhiteBoxTest;
+import sun.hotspot.code.Compiler;
+import jtreg.SkippedException;
+
public class TestCipherBlockChainingEncrypt {
private static String algorithm = "PBEWithHmacSHA1AndAES_256";
private static final String PBEPASS = "Hush, it's supposed to be a secret!";
@@ -53,8 +62,11 @@
private static Cipher ci;
public static void main(String[] args) throws Exception {
- for(int i=0; i<5_000; i++) {
- if (!(new TestCipherBlockChainingEncrypt().test(args))) {
+ if (!Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.CipherBlockChaining", "implEncrypt", byte[].class, int.class, int.class, byte[].class, int.class)) {
+ throw new SkippedException("Base64 intrinsic is not available");
+ }
+ for(int i=0; i<2_000; i++) {
+ if (!(new TestCipherBlockChainingEncrypt().test(args))) {
throw new RuntimeException("TestCipherBlockChainingEncrypt test failed");
}
}
--- a/test/hotspot/jtreg/compiler/intrinsics/math/TestFpMinMaxIntrinsics.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/compiler/intrinsics/math/TestFpMinMaxIntrinsics.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Arm Limited. All rights reserved.
* 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,20 +27,41 @@
* @bug 8212043
* @summary Test compiler intrinsics of floating-point Math.min/max
*
- * @run main/othervm -Xint compiler.intrinsics.math.TestFpMinMaxIntrinsics
+ * @run main/othervm -Xint compiler.intrinsics.math.TestFpMinMaxIntrinsics sanityTests 1
* @run main/othervm -XX:+UnlockDiagnosticVMOptions
* -Xcomp -XX:TieredStopAtLevel=1
* -XX:CompileOnly=java/lang/Math
- * compiler.intrinsics.math.TestFpMinMaxIntrinsics
+ * compiler.intrinsics.math.TestFpMinMaxIntrinsics sanityTests 1
* @run main/othervm -XX:+UnlockDiagnosticVMOptions
* -Xcomp -XX:-TieredCompilation
* -XX:CompileOnly=java/lang/Math
- * compiler.intrinsics.math.TestFpMinMaxIntrinsics
+ * compiler.intrinsics.math.TestFpMinMaxIntrinsics sanityTests 1
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
+ * -XX:-TieredCompilation -XX:CompileThresholdScaling=0.1
+ * -XX:CompileCommand=print,compiler/intrinsics/math/TestFpMinMaxIntrinsics.*Test*
+ * compiler.intrinsics.math.TestFpMinMaxIntrinsics sanityTests 10000
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
+ * -XX:-TieredCompilation -Xcomp
+ * -XX:CompileCommand=print,compiler/intrinsics/math/TestFpMinMaxIntrinsics.*Test*
+ * -XX:CompileCommand=compileonly,compiler/intrinsics/math/TestFpMinMaxIntrinsics.*Test*
+ * compiler.intrinsics.math.TestFpMinMaxIntrinsics reductionTests 100
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
+ * -XX:+TieredCompilation
+ * -XX:CompileCommand=print,compiler/intrinsics/math/TestFpMinMaxIntrinsics.min*
+ * -XX:CompileCommand=dontinline,compiler/intrinsics/math/TestFpMinMaxIntrinsics.min*
+ * compiler.intrinsics.math.TestFpMinMaxIntrinsics randomSearchTree 1
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
+ * -XX:+TieredCompilation
+ * -XX:CompileCommand=print,compiler/intrinsics/math/TestFpMinMaxIntrinsics.min*
+ * -XX:CompileCommand=dontinline,compiler/intrinsics/math/TestFpMinMaxIntrinsics.min*
+ * compiler.intrinsics.math.TestFpMinMaxIntrinsics sortedSearchTree 1
*/
package compiler.intrinsics.math;
import java.util.Arrays;
+import java.util.Random;
+import java.lang.reflect.Method;
public class TestFpMinMaxIntrinsics {
@@ -63,63 +84,220 @@
private static final float[][] f_cases = {
// a b min max
{ fPos, fPos, fPos, fPos },
+ { fNeg, fNeg, fNeg, fNeg },
{ fPos, fNeg, fNeg, fPos },
+ { fNeg, fPos, fNeg, fPos },
+
{ fPosZero, fNegZero, fNegZero, fPosZero },
+ { fNegZero, fPosZero, fNegZero, fPosZero },
{ fNegZero, fNegZero, fNegZero, fNegZero },
+
{ fPos, fPosInf, fPos, fPosInf },
{ fNeg, fNegInf, fNegInf, fNeg },
+
{ fPos, fNaN, fNaN, fNaN },
+ { fNaN, fPos, fNaN, fNaN },
+ { fNeg, fNaN, fNaN, fNaN },
+ { fNaN, fNeg, fNaN, fNaN },
+
+ { fPosInf, fNaN, fNaN, fNaN },
+ { fNaN, fPosInf, fNaN, fNaN },
{ fNegInf, fNaN, fNaN, fNaN },
+ { fNaN, fNegInf, fNaN, fNaN }
};
private static final double[][] d_cases = {
// a b min max
{ dPos, dPos, dPos, dPos },
+ { dNeg, dNeg, dNeg, dNeg },
{ dPos, dNeg, dNeg, dPos },
+ { dNeg, dPos, dNeg, dPos },
+
{ dPosZero, dNegZero, dNegZero, dPosZero },
+ { dNegZero, dPosZero, dNegZero, dPosZero },
{ dNegZero, dNegZero, dNegZero, dNegZero },
+
{ dPos, dPosInf, dPos, dPosInf },
{ dNeg, dNegInf, dNegInf, dNeg },
+
{ dPos, dNaN, dNaN, dNaN },
+ { dNaN, dPos, dNaN, dNaN },
+ { dNeg, dNaN, dNaN, dNaN },
+ { dNaN, dNeg, dNaN, dNaN },
+
+ { dPosInf, dNaN, dNaN, dNaN },
+ { dNaN, dPosInf, dNaN, dNaN },
{ dNegInf, dNaN, dNaN, dNaN },
+ { dNaN, dNegInf, dNaN, dNaN }
};
private static void fTest(float[] row) {
- float min = Math.min(row[0], row[1]);
- float max = Math.max(row[0], row[1]);
- if (Float.isNaN(min) && Float.isNaN(max)
- && Float.isNaN(row[2]) && Float.isNaN(row[3])) {
- // Return if all of them are NaN
- return;
+ fCheck(row[0], row[1], Math.min(row[0], row[1]), Math.max(row[0], row[1]), row[2], row[3]);
+ }
+
+ private static void fReductionTest(float[] row) {
+ float fmin = row[0], fmax = row[0];
+
+ for (int i=0; i<100; i++) {
+ fmin = Math.min(fmin, row[1]);
+ fmax = Math.max(fmax, row[1]);
}
- if (min != row[2] || max != row[3]) {
+
+ fCheck(row[0], row[1], fmin, fmax, row[2], row[3]);
+ }
+
+ private static void fCheck(float a, float b, float fmin, float fmax, float efmin, float efmax) {
+ int min = Float.floatToRawIntBits(fmin);
+ int max = Float.floatToRawIntBits(fmax);
+ int emin = Float.floatToRawIntBits(efmin);
+ int emax = Float.floatToRawIntBits(efmax);
+
+ if (min != emin || max != emax) {
throw new AssertionError("Unexpected result of float min/max: " +
- "a = " + row[0] + ", b = " + row[1] + ", " +
- "result = (" + min + ", " + max + "), " +
- "expected = (" + row[2] + ", " + row[3] + ")");
+ "a = " + a + ", b = " + b + ", " +
+ "result = (" + fmin + ", " + fmax + "), " +
+ "expected = (" + efmin + ", " + efmax + ")");
}
}
private static void dTest(double[] row) {
- double min = Math.min(row[0], row[1]);
- double max = Math.max(row[0], row[1]);
- if (Double.isNaN(min) && Double.isNaN(max)
- && Double.isNaN(row[2]) && Double.isNaN(row[3])) {
- // Return if all of them are NaN
- return;
+ dCheck(row[0], row[1], Math.min(row[0], row[1]), Math.max(row[0], row[1]), row[2], row[3]);
+ }
+
+ private static void dReductionTest(double[] row) {
+ double dmin = row[0], dmax = row[0];
+
+ for (int i=0; i<100; i++) {
+ dmin = Math.min(dmin, row[1]);
+ dmax = Math.max(dmax, row[1]);
}
- if (min != row[2] || max != row[3]) {
- throw new AssertionError("Unexpected result of double min/max" +
- "a = " + row[0] + ", b = " + row[1] + ", " +
- "result = (" + min + ", " + max + "), " +
- "expected = (" + row[2] + ", " + row[3] + ")");
+
+ dCheck(row[0], row[1], dmin, dmax, row[2], row[3]);
+ }
+
+ private static void dCheck(double a, double b, double dmin, double dmax, double edmin, double edmax) {
+ double min = Double.doubleToRawLongBits(dmin);
+ double max = Double.doubleToRawLongBits(dmax);
+ double emin = Double.doubleToRawLongBits(edmin);
+ double emax = Double.doubleToRawLongBits(edmax);
+
+ if (min != emin || max != emax) {
+ throw new AssertionError("Unexpected result of double min/max: " +
+ "a = " + a + ", b = " + b + ", " +
+ "result = (" + dmin + ", " + dmax + "), " +
+ "expected = (" + edmin + ", " + edmax + ")");
}
}
- public static void main(String[] args) {
+ public static void sanityTests() {
Arrays.stream(f_cases).forEach(TestFpMinMaxIntrinsics::fTest);
Arrays.stream(d_cases).forEach(TestFpMinMaxIntrinsics::dTest);
- System.out.println("PASS");
+ }
+
+ public static void reductionTests() {
+ Arrays.stream(f_cases).forEach(TestFpMinMaxIntrinsics::fReductionTest);
+ Arrays.stream(d_cases).forEach(TestFpMinMaxIntrinsics::dReductionTest);
+ }
+
+ public static void main(String[] args) throws Exception {
+ Method m = TestFpMinMaxIntrinsics.class.getDeclaredMethod(args[0]);
+ for (int i = 0 ; i < Integer.parseInt(args[1]) ; i++)
+ m.invoke(null);
+ }
+
+ private static final int COUNT = 1000;
+ private static final int LOOPS = 100;
+
+ private static Random r = new Random();
+
+ private static Node[] pool = new Node[COUNT];
+
+ private static long time = 0;
+ private static long times = 0;
+
+ public static void init() {
+ for (int i=0; i<COUNT; i++)
+ pool[i] = new Node(Double.NaN);
+ }
+
+ public static void finish() {
+ // String sorted = pool[0].toString();
+ // System.out.println("Sorted: {" + sorted.substring(0, Math.min(sorted.length(), 180)) + "... }");
+ System.out.println("Average time: " + (time/times) + " ns");
+ }
+
+ public static void randomSearchTree() {
+ init();
+ for (int l=0; l < LOOPS; l++) {
+ Node root = pool[0].reset(r.nextDouble());
+
+ for (int i=1; i<COUNT; i++)
+ insert(root, pool[i].reset(r.nextDouble()));
+ }
+ finish();
+ }
+
+ public static void sortedSearchTree() {
+ init();
+ for (int l=0; l < LOOPS; l++) {
+ Node root = pool[0].reset(-0.0);
+
+ for (int i=1; i<COUNT; i++)
+ insert(root, pool[i].reset(i-1));
+ }
+ finish();
+ }
+
+ private static class Node {
+ private double value;
+ private Node min;
+ private Node max;
+
+ public Node(double d) { value = d; }
+
+ public Node reset(double d) { value = d; min = max = null; return this; }
+
+ @Override
+ public String toString() {
+ return (min != null ? min + ", " : "") +
+ value +
+ (max != null ? ", " + max : "");
+ }
+ }
+
+ private static Node insert(Node root, Node d) {
+ for ( ; ; ) {
+ long rootBits = Double.doubleToRawLongBits(root.value);
+ long dBits = Double.doubleToRawLongBits(d.value);
+
+ // No duplicates
+ if (rootBits == dBits)
+ return root;
+
+ long delta = System.nanoTime();
+
+ double dmin = min(root.value, d.value);
+
+ time += System.nanoTime() - delta;
+ times++;
+
+ long minBits = Double.doubleToRawLongBits(dmin);
+
+ if (minBits == dBits)
+ if (root.min != null)
+ root = root.min;
+ else
+ return root.min = d;
+ else
+ if (root.max != null)
+ root = root.max;
+ else
+ return root.max = d;
+ }
+ }
+
+ // Wrapper method to prevent code reordering from affecting measures (JLS 17.4).
+ private static double min(double a, double b) {
+ return Math.min(a, b);
}
}
-
--- a/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java Sat Mar 09 12:54:20 2019 +0000
@@ -26,8 +26,8 @@
* @bug 8148490
* @summary Test correct saving and restoring of vector registers at safepoints.
*
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:-TieredCompilation
- * -XX:+SafepointALot
+ * @run main/othervm -Xbatch -XX:-TieredCompilation
+ * -XX:+UnlockDiagnosticVMOptions -XX:+SafepointALot
* -XX:CompileCommand=exclude,compiler.runtime.safepoints.TestRegisterRestoring::main
* compiler.runtime.safepoints.TestRegisterRestoring
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/g1/TestPeriodicCollectionJNI.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 gc.g1;
+
+/* @test
+ * @bug 8218880
+ * @summary Test that issuing a periodic collection while the GC locker is
+ * held does not crash the VM.
+ * @key gc
+ * @requires vm.gc.G1
+ * @modules java.base
+ * @run main/othervm/native
+ * -Xbootclasspath/a:.
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+UseG1GC -XX:G1PeriodicGCInterval=100
+ * -XX:+G1PeriodicGCInvokesConcurrent
+ * -Xlog:gc,gc+periodic=debug
+ * gc.g1.TestPeriodicCollectionJNI
+ * @run main/othervm/native
+ * -Xbootclasspath/a:.
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+UseG1GC -XX:G1PeriodicGCInterval=100
+ * -XX:-G1PeriodicGCInvokesConcurrent
+ * -Xlog:gc,gc+periodic=debug
+ * gc.g1.TestPeriodicCollectionJNI
+ */
+
+public class TestPeriodicCollectionJNI {
+ static { System.loadLibrary("TestPeriodicCollectionJNI"); }
+
+ private static native boolean blockInNative(byte[] array);
+ private static native void unblock();
+
+ public static void block() {
+ if (!blockInNative(new byte[0])) {
+ throw new RuntimeException("failed to acquire lock to dummy object");
+ }
+ }
+
+ public static void main(String[] args) throws InterruptedException {
+ long timeout = 2000;
+ long startTime = System.currentTimeMillis();
+
+ // Start thread doing JNI call
+ BlockInNative blocker = new BlockInNative();
+ blocker.start();
+
+ try {
+ // Wait for periodic GC timeout to trigger
+ while (System.currentTimeMillis() < startTime + timeout) {
+ System.out.println("Sleeping to let periodic GC trigger...");
+ Thread.sleep(200);
+ }
+ } finally {
+ unblock();
+ }
+ }
+}
+
+class BlockInNative extends Thread {
+
+ public void run() {
+ TestPeriodicCollectionJNI.block();
+ }
+
+ native void unlock();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/g1/libTestPeriodicCollectionJNI.c Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+/*
+ * Native support for TestPeriodicCollectionJNI test.
+ */
+
+#include "jni.h"
+
+#ifdef WINDOWS
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static volatile int release_critical = 0;
+
+JNIEXPORT jboolean JNICALL
+Java_gc_g1_TestPeriodicCollectionJNI_blockInNative(JNIEnv* env, jobject obj, jintArray dummy) {
+ void* native_array = (*env)->GetPrimitiveArrayCritical(env, dummy, 0);
+
+ if (native_array == NULL) {
+ return JNI_FALSE;
+ }
+
+ while (!release_critical) {
+#ifdef WINDOWS
+ Sleep(1);
+#else
+ usleep(1000);
+#endif
+ }
+
+ (*env)->ReleasePrimitiveArrayCritical(env, dummy, native_array, 0);
+
+ return JNI_TRUE;
+}
+
+JNIEXPORT void JNICALL Java_gc_g1_TestPeriodicCollectionJNI_unblock(JNIEnv *env, jobject obj)
+{
+ release_critical = 1;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -203,7 +203,13 @@
allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap(origin -> (!(origin.contains("develop") || origin.contains("notproduct"))));
/*
- * Remove CICompilerCount from testing because currently it can hang system
+ * Exclude VMThreadStackSize from max range testing, because it will always exit with code 1,
+ * which technically passes, but really it fails, and worse yet, it produces hs_err_pid file.
+ */
+ excludeTestMaxRange("VMThreadStackSize");
+
+ /*
+ * Exclude CICompilerCount from testing because currently it can hang system
*/
excludeTestMaxRange("CICompilerCount");
--- a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java Sat Mar 09 12:54:20 2019 +0000
@@ -45,6 +45,7 @@
{"MinRAMFraction", "2"},
{"InitialRAMFraction", "64"},
{"TLABStats", "false"},
+ {"ThreadLocalHandshakes", "true"},
// deprecated alias flags (see also aliased_jvm_flags):
{"DefaultMaxRAMFraction", "4"},
--- a/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java Sat Mar 09 12:54:20 2019 +0000
@@ -30,7 +30,7 @@
* java.management
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. UseCompressedOops
+ * @run main/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. UseCompressedOops
*/
import java.util.ArrayList;
import java.util.Collections;
--- a/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,15 @@
/*
* @test
- * @bug 8151486
+ * @bug 8151486 8218266
* @summary Call Class.forName() on the system classloader from a class loaded
* from a custom classloader, using the current class's protection domain.
* @library /test/lib
+ * @modules java.base/jdk.internal.misc
* @build jdk.test.lib.Utils
* jdk.test.lib.util.JarUtils
* @build ClassForName ProtectionDomainCacheTest
- * @run main/othervm/policy=test.policy -XX:+UnlockDiagnosticVMOptions -XX:VerifySubSet=dictionary -XX:+VerifyAfterGC -Xlog:gc+verify=debug,protectiondomain=trace,class+unload:gc.log -Djava.security.manager ProtectionDomainCacheTest
+ * @run main/othervm/policy=test.policy -Djava.security.manager ProtectionDomainCacheTest
*/
import java.net.URL;
@@ -42,48 +43,69 @@
import java.util.List;
import jdk.test.lib.Utils;
import jdk.test.lib.util.JarUtils;
+import java.io.File;
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
/*
* Create .jar, load ClassForName from .jar using a URLClassLoader
*/
public class ProtectionDomainCacheTest {
- private static final long TIMEOUT = (long)(5000.0 * Utils.TIMEOUT_FACTOR);
- private static final String TESTCLASSES = System.getProperty("test.classes", ".");
- private static final String CLASSFILENAME = "ClassForName.class";
+ static class Test {
+ private static final long TIMEOUT = (long)(5000.0 * Utils.TIMEOUT_FACTOR);
+ private static final String TESTCLASSES = System.getProperty("test.classes", ".");
+ private static final String CLASSFILENAME = "ClassForName.class";
+
+ // Use a new classloader to load the ClassForName class.
+ public static void loadAndRun(Path jarFilePath)
+ throws Exception {
+ ClassLoader classLoader = new URLClassLoader(
+ new URL[]{jarFilePath.toUri().toURL()}) {
+ @Override public String toString() { return "LeakedClassLoader"; }
+ };
+
+ Class<?> loadClass = Class.forName("ClassForName", true, classLoader);
+ loadClass.newInstance();
+
+ System.out.println("returning : " + classLoader);
+ }
- // Use a new classloader to load the ClassForName class.
- public static void loadAndRun(Path jarFilePath)
- throws Exception {
- ClassLoader classLoader = new URLClassLoader(
- new URL[]{jarFilePath.toUri().toURL()}) {
- @Override public String toString() { return "LeakedClassLoader"; }
- };
+ public static void main(final String[] args) throws Exception {
+ // Create a temporary .jar file containing ClassForName.class
+ Path testClassesDir = Paths.get(TESTCLASSES);
+ Path jarFilePath = Files.createTempFile("cfn", ".jar");
+ JarUtils.createJarFile(jarFilePath, testClassesDir, CLASSFILENAME);
+ jarFilePath.toFile().deleteOnExit();
- Class<?> loadClass = Class.forName("ClassForName", true, classLoader);
- loadClass.newInstance();
+ // Remove the ClassForName.class file that jtreg built, to make sure
+ // we're loading from the tmp .jar
+ Path classFile = FileSystems.getDefault().getPath(TESTCLASSES,
+ CLASSFILENAME);
+ Files.delete(classFile);
- System.out.println("returning : " + classLoader);
+ loadAndRun(jarFilePath);
+
+ // Give the GC a chance to unload protection domains
+ for (int i = 0; i < 100; i++) {
+ System.gc();
+ }
+ System.out.println("All Classloaders and protection domain cache entries successfully unloaded");
+ }
}
- public static void main(final String[] args) throws Exception {
- // Create a temporary .jar file containing ClassForName.class
- Path testClassesDir = Paths.get(TESTCLASSES);
- Path jarFilePath = Files.createTempFile("cfn", ".jar");
- JarUtils.createJarFile(jarFilePath, testClassesDir, CLASSFILENAME);
- jarFilePath.toFile().deleteOnExit();
-
- // Remove the ClassForName.class file that jtreg built, to make sure
- // we're loading from the tmp .jar
- Path classFile = FileSystems.getDefault().getPath(TESTCLASSES,
- CLASSFILENAME);
- Files.delete(classFile);
-
- loadAndRun(jarFilePath);
-
- // Give the GC a chance to unload protection domains
- for (int i = 0; i < 100; i++) {
- System.gc();
- }
- System.out.println("All Classloaders and protection domain cache entries successfully unloaded");
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+ "-Djava.security.policy==" + System.getProperty("test.src") + File.separator + "test.policy",
+ "-Dtest.classes=" + System.getProperty("test.classes", "."),
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:VerifySubSet=dictionary",
+ "-XX:+VerifyAfterGC",
+ "-Xlog:gc+verify,protectiondomain=debug",
+ "-Djava.security.manager",
+ Test.class.getName());
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("PD in set is not alive");
+ output.shouldHaveExitValue(0);
}
}
--- a/test/hotspot/jtreg/runtime/Dictionary/test.policy Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/runtime/Dictionary/test.policy Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
grant {
- permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete";
+ permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete, execute";
permission java.lang.RuntimePermission "createClassLoader";
permission java.lang.RuntimePermission "getClassLoader";
permission java.util.PropertyPermission "*", "read"; /* for Utils */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2019, SAP SE. All rights reserved.
+ * 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 TestAbortVMOnSafepointTimeout
+ * @summary Check if VM can kill thread which doesn't reach safepoint.
+ * @bug 8219584
+ * @requires vm.compiler2.enabled
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * java.management
+ */
+
+public class TestAbortVMOnSafepointTimeout {
+
+ public static void main(String[] args) throws Exception {
+ if (args.length > 0) {
+ int result = test_loop(3);
+ System.out.println("This message would occur after some time with result " + result);
+ return;
+ }
+
+ testWith(500, 500);
+ }
+
+ static int test_loop(int x) {
+ int sum = 0;
+ if (x != 0) {
+ // Long running loop without safepoint.
+ for (int y = 1; y < Integer.MAX_VALUE; ++y) {
+ if (y % x == 0) ++sum;
+ }
+ }
+ return sum;
+ }
+
+ public static void testWith(int sfpt_interval, int timeout_delay) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:+SafepointTimeout",
+ "-XX:+SafepointALot",
+ "-XX:+AbortVMOnSafepointTimeout",
+ "-XX:SafepointTimeoutDelay=" + timeout_delay,
+ "-XX:GuaranteedSafepointInterval=" + sfpt_interval,
+ "-XX:-TieredCompilation",
+ "-XX:-UseCountedLoopSafepoints",
+ "-XX:LoopStripMiningIter=0",
+ "-XX:LoopUnrollLimit=0",
+ "-XX:CompileCommand=compileonly,TestAbortVMOnSafepointTimeout::test_loop",
+ "-Xcomp",
+ "-XX:-CreateCoredumpOnCrash",
+ "-Xms64m",
+ "TestAbortVMOnSafepointTimeout",
+ "runTestLoop"
+ );
+
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ if (Platform.isWindows()) {
+ output.shouldMatch("Safepoint sync time longer than");
+ } else {
+ output.shouldMatch("SIGILL");
+ if (Platform.isLinux()) {
+ output.shouldMatch("(sent by kill)");
+ }
+ output.shouldMatch("TestAbortVMOnSafepointTimeout.test_loop");
+ }
+ output.shouldNotHaveExitValue(0);
+ }
+}
--- a/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest Sat Mar 09 12:54:20 2019 +0000
@@ -1,4 +1,4 @@
-FROM oraclelinux:7.2
+FROM oraclelinux:7.6
MAINTAINER mikhailo.seledtsov@oracle.com
COPY /jdk /jdk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/containers/docker/JfrReporter.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+import java.nio.file.Paths;
+import jdk.jfr.Recording;
+import jdk.jfr.consumer.RecordedEvent;
+import jdk.jfr.consumer.RecordingFile;
+
+
+// This class is intended to run inside a container
+public class JfrReporter {
+ public static final String TEST_REPORTED_CORES="TEST_REPORTED_CORES";
+ public static final String TEST_REPORTED_MEMORY="TEST_REPORTED_MEMORY";
+ public static final String TEST_REPORTED_PID="TEST_REPORTED_PID";
+ public static final String TESTCASE_CPU="cpu";
+ public static final String TESTCASE_MEMORY="memory";
+ public static final String TESTCASE_PROCESS="process";
+
+ public static void main(String[] args) throws Exception {
+ String testCase = args[0];
+ System.out.println("Testcase: " + testCase);
+ switch (testCase) {
+ case TESTCASE_CPU:
+ RecordedEvent event = testEvent("jdk.CPUInformation", "cpu.jfr");
+ System.out.println(TEST_REPORTED_CORES + "=" + event.getInt("cores"));
+ break;
+ case TESTCASE_MEMORY:
+ event = testEvent("jdk.PhysicalMemory", "memory.jfr");
+ System.out.println(TEST_REPORTED_MEMORY + "=" + event.getLong("totalSize"));
+ break;
+ case TESTCASE_PROCESS:
+ event = testEvent("jdk.SystemProcess", "process.jfr");
+ System.out.println(TEST_REPORTED_PID + "=" + event.getString("pid"));
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid test case");
+ }
+ }
+
+ private static RecordedEvent testEvent(String event, String recordingPath) throws Exception {
+ System.out.println("========= Testing event: " + event);
+ Recording r = new Recording();
+ r.enable(event);
+ r.setDestination(Paths.get("tmp", recordingPath));
+ r.start();
+ r.stop();
+
+ RecordedEvent recordedEvent = RecordingFile.readAllEvents(r.getDestination()).get(0);
+ System.out.println("RecordedEvent: " + recordedEvent);
+ return recordedEvent;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/containers/docker/TestJFREvents.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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
+ * @summary Ensure that certain JFR events return correct results for resource values
+ * when run inside Docker container, such as available CPU and memory.
+ * Also make sure that PIDs are based on value provided by container,
+ * not by the host system.
+ * @requires (docker.support & os.maxMemory >= 2g)
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * java.management
+ * jdk.jartool/sun.tools.jar
+ * @build JfrReporter
+ * @run driver TestJFREvents
+ */
+import jdk.test.lib.containers.docker.Common;
+import jdk.test.lib.containers.docker.DockerRunOptions;
+import jdk.test.lib.containers.docker.DockerTestUtils;
+import jdk.test.lib.Utils;
+
+
+public class TestJFREvents {
+ private static final String imageName = Common.imageName("jfr-events");
+ private static final int availableCPUs = Runtime.getRuntime().availableProcessors();
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Test Environment: detected availableCPUs = " + availableCPUs);
+ if (!DockerTestUtils.canTestDocker()) {
+ return;
+ }
+
+ DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
+
+ try {
+ // leave one CPU for system and tools, otherwise this test may be unstable
+ int maxNrOfAvailableCpus = availableCPUs - 1;
+ for (int i=1; i < maxNrOfAvailableCpus; i = i * 2) {
+ testCPUInfo(i, i);
+ }
+
+ long MB = 1024*1024;
+ testMemory("200m", "" + 200*MB);
+ testMemory("500m", "" + 500*MB);
+ testMemory("1g", "" + 1024*MB);
+
+ testProcessInfo();
+
+ } finally {
+ DockerTestUtils.removeDockerImage(imageName);
+ }
+ }
+
+
+ private static void testCPUInfo(int valueToSet, int expectedValue) throws Exception {
+ Common.logNewTestCase("CPUInfo: --cpus = " + valueToSet);
+ DockerTestUtils.dockerRunJava(
+ commonDockerOpts()
+ .addDockerOpts("--cpus=" + valueToSet)
+ .addClassOptions(JfrReporter.TESTCASE_CPU))
+ .shouldHaveExitValue(0)
+ .shouldContain(JfrReporter.TEST_REPORTED_CORES);
+
+ // The following assertion is currently disabled due to JFR reporting incorrect values.
+ // JFR reports values for the host system as opposed to values for the container.
+ // @ignore 8219999
+ // .shouldContain(JfrReporter.TEST_REPORTED_CORES + "=" + expectedValue);
+ }
+
+
+ private static void testMemory(String valueToSet, String expectedValue) throws Exception {
+ Common.logNewTestCase("Memory: --memory = " + valueToSet);
+ DockerTestUtils.dockerRunJava(
+ commonDockerOpts()
+ .addDockerOpts("--memory=" + valueToSet)
+ .addClassOptions(JfrReporter.TESTCASE_MEMORY))
+ .shouldHaveExitValue(0)
+ .shouldContain(JfrReporter.TEST_REPORTED_MEMORY + "=" + expectedValue);
+ }
+
+
+ private static void testProcessInfo() throws Exception {
+ Common.logNewTestCase("ProcessInfo");
+ DockerTestUtils.dockerRunJava(
+ commonDockerOpts()
+ .addClassOptions(JfrReporter.TESTCASE_PROCESS))
+ .shouldHaveExitValue(0)
+ .shouldContain(JfrReporter.TEST_REPORTED_PID + "=1");
+
+ }
+
+
+ private static DockerRunOptions commonDockerOpts() {
+ return new DockerRunOptions(imageName, "/jdk/bin/java", "JfrReporter")
+ .addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
+ .addJavaOpts("-cp", "/test-classes/");
+ }
+}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassExclusionFilter/exclfilter001.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassExclusionFilter/exclfilter001.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,15 @@
package nsk.jdi.ClassUnloadRequest.addClassExclusionFilter;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jdi.*;
import com.sun.jdi.*;
import com.sun.jdi.event.*;
import com.sun.jdi.request.*;
+
import java.io.*;
-import java.util.*;
/**
* Debugger requests <code>ClassUnloadEvent</code> and sets class filter by calling
@@ -64,7 +65,7 @@
private static int exitStatus;
private static Log log;
private static Debugee debugee;
- private static int eventWaitTime;
+ private static long waitTime;
String[] patterns = {
prefix + "Sub*",
@@ -88,7 +89,7 @@
exclfilter001 tstObj = new exclfilter001();
ArgumentHandler argHandler = new ArgumentHandler(argv);
- eventWaitTime = argHandler.getWaitTime() * 60000;
+ waitTime = argHandler.getWaitTime();
log = new Log(out, argHandler);
debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
@@ -121,7 +122,7 @@
debugee.sendSignal(SGNL_UNLOAD);
debugee.receiveExpectedSignal(SGNL_READY);
- receiveEvents(eventWaitTime, patterns[i]);
+ receiveEvents(patterns[i]);
display("");
debugee.getEventRequestManager().deleteEventRequest(request);
@@ -146,19 +147,20 @@
return request;
}
- private void receiveEvents(int waitTime, String pattern) {
+ private void receiveEvents(String pattern) {
EventSet eventSet = null;
Event event;
- int totalTime = waitTime;
+ long totalWaitTime = Utils.adjustTimeout(waitTime * 10000);
+ long waitTimeout = Utils.adjustTimeout(waitTime * 1000);
long begin, delta;
int count = 0;
boolean exit = false;
try {
begin = System.currentTimeMillis();
- eventSet = debugee.VM().eventQueue().remove(totalTime);
+ eventSet = debugee.VM().eventQueue().remove(waitTimeout);
delta = System.currentTimeMillis() - begin;
- totalTime -= delta;
+ totalWaitTime -= delta;
while (eventSet != null) {
EventIterator eventIterator = eventSet.eventIterator();
while (eventIterator.hasNext()) {
@@ -174,14 +176,14 @@
throw new Failure("Unexpected VMDisconnectEvent received");
}
}
- if (totalTime <= 0 || exit) {
+ if (totalWaitTime <= 0 || exit) {
break;
}
debugee.resume();
- begin = System.currentTimeMillis();
- eventSet = debugee.VM().eventQueue().remove(totalTime);
+ begin = System.currentTimeMillis();
+ eventSet = debugee.VM().eventQueue().remove(waitTimeout);
delta = System.currentTimeMillis() - begin;
- totalTime -= delta;
+ totalWaitTime -= delta;
}
} catch(InterruptedException e) {
throw new Failure(e);
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassFilter/filter001.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassFilter/filter001.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
package nsk.jdi.ClassUnloadRequest.addClassFilter;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jdi.*;
@@ -63,7 +64,7 @@
private static int exitStatus;
private static Log log;
private static Debugee debugee;
- private static int eventWaitTime;
+ private static long waitTime;
String[] patterns = {
prefix + "Sub*",
@@ -87,7 +88,8 @@
filter001 tstObj = new filter001();
ArgumentHandler argHandler = new ArgumentHandler(argv);
- eventWaitTime = argHandler.getWaitTime() * 60000;
+ waitTime = argHandler.getWaitTime();
+
log = new Log(out, argHandler);
debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
@@ -120,7 +122,7 @@
debugee.sendSignal(SGNL_UNLOAD);
debugee.receiveExpectedSignal(SGNL_READY);
- receiveEvents(eventWaitTime, patterns[i]);
+ receiveEvents(patterns[i]);
display("");
debugee.getEventRequestManager().deleteEventRequest(request);
@@ -145,19 +147,20 @@
return request;
}
- private void receiveEvents(int waitTime, String pattern) {
+ private void receiveEvents(String pattern) {
EventSet eventSet = null;
Event event;
- int totalTime = waitTime;
+ long totalWaitTime = Utils.adjustTimeout(waitTime * 10000);
+ long waitTimeout = Utils.adjustTimeout(waitTime * 1000);
long begin, delta;
int count = 0;
boolean exit = false;
try {
begin = System.currentTimeMillis();
- eventSet = debugee.VM().eventQueue().remove(totalTime);
+ eventSet = debugee.VM().eventQueue().remove(waitTimeout);
delta = System.currentTimeMillis() - begin;
- totalTime -= delta;
+ totalWaitTime -= delta;
while (eventSet != null) {
EventIterator eventIterator = eventSet.eventIterator();
while (eventIterator.hasNext()) {
@@ -173,14 +176,14 @@
throw new Failure("Unexpected VMDisconnectEvent received");
}
}
- if (totalTime <= 0 || exit) {
+ if (totalWaitTime <= 0 || exit) {
break;
}
debugee.resume();
- begin = System.currentTimeMillis();
- eventSet = debugee.VM().eventQueue().remove(totalTime);
+ begin = System.currentTimeMillis();
+ eventSet = debugee.VM().eventQueue().remove(waitTimeout);
delta = System.currentTimeMillis() - begin;
- totalTime -= delta;
+ totalWaitTime -= delta;
}
} catch(InterruptedException e) {
throw new Failure(e);
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/_itself_/event001.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/_itself_/event001.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* 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,6 +36,7 @@
import java.util.List;
import java.io.*;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
@@ -234,7 +235,7 @@
// wait for a requested event
try {
- gotEvent.wait(argHandler.getWaitTime()*60000);
+ gotEvent.wait(Utils.adjustTimeout(argHandler.getWaitTime()*1000));
} catch (InterruptedException e) {
log.complain("TEST FAILURE: waiting for a requested AccessWatchpointEvent #"
+ i + ": caught " + e);
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
package nsk.jdi.EventQueue.remove;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
@@ -67,7 +68,7 @@
* <BR>
* The check includes two steps. <BR>
* In first one, second thread waits for any incoming event from the <BR>
- * debugger which is sleeping for "WAITTIME*90 seconds"; hence, <BR>
+ * debugger which is sleeping for some time; hence, <BR>
* no events are expected to be received at the debugger end. <BR>
* In second, second thread is interrupted, and the debugger waits for <BR>
* a breakpoint event after the debuggee finishes sleeping. <BR>
@@ -130,7 +131,7 @@
static Debugee debuggee;
static ArgumentHandler argsHandler;
- static int waitTime;
+ static long waitTime;
static VirtualMachine vm = null;
static EventRequestManager eventRManager = null;
@@ -140,6 +141,8 @@
static ReferenceType debuggeeClass = null;
+ static Value trueValue;
+
static int testExitCode = PASSED;
class JDITestRuntimeException extends RuntimeException {
@@ -156,7 +159,7 @@
logHandler = new Log(out, argsHandler);
Binder binder = new Binder(argsHandler, logHandler);
- waitTime = argsHandler.getWaitTime() * 60000;
+ waitTime = Utils.adjustTimeout(argsHandler.getWaitTime() * 1000);
try {
log2("launching a debuggee :");
@@ -285,6 +288,8 @@
if (!debuggeeClass.name().equals(debuggeeName))
throw new JDITestRuntimeException("** Unexpected ClassName for ClassPrepareEvent **");
+ trueValue = debuggeeClass.getValue(debuggeeClass.fieldByName("BOOLEAN_TRUE_VALUE"));
+
log2(" received: ClassPrepareEvent for debuggeeClass");
String bPointMethod = "methodForCommunication";
@@ -356,11 +361,11 @@
thread2.interrupt();
for (int i2 = 0; i2 < waitTime; ) {
- waitObj.wait(10000);
+ waitObj.wait(1000);
if (!thread2.isAlive()) {
break;
}
- i2 += 10000;
+ i2 += 1000;
}
if (thread2.isAlive()) {
log3("ERROR: thread2 is still alive");
@@ -508,9 +513,17 @@
log2("-----t2: eventSet = eventQueue.remove(); expects: InterruptedException");
eventSet = eventQueue.remove();
throw new JDITestRuntimeException("** return from eventQueue.remove(); **");
- } catch ( InterruptedException e1) {
+ } catch (InterruptedException e1) {
log2("-----t2: InterruptedException");
- } catch ( Exception e ) {
+ // Signal to debuggee to stop sleeping
+ try {
+ ((ClassType) debuggeeClass).setValue(debuggeeClass.fieldByName("stopSleeping"),
+ trueValue);
+ } catch (InvalidTypeException | ClassNotLoadedException e) {
+ log3("ERROR: -----t2: Exception : " + e);
+ testExitCode = FAILED;
+ }
+ } catch (Exception e) {
log3("ERROR: -----t2: Exception : " + e);
testExitCode = FAILED;
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004a.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004a.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
package nsk.jdi.EventQueue.remove;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
@@ -63,6 +64,12 @@
static int lineForComm = 2;
+ // Used for communication between debugger and debuggee
+ static volatile boolean stopSleeping = false;
+
+ // Used by debugger to set stopSleeping flag to true
+ static final boolean BOOLEAN_TRUE_VALUE = true;
+
private static void methodForCommunication() {
int i1 = instruction;
int i2 = i1;
@@ -97,10 +104,12 @@
log1("before: methodForCommunication();");
methodForCommunication();
log1("before: Thread.sleep");
- try {
- Thread.sleep(argHandler.getWaitTime()*90000);
- } catch (InterruptedException e) {
- }
+ Utils.waitForCondition(
+ () -> {
+ return stopSleeping;
+ },
+ Utils.adjustTimeout(argHandler.getWaitTime() * 10000),
+ 100);
log1("after: Thread.sleep");
break ;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
package nsk.jdi.EventQueue.remove_l;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
@@ -30,7 +31,6 @@
import com.sun.jdi.*;
import com.sun.jdi.event.*;
import com.sun.jdi.request.*;
-
import java.util.*;
import java.io.*;
@@ -63,8 +63,8 @@
* to be suspended and to inform the debugger with the event. <BR>
* The case for testing consists of of two steps. <BR>
* In the first one the first assertion is checked up on as follows: <BR>
- * the debugger sleeps for "WAITTIME * 90 sec"; <BR>
- * hence, no event is expected in the debugger within WAITTINE, and <BR>
+ * the debugger sleeps for some time; <BR>
+ * hence, no event is expected in the debugger within WAITTIME, and <BR>
* debugger's method breakpointForCommunication() should get null. <BR>
* After WAITTIME, the debugger just expects to get normal breakpoint event.<BR>
*/
@@ -126,7 +126,7 @@
static Debugee debuggee;
static ArgumentHandler argsHandler;
- static int waitTime;
+ static long waitTime;
static VirtualMachine vm = null;
static EventRequestManager eventRManager = null;
@@ -136,6 +136,8 @@
static ReferenceType debuggeeClass = null;
+ static Value trueValue;
+
static int testExitCode = PASSED;
class JDITestRuntimeException extends RuntimeException {
@@ -152,7 +154,7 @@
logHandler = new Log(out, argsHandler);
Binder binder = new Binder(argsHandler, logHandler);
- waitTime = argsHandler.getWaitTime() * 60000;
+ waitTime = Utils.adjustTimeout(argsHandler.getWaitTime() * 1000);
try {
log2("launching a debuggee :");
@@ -281,6 +283,8 @@
if (!debuggeeClass.name().equals(debuggeeName))
throw new JDITestRuntimeException("** Unexpected ClassName for ClassPrepareEvent **");
+ trueValue = debuggeeClass.getValue(debuggeeClass.fieldByName("BOOLEAN_TRUE_VALUE"));
+
log2(" received: ClassPrepareEvent for debuggeeClass");
String bPointMethod = "methodForCommunication";
@@ -326,6 +330,11 @@
testExitCode = FAILED;
throw new JDITestRuntimeException("** unexpected Exception **");
}
+
+ // Signal to debuggee to stop sleeping
+ ((ClassType) debuggeeClass).setValue(debuggeeClass.fieldByName("stopSleeping"),
+ trueValue);
+
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004a.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004a.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
package nsk.jdi.EventQueue.remove_l;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
@@ -63,6 +64,12 @@
static int lineForComm = 2;
+ // Used for communication between debugger and debuggee
+ static volatile boolean stopSleeping = false;
+
+ // Used by debugger to set stopSleeping flag to true
+ static final boolean BOOLEAN_TRUE_VALUE = true;
+
private static void methodForCommunication() {
int i1 = instruction;
int i2 = i1;
@@ -97,10 +104,12 @@
log1("before: methodForCommunication();");
methodForCommunication();
log1("before: Thread.sleep");
- try {
- Thread.sleep(argHandler.getWaitTime()*90000);
- } catch (InterruptedException e) {
- }
+ Utils.waitForCondition(
+ () -> {
+ return stopSleeping;
+ },
+ Utils.adjustTimeout(argHandler.getWaitTime() * 10000),
+ 100);
log1("after: Thread.sleep");
break ;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended002a.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended002a.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -63,8 +63,8 @@
public static void main (String argv[]) {
- for (int i=0; i<argv.length; i++) {
- if ( argv[i].equals("-vbs") || argv[i].equals("-verbose") ) {
+ for (int i = 0; i < argv.length; i++) {
+ if (argv[i].equals("-vbs") || argv[i].equals("-verbose")) {
verbMode = true;
break;
}
@@ -76,10 +76,8 @@
IOPipe pipe = argHandler.createDebugeeIOPipe();
pipe.println("ready");
-
int exitCode = PASSED;
for (int i = 0; ; i++) {
-
String instruction;
log1("waiting for an instruction from the debugger ...");
@@ -94,53 +92,70 @@
//------------------------------------------------------ section tested
case 0:
- Threadissuspended002a test_thread =
- new Threadissuspended002a("testedThread");
- log1(" thread2 is created");
-
- label:
- synchronized (Threadissuspended002a.lockingObject) {
- synchronized (Threadissuspended002a.waitnotifyObj) {
- log1(" synchronized (waitnotifyObj) { enter");
- log1(" before: test_thread.start()");
- test_thread.start();
+ Threadissuspended002a test_thread =
+ new Threadissuspended002a("testedThread");
+ log1(" thread2 is created");
+ label:
+ synchronized (Threadissuspended002a.lockingObject) {
+ synchronized (Threadissuspended002a.waitnotifyObj) {
+ log1(" synchronized (waitnotifyObj) { enter");
+ log1(" before: test_thread.start()");
+ test_thread.start();
- try {
- log1(" before: waitnotifyObj.wait();");
- Threadissuspended002a.waitnotifyObj.wait();
- log1(" after: waitnotifyObj.wait();");
- pipe.println("checkready");
- instruction = pipe.readln();
- if (!instruction.equals("continue")) {
- logErr("ERROR: unexpected instruction: " + instruction);
- exitCode = FAILED;
- break label;
- }
- pipe.println("docontinue");
- } catch ( Exception e2) {
- log1(" Exception e2 exception: " + e2 );
- pipe.println("waitnotifyerr");
- }
- }
- }
- log1("mainThread is out of: synchronized (lockingObject) {");
+ try {
+ log1(" before: waitnotifyObj.wait();");
+ Threadissuspended002a.waitnotifyObj.wait();
+ log1(" after: waitnotifyObj.wait();");
+ pipe.println("checkready");
+ instruction = pipe.readln();
+ if (!instruction.equals("continue")) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break label;
+ }
+ } catch ( Exception e2) {
+ log1(" Exception e2 exception: " + e2 );
+ pipe.println("waitnotifyerr");
+ }
+ }
+ }
+ log1("mainThread is out of: synchronized (lockingObject) {");
- break ;
+ // To avoid contention for the logging print stream lock
+ // the main thread will wait until the debuggee test thread
+ // has completed to the breakpoint.
+ // If the debugger suspends the main thread while it is holding
+ // the logging lock, the test is deadlocked on the test thread log
+ // calls.
+ synchronized (Threadissuspended002a.waitnotifyObj) {
+ try {
+ // Main debuggee thread is out of synchronized(lockingObject)
+ // so the test thread will continue.
+ // Send the debugger the "docontinue" command
+ // so it will enable the breakpoint in the test thread.
+ pipe.println("docontinue");
+
+ Threadissuspended002a.waitnotifyObj.wait();
+ } catch (Exception e3) {
+ pipe.println("waitnotifyerr");
+ }
+ }
+
+ break ;
//------------------------------------------------- standard end section
default:
- pipe.println("checkend");
- break ;
+ pipe.println("checkend");
+ break ;
}
} else {
- logErr("ERRROR: unexpected instruction: " + instruction);
+ logErr("ERROR: unexpected instruction: " + instruction);
exitCode = FAILED;
break ;
}
}
-
System.exit(exitCode + PASS_BASE);
}
}
@@ -158,12 +173,14 @@
public void run() {
log("method 'run' enter");
- synchronized (waitnotifyObj) {
+ synchronized (waitnotifyObj) {
log("entered into block: synchronized (waitnotifyObj)");
- waitnotifyObj.notify(); }
+ waitnotifyObj.notify();
+ }
log("exited from block: synchronized (waitnotifyObj)");
- synchronized (lockingObject) {
- log("entered into block: synchronized (lockingObject)"); }
+ synchronized (lockingObject) {
+ log("entered into block: synchronized (lockingObject)");
+ }
log("exited from block: synchronized (lockingObject)");
i1++;
i2--;
@@ -171,6 +188,11 @@
runt1();
log("returned from the method 'runt1'");
log("method 'run' exit");
+
+ // Allow the main thread to continue
+ synchronized (waitnotifyObj) {
+ waitnotifyObj.notify();
+ }
return;
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/suspend/suspend001.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/suspend/suspend001.java Sat Mar 09 12:54:20 2019 +0000
@@ -23,6 +23,7 @@
package nsk.jdi.ThreadReference.suspend;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
@@ -429,7 +430,8 @@
* It removes events from EventQueue until gets first BreakpointEvent.
* To get next EventSet value, it uses the method
* EventQueue.remove(int timeout)
- * The timeout argument passed to the method, is "waitTime*60000".
+ * The timeout argument passed to the method, is "waitTime*1000" adjusted to
+ * test.timeout.factor system property.
* Note: the value of waitTime is set up with
* the method ArgumentHandler.getWaitTime() at the beginning of the test.
*
@@ -451,7 +453,7 @@
log2(" new: eventSet = eventQueue.remove();");
try {
- eventSet = eventQueue.remove (waitTime*60000);
+ eventSet = eventQueue.remove(Utils.adjustTimeout(waitTime*1000));
if (eventSet == null) {
log2(":::::: timeout when waiting for a BreakpintEvent");
// log3("ERROR: timeout for waiting for a BreakpintEvent");
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allThreads/allthreads001.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allThreads/allthreads001.java Sat Mar 09 12:54:20 2019 +0000
@@ -42,7 +42,7 @@
* <code>com.sun.jdi.VirtualMachine.allThreads()</code> <BR>
* complies with the its spec. <BR>
* <BR>
- * The test checks up the reasults of the method when <BR>
+ * The test checks up the results of the method when <BR>
* it is invoked two times in raw immediately after <BR>
* new thread has been started in the debuggee VM. <BR>
* <BR>
@@ -192,11 +192,15 @@
String threadName = "testedThread";
+ // Suspend VM to ensure no new background thread (e.g. JVMCI
+ // compiler thread) is started between two allThreads() calls.
+ vm.suspend();
List allThreads1 = vm.allThreads();
log2("allThreads1.size() = " + allThreads1.size());
List allThreads2 = vm.allThreads();
log2("allThreads2.size() = " + allThreads2.size());
+ vm.resume();
if ( allThreads1.size() != allThreads2.size() ) {
log3("ERROR: allThreads1.size() != allThreads2.size()");
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002.java Sat Mar 09 12:54:20 2019 +0000
@@ -23,6 +23,7 @@
package nsk.jdi.VirtualMachine.dispose;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
@@ -272,29 +273,29 @@
if (expresult != returnCode0)
break label1;
- log2(" Thread.sleep(waitTime*60000);");
- try {
- Thread.sleep(waitTime*60000);
- } catch ( InterruptedException e ) {
- log3("ERROR: InterruptedException");
- expresult = returnCode1;
- break label1;
- }
+ log2(" Waiting for thread2 is not alive");
- log2("......sending to the debuggee: 'check_alive'");
- log2(" expected reply: 'not_alive'");
- pipe.println("check_alive");
- line = pipe.readln();
- if (line.equals("alive")) {
- log3("ERROR: thread2 is alive");
- expresult = returnCode1;
- } else if (line.equals("not_alive")) {
- log2(" thread2 is not alive");
- } else {
- log3("ERROR: unexpected reply: " + line);
- expresult = returnCode4;
- }
+ Utils.waitForCondition(
+ () -> {
+ log2("......sending to the debuggee: 'check_alive'");
+ log2(" expected reply: 'not_alive'");
+ pipe.println("check_alive");
+ String reply = pipe.readln();
+ if (reply.equals("alive")) {
+ log3("ERROR: thread2 is alive");
+ return false;
+ } else if (reply.equals("not_alive")) {
+ log2(" thread2 is not alive");
+ return true;
+ } else {
+ log3("ERROR: unexpected reply: " + reply);
+ throw new RuntimeException("ERROR: unexpected reply: " + reply);
+ }
+ },
+ Utils.adjustTimeout(waitTime * 60000),
+ 1000);
+ pipe.println("check_done");
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -125,18 +125,26 @@
}
}
log1("mainThread is out of: synchronized (lockingObject)");
-
- instruction = pipe.readln();
- if (!instruction.equals("check_alive")) {
- logErr("ERROR: unexpected instruction: " + instruction);
- exitCode = FAILED;
- } else {
- log1("checking on: thread2.isAlive");
- if (test_thread.isAlive()) {
- pipe.println("alive");
- test_thread.interrupt();
+ while (true) {
+ instruction = pipe.readln();
+ if (instruction.equals("check_done")) {
+ if (test_thread.isAlive()) {
+ logErr("ERROR: thread thread2 is still alive");
+ exitCode = FAILED;
+ }
+ break;
+ } else if (instruction.equals("check_alive")) {
+ log1("checking on: thread2.isAlive");
+ if (test_thread.isAlive()) {
+ pipe.println("alive");
+ test_thread.interrupt();
+ } else {
+ pipe.println("not_alive");
+ }
} else {
- pipe.println("not_alive");
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break;
}
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003.java Sat Mar 09 12:54:20 2019 +0000
@@ -23,6 +23,7 @@
package nsk.jdi.VirtualMachine.dispose;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
@@ -179,6 +180,7 @@
int expresult = returnCode0;
+
String threadName = "testedThread";
List allThreads = null;
@@ -236,28 +238,28 @@
if (expresult != returnCode0)
break label1;
- log2(" Thread.sleep(waitTime*60000);");
- try {
- Thread.sleep(waitTime*60000);
- } catch ( InterruptedException e ) {
- log3("ERROR: InterruptedException");
- expresult = returnCode1;
- break label1;
- }
+ log2(" Waiting for thread2 is not alive");
- log2("......sending to the debuggee: 'check_alive'");
- log2(" expected reply: 'not_alive'");
- pipe.println("check_alive");
- line = pipe.readln();
- if (line.equals("alive")) {
- log3("ERROR: thread2 is alive");
- expresult = returnCode1;
- } else if (line.equals("not_alive")) {
- log2(" thread2 is not alive");
- } else {
- log3("ERROR: unexpected reply: " + line);
- expresult = returnCode4;
- }
+ Utils.waitForCondition(
+ () -> {
+ log2("......sending to the debuggee: 'check_alive'");
+ log2(" expected reply: 'not_alive'");
+ pipe.println("check_alive");
+ String reply = pipe.readln();
+ if (reply.equals("alive")) {
+ log3("ERROR: thread2 is alive");
+ return false;
+ } else if (reply.equals("not_alive")) {
+ log2(" thread2 is not alive");
+ return true;
+ } else {
+ log3("ERROR: unexpected reply: " + reply);
+ throw new RuntimeException("ERROR: unexpected reply: " + reply);
+ }
+ },
+ Utils.adjustTimeout(waitTime * 60000),
+ 1000);
+ pipe.println("check_done");
}
@@ -287,4 +289,6 @@
}
return testExitCode;
}
+
+
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -126,17 +126,26 @@
}
log1("mainThread is out of: synchronized (lockingObject)");
- instruction = pipe.readln();
- if (!instruction.equals("check_alive")) {
- logErr("ERROR: unexpected instruction: " + instruction);
- exitCode = FAILED;
- } else {
- log1("checking on: thread2.isAlive");
- if (test_thread.isAlive()) {
- test_thread.resume();
- pipe.println("alive");
+ while (true) {
+ instruction = pipe.readln();
+ if (instruction.equals("check_done")) {
+ if (test_thread.isAlive()) {
+ logErr("ERROR: thread2 thread is still alive");
+ exitCode = FAILED;
+ }
+ break;
+ } else if (instruction.equals("check_alive")) {
+ log1("checking on: thread2.isAlive");
+ if (test_thread.isAlive()) {
+ test_thread.resume();
+ pipe.println("alive");
+ } else {
+ pipe.println("not_alive");
+ }
} else {
- pipe.println("not_alive");
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break;
}
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004.java Sat Mar 09 12:54:20 2019 +0000
@@ -23,6 +23,7 @@
package nsk.jdi.VirtualMachine.dispose;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
@@ -261,29 +262,30 @@
if (expresult != returnCode0)
break label1;
- log2(" Thread.sleep(waitTime*60000);");
- try {
- Thread.sleep(waitTime*60000);
- } catch ( InterruptedException e ) {
- log3("ERROR: InterruptedException");
- expresult = returnCode1;
- break label1;
- }
+ log2(" Waiting for thread2 is not alive");
- log2("......sending to the debuggee: 'check_alive'");
- log2(" expected reply: 'not_alive'");
- pipe.println("check_alive");
- line = pipe.readln();
- if (line.equals("alive")) {
- log3("ERROR: thread2 is alive");
- expresult = returnCode1;
- } else if (line.equals("not_alive")) {
- log2(" thread2 is not alive");
- } else {
- log3("ERROR: unexpected reply: " + line);
- expresult = returnCode4;
- }
+ Utils.waitForCondition(
+ () -> {
+ log2("......sending to the debuggee: 'check_alive'");
+ log2(" expected reply: 'not_alive'");
+ pipe.println("check_alive");
+ String reply = pipe.readln();
+ if (reply.equals("alive")) {
+ log3("ERROR: thread2 is alive");
+ return false;
+ } else if (reply.equals("not_alive")) {
+ log2(" thread2 is not alive");
+ return true;
+ } else {
+ log3("ERROR: unexpected reply: " + reply);
+ throw new RuntimeException("ERROR: unexpected reply: " + reply);
+ }
+ },
+ Utils.adjustTimeout(waitTime * 60000),
+ 1000);
+
+ pipe.println("check_done");
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -127,18 +127,26 @@
}
}
log1("mainThread is out of: synchronized (lockingObject)");
-
- instruction = pipe.readln();
- if (!instruction.equals("check_alive")) {
- logErr("ERROR: unexpected instruction: " + instruction);
- exitCode = FAILED;
- } else {
- log1("checking on: thread2.isAlive");
- if (test_thread.isAlive()) {
- test_thread.resume();
- pipe.println("alive");
+ while (true) {
+ instruction = pipe.readln();
+ if (instruction.equals("check_done")) {
+ if (test_thread.isAlive()) {
+ logErr("thread thread2 is still alive");
+ exitCode = FAILED;
+ }
+ break;
+ } else if (instruction.equals("check_alive")) {
+ log1("checking on: thread2.isAlive");
+ if (test_thread.isAlive()) {
+ test_thread.resume();
+ pipe.println("alive");
+ } else {
+ pipe.println("not_alive");
+ }
} else {
- pipe.println("not_alive");
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break;
}
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/suspend/suspend001.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/suspend/suspend001.java Sat Mar 09 12:54:20 2019 +0000
@@ -23,6 +23,7 @@
package nsk.jdi.VirtualMachine.suspend;
+import jdk.test.lib.Utils;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
@@ -318,9 +319,10 @@
eventSet1.resume();
eventSet.resume();
- log2(" before: Thread.sleep(waitTime*60000);");
+ log2(" before: Thread.sleep(waitTime*1000);");
+
try {
- Thread.sleep(waitTime*60000);
+ Thread.sleep(Utils.adjustTimeout(waitTime*1000));
} catch ( InterruptedException e ) {
log3("ERROR: InterruptedException");
expresult = returnCode1;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -275,7 +275,6 @@
jint frameCount = 0;
jint frameStackSize = 0;
jvmtiFrameInfo frameStack[MAX_STACK_SIZE];
- int commonDepth = 0;
int found = 0;
int j;
@@ -296,12 +295,8 @@
}
NSK_DISPLAY1(" stack depth: %d\n", (int)frameStackSize);
- commonDepth = (frameCount < frameStackSize ? frameCount : frameStackSize);
- NSK_DISPLAY1(" common: %d\n", (int)commonDepth);
-
- /* check first commonDepth frames and find expected method there */
found = 0;
- for (j = 0; j < commonDepth; j++) {
+ for (j = 0; j < frameStackSize; j++) {
jmethodID qMethod = (jmethodID)NULL;
jlocation qLocation = NSK_JVMTI_INVALID_JLOCATION;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp Sat Mar 09 12:52:30 2019 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -295,7 +295,6 @@
jint frameCount = 0;
jint frameStackSize = 0;
jvmtiFrameInfo frameStack[MAX_STACK_SIZE];
- int commonDepth = 0;
int found = 0;
int j;
@@ -319,12 +318,8 @@
}
NSK_DISPLAY1(" stack depth: %d\n", (int)frameStackSize);
- commonDepth = (frameCount < frameStackSize ? frameCount : frameStackSize);
- NSK_DISPLAY1(" common: %d\n", (int)commonDepth);
-
- /* check first commonDepth frames and find expected method there */
found = 0;
- for (j = 0; j < commonDepth; j++) {
+ for (j = 0; j < frameStackSize; j++) {
jmethodID qMethod = (jmethodID)NULL;
jlocation qLocation = NSK_JVMTI_INVALID_JLOCATION;
--- a/test/jdk/TEST.groups Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/TEST.groups Sat Mar 09 12:54:20 2019 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -214,8 +214,7 @@
sun/security \
-sun/security/krb5 \
-sun/security/jgss \
- javax/net \
- com/sun/net/ssl
+ javax/net
jdk_security4 = \
com/sun/security/jgss \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMLargeDataKAT.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.GCMParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.MessageDigest;
+import java.util.HashMap;
+
+/*
+ * @test
+ * @bug 8220165
+ * @summary Verify correctness of large data sizes for GCM.
+ */
+
+/**
+ * This test stores the MD5 hash of correctly encrypted AES/GCM data for
+ * particular data lengths. Those lengths are run on SunJCE to verify returns
+ * the same MD5 hash of the encrypted data. These are not NIST data sets or
+ * provided by any other organization. The data sets are known good values,
+ * verified with two different JCE providers (solaris-sparcv9 ucrypto and
+ * linux SunJCE).
+ *
+ * Lengths around 64k are chosen because 64k is the point where
+ * com.sun.crypto.provider.GaloisCounterMode#doLastBlock() starts it's
+ * intrinsic warmup
+ *
+ * Plaintext is all zeros. Preset key and IV.
+ *
+ * The choice of MD5 is for speed. Shortcoming of the algorithm are
+ * not relevant for this test.
+ */
+
+public class GCMLargeDataKAT {
+
+ // Hash of encrypted results of AES/GCM for particular lengths.
+ // <data size, hash>
+ static final HashMap<Integer, String> results = new HashMap<>() {{
+ put(65534, "1397b91c31ce793895edace4e175bfee"); //64k-2
+ put(65535, "4ad101c9f450e686668b3f8f05db96f0"); //64k-1
+ put(65536, "fbfaee3451acd3f603200d6be0f39b24"); //64k
+ put(65537, "e7dfca4a71495c65d20982c3c9b9813f"); //64k+1
+ put(67583, "c8ebdcb3532ec6c165de961341af7635"); //66k-1
+ put(67584, "36559d108dfd25dd29da3fec3455b9e5"); //66k
+ put(67585, "1d21b42d80ea179810744fc23dc228b6"); //66k+1
+ put(102400, "0d1544fcab20bbd4c8103b9d273f2c82"); //100k
+ put(102401, "f2d53ef65fd12d0a861368659b23ea2e"); //100k+1
+ put(102402, "97f0f524cf63d2d9d23d81e64d416ee0"); //100k+2
+ put(102403, "4a6b4af55b7d9016b64114d6813d639c"); //100k+3
+ put(102404, "ba63cc131fcde2f12ddf2ac634201be8"); //100k+4
+ put(102405, "673d05c7fe5e283e42e5c0d049fdcea6"); //100k+5
+ put(102406, "76cc99a7850ce857eb3cb43049cf9877"); //100k+6
+ put(102407, "65863f99072cf2eb7fce18bd78b33f4e"); //100k+7
+ put(102408, "b9184f0f272682cc1f791fa7070eddd4"); //100k+8
+ put(102409, "45fe36afef43cc665bf22a9ca200c3c2"); //100k+9
+ put(102410, "67249e41646edcb37a78a61b0743cf11"); //100k+0
+ put(102411, "ffdc611e29c8849842e81ec78f32c415"); //100k+11
+ put(102412, "b7fde7fd52221057dccc1c181a140125"); //100k+12
+ put(102413, "4b1d6c64d56448105e5613157e69c0ae"); //100k+13
+ put(102414, "6d2c0b26c0c8785c8eec3298a5f0080c"); //100k+14
+ put(102415, "1df2061b114fbe56bdf3717e3ee61ef9"); //100k+15
+ put(102416, "a691742692c683ac9d1254df5fc5f768"); //100k+16
+ }};
+ static final int HIGHLEN = 102416;
+
+ static final int GCM_TAG_LENGTH = 16;
+ static final byte[] iv = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ static final byte[] key_code = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
+ };
+ static final GCMParameterSpec spec =
+ new GCMParameterSpec(GCM_TAG_LENGTH * 8, iv);
+ static final SecretKey key = new SecretKeySpec(key_code, "AES");
+ static boolean testresult = true;
+ static byte[] plaintext = new byte[HIGHLEN];
+ static MessageDigest md5;
+ Cipher cipher;
+
+ GCMLargeDataKAT() {
+ }
+
+ byte[] encrypt(int inLen) {
+ try {
+ cipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
+ cipher.init(Cipher.ENCRYPT_MODE, key, spec);
+ return cipher.doFinal(plaintext, 0, inLen);
+ } catch (Exception e) {
+ System.err.println("Encrypt Failure (length = " + inLen + ") : " +
+ e.getMessage());
+ e.printStackTrace();
+ }
+ return new byte[0];
+ }
+
+ static byte[] hash(byte[] data) {
+ return md5.digest(data);
+ }
+
+ // Decrypt the data and return a boolean if the plaintext is all 0's.
+ boolean decrypt(byte[] data) {
+ byte[] result = null;
+ int len = data.length - GCM_TAG_LENGTH;
+ if (data.length == 0) {
+ return false;
+ }
+ try {
+ cipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
+ cipher.init(Cipher.DECRYPT_MODE, key, spec);
+ result = cipher.doFinal(data);
+ } catch (Exception e) {
+ System.err.println("Decrypt Failure (length = " + len + ") : " +
+ e.getMessage());
+ e.printStackTrace();
+ return false;
+ }
+
+ if (result.length != len) {
+ System.err.println("Decrypt Failure (length = " + len +
+ ") : plaintext length invalid = " + result.length);
+ }
+ // Return false if we find a non zero.
+ int i = 0;
+ while (result.length > i) {
+ if (result[i++] != 0) {
+ System.err.println("Decrypt Failure (length = " + len +
+ ") : plaintext invalid, char index " + i);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ void test() throws Exception {
+
+ // results order is not important
+ for (int l : results.keySet()) {
+ byte[] enc = new GCMLargeDataKAT().encrypt(l);
+
+ // verify hash with stored hash of that length
+ String hashstr = toHex(hash(enc));
+ boolean r = (hashstr.compareTo(results.get(l)) == 0);
+
+ System.out.println("---------------------------------------------");
+
+ // Encrypted test & results
+ System.out.println("Encrypt data size " + l + " \tResult: " +
+ (r ? "Pass" : "Fail"));
+ if (!r) {
+ if (enc.length != 0) {
+ System.out.println("\tExpected: " + results.get(l));
+ System.out.println("\tReturned: " + hashstr);
+ }
+ testresult = false;
+ continue;
+ }
+
+ // Decrypted test & results
+ r = decrypt(enc);
+ System.out.println("Decrypt data size " + l + " \tResult: " +
+ (r ? "Pass" : "Fail"));
+ if (!r) {
+ testresult = false;
+ }
+ }
+
+ // After test complete, throw an error if there was a failure
+ if (!testresult) {
+ throw new Exception("Tests failed");
+ }
+ }
+
+ /**
+ * With no argument, the test will run the predefined data lengths
+ *
+ * With an integer argument, this test will print the hash of the encrypted
+ * data of that integer length.
+ *
+ */
+ public static void main(String args[]) throws Exception {
+ md5 = MessageDigest.getInstance("MD5");
+
+ if (args.length > 0) {
+ int len = Integer.parseInt(args[0]);
+ byte[] e = new GCMLargeDataKAT().encrypt(len);
+ System.out.println(toHex(hash(e)));
+ return;
+ }
+
+ new GCMLargeDataKAT().test();
+ }
+
+ // bytes to hex string
+ static String toHex(byte[] bytes) {
+ StringBuffer hexStringBuffer = new StringBuffer(32);
+ for (int i = 0; i < bytes.length; i++) {
+ hexStringBuffer.append(byteToHex(bytes[i]));
+ }
+ return hexStringBuffer.toString();
+ }
+ // byte to hex
+ static String byteToHex(byte num) {
+ char[] hexDigits = new char[2];
+ hexDigits[0] = Character.forDigit((num >> 4) & 0xF, 16);
+ hexDigits[1] = Character.forDigit((num & 0xF), 16);
+ return new String(hexDigits);
+ }
+}
--- a/test/jdk/com/sun/jdi/JdbStopThreadidTest.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/com/sun/jdi/JdbStopThreadidTest.java Sat Mar 09 12:54:20 2019 +0000
@@ -32,6 +32,7 @@
* @run main/othervm JdbStopThreadidTest
*/
+import jdk.test.lib.process.OutputAnalyzer;
import lib.jdb.Jdb;
import lib.jdb.JdbCommand;
import lib.jdb.JdbTest;
@@ -138,6 +139,7 @@
jdb.command(JdbCommand.cont().waitForPrompt("Breakpoint hit: \"thread=MYTHREAD-2\", \\S+MyThread.brkMethod", true));
// Continue until the application exits. Once again, hitting a breakpoint will cause
// a failure because we are not suppose to hit one.
- jdb.command(JdbCommand.cont().waitForPrompt(Jdb.APPLICATION_EXIT, true));
+ jdb.contToExit(1);
+ new OutputAnalyzer(getJdbOutput()).shouldContain(Jdb.APPLICATION_EXIT);
}
}
--- a/test/jdk/com/sun/jdi/RedefineNestmateAttr/TestNestmateAttr.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/com/sun/jdi/RedefineNestmateAttr/TestNestmateAttr.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -212,6 +212,8 @@
protected void startUp(String targetName) {
List<String> argList = new ArrayList<>(Arrays.asList(args));
argList.add(0, targetName); // pre-pend so it becomes the first "app" arg
+ // We need the class path that contains the path to jdk.test.lib.Asserts.
+ argList.add(0, " -cp " + System.getProperty("test.class.path"));
println("run args: " + argList);
connect((String[]) argList.toArray(args));
waitForVMStart();
--- a/test/jdk/com/sun/net/ssl/SSLSecurity/ComKeyManagerFactoryImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.security.*;
-import com.sun.net.ssl.*;
-
-public class ComKeyManagerFactoryImpl extends KeyManagerFactorySpi {
-
- public ComKeyManagerFactoryImpl() {
- System.out.println("ComKeyManagerFactoryImpl initialized");
- }
-
- protected void engineInit(KeyStore ks, char [] password)
- throws KeyStoreException {
- System.out.println("ComKeyManagerFactoryImpl init'd");
- }
-
- protected KeyManager[] engineGetKeyManagers() {
- return null;
- }
-}
--- a/test/jdk/com/sun/net/ssl/SSLSecurity/ComSSLContextImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.security.*;
-import com.sun.net.ssl.*;
-
-public class ComSSLContextImpl extends SSLContextSpi {
-
- public ComSSLContextImpl() {
- System.out.println("ComSSLContextImpl initialized");
- }
-
- protected void engineInit(KeyManager[] km,
- TrustManager[] tm, SecureRandom sr) throws KeyManagementException {
- System.out.println("ComSSLContextImpl init'd");
- }
-
- protected javax.net.ssl.SSLSocketFactory engineGetSocketFactory() {
- return null;
- }
-
- protected javax.net.ssl.SSLServerSocketFactory
- engineGetServerSocketFactory() {
- return null;
- }
-
-}
--- a/test/jdk/com/sun/net/ssl/SSLSecurity/ComTrustManagerFactoryImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.security.*;
-import com.sun.net.ssl.*;
-
-public class ComTrustManagerFactoryImpl extends TrustManagerFactorySpi {
-
- public ComTrustManagerFactoryImpl() {
- System.out.println("ComTrustManagerFactoryImpl initialized");
- }
-
- protected void engineInit(KeyStore ks) throws KeyStoreException {
- System.out.println("ComTrustManagerFactoryImpl init'd");
- }
-
- protected TrustManager[] engineGetTrustManagers() {
- return null;
- }
-}
--- a/test/jdk/com/sun/net/ssl/SSLSecurity/JavaxKeyManagerFactoryImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.security.*;
-import javax.net.ssl.*;
-
-public class JavaxKeyManagerFactoryImpl extends KeyManagerFactorySpi {
-
- public JavaxKeyManagerFactoryImpl () {
- System.out.println("JavaxKeyManagerFactoryImpl initialized");
- }
-
- protected void engineInit(KeyStore ks, char[] passwd)
- throws KeyStoreException {
- System.out.println("JavaxKeyManagerFactoryImpl init'd");
- }
-
- protected void engineInit(ManagerFactoryParameters spec)
- throws InvalidAlgorithmParameterException {
- }
-
- protected KeyManager[] engineGetKeyManagers() {
- return null;
- }
-}
--- a/test/jdk/com/sun/net/ssl/SSLSecurity/JavaxSSLContextImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.security.*;
-import javax.net.ssl.*;
-
-public class JavaxSSLContextImpl extends SSLContextSpi {
-
- public JavaxSSLContextImpl() {
- System.out.println("JavaxSSLContextImpl initialized");
- }
-
- protected void engineInit(KeyManager[] km,
- TrustManager[] tm, SecureRandom sr) throws KeyManagementException {
- System.out.println("JavaxSSLContextImpl init'd");
- }
-
- protected SSLEngine engineCreateSSLEngine() {
- return null;
- }
-
- protected SSLEngine engineCreateSSLEngine(String host, int port) {
- return null;
- }
-
- protected SSLSocketFactory engineGetSocketFactory() {
- return null;
- }
-
- protected SSLServerSocketFactory engineGetServerSocketFactory() {
- return null;
- }
-
- protected SSLSessionContext engineGetServerSessionContext() {
- return null;
- }
-
- protected SSLSessionContext engineGetClientSessionContext() {
- return null;
- }
-}
--- a/test/jdk/com/sun/net/ssl/SSLSecurity/JavaxTrustManagerFactoryImpl.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.security.*;
-import javax.net.ssl.*;
-
-public class JavaxTrustManagerFactoryImpl extends TrustManagerFactorySpi {
-
- public JavaxTrustManagerFactoryImpl () {
- System.out.println("JavaxTrustManagerFactoryImpl initialized");
- }
-
- protected void engineInit(KeyStore ks) throws KeyStoreException {
- System.out.println("JavaxTrustManagerFactoryImpl init'd");
- }
-
- protected void engineInit(ManagerFactoryParameters spec)
- throws InvalidAlgorithmParameterException {
- }
-
- protected TrustManager[] engineGetTrustManagers() {
- return null;
- }
-}
--- a/test/jdk/com/sun/net/ssl/SSLSecurity/ProviderTest.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 4667976 8130181
- * @modules java.base/com.sun.net.ssl
- * @compile JavaxSSLContextImpl.java ComSSLContextImpl.java
- * JavaxTrustManagerFactoryImpl.java ComTrustManagerFactoryImpl.java
- * JavaxKeyManagerFactoryImpl.java ComKeyManagerFactoryImpl.java
- * @run main/othervm ProviderTest
- * @summary brokenness in the com.sun.net.ssl.SSLSecurity wrappers
- */
-
-import java.security.*;
-import com.sun.net.ssl.*;
-
-public class ProviderTest {
-
- public static void main(String args[]) throws Exception {
- SSLContext sslc;
- TrustManagerFactory tmf;
- KeyManagerFactory kmf;
-
- Provider extraProvider = new MyProvider();
- Security.addProvider(extraProvider);
- try {
- System.out.println("getting a javax SSLContext");
- sslc = SSLContext.getInstance("javax");
- sslc.init(null, null, null);
- System.out.println("\ngetting a com SSLContext");
- sslc = SSLContext.getInstance("com");
- sslc.init(null, null, null);
-
- System.out.println("\ngetting a javax TrustManagerFactory");
- tmf = TrustManagerFactory.getInstance("javax");
- tmf.init((KeyStore) null);
- System.out.println("\ngetting a com TrustManagerFactory");
- tmf = TrustManagerFactory.getInstance("com");
- tmf.init((KeyStore) null);
-
- System.out.println("\ngetting a javax KeyManagerFactory");
- kmf = KeyManagerFactory.getInstance("javax");
- kmf.init((KeyStore) null, null);
- System.out.println("\ngetting a com KeyManagerFactory");
- kmf = KeyManagerFactory.getInstance("com");
- kmf.init((KeyStore) null, null);
- } finally {
- Security.removeProvider(extraProvider.getName());
- }
- }
-}
-
-class MyProvider extends Provider {
-
- private static String info = "Brad's provider";
-
- /**
- * Installs the JSSE provider.
- */
- public static synchronized void install()
- {
- /* nop. Remove this method in the future. */
- }
-
- public MyProvider()
- {
- super("BRAD", "1.0", info);
-
- AccessController.doPrivileged(new java.security.PrivilegedAction() {
- public Object run() {
-
- put("SSLContext.javax", "JavaxSSLContextImpl");
- put("SSLContext.com", "ComSSLContextImpl");
- put("TrustManagerFactory.javax",
- "JavaxTrustManagerFactoryImpl");
- put("TrustManagerFactory.com",
- "ComTrustManagerFactoryImpl");
- put("KeyManagerFactory.javax",
- "JavaxKeyManagerFactoryImpl");
- put("KeyManagerFactory.com",
- "ComKeyManagerFactoryImpl");
-
- return null;
- }
- });
-
- }
-}
--- a/test/jdk/com/sun/net/ssl/SSLSecurity/TruncateArray.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 4665824
- * @summary JSSE - ClassCastException with 1.4
- * @modules java.base/com.sun.net.ssl
- */
-
-import com.sun.net.ssl.*;
-
-public class TruncateArray {
-
- public static void main(String args[]) throws Exception {
- try {
-
- TrustManager tms [] = new TrustManager [] {
- new MyTM(), new MyTM(), new MyTM() };
-
- KeyManager kms [] = new KeyManager [] {
- new MyKM(), new MyKM(), new MyKM() };
-
- SSLContext ctx = SSLContext.getInstance("TLS");
- ctx.init(kms, tms, null);
-
- KeyManagerFactory kmf = KeyManagerFactory.getInstance("SUNX509");
- KeyManager[] km = kmf.getKeyManagers();
-
- TrustManagerFactory tmf =
- TrustManagerFactory.getInstance("SUNX509");
- TrustManager[] tm = tmf.getTrustManagers();
-
- } catch (ClassCastException e) {
- throw e;
- } catch (Throwable e) {
- /*
- * swallow anything else, we only are interested
- * in class casting errors here. For example, we soon
- * may be catching methods called on uninitialized factories.
- */
- System.out.println("Caught something else");
- e.printStackTrace();
- }
- }
-
- static class MyTM implements TrustManager {
- }
-
- static class MyKM implements KeyManager {
- }
-}
--- a/test/jdk/java/lang/SecurityManager/CheckSecurityProvider.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/lang/SecurityManager/CheckSecurityProvider.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@
expected.add("sun.security.rsa.SunRsaSign");
layer.findModule("jdk.crypto.ec")
.ifPresent(m -> expected.add("sun.security.ec.SunEC"));
- expected.add("com.sun.net.ssl.internal.ssl.Provider");
+ expected.add("sun.security.ssl.SunJSSE");
expected.add("com.sun.crypto.provider.SunJCE");
layer.findModule("jdk.security.jgss")
.ifPresent(m -> expected.add("sun.security.jgss.SunProvider"));
--- a/test/jdk/java/lang/StringBuffer/AppendCharSequence.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/lang/StringBuffer/AppendCharSequence.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 4812591 4705328 5019111
+ * @bug 4812591 4705328 5019111 8218228
* @summary Test append and insert methods with CharSequence params
* @key randomness
*/
@@ -230,6 +230,35 @@
throw new RuntimeException("CharSequence constructor failure");
}
}
+ checkNegativeLenCharSeq(-1);
+ checkNegativeLenCharSeq(-16);
+ checkNegativeLenCharSeq(-17);
+ checkNegativeLenCharSeq(Integer.MIN_VALUE);
}
+ // Test constructing from CharSequence of negative length
+ private static void checkNegativeLenCharSeq(int len) {
+ try {
+ CharSequence seq = new MyNegativeLenCharSeq(len);
+ StringBuffer sb = new StringBuffer(seq);
+ } catch (NegativeArraySizeException expected) {
+ } catch (Throwable exc) {
+ throw new RuntimeException("Unexpected: " + exc, exc);
+ }
+ }
+
+ private static class MyNegativeLenCharSeq implements CharSequence {
+ int length;
+ MyNegativeLenCharSeq(int length) {
+ this.length = length;
+ }
+ public char charAt(int i) {
+ throw new UnsupportedOperationException();
+ }
+ public int length() { return length; }
+ public CharSequence subSequence(int st, int e) {
+ throw new UnsupportedOperationException();
+ }
+ public String toString() { return ""; }
+ }
}
--- a/test/jdk/java/nio/Buffer/Basic-X.java.template Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/Basic-X.java.template Sat Mar 09 12:54:20 2019 +0000
@@ -648,7 +648,7 @@
}
}
- // Exceptions in absolute bulk operations
+ // Exceptions in absolute bulk and slice operations
catchNullArgument(b, () -> b.get(7, null, 0, 42));
catchNullArgument(b, () -> b.put(7, ($type$[])null, 0, 42));
@@ -668,6 +668,11 @@
catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1));
catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42));
+ catchIndexOutOfBounds(b, () -> b.slice(-1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(0, -1));
+ catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1));
+
// Values
b.clear();
@@ -832,6 +837,20 @@
+ sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
}
+ int bPos = b.position();
+ int bLim = b.limit();
+
+ b.position(7);
+ b.limit(42);
+ $Type$Buffer rsb = b.slice();
+ b.position(0);
+ b.limit(b.capacity());
+ $Type$Buffer asb = b.slice(7, 35);
+ checkSlice(rsb, asb);
+
+ b.position(bPos);
+ b.limit(bLim);
+
#if[byte]
// Views
--- a/test/jdk/java/nio/Buffer/Basic.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/Basic.java Sat Mar 09 12:54:20 2019 +0000
@@ -25,8 +25,8 @@
* @summary Unit test for buffers
* @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 4490253 4523725
* 4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 5029431
- * 6231529 6221101 6234263 6535542 6591971 6593946 6795561 7190219 7199551
- * 8065556 8149469
+ * 5071718 6231529 6221101 6234263 6535542 6591971 6593946 6795561 7190219
+ * 7199551 8065556 8149469
* @modules java.base/java.nio:open
* java.base/jdk.internal.misc
* @author Mark Reinhold
--- a/test/jdk/java/nio/Buffer/BasicByte.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/BasicByte.java Sat Mar 09 12:54:20 2019 +0000
@@ -648,7 +648,7 @@
}
}
- // Exceptions in absolute bulk operations
+ // Exceptions in absolute bulk and slice operations
catchNullArgument(b, () -> b.get(7, null, 0, 42));
catchNullArgument(b, () -> b.put(7, (byte[])null, 0, 42));
@@ -668,6 +668,11 @@
catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1));
catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42));
+ catchIndexOutOfBounds(b, () -> b.slice(-1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(0, -1));
+ catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1));
+
// Values
b.clear();
@@ -832,6 +837,20 @@
+ sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
}
+ int bPos = b.position();
+ int bLim = b.limit();
+
+ b.position(7);
+ b.limit(42);
+ ByteBuffer rsb = b.slice();
+ b.position(0);
+ b.limit(b.capacity());
+ ByteBuffer asb = b.slice(7, 35);
+ checkSlice(rsb, asb);
+
+ b.position(bPos);
+ b.limit(bLim);
+
// Views
--- a/test/jdk/java/nio/Buffer/BasicChar.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/BasicChar.java Sat Mar 09 12:54:20 2019 +0000
@@ -648,7 +648,7 @@
}
}
- // Exceptions in absolute bulk operations
+ // Exceptions in absolute bulk and slice operations
catchNullArgument(b, () -> b.get(7, null, 0, 42));
catchNullArgument(b, () -> b.put(7, (char[])null, 0, 42));
@@ -668,6 +668,11 @@
catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1));
catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42));
+ catchIndexOutOfBounds(b, () -> b.slice(-1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(0, -1));
+ catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1));
+
// Values
b.clear();
@@ -832,6 +837,20 @@
+ sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
}
+ int bPos = b.position();
+ int bLim = b.limit();
+
+ b.position(7);
+ b.limit(42);
+ CharBuffer rsb = b.slice();
+ b.position(0);
+ b.limit(b.capacity());
+ CharBuffer asb = b.slice(7, 35);
+ checkSlice(rsb, asb);
+
+ b.position(bPos);
+ b.limit(bLim);
+
--- a/test/jdk/java/nio/Buffer/BasicDouble.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/BasicDouble.java Sat Mar 09 12:54:20 2019 +0000
@@ -648,7 +648,7 @@
}
}
- // Exceptions in absolute bulk operations
+ // Exceptions in absolute bulk and slice operations
catchNullArgument(b, () -> b.get(7, null, 0, 42));
catchNullArgument(b, () -> b.put(7, (double[])null, 0, 42));
@@ -668,6 +668,11 @@
catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1));
catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42));
+ catchIndexOutOfBounds(b, () -> b.slice(-1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(0, -1));
+ catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1));
+
// Values
b.clear();
@@ -832,6 +837,20 @@
+ sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
}
+ int bPos = b.position();
+ int bLim = b.limit();
+
+ b.position(7);
+ b.limit(42);
+ DoubleBuffer rsb = b.slice();
+ b.position(0);
+ b.limit(b.capacity());
+ DoubleBuffer asb = b.slice(7, 35);
+ checkSlice(rsb, asb);
+
+ b.position(bPos);
+ b.limit(bLim);
+
--- a/test/jdk/java/nio/Buffer/BasicFloat.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/BasicFloat.java Sat Mar 09 12:54:20 2019 +0000
@@ -648,7 +648,7 @@
}
}
- // Exceptions in absolute bulk operations
+ // Exceptions in absolute bulk and slice operations
catchNullArgument(b, () -> b.get(7, null, 0, 42));
catchNullArgument(b, () -> b.put(7, (float[])null, 0, 42));
@@ -668,6 +668,11 @@
catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1));
catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42));
+ catchIndexOutOfBounds(b, () -> b.slice(-1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(0, -1));
+ catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1));
+
// Values
b.clear();
@@ -832,6 +837,20 @@
+ sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
}
+ int bPos = b.position();
+ int bLim = b.limit();
+
+ b.position(7);
+ b.limit(42);
+ FloatBuffer rsb = b.slice();
+ b.position(0);
+ b.limit(b.capacity());
+ FloatBuffer asb = b.slice(7, 35);
+ checkSlice(rsb, asb);
+
+ b.position(bPos);
+ b.limit(bLim);
+
--- a/test/jdk/java/nio/Buffer/BasicInt.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/BasicInt.java Sat Mar 09 12:54:20 2019 +0000
@@ -648,7 +648,7 @@
}
}
- // Exceptions in absolute bulk operations
+ // Exceptions in absolute bulk and slice operations
catchNullArgument(b, () -> b.get(7, null, 0, 42));
catchNullArgument(b, () -> b.put(7, (int[])null, 0, 42));
@@ -668,6 +668,11 @@
catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1));
catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42));
+ catchIndexOutOfBounds(b, () -> b.slice(-1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(0, -1));
+ catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1));
+
// Values
b.clear();
@@ -832,6 +837,20 @@
+ sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
}
+ int bPos = b.position();
+ int bLim = b.limit();
+
+ b.position(7);
+ b.limit(42);
+ IntBuffer rsb = b.slice();
+ b.position(0);
+ b.limit(b.capacity());
+ IntBuffer asb = b.slice(7, 35);
+ checkSlice(rsb, asb);
+
+ b.position(bPos);
+ b.limit(bLim);
+
--- a/test/jdk/java/nio/Buffer/BasicLong.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/BasicLong.java Sat Mar 09 12:54:20 2019 +0000
@@ -648,7 +648,7 @@
}
}
- // Exceptions in absolute bulk operations
+ // Exceptions in absolute bulk and slice operations
catchNullArgument(b, () -> b.get(7, null, 0, 42));
catchNullArgument(b, () -> b.put(7, (long[])null, 0, 42));
@@ -668,6 +668,11 @@
catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1));
catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42));
+ catchIndexOutOfBounds(b, () -> b.slice(-1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(0, -1));
+ catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1));
+
// Values
b.clear();
@@ -832,6 +837,20 @@
+ sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
}
+ int bPos = b.position();
+ int bLim = b.limit();
+
+ b.position(7);
+ b.limit(42);
+ LongBuffer rsb = b.slice();
+ b.position(0);
+ b.limit(b.capacity());
+ LongBuffer asb = b.slice(7, 35);
+ checkSlice(rsb, asb);
+
+ b.position(bPos);
+ b.limit(bLim);
+
--- a/test/jdk/java/nio/Buffer/BasicShort.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/BasicShort.java Sat Mar 09 12:54:20 2019 +0000
@@ -648,7 +648,7 @@
}
}
- // Exceptions in absolute bulk operations
+ // Exceptions in absolute bulk and slice operations
catchNullArgument(b, () -> b.get(7, null, 0, 42));
catchNullArgument(b, () -> b.put(7, (short[])null, 0, 42));
@@ -668,6 +668,11 @@
catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1));
catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42));
+ catchIndexOutOfBounds(b, () -> b.slice(-1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7));
+ catchIndexOutOfBounds(b, () -> b.slice(0, -1));
+ catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1));
+
// Values
b.clear();
@@ -832,6 +837,20 @@
+ sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
}
+ int bPos = b.position();
+ int bLim = b.limit();
+
+ b.position(7);
+ b.limit(42);
+ ShortBuffer rsb = b.slice();
+ b.position(0);
+ b.limit(b.capacity());
+ ShortBuffer asb = b.slice(7, 35);
+ checkSlice(rsb, asb);
+
+ b.position(bPos);
+ b.limit(bLim);
+
--- a/test/jdk/java/nio/Buffer/ByteBufferViews.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/ByteBufferViews.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -64,6 +64,8 @@
size -> ByteBuffer.allocate(size).position(8).slice()),
Map.entry("ByteBuffer.allocate(size).position(8).slice().duplicate()",
size -> ByteBuffer.allocate(size).position(8).slice().duplicate()),
+ Map.entry("ByteBuffer.allocate(size).slice(8,size-8)",
+ size -> ByteBuffer.allocate(size).slice(8,size-8)),
// Unaligned
Map.entry("ByteBuffer.allocate(size).position(1)",
size -> ByteBuffer.allocate(size).position(1)),
@@ -71,6 +73,8 @@
size -> ByteBuffer.allocate(size).position(1).slice()),
Map.entry("ByteBuffer.allocate(size).position(1).slice().duplicate()",
size -> ByteBuffer.allocate(size).position(1).slice().duplicate()),
+ Map.entry("ByteBuffer.allocate(size).slice(1,size-1)",
+ size -> ByteBuffer.allocate(size).slice(1,size-1)),
// Off-heap
Map.entry("ByteBuffer.allocateDirect(size)",
@@ -82,13 +86,17 @@
size -> ByteBuffer.allocateDirect(size).position(8).slice()),
Map.entry("ByteBuffer.allocateDirect(size).position(8).slice().duplicate()",
size -> ByteBuffer.allocateDirect(size).position(8).slice().duplicate()),
+ Map.entry("ByteBuffer.allocateDirect(size).slice(8,size-8)",
+ size -> ByteBuffer.allocateDirect(size).slice(8,size-8)),
// Unaligned
Map.entry("ByteBuffer.allocateDirect(size).position(1)",
size -> ByteBuffer.allocateDirect(size).position(1)),
Map.entry("ByteBuffer.allocateDirect(size).position(1).slice()",
size -> ByteBuffer.allocateDirect(size).position(1).slice()),
Map.entry("ByteBuffer.allocateDirect(size).position(1).slice().duplicate()",
- size -> ByteBuffer.allocateDirect(size).position(1).slice().duplicate())
+ size -> ByteBuffer.allocateDirect(size).position(1).slice().duplicate()),
+ Map.entry("ByteBuffer.allocateDirect(size).slice(1,size-1)",
+ size -> ByteBuffer.allocateDirect(size).slice(1,size-1))
);
// List of buffer byte order functions
--- a/test/jdk/java/nio/Buffer/StringCharBufferSliceTest.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/nio/Buffer/StringCharBufferSliceTest.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,11 +22,14 @@
*/
/* @test
- * @bug 4997655 7000913
+ * @bug 4997655 5071718 7000913
* @summary (bf) CharBuffer.slice() on wrapped CharSequence results in wrong position
*/
-import java.nio.*;
+import java.nio.CharBuffer;
+import java.nio.InvalidMarkException;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
public class StringCharBufferSliceTest {
public static void main( String[] args) throws Exception {
@@ -40,85 +43,114 @@
CharBuffer buff = CharBuffer.wrap(in);
test(buff, buff.slice());
+ test(buff, buff.slice(0, buff.remaining()));
System.out.println(
">>> StringCharBufferSliceTest-main: testing with new position.");
buff.position(2);
test(buff, buff.slice());
+ test(buff, buff.slice(2, buff.remaining()));
System.out.println(
">>> StringCharBufferSliceTest-main: testing with non zero initial position.");
buff = CharBuffer.wrap(in, 3, in.length());
test(buff, buff.slice());
+ test(buff, buff.slice(0, buff.remaining()));
System.out.println(
">>> StringCharBufferSliceTest-main: testing slice result with get()");
buff.position(4);
buff.limit(7);
- CharBuffer slice = buff.slice();
- for (int i = 0; i < 3; i++) {
- if (slice.get() != buff.get()) {
- throw new RuntimeException("Wrong characters in slice result.");
+ BiConsumer<CharBuffer,CharBuffer> bitest = (b, s) -> {
+ for (int i = 0; i < 3; i++) {
+ if (s.get() != b.get()) {
+ throw new RuntimeException
+ ("Wrong characters in slice result.");
+ }
}
- }
+ };
+ bitest.accept(buff, buff.slice());
+ buff.position(4);
+ bitest.accept(buff, buff.slice(4, 3));
System.out.println(
">>> StringCharBufferSliceTest-main: testing slice result with get(int)");
buff.position(4);
buff.limit(7);
- slice = buff.slice();
- for (int i = 0; i < 3; i++) {
- if (slice.get(i) != buff.get(4 + i)) {
- throw new RuntimeException("Wrong characters in slice result.");
+ bitest = (b, s) -> {
+ for (int i = 0; i < 3; i++) {
+ if (s.get(i) != b.get(4 + i)) {
+ throw new RuntimeException
+ ("Wrong characters in slice result.");
+ }
}
- }
+ };
+ bitest.accept(buff, buff.slice());
+ buff.position(4);
+ bitest.accept(buff, buff.slice(4, 3));
System.out.println(
">>> StringCharBufferSliceTest-main: testing slice with result of slice");
buff.position(0);
buff.limit(buff.capacity());
- slice = buff.slice();
- for (int i=0; i<4; i++) {
- slice.position(i);
- CharBuffer nextSlice = slice.slice();
- if (nextSlice.position() != 0)
- throw new RuntimeException("New buffer's position should be zero");
- if (!nextSlice.equals(slice))
- throw new RuntimeException("New buffer should be equal");
- slice = nextSlice;
- }
+ Consumer<CharBuffer> test = (s) -> {
+ for (int i=0; i<4; i++) {
+ s.position(i);
+ CharBuffer nextSlice = s.slice();
+ if (nextSlice.position() != 0)
+ throw new RuntimeException
+ ("New buffer's position should be zero");
+ if (!nextSlice.equals(s))
+ throw new RuntimeException("New buffer should be equal");
+ s = nextSlice;
+ }
+ };
+ test.accept(buff.slice());
+ test.accept(buff.slice(0, buff.capacity()));
System.out.println(
">>> StringCharBufferSliceTest-main: testing toString.");
buff.position(4);
buff.limit(7);
- slice = buff.slice();
- if (!slice.toString().equals("tes")) {
- throw new RuntimeException("bad toString() after slice(): " + slice.toString());
- }
+ test = (s) -> {
+ if (!s.toString().equals("tes")) {
+ throw new RuntimeException
+ ("bad toString() after slice(): " + s.toString());
+ }
+ };
+ test.accept(buff.slice());
+ test.accept(buff.slice(4, 3));
System.out.println(
">>> StringCharBufferSliceTest-main: testing subSequence.");
buff.position(4);
buff.limit(8);
- slice = buff.slice();
- CharSequence subSeq = slice.subSequence(1, 3);
- if (subSeq.charAt(0) != 'e' || subSeq.charAt(1) != 's') {
- throw new RuntimeException("bad subSequence() after slice(): '" + subSeq + "'");
- }
+ test = (s) -> {
+ CharSequence subSeq = s.subSequence(1, 3);
+ if (subSeq.charAt(0) != 'e' || subSeq.charAt(1) != 's') {
+ throw new RuntimeException
+ ("bad subSequence() after slice(): '" + subSeq + "'");
+ }
+ };
+ test.accept(buff.slice());
+ test.accept(buff.slice(4, 4));
System.out.println(
">>> StringCharBufferSliceTest-main: testing duplicate.");
buff.position(4);
buff.limit(8);
- slice = buff.slice();
- CharBuffer dupe = slice.duplicate();
- if (dupe.charAt(0) != 't' || dupe.charAt(1) != 'e'
- || dupe.charAt(2) != 's' || dupe.charAt(3) != 't') {
- throw new RuntimeException("bad duplicate() after slice(): '" + dupe + "'");
- }
+ test = (s) -> {
+ CharBuffer dupe = s.duplicate();
+ if (dupe.charAt(0) != 't' || dupe.charAt(1) != 'e'
+ || dupe.charAt(2) != 's' || dupe.charAt(3) != 't') {
+ throw new RuntimeException
+ ("bad duplicate() after slice(): '" + dupe + "'");
+ }
+ };
+ test.accept(buff.slice());
+ test.accept(buff.slice(4, 4));
System.out.println(">>> StringCharBufferSliceTest-main: done!");
}
--- a/test/jdk/java/security/BasicPermission/Wildcard.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/security/BasicPermission/Wildcard.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,8 +33,7 @@
* @summary Check that BasicPermission subclasses don't throw exception if name
* contains wildcard character ("*") but does not signify a
* wildcard match
- * @modules java.base/com.sun.net.ssl
- * java.sql
+ * @modules java.sql
*/
public class Wildcard {
@@ -51,6 +50,5 @@
new SQLPermission(wildcard);
new PropertyPermission(wildcard, "read");
new SSLPermission(wildcard);
- new com.sun.net.ssl.SSLPermission(wildcard);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/text/Format/DateFormat/SDFTCKZoneNamesTest.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8218948
+ * @summary TCK tests that check the time zone names between DFS.getZoneStrings()
+ * and SDF.format("z*")
+ * @run main SDFTCKZoneNamesTest
+ */
+import java.text.*;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
+
+public class SDFTCKZoneNamesTest {
+
+ StringBuffer myFormat(Date date, SimpleDateFormat sdf) {
+ String pattern = sdf.toPattern();
+ StringBuffer toAppendTo = new StringBuffer("");
+ boolean inQuote = false;
+ char prevCh = 0;
+ char ch;
+ int count = 0;
+ for (int i = 0; i < pattern.length(); i++) {
+ ch = pattern.charAt(i);
+ if (inQuote) {
+ if (ch == '\'') {
+ inQuote = false;
+ if (count == 0) toAppendTo.append(ch);
+ else count = 0;
+ } else {
+ toAppendTo.append(ch);
+ count++;
+ }
+ } else { // not inQuote
+ if (ch == '\'') {
+ inQuote = true;
+ if (count > 0) {
+ toAppendTo.append(subFormat(prevCh, count, date, sdf));
+ count = 0;
+ prevCh = 0;
+ }
+ } else if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z') {
+ if (ch != prevCh && count > 0) {
+ toAppendTo.append(subFormat(prevCh, count, date, sdf));
+ prevCh = ch;
+ count = 1;
+ } else {
+ if (ch != prevCh) prevCh = ch;
+ count++;
+ }
+ } else if (count > 0) {
+ toAppendTo.append(subFormat(prevCh, count, date, sdf));
+ toAppendTo.append(ch);
+ prevCh = 0;
+ count = 0;
+ } else toAppendTo.append(ch);
+ }
+ }
+ if (count > 0) {
+ toAppendTo.append(subFormat(prevCh, count, date, sdf));
+ }
+ return toAppendTo;
+ }
+
+ private String subFormat(char ch, int count, Date date, SimpleDateFormat sdf)
+ throws IllegalArgumentException {
+ int value = 0;
+ int patternCharIndex = -1;
+ int maxIntCount = 10;
+ String current = "";
+ DateFormatSymbols formatData = sdf.getDateFormatSymbols();
+ Calendar calendar = sdf.getCalendar();
+ calendar.setTime(date);
+ NumberFormat nf = sdf.getNumberFormat();
+ nf.setGroupingUsed(false);
+
+ if ((patternCharIndex = "GyMdkHmsSEDFwWahKz".indexOf(ch)) == -1)
+ throw new IllegalArgumentException("Illegal pattern character " +
+ "'" + ch + "'");
+ switch (patternCharIndex) {
+ case 0: // 'G' - ERA
+ value = calendar.get(Calendar.ERA);
+ current = formatData.getEras()[value];
+ break;
+ case 1: // 'y' - YEAR
+ value = calendar.get(Calendar.YEAR);
+
+ if (count == 2) {
+ // For formatting, if the number of pattern letters is 2,
+ // the year is truncated to 2 digits;
+ current = zeroPaddingNumber(value, 2, 2, nf);
+ } else {
+ // otherwise it is interpreted as a number.
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ }
+
+ break;
+ case 2: // 'M' - MONTH
+ value = calendar.get(Calendar.MONTH);
+ if (count >= 4)
+ // DateFormatSymbols::getMonths spec: "If the language requires different forms for formatting
+ // and stand-alone usages, this method returns month names in the formatting form."
+ // Because of that only formatting cases patterns may be tested. Like, "MMMM yyyy". Wrong
+ // pattern: "MMMM".
+ current = formatData.getMonths()[value];
+ else if (count == 3)
+ // DateFormatSymbols::getShortMonths spec: "If the language requires different forms for formatting
+ // and stand-alone usages, This method returns short month names in the formatting form."
+ // Because of that only formatting cases patterns may be tested. Like, "MMM yyyy". Wrong pattern:
+ // "MMM".
+ current = formatData.getShortMonths()[value];
+ else
+ current = zeroPaddingNumber(value + 1, count, maxIntCount, nf);
+ break;
+ case 3: // 'd' - DATE
+ value = calendar.get(Calendar.DATE);
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 4: // 'k' - HOUR_OF_DAY: 1-based. eg, 23:59 + 1 hour =>> 24:59
+ if ((value = calendar.get(Calendar.HOUR_OF_DAY)) == 0)
+ current = zeroPaddingNumber(
+ calendar.getMaximum(Calendar.HOUR_OF_DAY) + 1,
+ count, maxIntCount, nf);
+ else
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 5: // 'H' - HOUR_OF_DAY:0-based. eg, 23:59 + 1 hour =>> 00:59
+ value = calendar.get(Calendar.HOUR_OF_DAY);
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 6: // 'm' - MINUTE
+ value = calendar.get(Calendar.MINUTE);
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 7: // 's' - SECOND
+ value = calendar.get(Calendar.SECOND);
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 8: // 'S' - MILLISECOND
+ value = calendar.get(Calendar.MILLISECOND);
+ /*
+ if (count > 3)
+ value = value * (int) Math.pow(10, count - 3);
+ else if (count == 2)
+ value = (value + 5) / 10;
+ else if (count == 1)
+ value = (value + 50) / 100;
+ */
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 9: // 'E' - DAY_OF_WEEK
+ value = calendar.get(Calendar.DAY_OF_WEEK);
+ if (count >= 4)
+ current = formatData.getWeekdays()[value];
+ else // count < 4, use abbreviated form if exists
+ current = formatData.getShortWeekdays()[value];
+ break;
+ case 10: // 'D' - DAY_OF_YEAR
+ value = calendar.get(Calendar.DAY_OF_YEAR);
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 11: // 'F' - DAY_OF_WEEK_IN_MONTH
+ value = calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH);
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 12: // 'w' - WEEK_OF_YEAR
+ value = calendar.get(Calendar.WEEK_OF_YEAR);
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 13: // 'W' - WEEK_OF_MONTH
+ value = calendar.get(Calendar.WEEK_OF_MONTH);
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 14: // 'a' - AM_PM
+ value = calendar.get(Calendar.AM_PM);
+ current = formatData.getAmPmStrings()[value];
+ break;
+ case 15: // 'h' - HOUR:1-based. eg, 11PM + 1 hour =>> 12 AM
+ if ((value = calendar.get(Calendar.HOUR)) == 0)
+ current = zeroPaddingNumber(
+ calendar.getLeastMaximum(Calendar.HOUR) + 1,
+ count, maxIntCount, nf);
+ else
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 16: // 'K' - HOUR: 0-based. eg, 11PM + 1 hour =>> 0 AM
+ value = calendar.get(Calendar.HOUR);
+ current = zeroPaddingNumber(value, count, maxIntCount, nf);
+ break;
+ case 17: // 'z' - ZONE_OFFSET
+ int zoneIndex = getZoneIndex(calendar.getTimeZone().getID(), formatData);
+ if (zoneIndex == -1) {
+ StringBuffer zoneString = new StringBuffer();
+ value = calendar.get(Calendar.ZONE_OFFSET)
+ + calendar.get(Calendar.DST_OFFSET);
+ if (value < 0) {
+ zoneString.append("GMT-");
+ value = -value; // suppress the '-' sign for text display.
+ } else
+ zoneString.append("GMT+");
+ zoneString.append(
+ zeroPaddingNumber((int) (value / (60 * 60 * 1000)), 2, 2, nf));
+ zoneString.append(':');
+ zoneString.append(
+ zeroPaddingNumber(
+ (int) ((value % (60 * 60 * 1000)) / (60 * 1000)), 2, 2, nf));
+ current = zoneString.toString();
+ } else if (calendar.get(Calendar.DST_OFFSET) != 0) {
+ if (count >= 4)
+ current = formatData.getZoneStrings()[zoneIndex][3];
+ else
+ // count < 4, use abbreviated form if exists
+ current = formatData.getZoneStrings()[zoneIndex][4];
+ } else {
+ if (count >= 4)
+ current = formatData.getZoneStrings()[zoneIndex][1];
+ else
+ current = formatData.getZoneStrings()[zoneIndex][2];
+ }
+ break;
+ }
+
+ return current;
+ }
+
+
+ String zeroPaddingNumber(long value, int minDigits, int maxDigits,
+ NumberFormat nf) {
+ nf.setMinimumIntegerDigits(minDigits);
+ nf.setMaximumIntegerDigits(maxDigits);
+ return nf.format(value);
+ }
+
+
+ int getZoneIndex(String ID, DateFormatSymbols dfs) {
+ String[][] zoneStrings = dfs.getZoneStrings();
+
+ for (int index = 0; index < zoneStrings.length; index++) {
+ if (ID.equalsIgnoreCase(zoneStrings[index][0])) return index;
+ }
+ return -1;
+ }
+
+
+ final int second = 1000;
+ final int minute = 60 * second;
+ final int hour = 60 * minute;
+ final int day = 24 * hour;
+ final int month = 30 * day;
+ final int year = 365 * day;
+ final int someday = 30 * year + 3 * month + 19 * day + 5 * hour;
+
+
+ /* standalone interface */
+ public static void main(String argv[]) {
+ Locale defaultLocale = Locale.getDefault();
+ SDFTCKZoneNamesTest test = new SDFTCKZoneNamesTest();
+
+ try {
+ List.of(Locale.ROOT,
+ Locale.CHINA,
+ Locale.forLanguageTag("es-419"),
+ Locale.GERMANY,
+ Locale.forLanguageTag("hi-IN"),
+ Locale.JAPAN,
+ Locale.TAIWAN,
+ Locale.UK,
+ Locale.US,
+ Locale.forLanguageTag("uz-Cyrl-UZ"),
+ Locale.forLanguageTag("zh-SG"),
+ Locale.forLanguageTag("zh-HK"),
+ Locale.forLanguageTag("zh-MO")).stream()
+ .forEach(l -> {
+ System.out.printf("Testing locale: %s%n", l);
+ Locale.setDefault(l);
+ test.SimpleDateFormat0062();
+ });
+ } finally {
+ Locale.setDefault(defaultLocale);
+ }
+ }
+
+
+ /**
+ * Equivalence class partitioning
+ * with state, input and output values orientation
+ * for public StringBuffer format(Date date, StringBuffer result, FieldPosition fp),
+ * <br><b>pre-conditions</b>: patterns: { "'s0mething'z mm::hh,yyyy zz",
+ * "zzzz",
+ * "z"} (each pattern contains letter for TIMEZONE_FIELD),
+ * <br><b>date</b>: a Date object
+ * <br><b>result</b>: a string
+ * <br><b>fp</b>: a FieldPosition object with TIMEZONE_FIELD field
+ * <br><b>output</b>: formatted date as expected.
+ */
+ public void SimpleDateFormat0062() {
+ boolean passed = true;
+ String patterns[] = {"'s0mething'z mm::hh,yyyy zz",
+ "zzzz",
+ "z"};
+ SimpleDateFormat sdf = new SimpleDateFormat();
+ Date date = new Date(1234567890);
+ for (String[] tz : sdf.getDateFormatSymbols().getZoneStrings()) {
+ sdf.setTimeZone(TimeZone.getTimeZone(tz[0]));
+ for (int i = 0; i < patterns.length && passed; i++) {
+ StringBuffer result = new StringBuffer("qwerty");
+ FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD);
+ sdf.applyPattern(patterns[i]);
+ String expected = new
+ StringBuffer("qwerty").append(myFormat(date,
+ sdf)).toString();
+ String formatted = sdf.format(date, result, fp).toString();
+
+ if (!expected.equals(formatted)) {
+ System.out.println(
+ "method format(date, StringBuffer, FieldPosition) formats wrong");
+ System.out.println(" pattern: " + patterns[i]);
+ System.out.println(" time zone ID: " + tz[0]);
+ System.out.println(" expected result: " + expected);
+ System.out.println(" formatted result: " + formatted);
+ passed = false;
+ }
+
+ if (passed && !expected.equals(result.toString())) {
+ System.out.println(
+ "method format(Date date, StringBuffer toAppendTo, FieldPosition fp) toAppendTo is not " +
+ "equal to output");
+ System.out.println(" pattern: " + patterns[i]);
+ System.out.println(" time zone ID: " + tz[0]);
+ System.out.println(" toAppendTo : " + result);
+ System.out.println(" formatted date: " + formatted);
+ passed = false;
+ }
+ }
+ }
+ if(passed)
+ {
+ System.out.println("PASSED : OKAY");
+ }else
+ {
+ throw new RuntimeException("FAILED");
+ }
+ }
+}
--- a/test/jdk/java/util/Calendar/JapaneseEraNameTest.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/java/util/Calendar/JapaneseEraNameTest.java Sat Mar 09 12:54:20 2019 +0000
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8202088 8207152 8217609
+ * @bug 8202088 8207152 8217609 8219890
* @summary Test the localized Japanese new era name (May 1st. 2019-)
* is retrieved no matter CLDR provider contains the name or not.
* @modules jdk.localedata
@@ -53,8 +53,10 @@
// type, locale, name
{ LONG, JAPAN, "\u5143\u53f7" }, // NewEra
{ LONG, US, "NewEra" },
+ { LONG, CHINA, "NewEra" },
{ SHORT, JAPAN, "\u5143\u53f7" },
{ SHORT, US, "NewEra" },
+ { SHORT, CHINA, "N" },
};
}
--- a/test/jdk/javax/net/ssl/FixingJavadocs/ComURLNulls.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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 4387882 4451038
- * @summary Need to revisit the javadocs for JSSE, especially the
- * promoted classes, and HttpsURLConnection.getCipherSuite throws
- * NullPointerException
- * @modules java.base/com.sun.net.ssl
- * java.base/com.sun.net.ssl.internal.www.protocol.https
- * @run main/othervm ComURLNulls
- *
- * SunJSSE does not support dynamic system properties, no way to re-use
- * system properties in samevm/agentvm mode.
- * @author Brad Wetmore
- */
-
-import java.net.*;
-import java.io.*;
-import javax.net.ssl.*;
-import com.sun.net.ssl.HttpsURLConnection;
-import com.sun.net.ssl.HostnameVerifier;
-
-/*
- * Tests that the com null argument changes made it in ok.
- */
-
-public class ComURLNulls {
-
- private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory {
- private static String SUPPORTED_PROTOCOL = "https";
-
- public URLStreamHandler createURLStreamHandler(String protocol) {
- if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL))
- return null;
-
- return new com.sun.net.ssl.internal.www.protocol.https.Handler();
- }
- }
-
- public static void main(String[] args) throws Exception {
- HostnameVerifier reservedHV =
- HttpsURLConnection.getDefaultHostnameVerifier();
- try {
- URL.setURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory());
-
- /**
- * This test does not establish any connection to the specified
- * URL, hence a dummy URL is used.
- */
- URL foobar = new URL("https://example.com/");
-
- HttpsURLConnection urlc =
- (HttpsURLConnection) foobar.openConnection();
-
- try {
- urlc.getCipherSuite();
- } catch (IllegalStateException e) {
- System.out.print("Caught proper exception: ");
- System.out.println(e.getMessage());
- }
-
- try {
- urlc.getServerCertificates();
- } catch (IllegalStateException e) {
- System.out.print("Caught proper exception: ");
- System.out.println(e.getMessage());
- }
-
- try {
- urlc.setDefaultHostnameVerifier(null);
- } catch (IllegalArgumentException e) {
- System.out.print("Caught proper exception: ");
- System.out.println(e.getMessage());
- }
-
- try {
- urlc.setHostnameVerifier(null);
- } catch (IllegalArgumentException e) {
- System.out.print("Caught proper exception: ");
- System.out.println(e.getMessage());
- }
-
- try {
- urlc.setDefaultSSLSocketFactory(null);
- } catch (IllegalArgumentException e) {
- System.out.print("Caught proper exception: ");
- System.out.println(e.getMessage());
- }
-
- try {
- urlc.setSSLSocketFactory(null);
- } catch (IllegalArgumentException e) {
- System.out.print("Caught proper exception");
- System.out.println(e.getMessage());
- }
- System.out.println("TESTS PASSED");
- } finally {
- HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
- }
- }
-}
--- a/test/jdk/javax/net/ssl/GetInstance.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/javax/net/ssl/GetInstance.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* 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,6 @@
* @summary verify getInstance() works using Provider.getService()
* Export "PKIX" as the standard algorithm name of KeyManagerFactory
* @author Andreas Sterbenz
- * @modules java.base/com.sun.net.ssl
*/
import java.security.*;
@@ -113,38 +112,7 @@
tmf = TrustManagerFactory.getInstance("X.509", p);
same(p, tmf.getProvider());
- testComSun();
-
long stop = System.currentTimeMillis();
System.out.println("Done (" + (stop - start) + " ms).");
}
-
- private static void testComSun() throws Exception {
- Provider p = Security.getProvider("SunJSSE");
-
- com.sun.net.ssl.SSLContext context;
- context = com.sun.net.ssl.SSLContext.getInstance("SSL");
- same(p, context.getProvider());
- context = com.sun.net.ssl.SSLContext.getInstance("SSL", "SunJSSE");
- same(p, context.getProvider());
- context = com.sun.net.ssl.SSLContext.getInstance("SSL", p);
- same(p, context.getProvider());
-
- com.sun.net.ssl.KeyManagerFactory kmf;
- kmf = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509");
- same(p, kmf.getProvider());
- kmf = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509", "SunJSSE");
- same(p, kmf.getProvider());
- kmf = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509", p);
- same(p, kmf.getProvider());
-
- com.sun.net.ssl.TrustManagerFactory tmf;
- tmf = com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509");
- same(p, tmf.getProvider());
- tmf = com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509", "SunJSSE");
- same(p, tmf.getProvider());
- tmf = com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509", p);
- same(p, tmf.getProvider());
- }
-
}
--- a/test/jdk/javax/net/ssl/SSLSession/CheckMyTrustedKeystore.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,407 +0,0 @@
-/*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-// SunJSSE does not support dynamic system properties, no way to re-use
-// system properties in samevm/agentvm mode.
-
-/*
- * @test
- * @bug 4329114
- * @summary Need better way of reflecting the reason when a chain is
- * rejected as untrusted.
- * @modules java.base/com.sun.net.ssl
- * @ignore JSSE supports algorithm constraints with CR 6916074,
- * need to update this test case in JDK 7 soon
- * @run main/othervm CheckMyTrustedKeystore
- *
- * @author Brad Wetmore
- */
-
-// This is a serious hack job!
-
-import java.io.*;
-import java.net.*;
-import java.security.*;
-import javax.net.ssl.*;
-import java.security.cert.*;
-
-public class CheckMyTrustedKeystore {
-
- /*
- * =============================================================
- * Set the various variables needed for the tests, then
- * specify what tests to run on each side.
- */
-
- /*
- * Should we run the client or server in a separate thread?
- * Both sides can throw exceptions, but do you have a preference
- * as to which side should be the main thread.
- */
- static boolean separateServerThread = true;
-
- /*
- * Where do we find the keystores?
- */
- final static String pathToStores = "../etc";
- final static String keyStoreFile = "keystore";
- final static String trustStoreFile = "truststore";
- final static String unknownStoreFile = "unknown_keystore";
- final static String passwd = "passphrase";
- final static char[] cpasswd = "passphrase".toCharArray();
-
- /*
- * Is the server ready to serve?
- */
- volatile static boolean serverReady = false;
-
- /*
- * Turn on SSL debugging?
- */
- final static boolean debug = false;
-
- /*
- * If the client or server is doing some kind of object creation
- * that the other side depends on, and that thread prematurely
- * exits, you may experience a hang. The test harness will
- * terminate all hung threads after its timeout has expired,
- * currently 3 minutes by default, but you might try to be
- * smart about it....
- */
-
- /*
- * Define the server side of the test.
- *
- * If the server prematurely exits, serverReady will be set to true
- * to avoid infinite hangs.
- */
- void doServerSide() throws Exception {
- KeyStore ks = KeyStore.getInstance("JKS");
- com.sun.net.ssl.SSLContext ctx =
- com.sun.net.ssl.SSLContext.getInstance("TLS");
- com.sun.net.ssl.KeyManagerFactory kmf =
- com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509");
-
- ks.load(new FileInputStream(keyFilename), cpasswd);
- kmf.init(ks, cpasswd);
-
- com.sun.net.ssl.TrustManager [] tms =
- new com.sun.net.ssl.TrustManager []
- { new MyComX509TrustManager() };
-
- ctx.init(kmf.getKeyManagers(), tms, null);
-
- SSLServerSocketFactory sslssf =
- (SSLServerSocketFactory) ctx.getServerSocketFactory();
-
- SSLServerSocket sslServerSocket =
- (SSLServerSocket) sslssf.createServerSocket(serverPort);
- serverPort = sslServerSocket.getLocalPort();
-
- sslServerSocket.setNeedClientAuth(true);
-
- /*
- * Create using the other type.
- */
- SSLContext ctx1 =
- SSLContext.getInstance("TLS");
- KeyManagerFactory kmf1 =
- KeyManagerFactory.getInstance("SunX509");
-
- TrustManager [] tms1 =
- new TrustManager []
- { new MyJavaxX509TrustManager() };
-
- kmf1.init(ks, cpasswd);
-
- ctx1.init(kmf1.getKeyManagers(), tms1, null);
-
- sslssf = (SSLServerSocketFactory) ctx1.getServerSocketFactory();
-
- SSLServerSocket sslServerSocket1 =
- (SSLServerSocket) sslssf.createServerSocket(serverPort1);
- serverPort1 = sslServerSocket1.getLocalPort();
- sslServerSocket1.setNeedClientAuth(true);
-
- /*
- * Signal Client, we're ready for his connect.
- */
- serverReady = true;
-
- SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
- sslServerSocket.close();
- serverReady = false;
-
- InputStream sslIS = sslSocket.getInputStream();
- OutputStream sslOS = sslSocket.getOutputStream();
-
- sslIS.read();
- sslOS.write(85);
- sslOS.flush();
- sslSocket.close();
-
- sslSocket = (SSLSocket) sslServerSocket1.accept();
- sslIS = sslSocket.getInputStream();
- sslOS = sslSocket.getOutputStream();
-
- sslIS.read();
- sslOS.write(85);
- sslOS.flush();
- sslSocket.close();
-
- System.out.println("Server exiting!");
- System.out.flush();
- }
-
- void doTest(SSLSocket sslSocket) throws Exception {
- InputStream sslIS = sslSocket.getInputStream();
- OutputStream sslOS = sslSocket.getOutputStream();
-
- System.out.println(" Writing");
- sslOS.write(280);
- sslOS.flush();
- System.out.println(" Reading");
- sslIS.read();
-
- sslSocket.close();
- }
-
- /*
- * Define the client side of the test.
- *
- * If the server prematurely exits, serverReady will be set to true
- * to avoid infinite hangs.
- */
- void doClientSide() throws Exception {
-
- /*
- * Wait for server to get started.
- */
- while (!serverReady) {
- Thread.sleep(50);
- }
-
- /*
- * See if an unknown keystore actually gets checked ok.
- */
- System.out.println("==============");
- System.out.println("Starting test0");
- KeyStore uks = KeyStore.getInstance("JKS");
- SSLContext ctx =
- SSLContext.getInstance("TLS");
- KeyManagerFactory kmf =
- KeyManagerFactory.getInstance("SunX509");
-
- uks.load(new FileInputStream(unknownFilename), cpasswd);
- kmf.init(uks, cpasswd);
-
- TrustManager [] tms = new TrustManager []
- { new MyJavaxX509TrustManager() };
-
- ctx.init(kmf.getKeyManagers(), tms, null);
-
- SSLSocketFactory sslsf =
- (SSLSocketFactory) ctx.getSocketFactory();
-
- System.out.println("Trying first socket " + serverPort);
- SSLSocket sslSocket = (SSLSocket)
- sslsf.createSocket("localhost", serverPort);
-
- doTest(sslSocket);
-
- /*
- * Now try the other way.
- */
- com.sun.net.ssl.SSLContext ctx1 =
- com.sun.net.ssl.SSLContext.getInstance("TLS");
- com.sun.net.ssl.KeyManagerFactory kmf1 =
- com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509");
- kmf1.init(uks, cpasswd);
-
- com.sun.net.ssl.TrustManager [] tms1 =
- new com.sun.net.ssl.TrustManager []
- { new MyComX509TrustManager() };
-
- ctx1.init(kmf1.getKeyManagers(), tms1, null);
-
- sslsf = (SSLSocketFactory) ctx1.getSocketFactory();
-
- System.out.println("Trying second socket " + serverPort1);
- sslSocket = (SSLSocket) sslsf.createSocket("localhost",
- serverPort1);
-
- doTest(sslSocket);
- System.out.println("Completed test1");
- }
-
- /*
- * =============================================================
- * The remainder is just support stuff
- */
-
- int serverPort = 0;
- int serverPort1 = 0;
-
- volatile Exception serverException = null;
- volatile Exception clientException = null;
-
- final static String keyFilename =
- System.getProperty("test.src", "./") + "/" + pathToStores +
- "/" + keyStoreFile;
- final static String unknownFilename =
- System.getProperty("test.src", "./") + "/" + pathToStores +
- "/" + unknownStoreFile;
-
- public static void main(String[] args) throws Exception {
-
- if (debug)
- System.setProperty("javax.net.debug", "all");
-
- /*
- * Start the tests.
- */
- new CheckMyTrustedKeystore();
- }
-
- Thread clientThread = null;
- Thread serverThread = null;
-
- /*
- * Primary constructor, used to drive remainder of the test.
- *
- * Fork off the other side, then do your work.
- */
- CheckMyTrustedKeystore() throws Exception {
- if (separateServerThread) {
- startServer(true);
- startClient(false);
- } else {
- startClient(true);
- startServer(false);
- }
-
- /*
- * Wait for other side to close down.
- */
- if (separateServerThread) {
- serverThread.join();
- } else {
- clientThread.join();
- }
-
- /*
- * When we get here, the test is pretty much over.
- *
- * If the main thread excepted, that propagates back
- * immediately. If the other thread threw an exception, we
- * should report back.
- */
- if (serverException != null) {
- System.out.print("Server Exception:");
- throw serverException;
- }
- if (clientException != null) {
- System.out.print("Client Exception:");
- throw clientException;
- }
- }
-
- void startServer(boolean newThread) throws Exception {
- if (newThread) {
- serverThread = new Thread() {
- public void run() {
- try {
- doServerSide();
- } catch (Exception e) {
- /*
- * Our server thread just died.
- *
- * Release the client, if not active already...
- */
- System.err.println("Server died...");
- serverReady = true;
- serverException = e;
- }
- }
- };
- serverThread.start();
- } else {
- doServerSide();
- }
- }
-
- void startClient(boolean newThread) throws Exception {
- if (newThread) {
- clientThread = new Thread() {
- public void run() {
- try {
- doClientSide();
- } catch (Exception e) {
- /*
- * Our client thread just died.
- */
- System.err.println("Client died...");
- clientException = e;
- }
- }
- };
- clientThread.start();
- } else {
- doClientSide();
- }
- }
-}
-
-class MyComX509TrustManager implements com.sun.net.ssl.X509TrustManager {
-
- public X509Certificate[] getAcceptedIssuers() {
- return (new X509Certificate[0]);
- }
-
- public boolean isClientTrusted(X509Certificate[] chain) {
- System.out.println(" IsClientTrusted?");
- return true;
- }
-
- public boolean isServerTrusted(X509Certificate[] chain) {
- System.out.println(" IsServerTrusted?");
- return true;
- }
-}
-
-class MyJavaxX509TrustManager implements X509TrustManager {
-
- public X509Certificate[] getAcceptedIssuers() {
- return (new X509Certificate[0]);
- }
-
- public void checkClientTrusted(X509Certificate[] chain, String authType)
- throws CertificateException {
- System.out.println(" CheckClientTrusted(" + authType + ")?");
- }
-
- public void checkServerTrusted(X509Certificate[] chain, String authType)
- throws CertificateException {
- System.out.println(" CheckServerTrusted(" + authType + ")?");
- }
-}
--- a/test/jdk/javax/xml/crypto/dsig/GenerationTests.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/javax/xml/crypto/dsig/GenerationTests.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
/**
* @test
* @bug 4635230 6283345 6303830 6824440 6867348 7094155 8038184 8038349 8046949
- * 8046724 8079693 8177334 8205507 8210736
+ * 8046724 8079693 8177334 8205507 8210736 8217878
* @summary Basic unit tests for generating XML Signatures with JSR 105
* @modules java.base/sun.security.util
* java.base/sun.security.x509
@@ -126,8 +126,12 @@
private final static String CRL =
DATA_DIR + System.getProperty("file.separator") + "certs" +
System.getProperty("file.separator") + "crl";
+ // XML Document with a DOCTYPE declaration
private final static String ENVELOPE =
DATA_DIR + System.getProperty("file.separator") + "envelope.xml";
+ // XML Document without a DOCTYPE declaration
+ private final static String ENVELOPE2 =
+ DATA_DIR + System.getProperty("file.separator") + "envelope2.xml";
private static URIDereferencer httpUd = null;
private final static String STYLESHEET =
"http://www.w3.org/TR/xml-stylesheet";
@@ -328,6 +332,10 @@
test_create_signature_reference_dependency();
test_create_signature_with_attr_in_no_namespace();
test_create_signature_with_empty_id();
+ test_create_signature_enveloping_over_doc(ENVELOPE, true);
+ test_create_signature_enveloping_over_doc(ENVELOPE2, true);
+ test_create_signature_enveloping_over_doc(ENVELOPE, false);
+ test_create_signature_enveloping_dom_level1();
// run tests for detached signatures with local http server
try (Http server = Http.startServer()) {
@@ -1038,6 +1046,109 @@
"signature", null);
DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA", 512), doc);
sig.sign(dsc);
+
+ System.out.println();
+ }
+
+ static void test_create_signature_enveloping_over_doc(String filename,
+ boolean pass) throws Exception
+ {
+ System.out.println("* Generating signature-enveloping-over-doc.xml");
+
+ // create reference
+ Reference ref = fac.newReference("#object", sha256);
+
+ // create SignedInfo
+ SignedInfo si = fac.newSignedInfo(withoutComments, rsaSha256,
+ Collections.singletonList(ref));
+
+ // create object
+ Document doc = null;
+ try (FileInputStream fis = new FileInputStream(filename)) {
+ doc = db.parse(fis);
+ }
+ DOMStructure ds = pass ? new DOMStructure(doc.getDocumentElement())
+ : new DOMStructure(doc);
+ XMLObject obj = fac.newXMLObject(Collections.singletonList(ds),
+ "object", null, "UTF-8");
+
+ // This creates an enveloping signature over the entire XML Document
+ XMLSignature sig = fac.newXMLSignature(si, rsa,
+ Collections.singletonList(obj),
+ "signature", null);
+ DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA", 1024), doc);
+ try {
+ sig.sign(dsc);
+ if (!pass) {
+ // A Document node can only exist at the root of the doc so this
+ // should fail
+ throw new Exception("Test unexpectedly passed");
+ }
+ } catch (Exception e) {
+ if (!pass) {
+ System.out.println("Test failed as expected: " + e);
+ } else {
+ throw e;
+ }
+ }
+
+ if (pass) {
+ DOMValidateContext dvc = new DOMValidateContext
+ (getPublicKey("RSA", 1024), doc.getDocumentElement());
+ XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
+
+ if (sig.equals(sig2) == false) {
+ throw new Exception
+ ("Unmarshalled signature is not equal to generated signature");
+ }
+ if (sig2.validate(dvc) == false) {
+ throw new Exception("Validation of generated signature failed");
+ }
+ }
+
+ System.out.println();
+ }
+
+ static void test_create_signature_enveloping_dom_level1() throws Exception {
+ System.out.println("* Generating signature-enveloping-dom-level1.xml");
+
+ // create reference
+ Reference ref = fac.newReference("#object", sha256);
+
+ // create SignedInfo
+ SignedInfo si = fac.newSignedInfo(withoutComments, rsaSha256,
+ Collections.singletonList(ref));
+
+ // create object using DOM Level 1 methods
+ Document doc = db.newDocument();
+ Element child = doc.createElement("Child");
+ child.setAttribute("Version", "1.0");
+ child.setAttribute("Id", "child");
+ child.setIdAttribute("Id", true);
+ child.appendChild(doc.createComment("Comment"));
+ XMLObject obj = fac.newXMLObject(
+ Collections.singletonList(new DOMStructure(child)),
+ "object", null, "UTF-8");
+
+ XMLSignature sig = fac.newXMLSignature(si, rsa,
+ Collections.singletonList(obj),
+ "signature", null);
+ DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA", 1024), doc);
+ sig.sign(dsc);
+
+ DOMValidateContext dvc = new DOMValidateContext
+ (getPublicKey("RSA", 1024), doc.getDocumentElement());
+ XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
+
+ if (sig.equals(sig2) == false) {
+ throw new Exception
+ ("Unmarshalled signature is not equal to generated signature");
+ }
+ if (sig2.validate(dvc) == false) {
+ throw new Exception("Validation of generated signature failed");
+ }
+
+ System.out.println();
}
static void test_create_signature() throws Exception {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/xml/crypto/dsig/data/envelope2.xml Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Preamble -->
+<Envelope xmlns:foo="http://example.org/foo" xmlns="http://example.org/usps">
+ <DearSir>foo</DearSir>
+ <Body>bar</Body>
+ <YoursSincerely>
+ </YoursSincerely>
+ <PostScript>bar</PostScript>
+ <Notaries xmlns="" Id="notaries">
+ <Notary name="Great, A. T." />
+ <Notary name="Hun, A. T." />
+ </Notaries>
+ <!-- Commentary -->
+</Envelope>
+<!-- Postamble -->
--- a/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest Sat Mar 09 12:54:20 2019 +0000
@@ -1,4 +1,4 @@
-FROM oraclelinux:7.2
+FROM oraclelinux:7.6
MAINTAINER mikhailo.seledtsov@oracle.com
COPY /jdk /jdk
--- a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
*/
package jdk.jfr.jvm;
+import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -54,48 +55,66 @@
private static final CharSequence LOG_FILE_EXTENSION = ".log";
private static final CharSequence JFR_FILE_EXTENSION = ".jfr";
- static class Crasher {
+ static class CrasherIllegalAccess {
public static void main(String[] args) {
Unsafe.getUnsafe().putInt(0L, 0);
}
}
- public static void main(String[] args) throws Exception {
- processOutput(runProcess());
+ static class CrasherHalt {
+ public static void main(String[] args) {
+ System.out.println("Running Runtime.getRuntime.halt");
+ Runtime.getRuntime().halt(17);
+ }
+ }
+
+ static class CrasherSig {
+ public static void main(String[] args) throws Exception {
+ String signalName = args[0];
+ System.out.println("Sending SIG" + signalName + " to process " + ProcessHandle.current().pid());
+ Runtime.getRuntime().exec("kill -" + signalName + " " + ProcessHandle.current().pid()).waitFor();
+ }
}
- private static OutputAnalyzer runProcess() throws Exception {
- return new OutputAnalyzer(
- ProcessTools.createJavaProcessBuilder(true,
+ public static void main(String[] args) throws Exception {
+ verify(runProcess(CrasherIllegalAccess.class.getName(), ""));
+ verify(runProcess(CrasherHalt.class.getName(), ""));
+
+ // Verification is excluded for the test case below until 8219680 is fixed
+ long pid = runProcess(CrasherSig.class.getName(), "FPE");
+ // @ignore 8219680
+ // verify(pid);
+ }
+
+ private static long runProcess(String crasher, String signal) throws Exception {
+ System.out.println("Test case for crasher " + crasher);
+ Process p = ProcessTools.createJavaProcessBuilder(true,
"-Xmx64m",
- "-Xint",
"-XX:-CreateCoredumpOnCrash",
"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
- "-XX:StartFlightRecording=dumponexit=true",
- Crasher.class.getName()).start());
+ "-XX:StartFlightRecording",
+ crasher,
+ signal)
+ .start();
+
+ OutputAnalyzer output = new OutputAnalyzer(p);
+ System.out.println("========== Crasher process output:");
+ System.out.println(output.getOutput());
+ System.out.println("==================================");
+
+ return p.pid();
}
- private static void processOutput(OutputAnalyzer output) throws Exception {
- output.shouldContain("CreateCoredumpOnCrash turned off, no core file dumped");
+ private static void verify(long pid) throws IOException {
+ String fileName = "hs_err_pid" + pid + ".jfr";
+ Path file = Paths.get(fileName).toAbsolutePath().normalize();
- final Path jfrEmergencyFilePath = getHsErrJfrPath(output);
- Asserts.assertTrue(Files.exists(jfrEmergencyFilePath), "No emergency jfr recording file " + jfrEmergencyFilePath + " exists");
- Asserts.assertNotEquals(Files.size(jfrEmergencyFilePath), 0L, "File length 0. Should at least be some bytes");
- System.out.printf("File size=%d%n", Files.size(jfrEmergencyFilePath));
+ Asserts.assertTrue(Files.exists(file), "No emergency jfr recording file " + file + " exists");
+ Asserts.assertNotEquals(Files.size(file), 0L, "File length 0. Should at least be some bytes");
+ System.out.printf("File size=%d%n", Files.size(file));
- List<RecordedEvent> events = RecordingFile.readAllEvents(jfrEmergencyFilePath);
+ List<RecordedEvent> events = RecordingFile.readAllEvents(file);
Asserts.assertFalse(events.isEmpty(), "No event found");
System.out.printf("Found event %s%n", events.get(0).getEventType().getName());
}
-
- private static Path getHsErrJfrPath(OutputAnalyzer output) throws Exception {
- // extract to find hs-err_pid log file location
- final String hs_err_pid_log_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
- if (hs_err_pid_log_file == null) {
- throw new RuntimeException("Did not find hs_err_pid.log file in output.\n");
- }
- // the dumped out jfr file should have the same name and location but with a .jfr extension
- final String hs_err_pid_jfr_file = hs_err_pid_log_file.replace(LOG_FILE_EXTENSION, JFR_FILE_EXTENSION);
- return Paths.get(hs_err_pid_jfr_file);
- }
}
--- a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/CheckMethods.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/CheckMethods.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* 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,13 +26,12 @@
* @bug 4423074
* @summary Need to rebase all the duplicated classes from Merlin.
* This test will check out http POST
- * @modules java.base/sun.net.www.protocol.https java.base/com.sun.net.ssl.internal.www.protocol.https
+ * @modules java.base/sun.net.www.protocol.https
*/
import java.net.*;
import java.util.*;
import java.lang.reflect.*;
import sun.net.www.protocol.https.HttpsURLConnectionImpl;
-import com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl;
public class CheckMethods {
static boolean debug = false;
@@ -85,9 +84,8 @@
}
}
- // check HttpsURLConnectionImpl and HttpsURLConnectionOldImpl
- // contain all public and protected methods defined in
- // HttpURLConnection and URLConnection
+ // check HttpsURLConnectionImpl contain all public and protected methods
+ // defined in HttpURLConnection and URLConnection
public static void main(String[] args) {
ArrayList allMethods = new ArrayList(
Arrays.asList(HttpURLConnection.class.getDeclaredMethods()));
@@ -121,24 +119,6 @@
throw new RuntimeException("Method definition test failed on HttpsURLConnectionImpl");
}
- // testing HttpsURLConnectionOldImpl
- List httpsOldMethods =
- Arrays.asList(HttpsURLConnectionOldImpl.class.getDeclaredMethods());
-
- ArrayList httpsOldMethodSignatures = new ArrayList();
- for (Iterator itr = httpsOldMethods.iterator(); itr.hasNext(); ) {
- Method m = (Method)itr.next();
- if (!Modifier.isStatic(m.getModifiers())) {
- httpsOldMethodSignatures.add(
- new MethodSignature(m.getName(), m.getParameterTypes()));
- }
- }
-
- if (!httpsOldMethodSignatures.containsAll(allMethodSignatures)) {
- throw new RuntimeException("Method definition test failed" +
- " on HttpsURLConnectionOldImpl");
- }
-
// testing for non static public field
ArrayList allFields = new ArrayList(
Arrays.asList(URLConnection.class.getFields()));
--- a/test/jdk/sun/net/www/protocol/https/NewImpl/ComHTTPSConnection.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,393 +0,0 @@
-/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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 4474255
- * @summary Can no longer obtain a com.sun.net.ssl.HttpsURLConnection
- * @modules java.base/com.sun.net.ssl
- * java.base/com.sun.net.ssl.internal.www.protocol.https
- * @run main/othervm ComHTTPSConnection
- *
- * SunJSSE does not support dynamic system properties, no way to re-use
- * system properties in samevm/agentvm mode.
- * @author Brad Wetmore
- */
-
-import java.io.*;
-import java.net.*;
-import java.security.cert.Certificate;
-import javax.net.ssl.*;
-import com.sun.net.ssl.HostnameVerifier;
-import com.sun.net.ssl.HttpsURLConnection;
-
-/**
- * See if we can obtain a com.sun.net.ssl.HttpsURLConnection,
- * and then play with it a bit.
- */
-public class ComHTTPSConnection {
-
- /*
- * =============================================================
- * Set the various variables needed for the tests, then
- * specify what tests to run on each side.
- */
-
- /*
- * Should we run the client or server in a separate thread?
- * Both sides can throw exceptions, but do you have a preference
- * as to which side should be the main thread.
- */
- static boolean separateServerThread = true;
-
- /*
- * Where do we find the keystores?
- */
- static String pathToStores = "../../../../../../javax/net/ssl/etc";
- static String keyStoreFile = "keystore";
- static String trustStoreFile = "truststore";
- static String passwd = "passphrase";
-
- /*
- * Is the server ready to serve?
- */
- volatile static boolean serverReady = false;
-
- /*
- * Turn on SSL debugging?
- */
- static boolean debug = false;
-
- /*
- * If the client or server is doing some kind of object creation
- * that the other side depends on, and that thread prematurely
- * exits, you may experience a hang. The test harness will
- * terminate all hung threads after its timeout has expired,
- * currently 3 minutes by default, but you might try to be
- * smart about it....
- */
-
- /**
- * Returns the path to the file obtained from
- * parsing the HTML header.
- */
- private static String getPath(DataInputStream in)
- throws IOException
- {
- String line = in.readLine();
- String path = "";
- // extract class from GET line
- if (line.startsWith("GET /")) {
- line = line.substring(5, line.length()-1).trim();
- int index = line.indexOf(' ');
- if (index != -1) {
- path = line.substring(0, index);
- }
- }
-
- // eat the rest of header
- do {
- line = in.readLine();
- } while ((line.length() != 0) &&
- (line.charAt(0) != '\r') && (line.charAt(0) != '\n'));
-
- if (path.length() != 0) {
- return path;
- } else {
- throw new IOException("Malformed Header");
- }
- }
-
- /**
- * Returns an array of bytes containing the bytes for
- * the file represented by the argument <b>path</b>.
- *
- * In our case, we just pretend to send something back.
- *
- * @return the bytes for the file
- * @exception FileNotFoundException if the file corresponding
- * to <b>path</b> could not be loaded.
- */
- private byte[] getBytes(String path)
- throws IOException
- {
- return "Hello world, I am here".getBytes();
- }
-
- /*
- * Define the server side of the test.
- *
- * If the server prematurely exits, serverReady will be set to true
- * to avoid infinite hangs.
- */
- void doServerSide() throws Exception {
-
- SSLServerSocketFactory sslssf =
- (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
- SSLServerSocket sslServerSocket =
- (SSLServerSocket) sslssf.createServerSocket(serverPort);
- serverPort = sslServerSocket.getLocalPort();
-
- /*
- * Signal Client, we're ready for his connect.
- */
- serverReady = true;
-
- SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
- DataOutputStream out =
- new DataOutputStream(sslSocket.getOutputStream());
-
- try {
- // get path to class file from header
- DataInputStream in =
- new DataInputStream(sslSocket.getInputStream());
- String path = getPath(in);
- // retrieve bytecodes
- byte[] bytecodes = getBytes(path);
- // send bytecodes in response (assumes HTTP/1.0 or later)
- try {
- out.writeBytes("HTTP/1.0 200 OK\r\n");
- out.writeBytes("Content-Length: " + bytecodes.length + "\r\n");
- out.writeBytes("Content-Type: text/html\r\n\r\n");
- out.write(bytecodes);
- out.flush();
- } catch (IOException ie) {
- ie.printStackTrace();
- return;
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- // write out error response
- out.writeBytes("HTTP/1.0 400 " + e.getMessage() + "\r\n");
- out.writeBytes("Content-Type: text/html\r\n\r\n");
- out.flush();
- } finally {
- // close the socket
- System.out.println("Server closing socket");
- sslSocket.close();
- serverReady = false;
- }
- }
-
- private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory {
- private static String SUPPORTED_PROTOCOL = "https";
-
- public URLStreamHandler createURLStreamHandler(String protocol) {
- if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL))
- return null;
-
- return new com.sun.net.ssl.internal.www.protocol.https.Handler();
- }
- }
-
- /*
- * Define the client side of the test.
- *
- * If the server prematurely exits, serverReady will be set to true
- * to avoid infinite hangs.
- */
- void doClientSide() throws Exception {
- /*
- * Wait for server to get started.
- */
- while (!serverReady) {
- Thread.sleep(50);
- }
-
- HostnameVerifier reservedHV =
- HttpsURLConnection.getDefaultHostnameVerifier();
- try {
- URL.setURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory());
- HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
-
- URL url = new URL("https://" + "localhost:" + serverPort +
- "/etc/hosts");
- URLConnection urlc = url.openConnection();
-
- if (!(urlc instanceof com.sun.net.ssl.HttpsURLConnection)) {
- throw new Exception(
- "URLConnection ! instanceof " +
- "com.sun.net.ssl.HttpsURLConnection");
- }
-
- BufferedReader in = null;
- try {
- in = new BufferedReader(new InputStreamReader(
- urlc.getInputStream()));
- String inputLine;
- System.out.print("Client reading... ");
- while ((inputLine = in.readLine()) != null)
- System.out.println(inputLine);
-
- System.out.println("Cipher Suite: " +
- ((HttpsURLConnection)urlc).getCipherSuite());
- Certificate[] certs =
- ((HttpsURLConnection)urlc).getServerCertificates();
- for (int i = 0; i < certs.length; i++) {
- System.out.println(certs[0]);
- }
-
- in.close();
- } catch (SSLException e) {
- if (in != null)
- in.close();
- throw e;
- }
- System.out.println("Client reports: SUCCESS");
- } finally {
- HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
- }
- }
-
- static class NameVerifier implements HostnameVerifier {
- public boolean verify(String urlHostname,
- String certHostname) {
- System.out.println(
- "CertificateHostnameVerifier: " + urlHostname + " == "
- + certHostname + " returning true");
- return true;
- }
- }
-
- /*
- * =============================================================
- * The remainder is just support stuff
- */
-
- // use any free port by default
- volatile int serverPort = 0;
-
- volatile Exception serverException = null;
- volatile Exception clientException = null;
-
- public static void main(String[] args) throws Exception {
- String keyFilename =
- System.getProperty("test.src", "./") + "/" + pathToStores +
- "/" + keyStoreFile;
- String trustFilename =
- System.getProperty("test.src", "./") + "/" + pathToStores +
- "/" + trustStoreFile;
-
- System.setProperty("javax.net.ssl.keyStore", keyFilename);
- System.setProperty("javax.net.ssl.keyStorePassword", passwd);
- System.setProperty("javax.net.ssl.trustStore", trustFilename);
- System.setProperty("javax.net.ssl.trustStorePassword", passwd);
-
- if (debug)
- System.setProperty("javax.net.debug", "all");
-
- /*
- * Start the tests.
- */
- new ComHTTPSConnection();
- }
-
- Thread clientThread = null;
- Thread serverThread = null;
-
- /*
- * Primary constructor, used to drive remainder of the test.
- *
- * Fork off the other side, then do your work.
- */
- ComHTTPSConnection() throws Exception {
- if (separateServerThread) {
- startServer(true);
- startClient(false);
- } else {
- startClient(true);
- startServer(false);
- }
-
- /*
- * Wait for other side to close down.
- */
- if (separateServerThread) {
- serverThread.join();
- } else {
- clientThread.join();
- }
-
- /*
- * When we get here, the test is pretty much over.
- *
- * If the main thread excepted, that propagates back
- * immediately. If the other thread threw an exception, we
- * should report back.
- */
- if (serverException != null) {
- System.out.print("Server Exception:");
- throw serverException;
- }
- if (clientException != null) {
- System.out.print("Client Exception:");
- throw clientException;
- }
- }
-
- void startServer(boolean newThread) throws Exception {
- if (newThread) {
- serverThread = new Thread() {
- public void run() {
- try {
- doServerSide();
- } catch (Exception e) {
- /*
- * Our server thread just died.
- *
- * Release the client, if not active already...
- */
- System.err.println("Server died...");
- serverReady = true;
- serverException = e;
- }
- }
- };
- serverThread.start();
- } else {
- doServerSide();
- }
- }
-
- void startClient(boolean newThread) throws Exception {
- if (newThread) {
- clientThread = new Thread() {
- public void run() {
- try {
- doClientSide();
- } catch (Exception e) {
- /*
- * Our client thread just died.
- */
- System.err.println("Client died...");
- clientException = e;
- }
- }
- };
- clientThread.start();
- } else {
- doClientSide();
- }
- }
-}
--- a/test/jdk/sun/net/www/protocol/https/NewImpl/ComHostnameVerifier.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,362 +0,0 @@
-/*
- * 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.
- *
- * 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.
- */
-
-// SunJSSE does not support dynamic system properties, no way to re-use
-// system properties in samevm/agentvm mode.
-
-/*
- * @test
- * @bug 4474255 4484246
- * @summary When an application enables anonymous SSL cipher suite,
- * Hostname verification is not required
- * @modules java.base/com.sun.net.ssl
- * java.base/com.sun.net.ssl.internal.www.protocol.https
- * @run main/othervm ComHostnameVerifier
- */
-
-import java.io.*;
-import java.net.*;
-import java.security.Security;
-import javax.net.ssl.*;
-import javax.security.cert.*;
-import com.sun.net.ssl.HostnameVerifier;
-import com.sun.net.ssl.HttpsURLConnection;
-
-/**
- * Use com.net.net.ssl.HostnameVerifier
- */
-public class ComHostnameVerifier {
-
- /*
- * =============================================================
- * Set the various variables needed for the tests, then
- * specify what tests to run on each side.
- */
-
- /*
- * Should we run the client or server in a separate thread?
- * Both sides can throw exceptions, but do you have a preference
- * as to which side should be the main thread.
- */
- static boolean separateServerThread = true;
-
- /*
- * Is the server ready to serve?
- */
- volatile static boolean serverReady = false;
-
- /*
- * Turn on SSL debugging?
- */
- static boolean debug = false;
-
- /*
- * If the client or server is doing some kind of object creation
- * that the other side depends on, and that thread prematurely
- * exits, you may experience a hang. The test harness will
- * terminate all hung threads after its timeout has expired,
- * currently 3 minutes by default, but you might try to be
- * smart about it....
- */
-
- /**
- * Returns the path to the file obtained from
- * parsing the HTML header.
- */
- private static String getPath(DataInputStream in)
- throws IOException
- {
- String line = in.readLine();
- if (line == null)
- return null;
- String path = "";
- // extract class from GET line
- if (line.startsWith("GET /")) {
- line = line.substring(5, line.length()-1).trim();
- int index = line.indexOf(' ');
- if (index != -1) {
- path = line.substring(0, index);
- }
- }
-
- // eat the rest of header
- do {
- line = in.readLine();
- } while ((line.length() != 0) &&
- (line.charAt(0) != '\r') && (line.charAt(0) != '\n'));
-
- if (path.length() != 0) {
- return path;
- } else {
- throw new IOException("Malformed Header");
- }
- }
-
- /**
- * Returns an array of bytes containing the bytes for
- * the file represented by the argument <b>path</b>.
- *
- * In our case, we just pretend to send something back.
- *
- * @return the bytes for the file
- * @exception FileNotFoundException if the file corresponding
- * to <b>path</b> could not be loaded.
- */
- private byte[] getBytes(String path)
- throws IOException
- {
- return "Hello world, I am here".getBytes();
- }
-
- /*
- * Define the server side of the test.
- *
- * If the server prematurely exits, serverReady will be set to true
- * to avoid infinite hangs.
- */
- void doServerSide() throws Exception {
-
- SSLServerSocketFactory sslssf =
- (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
- SSLServerSocket sslServerSocket =
- (SSLServerSocket) sslssf.createServerSocket(serverPort);
- serverPort = sslServerSocket.getLocalPort();
-
- String ciphers[]= { "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA" };
- sslServerSocket.setEnabledCipherSuites(ciphers);
-
- /*
- * Signal Client, we're ready for his connect.
- */
- serverReady = true;
-
- SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
- DataOutputStream out =
- new DataOutputStream(sslSocket.getOutputStream());
-
- try {
- // get path to class file from header
- DataInputStream in =
- new DataInputStream(sslSocket.getInputStream());
- String path = getPath(in);
- // retrieve bytecodes
- byte[] bytecodes = getBytes(path);
- // send bytecodes in response (assumes HTTP/1.0 or later)
- try {
- out.writeBytes("HTTP/1.0 200 OK\r\n");
- out.writeBytes("Content-Length: " + bytecodes.length + "\r\n");
- out.writeBytes("Content-Type: text/html\r\n\r\n");
- out.write(bytecodes);
- out.flush();
- } catch (IOException ie) {
- ie.printStackTrace();
- return;
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- // write out error response
- out.writeBytes("HTTP/1.0 400 " + e.getMessage() + "\r\n");
- out.writeBytes("Content-Type: text/html\r\n\r\n");
- out.flush();
- } finally {
- // close the socket
- System.out.println("Server closing socket");
- sslSocket.close();
- serverReady = false;
- }
- }
-
- private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory {
- private static String SUPPORTED_PROTOCOL = "https";
-
- public URLStreamHandler createURLStreamHandler(String protocol) {
- if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL))
- return null;
-
- return new com.sun.net.ssl.internal.www.protocol.https.Handler();
- }
- }
-
- /*
- * Define the client side of the test.
- *
- * If the server prematurely exits, serverReady will be set to true
- * to avoid infinite hangs.
- */
- void doClientSide() throws Exception {
- /*
- * Wait for server to get started.
- */
- while (!serverReady) {
- Thread.sleep(50);
- }
-
- URL.setURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory());
-
- System.setProperty("https.cipherSuites",
- "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA");
-
- // use the default hostname verifier
-
- URL url = new URL("https://" + "localhost:" + serverPort +
- "/etc/hosts");
- URLConnection urlc = url.openConnection();
-
- if (!(urlc instanceof com.sun.net.ssl.HttpsURLConnection)) {
- throw new Exception(
- "URLConnection ! instanceof " +
- "com.sun.net.ssl.HttpsURLConnection");
- }
-
- BufferedReader in = null;
- try {
- in = new BufferedReader(new InputStreamReader(
- urlc.getInputStream()));
- String inputLine;
- System.out.print("Client reading... ");
- while ((inputLine = in.readLine()) != null)
- System.out.println(inputLine);
- System.out.println("Cipher Suite: " +
- ((HttpsURLConnection)urlc).getCipherSuite());
- in.close();
- } catch (SSLException e) {
- if (in != null)
- in.close();
- throw e;
- }
- System.out.println("Client reports: SUCCESS");
- }
-
- /*
- * =============================================================
- * The remainder is just support stuff
- */
-
- // use any free port by default
- volatile int serverPort = 0;
-
- volatile Exception serverException = null;
- volatile Exception clientException = null;
-
- public static void main(String[] args) throws Exception {
- // re-enable 3DES
- Security.setProperty("jdk.tls.disabledAlgorithms", "");
-
- if (debug)
- System.setProperty("javax.net.debug", "all");
-
- /*
- * Start the tests.
- */
- new ComHostnameVerifier();
- }
-
- Thread clientThread = null;
- Thread serverThread = null;
-
- /*
- * Primary constructor, used to drive remainder of the test.
- *
- * Fork off the other side, then do your work.
- */
- ComHostnameVerifier() throws Exception {
- if (separateServerThread) {
- startServer(true);
- startClient(false);
- } else {
- startClient(true);
- startServer(false);
- }
-
- /*
- * Wait for other side to close down.
- */
- if (separateServerThread) {
- serverThread.join();
- } else {
- clientThread.join();
- }
-
- /*
- * When we get here, the test is pretty much over.
- *
- * If the main thread excepted, that propagates back
- * immediately. If the other thread threw an exception, we
- * should report back.
- */
- if (serverException != null) {
- System.out.print("Server Exception:");
- throw serverException;
- }
- if (clientException != null) {
- System.out.print("Client Exception:");
- throw clientException;
- }
- }
-
- void startServer(boolean newThread) throws Exception {
- if (newThread) {
- serverThread = new Thread() {
- public void run() {
- try {
- doServerSide();
- } catch (Exception e) {
- /*
- * Our server thread just died.
- *
- * Release the client, if not active already...
- */
- System.err.println("Server died...");
- serverReady = true;
- serverException = e;
- }
- }
- };
- serverThread.start();
- } else {
- doServerSide();
- }
- }
-
- void startClient(boolean newThread) throws Exception {
- if (newThread) {
- clientThread = new Thread() {
- public void run() {
- try {
- doClientSide();
- } catch (Exception e) {
- /*
- * Our client thread just died.
- */
- System.err.println("Client died...");
- clientException = e;
- }
- }
- };
- clientThread.start();
- } else {
- doClientSide();
- }
- }
-}
--- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/CheckNullEntity.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/CheckNullEntity.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* 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,6 @@
* @summary unspecified exceptions in X509TrustManager.checkClient[Server]Truste
d
* @author Xuelei Fan
- * @modules java.base/com.sun.net.ssl.internal.ssl
*/
import java.io.*;
@@ -37,8 +36,6 @@
import java.security.*;
import java.util.Enumeration;
-import com.sun.net.ssl.internal.ssl.X509ExtendedTrustManager;
-
public class CheckNullEntity {
/*
@@ -157,7 +154,7 @@
if (trustManager instanceof X509ExtendedTrustManager) {
try {
((X509ExtendedTrustManager)trustManager).checkClientTrusted(
- certChain, (String)null, "localhost", null);
+ certChain, (String)null, (Socket)null);
} catch (IllegalArgumentException iae) {
// get the right exception
extFailed >>= 1;
@@ -165,7 +162,7 @@
try {
((X509ExtendedTrustManager)trustManager).checkServerTrusted(
- certChain, (String)null, "localhost", null);
+ certChain, (String)null, (Socket)null);
} catch (IllegalArgumentException iae) {
// get the right exception
extFailed >>= 1;
@@ -173,7 +170,7 @@
try {
((X509ExtendedTrustManager)trustManager).checkClientTrusted(
- certChain, "", "localhost", null);
+ certChain, "", (Socket)null);
} catch (IllegalArgumentException iae) {
// get the right exception
extFailed >>= 1;
@@ -181,7 +178,7 @@
try {
((X509ExtendedTrustManager)trustManager).checkServerTrusted(
- certChain, "", "localhost", null);
+ certChain, "", (Socket)null);
} catch (IllegalArgumentException iae) {
// get the right exception
extFailed >>= 1;
@@ -189,7 +186,7 @@
try {
((X509ExtendedTrustManager)trustManager).checkClientTrusted(
- null, authType, "localhost", null);
+ null, authType, (Socket)null);
} catch (IllegalArgumentException iae) {
// get the right exception
extFailed >>= 1;
@@ -197,7 +194,7 @@
try {
((X509ExtendedTrustManager)trustManager).checkServerTrusted(
- null, authType, "localhost", null);
+ null, authType, (Socket)null);
} catch (IllegalArgumentException iae) {
// get the right exception
extFailed >>= 1;
--- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/ClientServer.java Sat Mar 09 12:52:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,365 +0,0 @@
-/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 4717766
- * @author Brad Wetmore
- * @summary 1.0.3 JsseX509TrustManager erroneously calls isClientTrusted()
- * @modules java.base/com.sun.net.ssl
- * @run main/manual ClientServer
- */
-
-/*
- * SunJSSE does not support dynamic system properties, no way to re-use
- * system properties in samevm/agentvm mode.
- *
- * JSSE supports algorithm constraints with CR 6916074, need to update
- * this test case in JDK 7 soon.
- *
- * This problem didn't exist in JSSE 1.4, only JSSE 1.0.3. However,
- * this is a useful test, so I decided to include it in 1.4.2.
- */
-
-import java.io.*;
-import java.net.*;
-import javax.net.ssl.*;
-import java.security.cert.*;
-import java.security.*;
-import com.sun.net.ssl.*;
-
-public class ClientServer {
-
- /*
- * =============================================================
- * Set the various variables needed for the tests, then
- * specify what tests to run on each side.
- */
-
- /*
- * Should we run the client or server in a separate thread?
- * Both sides can throw exceptions, but do you have a preference
- * as to which side should be the main thread.
- */
- static boolean separateServerThread = true;
-
- /*
- * Where do we find the keystores?
- */
- static String pathToStores = "../../../../javax/net/ssl/etc";
- static String keyStoreFile = "keystore";
- static String trustStoreFile = "truststore";
- static String passwd = "passphrase";
-
- /*
- * Is the server ready to serve?
- */
- volatile static boolean serverReady = false;
-
- /*
- * Turn on SSL debugging?
- */
- static boolean debug = false;
-
- /*
- * If the client or server is doing some kind of object creation
- * that the other side depends on, and that thread prematurely
- * exits, you may experience a hang. The test harness will
- * terminate all hung threads after its timeout has expired,
- * currently 3 minutes by default, but you might try to be
- * smart about it....
- */
-
- /*
- * Define the server side of the test.
- *
- * If the server prematurely exits, serverReady will be set to true
- * to avoid infinite hangs.
- */
- void doServerSide() throws Exception {
- SSLServerSocketFactory sslssf = getDefaultServer();
- SSLServerSocket sslServerSocket =
- (SSLServerSocket) sslssf.createServerSocket(serverPort);
- serverPort = sslServerSocket.getLocalPort();
-
- /*
- * Signal Client, we're ready for his connect.
- */
- serverReady = true;
-
- SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
- sslSocket.setNeedClientAuth(true);
- InputStream sslIS = sslSocket.getInputStream();
- OutputStream sslOS = sslSocket.getOutputStream();
-
- sslIS.read();
- sslOS.write(85);
- sslOS.flush();
-
- sslSocket.close();
-
- if (!serverTM.wasServerChecked() && serverTM.wasClientChecked()) {
- System.out.println("SERVER TEST PASSED!");
- } else {
- throw new Exception("SERVER TEST FAILED! " +
- !serverTM.wasServerChecked() + " " +
- serverTM.wasClientChecked());
- }
- }
-
- /*
- * Define the client side of the test.
- *
- * If the server prematurely exits, serverReady will be set to true
- * to avoid infinite hangs.
- */
- void doClientSide() throws Exception {
-
- /*
- * Wait for server to get started.
- */
- while (!serverReady) {
- Thread.sleep(50);
- }
-
- SSLSocketFactory sslsf = getDefaultClient();
- SSLSocket sslSocket = (SSLSocket)
- sslsf.createSocket("localhost", serverPort);
-
- InputStream sslIS = sslSocket.getInputStream();
- OutputStream sslOS = sslSocket.getOutputStream();
-
- sslOS.write(280);
- sslOS.flush();
- sslIS.read();
-
- sslSocket.close();
-
- if (clientTM.wasServerChecked() && !clientTM.wasClientChecked()) {
- System.out.println("CLIENT TEST PASSED!");
- } else {
- throw new Exception("CLIENT TEST FAILED! " +
- clientTM.wasServerChecked() + " " +
- !clientTM.wasClientChecked());
- }
- }
-
- private com.sun.net.ssl.SSLContext getDefault(MyX509TM tm)
- throws Exception {
-
- String keyFilename =
- System.getProperty("test.src", "./") + "/" + pathToStores +
- "/" + keyStoreFile;
- String trustFilename =
- System.getProperty("test.src", "./") + "/" + pathToStores +
- "/" + trustStoreFile;
-
- char[] passphrase = "passphrase".toCharArray();
- KeyStore ks = KeyStore.getInstance("JKS");
- ks.load(new FileInputStream(keyFilename), passphrase);
-
- com.sun.net.ssl.KeyManagerFactory kmf =
- com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509");
- kmf.init(ks, passphrase);
-
- ks = KeyStore.getInstance("JKS");
- ks.load(new FileInputStream(trustFilename), passphrase);
-
- com.sun.net.ssl.TrustManagerFactory tmf =
- com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509");
- tmf.init(ks);
-
- com.sun.net.ssl.TrustManager [] tms = tmf.getTrustManagers();
-
- int i;
- for (i = 0; i < tms.length; i++) {
- if (tms[i] instanceof com.sun.net.ssl.X509TrustManager) {
- break;
- }
- }
-
- if (i >= tms.length) {
- throw new Exception("Couldn't find X509TM");
- }
-
- tm.init((com.sun.net.ssl.X509TrustManager)tms[i]);
- tms = new MyX509TM [] { tm };
-
- com.sun.net.ssl.SSLContext ctx =
- com.sun.net.ssl.SSLContext.getInstance("TLS");
- ctx.init(kmf.getKeyManagers(), tms, null);
- return ctx;
- }
-
- MyX509TM serverTM;
- MyX509TM clientTM;
-
- private SSLServerSocketFactory getDefaultServer() throws Exception {
- serverTM = new MyX509TM();
- return getDefault(serverTM).getServerSocketFactory();
- }
-
- private SSLSocketFactory getDefaultClient() throws Exception {
- clientTM = new MyX509TM();
- return getDefault(clientTM).getSocketFactory();
- }
-
- static class MyX509TM implements com.sun.net.ssl.X509TrustManager {
-
- com.sun.net.ssl.X509TrustManager tm;
- boolean clientChecked;
- boolean serverChecked;
-
- void init(com.sun.net.ssl.X509TrustManager x509TM) {
- tm = x509TM;
- }
-
- public boolean wasClientChecked() {
- return clientChecked;
- }
-
- public boolean wasServerChecked() {
- return serverChecked;
- }
-
- public boolean isClientTrusted(X509Certificate[] chain) {
- clientChecked = true;
- return true;
- }
-
- public boolean isServerTrusted(X509Certificate[] chain) {
- serverChecked = true;
- return true;
- }
-
- public X509Certificate[] getAcceptedIssuers() {
- return tm.getAcceptedIssuers();
- }
- }
-
- /*
- * =============================================================
- * The remainder is just support stuff
- */
-
- // use any free port by default
- volatile int serverPort = 0;
-
- volatile Exception serverException = null;
- volatile Exception clientException = null;
-
- public static void main(String[] args) throws Exception {
-
- if (debug)
- System.setProperty("javax.net.debug", "all");
-
- /*
- * Start the tests.
- */
- new ClientServer();
- }
-
- Thread clientThread = null;
- Thread serverThread = null;
-
- /*
- * Primary constructor, used to drive remainder of the test.
- *
- * Fork off the other side, then do your work.
- */
- ClientServer() throws Exception {
- if (separateServerThread) {
- startServer(true);
- startClient(false);
- } else {
- startClient(true);
- startServer(false);
- }
-
- /*
- * Wait for other side to close down.
- */
- if (separateServerThread) {
- serverThread.join();
- } else {
- clientThread.join();
- }
-
- /*
- * When we get here, the test is pretty much over.
- *
- * If the main thread excepted, that propagates back
- * immediately. If the other thread threw an exception, we
- * should report back.
- */
- if (serverException != null)
- throw serverException;
- if (clientException != null)
- throw clientException;
- }
-
- void startServer(boolean newThread) throws Exception {
- if (newThread) {
- serverThread = new Thread() {
- public void run() {
- try {
- doServerSide();
- } catch (Exception e) {
- /*
- * Our server thread just died.
- *
- * Release the client, if not active already...
- */
- System.err.println("Server died...");
- serverReady = true;
- serverException = e;
- }
- }
- };
- serverThread.start();
- } else {
- doServerSide();
- }
- }
-
- void startClient(boolean newThread) throws Exception {
- if (newThread) {
- clientThread = new Thread() {
- public void run() {
- try {
- doClientSide();
- } catch (Exception e) {
- /*
- * Our client thread just died.
- */
- System.err.println("Client died...");
- clientException = e;
- }
- }
- };
- clientThread.start();
- } else {
- doClientSide();
- }
- }
-}
--- a/test/jdk/tools/launcher/Test7029048.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/jdk/tools/launcher/Test7029048.java Sat Mar 09 12:54:20 2019 +0000
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 7029048 8217340
+ * @bug 7029048 8217340 8217216
* @summary Ensure that the launcher defends against user settings of the
* LD_LIBRARY_PATH environment variable on Unixes
* @library /test/lib
@@ -89,6 +89,29 @@
}
static void analyze(TestResult tr, int nLLPComponents, String caseID) {
+ if (isSolaris) {
+ String envValue = getValue("LD_LIBRARY_PATH_64", tr.testOutput);
+ /*
+ * the envValue can never be null, since the test code should always
+ * print a "null" string.
+ */
+ if (envValue == null) {
+ throw new RuntimeException("NPE, likely a program crash ??");
+ }
+ boolean noLLP64 = envValue.equals("null");
+ if (nLLPComponents == 0 && noLLP64) {
+ System.out.println("FAIL: test7029048, " + caseID);
+ System.out.println(" Missing LD_LIBRARY_PATH_64");
+ errors++;
+ return;
+ } else if (nLLPComponents > 3 && !noLLP64) {
+ System.out.println("FAIL: test7029048, " + caseID);
+ System.out.println(" Unexpected LD_LIBRARY_PATH_64: " + envValue);
+ errors++;
+ return;
+ }
+ }
+
String envValue = getValue(LD_LIBRARY_PATH, tr.testOutput);
/*
* the envValue can never be null, since the test code should always
@@ -202,8 +225,8 @@
env.clear();
env.put(LD_LIBRARY_PATH_64, dstServerDir.getAbsolutePath());
run(env,
- v.value, // Do not add one, since we didn't set
- // LD_LIBRARY_PATH here
+ // LD_LIBRARY_PATH_64 is copied into LD_LIBRARY_PATH for LIBJVM case
+ v.value == 0 ? 0 : v.value + 1,
"Case 3: " + desc);
}
}
--- a/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,13 +56,13 @@
checkExit(Exit.OK);
checkOutput("overview-summary.html", true,
"<script type=\"text/javascript\">",
- "<body>");
+ "<body class=\"package-index\">");
// Test that "onload" is not present in BODY tag:
- checkOutput("p1/package-summary.html", true, "<body>");
- checkOutput("overview-frame.html", true, "<body>");
- checkOutput("allclasses-frame.html", true, "<body>");
- checkOutput("p1/package-frame.html", true, "<body>");
+ checkOutput("p1/package-summary.html", true, "<body class=\"package-declaration\">");
+ checkOutput("overview-frame.html", true, "<body class=\"package-index-frame\">");
+ checkOutput("allclasses-frame.html", true, "<body class=\"all-classes-frame\">");
+ checkOutput("p1/package-frame.html", true, "<body class=\"package-frame\">");
// Test that win title javascript is followed by NOSCRIPT code.
checkOutput("p1/C.html", true,
--- a/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java Sat Mar 09 12:54:20 2019 +0000
@@ -57,11 +57,11 @@
+ "<li><a href=\"#annotation.type."
+ "field.detail\">Field</a> | </li>",
"<!-- =========== ANNOTATION TYPE FIELD SUMMARY =========== -->",
- "<h3>Field Summary</h3>",
+ "<h2>Field Summary</h2>",
"<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\"><a href=\"#DEFAULT_NAME\">DEFAULT_NAME</a></span>"
+ "</code></th>",
"<!-- ============ ANNOTATION TYPE FIELD DETAIL =========== -->",
- "<h4>DEFAULT_NAME</h4>\n"
+ "<h3>DEFAULT_NAME</h3>\n"
+ "<pre>static final java."
+ "lang.String DEFAULT_NAME</pre>");
@@ -77,13 +77,13 @@
"<li class=\"blockList\"><a id=\"annotation.type.element.detail\">",
"<!-- -->",
"</a>",
- "<h3>Element Detail</h3>",
+ "<h2>Element Detail</h2>",
"<a id=\"value()\">",
"<!-- -->",
"</a>",
"<ul class=\"blockListLast\">",
"<li class=\"blockList\">",
- "<h4>value</h4>",
+ "<h3>value</h3>",
"<pre>int value</pre>" );
checkOutput("pkg/AnnotationType.html", false,
--- a/test/langtools/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java Sat Mar 09 12:54:20 2019 +0000
@@ -330,7 +330,7 @@
checkOutput("index.html", frames,
"<iframe ",
"</iframe>",
- "<body onload=\"loadFrames()\">\n"
+ "<body class=\"frames\" onload=\"loadFrames()\">\n"
+ "<script type=\"text/javascript\">\n"
+ "if (targetPage == \"\" || targetPage == \"undefined\")");
--- a/test/langtools/jdk/javadoc/doclet/testHeadings/TestHeadings.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testHeadings/TestHeadings.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,23 +37,6 @@
public class TestHeadings extends JavadocTester {
- private static final String[][] TEST = {
-
- {
- },
- { "serialized-form.html"
- },
- { "serialized-form.html"
- },
-
- {
- },
- { "overview-frame.html"
- },
- {
- }
- };
-
public static void main(String... args) throws Exception {
TestHeadings tester = new TestHeadings();
tester.runTests();
@@ -108,7 +91,7 @@
"<h2 title=\"Package\">Package pkg1</h2>",
"<h3>Class <a href=\"pkg1/C1.html\" title=\"class in pkg1\">"
+ "pkg1.C1</a> extends java.lang.Object implements Serializable</h3>",
- "<h3>Serialized Fields</h3>");
+ "<h4>Serialized Fields</h4>");
// Overview Frame
checkOutput("overview-frame.html", true,
--- a/test/langtools/jdk/javadoc/doclet/testHiddenTag/TestHiddenTag.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testHiddenTag/TestHiddenTag.java Sat Mar 09 12:54:20 2019 +0000
@@ -67,8 +67,8 @@
checkOutput("pkg1/A.VisibleInner.html", true,
"<code><a href=\"A.html#visibleField\">visibleField</a></code>",
"<code><a href=\"A.html#visibleMethod()\">visibleMethod</a></code>",
- "<h3>Nested classes/interfaces inherited from class pkg1." +
- "<a href=\"A.html\" title=\"class in pkg1\">A</a></h3>\n" +
+ "<h2>Nested classes/interfaces inherited from class pkg1." +
+ "<a href=\"A.html\" title=\"class in pkg1\">A</a></h2>\n" +
"<code><a href=\"A.VisibleInner.html\" title=\"class in pkg1\">" +
"A.VisibleInner</a>, <a href=\"A.VisibleInnerExtendsInvisibleInner.html\" " +
"title=\"class in pkg1\">A.VisibleInnerExtendsInvisibleInner</a></code></li>\n" +
--- a/test/langtools/jdk/javadoc/doclet/testHref/TestHref.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testHref/TestHref.java Sat Mar 09 12:54:20 2019 +0000
@@ -75,7 +75,7 @@
checkOutput("pkg/C4.html", true,
//Header does not link to the page itself.
- "Class C4<E extends C4<E>></h2>",
+ "Class C4<E extends C4<E>></h1>",
//Signature does not link to the page itself.
"public abstract class <span class=\"typeNameLabel\">C4<E extends C4<E>></span>"
);
--- a/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java Sat Mar 09 12:54:20 2019 +0000
@@ -109,7 +109,7 @@
Path srcDir = base.resolve("src");
createPackages(srcDir);
- Path outDir = base.resolve("out3");
+ Path outDir = base.resolve("out");
javadoc("-d", outDir.toString(),
"-doctitle", "Document Title",
"-header", "Test Header",
@@ -153,7 +153,7 @@
+ " </body>\n"
+ "</html>"));
- Path outDir = base.resolve("out5");
+ Path outDir = base.resolve("out");
javadoc("-d", outDir.toString(),
"-sourcepath", srcDir.toString(),
"pkg1", "pkg2");
@@ -171,12 +171,12 @@
void createModules(Path srcDir) throws Exception {
new ModuleBuilder(tb, "m1")
- .classes("package p1; public class a{}")
- .classes("package p2; public class b{}")
+ .classes("package p1; public class a { }")
+ .classes("package p2; public class b { }")
.write(srcDir);
new ModuleBuilder(tb, "m2")
- .classes("package p3; public class c{}")
- .classes("package p4; public class d{}")
+ .classes("package p3; public class c { }")
+ .classes("package p4; public class d { }")
.write(srcDir);
}
--- a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java Sat Mar 09 12:54:20 2019 +0000
@@ -78,7 +78,7 @@
+ "<li><a href=\"allclasses-frame.html\" target=\"packageFrame\">All Classes</a></li>",
"<main role=\"main\">\n"
+ "<div class=\"indexContainer\">\n"
- + "<h2 title=\"Packages\">Packages</h2>");
+ + "<h1 title=\"Packages\">Packages</h1>");
// Test for allclasses-frame page
checkOutput("allclasses-frame.html", true,
@@ -349,46 +349,46 @@
+ "<li class=\"blockList\"><a id=\"nested.class.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Nested Class Summary</h3>\n"
+ + "<h2>Nested Class Summary</h2>\n"
+ "<div class=\"memberSummary\">\n<table>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"field.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Field Summary</h3>\n"
+ + "<h2>Field Summary</h2>\n"
+ "<div class=\"memberSummary\">\n<table>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"constructor.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Summary</h3>\n"
+ + "<h2>Constructor Summary</h2>\n"
+ "<div class=\"memberSummary\">\n<table>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"method.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Summary</h3>",
+ + "<h2>Method Summary</h2>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"field.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Field Detail</h3>",
+ + "<h2>Field Detail</h2>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"constructor.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Detail</h3>",
+ + "<h2>Constructor Detail</h2>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"method.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Detail</h3>",
+ + "<h2>Method Detail</h2>",
"<footer role=\"contentinfo\">\n"
+ "<nav role=\"navigation\">\n"
+ "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
@@ -411,7 +411,7 @@
+ "<li class=\"blockList\"><a id=\"enum.constant.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Enum Constant Summary</h3>\n"
+ + "<h2>Enum Constant Summary</h2>\n"
+ "<div class=\"memberSummary\">\n",
"<table aria-labelledby=\"t0\">\n",
"<section role=\"region\">\n"
@@ -419,7 +419,7 @@
+ "<li class=\"blockList\"><a id=\"method.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Summary</h3>\n"
+ + "<h2>Method Summary</h2>\n"
+ "<div class=\"memberSummary\">\n",
"<table aria-labelledby=\"t0\">",
"<section role=\"region\">\n"
@@ -427,13 +427,13 @@
+ "<li class=\"blockList\"><a id=\"enum.constant.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Enum Constant Detail</h3>",
+ + "<h2>Enum Constant Detail</h2>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"method.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Detail</h3>",
+ + "<h2>Method Detail</h2>",
"<footer role=\"contentinfo\">\n"
+ "<nav role=\"navigation\">\n"
+ "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
@@ -456,7 +456,7 @@
+ "<li class=\"blockList\"><a id=\"method.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Summary</h3>\n"
+ + "<h2>Method Summary</h2>\n"
+ "<div class=\"memberSummary\">\n",
"<table aria-labelledby=\"t0\">\n",
"<section role=\"region\">\n"
@@ -464,7 +464,7 @@
+ "<li class=\"blockList\"><a id=\"method.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Detail</h3>",
+ + "<h2>Method Detail</h2>",
"<footer role=\"contentinfo\">\n"
+ "<nav role=\"navigation\">\n"
+ "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
@@ -487,13 +487,13 @@
+ "<li class=\"blockList\"><a id=\"constructor.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Summary</h3>",
+ + "<h2>Constructor Summary</h2>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"constructor.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Detail</h3>",
+ + "<h2>Constructor Detail</h2>",
"<footer role=\"contentinfo\">\n"
+ "<nav role=\"navigation\">\n"
+ "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
@@ -516,13 +516,13 @@
+ "<li class=\"blockList\"><a id=\"constructor.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Summary</h3>",
+ + "<h2>Constructor Summary</h2>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"constructor.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Detail</h3>",
+ + "<h2>Constructor Detail</h2>",
"<footer role=\"contentinfo\">\n"
+ "<nav role=\"navigation\">\n"
+ "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
@@ -545,21 +545,21 @@
+ "<li class=\"blockList\"><a id=\"annotation.type.required.element.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Required Element Summary</h3>\n"
+ + "<h2>Required Element Summary</h2>\n"
+ "<div class=\"memberSummary\">\n<table>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"annotation.type.optional.element.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Optional Element Summary</h3>\n"
+ + "<h2>Optional Element Summary</h2>\n"
+ "<div class=\"memberSummary\">\n<table>",
"<section role=\"region\">\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a id=\"annotation.type.element.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Element Detail</h3>",
+ + "<h2>Element Detail</h2>",
"<footer role=\"contentinfo\">\n"
+ "<nav role=\"navigation\">\n"
+ "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
@@ -581,7 +581,7 @@
"<section role=\"region\"><a id=\"pkg\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Uses of <a href=\"../RegClass.html\" title=\"class in pkg1\">RegClass</a> in <a href=\"../../pkg/package-summary.html\">pkg</a></h3>\n"
+ + "<h2>Uses of <a href=\"../RegClass.html\" title=\"class in pkg1\">RegClass</a> in <a href=\"../../pkg/package-summary.html\">pkg</a></h2>\n"
+ "<div class=\"useSummary\">\n<table>",
"<footer role=\"contentinfo\">\n"
+ "<nav role=\"navigation\">\n"
@@ -591,7 +591,7 @@
checkOutput("index.html", true,
"<!DOCTYPE HTML>",
"<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\" title=\"Style\">",
- "<body onload=\"loadFrames()\">\n"
+ "<body class=\"frames\" onload=\"loadFrames()\">\n"
+ "<script type=\"text/javascript\">\n"
+ "if (targetPage == \"\" || targetPage == \"undefined\")\n"
+ " window.location.replace('overview-summary.html');\n"
@@ -823,7 +823,7 @@
+ "<li class=\"blockList\"><a name=\"nested.class.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Nested Class Summary</h3>\n"
+ + "<h2>Nested Class Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<table summary=\"Nested Class Summary table, listing nested classes, and an explanation\">",
"<!-- =========== FIELD SUMMARY =========== -->\n"
@@ -831,7 +831,7 @@
+ "<li class=\"blockList\"><a name=\"field.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Field Summary</h3>\n"
+ + "<h2>Field Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<table summary=\"Field Summary table, listing fields, and an explanation\">",
"<!-- ======== CONSTRUCTOR SUMMARY ======== -->\n"
@@ -839,7 +839,7 @@
+ "<li class=\"blockList\"><a name=\"constructor.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Summary</h3>\n"
+ + "<h2>Constructor Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<table summary=\"Constructor Summary table, listing constructors, and an explanation\">",
"<!-- ========== METHOD SUMMARY =========== -->\n"
@@ -847,7 +847,7 @@
+ "<li class=\"blockList\"><a name=\"method.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Summary</h3>\n"
+ + "<h2>Method Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<table summary=\"Method Summary table, listing methods, and an explanation\">",
"<!-- ============ FIELD DETAIL =========== -->\n"
@@ -855,19 +855,19 @@
+ "<li class=\"blockList\"><a name=\"field.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Field Detail</h3>",
+ + "<h2>Field Detail</h2>",
"<!-- ========= CONSTRUCTOR DETAIL ======== -->\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a name=\"constructor.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Detail</h3>",
+ + "<h2>Constructor Detail</h2>",
"<!-- ============ METHOD DETAIL ========== -->\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a name=\"method.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Detail</h3>");
+ + "<h2>Method Detail</h2>");
// Negated test for enum page
checkOutput("pkg/AnotherClass.ModalExclusionType.html", false,
@@ -883,7 +883,7 @@
+ "<li class=\"blockList\"><a name=\"enum.constant.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Enum Constant Summary</h3>\n"
+ + "<h2>Enum Constant Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<table summary=\"Enum Constant Summary table, listing enum constants, and an explanation\">",
"<!-- ========== METHOD SUMMARY =========== -->\n"
@@ -891,7 +891,7 @@
+ "<li class=\"blockList\"><a name=\"method.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Summary</h3>\n"
+ + "<h2>Method Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<table summary=\"Method Summary table, listing methods, and an explanation\">",
"<!-- ============ ENUM CONSTANT DETAIL =========== -->\n"
@@ -899,13 +899,13 @@
+ "<li class=\"blockList\"><a name=\"enum.constant.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Enum Constant Detail</h3>",
+ + "<h2>Enum Constant Detail</h2>",
"<!-- ============ METHOD DETAIL ========== -->\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a name=\"method.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Detail</h3>");
+ + "<h2>Method Detail</h2>");
// Negated test for interface page
checkOutput("pkg2/Interface.html", false,
@@ -921,7 +921,7 @@
+ "<li class=\"blockList\"><a name=\"method.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Summary</h3>\n"
+ + "<h2>Method Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<table summary=\"Method Summary table, listing methods, and an explanation\">",
"<!-- ============ METHOD DETAIL ========== -->\n"
@@ -929,7 +929,7 @@
+ "<li class=\"blockList\"><a name=\"method.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Method Detail</h3>");
+ + "<h2>Method Detail</h2>");
// Negated test for error page
checkOutput("pkg/TestError.html", false,
@@ -945,13 +945,13 @@
+ "<li class=\"blockList\"><a name=\"constructor.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Summary</h3>",
+ + "<h2>Constructor Summary</h2>",
"<!-- ========= CONSTRUCTOR DETAIL ======== -->\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a name=\"constructor.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Detail</h3>");
+ + "<h2>Constructor Detail</h2>");
// Negated test for exception page
checkOutput("pkg/TestException.html", false,
@@ -967,13 +967,13 @@
+ "<li class=\"blockList\"><a name=\"constructor.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Summary</h3>",
+ + "<h2>Constructor Summary</h2>",
"<!-- ========= CONSTRUCTOR DETAIL ======== -->\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\"><a name=\"constructor.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Constructor Detail</h3>");
+ + "<h2>Constructor Detail</h2>");
// Negated test for annotation page
checkOutput("pkg2/TestAnnotationType.html", false,
@@ -989,7 +989,7 @@
+ "<li class=\"blockList\"><a name=\"annotation.type.required.element.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Required Element Summary</h3>\n"
+ + "<h2>Required Element Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<table summary=\"Required Element Summary table, listing required elements, and an explanation\">",
"<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== -->\n"
@@ -997,7 +997,7 @@
+ "<li class=\"blockList\"><a name=\"annotation.type.optional.element.summary\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Optional Element Summary</h3>\n"
+ + "<h2>Optional Element Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<table summary=\"Optional Element Summary table, listing optional elements, and an explanation\">",
"<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->\n"
@@ -1005,7 +1005,7 @@
+ "<li class=\"blockList\"><a name=\"annotation.type.element.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Element Detail</h3>");
+ + "<h2>Element Detail</h2>");
// Negated test for class use page
checkOutput("pkg1/class-use/RegClass.html", false,
@@ -1027,7 +1027,7 @@
"<li class=\"blockList\"><a name=\"pkg\">\n"
+ "<!-- -->\n"
+ "</a>\n"
- + "<h3>Uses of <a href=\"../RegClass.html\" title=\"class in pkg1\">RegClass</a> in <a href=\"../../pkg/package-summary.html\">pkg</a></h3>\n"
+ + "<h2>Uses of <a href=\"../RegClass.html\" title=\"class in pkg1\">RegClass</a> in <a href=\"../../pkg/package-summary.html\">pkg</a></h2>\n"
+ "<div class=\"useSummary\">\n<table summary=\"Use table, listing fields, and an explanation\">");
// Negated test for main index page
--- a/test/langtools/jdk/javadoc/doclet/testIndexTaglet/TestIndexTaglet.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testIndexTaglet/TestIndexTaglet.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -75,12 +75,12 @@
checkExit(Exit.OK);
checkOrder("pkg/A.html",
- "<h3>Method Detail</h3>\n",
+ "<h2>Method Detail</h2>\n",
"<div class=\"block\">test description with <a id=\"search_phrase_a\" "
+ "class=\"searchTagResult\">search_phrase_a</a></div>");
checkOrder("pkg/A.html",
- "<h3>Method Summary</h3>\n",
+ "<h2>Method Summary</h2>\n",
"<div class=\"block\">test description with search_phrase_a</div>");
}
--- a/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java Sat Mar 09 12:54:20 2019 +0000
@@ -131,7 +131,7 @@
"<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n");
checkOutput("pkg/ClassWithStaticMembers.html", true,
- "<h4>f</h4>\n"
+ "<h3>f</h3>\n"
+ "<pre>public static int f</pre>\n"
+ "<div class=\"block\">A hider field</div>",
@@ -142,7 +142,7 @@
+ "<div class=\"block\">A hider method</div>\n"
+ "</td>\n",
- "<h4>staticMethod</h4>\n"
+ "<h3>staticMethod</h3>\n"
+ "<pre class=\"methodSignature\">public static void staticMethod()</pre>\n"
+ "<div class=\"block\"><span class=\"descfrmTypeLabel\">"
+ "Description copied from interface: <code>"
@@ -183,8 +183,8 @@
checkOutput("pkg2/Spliterator.OfDouble.html", true,
// Ensure the correct type parameters are displayed correctly
- "<h3>Nested classes/interfaces inherited from interface pkg2."
- + "<a href=\"Spliterator.html\" title=\"interface in pkg2\">Spliterator</a></h3>\n"
+ "<h2>Nested classes/interfaces inherited from interface pkg2."
+ + "<a href=\"Spliterator.html\" title=\"interface in pkg2\">Spliterator</a></h2>\n"
+ "<code><a href=\"Spliterator.OfDouble.html\" title=\"interface in pkg2\">"
+ "Spliterator.OfDouble</a>, <a href=\"Spliterator.OfInt.html\" "
+ "title=\"interface in pkg2\">Spliterator.OfInt</a><"
--- a/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java Sat Mar 09 12:54:20 2019 +0000
@@ -86,14 +86,14 @@
+ "<a href=\"#pausedProperty\">paused</a></span></code></th>\n"
+ "<td class=\"colLast\">\n"
+ "<div class=\"block\">Defines if paused.</div>",
- "<h4>paused</h4>\n"
+ "<h3>paused</h3>\n"
+ "<pre>public final <a href=\"C.BooleanProperty.html\" "
+ "title=\"class in pkg1\">C.BooleanProperty</a> pausedProperty</pre>\n"
+ "<div class=\"block\">Defines if paused. The second line.</div>",
- "<h4>isPaused</h4>\n"
+ "<h3>isPaused</h3>\n"
+ "<pre class=\"methodSignature\">public final double isPaused()</pre>\n"
+ "<div class=\"block\">Gets the value of the property paused.</div>",
- "<h4>setPaused</h4>\n"
+ "<h3>setPaused</h3>\n"
+ "<pre class=\"methodSignature\">public final void setPaused​(boolean value)</pre>\n"
+ "<div class=\"block\">Sets the value of the property paused.</div>\n"
+ "<dl>\n"
@@ -101,7 +101,7 @@
+ "<dd>Defines if paused. The second line.</dd>\n"
+ "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
+ "<dd>false</dd>",
- "<h4>isPaused</h4>\n"
+ "<h3>isPaused</h3>\n"
+ "<pre class=\"methodSignature\">public final double isPaused()</pre>\n"
+ "<div class=\"block\">Gets the value of the property paused.</div>\n"
+ "<dl>\n"
@@ -109,13 +109,13 @@
+ "<dd>Defines if paused. The second line.</dd>\n"
+ "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
+ "<dd>false</dd>",
- "<h4>rate</h4>\n"
+ "<h3>rate</h3>\n"
+ "<pre>public final <a href=\"C.DoubleProperty.html\" "
+ "title=\"class in pkg1\">C.DoubleProperty</a> rateProperty</pre>\n"
+ "<div class=\"block\">Defines the direction/speed at which the "
+ "<code>Timeline</code> is expected to\n"
+ " be played. This is the second line.</div>",
- "<h4>setRate</h4>\n"
+ "<h3>setRate</h3>\n"
+ "<pre class=\"methodSignature\">public final void setRate​(double value)</pre>\n"
+ "<div class=\"block\">Sets the value of the property rate.</div>\n"
+ "<dl>\n"
@@ -126,7 +126,7 @@
+ "<dd>11</dd>\n"
+ "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ "<dd>JavaFX 8.0</dd>",
- "<h4>getRate</h4>\n"
+ "<h3>getRate</h3>\n"
+ "<pre class=\"methodSignature\">public final double getRate()</pre>\n"
+ "<div class=\"block\">Gets the value of the property rate.</div>\n"
+ "<dl>\n"
@@ -137,7 +137,7 @@
+ "<dd>11</dd>\n"
+ "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ "<dd>JavaFX 8.0</dd>",
- "<h3>Property Summary</h3>\n"
+ "<h2>Property Summary</h2>\n"
+ "<div class=\"memberSummary\">\n<table>\n"
+ "<caption><span>Properties</span><span class=\"tabEnd\"> </span></caption>",
"<tr class=\"altColor\">\n"
@@ -147,7 +147,7 @@
checkOutput("pkg1/C.html", false,
"A()",
- "<h3>Property Summary</h3>\n"
+ "<h2>Property Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<div role=\"tablist\" aria-orientation=\"horizontal\"><button role=\"tab\""
+ " aria-selected=\"true\" aria-controls=\"memberSummary_tabpanel\" tabindex=\"0\""
@@ -190,13 +190,13 @@
"pkg2");
checkExit(Exit.OK);
checkOutput("pkg2/Test.html", true,
- "<h3>Property Detail</h3>\n"
+ "<h2>Property Detail</h2>\n"
+ "<a id=\"betaProperty\">\n"
+ "<!-- -->\n"
+ "</a>\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\">\n"
- + "<h4>beta</h4>\n"
+ + "<h3>beta</h3>\n"
+ "<pre>public java.lang.Object betaProperty</pre>\n"
+ "</li>\n"
+ "</ul>\n"
@@ -205,7 +205,7 @@
+ "</a>\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\">\n"
- + "<h4>gamma</h4>\n"
+ + "<h3>gamma</h3>\n"
+ "<pre>public final java.util.List<java.lang.String> gammaProperty</pre>\n"
+ "</li>\n"
+ "</ul>\n"
@@ -214,19 +214,19 @@
+ "</a>\n"
+ "<ul class=\"blockListLast\">\n"
+ "<li class=\"blockList\">\n"
- + "<h4>delta</h4>\n"
+ + "<h3>delta</h3>\n"
+ "<pre>public final java.util.List<"
+ "java.util.Set<? super java.lang.Object>> deltaProperty</pre>\n"
+ "</li>\n"
+ "</ul>\n"
+ "</li>\n"
+ "</ul>",
- "<h3>Property Summary</h3>\n"
+ "<h2>Property Summary</h2>\n"
+ "<div class=\"memberSummary\">\n<table>\n"
+ "<caption><span>Properties</span><span class=\"tabEnd\"> </span></caption>");
checkOutput("pkg2/Test.html", false,
- "<h3>Property Summary</h3>\n"
+ "<h2>Property Summary</h2>\n"
+ "<div class=\"memberSummary\">\n"
+ "<div role=\"tablist\" aria-orientation=\"horizontal\"><button role=\"tab\""
+ " aria-selected=\"true\" aria-controls=\"memberSummary_tabpanel\" tabindex=\"0\""
@@ -250,7 +250,7 @@
"-package",
"pkg2");
checkExit(Exit.OK);
- checkOutput("pkg2/Test.html", false, "<h3>Property Summary</h3>");
+ checkOutput("pkg2/Test.html", false, "<h2>Property Summary</h2>");
checkOutput("pkg2/Test.html", true,
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colSecond\" scope=\"col\">Method</th>\n"
--- a/test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -115,7 +115,7 @@
+ "</script>");
checkOutput("index.html", true,
- "<body onload=\"loadFrames()\"");
+ "<body class=\"frames\" onload=\"loadFrames()\"");
//Make sure title javascript only runs if is-external is not true
checkOutput("pkg/C.html", true,
--- a/test/langtools/jdk/javadoc/doclet/testMetadata/TestMetadata.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testMetadata/TestMetadata.java Sat Mar 09 12:54:20 2019 +0000
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8218998
+ * @bug 8218998 8219946
* @summary Add metadata to generated API documentation files
* @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -62,6 +62,7 @@
enum Source { PACKAGES, MODULES };
final ToolBox tb = new ToolBox();
+ final Set<String> allBodyClassesFound = new HashSet<>();
final Set<String> allGeneratorsFound = new HashSet<>();
public void runTests() throws Exception {
@@ -93,6 +94,7 @@
}
javadoc(args.toArray(new String[args.size()]));
checkExit(Exit.OK);
+ checkBodyClasses();
checkMetadata();
// spot check the descriptions for declarations
@@ -126,10 +128,91 @@
failed("not found: " + notFound);
}
+ checking ("all body classes");
+ if (allBodyClassesFound.equals(allBodyClasses)) {
+ passed("all gbody classes found");
+ } else {
+ Set<String> notFound = new TreeSet<>(allBodyClasses);
+ notFound.removeAll(allBodyClassesFound);
+ failed("not found: " + notFound);
+ }
+
printSummary();
}
final Pattern nl = Pattern.compile("[\\r\\n]+");
+ final Pattern bodyPattern = Pattern.compile("<body [^>]*class=\"([^\"]+)\"");
+ final Set<String> allBodyClasses = Set.of(
+ "all-classes-frame",
+ "all-classes-index",
+ "all-packages-index",
+ "class-declaration",
+ "class-use",
+ "constants-summary",
+ "deprecated-list",
+ "doc-file",
+ "frames",
+ "help",
+ "index-redirect",
+ "module-declaration",
+ "module-frame",
+ "module-index",
+ "module-index-frame",
+ "module-package-index-frame",
+ "package-declaration",
+ "package-frame",
+ "package-index",
+ "package-index-frame",
+ "package-tree",
+ "package-use",
+ "serialized-form",
+ "single-index",
+ "source",
+ "split-index",
+ "tree"
+ );
+
+ void checkBodyClasses() throws IOException {
+ Path outputDirPath = outputDir.toPath();
+ for (Path p : tb.findFiles(".html", outputDirPath)) {
+ checkBodyClass(outputDirPath.relativize(p));
+ }
+ }
+
+ void checkBodyClass(Path p) {
+ checking("Check body: " + p);
+
+ List<String> bodyLines = nl.splitAsStream(readOutputFile(p.toString()))
+ .filter(s -> s.contains("<body class="))
+ .collect(Collectors.toList());
+
+ String bodyLine;
+ switch (bodyLines.size()) {
+ case 0:
+ failed("Not found: <body class=");
+ return;
+ case 1:
+ bodyLine = bodyLines.get(0);
+ break;
+ default:
+ failed("Multiple found: <body class=");
+ return;
+ }
+
+ Matcher m = bodyPattern.matcher(bodyLine);
+ if (m.find()) {
+ String bodyClass = m.group(1);
+ if (allBodyClasses.contains(bodyClass)) {
+ passed("found: " + bodyClass);
+ allBodyClassesFound.add(bodyClass);
+ } else {
+ failed("Unrecognized body class: " + bodyClass);
+ }
+ } else {
+ failed("Unrecognized line:\n" + bodyLine);
+ }
+ }
+
final Pattern contentPattern = Pattern.compile("content=\"([^\"]+)\">");
final Pattern generatorPattern = Pattern.compile("content=\"javadoc/([^\"]+)\">");
final Set<String> allGenerators = Set.of(
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java Sat Mar 09 12:54:20 2019 +0000
@@ -173,7 +173,7 @@
checkExit(Exit.OK);
checkOutput("m/module-summary.html", false,
- "<h3>Services</h3>");
+ "<h2>Services</h2>");
}
@Test
@@ -194,7 +194,7 @@
checkExit(Exit.OK);
checkOutput("m/module-summary.html", true,
- "<h3>Services</h3>");
+ "<h2>Services</h2>");
checkOutput("m/module-summary.html", true,
"<div class=\"usesSummary\">\n<table>\n" +
@@ -235,7 +235,7 @@
checkExit(Exit.OK);
checkOutput("m/module-summary.html", true,
- "<h3>Services</h3>");
+ "<h2>Services</h2>");
checkOutput("m/module-summary.html", true,
"<div class=\"usesSummary\">\n<table>\n" +
@@ -276,7 +276,7 @@
checkExit(Exit.OK);
checkOutput("m/module-summary.html", false,
- "<h3>Services</h3>");
+ "<h2>Services</h2>");
}
@Test
@@ -302,7 +302,7 @@
checkExit(Exit.OK);
checkOutput("m/module-summary.html", true,
- "<h3>Services</h3>");
+ "<h2>Services</h2>");
checkOutput("m/module-summary.html", true,
"<div class=\"providesSummary\">\n<table>\n" +
@@ -346,7 +346,7 @@
checkExit(Exit.OK);
checkOutput("m/module-summary.html", true,
- "<h3>Services</h3>");
+ "<h2>Services</h2>");
checkOutput("m/module-summary.html", true,
"<div class=\"providesSummary\">\n<table>\n" +
@@ -389,7 +389,7 @@
checkExit(Exit.OK);
checkOutput("m/module-summary.html", true,
- "<h3>Services</h3>");
+ "<h2>Services</h2>");
checkOutput("m/module-summary.html", true,
"<div class=\"providesSummary\">\n<table>\n" +
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java Sat Mar 09 12:54:20 2019 +0000
@@ -1261,7 +1261,7 @@
+ "<div class=\"block\">This is a test description for the test.moduleFullName.</div>\n"
+ "</dd>");
checkOutput("module-overview-frame.html", found,
- "<h2 title=\"Modules\">Modules</h2>\n"
+ "<h1 title=\"Modules\">Modules</h1>\n"
+ "<ul title=\"Modules\">\n"
+ "<li><a href=\"moduleB/module-frame.html\" target=\"packageListFrame\" onclick=\"updateModuleFrame('moduleB/module-type-frame.html','moduleB/module-summary.html');\">moduleB</a></li>\n"
+ "<li><a href=\"test.moduleFullName/module-frame.html\" target=\"packageListFrame\" onclick=\"updateModuleFrame('test.moduleFullName/module-type-frame.html','test.moduleFullName/module-summary.html');\">test.moduleFullName</a></li>\n"
--- a/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java Sat Mar 09 12:54:20 2019 +0000
@@ -24,7 +24,7 @@
/*
* @test
* @bug 4789689 4905985 4927164 4827184 4993906 5004549 7025314 7010344 8025633 8026567 8162363
- * 8175200 8186332 8182765 8196202 8187288 8173730
+ * 8175200 8186332 8182765 8196202 8187288 8173730 8215307
* @summary Run Javadoc on a set of source files that demonstrate new
* language features. Check the output to ensure that the new
* language features are properly documented.
@@ -66,7 +66,7 @@
void checkEnums() {
checkOutput("pkg/Coin.html", true,
// Make sure enum header is correct.
- "Enum Coin</h2>",
+ "Enum Coin</h1>",
// Make sure enum signature is correct.
"<pre>public enum "
+ "<span class=\"typeNameLabel\">Coin</span>\n"
@@ -110,7 +110,7 @@
void checkTypeParameters() {
checkOutput("pkg/TypeParameters.html", true,
// Make sure the header is correct.
- "Class TypeParameters<E></h2>",
+ "Class TypeParameters<E></h1>",
// Check class type parameters section.
"<dt><span class=\"paramLabel\">Type Parameters:</span></dt>\n"
+ "<dd><code>E</code> - "
--- a/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java Sat Mar 09 12:54:20 2019 +0000
@@ -193,10 +193,10 @@
"<pre>@Documented\npublic @interface <a href="
+ "\"../src-html/linksource/AnnotationTypeField.html#line.31\">"
+ "AnnotationTypeField</a></pre>",
- "<h4>DEFAULT_NAME</h4>\n<pre>static final java.lang.String "
+ "<h3>DEFAULT_NAME</h3>\n<pre>static final java.lang.String "
+ "<a href=\"../src-html/linksource/AnnotationTypeField.html#line.32\">"
+ "DEFAULT_NAME</a></pre>",
- "<h4>name</h4>\n<pre>java.lang.String <a href="
+ "<h3>name</h3>\n<pre>java.lang.String <a href="
+ "\"../src-html/linksource/AnnotationTypeField.html#line.34\">name</a></pre>");
checkOutput("src-html/linksource/AnnotationTypeField.html", true,
--- a/test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java Sat Mar 09 12:54:20 2019 +0000
@@ -551,107 +551,107 @@
checkExit(Exit.OK);
checkOrder("pkg5/AnnoFieldTest.html",
- "<h3>Field Detail</h3>",
+ "<h2>Field Detail</h2>",
"<pre>static final int one</pre>",
"<pre>static final int two</pre>",
"<pre>static final int three</pre>",
"<pre>static final int four</pre>");
checkOrder("pkg5/AnnoOptionalTest.html",
- "<h3>Optional Element Summary</h3>",
+ "<h2>Optional Element Summary</h2>",
"<a href=\"#four()\">four</a>",
"<a href=\"#one()\">one</a>",
"<a href=\"#three()\">three</a>",
"<a href=\"#two()\">two</a>",
- "<h3>Element Detail</h3>",
- "<h4>one</h4>",
- "<h4>two</h4>",
- "<h4>three</h4>",
- "<h4>four</h4>");
+ "<h2>Element Detail</h2>",
+ "<h3>one</h3>",
+ "<h3>two</h3>",
+ "<h3>three</h3>",
+ "<h3>four</h3>");
checkOrder("pkg5/AnnoRequiredTest.html",
- "<h3>Required Element Summary</h3>",
+ "<h2>Required Element Summary</h2>",
"<a href=\"#four()\">four</a>",
"<a href=\"#one()\">one</a>",
"<a href=\"#three()\">three</a>",
"<a href=\"#two()\">two</a>",
- "<h3>Element Detail</h3>",
- "<h4>one</h4>",
- "<h4>two</h4>",
- "<h4>three</h4>",
- "<h4>four</h4>");
+ "<h2>Element Detail</h2>",
+ "<h3>one</h3>",
+ "<h3>two</h3>",
+ "<h3>three</h3>",
+ "<h3>four</h3>");
checkOrder("pkg5/CtorTest.html",
- "<h3>Constructor Summary</h3>",
+ "<h2>Constructor Summary</h2>",
"<a href=\"#%3Cinit%3E(int)\"",
"<a href=\"#%3Cinit%3E(int,int)\"",
"<a href=\"#%3Cinit%3E(int,int,int)\"",
"<a href=\"#%3Cinit%3E(int,int,int,int)\"",
- "<h3>Constructor Detail</h3>",
+ "<h2>Constructor Detail</h2>",
"<a id=\"<init>(int,int,int,int)\">",
"<a id=\"<init>(int,int,int)\">",
"<a id=\"<init>(int,int)\">",
"<a id=\"<init>(int)\">");
checkOrder("pkg5/EnumTest.html",
- "<h3>Enum Constant Summary</h3>",
+ "<h2>Enum Constant Summary</h2>",
"<a href=\"#FOUR\">FOUR</a>",
"<a href=\"#ONE\">ONE</a>",
"<a href=\"#THREE\">THREE</a>",
"<a href=\"#TWO\">TWO</a>",
- "<h3>Enum Constant Detail</h3>",
- "<h4>ONE</h4>",
- "<h4>TWO</h4>",
- "<h4>THREE</h4>",
- "<h4>FOUR</h4>");
+ "<h2>Enum Constant Detail</h2>",
+ "<h3>ONE</h3>",
+ "<h3>TWO</h3>",
+ "<h3>THREE</h3>",
+ "<h3>FOUR</h3>");
checkOrder("pkg5/FieldTest.html",
- "<h3>Field Summary</h3>",
+ "<h2>Field Summary</h2>",
"<a href=\"#four\">four</a>",
"<a href=\"#one\">one</a>",
"<a href=\"#three\">three</a>",
"<a href=\"#two\">two</a>",
- "<h3>Field Detail</h3>",
- "<h4>one</h4>",
- "<h4>two</h4>",
- "<h4>three</h4>",
- "<h4>four</h4>");
+ "<h2>Field Detail</h2>",
+ "<h3>one</h3>",
+ "<h3>two</h3>",
+ "<h3>three</h3>",
+ "<h3>four</h3>");
checkOrder("pkg5/IntfTest.html",
- "<h3>Method Summary</h3>",
+ "<h2>Method Summary</h2>",
"<a href=\"#four()\">four</a>",
"<a href=\"#one()\">one</a>",
"<a href=\"#three()\">three</a>",
"<a href=\"#two()\">two</a>",
- "<h3>Method Detail</h3>",
- "<h4>one</h4>",
- "<h4>two</h4>",
- "<h4>three</h4>",
- "<h4>four</h4>");
+ "<h2>Method Detail</h2>",
+ "<h3>one</h3>",
+ "<h3>two</h3>",
+ "<h3>three</h3>",
+ "<h3>four</h3>");
checkOrder("pkg5/MethodTest.html",
- "<h3>Method Summary</h3>",
+ "<h2>Method Summary</h2>",
"<a href=\"#four()\">four</a>",
"<a href=\"#one()\">one</a>",
"<a href=\"#three()\">three</a>",
"<a href=\"#two()\">two</a>",
- "<h3>Method Detail</h3>",
- "<h4>one</h4>",
- "<h4>two</h4>",
- "<h4>three</h4>",
- "<h4>four</h4>");
+ "<h2>Method Detail</h2>",
+ "<h3>one</h3>",
+ "<h3>two</h3>",
+ "<h3>three</h3>",
+ "<h3>four</h3>");
checkOrder("pkg5/PropertyTest.html",
- "<h3>Property Summary</h3>",
+ "<h2>Property Summary</h2>",
"<a href=\"#fourProperty\">four</a>",
"<a href=\"#oneProperty\">one</a>",
"<a href=\"#threeProperty\">three</a>",
"<a href=\"#twoProperty\">two</a>",
- "<h3>Property Detail</h3>",
- "<h4>oneProperty</h4>",
- "<h4>twoProperty</h4>",
- "<h4>threeProperty</h4>",
- "<h4>fourProperty</h4>");
+ "<h2>Property Detail</h2>",
+ "<h3>oneProperty</h3>",
+ "<h3>twoProperty</h3>",
+ "<h3>threeProperty</h3>",
+ "<h3>fourProperty</h3>");
}
}
--- a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@
checkOutput("pkg4/Foo.html", true,
"<li class=\"blockList\">\n"
- + "<h4>toString</h4>\n"
+ + "<h3>toString</h3>\n"
+ "<pre class=\"methodSignature\">public void toString()</pre>\n"
+ "<div class=\"block\">Why can't I do this ?</div>\n"
+ "</li>");
--- a/test/langtools/jdk/javadoc/doclet/testSerializedForm/TestSerializedForm.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testSerializedForm/TestSerializedForm.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4341304 4485668 4966728 8032066 8071982 8192933
+ * @bug 4341304 4485668 4966728 8032066 8071982 8192933 8215307
* @summary Test that methods readResolve and writeReplace show
* up in serialized-form.html the same way that readObject and writeObject do.
* If the doclet includes readResolve and writeReplace in the serialized-form
@@ -109,6 +109,8 @@
testSrc("SerializedForm.java"), testSrc("ExternalizedForm.java"), "pkg1");
checkExit(Exit.OK);
+ showHeadings("serialized-form.html");
+
checkOutput("serialized-form.html", true,
"<h3>Class <a href=\"pkg1/NestedInnerClass.InnerClass.ProNestedInnerClass.html\" "
+ "title=\"class in pkg1\">pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass</a> "
@@ -130,15 +132,15 @@
+ "extends java.lang.Object implements Serializable</h3>");
checkOutput("serialized-form.html", true,
- "<h3>Serialized Fields</h3>\n" +
+ "<h4>Serialized Fields</h4>\n" +
"<ul class=\"blockList\">\n" +
"<li class=\"blockList\">\n" +
- "<h4>longs</h4>\n" +
+ "<h5>longs</h5>\n" +
"<pre>Long[] longs</pre>\n" +
"<div class=\"block\">the longs</div>\n" +
"</li>\n" +
"<li class=\"blockListLast\">\n" +
- "<h4>name</h4>\n" +
+ "<h5>name</h5>\n" +
"<pre>java.lang.String name</pre>\n" +
"<div class=\"block\">a test</div>");
}
--- a/test/langtools/jdk/javadoc/doclet/testSummaryHeading/TestSummaryHeading.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testSummaryHeading/TestSummaryHeading.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,6 @@
checkExit(Exit.OK);
checkOutput("C.html", true,
- "<h3>Method Summary</h3>");
+ "<h2>Method Summary</h2>");
}
}
--- a/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java Sat Mar 09 12:54:20 2019 +0000
@@ -86,7 +86,7 @@
// make sure the second @summary's content is displayed correctly
checkOutput("p1/A.html", true,
"<li class=\"blockList\">\n"
- + "<h4>m3</h4>\n"
+ + "<h3>m3</h3>\n"
+ "<pre class=\"methodSignature\">public void m3()</pre>\n"
+ "<div class=\"block\">First sentence some text maybe second sentence.</div>\n"
+ "</li>\n"
--- a/test/langtools/jdk/javadoc/doclet/testSystemPropertyTaglet/TestSystemPropertyTaglet.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testSystemPropertyTaglet/TestSystemPropertyTaglet.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -76,9 +76,9 @@
checkExit(Exit.OK);
checkOrder("pkg/A.html",
- "<h2 title=\"Class A\" class=\"title\">Class A</h2>",
+ "<h1 title=\"Class A\" class=\"title\">Class A</h1>",
"test with <code><a id=\"user.name\" class=\"searchTagResult\">user.name</a></code>",
- "<h3>Method Detail</h3>",
+ "<h2>Method Detail</h2>",
"test with <code><a id=\"java.version\" class=\"searchTagResult\">java.version</a></code>");
checkOrder("index-all.html",
--- a/test/langtools/jdk/javadoc/lib/javadoc/tester/A11yChecker.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/lib/javadoc/tester/A11yChecker.java Sat Mar 09 12:54:20 2019 +0000
@@ -36,7 +36,7 @@
private boolean html5;
- private int currLevel;
+ private int currRank;
private int headingErrors;
private boolean inBody;
@@ -86,6 +86,7 @@
switch (name) {
case "body":
inBody = true;
+ currRank = 0;
break;
case "h1": case "h2": case "h3": case "h4": case "h5": case "h6":
@@ -126,18 +127,18 @@
}
private void checkHeading(String h) {
- int level = Character.digit(h.charAt(1), 10);
- if (level > currLevel + 1) {
+ int rank = Character.digit(h.charAt(1), 10);
+ if (rank > currRank + 1) {
headingErrors++;
StringBuilder sb = new StringBuilder();
String sep = "";
- for (int i = currLevel + 1; i < level; i++) {
+ for (int i = currRank + 1; i < rank; i++) {
sb.append(sep).append("h").append(i);
sep = ", ";
}
error(currFile, getLineNumber(), "missing headings: " + sb);
}
- currLevel = level;
+ currRank = rank;
}
@Override
--- a/test/langtools/jdk/javadoc/lib/javadoc/tester/JavadocTester.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/jdk/javadoc/lib/javadoc/tester/JavadocTester.java Sat Mar 09 12:54:20 2019 +0000
@@ -232,7 +232,7 @@
private DirectoryCheck outputDirectoryCheck = DirectoryCheck.EMPTY;
- private boolean automaticCheckAccessibility = false;
+ private boolean automaticCheckAccessibility = true;
private boolean automaticCheckLinks = true;
/** The current subtest number. Incremented when checking(...) is called. */
@@ -261,7 +261,7 @@
}
/**
- * Run all methods annotated with @Test, followed by printSummary.
+ * Runs all methods annotated with @Test, followed by printSummary.
* Typically called on a tester object in main()
* @param f a function which will be used to provide arguments to each
* invoked method
@@ -285,7 +285,7 @@
}
/**
- * Run javadoc.
+ * Runs javadoc.
* The output directory used by this call and the final exit code
* will be saved for later use.
* To aid the reader, it is recommended that calls to this method
@@ -391,7 +391,7 @@
}
/**
- * Set the kind of check for the initial contents of the output directory
+ * Sets the kind of check for the initial contents of the output directory
* before javadoc is run.
* The filter should return true for files that should <b>not</b> appear.
* @param c the kind of check to perform
@@ -401,7 +401,14 @@
}
/**
- * Set whether or not to perform an automatic call of checkLinks.
+ * Sets whether or not to perform an automatic call of checkAccessibility.
+ */
+ public void setAutomaticCheckAccessibility(boolean b) {
+ automaticCheckAccessibility = b;
+ }
+
+ /**
+ * Sets whether or not to perform an automatic call of checkLinks.
*/
public void setAutomaticCheckLinks(boolean b) {
automaticCheckLinks = b;
@@ -431,7 +438,7 @@
}
/**
- * Check the exit code of the most recent call of javadoc.
+ * Checks the exit code of the most recent call of javadoc.
*
* @param expected the exit code that is required for the test
* to pass.
@@ -446,7 +453,7 @@
}
/**
- * Check for content in (or not in) the generated output.
+ * Checks for content in (or not in) the generated output.
* Within the search strings, the newline character \n
* will be translated to the platform newline character sequence.
* @param path a path within the most recent output directory
@@ -465,7 +472,7 @@
}
/**
- * Check for content in (or not in) the generated output.
+ * Checks for content in (or not in) the generated output.
* Within the search strings, the newline character \n
* will be translated to the platform newline character sequence.
* @param path a path within the most recent output directory, identifying
@@ -487,7 +494,7 @@
}
/**
- * Check for content in (or not in) the one of the output streams written by
+ * Checks for content in (or not in) the one of the output streams written by
* javadoc. Within the search strings, the newline character \n
* will be translated to the platform newline character sequence.
* @param output the output stream to check
@@ -519,6 +526,11 @@
}
}
+ /**
+ * Performs some structural accessibility checks on the files generated by the most
+ * recent run of javadoc.
+ * The checks can be run automatically by calling {@link #setAutomaticCheckAccessibility}.
+ */
public void checkAccessibility() {
checking("Check accessibility");
A11yChecker c = new A11yChecker(out, this::readFile);
@@ -536,6 +548,11 @@
}
}
+ /**
+ * Checks all the links within the files generated by the most
+ * recent run of javadoc.
+ * The checks can be run automatically by calling {@link #setAutomaticCheckLinks}.
+ */
public void checkLinks() {
checking("Check links");
LinkChecker c = new LinkChecker(out, this::readFile);
@@ -554,7 +571,27 @@
}
/**
- * Get the content of the one of the output streams written by javadoc.
+ * Shows the heading structure for each of the specified files.
+ * The structure is is printed in plain text to the main output stream.
+ * No errors are reported (unless there is a problem reading a file)
+ * but missing headings are noted within the output.
+ * @params the files
+ */
+ public void showHeadings(String... paths) {
+ ShowHeadings s = new ShowHeadings(out, this::readFile);
+ for (String p : paths) {
+ try {
+ File f = new File(outputDir, p);
+ s.checkFiles(List.of(f.toPath()), false, Collections.emptySet());
+ } catch (IOException e) {
+ checking("Read file");
+ failed("Error reading file: " + e);
+ }
+ }
+ }
+
+ /**
+ * Gets the content of the one of the output streams written by javadoc.
* @param output the name of the output stream
* @return the content of the output stream
*/
@@ -563,7 +600,7 @@
}
/**
- * Get the content of the one of the output streams written by javadoc.
+ * Gets the content of the one of the output streams written by javadoc.
* @param output the name of the output stream
* @return the content of the output stream, as a line of lines
*/
@@ -573,7 +610,7 @@
}
/**
- * Check for files in (or not in) the generated output.
+ * Checks for files in (or not in) the generated output.
* @param expectedFound true if all of the files are expected
* to be found, or false if all of the files are expected to be
* not found
@@ -584,7 +621,7 @@
}
/**
- * Check for files in (or not in) the generated output.
+ * Checks for files in (or not in) the generated output.
* @param expectedFound true if all of the files are expected
* to be found, or false if all of the files are expected to be
* not found
@@ -605,7 +642,7 @@
}
/**
- * Check that a series of strings are found in order in a file in
+ * Checks that a series of strings are found in order in a file in
* the generated output.
* @param path the file to check
* @param strings the strings whose order to check
@@ -658,7 +695,7 @@
}
/**
- * Compare a set of files in each of two directories.
+ * Compares a set of files in each of two directories.
*
* @param baseDir1 the directory containing the first set of files
* @param baseDir2 the directory containing the second set of files
@@ -673,7 +710,7 @@
}
/**
- * A utility to copy a directory from one place to another.
+ * Copies a directory from one place to another.
*
* @param targetDir the directory to copy.
* @param destDir the destination to copy the directory to.
@@ -707,7 +744,7 @@
}
/**
- * Copy source file to destination file.
+ * Copies a file.
*
* @param destfile the destination file
* @param srcfile the source file
@@ -749,7 +786,7 @@
}
/**
- * Read the file and return it as a string.
+ * Reads the file and return it as a string.
*
* @param baseDir the directory in which to locate the file
* @param fileName the name of the file to read
@@ -825,7 +862,7 @@
}
/**
- * Print a summary of the test results.
+ * Prints a summary of the test results.
*/
protected void printSummary() {
String javadocRuns = (javadocRunNum <= 1) ? ""
@@ -845,7 +882,7 @@
}
/**
- * Search for the string in the given file and return true
+ * Searches for the string in the given file and return true
* if the string was found.
*
* @param fileString the contents of the file to search through
@@ -861,7 +898,7 @@
}
/**
- * Compare the two given files.
+ * Compares the two given files.
*
* @param baseDir1 the directory in which to locate the first file
* @param baseDir2 the directory in which to locate the second file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/jdk/javadoc/lib/javadoc/tester/ShowHeadings.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 javadoc.tester;
+
+import java.io.PrintStream;
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.function.Function;
+
+public class ShowHeadings extends HtmlChecker {
+
+ private int currLevel;
+
+ private boolean copyContent;
+
+ ShowHeadings(PrintStream out, Function<Path,String> fileReader) {
+ super(out, fileReader);
+ }
+
+ @Override
+ public void report() {
+ }
+
+ @Override
+ public void startFile(Path path) {
+ out.println("Headings: " + path);
+ currLevel = 0;
+ }
+
+ @Override
+ public void endFile() {
+ }
+
+ @Override
+ public void docType(String doctype) {
+ }
+
+ @Override
+ public void startElement(String name, Map<String,String> attrs, boolean selfClosing) {
+ switch (name) {
+ case "h1": case "h2": case "h3": case "h4": case "h5": case "h6":
+ startHeading(name);
+ break;
+ }
+ }
+
+ @Override
+ public void endElement(String name) {
+ switch (name) {
+ case "h1": case "h2": case "h3": case "h4": case "h5": case "h6":
+ out.println();
+ copyContent = false;
+ break;
+ }
+
+ }
+
+ private void startHeading(String h) {
+ int level = Character.digit(h.charAt(1), 10);
+ while (level > currLevel + 1) {
+ currLevel++;
+ out.println("* ".repeat(currLevel - 1) + "H" + currLevel + ": *** MISSING ***");
+ }
+ currLevel = level;
+ out.print("* ".repeat(currLevel - 1) + "H" + currLevel + ": ");
+ copyContent = true;
+ }
+
+ @Override
+ public void content(String s) {
+ if (copyContent) {
+ out.print(s.replace(" ", " ")
+ .replace("<", "<")
+ .replace(">", ">")
+ .replace("&", "&")
+ .replaceAll("\\s+", " ")
+ );
+ }
+ }
+}
+
--- a/test/langtools/tools/javac/modules/PatchModulesTest.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/tools/javac/modules/PatchModulesTest.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8160489
+ * @bug 8160489 8217868
* @summary tests for --patch-modules
* @library /tools/lib
* @modules
@@ -192,5 +192,23 @@
throw new AssertionError();
}
}
+
+ @Test
+ public void testPatchModuleSourcePathClash(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src,
+ "module m { uses test.Test; }",
+ "package test; public class Test { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new toolbox.JavacTask(tb)
+ .options("--patch-module", "other=" + src.toString(),
+ "-sourcepath", src.toString())
+ .outdir(classes)
+ .files(findJavaFiles(src.resolve("module-info.java")))
+ .run()
+ .writeAll();
+ }
}
--- a/test/langtools/tools/javac/processing/model/completionfailure/SymbolsDontCumulate.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/langtools/tools/javac/processing/model/completionfailure/SymbolsDontCumulate.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,25 +24,31 @@
/*
* @test
* @bug 8209055
- * @summary Verify that speculative symbols are not unnecesarily retained in
+ * @summary Verify that speculative symbols are not unnecessarily retained in
* the DeferredCompletionFailureHandler
* @library /tools/javac/lib /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.code:+open
+ * jdk.compiler/com.sun.tools.javac.main
* @run main SymbolsDontCumulate
*/
import java.lang.reflect.Field;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import javax.tools.JavaCompiler;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
-import toolbox.*;
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.code.DeferredCompletionFailureHandler;
+import toolbox.ToolBox;
+
public class SymbolsDontCumulate {
ToolBox tb = new ToolBox();
@@ -65,7 +71,7 @@
DeferredCompletionFailureHandler h = DeferredCompletionFailureHandler.instance(((JavacTaskImpl) task).getContext());
Field class2Flip = h.userCodeHandler.getClass().getDeclaredField("class2Flip");
class2Flip.setAccessible(true);
- int size = ((Map) class2Flip.get(h.userCodeHandler)).size();
+ int size = ((Map<?,?>) class2Flip.get(h.userCodeHandler)).size();
assertEquals(0, size);
}
}
--- a/test/micro/org/openjdk/bench/java/lang/StringIndexOf.java Sat Mar 09 12:52:30 2019 +0000
+++ b/test/micro/org/openjdk/bench/java/lang/StringIndexOf.java Sat Mar 09 12:54:20 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,12 @@
private String shortSub1;
private String data2;
private String shortSub2;
+ private String string16Short;
+ private String string16Medium;
+ private String string16Long;
+ private char searchChar;
+ private char searchChar16;
+ private String searchString16;
@Setup
public void setup() {
@@ -58,9 +64,122 @@
shortSub1 = "1";
data2 = "00001001010100a10110101010010101110101001110110101010010101010010000010111010101010101010a100010010101110111010101101010100010010a100a0010101111111000010101010010101000010101010010101010101110a10010101010101010101010101010";
shortSub2 = "a";
+ searchChar = 's';
+
+ string16Short = "scar\u01fe1";
+ string16Medium = "capaapapapasdkajdlkajskldjaslkjdlkasjdsalksca1r\u01fescar";
+ string16Long = "2937489745890797905764956790452976742965790437698498409583479067ngdcapaapapapasdkajdlkajskldjaslkjdlkasjdsalkja1sscar\u01fescar";
+ searchChar16 = 0x1fe;
+ searchString16 = "\u01fe";
+ }
+
+
+ /** IndexOf Micros Chars */
+ @Benchmark
+ public int searchCharLongSuccess() {
+ return dataStringBig.indexOf(searchChar);
+ }
+
+ @Benchmark
+ public int searchCharMediumSuccess() {
+ return searchStringBig.indexOf(searchChar);
+ }
+
+ @Benchmark
+ public int searchCharShortSuccess() {
+ return searchString.indexOf(searchChar);
+ }
+
+ @Benchmark
+ public int searchChar16LongSuccess() {
+ return string16Long.indexOf(searchChar16);
+ }
+
+ @Benchmark
+ public int searchChar16MediumSuccess() {
+ return string16Medium.indexOf(searchChar16);
+ }
+
+ @Benchmark
+ public int searchChar16ShortSuccess() {
+ return string16Short.indexOf(searchChar16);
+ }
+
+ @Benchmark
+ public int searchChar16LongWithOffsetSuccess() {
+ return string16Long.indexOf(searchChar16, 3);
+ }
+
+ @Benchmark
+ public int searchChar16MediumWithOffsetSuccess() {
+ return string16Medium.indexOf(searchChar16, 3);
+ }
+
+ @Benchmark
+ public int searchChar16ShortWithOffsetSuccess() {
+ return string16Short.indexOf(searchChar16, 2);
}
/** IndexOf Micros Strings */
+ @Benchmark
+ public int searchString16LongLatinSuccess() {
+ return string16Long.indexOf(shortSub1);
+ }
+
+ @Benchmark
+ public int searchString16MediumLatinSuccess() {
+ return string16Medium.indexOf(shortSub1);
+ }
+
+ @Benchmark
+ public int searchString16ShortLatinSuccess() {
+ return string16Long.indexOf(shortSub2);
+ }
+
+ @Benchmark
+ public int searchString16LongWithOffsetLatinSuccess() {
+ return string16Long.indexOf(shortSub1, 3);
+ }
+
+ @Benchmark
+ public int searchString16MediumWithOffsetLatinSuccess() {
+ return string16Medium.indexOf(shortSub1, 3);
+ }
+
+ @Benchmark
+ public int searchString16ShortWithOffsetLatinSuccess() {
+ return string16Short.indexOf(shortSub2, 1);
+ }
+
+ @Benchmark
+ public int searchString16LongWithOffsetSuccess() {
+ return string16Long.indexOf(searchString16, 3);
+ }
+
+ @Benchmark
+ public int searchString16MediumWithOffsetSuccess() {
+ return string16Medium.indexOf(searchString16, 3);
+ }
+
+ @Benchmark
+ public int searchString16ShortWithOffsetSuccess() {
+ return string16Short.indexOf(searchString16, 2);
+ }
+
+ @Benchmark
+ public int searchString16LongSuccess() {
+ return string16Long.indexOf(searchString16);
+ }
+
+ @Benchmark
+ public int searchString16MediumSuccess() {
+ return string16Medium.indexOf(searchString16);
+ }
+
+ @Benchmark
+ public int searchString16ShortSuccess() {
+ return string16Short.indexOf(searchString16);
+ }
/**
* Benchmarks String.indexOf with a rather small String to search and a rather small String to search for. The
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/micro/org/openjdk/bench/vm/compiler/FpMinMaxIntrinsics.java Sat Mar 09 12:54:20 2019 +0000
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 org.openjdk.bench.vm.compiler;
+
+import org.openjdk.jmh.annotations.*;
+import org.openjdk.jmh.infra.*;
+
+import java.util.concurrent.TimeUnit;
+import java.util.Random;
+
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@State(Scope.Thread)
+public class FpMinMaxIntrinsics {
+ private static final int COUNT = 1000;
+
+ private double[] doubles = new double[COUNT];
+ private float[] floats = new float[COUNT];
+
+ private int c1, c2, s1, s2;
+
+ private Random r = new Random();
+
+ @Setup
+ public void init() {
+ c1 = s1 = step();
+ c2 = COUNT - (s2 = step());
+
+ for (int i=0; i<COUNT; i++) {
+ floats[i] = r.nextFloat();
+ doubles[i] = r.nextDouble();
+ }
+ }
+
+ private int step() {
+ return (r.nextInt() & 0xf) + 1;
+ }
+
+ @Benchmark
+ public void dMax(Blackhole bh) {
+ for (int i=0; i<COUNT; i++)
+ bh.consume(dMaxBench());
+ }
+
+ @Benchmark
+ public void dMin(Blackhole bh) {
+ for (int i=0; i<COUNT; i++)
+ bh.consume(dMinBench());
+ }
+
+ @Benchmark
+ public void fMax(Blackhole bh) {
+ for (int i=0; i<COUNT; i++)
+ bh.consume(fMaxBench());
+ }
+
+ @Benchmark
+ public void fMin(Blackhole bh) {
+ for (int i=0; i<COUNT; i++)
+ bh.consume(fMinBench());
+ }
+
+ private double dMaxBench() {
+ inc();
+ return Math.max(doubles[c1], doubles[c2]);
+ }
+
+ private double dMinBench() {
+ inc();
+ return Math.min(doubles[c1], doubles[c2]);
+ }
+
+ private float fMaxBench() {
+ inc();
+ return Math.max(floats[c1], floats[c2]);
+ }
+
+ private float fMinBench() {
+ inc();
+ return Math.min(floats[c1], floats[c2]);
+ }
+
+ private void inc() {
+ c1 = c1 + s1 < COUNT ? c1 + s1 : (s1 = step());
+ c2 = c2 - s2 > 0 ? c2 - s2 : COUNT - (s2 = step());
+ }
+
+ @Benchmark
+ public float fMinReduce() {
+ float result = Float.MAX_VALUE;
+
+ for (int i=0; i<COUNT; i++)
+ result = Math.min(result, floats[i]);
+
+ return result;
+ }
+
+ @Benchmark
+ public double dMinReduce() {
+ double result = Double.MAX_VALUE;
+
+ for (int i=0; i<COUNT; i++)
+ result = Math.min(result, doubles[i]);
+
+ return result;
+ }
+}