From b870098ffdf02af90f7ca66dd408663fe514fb4d Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 17 May 2017 12:42:58 +0200 Subject: [PATCH 01/13] 8180472: Pandoc should generate html5 from markdown Reviewed-by: erikj --- common/doc/building.html | 238 ++++++++++++++++---------------- common/doc/testing.html | 23 +-- make/common/ProcessMarkdown.gmk | 4 +- 3 files changed, 135 insertions(+), 130 deletions(-) diff --git a/common/doc/building.html b/common/doc/building.html index 9a086783f02..624c3e8e853 100644 --- a/common/doc/building.html +++ b/common/doc/building.html @@ -1,21 +1,23 @@ - - + + - - - + + + OpenJDK Build README - + + - -
-OpenJDK -

OpenJDK

-
+ +
+OpenJDK
OpenJDK
+

Introduction

This README file contains build instructions for the OpenJDK. Building the source code for the OpenJDK requires a certain degree of technical expertise.

@@ -149,50 +151,50 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + +
PackageVersionPackageVersion
developer/solarisstudio-124/backend12.4-1.0.6.0developer/solarisstudio-124/backend12.4-1.0.6.0
developer/solarisstudio-124/c++12.4-1.0.10.0developer/solarisstudio-124/c++12.4-1.0.10.0
developer/solarisstudio-124/cc12.4-1.0.4.0developer/solarisstudio-124/cc12.4-1.0.4.0
developer/solarisstudio-124/library/c++-libs12.4-1.0.10.0developer/solarisstudio-124/library/c++-libs12.4-1.0.10.0
developer/solarisstudio-124/library/math-libs12.4-1.0.0.1developer/solarisstudio-124/library/math-libs12.4-1.0.0.1
developer/solarisstudio-124/library/studio-gccrt12.4-1.0.0.1developer/solarisstudio-124/library/studio-gccrt12.4-1.0.0.1
developer/solarisstudio-124/studio-common12.4-1.0.0.1developer/solarisstudio-124/studio-common12.4-1.0.0.1
developer/solarisstudio-124/studio-ja12.4-1.0.0.1developer/solarisstudio-124/studio-ja12.4-1.0.0.1
developer/solarisstudio-124/studio-legal12.4-1.0.0.1developer/solarisstudio-124/studio-legal12.4-1.0.0.1
developer/solarisstudio-124/studio-zhCN12.4-1.0.0.1developer/solarisstudio-124/studio-zhCN12.4-1.0.0.1
@@ -211,66 +213,66 @@ - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + +
Binary NameCategoryPackageDescriptionBinary NameCategoryPackageDescription
ar.exeDevelbinutilsThe GNU assembler, linker and binary utilitiesar.exeDevelbinutilsThe GNU assembler, linker and binary utilities
make.exeDevelmakeThe GNU version of the 'make' utility built for CYGWINmake.exeDevelmakeThe GNU version of the 'make' utility built for CYGWIN
m4.exeInterpretersm4GNU implementation of the traditional Unix macro processorm4.exeInterpretersm4GNU implementation of the traditional Unix macro processor
cpio.exeUtilscpioA program to manage archives of filescpio.exeUtilscpioA program to manage archives of files
gawk.exeUtilsawkPattern-directed scanning and processing languagegawk.exeUtilsawkPattern-directed scanning and processing language
file.exeUtilsfileDetermines file type using 'magic' numbersfile.exeUtilsfileDetermines file type using 'magic' numbers
zip.exeArchivezipPackage and compress (archive) fileszip.exeArchivezipPackage and compress (archive) files
unzip.exeArchiveunzipExtract compressed files in a ZIP archiveunzip.exeArchiveunzipExtract compressed files in a ZIP archive
free.exeSystemprocpsDisplay amount of free and used memory in the systemfree.exeSystemprocpsDisplay amount of free and used memory in the system
@@ -561,14 +563,14 @@ This is caused by a missing libstdc++.a library. This is installed as part of a This is probably an issue with SELinux (See SELinux on Wikipedia). Parts of the VM is built without the -fPIC for performance reasons.

To completely disable SELinux:

-
    +
    1. $ su root
    2. # system-config-securitylevel
    3. In the window that appears, select the SELinux tab
    4. Disable SELinux

    Alternatively, instead of completely disabling it you could disable just this one check.

    -
      +
      1. Select System->Administration->SELinux Management
      2. In the SELinux Management Tool which appears, select "Boolean" from the menu on the left
      3. Expand the "Memory Protection" group
      4. @@ -616,62 +618,62 @@ Try rebooting the system, or there could be some kind of issue with the disk or - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
        Base OS and ArchitectureOSC/C++ CompilerProcessorsRAM MinimumDISK NeedsBase OS and ArchitectureOSC/C++ CompilerProcessorsRAM MinimumDISK Needs
        Linux X86 (32-bit) and X64 (64-bit)Oracle Enterprise Linux 6.4gcc 4.9.22 or more1 GB6 GBLinux X86 (32-bit) and X64 (64-bit)Oracle Enterprise Linux 6.4gcc 4.9.22 or more1 GB6 GB
        Solaris SPARCV9 (64-bit)Solaris 11 Update 1Studio 12 Update 4 + patches4 or more4 GB8 GBSolaris SPARCV9 (64-bit)Solaris 11 Update 1Studio 12 Update 4 + patches4 or more4 GB8 GB
        Solaris X64 (64-bit)Solaris 11 Update 1Studio 12 Update 4 + patches4 or more4 GB8 GBSolaris X64 (64-bit)Solaris 11 Update 1Studio 12 Update 4 + patches4 or more4 GB8 GB
        Windows X86 (32-bit)Windows Server 2012 R2 x64Microsoft Visual Studio C++ 2013 Professional Edition2 or more2 GB6 GBWindows X86 (32-bit)Windows Server 2012 R2 x64Microsoft Visual Studio C++ 2013 Professional Edition2 or more2 GB6 GB
        Windows X64 (64-bit)Windows Server 2012 R2 x64Microsoft Visual Studio C++ 2013 Professional Edition2 or more2 GB6 GBWindows X64 (64-bit)Windows Server 2012 R2 x64Microsoft Visual Studio C++ 2013 Professional Edition2 or more2 GB6 GB
        Mac OS X X64 (64-bit)Mac OS X 10.9 "Mavericks"Xcode 6.3 or newer2 or more4 GB6 GBMac OS X X64 (64-bit)Mac OS X 10.9 "Mavericks"Xcode 6.3 or newer2 or more4 GB6 GB
        diff --git a/common/doc/testing.html b/common/doc/testing.html index 265be8b9e8a..64f635d2306 100644 --- a/common/doc/testing.html +++ b/common/doc/testing.html @@ -1,19 +1,22 @@ - - + + - - - + + + Testing OpenJDK - + + - - +

        Using the run-test framework

        This new way of running tests is developer-centric. It assumes that you have built a jdk locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.

        Some example command-lines:

        diff --git a/make/common/ProcessMarkdown.gmk b/make/common/ProcessMarkdown.gmk index eec4d0cf060..fe4d30e75cf 100644 --- a/make/common/ProcessMarkdown.gmk +++ b/make/common/ProcessMarkdown.gmk @@ -36,7 +36,7 @@ define ProcessMarkdown ifneq ($$(findstring http:/, $$($1_CSS)), ) $1_$2_CSS_OPTION := --css '$$($1_CSS)' else - $1_$2_CSS := $$(call RelativePath, $$($1_CSS), $$($1_$2_TARGET_DIR)) + $1_$2_CSS := $$(strip $$(call RelativePath, $$($1_CSS), $$($1_$2_TARGET_DIR))) $1_$2_CSS_OPTION := --css '$$($1_$2_CSS)' endif endif @@ -51,7 +51,7 @@ $$($1_$2_OUTPUT_FILE): $$($1_SRC)/$2 $$($1_$2_VARDEPS_FILE) $$(call LogInfo, Converting $2 to html) $$(call MakeDir, $$($1_$2_TARGET_DIR) $$(SUPPORT_OUTPUTDIR)/markdown) $$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER), \ - $$(PANDOC) $$($1_OPTIONS) -f markdown -t html --standalone \ + $$(PANDOC) $$($1_OPTIONS) -f markdown -t html5 --standalone \ $$($1_$2_CSS_OPTION) $$($1_$2_OPTIONS) '$$<' -o '$$@') ifneq ($$(findstring $$(LOG_LEVEL), debug trace),) TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` || true ; \ From daf44b840b27c77c4c3821172292db914298abf2 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 17 May 2017 12:44:12 +0200 Subject: [PATCH 02/13] 8180318: Enable HTML 5 checking at compile time Reviewed-by: erikj --- make/CompileJavaModules.gmk | 6 ++++-- make/common/SetupJavaCompilers.gmk | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 73c6a40c822..76bdf22b950 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -42,7 +42,8 @@ java.activation_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS ################################################################################ -java.base_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' -XDstringConcat=inline +java.base_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' -XDstringConcat=inline \ + --doclint-format html4 java.base_COPY := .icu .dat .spp content-types.properties hijrah-config-islamic-umalqura.properties java.base_CLEAN := intrinsic.properties @@ -95,7 +96,8 @@ java.datatransfer_COPY := flavormap.properties ################################################################################ java.desktop_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference \ - '-Xdoclint/package:java.*,javax.*' -Xlint:exports + '-Xdoclint/package:java.*,javax.*' -Xlint:exports \ + --doclint-format html4 java.desktop_COPY := .gif .png .wav .txt .xml .css .pf java.desktop_CLEAN := iio-plugin.properties cursors.properties diff --git a/make/common/SetupJavaCompilers.gmk b/make/common/SetupJavaCompilers.gmk index 1a80d47fddc..4e7c8eebf19 100644 --- a/make/common/SetupJavaCompilers.gmk +++ b/make/common/SetupJavaCompilers.gmk @@ -69,7 +69,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE, \ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \ JVM := $(JAVA_JAVAC), \ JAVAC := $(NEW_JAVAC), \ - FLAGS := -source 9 -target 9 \ + FLAGS := -source 9 -target 9 --doclint-format html5 \ -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \ SERVER_DIR := $(SJAVAC_SERVER_DIR), \ SERVER_JVM := $(SJAVAC_SERVER_JAVA))) From 671a3b797beae8b5497d4da43b03b4bfb2b1c9ab Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 18 May 2017 09:23:55 +0200 Subject: [PATCH 03/13] 8180426: Use standard css file for new docs bundle index.html page Reviewed-by: mchung, erikj --- make/Docs.gmk | 35 +++++++++++++++++++---------------- make/Main.gmk | 3 ++- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/make/Docs.gmk b/make/Docs.gmk index f95a57d376f..077750bec36 100644 --- a/make/Docs.gmk +++ b/make/Docs.gmk @@ -163,7 +163,7 @@ JAVASE_JAVADOC_DOC_TITLE := Java™ Platform, Standard Edition \ ################################################################################ -JDK_DOCS_INDEX_HTML_TITLE := Java™ Platform, Standard Edition Development Kit \ +JDK_INDEX_TITLE := Java™ Platform, Standard Edition Development Kit \ (JDK™) $(VERSION_SPECIFICATION) Specification
        $(DRAFT_MARKER_TITLE) ################################################################################ @@ -356,15 +356,27 @@ $(eval $(call SetupApiDocsGeneration, JAVASE_API, \ ################################################################################ -JDK_DOCS_INDEX_HTML := $(DOCS_OUTPUTDIR)/index.html +JDK_INDEX_HTML := $(DOCS_OUTPUTDIR)/index.html +JDK_INDEX_TOOLS_DIR := $(TOOLS_CLASSES_DIR)/build/tools/docs -$(JDK_DOCS_INDEX_HTML): $(BUILD_JIGSAW_TOOLS) +$(JDK_INDEX_HTML): $(BUILD_JIGSAW_TOOLS) \ + $(JDK_INDEX_TOOLS_DIR)/docs-bundle-page.html \ + $(JDK_INDEX_TOOLS_DIR)/docs-module-groups.properties $(call LogInfo, Generating docs bundle index page) $(MKDIR) -p $(@D) - $(TOOL_GEN_DOCS_BUNDLE_PAGE) --title '$(JDK_DOCS_INDEX_HTML_TITLE)' \ + $(TOOL_GEN_DOCS_BUNDLE_PAGE) --title '$(JDK_INDEX_TITLE)' \ --output $@ -JDK_DOCS_INDEX_HTML_TARGETS := $(JDK_DOCS_INDEX_HTML) +JDK_INDEX_TARGETS := $(JDK_INDEX_HTML) + +# Copy the global resources +GLOBAL_SPECS_RESOURCES_DIR := $(JDK_TOPDIR)/make/data/docs-resources/ +$(eval $(call SetupCopyFiles, COPY_GLOBAL_RESOURCES, \ + SRC := $(GLOBAL_SPECS_RESOURCES_DIR), \ + FILES := $(call CacheFind, $(GLOBAL_SPECS_RESOURCES_DIR)), \ + DEST := $(DOCS_OUTPUTDIR), \ +)) +JDK_INDEX_TARGETS += $(COPY_GLOBAL_RESOURCES) ################################################################################ # Copy JDK specs files @@ -389,20 +401,11 @@ $(foreach m, $(ALL_MODULES), \ ) \ ) -# Copy the global resources -GLOBAL_SPECS_RESOURCES_DIR := $(JDK_TOPDIR)/make/data/docs-resources/specs -$(eval $(call SetupCopyFiles, COPY_GLOBAL_RESOURCES, \ - SRC := $(GLOBAL_SPECS_RESOURCES_DIR), \ - FILES := $(call CacheFind, $(GLOBAL_SPECS_RESOURCES_DIR)), \ - DEST := $(DOCS_OUTPUTDIR)/specs/, \ -)) -JDK_SPECS_TARGETS += $(COPY_GLOBAL_RESOURCES) - ifeq ($(ENABLE_FULL_DOCS), true) # For all markdown files in $module/share/specs directories, convert them to # html. - GLOBAL_SPECS_DEFAULT_CSS_FILE := $(DOCS_OUTPUTDIR)/specs/resources/jdk-default.css + GLOBAL_SPECS_DEFAULT_CSS_FILE := $(DOCS_OUTPUTDIR)/resources/jdk-default.css $(foreach m, $(ALL_MODULES), \ $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \ @@ -464,7 +467,7 @@ docs-javase-api-modulegraph: $(JAVASE_API_MODULEGRAPH_TARGETS) docs-jdk-specs: $(JDK_SPECS_TARGETS) -docs-jdk-index: $(JDK_DOCS_INDEX_HTML_TARGETS) +docs-jdk-index: $(JDK_INDEX_TARGETS) docs-zip: $(ZIP_TARGETS) diff --git a/make/Main.gmk b/make/Main.gmk index ab6eb7d2e2b..a5e1d8625ce 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -798,7 +798,8 @@ else docs-javase-api-modulegraph: exploded-image buildtools-modules # The gensrc steps for hotspot and jdk.jdi create html spec files. - docs-jdk-specs: hotspot-$(JVM_VARIANT_MAIN)-gensrc jdk.jdi-gensrc + docs-jdk-specs: hotspot-$(JVM_VARIANT_MAIN)-gensrc jdk.jdi-gensrc \ + docs-jdk-index docs-jdk-index: exploded-image buildtools-modules From bd4cbecc4bbcd2c694ff30993ee7bf733d959d29 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 18 May 2017 10:31:46 -0700 Subject: [PATCH 04/13] 8180540: Add pandoc build fix for windows Reviewed-by: wetmore --- common/autoconf/spec.gmk.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 247b15070e5..9946fa2b679 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -650,7 +650,7 @@ MKDIR:=@MKDIR@ MV:=@MV@ NAWK:=@NAWK@ NICE:=@NICE@ -PANDOC:=@PANDOC@ +PANDOC:=@FIXPATH@ @PANDOC@ PATCH:=@PATCH@ PRINTF:=@PRINTF@ RM:=@RM@ From 8ff6b30d2826b888927e9afe83929c686cfc20da Mon Sep 17 00:00:00 2001 From: Ujwal Vangapally Date: Fri, 19 May 2017 15:27:25 +0530 Subject: [PATCH 05/13] 8175845: Provide javadoc descriptions for jdk.hotspot.agent module Added description for jdk.hotspot.agent module Reviewed-by: mchung --- make/common/Modules.gmk | 1 + 1 file changed, 1 insertion(+) diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index 7477013efd5..8158d7166d2 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -151,6 +151,7 @@ DOCS_MODULES += \ jdk.crypto.ec \ jdk.dynalink \ jdk.editpad \ + jdk.hotspot.agent \ jdk.httpserver \ jdk.incubator.httpclient \ jdk.jartool \ From 1d389cce1ce483de88558158cc08381ba7c2134b Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 22 May 2017 09:47:31 +0200 Subject: [PATCH 06/13] 8180480: Use "requires transitive" relationship when determining modules for javadoc Reviewed-by: mchung, erikj --- make/Docs.gmk | 12 +++++------ make/common/Modules.gmk | 46 +++++++++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/make/Docs.gmk b/make/Docs.gmk index 077750bec36..06237cbba63 100644 --- a/make/Docs.gmk +++ b/make/Docs.gmk @@ -55,7 +55,6 @@ COPYRIGHT_URL := {@docroot}/../legal/cpyr.html LICENSE_URL := http://www.oracle.com/technetwork/java/javase/terms/license/java9speclicense.html REDISTRIBUTION_URL := http://www.oracle.com/technetwork/java/redist-137594.html - # In order to get a specific ordering it's necessary to specify the total # ordering of tags as the tags are otherwise ordered in order of definition. JAVADOC_TAGS := \ @@ -211,10 +210,10 @@ endef SetupApiDocsGeneration = $(NamedParamsMacroTemplate) define SetupApiDocsGenerationBody - # Figure out all modules, both specified and transitive, that will be processed - # by javadoc. - $1_TRANSITIVE_MODULES := $$(call FindTransitiveDepsForModules, $$($1_MODULES)) - $1_ALL_MODULES := $$(sort $$($1_MODULES) $$($1_TRANSITIVE_MODULES)) + # Figure out all modules, both specified and transitive indirect exports, that + # will be processed by javadoc. + $1_INDIRECT_EXPORTS := $$(call FindTransitiveIndirectDepsForModules, $$($1_MODULES)) + $1_ALL_MODULES := $$(sort $$($1_MODULES) $$($1_INDIRECT_EXPORTS)) ifeq ($$(ENABLE_FULL_DOCS), true) # Tell the ModuleGraph taglet to generate html links to soon-to-be-created @@ -334,7 +333,8 @@ $(eval $(call SetupApiDocsGeneration, JDK_API, \ ################################################################################ # Setup generation of the Java SE API documentation (javadoc + modulegraph) -# The Java SE module scope is just java.se.ee and it's transitive modules. +# The Java SE module scope is just java.se.ee and it's transitive indirect +# exports. JAVASE_JAVADOC_MODULES := java.se.ee JAVASE_JAVADOC_OVERVIEW := $(JDK_TOPDIR)/src/java.base/share/classes/overview-core.html diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index 8158d7166d2..d65adcd6aef 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -299,7 +299,8 @@ GetModuleSrcPath = \ $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS)))) ################################################################################ -# Extract module dependencies from module-info.java files. +# Extract module dependencies from module-info.java files, both normal +# dependencies ("requires"), and indirect exports ("requires transitive"). MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk @@ -321,17 +322,31 @@ $(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \ gsub(/^ +\*.*/, ""); \ gsub(/ /, ""); \ printf(" %s", $$0) } \ + END { printf("\n") }' $m && \ + $(PRINTF) "TRANSITIVE_MODULES_$(call GetModuleNameFromModuleInfo, $m) :=" && \ + $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ + BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ + /^ *requires *transitive/ { \ + sub(/;/, ""); \ + sub(/requires/, ""); \ + sub(/transitive/, ""); \ + sub(/\/\/.*/, ""); \ + sub(/\/\*.*\*\//, ""); \ + gsub(/^ +\*.*/, ""); \ + gsub(/ /, ""); \ + printf(" %s", $$0) } \ END { printf("\n") }' $m \ ) >> $@ $(NEWLINE)) -include $(MODULE_DEPS_MAKEFILE) -# Param 1: Module to find deps for +# Find dependencies ("requires") for a given module. +# Param 1: Module to find dependencies for. FindDepsForModule = \ $(DEPS_$(strip $1)) -# Finds transitive dependencies in 3 levels. -# Param 1: Module to find transitive deps for +# Find dependencies ("requires") transitively in 3 levels for a given module. +# Param 1: Module to find dependencies for. FindTransitiveDepsForModule = \ $(sort $(call FindDepsForModule, $1) \ $(foreach m, $(call FindDepsForModule, $1), \ @@ -339,11 +354,30 @@ FindTransitiveDepsForModule = \ $(foreach n, $(call FindDepsForModule, $m), \ $(call FindDepsForModule, $n)))) -# Finds transitive dependencies in 3 levels for a set of modules. -# Param 1: List of modules to find transitive deps for +# Find dependencies ("requires") transitively in 3 levels for a set of modules. +# Param 1: List of modules to find dependencies for. FindTransitiveDepsForModules = \ $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m))) +# Find indirect exported modules ("requires transitive") for a given module . +# Param 1: Module to find indirect exported modules for. +FindIndirectExportsForModule = \ + $(TRANSITIVE_MODULES_$(strip $1)) + +# Finds indirect exported modules transitively in 3 levels for a given module. +# Param 1: Module to find indirect exported modules for. +FindTransitiveIndirectDepsForModule = \ + $(sort $(call FindIndirectExportsForModule, $1) \ + $(foreach m, $(call FindIndirectExportsForModule, $1), \ + $(call FindIndirectExportsForModule, $m) \ + $(foreach n, $(call FindIndirectExportsForModule, $m), \ + $(call FindIndirectExportsForModule, $n)))) + +# Finds indirect exported modules transitively in 3 levels for a set of modules. +# Param 1: List of modules to find indirect exported modules for. +FindTransitiveIndirectDepsForModules = \ + $(sort $(foreach m, $1, $(call FindTransitiveIndirectDepsForModule, $m))) + # Upgradeable modules are those that are either defined as upgradeable or that # require an upradeable module. FindAllUpgradeableModules = \ From f6eceb7756eeb661355a6a4ad708479e8677f873 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Mon, 22 May 2017 15:28:29 -0700 Subject: [PATCH 07/13] 8180793: move jdk.test.lib.wrappers.* to jdk.test.lib package Reviewed-by: mchung --- test/lib/jdk/test/lib/{wrappers => }/InfiniteLoop.java | 2 +- test/lib/jdk/test/lib/{wrappers => }/TimeLimitedRunner.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename test/lib/jdk/test/lib/{wrappers => }/InfiniteLoop.java (98%) rename test/lib/jdk/test/lib/{wrappers => }/TimeLimitedRunner.java (99%) diff --git a/test/lib/jdk/test/lib/wrappers/InfiniteLoop.java b/test/lib/jdk/test/lib/InfiniteLoop.java similarity index 98% rename from test/lib/jdk/test/lib/wrappers/InfiniteLoop.java rename to test/lib/jdk/test/lib/InfiniteLoop.java index dbee901f8c0..15097b66ff5 100644 --- a/test/lib/jdk/test/lib/wrappers/InfiniteLoop.java +++ b/test/lib/jdk/test/lib/InfiniteLoop.java @@ -21,7 +21,7 @@ * questions. */ -package jdk.test.lib.wrappers; +package jdk.test.lib; import java.util.Objects; diff --git a/test/lib/jdk/test/lib/wrappers/TimeLimitedRunner.java b/test/lib/jdk/test/lib/TimeLimitedRunner.java similarity index 99% rename from test/lib/jdk/test/lib/wrappers/TimeLimitedRunner.java rename to test/lib/jdk/test/lib/TimeLimitedRunner.java index 73d53b43b12..cea92f34405 100644 --- a/test/lib/jdk/test/lib/wrappers/TimeLimitedRunner.java +++ b/test/lib/jdk/test/lib/TimeLimitedRunner.java @@ -21,7 +21,7 @@ * questions. */ -package jdk.test.lib.wrappers; +package jdk.test.lib; import java.util.Objects; import java.util.concurrent.Callable; From db214b049ecbdfea4ca2294eb8dcb8ee1e5e7cf3 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Fri, 26 May 2017 00:29:11 +0000 Subject: [PATCH 08/13] Added tag jdk-9+171 for changeset 562ad59ed4e7 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 1aa95fe45fa..942f685a939 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -413,3 +413,4 @@ ba5b16c9c6d80632b61959a33d424b1c3398ce62 jdk-9+166 143d4c87bc1ef1ed6dadd613cd9dd4488fdefc29 jdk-9+168 b25838a28195f4b6dab34668411eedd2d366a16c jdk-9+169 4d163ec59d989a9261ed7f848bc6303f90869af5 jdk-9+170 +4c12464a907db4656c1033f56fa49cba643ac629 jdk-9+171 From 83e1ea4eeb5e1a4f08ba2c3a9fc2fc46cd2298f4 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Fri, 26 May 2017 01:00:32 +0000 Subject: [PATCH 09/13] Added tag jdk-10+9 for changeset 72bd5e8aab2f --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index bf64ef1712e..f1447c76afb 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -423,3 +423,4 @@ b25838a28195f4b6dab34668411eedd2d366a16c jdk-9+169 aa3c97810d7c484c93a2fd75d3c76ff574deb6d8 jdk-10+7 df33ef1dc163f994177fd97d4d0e73a1e3cb5d85 jdk-10+8 +b94be69cbb1d2943b886bf2d458745756df146e4 jdk-10+9 From 79f9ab423571c585e2716d06894a94bd36299d44 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Mon, 29 May 2017 14:06:24 +0200 Subject: [PATCH 10/13] 8180651: Make target to run tests on exploded image Reviewed-by: ihse --- common/doc/testing.html | 4 +++- common/doc/testing.md | 6 ++++++ make/Help.gmk | 2 ++ make/Main.gmk | 15 +++++++++++++-- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/common/doc/testing.html b/common/doc/testing.html index 265be8b9e8a..1b782f07eae 100644 --- a/common/doc/testing.html +++ b/common/doc/testing.html @@ -29,13 +29,15 @@

        Using the run-test framework

        This new way of running tests is developer-centric. It assumes that you have built a jdk locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.

        +

        The main target "run-test" uses the jdk-image as the tested product. There is also an alternate target "exploded-run-test" that uses the exploded image instead. Not all tests will run successfully on the exploded image, but using this target can greatly improve rebuild times for certain workflows.

        Some example command-lines:

        $ make run-test-tier1
         $ make run-test-jdk_lang JTREG="JOBS=8"
         $ make run-test TEST=jdk_lang
         $ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1"
         $ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"
        -$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
        +$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java" +$ make exploded-run-test TEST=hotspot_tier1

        Test selection

        All functionality is available using the run-test make target. In this use case, the test or tests to be executed is controlled using the TEST variable. To speed up subsequent test runs with no source code changes, run-test-only can be used instead, which do not depend on the source and test image build.

        For some common top-level tests, direct make targets have been generated. This includes all JTreg test groups, the hotspot gtest, and custom tests (if present). This means that make run-test-tier1 is equivalent to make run-test TEST="tier1", but the latter is more tab-completion friendly. For more complex test runs, the run-test TEST="x" solution needs to be used.

        diff --git a/common/doc/testing.md b/common/doc/testing.md index f84bd27dda2..231755c92b1 100644 --- a/common/doc/testing.md +++ b/common/doc/testing.md @@ -7,6 +7,11 @@ built a jdk locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve. +The main target "run-test" uses the jdk-image as the tested product. There is +also an alternate target "exploded-run-test" that uses the exploded image +instead. Not all tests will run successfully on the exploded image, but using +this target can greatly improve rebuild times for certain workflows. + Some example command-lines: $ make run-test-tier1 @@ -15,6 +20,7 @@ Some example command-lines: $ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1" $ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug" $ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java" + $ make exploded-run-test TEST=hotspot_tier1 ## Test selection diff --git a/make/Help.gmk b/make/Help.gmk index c9a06d291af..4514eb08b8d 100644 --- a/make/Help.gmk +++ b/make/Help.gmk @@ -56,6 +56,8 @@ help: $(info $(_) make test # Run tests, default is all tests (see TEST below)) $(info $(_) make run-test- # Run test, e.g. run-test-tier1) $(info $(_) make run-test TEST= # Run test(s) given by TEST specification) + $(info $(_) make exploded-run-test TEST= # Run test(s) on the exploded image instead of) + $(info $(_) # the full jdk image) $(info ) $(info Targets for cleaning) $(info $(_) make clean # Remove all files generated by make, but not those) diff --git a/make/Main.gmk b/make/Main.gmk index ab6eb7d2e2b..7d85c1b062a 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -450,13 +450,18 @@ define DeclareRunTestRecipe run-test-$1: +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$1") + exploded-run-test-$1: + +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test \ + TEST="$1" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR)) + endef # ALL_NAMED_TESTS is defined in FindTests.gmk $(foreach t, $(ALL_NAMED_TESTS), $(eval $(call DeclareRunTestRecipe,$t))) ALL_TEST_TARGETS := $(addprefix run-test-, $(ALL_NAMED_TESTS)) +ALL_EXPLODED_TEST_TARGETS := $(addprefix exploded-run-test-, $(ALL_NAMED_TESTS)) -ALL_TARGETS += $(ALL_TEST_TARGETS) +ALL_TARGETS += $(ALL_TEST_TARGETS) $(ALL_EXPLODED_TEST_TARGETS) ################################################################################ # Build tests @@ -485,6 +490,10 @@ test-image-jdk-jtreg-native: run-test: +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$(TEST)") +exploded-run-test: + +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test \ + TEST="$(TEST)" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR)) + ifeq ($(BUILD_GTEST), true) test-image-hotspot-gtest: +($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f GtestImage.gmk) @@ -514,7 +523,7 @@ ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \ test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \ test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \ test-failure-handler test-image-failure-handler test-image-hotspot-gtest \ - run-test + run-test exploded-run-test ################################################################################ # Run tests @@ -807,9 +816,11 @@ else test: jdk-image test-image run-test: jdk-image test-image + exploded-run-test: exploded-image test-image # Declare dependency for all generated test targets $(foreach t, $(ALL_TEST_TARGETS), $(eval $t: jdk-image test-image)) + $(foreach t, $(ALL_EXPLODED_TEST_TARGETS), $(eval $t: exploded-image test-image)) create-buildjdk-copy: jdk.jlink-java java.base-gendata \ $(addsuffix -java, $(INTERIM_IMAGE_MODULES)) From 6d94dde81362e5bc451048afbd0bc5466c825009 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 30 May 2017 14:56:43 -0700 Subject: [PATCH 11/13] 8180887: move FileUtils to top level testlibrary Reviewed-by: psandoz --- test/lib/jdk/test/lib/util/FileUtils.java | 229 ++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 test/lib/jdk/test/lib/util/FileUtils.java diff --git a/test/lib/jdk/test/lib/util/FileUtils.java b/test/lib/jdk/test/lib/util/FileUtils.java new file mode 100644 index 00000000000..8bbaded9586 --- /dev/null +++ b/test/lib/jdk/test/lib/util/FileUtils.java @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.util; + +import jdk.test.lib.Platform; + +import java.io.IOException; +import java.nio.file.DirectoryNotEmptyException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + + +/** + * Common library for various test file utility functions. + */ +public final class FileUtils { + private static final boolean IS_WINDOWS = Platform.isWindows(); + private static final int RETRY_DELETE_MILLIS = IS_WINDOWS ? 500 : 0; + private static final int MAX_RETRY_DELETE_TIMES = IS_WINDOWS ? 15 : 0; + + /** + * Deletes a file, retrying if necessary. + * + * @param path the file to delete + * + * @throws NoSuchFileException + * if the file does not exist (optional specific exception) + * @throws DirectoryNotEmptyException + * if the file is a directory and could not otherwise be deleted + * because the directory is not empty (optional specific exception) + * @throws IOException + * if an I/O error occurs + */ + public static void deleteFileWithRetry(Path path) throws IOException { + try { + deleteFileWithRetry0(path); + } catch (InterruptedException x) { + throw new IOException("Interrupted while deleting.", x); + } + } + + /** + * Deletes a file, retrying if necessary. + * No exception thrown if file doesn't exist. + * + * @param path the file to delete + * + * @throws NoSuchFileException + * if the file does not exist (optional specific exception) + * @throws DirectoryNotEmptyException + * if the file is a directory and could not otherwise be deleted + * because the directory is not empty (optional specific exception) + * @throws IOException + * if an I/O error occurs + */ + public static void deleteFileIfExistsWithRetry(Path path) throws IOException { + try { + if (Files.exists(path)) { + deleteFileWithRetry0(path); + } + } catch (InterruptedException x) { + throw new IOException("Interrupted while deleting.", x); + } + } + + private static void deleteFileWithRetry0(Path path) + throws IOException, InterruptedException { + int times = 0; + IOException ioe = null; + while (true) { + try { + Files.delete(path); + while (Files.exists(path)) { + times++; + if (times > MAX_RETRY_DELETE_TIMES) { + throw new IOException("File still exists after " + times + " waits."); + } + Thread.sleep(RETRY_DELETE_MILLIS); + } + break; + } catch (NoSuchFileException | DirectoryNotEmptyException x) { + throw x; + } catch (IOException x) { + // Backoff/retry in case another process is accessing the file + times++; + if (ioe == null) { + ioe = x; + } else { + ioe.addSuppressed(x); + } + + if (times > MAX_RETRY_DELETE_TIMES) { + throw ioe; + } + Thread.sleep(RETRY_DELETE_MILLIS); + } + } + } + + /** + * Deletes a directory and its subdirectories, retrying if necessary. + * + * @param dir the directory to delete + * + * @throws IOException + * If an I/O error occurs. Any such exceptions are caught + * internally. If only one is caught, then it is re-thrown. + * If more than one exception is caught, then the second and + * following exceptions are added as suppressed exceptions of the + * first one caught, which is then re-thrown. + */ + public static void deleteFileTreeWithRetry(Path dir) throws IOException { + IOException ioe = null; + final List excs = deleteFileTreeUnchecked(dir); + if (!excs.isEmpty()) { + ioe = excs.remove(0); + for (IOException x : excs) { + ioe.addSuppressed(x); + } + } + if (ioe != null) { + throw ioe; + } + } + + public static List deleteFileTreeUnchecked(Path dir) { + final List excs = new ArrayList<>(); + try { + java.nio.file.Files.walkFileTree(dir, new SimpleFileVisitor<>() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { + try { + deleteFileWithRetry0(file); + } catch (IOException x) { + excs.add(x); + } catch (InterruptedException x) { + excs.add(new IOException("Interrupted while deleting.", x)); + return FileVisitResult.TERMINATE; + } + return FileVisitResult.CONTINUE; + } + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) { + try { + deleteFileWithRetry0(dir); + } catch (IOException x) { + excs.add(x); + } catch (InterruptedException x) { + excs.add(new IOException("Interrupted while deleting.", x)); + return FileVisitResult.TERMINATE; + } + return FileVisitResult.CONTINUE; + } + @Override + public FileVisitResult visitFileFailed(Path file, IOException exc) { + excs.add(exc); + return FileVisitResult.CONTINUE; + } + }); + } catch (IOException x) { + excs.add(x); + } + return excs; + } + + /** + * Checks whether all file systems are accessible. This is performed + * by checking free disk space on all mounted file systems via a + * separate, spawned process. File systems are considered to be + * accessible if this process completes successfully before a given + * fixed duration has elapsed. + * + * @implNote On Unix this executes the {@code df} command in a separate + * process and on Windows always returns {@code true}. + */ + public static boolean areFileSystemsAccessible() throws IOException { + boolean areFileSystemsAccessible = true; + if (!IS_WINDOWS) { + // try to check whether 'df' hangs + System.out.println("\n--- df output ---"); + System.out.flush(); + Process proc = new ProcessBuilder("df").inheritIO().start(); + try { + proc.waitFor(90, TimeUnit.SECONDS); + } catch (InterruptedException ignored) { + } + try { + int exitValue = proc.exitValue(); + if (exitValue != 0) { + System.err.printf("df process exited with %d != 0%n", + exitValue); + areFileSystemsAccessible = false; + } + } catch (IllegalThreadStateException ignored) { + System.err.println("df command apparently hung"); + areFileSystemsAccessible = false; + } + } + return areFileSystemsAccessible; + } +} From 88c4940eeb34d8d2a702a21ce1ef8ad7cf781b62 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 30 May 2017 21:07:14 -0700 Subject: [PATCH 12/13] 8180888: move jdk.testlibrary.JarUtils to the top level testlibrary Reviewed-by: weijun --- test/lib/jdk/test/lib/util/JarUtils.java | 148 +++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 test/lib/jdk/test/lib/util/JarUtils.java diff --git a/test/lib/jdk/test/lib/util/JarUtils.java b/test/lib/jdk/test/lib/util/JarUtils.java new file mode 100644 index 00000000000..76705f5395c --- /dev/null +++ b/test/lib/jdk/test/lib/util/JarUtils.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.util; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; + +/** + * Common library for various test jar file utility functions. + */ +public final class JarUtils { + + /** + * Create jar file with specified files. If a specified file does not exist, + * a new jar entry will be created with the file name itself as the content. + */ + public static void createJar(String dest, String... files) + throws IOException { + try (JarOutputStream jos = new JarOutputStream( + new FileOutputStream(dest), new Manifest())) { + for (String file : files) { + System.out.println(String.format("Adding %s to %s", + file, dest)); + + // add an archive entry, and write a file + jos.putNextEntry(new JarEntry(file)); + try (FileInputStream fis = new FileInputStream(file)) { + fis.transferTo(jos); + } catch (FileNotFoundException e) { + jos.write(file.getBytes()); + } + } + } + System.out.println(); + } + + /** + * Add or remove specified files to existing jar file. If a specified file + * to be updated or added does not exist, the jar entry will be created + * with the file name itself as the content. + * + * @param src the original jar file name + * @param dest the new jar file name + * @param files the files to update. The list is broken into 2 groups + * by a "-" string. The files before in the 1st group will + * be either updated or added. The files in the 2nd group + * will be removed. If no "-" exists, all files belong to + * the 1st group. + */ + public static void updateJar(String src, String dest, String... files) + throws IOException { + try (JarOutputStream jos = new JarOutputStream( + new FileOutputStream(dest))) { + + // copy each old entry into destination unless the entry name + // is in the updated list + List updatedFiles = new ArrayList<>(); + try (JarFile srcJarFile = new JarFile(src)) { + Enumeration entries = srcJarFile.entries(); + while (entries.hasMoreElements()) { + JarEntry entry = entries.nextElement(); + String name = entry.getName(); + boolean found = false; + boolean update = true; + for (String file : files) { + if (file.equals("-")) { + update = false; + } else if (name.equals(file)) { + updatedFiles.add(file); + found = true; + break; + } + } + + if (found) { + if (update) { + System.out.println(String.format("Updating %s with %s", + dest, name)); + jos.putNextEntry(new JarEntry(name)); + try (FileInputStream fis = new FileInputStream(name)) { + fis.transferTo(jos); + } catch (FileNotFoundException e) { + jos.write(name.getBytes()); + } + } else { + System.out.println(String.format("Removing %s from %s", + name, dest)); + } + } else { + System.out.println(String.format("Copying %s to %s", + name, dest)); + jos.putNextEntry(entry); + srcJarFile.getInputStream(entry).transferTo(jos); + } + } + } + + // append new files + for (String file : files) { + if (file.equals("-")) { + break; + } + if (!updatedFiles.contains(file)) { + System.out.println(String.format("Adding %s with %s", + dest, file)); + jos.putNextEntry(new JarEntry(file)); + try (FileInputStream fis = new FileInputStream(file)) { + fis.transferTo(jos); + } catch (FileNotFoundException e) { + jos.write(file.getBytes()); + } + } + } + } + System.out.println(); + } + +} From 1ccebabd11bc30ab0bf4dd9f1f03bd4359ee29c1 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 30 May 2017 21:14:02 -0700 Subject: [PATCH 13/13] 8180805: move RandomFactory to the top level testlibrary Reviewed-by: bpb, rriggs --- test/lib/jdk/test/lib/RandomFactory.java | 103 +++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 test/lib/jdk/test/lib/RandomFactory.java diff --git a/test/lib/jdk/test/lib/RandomFactory.java b/test/lib/jdk/test/lib/RandomFactory.java new file mode 100644 index 00000000000..8930a380008 --- /dev/null +++ b/test/lib/jdk/test/lib/RandomFactory.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib; + +import java.util.Random; +import java.util.SplittableRandom; + +/** + * Factory class which generates and prints to STDOUT a long-valued seed + * for use in initializing a PRNG. An instance of {@code Random} or + * {@code SplittableRandom} may likewise be obtained. + */ +public class RandomFactory { + /** + * Attempt to obtain the seed from the value of the "seed" property. + * @return The seed or {@code null} if the "seed" property was not set or + * could not be parsed. + */ + private static Long getSystemSeed() { + Long seed = null; + try { + // note that Long.valueOf(null) also throws a + // NumberFormatException so if the property is undefined this + // will still work correctly + seed = Long.valueOf(System.getProperty("seed")); + } catch (NumberFormatException e) { + // do nothing: seed is still null + } + + return seed; + } + + /** + * Obtain a seed from an independent PRNG. + * + * @return A random seed. + */ + private static long getRandomSeed() { + return new Random().nextLong(); + } + + /** + * Obtain and print to STDOUT a seed appropriate for initializing a PRNG. + * If the system property "seed" is set and has value which may be correctly + * parsed it is used, otherwise a seed is generated using an independent + * PRNG. + * + * @return The seed. + */ + public static long getSeed() { + Long seed = getSystemSeed(); + if (seed == null) { + seed = getRandomSeed(); + } + System.out.println("Seed from RandomFactory = "+seed+"L"); + return seed; + } + + /** + * Obtain and print to STDOUT a seed and use it to initialize a new + * {@code Random} instance which is returned. If the system + * property "seed" is set and has value which may be correctly parsed it + * is used, otherwise a seed is generated using an independent PRNG. + * + * @return The {@code Random} instance. + */ + public static Random getRandom() { + return new Random(getSeed()); + } + + /** + * Obtain and print to STDOUT a seed and use it to initialize a new + * {@code SplittableRandom} instance which is returned. If the system + * property "seed" is set and has value which may be correctly parsed it + * is used, otherwise a seed is generated using an independent PRNG. + * + * @return The {@code SplittableRandom} instance. + */ + public static SplittableRandom getSplittableRandom() { + return new SplittableRandom(getSeed()); + } +}