From 26ae2cbf89f5195ee05bc443b52e7a4adef5d9ce Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 9 May 2017 17:20:10 -0700 Subject: [PATCH 01/66] 8179479: Add new styles to enable HTML 5 tables Reviewed-by: bpatel --- .../doclets/toolkit/resources/stylesheet.css | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css index 985466b8c54..073dc84bf63 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css @@ -789,4 +789,82 @@ ul.ui-autocomplete li { z-index: 1; } +/* + * Styles for user-provided tables. + * + * borderless: + * No borders, vertical margins, styled caption. + * This style is provided for use with existing doc comments. + * In general, borderless tables should not be used for layout purposes. + * + * plain: + * Plain borders around table and cells, vertical margins, styled caption. + * Best for small tables or for complex tables for tables with cells that span + * rows and columns, when the "striped" style does not work well. + * + * striped: + * Borders around the table and vertical borders between cells, striped rows, + * vertical margins, styled caption. + * Best for tables that have a header row, and a body containing a series of simple rows. + */ +table.borderless, +table.plain, +table.striped { + margin-top: 10px; + margin-bottom: 10px; +} + +table.borderless > caption, +table.plain > caption, +table.striped > caption { + font-weight: bold; + font-size: smaller; +} + +table.borderless th, table.borderless td, +table.plain th, table.plain td, +table.striped th, table.striped td { + padding: 2px 5px; +} + +table.borderless, +table.borderless > thead > tr > th, table.borderless > tbody > tr > th, table.borderless > tr > th, +table.borderless > thead > tr > td, table.borderless > tbody > tr > td, table.borderless > tr > td { + border: none; +} +table.borderless > thead > tr, table.borderless > tbody > tr, table.borderless > tr { + background-color: transparent; +} + +table.plain { + border-collapse: collapse; + border: 1px solid black; +} +table.plain > thead > tr, table.plain > tbody tr, table.plain > tr { + background-color: transparent; +} +table.plain > thead > tr > th, table.plain > tbody > tr > th, table.plain > tr > th, +table.plain > thead > tr > td, table.plain > tbody > tr > td, table.plain > tr > td { + border: 1px solid black; +} + +table.striped { + border-collapse: collapse; + border: 1px solid black; +} +table.striped > thead { + background-color: #DDD; + border: 1px solid black; +} +table.striped > tbody > tr:nth-child(even) { + background-color: #EEE +} +table.striped > tbody > tr:nth-child(odd) { + background-color: #FFF +} +table.striped > thead > tr > th, table.striped > tbody > tr > th, +table.striped > tbody > tr > td, table.striped > tbody > tr > td { + border-left: 1px solid black; + border-right: 1px solid black; +} From a6a7d06315082554f590e08ff55f3d0ce92e4e26 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Tue, 9 May 2017 18:26:42 -0700 Subject: [PATCH 02/66] 8179868: Java API Docs of javax.xml.transform.stax contains TODOs Reviewed-by: lancea, bpb --- .../javax/xml/transform/stax/package.html | 74 +++++++++---------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/jaxp/src/java.xml/share/classes/javax/xml/transform/stax/package.html b/jaxp/src/java.xml/share/classes/javax/xml/transform/stax/package.html index abdd5ecd846..0275a36f737 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/transform/stax/package.html +++ b/jaxp/src/java.xml/share/classes/javax/xml/transform/stax/package.html @@ -1,7 +1,6 @@ + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - - javax.xml.transform.stax + + javax.xml.transform.stax - - - - - -

- Provides for StAX-specific transformation APIs. - TODO: better description(s). -

+ + + + + +

+ This package implements StAX-specific transformation APIs. It provides + classes which allow input from a StAX reader, that is, + {@link javax.xml.stream.XMLStreamReader} or {@link javax.xml.stream.XMLEventReader}, + and output to a StAX writer, that is, + {@link javax.xml.stream.XMLStreamWriter} or {@link javax.xml.stream.XMLEventWriter}. +

+

+ The {@link javax.xml.transform.stax.StAXSource} class encapsulates a + {@link javax.xml.stream.XMLStreamReader} or {@link javax.xml.stream.XMLEventReader} + and can be used as an input where a {@link javax.xml.transform.Source} + object is accepted. +

+

+ The {@link javax.xml.transform.stax.StAXResult} class encapsulates a + {@link javax.xml.stream.XMLStreamWriter} or {@link javax.xml.stream.XMLEventWriter} + and can be used as an output where a {@link javax.xml.transform.Result} + object is accepted. +

-

Package Specification

- - -

Related Documentation

- -

For overviews, tutorials, examples, guides, and tool documentation, please see:

- - - - - - @since 1.6 - + @since 1.6 + + From 69d205a2786968c360d266093c0ccee6329a97db Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 10 May 2017 09:02:51 +0200 Subject: [PATCH 03/66] 8178278: Move Standard Algorithm Names document to specs directory Reviewed-by: erikj --- make/Javadoc.gmk | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index 4d088b86a65..3b961f46511 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -367,13 +367,15 @@ COPY_SPEC_FILTER := %.html %.gif %.jpg %.mib %.css $(foreach m, $(ALL_MODULES), \ $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \ - $(if $(SPECS_$m), \ - $(eval $(call SetupCopyFiles, COPY_$m, \ - SRC := $(SPECS_$m), \ - FILES := $(filter $(COPY_SPEC_FILTER), $(call CacheFind, $(SPECS_$m))), \ - DEST := $(JAVADOC_OUTPUTDIR)/specs/, \ - )) \ - $(eval JDK_SPECS_TARGETS += $(COPY_$m)) \ + $(foreach d, $(SPECS_$m), \ + $(if $(filter $(COPY_SPEC_FILTER), $(call CacheFind, $d)), \ + $(eval $(call SetupCopyFiles, COPY_$m, \ + SRC := $d, \ + FILES := $(filter $(COPY_SPEC_FILTER), $(call CacheFind, $d)), \ + DEST := $(JAVADOC_OUTPUTDIR)/specs/, \ + )) \ + $(eval JDK_SPECS_TARGETS += $(COPY_$m)) \ + ) \ ) \ ) From d1a39aa352a36224904aa0d2669c065fb392f5e8 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 10 May 2017 18:27:31 +0200 Subject: [PATCH 04/66] 8179867: JDK9 b167: demos exist in JDK bundles Reviewed-by: ihse --- make/Bundles.gmk | 1 + make/Main.gmk | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/make/Bundles.gmk b/make/Bundles.gmk index 66436381e92..ba35dcbf48e 100644 --- a/make/Bundles.gmk +++ b/make/Bundles.gmk @@ -183,6 +183,7 @@ ifneq ($(filter product-bundles, $(MAKECMDGOALS)), ) $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ $(JDK_EXTRA_EXCLUDES) \ $(SYMBOLS_EXCLUDE_PATTERN) \ + $(JDK_IMAGE_HOMEDIR)/demo/% , \ $(ALL_JDK_FILES) \ ) diff --git a/make/Main.gmk b/make/Main.gmk index cb7c7ec44d4..81131518689 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -277,7 +277,10 @@ ALL_TARGETS += $(HOTSPOT_VARIANT_TARGETS) $(HOTSPOT_VARIANT_GENSRC_TARGETS) \ demos-jdk: +($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk) -ALL_TARGETS += demos-jdk +test-image-demos-jdk: + +($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk images) + +ALL_TARGETS += demos-jdk test-image-demos-jdk ################################################################################ # Jigsaw specific data and analysis targets. @@ -631,6 +634,7 @@ else # jdk libs, even though they don't need to. To avoid warnings, make sure they # aren't built until after libjava and libjvm are available to link to. demos-jdk: java.base-libs exploded-image-optimize + test-image-demos-jdk: demos-jdk # Declare dependency from -java to -gensrc $(foreach m, $(GENSRC_MODULES), $(eval $m-java: $m-gensrc)) @@ -963,7 +967,8 @@ docs-image: docs-jdk # This target builds the test image test-image: prepare-test-image test-image-hotspot-jtreg-native \ - test-image-jdk-jtreg-native test-image-failure-handler test-image-hotspot-gtest + test-image-jdk-jtreg-native test-image-failure-handler test-image-hotspot-gtest \ + test-image-demos-jdk # all-images builds all our deliverables as images. all-images: product-images test-image docs-image From 74f02ffc4632c882ac3b8291928766a35bbbbe51 Mon Sep 17 00:00:00 2001 From: Tim Bell Date: Wed, 10 May 2017 14:55:31 -0700 Subject: [PATCH 05/66] 8180129: Bundles.gmk:181: *** unterminated call to function 'filter-out': missing ')'. Stop Reviewed-by: erikj --- make/Bundles.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/Bundles.gmk b/make/Bundles.gmk index ba35dcbf48e..81321550e23 100644 --- a/make/Bundles.gmk +++ b/make/Bundles.gmk @@ -183,7 +183,7 @@ ifneq ($(filter product-bundles, $(MAKECMDGOALS)), ) $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ $(JDK_EXTRA_EXCLUDES) \ $(SYMBOLS_EXCLUDE_PATTERN) \ - $(JDK_IMAGE_HOMEDIR)/demo/% + $(JDK_IMAGE_HOMEDIR)/demo/% \ , \ $(ALL_JDK_FILES) \ ) From fd872c65c8ce697d4c3e5c3a5c6f438319bca7ce Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 10 May 2017 15:24:29 -0700 Subject: [PATCH 06/66] 8180041: Fix HTML 5 issues in java.corba Reviewed-by: alanb, lancea --- .../sun/corba/se/spi/monitoring/package.html | 4 +- .../share/classes/org/omg/CORBA/Any.java | 4 +- .../share/classes/org/omg/CORBA/ORB.java | 10 ++- .../org/omg/CORBA/doc-files/compliance.html | 2 +- .../omg/CORBA/doc-files/generatedfiles.html | 2 +- .../share/classes/org/omg/CORBA/package.html | 20 +++--- .../org/omg/CORBA/portable/package.html | 8 +-- .../classes/org/omg/CORBA_2_3/package.html | 8 +-- .../org/omg/PortableInterceptor/IOP.idl | 4 +- .../omg/PortableInterceptor/Interceptors.idl | 72 ++++++++++--------- .../org/omg/PortableInterceptor/package.html | 8 +-- .../org/omg/PortableServer/package.html | 8 +-- 12 files changed, 78 insertions(+), 72 deletions(-) diff --git a/corba/src/java.corba/share/classes/com/sun/corba/se/spi/monitoring/package.html b/corba/src/java.corba/share/classes/com/sun/corba/se/spi/monitoring/package.html index 4a72719c0cf..f73b0cbb907 100644 --- a/corba/src/java.corba/share/classes/com/sun/corba/se/spi/monitoring/package.html +++ b/corba/src/java.corba/share/classes/com/sun/corba/se/spi/monitoring/package.html @@ -1,4 +1,4 @@ - + @@ -6,7 +6,7 @@ package - -Provides the mapping of the OMG CORBA APIs to the JavaTM + +Provides the mapping of the OMG CORBA APIs to the Java™ programming language, including the class ORB, which is implemented so that a programmer can use it as a fully-functional Object Request Broker (ORB). @@ -427,7 +427,7 @@ will contain the static methods needed for manipulating instances of the type, in this case, Account objects. - +

The narrow Method

When an object is the return value for a method, it is returned in the form of a generic object, either an org.omg.CORBA.Object object @@ -465,7 +465,7 @@ tutorial uses a narrow method that looks like this: helloImpl = HelloHelper.narrow(ncRef.resolve_str(name)); - +

Example of a Basic Helper Class

A basic helper class, for purposes of this explanation, is one with the methods that are provided by every helper class, plus a narrow @@ -671,7 +671,7 @@ abstract public class AddressHelper      WStringSeqHelper      WStringValueHelper - +

Other Classes

The other classes and interfaces in the CORBA package, which are @@ -868,17 +868,17 @@ For overviews, guides, and a tutorial, please see: -

+

CORBA Features Not Implemented in Java IDL

Some of the API included in org.omg subpackages is provided for conformance with the current OMG CORBA specification but is not implemented -in Sun's release of the JDKTM. This enables +in Sun's release of the JDK™. This enables other JDK licensees to provide implementations of this API in standard extensions and products. -

+

Features That Throw NO_IMPLEMENT

Some of the API included in org.omg subpackages throw diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/portable/package.html b/corba/src/java.corba/share/classes/org/omg/CORBA/portable/package.html index c8f6b33ae37..e0f5cbb0372 100644 --- a/corba/src/java.corba/share/classes/org/omg/CORBA/portable/package.html +++ b/corba/src/java.corba/share/classes/org/omg/CORBA/portable/package.html @@ -1,8 +1,8 @@ - + - + Provides a portability layer, that is, a set of ORB APIs that makes it possible for code generated @@ -38,7 +38,7 @@ can call into these ORB APIs.

- +


CORBA Features Throwing NO_IMPLEMENT() Exceptions


diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/package.html b/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/package.html index c1869b1c512..7a82edb9275 100644 --- a/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/package.html +++ b/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/package.html @@ -1,4 +1,4 @@ - + @@ -6,7 +6,7 @@ package - + The CORBA_2_3 package defines additions to existing CORBA interfaces in the Java[tm] Standard Edition 6.   These changes occurred in recent revisions to the CORBA API defined by the OMG.  The new methods were @@ -46,7 +46,7 @@ the Java[tm] Platform, Standard Edition 6, ORB complies, see Official Specifications for CORBA support in Java[tm] SE 6.

- + The following methods in the abstract class org.omg.CORBA_2_3.ORB are unimplemented:

    diff --git a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/IOP.idl b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/IOP.idl index d3c4ed75e15..3dc071dc1bb 100644 --- a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/IOP.idl +++ b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/IOP.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -425,7 +425,7 @@ module IOP { * encoded using GIOP 1.2 with a TCS-W of UTF-16. This service context * may be sent on Reply messages with a reply_status of SYSTEM_EXCEPTION * or USER_EXCEPTION. The usage of this service context is defined - * by language mappings.

    + * by language mappings.

    * * IDL/Java: ptc/02-01-22: 1.15.2: * When a System Exception is marshaled, its GIOP Reply message shall diff --git a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/Interceptors.idl b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/Interceptors.idl index bcb9b544a32..ca2612e5719 100644 --- a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/Interceptors.idl +++ b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/Interceptors.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -580,7 +580,8 @@ module PortableInterceptor { * to access it will result in a BAD_INV_ORDER being thrown * with a standard minor code of 14. * - * + *
    + * * * * @@ -597,42 +598,42 @@ module PortableInterceptor { * * * - * + * * * * * * * - * + * * * * * * * - * + * * * * * * * - * + * * * * * * * - * + * * * * * * * - * + * * * * @@ -640,7 +641,7 @@ module PortableInterceptor { * * * - * + * * * * @@ -648,14 +649,14 @@ module PortableInterceptor { * * * - * + * * * * * * * - * + * * * * @@ -663,14 +664,14 @@ module PortableInterceptor { * * * - * + * * * * * * * - * + * * * * @@ -678,21 +679,21 @@ module PortableInterceptor { * * - * + * * * * * * * - * + * * * * * * * - * + * * * * @@ -704,14 +705,14 @@ module PortableInterceptor { * * * - * + * * * * * * * - * + * * * * @@ -719,49 +720,49 @@ module PortableInterceptor { * * * - * + * * * * * * * - * + * * * * * * * - * + * * * * * * * - * + * * * * * * * - * + * * * * * * * - * + * * * * * * * - * + * * * * @@ -935,7 +936,8 @@ module PortableInterceptor { * standard minor code of 14. * * - *
    Shows the validity of each attribute or operation
     Inherited from RequestInfo:

    request_id

    request_id

    yesyesyesyesyes

    operation

    operation

    yesyesyesyesyes

    arguments

    arguments

    yes1no yesno no

    exceptions

    exceptions

    yesno yesyesyes

    contexts

    contexts

    yesno yesyesyes

    operation_context

    operation_context

    yesno yesyes

    result

    result

    no no yesno

    response_expected

    response_expected

    yesyesyesyesyes

    sync_scope

    sync_scope

    yesno yesyes

    reply_status

    reply_status

    no no yesyesyes

    forward_reference

    forward_reference

    no no no yes2 *

    get_slot

    get_slot

    yesyesyesyesyes

    get_request_service_context

    get_request_service_context

    yesno yesyesyes

    get_reply_service_context

    get_reply_service_context

    no no yesClientRequestInfo-specific:

    target

    target

    yesyesyesyesyes

    effective_target

    effective_target

    yesyesyesyes

    effective_profile

    effective_profile

    yesyesyesyesyes

    received_exception

    received_exception

    no no no yesno

    received_exception_id

    received_exception_id

    no no no yesno

    get_effective_component

    get_effective_component

    yesno yesyesyes

    get_effective_components

    get_effective_components

    yesno yesyesyes

    get_request_policy

    get_request_policy

    yesno yesyesyes

    add_request_service_context

    add_request_service_context

    yesno no
    + *
    + * * * * @@ -953,21 +955,21 @@ module PortableInterceptor { * * * - * + * * * * * * * - * + * * * * * * * - * + * * * * @@ -975,21 +977,21 @@ module PortableInterceptor { * * - * + * * * * * * * - * + * * * * * * * - * + * * * * @@ -997,7 +999,7 @@ module PortableInterceptor { * * * - * + * * * * @@ -1005,14 +1007,14 @@ module PortableInterceptor { * * * - * + * * * * * * * - * + * * * * diff --git a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/package.html b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/package.html index 3e192706b72..f35c5347b3f 100644 --- a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/package.html +++ b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/package.html @@ -1,9 +1,9 @@ - + - + Provides a mechanism to register ORB hooks through which ORB services can intercept the normal flow of execution of the ORB. @@ -52,7 +52,7 @@ See the javadocs for class {@link org.omg.PortableInterceptor.ORBInitializer ORBInitializer} for how to go about registering interceptors. - +

    Known limitations / unimplemented methods in package org.omg.PortableInterceptor

    diff --git a/corba/src/java.corba/share/classes/org/omg/PortableServer/package.html b/corba/src/java.corba/share/classes/org/omg/PortableServer/package.html index cabb3b46055..9994e12ad97 100644 --- a/corba/src/java.corba/share/classes/org/omg/PortableServer/package.html +++ b/corba/src/java.corba/share/classes/org/omg/PortableServer/package.html @@ -1,9 +1,9 @@ - + - + Provides classes and interfaces for making the server side of your applications portable across multivendor ORBs. @@ -160,7 +160,7 @@ follows exactly the same pattern as the other holder classes for basic types. Java IDL home page.

    Example Code

    - +

    Example Server Code

     import javax.naming.InitialContext;
    
    From 5adcb2d3d78dee73438e3e5eb2dc1f5c2f48d4a4 Mon Sep 17 00:00:00 2001
    From: Magnus Ihse Bursie 
    Date: Thu, 11 May 2017 08:56:44 +0200
    Subject: [PATCH 07/66] 8179105: Respect "include_in_docs" property from
     imported modules
    
    Reviewed-by: mchung, erikj
    ---
     make/common/Modules.gmk | 5 ++++-
     1 file changed, 4 insertions(+), 1 deletion(-)
    
    diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk
    index b14616ffc21..7477013efd5 100644
    --- a/make/common/Modules.gmk
    +++ b/make/common/Modules.gmk
    @@ -391,7 +391,10 @@ define ReadSingleImportMetaData
           else ifeq ($$(classloader), ext)
             PLATFORM_MODULES += $1
           endif
    -      DOCS_MODULES += $1
    +      ifneq ($$(include_in_docs), false)
    +        # defaults to true if unspecified
    +        DOCS_MODULES += $1
    +      endif
         else
           # Default to include in all
           JRE_MODULES += $1
    
    From f69b0746773d02f60a9f3ff0ae526eefc6847a63 Mon Sep 17 00:00:00 2001
    From: Magnus Ihse Bursie 
    Date: Thu, 11 May 2017 09:00:56 +0200
    Subject: [PATCH 08/66] 8174848: Remove gpl templates from hotspot/make
    
    Reviewed-by: erikj
    ---
     hotspot/make/templates/gpl-cp-header | 22 ----------------------
     hotspot/make/templates/gpl-header    | 20 --------------------
     2 files changed, 42 deletions(-)
     delete mode 100644 hotspot/make/templates/gpl-cp-header
     delete mode 100644 hotspot/make/templates/gpl-header
    
    diff --git a/hotspot/make/templates/gpl-cp-header b/hotspot/make/templates/gpl-cp-header
    deleted file mode 100644
    index f5b3943c4c9..00000000000
    --- a/hotspot/make/templates/gpl-cp-header
    +++ /dev/null
    @@ -1,22 +0,0 @@
    -Copyright (c) %YEARS%, Oracle and/or its affiliates. All rights reserved.
    -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.
    diff --git a/hotspot/make/templates/gpl-header b/hotspot/make/templates/gpl-header
    deleted file mode 100644
    index 9eadb48b613..00000000000
    --- a/hotspot/make/templates/gpl-header
    +++ /dev/null
    @@ -1,20 +0,0 @@
    -Copyright (c) %YEARS%, Oracle and/or its affiliates. All rights reserved.
    -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.
    
    From 116ba945dc498493ee6562ffd64a33380d50f9cb Mon Sep 17 00:00:00 2001
    From: Igor Ignatyev 
    Date: Thu, 11 May 2017 14:03:50 -0700
    Subject: [PATCH 09/66] 8180037: move jdk.test.lib.InMemoryJavaCompiler to a
     separate package
    
    Reviewed-by: mseledtsov, vlivanov
    ---
     hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java     | 2 +-
     hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java   | 2 +-
     hotspot/test/runtime/RedefineTests/ModifyAnonymous.java      | 5 ++---
     hotspot/test/runtime/Unsafe/DefineClass.java                 | 4 ++--
     hotspot/test/runtime/Unsafe/NestedUnsafe.java                | 5 +----
     hotspot/test/runtime/defineAnonClass/NestedUnsafe.java       | 5 ++---
     hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java      | 5 ++---
     hotspot/test/runtime/getSysPackage/GetSysPkgTest.java        | 2 +-
     hotspot/test/runtime/modules/ModuleStress/ModuleStress.java  | 3 +--
     .../test/runtime/modules/PatchModule/PatchModule2Dirs.java   | 3 +--
     hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java | 3 +--
     .../runtime/modules/PatchModule/PatchModuleClassList.java    | 2 +-
     .../runtime/modules/PatchModule/PatchModuleJavaBase.java     | 2 +-
     .../test/runtime/modules/PatchModule/PatchModuleTest.java    | 2 +-
     .../test/runtime/modules/PatchModule/PatchModuleTestJar.java | 2 +-
     .../runtime/modules/PatchModule/PatchModuleTestJarDir.java   | 4 ++--
     .../test/runtime/modules/PatchModule/PatchModuleTraceCL.java | 3 +--
     .../runtime/modules/Visibility/PatchModuleVisibility.java    | 2 +-
     .../test/runtime/modules/Visibility/XbootcpNoVisibility.java | 2 +-
     .../test/runtime/modules/Visibility/XbootcpVisibility.java   | 2 +-
     20 files changed, 25 insertions(+), 35 deletions(-)
    
    diff --git a/hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java b/hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java
    index 06be649608d..f648be9f484 100644
    --- a/hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java
    +++ b/hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java
    @@ -26,7 +26,7 @@ import java.util.List;
     import java.util.ArrayList;
     
     import jdk.test.lib.ByteCodeLoader;
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.Platform;
     
     import sun.management.ManagementFactoryHelper;
    diff --git a/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java b/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java
    index 186b235f0de..249993961b2 100644
    --- a/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java
    +++ b/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java
    @@ -31,7 +31,7 @@
      * @run main BootstrapRedefine
      */
     
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.ProcessTools;
     import jdk.test.lib.process.OutputAnalyzer;
     
    diff --git a/hotspot/test/runtime/RedefineTests/ModifyAnonymous.java b/hotspot/test/runtime/RedefineTests/ModifyAnonymous.java
    index 700a8f04e93..3eeb96e4a0a 100644
    --- a/hotspot/test/runtime/RedefineTests/ModifyAnonymous.java
    +++ b/hotspot/test/runtime/RedefineTests/ModifyAnonymous.java
    @@ -34,15 +34,14 @@
     
     import java.io.FileNotFoundException;
     import java.io.PrintWriter;
    -import java.lang.NoSuchFieldException;
    -import java.lang.NoSuchMethodException;
     import java.lang.RuntimeException;
     import java.lang.instrument.ClassDefinition;
     import java.lang.instrument.ClassFileTransformer;
     import java.lang.instrument.IllegalClassFormatException;
     import java.lang.instrument.Instrumentation;
     import java.security.ProtectionDomain;
    -import jdk.test.lib.*;
    +
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     
     public class ModifyAnonymous {
     
    diff --git a/hotspot/test/runtime/Unsafe/DefineClass.java b/hotspot/test/runtime/Unsafe/DefineClass.java
    index 5973f666122..1c48d95b49b 100644
    --- a/hotspot/test/runtime/Unsafe/DefineClass.java
    +++ b/hotspot/test/runtime/Unsafe/DefineClass.java
    @@ -32,8 +32,8 @@
      */
     
     import java.security.ProtectionDomain;
    -import java.io.InputStream;
    -import jdk.test.lib.InMemoryJavaCompiler;
    +
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.internal.misc.Unsafe;
     import static jdk.test.lib.Asserts.*;
     
    diff --git a/hotspot/test/runtime/Unsafe/NestedUnsafe.java b/hotspot/test/runtime/Unsafe/NestedUnsafe.java
    index a1a995ab636..ec63bf271f6 100644
    --- a/hotspot/test/runtime/Unsafe/NestedUnsafe.java
    +++ b/hotspot/test/runtime/Unsafe/NestedUnsafe.java
    @@ -31,12 +31,9 @@
      * @run main NestedUnsafe
      */
     
    -import java.security.ProtectionDomain;
    -import java.io.InputStream;
     import java.lang.*;
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.internal.misc.Unsafe;
    -import static jdk.test.lib.Asserts.*;
     
     // package p;
     
    diff --git a/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java b/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java
    index f4a80a61a59..247a42c4291 100644
    --- a/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java
    +++ b/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java
    @@ -34,11 +34,10 @@
     
     package p;
     
    -import java.security.ProtectionDomain;
    -import java.io.InputStream;
     import java.lang.*;
    -import jdk.test.lib.*;
    +
     import jdk.internal.misc.Unsafe;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     
     
     // Test that an anonymous class in package 'p' cannot define its own anonymous class
    diff --git a/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java b/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java
    index 0d773a56feb..459b9f704b4 100644
    --- a/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java
    +++ b/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java
    @@ -34,11 +34,10 @@
     
     package p;
     
    -import java.security.ProtectionDomain;
    -import java.io.InputStream;
     import java.lang.*;
    -import jdk.test.lib.*;
    +
     import jdk.internal.misc.Unsafe;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     
     
     // Test that an anonymous class that gets put in its host's package cannot define
    diff --git a/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java b/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java
    index 6847f26c8f1..75360e2e394 100644
    --- a/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java
    +++ b/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java
    @@ -33,7 +33,7 @@
     import java.io.File;
     import java.lang.reflect.InvocationTargetException;
     import java.lang.reflect.Method;
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.ProcessTools;
     import jdk.test.lib.process.OutputAnalyzer;
     
    diff --git a/hotspot/test/runtime/modules/ModuleStress/ModuleStress.java b/hotspot/test/runtime/modules/ModuleStress/ModuleStress.java
    index c3906bcfb15..bc6341aa9cb 100644
    --- a/hotspot/test/runtime/modules/ModuleStress/ModuleStress.java
    +++ b/hotspot/test/runtime/modules/ModuleStress/ModuleStress.java
    @@ -38,8 +38,7 @@
     
     import jdk.test.lib.process.ProcessTools;
     import jdk.test.lib.process.OutputAnalyzer;
    -import jdk.test.lib.InMemoryJavaCompiler;
    -import java.io.File;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     
     public class ModuleStress {
     
    diff --git a/hotspot/test/runtime/modules/PatchModule/PatchModule2Dirs.java b/hotspot/test/runtime/modules/PatchModule/PatchModule2Dirs.java
    index 5af477b5c30..4c49e6613ce 100644
    --- a/hotspot/test/runtime/modules/PatchModule/PatchModule2Dirs.java
    +++ b/hotspot/test/runtime/modules/PatchModule/PatchModule2Dirs.java
    @@ -30,10 +30,9 @@
      * @run main PatchModule2Dirs
      */
     
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
    -import java.io.File;
     
     public class PatchModule2Dirs {
     
    diff --git a/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java
    index cd9a66e49ab..2ebc75ec2db 100644
    --- a/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java
    +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java
    @@ -31,8 +31,7 @@
      * @run main PatchModuleCDS
      */
     
    -import java.io.File;
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     
    diff --git a/hotspot/test/runtime/modules/PatchModule/PatchModuleClassList.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleClassList.java
    index e590e63a3fc..ec9776f20a8 100644
    --- a/hotspot/test/runtime/modules/PatchModule/PatchModuleClassList.java
    +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleClassList.java
    @@ -33,7 +33,7 @@
     
     import java.nio.file.Files;
     import java.nio.file.Paths;
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     
    diff --git a/hotspot/test/runtime/modules/PatchModule/PatchModuleJavaBase.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleJavaBase.java
    index e43325703e9..e7fe2da1705 100644
    --- a/hotspot/test/runtime/modules/PatchModule/PatchModuleJavaBase.java
    +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleJavaBase.java
    @@ -31,7 +31,7 @@
      * @run main PatchModuleJavaBase
      */
     
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     
    diff --git a/hotspot/test/runtime/modules/PatchModule/PatchModuleTest.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleTest.java
    index a5eb563a230..d58ca4240ef 100644
    --- a/hotspot/test/runtime/modules/PatchModule/PatchModuleTest.java
    +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTest.java
    @@ -31,7 +31,7 @@
      * @run main PatchModuleTest
      */
     
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     
    diff --git a/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJar.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJar.java
    index c7775c0c136..5979da68a5c 100644
    --- a/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJar.java
    +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJar.java
    @@ -31,7 +31,7 @@
      * @run main PatchModuleTestJar
      */
     
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     
    diff --git a/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJarDir.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJarDir.java
    index 18cc2597c2b..5c5a12e7c4b 100644
    --- a/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJarDir.java
    +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJarDir.java
    @@ -32,8 +32,8 @@
      */
     
     import java.io.File;
    -import java.nio.file.Files;
    -import jdk.test.lib.InMemoryJavaCompiler;
    +
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     
    diff --git a/hotspot/test/runtime/modules/PatchModule/PatchModuleTraceCL.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleTraceCL.java
    index 7dda4a51d55..d1255d61e68 100644
    --- a/hotspot/test/runtime/modules/PatchModule/PatchModuleTraceCL.java
    +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTraceCL.java
    @@ -32,8 +32,7 @@
      * @run main PatchModuleTraceCL
      */
     
    -import java.io.File;
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     
    diff --git a/hotspot/test/runtime/modules/Visibility/PatchModuleVisibility.java b/hotspot/test/runtime/modules/Visibility/PatchModuleVisibility.java
    index 95fbce1b125..124fd7a5665 100644
    --- a/hotspot/test/runtime/modules/Visibility/PatchModuleVisibility.java
    +++ b/hotspot/test/runtime/modules/Visibility/PatchModuleVisibility.java
    @@ -36,7 +36,7 @@ import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     
    diff --git a/hotspot/test/runtime/modules/Visibility/XbootcpNoVisibility.java b/hotspot/test/runtime/modules/Visibility/XbootcpNoVisibility.java
    index 5f56b2573eb..4ea90f03b2c 100644
    --- a/hotspot/test/runtime/modules/Visibility/XbootcpNoVisibility.java
    +++ b/hotspot/test/runtime/modules/Visibility/XbootcpNoVisibility.java
    @@ -31,7 +31,7 @@
      * @run main/othervm XbootcpNoVisibility
      */
     
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.ProcessTools;
     import jdk.test.lib.process.OutputAnalyzer;
     
    diff --git a/hotspot/test/runtime/modules/Visibility/XbootcpVisibility.java b/hotspot/test/runtime/modules/Visibility/XbootcpVisibility.java
    index 1530d8bed13..4b36695c29d 100644
    --- a/hotspot/test/runtime/modules/Visibility/XbootcpVisibility.java
    +++ b/hotspot/test/runtime/modules/Visibility/XbootcpVisibility.java
    @@ -36,7 +36,7 @@ import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     
    
    From 8e28d5772d7244815995190b48840816c50d0114 Mon Sep 17 00:00:00 2001
    From: Igor Ignatyev 
    Date: Thu, 11 May 2017 14:13:59 -0700
    Subject: [PATCH 10/66] 8180004: jdk.test.lib.DynamicVMOption should be moved
     to jdk.test.lib.management
    
    Reviewed-by: mseledtsov, vlivanov
    ---
     hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java          | 2 +-
     hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java          | 2 +-
     hotspot/test/gc/parallel/TestDynShrinkHeap.java                 | 2 +-
     .../runtime/CommandLine/OptionsValidation/TestJcmdOutput.java   | 2 +-
     .../OptionsValidation/common/optionsvalidation/JVMOption.java   | 2 +-
     .../runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java    | 2 +-
     6 files changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java b/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java
    index c6d2b547357..4b7fd30ab41 100644
    --- a/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java
    +++ b/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java
    @@ -24,7 +24,7 @@
     import static jdk.test.lib.Asserts.assertEQ;
     import static jdk.test.lib.Asserts.assertFalse;
     import static jdk.test.lib.Asserts.assertTrue;
    -import jdk.test.lib.DynamicVMOption;
    +import jdk.test.lib.management.DynamicVMOption;
     
     /**
      * @test TestDynMaxHeapFreeRatio
    diff --git a/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java b/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java
    index e21f066b0a0..09f24e7af35 100644
    --- a/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java
    +++ b/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java
    @@ -38,7 +38,7 @@
     import static jdk.test.lib.Asserts.assertEQ;
     import static jdk.test.lib.Asserts.assertFalse;
     import static jdk.test.lib.Asserts.assertTrue;
    -import jdk.test.lib.DynamicVMOption;
    +import jdk.test.lib.management.DynamicVMOption;
     
     public class TestDynMinHeapFreeRatio {
     
    diff --git a/hotspot/test/gc/parallel/TestDynShrinkHeap.java b/hotspot/test/gc/parallel/TestDynShrinkHeap.java
    index f5e78ab7346..78c5946c4b7 100644
    --- a/hotspot/test/gc/parallel/TestDynShrinkHeap.java
    +++ b/hotspot/test/gc/parallel/TestDynShrinkHeap.java
    @@ -31,7 +31,7 @@
      * @library /test/lib /
      * @run main/othervm -XX:+UseAdaptiveSizePolicyWithSystemGC -XX:+UseParallelGC -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 -Xmx1g -verbose:gc TestDynShrinkHeap
      */
    -import jdk.test.lib.DynamicVMOption;
    +import jdk.test.lib.management.DynamicVMOption;
     import java.lang.management.ManagementFactory;
     import java.lang.management.MemoryUsage;
     import java.util.ArrayList;
    diff --git a/hotspot/test/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java b/hotspot/test/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java
    index d15d536b751..1a46eb01877 100644
    --- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java
    +++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java
    @@ -34,7 +34,7 @@
      */
     
     import jdk.test.lib.Asserts;
    -import jdk.test.lib.DynamicVMOption;
    +import jdk.test.lib.management.DynamicVMOption;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     import jdk.test.lib.dcmd.PidJcmdExecutor;
    diff --git a/hotspot/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java b/hotspot/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java
    index b10ac75c56e..dd19e352d32 100644
    --- a/hotspot/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java
    +++ b/hotspot/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java
    @@ -29,7 +29,7 @@ import java.util.Arrays;
     import java.util.HashSet;
     import java.util.List;
     import java.util.Set;
    -import jdk.test.lib.DynamicVMOption;
    +import jdk.test.lib.management.DynamicVMOption;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     import jdk.test.lib.dcmd.CommandExecutor;
    diff --git a/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java b/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java
    index 865fb9b8556..b88c50683b2 100644
    --- a/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java
    +++ b/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java
    @@ -51,7 +51,7 @@ import java.util.List;
     import java.util.Properties;
     import java.util.Set;
     import jdk.test.lib.Asserts;
    -import jdk.test.lib.DynamicVMOption;
    +import jdk.test.lib.management.DynamicVMOption;
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     
    
    From c775f6f58be85e196a0eb4d7402b7f30515b66fb Mon Sep 17 00:00:00 2001
    From: Thomas Schatzl 
    Date: Mon, 15 May 2017 12:20:15 +0200
    Subject: [PATCH 11/66] 8180048: Interned string and symbol table leak memory
     during parallel unlinking
    
    Make appending found dead BasicHashtableEntrys to the free list atomic.
    
    Reviewed-by: ehelin, shade, coleenp
    ---
     .../src/share/vm/classfile/stringTable.cpp    | 19 ++++++----
     .../src/share/vm/classfile/stringTable.hpp    |  8 +++--
     .../src/share/vm/classfile/symbolTable.cpp    | 35 +++++++++++--------
     .../src/share/vm/classfile/symbolTable.hpp    |  9 +++--
     hotspot/src/share/vm/runtime/vmStructs.cpp    |  2 +-
     hotspot/src/share/vm/utilities/hashtable.cpp  | 31 +++++++++++++++-
     hotspot/src/share/vm/utilities/hashtable.hpp  | 22 ++++++++++--
     7 files changed, 97 insertions(+), 29 deletions(-)
    
    diff --git a/hotspot/src/share/vm/classfile/stringTable.cpp b/hotspot/src/share/vm/classfile/stringTable.cpp
    index 05f6fd8be46..731cba8a8a6 100644
    --- a/hotspot/src/share/vm/classfile/stringTable.cpp
    +++ b/hotspot/src/share/vm/classfile/stringTable.cpp
    @@ -314,7 +314,11 @@ oop StringTable::intern(const char* utf8_string, TRAPS) {
     }
     
     void StringTable::unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int* processed, int* removed) {
    -  buckets_unlink_or_oops_do(is_alive, f, 0, the_table()->table_size(), processed, removed);
    +  BucketUnlinkContext context;
    +  buckets_unlink_or_oops_do(is_alive, f, 0, the_table()->table_size(), &context);
    +  _the_table->bulk_free_entries(&context);
    +  *processed = context._num_processed;
    +  *removed = context._num_removed;
     }
     
     void StringTable::possibly_parallel_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int* processed, int* removed) {
    @@ -323,6 +327,7 @@ void StringTable::possibly_parallel_unlink_or_oops_do(BoolObjectClosure* is_aliv
       assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
       const int limit = the_table()->table_size();
     
    +  BucketUnlinkContext context;
       for (;;) {
         // Grab next set of buckets to scan
         int start_idx = Atomic::add(ClaimChunkSize, &_parallel_claimed_idx) - ClaimChunkSize;
    @@ -332,8 +337,11 @@ void StringTable::possibly_parallel_unlink_or_oops_do(BoolObjectClosure* is_aliv
         }
     
         int end_idx = MIN2(limit, start_idx + ClaimChunkSize);
    -    buckets_unlink_or_oops_do(is_alive, f, start_idx, end_idx, processed, removed);
    +    buckets_unlink_or_oops_do(is_alive, f, start_idx, end_idx, &context);
       }
    +  _the_table->bulk_free_entries(&context);
    +  *processed = context._num_processed;
    +  *removed = context._num_removed;
     }
     
     void StringTable::buckets_oops_do(OopClosure* f, int start_idx, int end_idx) {
    @@ -359,7 +367,7 @@ void StringTable::buckets_oops_do(OopClosure* f, int start_idx, int end_idx) {
       }
     }
     
    -void StringTable::buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, int* processed, int* removed) {
    +void StringTable::buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, BucketUnlinkContext* context) {
       const int limit = the_table()->table_size();
     
       assert(0 <= start_idx && start_idx <= limit,
    @@ -383,10 +391,9 @@ void StringTable::buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClos
             p = entry->next_addr();
           } else {
             *p = entry->next();
    -        the_table()->free_entry(entry);
    -        (*removed)++;
    +        context->free_entry(entry);
           }
    -      (*processed)++;
    +      context->_num_processed++;
           entry = *p;
         }
       }
    diff --git a/hotspot/src/share/vm/classfile/stringTable.hpp b/hotspot/src/share/vm/classfile/stringTable.hpp
    index 2c0afc8bca5..0ef225f1c54 100644
    --- a/hotspot/src/share/vm/classfile/stringTable.hpp
    +++ b/hotspot/src/share/vm/classfile/stringTable.hpp
    @@ -61,9 +61,13 @@ private:
       // Apply the give oop closure to the entries to the buckets
       // in the range [start_idx, end_idx).
       static void buckets_oops_do(OopClosure* f, int start_idx, int end_idx);
    +
    +  typedef StringTable::BucketUnlinkContext BucketUnlinkContext;
       // Unlink or apply the give oop closure to the entries to the buckets
    -  // in the range [start_idx, end_idx).
    -  static void buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, int* processed, int* removed);
    +  // in the range [start_idx, end_idx). Unlinked bucket entries are collected in the given
    +  // context to be freed later.
    +  // This allows multiple threads to work on the table at once.
    +  static void buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, BucketUnlinkContext* context);
     
       // Hashing algorithm, used as the hash value used by the
       //     StringTable for bucket selection and comparison (stored in the
    diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp
    index 5121fdbcd64..548be92bcad 100644
    --- a/hotspot/src/share/vm/classfile/symbolTable.cpp
    +++ b/hotspot/src/share/vm/classfile/symbolTable.cpp
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 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
    @@ -98,7 +98,7 @@ int SymbolTable::_symbols_removed = 0;
     int SymbolTable::_symbols_counted = 0;
     volatile int SymbolTable::_parallel_claimed_idx = 0;
     
    -void SymbolTable::buckets_unlink(int start_idx, int end_idx, int* processed, int* removed) {
    +void SymbolTable::buckets_unlink(int start_idx, int end_idx, BucketUnlinkContext* context) {
       for (int i = start_idx; i < end_idx; ++i) {
         HashtableEntry** p = the_table()->bucket_addr(i);
         HashtableEntry* entry = the_table()->bucket(i);
    @@ -111,15 +111,14 @@ void SymbolTable::buckets_unlink(int start_idx, int end_idx, int* processed, int
             break;
           }
           Symbol* s = entry->literal();
    -      (*processed)++;
    +      context->_num_processed++;
           assert(s != NULL, "just checking");
           // If reference count is zero, remove.
           if (s->refcount() == 0) {
             assert(!entry->is_shared(), "shared entries should be kept live");
             delete s;
    -        (*removed)++;
             *p = entry->next();
    -        the_table()->free_entry(entry);
    +        context->free_entry(entry);
           } else {
             p = entry->next_addr();
           }
    @@ -132,17 +131,20 @@ void SymbolTable::buckets_unlink(int start_idx, int end_idx, int* processed, int
     // Remove unreferenced symbols from the symbol table
     // This is done late during GC.
     void SymbolTable::unlink(int* processed, int* removed) {
    -  size_t memory_total = 0;
    -  buckets_unlink(0, the_table()->table_size(), processed, removed);
    -  _symbols_removed += *removed;
    -  _symbols_counted += *processed;
    +  BucketUnlinkContext context;
    +  buckets_unlink(0, the_table()->table_size(), &context);
    +  _the_table->bulk_free_entries(&context);
    +  *processed = context._num_processed;
    +  *removed = context._num_removed;
    +
    +  _symbols_removed = context._num_removed;
    +  _symbols_counted = context._num_processed;
     }
     
     void SymbolTable::possibly_parallel_unlink(int* processed, int* removed) {
       const int limit = the_table()->table_size();
     
    -  size_t memory_total = 0;
    -
    +  BucketUnlinkContext context;
       for (;;) {
         // Grab next set of buckets to scan
         int start_idx = Atomic::add(ClaimChunkSize, &_parallel_claimed_idx) - ClaimChunkSize;
    @@ -152,10 +154,15 @@ void SymbolTable::possibly_parallel_unlink(int* processed, int* removed) {
         }
     
         int end_idx = MIN2(limit, start_idx + ClaimChunkSize);
    -    buckets_unlink(start_idx, end_idx, processed, removed);
    +    buckets_unlink(start_idx, end_idx, &context);
       }
    -  Atomic::add(*processed, &_symbols_counted);
    -  Atomic::add(*removed, &_symbols_removed);
    +
    +  _the_table->bulk_free_entries(&context);
    +  *processed = context._num_processed;
    +  *removed = context._num_removed;
    +
    +  Atomic::add(context._num_processed, &_symbols_counted);
    +  Atomic::add(context._num_removed, &_symbols_removed);
     }
     
     // Create a new table and using alternate hash code, populate the new table
    diff --git a/hotspot/src/share/vm/classfile/symbolTable.hpp b/hotspot/src/share/vm/classfile/symbolTable.hpp
    index e45ec753ef1..8e7b1362fff 100644
    --- a/hotspot/src/share/vm/classfile/symbolTable.hpp
    +++ b/hotspot/src/share/vm/classfile/symbolTable.hpp
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 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
    @@ -154,8 +154,11 @@ private:
     
       static volatile int _parallel_claimed_idx;
     
    -  // Release any dead symbols
    -  static void buckets_unlink(int start_idx, int end_idx, int* processed, int* removed);
    +  typedef SymbolTable::BucketUnlinkContext BucketUnlinkContext;
    +  // Release any dead symbols. Unlinked bucket entries are collected in the given
    +  // context to be freed later.
    +  // This allows multiple threads to work on the table at once.
    +  static void buckets_unlink(int start_idx, int end_idx, BucketUnlinkContext* context);
     public:
       enum {
         symbol_alloc_batch_size = 8,
    diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp
    index d5b9e3db03c..0d973ca5ee8 100644
    --- a/hotspot/src/share/vm/runtime/vmStructs.cpp
    +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp
    @@ -673,7 +673,7 @@ typedef CompactHashtable       SymbolCompactHashTable;
                                                                                                                                          \
       nonstatic_field(BasicHashtable,  _table_size,                                   int)                                   \
       nonstatic_field(BasicHashtable,  _buckets,                                      HashtableBucket*)          \
    -  nonstatic_field(BasicHashtable,  _free_list,                                    BasicHashtableEntry*)      \
    +  volatile_nonstatic_field(BasicHashtable,  _free_list,                           BasicHashtableEntry*)      \
       nonstatic_field(BasicHashtable,  _first_free_entry,                             char*)                                 \
       nonstatic_field(BasicHashtable,  _end_block,                                    char*)                                 \
       nonstatic_field(BasicHashtable,  _entry_size,                                   int)                                   \
    diff --git a/hotspot/src/share/vm/utilities/hashtable.cpp b/hotspot/src/share/vm/utilities/hashtable.cpp
    index f5d37f45fa9..5fce98e2694 100644
    --- a/hotspot/src/share/vm/utilities/hashtable.cpp
    +++ b/hotspot/src/share/vm/utilities/hashtable.cpp
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 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
    @@ -173,6 +173,35 @@ template  void BasicHashtable::reverse() {
       }
     }
     
    +template  void BasicHashtable::BucketUnlinkContext::free_entry(BasicHashtableEntry* entry) {
    +  entry->set_next(_removed_head);
    +  _removed_head = entry;
    +  if (_removed_tail == NULL) {
    +    _removed_tail = entry;
    +  }
    +  _num_removed++;
    +}
    +
    +template  void BasicHashtable::bulk_free_entries(BucketUnlinkContext* context) {
    +  if (context->_num_removed == 0) {
    +    assert(context->_removed_head == NULL && context->_removed_tail == NULL,
    +           "Zero entries in the unlink context, but elements linked from " PTR_FORMAT " to " PTR_FORMAT,
    +           p2i(context->_removed_head), p2i(context->_removed_tail));
    +    return;
    +  }
    +
    +  // MT-safe add of the list of BasicHashTableEntrys from the context to the free list.
    +  BasicHashtableEntry* current = _free_list;
    +  while (true) {
    +    context->_removed_tail->set_next(current);
    +    BasicHashtableEntry* old = (BasicHashtableEntry*)Atomic::cmpxchg_ptr(context->_removed_head, &_free_list, current);
    +    if (old == current) {
    +      break;
    +    }
    +    current = old;
    +  }
    +  Atomic::add(-context->_num_removed, &_number_of_entries);
    +}
     
     // Copy the table to the shared space.
     
    diff --git a/hotspot/src/share/vm/utilities/hashtable.hpp b/hotspot/src/share/vm/utilities/hashtable.hpp
    index 51324a18c62..76e8005c260 100644
    --- a/hotspot/src/share/vm/utilities/hashtable.hpp
    +++ b/hotspot/src/share/vm/utilities/hashtable.hpp
    @@ -173,11 +173,11 @@ private:
       // Instance variables
       int               _table_size;
       HashtableBucket*     _buckets;
    -  BasicHashtableEntry* _free_list;
    +  BasicHashtableEntry* volatile _free_list;
       char*             _first_free_entry;
       char*             _end_block;
       int               _entry_size;
    -  int               _number_of_entries;
    +  volatile int      _number_of_entries;
     
     protected:
     
    @@ -225,6 +225,24 @@ protected:
       // Free the buckets in this hashtable
       void free_buckets();
     
    +  // Helper data structure containing context for the bucket entry unlink process,
    +  // storing the unlinked buckets in a linked list.
    +  // Also avoids the need to pass around these four members as parameters everywhere.
    +  struct BucketUnlinkContext {
    +    int _num_processed;
    +    int _num_removed;
    +    // Head and tail pointers for the linked list of removed entries.
    +    BasicHashtableEntry* _removed_head;
    +    BasicHashtableEntry* _removed_tail;
    +
    +    BucketUnlinkContext() : _num_processed(0), _num_removed(0), _removed_head(NULL), _removed_tail(NULL) {
    +    }
    +
    +    void free_entry(BasicHashtableEntry* entry);
    +  };
    +  // Add of bucket entries linked together in the given context to the global free list. This method
    +  // is mt-safe wrt. to other calls of this method.
    +  void bulk_free_entries(BucketUnlinkContext* context);
     public:
       int table_size() { return _table_size; }
       void set_entry(int index, BasicHashtableEntry* entry);
    
    From 916cb71538130c0afaf6f60bfdc49cbf5758d42c Mon Sep 17 00:00:00 2001
    From: Andrew Haley 
    Date: Thu, 11 May 2017 13:11:42 +0100
    Subject: [PATCH 12/66] 8179954: AArch64: C1 and C2 volatile accesses are not
     sequentially consistent
    
    Reviewed-by: roland
    ---
     .../aarch64/vm/c1_LIRGenerator_aarch64.cpp    | 10 ++++
     .../cpu/aarch64/vm/templateTable_aarch64.cpp  | 54 +++++++++++++++++--
     2 files changed, 60 insertions(+), 4 deletions(-)
    
    diff --git a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp
    index 0c25198c04f..5abe4281aa2 100644
    --- a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp
    +++ b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp
    @@ -1347,6 +1347,16 @@ void LIRGenerator::volatile_field_store(LIR_Opr value, LIR_Address* address,
     
     void LIRGenerator::volatile_field_load(LIR_Address* address, LIR_Opr result,
                                            CodeEmitInfo* info) {
    +  // 8179954: We need to make sure that the code generated for
    +  // volatile accesses forms a sequentially-consistent set of
    +  // operations when combined with STLR and LDAR.  Without a leading
    +  // membar it's possible for a simple Dekker test to fail if loads
    +  // use LD;DMB but stores use STLR.  This can happen if C2 compiles
    +  // the stores in one method and C1 compiles the loads in another.
    +  if (! UseBarriersForVolatile) {
    +    __ membar();
    +  }
    +
       __ volatile_load_mem_reg(address, result, info);
     }
     
    diff --git a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp
    index 471a94511ad..f0f0f5a6ee5 100644
    --- a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp
    +++ b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp
    @@ -2389,17 +2389,31 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
       const Register obj   = r4;
       const Register off   = r19;
       const Register flags = r0;
    +  const Register raw_flags = r6;
       const Register bc    = r4; // uses same reg as obj, so don't mix them
     
       resolve_cache_and_index(byte_no, cache, index, sizeof(u2));
       jvmti_post_field_access(cache, index, is_static, false);
    -  load_field_cp_cache_entry(obj, cache, index, off, flags, is_static);
    +  load_field_cp_cache_entry(obj, cache, index, off, raw_flags, is_static);
     
       if (!is_static) {
         // obj is on the stack
         pop_and_check_object(obj);
       }
     
    +  // 8179954: We need to make sure that the code generated for
    +  // volatile accesses forms a sequentially-consistent set of
    +  // operations when combined with STLR and LDAR.  Without a leading
    +  // membar it's possible for a simple Dekker test to fail if loads
    +  // use LDR;DMB but stores use STLR.  This can happen if C2 compiles
    +  // the stores in one method and we interpret the loads in another.
    +  if (! UseBarriersForVolatile) {
    +    Label notVolatile;
    +    __ tbz(raw_flags, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
    +    __ membar(MacroAssembler::AnyAny);
    +    __ bind(notVolatile);
    +  }
    +
       const Address field(obj, off);
     
       Label Done, notByte, notBool, notInt, notShort, notChar,
    @@ -2407,7 +2421,8 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
     
       // x86 uses a shift and mask or wings it with a shift plus assert
       // the mask is not needed. aarch64 just uses bitfield extract
    -  __ ubfxw(flags, flags, ConstantPoolCacheEntry::tos_state_shift,  ConstantPoolCacheEntry::tos_state_bits);
    +  __ ubfxw(flags, raw_flags, ConstantPoolCacheEntry::tos_state_shift,
    +           ConstantPoolCacheEntry::tos_state_bits);
     
       assert(btos == 0, "change code, btos != 0");
       __ cbnz(flags, notByte);
    @@ -2529,9 +2544,11 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
     #endif
     
       __ bind(Done);
    -  // It's really not worth bothering to check whether this field
    -  // really is volatile in the slow case.
    +
    +  Label notVolatile;
    +  __ tbz(raw_flags, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
       __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore);
    +  __ bind(notVolatile);
     }
     
     
    @@ -2979,6 +2996,19 @@ void TemplateTable::fast_accessfield(TosState state)
       __ null_check(r0);
       const Address field(r0, r1);
     
    +  // 8179954: We need to make sure that the code generated for
    +  // volatile accesses forms a sequentially-consistent set of
    +  // operations when combined with STLR and LDAR.  Without a leading
    +  // membar it's possible for a simple Dekker test to fail if loads
    +  // use LDR;DMB but stores use STLR.  This can happen if C2 compiles
    +  // the stores in one method and we interpret the loads in another.
    +  if (! UseBarriersForVolatile) {
    +    Label notVolatile;
    +    __ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
    +    __ membar(MacroAssembler::AnyAny);
    +    __ bind(notVolatile);
    +  }
    +
       // access field
       switch (bytecode()) {
       case Bytecodes::_fast_agetfield:
    @@ -3027,6 +3057,22 @@ void TemplateTable::fast_xaccess(TosState state)
       __ get_cache_and_index_at_bcp(r2, r3, 2);
       __ ldr(r1, Address(r2, in_bytes(ConstantPoolCache::base_offset() +
                                       ConstantPoolCacheEntry::f2_offset())));
    +
    +  // 8179954: We need to make sure that the code generated for
    +  // volatile accesses forms a sequentially-consistent set of
    +  // operations when combined with STLR and LDAR.  Without a leading
    +  // membar it's possible for a simple Dekker test to fail if loads
    +  // use LDR;DMB but stores use STLR.  This can happen if C2 compiles
    +  // the stores in one method and we interpret the loads in another.
    +  if (! UseBarriersForVolatile) {
    +    Label notVolatile;
    +    __ ldrw(r3, Address(r2, in_bytes(ConstantPoolCache::base_offset() +
    +                                     ConstantPoolCacheEntry::flags_offset())));
    +    __ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
    +    __ membar(MacroAssembler::AnyAny);
    +    __ bind(notVolatile);
    +  }
    +
       // make sure exception is reported in correct bcp range (getfield is
       // next instruction)
       __ increment(rbcp);
    
    From a98da97e09b6df6949446ed1289d24e38d0f2db4 Mon Sep 17 00:00:00 2001
    From: Erik Joelsson 
    Date: Thu, 11 May 2017 18:41:56 +0200
    Subject: [PATCH 13/66] 8180083: Adjust Jib and JDL configurations for 9 to
     support new generation Mach 5
    
    Reviewed-by: tbell, ihse
    ---
     common/conf/jib-profiles.js | 154 +++++++++++++++++++++++-------------
     1 file changed, 98 insertions(+), 56 deletions(-)
    
    diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js
    index 8ac3df48218..b6fd25a6fcf 100644
    --- a/common/conf/jib-profiles.js
    +++ b/common/conf/jib-profiles.js
    @@ -239,11 +239,8 @@ var getJibProfilesCommon = function (input, data) {
         common.main_profile_base = {
             dependencies: ["boot_jdk", "gnumake", "jtreg"],
             default_make_targets: ["product-bundles", "test-bundles"],
    -        configure_args: [
    -            "--with-version-opt=" + common.build_id,
    -            "--enable-jtreg-failure-handler",
    -            "--with-version-build=" + common.build_number
    -        ]
    +        configure_args: concat(["--enable-jtreg-failure-handler"],
    +                               versionArgs(input, common))
         };
         // Extra settings for debug profiles
         common.debug_suffix = "-debug";
    @@ -269,10 +266,12 @@ var getJibProfilesCommon = function (input, data) {
     
         /**
          * Define common artifacts template for all main profiles
    -     * @param pf - Name of platform in bundle names
    -     * @param demo_ext - Type of extension for demo bundle
    +     * @param o - Object containing data for artifacts
          */
    -    common.main_profile_artifacts = function (pf, demo_ext) {
    +    common.main_profile_artifacts = function (o) {
    +        var jdk_subdir = (o.jdk_subdir != null ? o.jdk_subdir : "jdk-" + data.version);
    +        var jre_subdir = (o.jre_subdir != null ? o.jre_subdir : "jre-" + data.version);
    +        var pf = o.platform
             return {
                 artifacts: {
                     jdk: {
    @@ -281,7 +280,7 @@ var getJibProfilesCommon = function (input, data) {
                             "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin.tar.gz",
                             "bundles/" + pf + "/\\1"
                         ],
    -                    subdir: "jdk-" + data.version,
    +                    subdir: jdk_subdir,
                         exploded: "images/jdk"
                     },
                     jre: {
    @@ -290,7 +289,7 @@ var getJibProfilesCommon = function (input, data) {
                             "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin.tar.gz",
                             "bundles/" + pf + "/\\1"
                         ],
    -                    subdir: "jre-" + data.version,
    +                    subdir: jre_subdir,
                         exploded: "images/jre"
                     },
                     test: {
    @@ -307,7 +306,7 @@ var getJibProfilesCommon = function (input, data) {
                             "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-symbols.tar.gz",
                             "bundles/" + pf + "/\\1"
                         ],
    -                    subdir: "jdk-" + data.version,
    +                    subdir: jdk_subdir,
                         exploded: "images/jdk"
                     },
                     jre_symbols: {
    @@ -316,15 +315,8 @@ var getJibProfilesCommon = function (input, data) {
                             "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin-symbols.tar.gz",
                             "bundles/" + pf + "/\\1"
                         ],
    -                    subdir: "jre-" + data.version,
    +                    subdir: jre_subdir,
                         exploded: "images/jre"
    -                },
    -                demo: {
    -                    local: "bundles/\\(jdk.*demo." + demo_ext + "\\)",
    -                    remote: [
    -                        "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_demo." + demo_ext,
    -                        "bundles/" + pf + "/\\1"
    -                    ],
                     }
                 }
             };
    @@ -333,9 +325,12 @@ var getJibProfilesCommon = function (input, data) {
     
         /**
          * Define common artifacts template for all debug profiles
    -     * @param pf - Name of platform in bundle names
    +     * @param o - Object containing data for artifacts
          */
    -    common.debug_profile_artifacts = function (pf) {
    +    common.debug_profile_artifacts = function (o) {
    +        var jdk_subdir = "jdk-" + data.version + "/fastdebug";
    +        var jre_subdir = "jre-" + data.version + "/fastdebug";
    +        var pf = o.platform
             return {
                 artifacts: {
                     jdk: {
    @@ -344,7 +339,7 @@ var getJibProfilesCommon = function (input, data) {
                             "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-debug.tar.gz",
                             "bundles/" + pf + "/\\1"
                         ],
    -                    subdir: "jdk-" + data.version,
    +                    subdir: jdk_subdir,
                         exploded: "images/jdk"
                     },
                     jre: {
    @@ -353,7 +348,7 @@ var getJibProfilesCommon = function (input, data) {
                             "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin-debug.tar.gz",
                             "bundles/" + pf + "/\\1"
                         ],
    -                    subdir: "jre-" + data.version,
    +                    subdir: jre_subdir,
                         exploded: "images/jre"
                     },
                     test: {
    @@ -370,7 +365,7 @@ var getJibProfilesCommon = function (input, data) {
                             "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-debug-symbols.tar.gz",
                             "bundles/" + pf + "/\\1"
                         ],
    -                    subdir: "jdk-" + data.version,
    +                    subdir: jdk_subdir,
                         exploded: "images/jdk"
                     },
                     jre_symbols: {
    @@ -379,7 +374,7 @@ var getJibProfilesCommon = function (input, data) {
                             "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin-debug-symbols.tar.gz",
                             "bundles/" + pf + "/\\1"
                         ],
    -                    subdir: "jre-" + data.version,
    +                    subdir: jre_subdir,
                         exploded: "images/jre"
                     }
                 }
    @@ -621,7 +616,7 @@ var getJibProfilesProfiles = function (input, common, data) {
         var testOnlyProfilesPrebuilt = {
             "run-test-prebuilt": {
                 src: "src.conf",
    -            dependencies: [ "jtreg", "gnumake", testedProfile + ".jdk",
    +            dependencies: [ "jtreg", "gnumake", "boot_jdk", testedProfile + ".jdk",
                     testedProfile + ".test", "src.full"
                 ],
                 work_dir: input.get("src.full", "install_path") + "/test",
    @@ -665,61 +660,53 @@ var getJibProfilesProfiles = function (input, common, data) {
         //
         // Define artifacts for profiles
         //
    -    // Macosx bundles are named osx and Windows demo bundles use zip instead of
    +    // Macosx bundles are named osx
         // tar.gz.
         var artifactData = {
             "linux-x64": {
                 platform: "linux-x64",
    -            demo_ext: "tar.gz"
             },
             "linux-x86": {
                 platform: "linux-x86",
    -            demo_ext: "tar.gz"
             },
             "macosx-x64": {
                 platform: "osx-x64",
    -            demo_ext: "tar.gz"
    +            jdk_subdir: "jdk-" + data.version +  ".jdk/Contents/Home",
    +            jre_subdir: "jre-" + data.version +  ".jre/Contents/Home"
             },
             "solaris-x64": {
                 platform: "solaris-x64",
    -            demo_ext: "tar.gz"
             },
             "solaris-sparcv9": {
                 platform: "solaris-sparcv9",
    -            demo_ext: "tar.gz"
             },
             "windows-x64": {
                 platform: "windows-x64",
    -            demo_ext: "zip"
             },
             "windows-x86": {
                 platform: "windows-x86",
    -            demo_ext: "zip"
             },
            "linux-arm64": {
                 platform: "linux-arm64-vfp-hflt",
    -            demo_ext: "tar.gz"
             },
             "linux-arm-vfp-hflt": {
                 platform: "linux-arm32-vfp-hflt",
    -            demo_ext: "tar.gz"
             },
             "linux-arm-vfp-hflt-dyn": {
                 platform: "linux-arm32-vfp-hflt-dyn",
    -            demo_ext: "tar.gz"
             }
         }
         // Generate common artifacts for all main profiles
         Object.keys(artifactData).forEach(function (name) {
             profiles[name] = concatObjects(profiles[name],
    -            common.main_profile_artifacts(artifactData[name].platform, artifactData[name].demo_ext));
    +            common.main_profile_artifacts(artifactData[name]));
         });
     
         // Generate common artifacts for all debug profiles
         Object.keys(artifactData).forEach(function (name) {
             var debugName = name + common.debug_suffix;
             profiles[debugName] = concatObjects(profiles[debugName],
    -            common.debug_profile_artifacts(artifactData[name].platform));
    +            common.debug_profile_artifacts(artifactData[name]));
         });
     
         // Extra profile specific artifacts
    @@ -740,7 +727,12 @@ var getJibProfilesProfiles = function (input, common, data) {
                 artifacts: {
                     jdk: {
                         local: "bundles/\\(jdk.*bin.tar.gz\\)",
    -                    remote: "bundles/openjdk/GPL/linux-x64/\\1",
    +                    remote: [
    +                        "bundles/openjdk/GPL/linux-x64/jdk-" + data.version
    +                            + "_linux-x64_bin.tar.gz",
    +                        "bundles/openjdk/GPL/linux-x64/\\1"
    +                    ],
    +                    subdir: "jdk-" + data.version
                     },
                     jre: {
                         local: "bundles/\\(jre.*bin.tar.gz\\)",
    @@ -748,20 +740,25 @@ var getJibProfilesProfiles = function (input, common, data) {
                     },
                     test: {
                         local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
    -                    remote: "bundles/openjdk/GPL/linux-x64/\\1",
    +                    remote: [
    +                        "bundles/openjdk/GPL/linux-x64/jdk-" + data.version
    +                            + "_linux-x64_bin-tests.tar.gz",
    +                        "bundles/openjdk/GPL/linux-x64/\\1"
    +                    ]
                     },
                     jdk_symbols: {
                         local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
    -                    remote: "bundles/openjdk/GPL/linux-x64/\\1",
    +                    remote: [
    +                        "bundles/openjdk/GPL/linux-x64/jdk-" + data.version
    +                            + "_linux-x64_bin-symbols.tar.gz",
    +                        "bundles/openjdk/GPL/linux-x64/\\1"
    +                    ],
    +                    subdir: "jdk-" + data.version
                     },
                     jre_symbols: {
                         local: "bundles/\\(jre.*bin-symbols.tar.gz\\)",
                         remote: "bundles/openjdk/GPL/linux-x64/\\1",
                     },
    -                demo: {
    -                    local: "bundles/\\(jdk.*demo.tar.gz\\)",
    -                    remote: "bundles/openjdk/GPL/linux-x64/\\1",
    -                },
                     doc_api_spec: {
                         local: "bundles/\\(jdk.*doc-api-spec.tar.gz\\)",
                         remote: "bundles/openjdk/GPL/linux-x64/\\1",
    @@ -773,11 +770,29 @@ var getJibProfilesProfiles = function (input, common, data) {
                 artifacts: {
                     jdk: {
                         local: "bundles/\\(jdk.*bin.tar.gz\\)",
    -                    remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
    +                    remote: [
    +                        "bundles/openjdk/GPL/linux-x86/jdk-" + data.version
    +                            + "_linux-x86_bin.tar.gz",
    +                        "bundles/openjdk/GPL/linux-x86/\\1"
    +                    ],
    +                    subdir: "jdk-" + data.version
                     },
                     jdk_symbols: {
                         local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
    -                    remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
    +                    remote: [
    +                        "bundles/openjdk/GPL/linux-x86/jdk-" + data.version
    +                            + "_linux-x86_bin-symbols.tar.gz",
    +                        "bundles/openjdk/GPL/linux-x86/\\1"
    +                    ],
    +                    subdir: "jdk-" + data.version
    +                },
    +                test: {
    +                    local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
    +                    remote: [
    +                        "bundles/openjdk/GPL/linux-x86/jdk-" + data.version
    +                            + "_linux-x86_bin-tests.tar.gz",
    +                        "bundles/openjdk/GPL/linux-x86/\\1"
    +                    ]
                     },
                     jre: {
                         // This regexp needs to not match the compact* files below
    @@ -803,7 +818,12 @@ var getJibProfilesProfiles = function (input, common, data) {
                 artifacts: {
                     jdk: {
                         local: "bundles/\\(jdk.*bin.tar.gz\\)",
    -                    remote: "bundles/openjdk/GPL/windows-x86/\\1",
    +                    remote: [
    +                        "bundles/openjdk/GPL/windows-x86/jdk-" + data.version
    +                            + "_windows-x86_bin.tar.gz",
    +                        "bundles/openjdk/GPL/windows-x86/\\1"
    +                    ],
    +                    subdir: "jdk-" + data.version
                     },
                     jre: {
                         local: "bundles/\\(jre.*bin.tar.gz\\)",
    @@ -811,19 +831,24 @@ var getJibProfilesProfiles = function (input, common, data) {
                     },
                     test: {
                         local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
    -                    remote: "bundles/openjdk/GPL/windows-x86/\\1",
    +                    remote: [
    +                        "bundles/openjdk/GPL/windows-x86/jdk-" + data.version
    +                            + "_windows-x86_bin-tests.tar.gz",
    +                        "bundles/openjdk/GPL/windows-x86/\\1"
    +                    ]
                     },
                     jdk_symbols: {
                         local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
    -                    remote: "bundles/openjdk/GPL/windows-x86/\\1"
    +                    remote: [
    +                        "bundles/openjdk/GPL/windows-x86/jdk-" + data.version
    +                            + "_windows-x86_bin-symbols.tar.gz",
    +                        "bundles/openjdk/GPL/windows-x86/\\1"
    +                    ],
    +                    subdir: "jdk-" + data.version
                     },
                     jre_symbols: {
                         local: "bundles/\\(jre.*bin-symbols.tar.gz\\)",
                         remote: "bundles/openjdk/GPL/windows-x86/\\1",
    -                },
    -                demo: {
    -                    local: "bundles/\\(jdk.*demo.zip\\)",
    -                    remote: "bundles/openjdk/GPL/windows-x86/\\1",
                     }
                 }
             },
    @@ -1148,12 +1173,29 @@ var getVersion = function (major, minor, security, patch) {
             + "." + (minor != null ? minor : version_numbers.get("DEFAULT_VERSION_MINOR"))
             + "." + (security != null ? security :  version_numbers.get("DEFAULT_VERSION_SECURITY"))
             + "." + (patch != null ? patch : version_numbers.get("DEFAULT_VERSION_PATCH"));
    -    while (version.match(".*\.0$")) {
    +    while (version.match(".*\\.0$")) {
             version = version.substring(0, version.length - 2);
         }
         return version;
     };
     
    +/**
    + * Constructs the common version configure args based on build type and
    + * other version inputs
    + */
    +var versionArgs = function(input, common) {
    +    var args = ["--with-version-build=" + common.build_number];
    +    if (input.build_type == "promoted") {
    +        args = concat(args,
    +                      // This needs to be changed when we start building release candidates
    +                      "--with-version-pre=ea",
    +                      "--without-version-opt");
    +    } else {
    +        args = concat(args, "--with-version-opt=" + common.build_id);
    +    }
    +    return args;
    +}
    +
     // Properties representation of the common/autoconf/version-numbers file. Lazily
     // initiated by the function below.
     var version_numbers;
    
    From 25e5108c99ead867effffa50a7c3800adcc418ae Mon Sep 17 00:00:00 2001
    From: Igor Ignatyev 
    Date: Thu, 11 May 2017 13:58:05 -0700
    Subject: [PATCH 14/66] 8180037: move jdk.test.lib.InMemoryJavaCompiler to a
     separate package
    
    Reviewed-by: mseledtsov, vlivanov
    ---
     test/lib/RedefineClassHelper.java                             | 2 +-
     .../lib/jdk/test/lib/{ => compiler}/InMemoryJavaCompiler.java | 4 ++--
     2 files changed, 3 insertions(+), 3 deletions(-)
     rename test/lib/jdk/test/lib/{ => compiler}/InMemoryJavaCompiler.java (98%)
    
    diff --git a/test/lib/RedefineClassHelper.java b/test/lib/RedefineClassHelper.java
    index 75768092365..2c236907a7a 100644
    --- a/test/lib/RedefineClassHelper.java
    +++ b/test/lib/RedefineClassHelper.java
    @@ -23,7 +23,7 @@
     
     import java.io.PrintWriter;
     import java.lang.instrument.*;
    -import jdk.test.lib.InMemoryJavaCompiler;
    +import jdk.test.lib.compiler.InMemoryJavaCompiler;
     
     /*
      * Helper class to write tests that redefine classes.
    diff --git a/test/lib/jdk/test/lib/InMemoryJavaCompiler.java b/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java
    similarity index 98%
    rename from test/lib/jdk/test/lib/InMemoryJavaCompiler.java
    rename to test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java
    index 4033fcab0ca..e174b320180 100644
    --- a/test/lib/jdk/test/lib/InMemoryJavaCompiler.java
    +++ b/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java
    @@ -21,7 +21,7 @@
      * questions.
      */
     
    -package jdk.test.lib;
    +package jdk.test.lib.compiler;
     
     import java.io.ByteArrayOutputStream;
     import java.io.IOException;
    @@ -56,7 +56,7 @@ import javax.tools.ToolProvider;
      *
      * 
      * {@code
    - * import jdk.test.lib.InMemoryJavaCompiler;
    + * import jdk.test.lib.compiler.InMemoryJavaCompiler;
      * import jdk.test.lib.ByteClassLoader;
      *
      * class Example {
    
    From ce8579b6c7802c1c9bd428647e43b892739b8170 Mon Sep 17 00:00:00 2001
    From: Igor Ignatyev 
    Date: Thu, 11 May 2017 13:58:54 -0700
    Subject: [PATCH 15/66] 8180004: jdk.test.lib.DynamicVMOption should be moved
     to jdk.test.lib.management
    
    Reviewed-by: mseledtsov, vlivanov
    ---
     test/lib/jdk/test/lib/{ => management}/DynamicVMOption.java | 3 ++-
     1 file changed, 2 insertions(+), 1 deletion(-)
     rename test/lib/jdk/test/lib/{ => management}/DynamicVMOption.java (99%)
    
    diff --git a/test/lib/jdk/test/lib/DynamicVMOption.java b/test/lib/jdk/test/lib/management/DynamicVMOption.java
    similarity index 99%
    rename from test/lib/jdk/test/lib/DynamicVMOption.java
    rename to test/lib/jdk/test/lib/management/DynamicVMOption.java
    index 17f545e126e..786f1d85b22 100644
    --- a/test/lib/jdk/test/lib/DynamicVMOption.java
    +++ b/test/lib/jdk/test/lib/management/DynamicVMOption.java
    @@ -20,7 +20,8 @@
      * or visit www.oracle.com if you need additional information or have any
      * questions.
      */
    -package jdk.test.lib;
    +
    +package jdk.test.lib.management;
     
     import com.sun.management.HotSpotDiagnosticMXBean;
     import java.lang.management.ManagementFactory;
    
    From f2fceb6de153ed263614bac7d87b16a53fe9c5b9 Mon Sep 17 00:00:00 2001
    From: Kumar Srinivasan 
    Date: Thu, 11 May 2017 15:12:38 -0700
    Subject: [PATCH 16/66] 8179632: Fix the old doclet documentation
    
    Reviewed-by: jjg
    ---
     .../classes/com/sun/javadoc/package-info.java |  2 +-
     .../com/sun/tools/doclets/package-info.java   | 12 ++-----
     .../tools/doclets/standard/package-info.java  | 33 +++++++++++++++++++
     3 files changed, 36 insertions(+), 11 deletions(-)
     create mode 100644 langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/package-info.java
    
    diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/javadoc/package-info.java b/langtools/src/jdk.javadoc/share/classes/com/sun/javadoc/package-info.java
    index 87b3feecaea..dfc4ff38092 100644
    --- a/langtools/src/jdk.javadoc/share/classes/com/sun/javadoc/package-info.java
    +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/javadoc/package-info.java
    @@ -26,7 +26,7 @@
     /**
     

    Note: The declarations in this package have been superseded by those -in the package {@code jdk.javadoc.doclet}. +in the package {@link jdk.javadoc.doclet}. For more information, see the Migration Guide in the documentation for that package.

    diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/package-info.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/package-info.java index 735bfa5c5cc..c8912b29074 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/package-info.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -26,16 +26,8 @@ /**

    Note: The declarations in this package have been superseded by those -in the new package {@code jdk.javadoc.doclet}. +in the new package {@link jdk.javadoc.doclet}.

    - - As of JDK version 1.5, replaced by - {@code com.sun.tools.doclets.internal.toolkit.util}. - -

    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. */ package com.sun.tools.doclets; diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/package-info.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/package-info.java new file mode 100644 index 00000000000..4b93a8cbd8b --- /dev/null +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/package-info.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2003, 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: The declarations in this package have been superseded by those +in the new package {@link jdk.javadoc.doclet}. +

    +*/ + +package com.sun.tools.doclets.standard; From f417779f87075283df749de0285a04c9b4cd4567 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Fri, 12 May 2017 06:42:37 +0200 Subject: [PATCH 17/66] 8178152: Handling of incubating modules, the jdk.unsupported module and --add-exports with --release --release 9 should only allow documented modules; --add-exports/--add-reads/--patch-module should not be allowed on system modules when --release 9 is used. Reviewed-by: jjg, erikj, ihse --- .../make/gendata/Gendata-jdk.compiler.gmk | 22 +- .../TransitiveDependencies.java | 103 ++++++ .../com/sun/tools/javac/comp/Modules.java | 35 +- .../com/sun/tools/javac/main/Arguments.java | 10 +- .../javac/platform/JDKPlatformProvider.java | 24 +- .../tools/javac/resources/compiler.properties | 12 + .../diags/examples/AddExportsWithRelease.java | 28 ++ .../diags/examples/AddReadsWithRelease.java | 28 ++ .../PatchModuleWithRelease.java | 28 ++ .../patchmodule/java.base/java/lang/Test.java | 27 ++ .../options/release/ReleaseOptionClashes.java | 22 +- .../release/ReleaseOptionUnsupported.java | 313 ++++++++++++++++++ 12 files changed, 627 insertions(+), 25 deletions(-) create mode 100644 langtools/make/src/classes/build/tools/symbolgenerator/TransitiveDependencies.java create mode 100644 langtools/test/tools/javac/diags/examples/AddExportsWithRelease.java create mode 100644 langtools/test/tools/javac/diags/examples/AddReadsWithRelease.java create mode 100644 langtools/test/tools/javac/diags/examples/PatchModuleWithRelease/PatchModuleWithRelease.java create mode 100644 langtools/test/tools/javac/diags/examples/PatchModuleWithRelease/patchmodule/java.base/java/lang/Test.java create mode 100644 langtools/test/tools/javac/options/release/ReleaseOptionUnsupported.java diff --git a/langtools/make/gendata/Gendata-jdk.compiler.gmk b/langtools/make/gendata/Gendata-jdk.compiler.gmk index ea7ba9bfff1..d37c94e70a4 100644 --- a/langtools/make/gendata/Gendata-jdk.compiler.gmk +++ b/langtools/make/gendata/Gendata-jdk.compiler.gmk @@ -25,10 +25,20 @@ include JarArchive.gmk include JavaCompilation.gmk +include Modules.gmk include SetupJavaCompilers.gmk ################################################################################ +# This is needed to properly setup DOCS_MODULES. +$(eval $(call ReadImportMetaData)) + +# Modules that should be visible for 9 - the documented modules: +CT_MODULES := $(DOCS_MODULES) + +# Get the complete module source path: +CT_MODULESOURCEPATH := $(call GetModuleSrcPath) + CT_DATA_DESCRIPTION ?= $(LANGTOOLS_TOPDIR)/make/data/symbols/symbols $(eval $(call SetupJavaCompilation, COMPILE_CREATE_SYMBOLS, \ @@ -41,6 +51,8 @@ $(eval $(call SetupJavaCompilation, COMPILE_CREATE_SYMBOLS, \ ifeq ($(BOOT_JDK_MODULAR), true) COMPILECREATESYMBOLS_ADD_EXPORTS := \ + --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ + --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \ --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \ --add-exports=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED \ --add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED @@ -59,6 +71,14 @@ $(SUPPORT_OUTPUTDIR)/symbols/ct.sym-files/_the.symbols: \ build-ctsym \ $(CT_DATA_DESCRIPTION) \ $(@D) + $(MKDIR) $(@D)/9 + $(JAVA_SMALL) $(INTERIM_LANGTOOLS_ARGS) \ + $(COMPILECREATESYMBOLS_ADD_EXPORTS) \ + -classpath $(BUILDTOOLS_OUTPUTDIR)/create_symbols \ + build.tools.symbolgenerator.TransitiveDependencies \ + $(CT_MODULESOURCEPATH) \ + $(CT_MODULES) \ + >$(@D)/9/system-modules $(TOUCH) $@ # Can't generate ct.sym directly into modules libs as the SetupJarArchive macro @@ -66,7 +86,7 @@ $(SUPPORT_OUTPUTDIR)/symbols/ct.sym-files/_the.symbols: \ $(eval $(call SetupJarArchive, CREATE_CTSYM, \ DEPENDENCIES := $(SUPPORT_OUTPUTDIR)/symbols/ct.sym-files/_the.symbols, \ SRCS := $(SUPPORT_OUTPUTDIR)/symbols/ct.sym-files, \ - SUFFIXES := .sig, \ + SUFFIXES := .sig system-modules, \ JAR := $(SUPPORT_OUTPUTDIR)/symbols/ct.sym, \ )) diff --git a/langtools/make/src/classes/build/tools/symbolgenerator/TransitiveDependencies.java b/langtools/make/src/classes/build/tools/symbolgenerator/TransitiveDependencies.java new file mode 100644 index 00000000000..9ebc019166f --- /dev/null +++ b/langtools/make/src/classes/build/tools/symbolgenerator/TransitiveDependencies.java @@ -0,0 +1,103 @@ +/* + * 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. 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 build.tools.symbolgenerator; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.lang.model.element.ModuleElement.RequiresDirective; +import javax.lang.model.util.Elements; +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; + +import com.sun.tools.javac.api.JavacTaskImpl; +import com.sun.tools.javac.code.Symbol.ModuleSymbol; + +/** + * Print reflexive transitive closure of the given modules along their requires transitive edges. + */ +public class TransitiveDependencies { + + private static void help() { + System.err.println("java TransitiveDependencies "); + } + + public static void main(String... args) throws IOException { + if (args.length < 1) { + help(); + return ; + } + + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + List options = Arrays.asList("-source", "9", + "-target", "9", + "--system", "none", + "--module-source-path", args[0], + "--add-modules", Arrays.stream(args) + .skip(1) + .collect(Collectors.joining(","))); + List jlObjectList = Arrays.asList("java.lang.Object"); + JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, null, d -> {}, options, jlObjectList, null); + task.enter(); + Elements elements = task.getElements(); + List todo = new LinkedList<>(); + Arrays.stream(args).skip(1).forEach(todo::add); + Set allModules = new HashSet<>(); + + while (!todo.isEmpty()) { + String current = todo.remove(0); + + if (!allModules.add(current)) + continue; + + ModuleSymbol mod = (ModuleSymbol) elements.getModuleElement(current); + + if (mod == null) { + throw new IllegalStateException("Missing: " + current); + } + + //use the internal structure to avoid unnecesarily completing the symbol using the UsesProvidesVisitor: + for (RequiresDirective rd : mod.requires) { + if (rd.isTransitive()) { + todo.add(rd.getDependency().getQualifiedName().toString()); + } + } + } + + allModules.add("java.base"); + allModules.add("jdk.unsupported"); + + allModules.stream() + .sorted() + .forEach(System.out::println); + } + +} diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java index 9eae9b6e52d..9b5da2bd856 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java @@ -142,6 +142,7 @@ public class Modules extends JCTree.Visitor { private final ModuleFinder moduleFinder; private final Source source; private final boolean allowModules; + private final boolean allowAccessIntoSystem; public final boolean multiModuleMode; @@ -192,6 +193,7 @@ public class Modules extends JCTree.Visitor { allowModules = source.allowModules(); Options options = Options.instance(context); + allowAccessIntoSystem = options.isUnset(Option.RELEASE); lintOptions = options.isUnset(Option.XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option); Collection xmodules = options.keySet() @@ -1230,7 +1232,7 @@ public class Modules extends JCTree.Visitor { for (String limit : extraLimitMods) { limitMods.add(syms.enterModule(names.fromString(limit))); } - observable = computeTransitiveClosure(limitMods, null); + observable = computeTransitiveClosure(limitMods, rootModules, null); observable.addAll(rootModules); if (lintOptions) { for (ModuleSymbol msym : limitMods) { @@ -1310,7 +1312,7 @@ public class Modules extends JCTree.Visitor { } } - Set result = computeTransitiveClosure(enabledRoot, observable); + Set result = computeTransitiveClosure(enabledRoot, rootModules, observable); result.add(syms.unnamedModule); @@ -1348,12 +1350,18 @@ public class Modules extends JCTree.Visitor { return allModules == null || allModules.contains(msym); } - private Set computeTransitiveClosure(Set base, Set observable) { + private Set computeTransitiveClosure(Set base, + Set rootModules, + Set observable) { List primaryTodo = List.nil(); List secondaryTodo = List.nil(); for (ModuleSymbol ms : base) { - primaryTodo = primaryTodo.prepend(ms); + if (rootModules.contains(ms)) { + primaryTodo = primaryTodo.prepend(ms); + } else { + secondaryTodo = secondaryTodo.prepend(ms); + } } Set result = new LinkedHashSet<>(); @@ -1376,12 +1384,12 @@ public class Modules extends JCTree.Visitor { if (!result.add(current) || current == syms.unnamedModule || ((current.flags_field & Flags.AUTOMATIC_MODULE) != 0)) continue; current.complete(); - if (current.kind == ERR && isPrimaryTodo && warnedMissing.add(current)) { + if (current.kind == ERR && (isPrimaryTodo || base.contains(current)) && warnedMissing.add(current)) { log.error(Errors.ModuleNotFound(current)); } for (RequiresDirective rd : current.requires) { if (rd.module == syms.java_base) continue; - if ((rd.isTransitive() && isPrimaryTodo) || base.contains(current)) { + if ((rd.isTransitive() && isPrimaryTodo) || rootModules.contains(current)) { primaryTodo = primaryTodo.prepend(rd.module); } else { secondaryTodo = secondaryTodo.prepend(rd.module); @@ -1488,6 +1496,10 @@ public class Modules extends JCTree.Visitor { } } + if (!allowAccessIntoSystem && (msym.flags() & Flags.SYSTEM_MODULE) != 0 && + msym.patchLocation != null) { + log.error(Errors.PatchModuleWithRelease(msym)); + } } private Set retrieveRequiresTransitive(ModuleSymbol msym) { @@ -1613,6 +1625,12 @@ public class Modules extends JCTree.Visitor { if (!isValidName(packageName)) continue; + + if (!allowAccessIntoSystem && (msym.flags() & Flags.SYSTEM_MODULE) != 0) { + log.error(Errors.AddExportsWithRelease(msym)); + continue; + } + PackageSymbol p = syms.enterPackage(msym, names.fromString(packageName)); p.modle = msym; // TODO: do we need this? @@ -1688,6 +1706,11 @@ public class Modules extends JCTree.Visitor { continue; } + if (!allowAccessIntoSystem && (msym.flags() & Flags.SYSTEM_MODULE) != 0) { + log.error(Errors.AddReadsWithRelease(msym)); + continue; + } + for (String targetName : targetNames.split("[ ,]+", -1)) { ModuleSymbol targetModule; if (targetName.equals("ALL-UNNAMED")) { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java index efe65381610..ab119c611ef 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java @@ -300,7 +300,8 @@ public class Arguments { Option.XBOOTCLASSPATH_PREPEND, Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS, Option.EXTDIRS, Option.DJAVA_EXT_DIRS, - Option.SOURCE, Option.TARGET); + Option.SOURCE, Option.TARGET, + Option.SYSTEM, Option.UPGRADE_MODULE_PATH); if (platformString != null) { PlatformDescription platformDescription = PlatformUtils.lookupPlatformDescription(platformString); @@ -331,7 +332,12 @@ public class Arguments { try { StandardJavaFileManager sfm = (StandardJavaFileManager) fm; - sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP); + if (Source.instance(context).allowModules()) { + sfm.handleOption("--system", Arrays.asList("none").iterator()); + sfm.setLocationFromPaths(StandardLocation.UPGRADE_MODULE_PATH, platformCP); + } else { + sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP); + } } catch (IOException ex) { log.printLines(PrefixKind.JAVAC, "msg.io"); ex.printStackTrace(log.getWriter(WriterKind.NOTICE)); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java index 07d020f2a93..4d836ebc1df 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java @@ -26,6 +26,8 @@ package com.sun.tools.javac.platform; import java.io.IOException; +import java.net.URI; +import java.nio.charset.Charset; import java.nio.file.DirectoryStream; import java.nio.file.FileSystem; import java.nio.file.FileSystems; @@ -41,6 +43,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; +import java.util.stream.Stream; import javax.annotation.processing.Processor; @@ -90,7 +93,6 @@ public class JDKPlatformProvider implements PlatformProvider { } catch (IOException | ProviderNotFoundException ex) { } } - SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(Target.DEFAULT)); } private static String targetNumericVersion(Target target) { @@ -108,10 +110,6 @@ public class JDKPlatformProvider implements PlatformProvider { @Override public Collection getPlatformPath() { - if (Target.lookup(version) == Target.DEFAULT) { - return null; - } - List paths = new ArrayList<>(); Path file = findCtSym(); // file == ${jdk.home}/lib/ct.sym @@ -128,7 +126,21 @@ public class JDKPlatformProvider implements PlatformProvider { try (DirectoryStream dir = Files.newDirectoryStream(root)) { for (Path section : dir) { if (section.getFileName().toString().contains(version)) { - paths.add(section); + Path systemModules = section.resolve("system-modules"); + + if (Files.isRegularFile(systemModules)) { + Path modules = + FileSystems.getFileSystem(URI.create("jrt:/")) + .getPath("modules"); + try (Stream lines = + Files.lines(systemModules, Charset.forName("UTF-8"))) { + lines.map(line -> modules.resolve(line)) + .filter(mod -> Files.exists(mod)) + .forEach(mod -> paths.add(mod)); + } + } else { + paths.add(section); + } } } } catch (IOException ex) { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index f628c11da6e..7833fb21616 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -3027,6 +3027,18 @@ compiler.warn.module.for.option.not.found=\ compiler.err.addmods.all.module.path.invalid=\ --add-modules ALL-MODULE-PATH can only be used when compiling the unnamed module +# 0: symbol +compiler.err.add.exports.with.release=\ + exporting a package from system module {0} is not allowed with --release + +# 0: symbol +compiler.err.add.reads.with.release=\ + adding read edges for system module {0} is not allowed with --release + +# 0: symbol +compiler.err.patch.module.with.release=\ + patching system module {0} is not allowed in combination with --release + compiler.warn.addopens.ignored=\ --add-opens has no effect at compile time diff --git a/langtools/test/tools/javac/diags/examples/AddExportsWithRelease.java b/langtools/test/tools/javac/diags/examples/AddExportsWithRelease.java new file mode 100644 index 00000000000..52d8c56e6ac --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/AddExportsWithRelease.java @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// key: compiler.err.add.exports.with.release +// options: --add-exports java.base/jdk.internal.misc=ALL-UNNAMED --release 9 + +class AddExportsWithRelease { +} diff --git a/langtools/test/tools/javac/diags/examples/AddReadsWithRelease.java b/langtools/test/tools/javac/diags/examples/AddReadsWithRelease.java new file mode 100644 index 00000000000..3695353fa11 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/AddReadsWithRelease.java @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// key: compiler.err.add.reads.with.release +// options: --add-reads java.base=java.compiler --release 9 + +class AddReadsWithRelease { +} diff --git a/langtools/test/tools/javac/diags/examples/PatchModuleWithRelease/PatchModuleWithRelease.java b/langtools/test/tools/javac/diags/examples/PatchModuleWithRelease/PatchModuleWithRelease.java new file mode 100644 index 00000000000..6f1b11e4bba --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/PatchModuleWithRelease/PatchModuleWithRelease.java @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// key: compiler.err.patch.module.with.release +// options: --release 9 + +class PatchModuleWithRelease { +} diff --git a/langtools/test/tools/javac/diags/examples/PatchModuleWithRelease/patchmodule/java.base/java/lang/Test.java b/langtools/test/tools/javac/diags/examples/PatchModuleWithRelease/patchmodule/java.base/java/lang/Test.java new file mode 100644 index 00000000000..4c2f374a486 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/PatchModuleWithRelease/patchmodule/java.base/java/lang/Test.java @@ -0,0 +1,27 @@ +/* + * 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 java.lang; + +class Test { +} diff --git a/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java b/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java index e7e553c799c..c0a3b193c46 100644 --- a/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java +++ b/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java @@ -44,17 +44,19 @@ public class ReleaseOptionClashes { } void run() throws Exception { - doRunTest("-bootclasspath", "any"); - doRunTest("-Xbootclasspath:any"); - doRunTest("-Xbootclasspath/a:any"); - doRunTest("-Xbootclasspath/p:any"); - doRunTest("-endorseddirs", "any"); - doRunTest("-extdirs", "any"); - doRunTest("-source", "8"); - doRunTest("-target", "8"); + doRunTest("7", "-bootclasspath", "any"); + doRunTest("7", "-Xbootclasspath:any"); + doRunTest("7", "-Xbootclasspath/a:any"); + doRunTest("7", "-Xbootclasspath/p:any"); + doRunTest("7", "-endorseddirs", "any"); + doRunTest("7", "-extdirs", "any"); + doRunTest("7", "-source", "8"); + doRunTest("7", "-target", "8"); + doRunTest("9", "--system", "none"); + doRunTest("9", "--upgrade-module-path", "any"); } - void doRunTest(String... args) throws Exception { + void doRunTest(String release, String... args) throws Exception { System.out.println("Testing clashes for arguments: " + Arrays.asList(args)); Class log = Class.forName("com.sun.tools.javac.util.Log", true, cl); Field useRawMessages = log.getDeclaredField("useRawMessages"); @@ -62,7 +64,7 @@ public class ReleaseOptionClashes { useRawMessages.setBoolean(null, true); ByteArrayOutputStream out = new ByteArrayOutputStream(); List options = new ArrayList<>(); - options.addAll(Arrays.asList("--release", "7")); + options.addAll(Arrays.asList("--release", release)); options.addAll(Arrays.asList(args)); options.add(System.getProperty("test.src") + File.separator + "ReleaseOptionClashes.java"); compiler.run(null, null, out, options.toArray(new String[0])); diff --git a/langtools/test/tools/javac/options/release/ReleaseOptionUnsupported.java b/langtools/test/tools/javac/options/release/ReleaseOptionUnsupported.java new file mode 100644 index 00000000000..c25ae7279a7 --- /dev/null +++ b/langtools/test/tools/javac/options/release/ReleaseOptionUnsupported.java @@ -0,0 +1,313 @@ +/* + * 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. + */ + +/** + * @test + * @bug 8178152 + * @summary Verify unsupported modules and module options handling. + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.jvm + * jdk.jdeps/com.sun.tools.classfile + * jdk.jdeps/com.sun.tools.javap + * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavapTask toolbox.TestRunner + * @run main ReleaseOptionUnsupported + */ + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; + +import com.sun.tools.javac.jvm.Target; +import toolbox.JavacTask; +import toolbox.Task; +import toolbox.Task.Expect; +import toolbox.TestRunner; +import toolbox.ToolBox; + +public class ReleaseOptionUnsupported extends TestRunner { + + private final ToolBox tb = new ToolBox(); + + public ReleaseOptionUnsupported() { + super(System.err); + } + + public static void main(String... args) throws Exception { + new ReleaseOptionUnsupported().runTests(); + } + + @Test + public void testUnsafe(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "module m { requires jdk.unsupported; }", + "package test; public class Test { sun.misc.Unsafe unsafe; } "); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log; + List expected = Arrays.asList( + "Test.java:1:43: compiler.warn.sun.proprietary: sun.misc.Unsafe", + "1 warning" + ); + + log = new JavacTask(tb) + .options("-XDrawDiagnostics") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + + log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--release", Target.DEFAULT.multiReleaseValue()) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + } + + @Test + public void testUnsafeUnnamed(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "package test; public class Test { sun.misc.Unsafe unsafe; } "); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log; + List expected = Arrays.asList( + "Test.java:1:43: compiler.warn.sun.proprietary: sun.misc.Unsafe", + "1 warning" + ); + + log = new JavacTask(tb) + .options("-XDrawDiagnostics") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + + log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--release", Target.DEFAULT.multiReleaseValue()) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + } + + @Test + public void testAddExports(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "module m { }", + "package test; public class Test { jdk.internal.misc.Unsafe unsafe; } "); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + new JavacTask(tb) + .options("-XDrawDiagnostics", + "--add-exports", "java.base/jdk.internal.misc=m") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List log; + List expected; + + log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--add-exports", "java.base/jdk.internal.misc=m", + "--release", Target.DEFAULT.multiReleaseValue()) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList( + "- compiler.err.add.exports.with.release: java.base", + "1 error" + ); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + + //OK to add exports a package of a non-system module: + tb.writeJavaFiles(src, + "package test; public class Test { } "); + tb.createDirectories(classes); + + new JavacTask(tb) + .options("-XDrawDiagnostics", + "--add-exports", "m/test=ALL-UNNAMED", + "--release", Target.DEFAULT.multiReleaseValue()) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + } + + @Test + public void testAddReads(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "module m { }", + "package test; public class Test { } "); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + new JavacTask(tb) + .options("-XDrawDiagnostics", + "--add-reads", "java.base=m") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List log; + List expected; + + log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--add-reads", "java.base=m", + "--release", Target.DEFAULT.multiReleaseValue()) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList( + "- compiler.err.add.reads.with.release: java.base", + "1 error" + ); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + + //OK to add reads a package of a non-system module: + tb.createDirectories(classes); + + new JavacTask(tb) + .options("-XDrawDiagnostics", + "--add-reads", "m=java.base", + "--release", Target.DEFAULT.multiReleaseValue()) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + } + + @Test + public void testPatchModule(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "module m { }", + "package test; public class Test { } "); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + Path patch = base.resolve("patch"); + tb.createDirectories(patch); + + new JavacTask(tb) + .options("-XDrawDiagnostics", + "--patch-module", "java.base=" + patch) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List log; + List expected; + + log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--patch-module", "java.base=" + patch, + "--release", Target.DEFAULT.multiReleaseValue()) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList( + "- compiler.err.patch.module.with.release: java.base", + "1 error" + ); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + + //OK to patch a non-system module: + tb.createDirectories(classes); + + new JavacTask(tb) + .options("-XDrawDiagnostics", + "--patch-module", "m=" + patch, + "--release", Target.DEFAULT.multiReleaseValue()) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + } + + protected void runTests() throws Exception { + runTests(m -> new Object[] { Paths.get(m.getName()) }); + } +} From 679105dc96adebcb36669d611254853cdd247e12 Mon Sep 17 00:00:00 2001 From: Srinivas Dama Date: Fri, 12 May 2017 12:12:37 +0530 Subject: [PATCH 18/66] 8179891: JavaDoc for for..in is incorrect Fixed javadoc typo error Reviewed-by: sundar, hannesw, jlaskey --- .../share/classes/jdk/nashorn/api/tree/ForOfLoopTree.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForOfLoopTree.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForOfLoopTree.java index d95e2ed638e..999c4d3e3f9 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForOfLoopTree.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForOfLoopTree.java @@ -38,7 +38,7 @@ package jdk.nashorn.api.tree; */ public interface ForOfLoopTree extends LoopTree { /** - * The for..in left hand side expression. + * The for..of left hand side expression. * * @return the left hand side expression */ @@ -52,7 +52,7 @@ public interface ForOfLoopTree extends LoopTree { ExpressionTree getExpression(); /** - * The statement contained in this for..in statement. + * The statement contained in this for..of statement. * * @return the statement */ From a365f54c10d63bcc9390cd77142d2554d138e9f2 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Fri, 12 May 2017 19:09:50 +0200 Subject: [PATCH 19/66] 8175825: Stop including pubs repo Reviewed-by: erikj --- common/autoconf/generated-configure.sh | 2 +- common/autoconf/spec.gmk.in | 5 ++--- common/bin/hgforest.sh | 4 ++-- common/doc/building.html | 1 + common/doc/testing.html | 3 +-- make/{Javadoc.gmk => Docs.gmk} | 22 +++++++++++----------- make/Main.gmk | 12 ++++++------ 7 files changed, 24 insertions(+), 25 deletions(-) rename make/{Javadoc.gmk => Docs.gmk} (96%) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 30d6273dac4..e1d9795c280 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5183,7 +5183,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1493884285 +DATE_WHEN_GENERATED=1494608938 ############################################################################### # diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index ad113a258cb..247b15070e5 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -271,9 +271,6 @@ BUNDLES_OUTPUTDIR=$(BUILD_OUTPUT)/bundles TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/test-make MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/make-support -# By default, output javadoc directly into image -JAVADOC_OUTPUTDIR = $(DOCS_IMAGE_DIR) - # This does not get overridden in a bootcycle build CONFIGURESUPPORT_OUTPUTDIR:=@CONFIGURESUPPORT_OUTPUTDIR@ BUILDJDK_OUTPUTDIR=$(BUILD_OUTPUT)/buildjdk @@ -818,6 +815,8 @@ INTERIM_IMAGE_DIR := $(SUPPORT_OUTPUTDIR)/interim-image # Docs image DOCS_IMAGE_SUBDIR := docs DOCS_IMAGE_DIR = $(IMAGES_OUTPUTDIR)/$(DOCS_IMAGE_SUBDIR) +# Output docs directly into image +DOCS_OUTPUTDIR := $(DOCS_IMAGE_DIR) # Macosx bundles directory definitions JDK_MACOSX_BUNDLE_SUBDIR=jdk-bundle diff --git a/common/bin/hgforest.sh b/common/bin/hgforest.sh index 5d4f8eb7156..b5d6a6c938c 100644 --- a/common/bin/hgforest.sh +++ b/common/bin/hgforest.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 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 @@ -183,7 +183,7 @@ trap 'nice_exit' EXIT subrepos="corba jaxp jaxws langtools jdk hotspot nashorn" jdk_subrepos_extra="closed jdk/src/closed jdk/make/closed jdk/test/closed hotspot/make/closed hotspot/src/closed hotspot/test/closed" -subrepos_extra="$jdk_subrepos_extra deploy install sponsors pubs" +subrepos_extra="$jdk_subrepos_extra deploy install sponsors" # Only look in specific locations for possible forests (avoids long searches) pull_default="" diff --git a/common/doc/building.html b/common/doc/building.html index f44bceba174..9a086783f02 100644 --- a/common/doc/building.html +++ b/common/doc/building.html @@ -6,6 +6,7 @@ OpenJDK Build README +
    Shows the validity of each attribute or operation
     Inherited from RequestInfo:

    request_id

    request_id

    yesyesyesyesyes

    operation

    operation

    yesyesyesyesyes

    arguments

    arguments

    no yes1yesno2 *

    exceptions

    exceptions

    no yesyesyesyes

    contexts

    contexts

    no yesyesyesyes

    operation_context

    operation_context

    no yesyesno

    result

    result

    no no yesno

    response_expected

    response_expected

    yesyesyesyesyes

    sync_scope

    sync_scope

    yesyesyes
    \n" + + "
    \n" + ""); checkOutput("overview-summary.html", false, "
    Modules 
    \n" @@ -355,8 +406,10 @@ public class TestModules extends JavadocTester { + "
    \n" + "
    The overview summary page header.
    \n" + "
    \n" - + "
    \n" - + "\n" + + "
    \n" + ""); } @@ -405,7 +458,9 @@ public class TestModules extends JavadocTester { + "
    \n" + "
    The overview summary page header.
    \n" + "
    \n" - + "
    \n" + + "
    Modules 
    \n" + ""); checkOutput("overview-summary.html", false, @@ -416,7 +471,9 @@ public class TestModules extends JavadocTester { + "
    \n" + "
    The overview summary page header.
    \n" + "
    \n" - + "
    \n" + + "
    Modules 
    \n" + ""); } @@ -495,7 +552,7 @@ public class TestModules extends JavadocTester { void checkOverviewSummaryModules() { checkOutput("overview-summary.html", true, - "
    Modules 
    \n" + "
    \n" + "\n" + "\n" + "\n" @@ -512,7 +569,7 @@ public class TestModules extends JavadocTester { void checkOverviewSummaryPackages() { checkOutput("overview-summary.html", false, - "
    Modules 
    Module
    \n" + "
    \n" + "\n" + "\n" + "\n" @@ -523,7 +580,9 @@ public class TestModules extends JavadocTester { + "
    \n" + "
    The overview summary page header.
    \n" + "
    \n" - + "
    \n" + + "
    Modules 
    Module
    \n" + ""); checkOutput("overview-summary.html", true, @@ -537,7 +596,9 @@ public class TestModules extends JavadocTester { + "
    \n" + "
    The overview summary page header.
    \n" + "
    \n" - + "
    \n" + + "
    Packages 
    \n" + ""); } @@ -574,7 +635,9 @@ public class TestModules extends JavadocTester { + "
    \n" + "
    The overview summary page header.
    \n" + "
    \n" - + "
    \n" + + "
    Packages 
    \n" + ""); checkOutput("overview-summary.html", true, @@ -591,7 +654,9 @@ public class TestModules extends JavadocTester { + "
    \n" + "
    The overview summary page header.
    \n" + "
    \n" - + "
    \n" + + "
    Packages 
    \n" + ""); } @@ -974,4 +1039,54 @@ public class TestModules extends JavadocTester { + "", ""); } + + void checkGroupOption() { + checkOutput("overview-summary.html", true, + "
    Packages Concealed 
    \n" + + "", + "
    Module Group A 
    \n" + + "", + "
    Module Group B & C 
    \n" + + ""); + checkOutput("overview-summary.html", false, + "
    Other Modules 
    \n" + + "", + "Java SE Modules"); + } + + void checkUnnamedModuleGroupOption() { + checkOutput("overview-summary.html", true, + "
    Modules 
    \n" + + "\n" + + "", + "
    Package Group 0 
    \n" + + ""); + } + + void checkGroupOptionSingleModule() { + checkOutput("overview-summary.html", true, + "
    Package Group 1 
    \n" + + ""); + checkOutput("overview-summary.html", false, + "
    Module Group B 
    \n" + + ""); + } } From 2e29628481c029e281c6650a3b9264c3811e48eb Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 15 May 2017 16:34:52 +0200 Subject: [PATCH 23/66] 8180342: Fixup path for jtreg Reviewed-by: erikj --- common/autoconf/generated-configure.sh | 420 ++++++++++++++++++++++++- common/autoconf/toolchain.m4 | 2 + 2 files changed, 421 insertions(+), 1 deletion(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index d79d68917e4..cf23d7e99b8 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5183,7 +5183,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1494609053 +DATE_WHEN_GENERATED=1494858828 ############################################################################### # @@ -48896,6 +48896,424 @@ $as_echo "no, not found" >&6; } fi + # Only process if variable expands to non-empty + + if test "x$JTREGEXE" != x; then + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # First separate the path from the arguments. This will split at the first + # space. + complete="$JTREGEXE" + path="${complete%% *}" + tmp="$complete EOL" + arguments="${tmp#* }" + + # Input might be given as Windows format, start by converting to + # unix format. + new_path=`$CYGPATH -u "$path"` + + # Now try to locate executable using which + new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in cygwin causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path=`$CYGPATH -u "$path"` + fi + if test "x$new_path" = x; then + # Oops. Which didn't find the executable. + # The splitting of arguments from the executable at a space might have been incorrect, + # since paths with space are more likely in Windows. Give it another try with the whole + # argument. + path="$complete" + arguments="EOL" + new_path=`$CYGPATH -u "$path"` + new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in cygwin causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path=`$CYGPATH -u "$path"` + fi + if test "x$new_path" = x; then + # It's still not found. Now this is an unrecoverable error. + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JTREGEXE, which resolves as \"$complete\", is not found." >&5 +$as_echo "$as_me: The path of JTREGEXE, which resolves as \"$complete\", is not found." >&6;} + has_space=`$ECHO "$complete" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 +$as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} + fi + as_fn_error $? "Cannot locate the the path of JTREGEXE" "$LINENO" 5 + fi + fi + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file presence. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + # Short path failed, file does not exist as specified. + # Try adding .exe or .cmd + if test -f "${new_path}.exe"; then + input_to_shortpath="${new_path}.exe" + elif test -f "${new_path}.cmd"; then + input_to_shortpath="${new_path}.cmd" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JTREGEXE, which resolves as \"$new_path\", is invalid." >&5 +$as_echo "$as_me: The path of JTREGEXE, which resolves as \"$new_path\", is invalid." >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 +$as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} + as_fn_error $? "Cannot locate the the path of JTREGEXE" "$LINENO" 5 + fi + else + input_to_shortpath="$new_path" + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + new_path="$input_to_shortpath" + + input_path="$input_to_shortpath" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-style (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $input_to_shortpath | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + # remove trailing .exe if any + new_path="${new_path/%.exe/}" + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + # First separate the path from the arguments. This will split at the first + # space. + complete="$JTREGEXE" + path="${complete%% *}" + tmp="$complete EOL" + arguments="${tmp#* }" + + # Input might be given as Windows format, start by converting to + # unix format. + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + + # Now try to locate executable using which + new_path=`$WHICH "$new_path" 2> /dev/null` + + if test "x$new_path" = x; then + # Oops. Which didn't find the executable. + # The splitting of arguments from the executable at a space might have been incorrect, + # since paths with space are more likely in Windows. Give it another try with the whole + # argument. + path="$complete" + arguments="EOL" + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + + new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi + + if test "x$new_path" = x; then + # It's still not found. Now this is an unrecoverable error. + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JTREGEXE, which resolves as \"$complete\", is not found." >&5 +$as_echo "$as_me: The path of JTREGEXE, which resolves as \"$complete\", is not found." >&6;} + has_space=`$ECHO "$complete" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 +$as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} + fi + as_fn_error $? "Cannot locate the the path of JTREGEXE" "$LINENO" 5 + fi + fi + + # Now new_path has a complete unix path to the binary + if test "x`$ECHO $new_path | $GREP ^/bin/`" != x; then + # Keep paths in /bin as-is, but remove trailing .exe if any + new_path="${new_path/%.exe/}" + # Do not save /bin paths to all_fixpath_prefixes! + else + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $new_path` + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + # Output is in $new_path + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + # remove trailing .exe if any + new_path="${new_path/%.exe/}" + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + fi + + else + # We're on a unix platform. Hooray! :) + # First separate the path from the arguments. This will split at the first + # space. + complete="$JTREGEXE" + path="${complete%% *}" + tmp="$complete EOL" + arguments="${tmp#* }" + + # Cannot rely on the command "which" here since it doesn't always work. + is_absolute_path=`$ECHO "$path" | $GREP ^/` + if test -z "$is_absolute_path"; then + # Path to executable is not absolute. Find it. + IFS_save="$IFS" + IFS=: + for p in $PATH; do + if test -f "$p/$path" && test -x "$p/$path"; then + new_path="$p/$path" + break + fi + done + IFS="$IFS_save" + else + # This is an absolute path, we can use it without further modifications. + new_path="$path" + fi + + if test "x$new_path" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JTREGEXE, which resolves as \"$complete\", is not found." >&5 +$as_echo "$as_me: The path of JTREGEXE, which resolves as \"$complete\", is not found." >&6;} + has_space=`$ECHO "$complete" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 +$as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} + fi + as_fn_error $? "Cannot locate the the path of JTREGEXE" "$LINENO" 5 + fi + fi + + # Now join together the path and the arguments once again + if test "x$arguments" != xEOL; then + new_complete="$new_path ${arguments% *}" + else + new_complete="$new_path" + fi + + if test "x$complete" != "x$new_complete"; then + JTREGEXE="$new_complete" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting JTREGEXE to \"$new_complete\"" >&5 +$as_echo "$as_me: Rewriting JTREGEXE to \"$new_complete\"" >&6;} + fi + fi + + + # Only process if variable expands to non-empty + + if test "x$JT_HOME" != x; then + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # Input might be given as Windows format, start by converting to + # unix format. + path="$JT_HOME" + new_path=`$CYGPATH -u "$path"` + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JT_HOME, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of JT_HOME, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Cannot locate the the path of JT_HOME" "$LINENO" 5 + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-style (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + + if test "x$path" != "x$new_path"; then + JT_HOME="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting JT_HOME to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting JT_HOME to \"$new_path\"" >&6;} + fi + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + path="$JT_HOME" + has_colon=`$ECHO $path | $GREP ^.:` + new_path="$path" + if test "x$has_colon" = x; then + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $path` + fi + + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + if test "x$path" != "x$new_path"; then + JT_HOME="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting JT_HOME to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting JT_HOME to \"$new_path\"" >&6;} + fi + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + + else + # We're on a unix platform. Hooray! :) + path="$JT_HOME" + has_space=`$ECHO "$path" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JT_HOME, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of JT_HOME, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 + fi + + # Use eval to expand a potential ~ + eval path="$path" + if test ! -f "$path" && test ! -d "$path"; then + as_fn_error $? "The path of JT_HOME, which resolves as \"$path\", is not found." "$LINENO" 5 + fi + + if test -d "$path"; then + JT_HOME="`cd "$path"; $THEPWDCMD -L`" + else + dir="`$DIRNAME "$path"`" + base="`$BASENAME "$path"`" + JT_HOME="`cd "$dir"; $THEPWDCMD -L`/$base" + fi + fi + fi + + diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index 2f02ec62f4f..fca9b065aab 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -1000,6 +1000,8 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], fi fi + BASIC_FIXUP_EXECUTABLE(JTREGEXE) + BASIC_FIXUP_PATH(JT_HOME) AC_SUBST(JT_HOME) AC_SUBST(JTREGEXE) ]) From ac1c8796b2e9cd5b8247503bea1b88036de573b2 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Mon, 15 May 2017 20:27:38 -0700 Subject: [PATCH 24/66] 8180060: Examine copyright header for some files Reviewed-by: lancea --- .../xerces/internal/util/FeatureState.java | 9 +---- .../util/ParserConfigurationSettings.java | 2 +- .../xerces/internal/util/PropertyState.java | 8 +--- .../apache/xerces/internal/util/Status.java | 8 +--- .../dtd/nonvalidating/XMLSimpleType.java | 39 +++++++------------ 5 files changed, 18 insertions(+), 48 deletions(-) diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/FeatureState.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/FeatureState.java index e78b30c3773..36e56879d18 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/FeatureState.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/FeatureState.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 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 @@ -22,14 +23,6 @@ * questions. */ -/* - * Copyright (c) 2009 by Oracle Corporation. All Rights Reserved. - */ - -/* - * $Id: FeatureState.java 3024 2011-03-01 03:46:13Z joehw $ - */ - package com.sun.org.apache.xerces.internal.util; public class FeatureState { diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java index 36ef62a6da1..7eca1d312da 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/PropertyState.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/PropertyState.java index 5e133cae65c..5788b64ab12 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/PropertyState.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/PropertyState.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 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 @@ -22,13 +23,6 @@ * questions. */ -/* - * Copyright (c) 2009 by Oracle Corporation. All Rights Reserved. - */ - -/* - * $Id: PropertyState.java 3024 2011-03-01 03:46:13Z joehw $ - */ package com.sun.org.apache.xerces.internal.util; public class PropertyState { diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/Status.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/Status.java index 5fdcc5e19c1..b6d169eaa3d 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/Status.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/Status.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 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 @@ -22,13 +23,6 @@ * questions. */ -/* - * Copyright (c) 2009 by Oracle Corporation. All Rights Reserved. - */ - -/* - * $Id: Status.java 3024 2011-03-01 03:46:13Z joehw $ - */ package com.sun.org.apache.xerces.internal.util; public enum Status { diff --git a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/dtd/nonvalidating/XMLSimpleType.java b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/dtd/nonvalidating/XMLSimpleType.java index 31ae534390e..6d0763ef3a4 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/dtd/nonvalidating/XMLSimpleType.java +++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/dtd/nonvalidating/XMLSimpleType.java @@ -1,32 +1,21 @@ /* * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * 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 FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. */ - /* - * Copyright 2005 The Apache Software Foundation. + * 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 com.sun.xml.internal.stream.dtd.nonvalidating; From f7ec0ea64a471861e769abb6b0f4310538380e71 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Tue, 16 May 2017 14:13:48 +0200 Subject: [PATCH 25/66] 8180420: Set PATH for dot and pandoc in JIB Reviewed-by: erikj --- common/conf/jib-profiles.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js index b6fd25a6fcf..1892fafab9f 100644 --- a/common/conf/jib-profiles.js +++ b/common/conf/jib-profiles.js @@ -997,7 +997,8 @@ var getJibProfilesDependencies = function (input, common) { ext: "tar.gz", revision: "2.38.0-1+1.1", module: "graphviz-" + input.target_platform, - configure_args: "DOT=" + input.get("graphviz", "install_path") + "/dot" + configure_args: "DOT=" + input.get("graphviz", "install_path") + "/dot", + environment_path: input.get("graphviz", "install_path") }, pandoc: { @@ -1005,7 +1006,8 @@ var getJibProfilesDependencies = function (input, common) { ext: "tar.gz", revision: "1.17.2+1.0", module: "pandoc-" + input.target_platform, - configure_args: "PANDOC=" + input.get("pandoc", "install_path") + "/pandoc/pandoc" + configure_args: "PANDOC=" + input.get("pandoc", "install_path") + "/pandoc/pandoc", + environment_path: input.get("pandoc", "install_path") + "/pandoc" }, }; From 62b2c4716cf1ade3da20d728f3406f94a580953f Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Tue, 16 May 2017 14:14:26 +0200 Subject: [PATCH 26/66] 8180328: Bad links in footer of all javadoc-generated pages Reviewed-by: erikj --- make/Docs.gmk | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/make/Docs.gmk b/make/Docs.gmk index 2859070391d..f95a57d376f 100644 --- a/make/Docs.gmk +++ b/make/Docs.gmk @@ -48,11 +48,8 @@ $(eval $(call IncludeCustomExtension, , Docs.gmk)) MODULES_SOURCE_PATH := $(call PathList, $(call GetModuleSrcPath) \ $(SUPPORT_OUTPUTDIR)/rmic/* $(JDK_TOPDIR)/src/*/share/doc/stub) -# Should we use -Xdocrootparent? Allow custom to overwrite. -DOCROOTPARENT_FLAG ?= TRUE - # URLs -JAVADOC_BASE_URL := http://www.oracle.com/pls/topic/lookup?ctx=javase9&id=homepage +JAVADOC_BASE_URL := http://www.oracle.com/pls/topic/lookup?ctx=javase9&id=homepage BUG_SUBMIT_URL := http://bugreport.java.com/bugreport/ COPYRIGHT_URL := {@docroot}/../legal/cpyr.html LICENSE_URL := http://www.oracle.com/technetwork/java/javase/terms/license/java9speclicense.html @@ -130,7 +127,7 @@ JAVADOC_BOTTOM := \ \ Submit a bug or feature
    \ For further API reference and developer documentation, see \ - Java SE \ + Java SE \ Documentation. That documentation contains more detailed, \ developer-targeted descriptions, with conceptual overviews, definitions \ of terms, workarounds, and working code examples.
    \ @@ -236,10 +233,6 @@ define SetupApiDocsGenerationBody $1_OPTIONS += -Xdoclint:all,$$(call CommaList, $$(addprefix -, \ $$(JAVADOC_DISABLED_DOCLINT))) - ifeq ($$($$DOCROOTPARENT_FLAG), TRUE) - $1_OPTIONS += -Xdocrootparent $$(JAVADOC_BASE_URL) - endif - $1_OPTIONS += -doctitle '$$($1_DOC_TITLE)' $1_OPTIONS += -windowtitle '$$($1_WINDOW_TITLE)' $1_OPTIONS += -header '$$($1_HEADER_TITLE)' From 187b51e2254d33281f764a7ea3130d503ce64a0f Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 18 May 2017 14:54:52 +0000 Subject: [PATCH 27/66] Added tag jdk-9+170 for changeset 8ad1bd49f4bc --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 88b31a1ce33..1aa95fe45fa 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -412,3 +412,4 @@ ba5b16c9c6d80632b61959a33d424b1c3398ce62 jdk-9+166 35017c286513ddcbcc6b63b99679c604993fc639 jdk-9+167 143d4c87bc1ef1ed6dadd613cd9dd4488fdefc29 jdk-9+168 b25838a28195f4b6dab34668411eedd2d366a16c jdk-9+169 +4d163ec59d989a9261ed7f848bc6303f90869af5 jdk-9+170 From 9b6308c921201e85e447fb5e6db9d55471289352 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 18 May 2017 14:54:53 +0000 Subject: [PATCH 28/66] Added tag jdk-9+170 for changeset aa1fcec9731f --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 6dde9ab35df..1a96c62ac8c 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -412,3 +412,4 @@ a510b2201154abdd12ede42788086b5283bfb9a6 jdk-9+165 43de67f51801b9e16507865fcb7e8344f4ca4aa9 jdk-9+167 03a2cc9c8a1e8f87924c9863e917bc8b91770d5f jdk-9+168 b2218d41edef02ee8f94bb438f885b2ba79bfa08 jdk-9+169 +8a4ab3b0ab9a86df73d9a1e337134f2dbe006725 jdk-9+170 From cb190703ef201965fbe9afbfbdcbc315f3091301 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 18 May 2017 14:54:53 +0000 Subject: [PATCH 29/66] Added tag jdk-9+170 for changeset e3a622b2b7db --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 1ce36c1698b..3f07e474bf8 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -572,3 +572,4 @@ c92c6416ca03b1464d5ed99cf6201e52b5ba0a70 jdk-9+165 1ca7ed1b17b5776930d641d1379834f3140a74e4 jdk-9+167 fbb9c802649585d19f6d7e81b4a519d44806225a jdk-9+168 16d692be099c5c38eb48cc9aca78b0c900910d5b jdk-9+169 +38a240fd58a287acb1963920b92ed4d9c2fd39e3 jdk-9+170 From e87b6392b79dc1f4d4f3f247021dfa758e00d281 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 18 May 2017 14:54:54 +0000 Subject: [PATCH 30/66] Added tag jdk-9+170 for changeset 13796d1d9f0a --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index bc1c0c2fae9..3de43d927d2 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -412,3 +412,4 @@ d02b6fbcab06c59a5f5a4a6736bd4ec6d2567855 jdk-9+162 646567dcfa64b9a39b33d71330427737d1c1a0d5 jdk-9+167 23a87f409371fb8ce7b764cccb3a74c3f6b29900 jdk-9+168 5d9d2a65fb26aa183019346c11d9314819621665 jdk-9+169 +6e78f902f477a093afca85a1042f97410d01eb69 jdk-9+170 From 319619e55f30048ea998a2ce8929870fc143a0af Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 18 May 2017 14:54:54 +0000 Subject: [PATCH 31/66] Added tag jdk-9+170 for changeset 5198a9f0c661 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index a06eb101dc0..21073a683c7 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -415,3 +415,4 @@ b1f30c27367bd286fa4eb8a767335e917a5b5b82 jdk-9+166 1c610f1b4097c64cdd722a7fb59f5a4d9cc15ca9 jdk-9+167 2746716dcc5a8c28ccf41df0c8fb620b1a1e7098 jdk-9+168 912cf69806d518c5af7fba30b340c4cb5458dd22 jdk-9+169 +e75d3abe579a7b39b762fc0a1a337c49eb072d82 jdk-9+170 From 6dd266ef16eec60d08e103c9ca01d98edbe94195 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 18 May 2017 14:54:56 +0000 Subject: [PATCH 32/66] Added tag jdk-9+170 for changeset 685d1772b3cf --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 309e95d806c..842a6874e19 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -403,3 +403,4 @@ e36e62d3ea53c316f295b37bcc19867fbf510235 jdk-9+165 e118c818dbf84d15191414c453b77c089116fdc0 jdk-9+167 0f81cde5a1f75786f381dbfb59b9afbab70174c7 jdk-9+168 131e250080158e57ce45130560f5f987b92642b5 jdk-9+169 +550bfc15779f8f339610793867fdc251125811b5 jdk-9+170 From 2e6d1426b2fdfa98e40e97b7156fc86e016f7d76 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 18 May 2017 14:54:56 +0000 Subject: [PATCH 33/66] Added tag jdk-9+170 for changeset f5f796453339 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index f6415c80f54..0b1896d3de1 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -412,3 +412,4 @@ c7f3df19667b093538c6eecb73dcb3fb531706b4 jdk-9+164 f260f1a2acf616509a4ee5a29bc7f2acca3853e3 jdk-9+167 bc21e5ba6bf1538551093f57fa0f1a6571be05cc jdk-9+168 0e522ff8b9f52a9d4929af9a6aa84110f4dcd81d jdk-9+169 +18355c879c69a33167f1862896738a7b9a4da729 jdk-9+170 From ec43007637a55b7891cd83e6c2815f725a607665 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Thu, 18 May 2017 10:22:19 -0700 Subject: [PATCH 34/66] 8180395: move FilterClassLoader and ParentLastURLClassLoader to top level testlibrary Reviewed-by: psandoz --- .../lib/classloader/FilterClassLoader.java | 50 ++++++++++++++++++ .../classloader/ParentLastURLClassLoader.java | 51 +++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 test/lib/jdk/test/lib/classloader/FilterClassLoader.java create mode 100644 test/lib/jdk/test/lib/classloader/ParentLastURLClassLoader.java diff --git a/test/lib/jdk/test/lib/classloader/FilterClassLoader.java b/test/lib/jdk/test/lib/classloader/FilterClassLoader.java new file mode 100644 index 00000000000..327b1d27a7d --- /dev/null +++ b/test/lib/jdk/test/lib/classloader/FilterClassLoader.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014, 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.classloader; + +import java.util.function.Predicate; +/** + * A classloader, which using target classloader in case provided condition + * for class name is met, and using parent otherwise + */ +public class FilterClassLoader extends ClassLoader { + + private final ClassLoader target; + private final Predicate condition; + + public FilterClassLoader(ClassLoader target, ClassLoader parent, + Predicate condition) { + super(parent); + this.condition = condition; + this.target = target; + } + + @Override + public Class loadClass(String name) throws ClassNotFoundException { + if (condition.test(name)) { + return target.loadClass(name); + } + return super.loadClass(name); + } +} diff --git a/test/lib/jdk/test/lib/classloader/ParentLastURLClassLoader.java b/test/lib/jdk/test/lib/classloader/ParentLastURLClassLoader.java new file mode 100644 index 00000000000..71d8953b812 --- /dev/null +++ b/test/lib/jdk/test/lib/classloader/ParentLastURLClassLoader.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014, 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.classloader; + +import java.net.URL; +import java.net.URLClassLoader; + +/** + * An url classloader, which trying to load class from provided URL[] first, + * and using parent classloader in case it failed + */ +public class ParentLastURLClassLoader extends URLClassLoader { + + public ParentLastURLClassLoader(URL urls[], ClassLoader parent) { + super(urls, parent); + } + + @Override + public Class loadClass(String name) throws ClassNotFoundException { + try { + Class c = findClass(name); + if (c != null) { + return c; + } + } catch (ClassNotFoundException e) { + // ignore + } + return super.loadClass(name); + } +} From 08a3a230438c17685043cb21a2ed95702adbd4e0 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Thu, 18 May 2017 14:16:25 -0700 Subject: [PATCH 35/66] 8167554: jshell tool: re-execute a range and/or sequence of snippets 8180508: jshell tool: support id ranges in all commands with id arguments Reviewed-by: jlahoda --- .../internal/jshell/tool/ArgTokenizer.java | 11 + .../jdk/internal/jshell/tool/JShellTool.java | 377 ++++++++++++++---- .../jshell/tool/resources/l10n.properties | 92 ++++- .../jdk/jshell/CommandCompletionTest.java | 6 +- langtools/test/jdk/jshell/EditorTestBase.java | 2 +- .../jshell/MergedTabShiftTabCommandTest.java | 10 +- langtools/test/jdk/jshell/ToolBasicTest.java | 151 +++++-- .../jdk/jshell/ToolLocaleMessageTest.java | 1 - langtools/test/jdk/jshell/ToolSimpleTest.java | 54 ++- 9 files changed, 546 insertions(+), 158 deletions(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java index ad66b67d61e..1fb0661959e 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java @@ -120,6 +120,17 @@ class ArgTokenizer { } } + /** + * Is the specified option allowed. + * + * @param opt the option to check + * @return true if the option is allowed + */ + boolean isAllowedOption(String opt) { + Boolean has = options.get(opt); + return has != null; + } + /** * Has the specified option been encountered. * diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index 0a54674d7a4..c58ba51b883 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -90,7 +90,6 @@ import static java.nio.file.StandardOpenOption.CREATE; import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; import static java.nio.file.StandardOpenOption.WRITE; import java.util.MissingResourceException; -import java.util.Optional; import java.util.ResourceBundle; import java.util.ServiceLoader; import java.util.Spliterators; @@ -126,6 +125,7 @@ import static jdk.internal.jshell.tool.ContinuousCompletionProvider.STARTSWITH_M public class JShellTool implements MessageHandler { private static final Pattern LINEBREAK = Pattern.compile("\\R"); + private static final Pattern ID = Pattern.compile("[se]?\\d+([-\\s].*)?"); static final String RECORD_SEPARATOR = "\u241E"; private static final String RB_NAME_PREFIX = "jdk.internal.jshell.tool.resources"; private static final String VERSION_RB_NAME = RB_NAME_PREFIX + ".version"; @@ -1189,36 +1189,54 @@ public class JShellTool implements MessageHandler { } } - private void processCommand(String cmd) { - if (cmd.startsWith("/-")) { + /** + * Process a command (as opposed to a snippet) -- things that start with + * slash. + * + * @param input + */ + private void processCommand(String input) { + if (input.startsWith("/-")) { try { //handle "/-[number]" - cmdUseHistoryEntry(Integer.parseInt(cmd.substring(1))); + cmdUseHistoryEntry(Integer.parseInt(input.substring(1))); return ; } catch (NumberFormatException ex) { //ignore } } - String arg = ""; - int idx = cmd.indexOf(' '); + String cmd; + String arg; + int idx = input.indexOf(' '); if (idx > 0) { - arg = cmd.substring(idx + 1).trim(); - cmd = cmd.substring(0, idx); + arg = input.substring(idx + 1).trim(); + cmd = input.substring(0, idx); + } else { + cmd = input; + arg = ""; } + // find the command as a "real command", not a pseudo-command or doc subject Command[] candidates = findCommand(cmd, c -> c.kind.isRealCommand); switch (candidates.length) { case 0: - if (!rerunHistoryEntryById(cmd.substring(1))) { - errormsg("jshell.err.no.such.command.or.snippet.id", cmd); + // not found, it is either a snippet command or an error + if (ID.matcher(cmd.substring(1)).matches()) { + // it is in the form of a snipppet id, see if it is a valid history reference + rerunHistoryEntriesById(input); + } else { + errormsg("jshell.err.invalid.command", cmd); fluffmsg("jshell.msg.help.for.help"); - } break; + } + break; case 1: Command command = candidates[0]; // If comand was successful and is of a replayable kind, add it the replayable history if (command.run.apply(arg) && command.kind == CommandKind.REPLAY) { addToReplayHistory((command.command + " " + arg).trim()); - } break; + } + break; default: + // command if too short (ambigous), show the possibly matches errormsg("jshell.err.command.ambiguous", cmd, Arrays.stream(candidates).map(c -> c.command).collect(Collectors.joining(", "))); fluffmsg("jshell.msg.help.for.help"); @@ -1701,6 +1719,9 @@ public class JShellTool implements MessageHandler { registerCommand(new Command("context", "help.context", CommandKind.HELP_SUBJECT)); + registerCommand(new Command("rerun", + "help.rerun", + CommandKind.HELP_SUBJECT)); commandCompletions = new ContinuousCompletionProvider( commands.values().stream() @@ -2247,6 +2268,20 @@ public class JShellTool implements MessageHandler { Predicate defFilter, String rawargs, String cmd) { ArgTokenizer at = new ArgTokenizer(cmd, rawargs.trim()); at.allowedOptions("-all", "-start"); + return argsOptionsToSnippets(snippetSupplier, defFilter, at); + } + + /** + * Convert user arguments to a Stream of snippets referenced by those + * arguments (or lack of arguments). + * + * @param snippets the base list of possible snippets + * @param defFilter the filter to apply to the arguments if no argument + * @param at the ArgTokenizer, with allowed options set + * @return + */ + private Stream argsOptionsToSnippets(Supplier> snippetSupplier, + Predicate defFilter, ArgTokenizer at) { List args = new ArrayList<>(); String s; while ((s = at.next()) != null) { @@ -2263,11 +2298,11 @@ public class JShellTool implements MessageHandler { errormsg("jshell.err.conflicting.options", at.whole()); return null; } - if (at.hasOption("-all")) { + if (at.isAllowedOption("-all") && at.hasOption("-all")) { // all snippets including start-up, failed, and overwritten return snippetSupplier.get(); } - if (at.hasOption("-start")) { + if (at.isAllowedOption("-start") && at.hasOption("-start")) { // start-up snippets return snippetSupplier.get() .filter(this::inStartUp); @@ -2277,54 +2312,227 @@ public class JShellTool implements MessageHandler { return snippetSupplier.get() .filter(defFilter); } - return argsToSnippets(snippetSupplier, args); + return new ArgToSnippets<>(snippetSupplier).argsToSnippets(args); } /** - * Convert user arguments to a Stream of snippets referenced by those - * arguments. + * Support for converting arguments that are definition names, snippet ids, + * or snippet id ranges into a stream of snippets, * - * @param snippetSupplier the base list of possible snippets - * @param args the user's argument to the command, maybe be the empty list - * @return a Stream of referenced snippets or null if no matches to specific - * arg + * @param the snipper subtype */ - private Stream argsToSnippets(Supplier> snippetSupplier, - List args) { - Stream result = null; - for (String arg : args) { + private class ArgToSnippets { + + // the supplier of snippet streams + final Supplier> snippetSupplier; + // these two are parallel, and lazily filled if a range is encountered + List allSnippets; + String[] allIds = null; + + /** + * + * @param snippetSupplier the base list of possible snippets + */ + ArgToSnippets(Supplier> snippetSupplier) { + this.snippetSupplier = snippetSupplier; + } + + /** + * Convert user arguments to a Stream of snippets referenced by those + * arguments. + * + * @param args the user's argument to the command, maybe be the empty + * list + * @return a Stream of referenced snippets or null if no matches to + * specific arg + */ + Stream argsToSnippets(List args) { + Stream result = null; + for (String arg : args) { + // Find the best match + Stream st = argToSnippets(arg); + if (st == null) { + return null; + } else { + result = (result == null) + ? st + : Stream.concat(result, st); + } + } + return result; + } + + /** + * Convert a user argument to a Stream of snippets referenced by the + * argument. + * + * @param snippetSupplier the base list of possible snippets + * @param arg the user's argument to the command + * @return a Stream of referenced snippets or null if no matches to + * specific arg + */ + Stream argToSnippets(String arg) { + if (arg.contains("-")) { + return range(arg); + } // Find the best match Stream st = layeredSnippetSearch(snippetSupplier, arg); if (st == null) { - Stream est = layeredSnippetSearch(state::snippets, arg); - if (est == null) { - errormsg("jshell.err.no.such.snippets", arg); - } else { - errormsg("jshell.err.the.snippet.cannot.be.used.with.this.command", - arg, est.findFirst().get().source()); - } + badSnippetErrormsg(arg); return null; - } - if (result == null) { - result = st; } else { - result = Stream.concat(result, st); + return st; } } - return result; - } - private Stream layeredSnippetSearch(Supplier> snippetSupplier, String arg) { - return nonEmptyStream( - // the stream supplier - snippetSupplier, - // look for active user declarations matching the name - sn -> isActive(sn) && matchingDeclaration(sn, arg), - // else, look for any declarations matching the name - sn -> matchingDeclaration(sn, arg), - // else, look for an id of this name - sn -> sn.id().equals(arg) - ); + /** + * Look for inappropriate snippets to give best error message + * + * @param arg the bad snippet arg + * @param errKey the not found error key + */ + void badSnippetErrormsg(String arg) { + Stream est = layeredSnippetSearch(state::snippets, arg); + if (est == null) { + if (ID.matcher(arg).matches()) { + errormsg("jshell.err.no.snippet.with.id", arg); + } else { + errormsg("jshell.err.no.such.snippets", arg); + } + } else { + errormsg("jshell.err.the.snippet.cannot.be.used.with.this.command", + arg, est.findFirst().get().source()); + } + } + + /** + * Search through the snippets for the best match to the id/name. + * + * @param the snippet type + * @param aSnippetSupplier the supplier of snippet streams + * @param arg the arg to match + * @return a Stream of referenced snippets or null if no matches to + * specific arg + */ + Stream layeredSnippetSearch(Supplier> aSnippetSupplier, String arg) { + return nonEmptyStream( + // the stream supplier + aSnippetSupplier, + // look for active user declarations matching the name + sn -> isActive(sn) && matchingDeclaration(sn, arg), + // else, look for any declarations matching the name + sn -> matchingDeclaration(sn, arg), + // else, look for an id of this name + sn -> sn.id().equals(arg) + ); + } + + /** + * Given an id1-id2 range specifier, return a stream of snippets within + * our context + * + * @param arg the range arg + * @return a Stream of referenced snippets or null if no matches to + * specific arg + */ + Stream range(String arg) { + int dash = arg.indexOf('-'); + String iid = arg.substring(0, dash); + String tid = arg.substring(dash + 1); + int iidx = snippetIndex(iid); + if (iidx < 0) { + return null; + } + int tidx = snippetIndex(tid); + if (tidx < 0) { + return null; + } + if (tidx < iidx) { + errormsg("jshell.err.end.snippet.range.less.than.start", iid, tid); + return null; + } + return allSnippets.subList(iidx, tidx+1).stream(); + } + + /** + * Lazily initialize the id mapping -- needed only for id ranges. + */ + void initIdMapping() { + if (allIds == null) { + allSnippets = snippetSupplier.get() + .sorted((a, b) -> order(a) - order(b)) + .collect(toList()); + allIds = allSnippets.stream() + .map(sn -> sn.id()) + .toArray(n -> new String[n]); + } + } + + /** + * Return all the snippet ids -- within the context, and in order. + * + * @return the snippet ids + */ + String[] allIds() { + initIdMapping(); + return allIds; + } + + /** + * Establish an order on snippet ids. All startup snippets are first, + * all error snippets are last -- within that is by snippet number. + * + * @param id the id string + * @return an ordering int + */ + int order(String id) { + try { + switch (id.charAt(0)) { + case 's': + return Integer.parseInt(id.substring(1)); + case 'e': + return 0x40000000 + Integer.parseInt(id.substring(1)); + default: + return 0x20000000 + Integer.parseInt(id); + } + } catch (Exception ex) { + return 0x60000000; + } + } + + /** + * Establish an order on snippets, based on its snippet id. All startup + * snippets are first, all error snippets are last -- within that is by + * snippet number. + * + * @param sn the id string + * @return an ordering int + */ + int order(Snippet sn) { + return order(sn.id()); + } + + /** + * Find the index into the parallel allSnippets and allIds structures. + * + * @param s the snippet id name + * @return the index, or, if not found, report the error and return a + * negative number + */ + int snippetIndex(String s) { + int idx = Arrays.binarySearch(allIds(), 0, allIds().length, s, + (a, b) -> order(a) - order(b)); + if (idx < 0) { + // the id is not in the snippet domain, find the right error to report + if (!ID.matcher(s).matches()) { + errormsg("jshell.err.range.requires.id", s); + } else { + badSnippetErrormsg(s); + } + } + return idx; + } + } private boolean cmdDrop(String rawargs) { @@ -2342,24 +2550,13 @@ public class JShellTool implements MessageHandler { errormsg("jshell.err.drop.arg"); return false; } - Stream stream = argsToSnippets(this::dropableSnippets, args); + Stream stream = new ArgToSnippets<>(this::dropableSnippets).argsToSnippets(args); if (stream == null) { // Snippet not found. Error already printed fluffmsg("jshell.msg.see.classes.etc"); return false; } - List snippets = stream.collect(toList()); - if (snippets.size() > args.size()) { - // One of the args references more thean one snippet - errormsg("jshell.err.drop.ambiguous"); - fluffmsg("jshell.msg.use.one.of", snippets.stream() - .map(sn -> String.format("\n/drop %-5s : %s", sn.id(), sn.source().replace("\n", "\n "))) - .collect(Collectors.joining(", ")) - ); - return false; - } - snippets.stream() - .forEach(sn -> state.drop(sn).forEach(this::handleEvent)); + stream.forEach(sn -> state.drop(sn).forEach(this::handleEvent)); return true; } @@ -2690,37 +2887,38 @@ public class JShellTool implements MessageHandler { } private boolean cmdSave(String rawargs) { - ArgTokenizer at = new ArgTokenizer("/save", rawargs.trim()); - at.allowedOptions("-all", "-start", "-history"); - String filename = at.next(); - if (filename == null) { + // The filename to save to is the last argument, extract it + String[] args = rawargs.split("\\s"); + String filename = args[args.length - 1]; + if (filename.isEmpty()) { errormsg("jshell.err.file.filename", "/save"); return false; } - if (!checkOptionsAndRemainingInput(at)) { - return false; - } - if (at.optionCount() > 1) { - errormsg("jshell.err.conflicting.options", at.whole()); + // All the non-filename arguments are the specifier of what to save + String srcSpec = Arrays.stream(args, 0, args.length - 1) + .collect(Collectors.joining("\n")); + // From the what to save specifier, compute the snippets (as a stream) + ArgTokenizer at = new ArgTokenizer("/save", srcSpec); + at.allowedOptions("-all", "-start", "-history"); + Stream snippetStream = argsOptionsToSnippets(state::snippets, this::mainActive, at); + if (snippetStream == null) { + // error occurred, already reported return false; } try (BufferedWriter writer = Files.newBufferedWriter(toPathResolvingUserHome(filename), Charset.defaultCharset(), CREATE, TRUNCATE_EXISTING, WRITE)) { if (at.hasOption("-history")) { + // they want history (commands and snippets), ignore the snippet stream for (String s : input.currentSessionHistory()) { writer.write(s); writer.write("\n"); } - } else if (at.hasOption("-start")) { - writer.append(startup.toString()); } else { - String sources = (at.hasOption("-all") - ? state.snippets() - : state.snippets().filter(this::mainActive)) + // write the snippet stream to the file + writer.write(snippetStream .map(Snippet::source) - .collect(Collectors.joining("\n")); - writer.write(sources); + .collect(Collectors.joining("\n"))); } } catch (FileNotFoundException e) { errormsg("jshell.err.file.not.found", "/save", filename, e.getMessage()); @@ -2837,14 +3035,21 @@ public class JShellTool implements MessageHandler { return true; } - private boolean rerunHistoryEntryById(String id) { - Optional snippet = state.snippets() - .filter(s -> s.id().equals(id)) - .findFirst(); - return snippet.map(s -> { - rerunSnippet(s); - return true; - }).orElse(false); + /** + * Handle snippet reevaluation commands: {@code /}. These commands are a + * sequence of ids and id ranges (names are permitted, though not in the + * first position. Support for names is purposely not documented). + * + * @param rawargs the whole command including arguments + */ + private void rerunHistoryEntriesById(String rawargs) { + ArgTokenizer at = new ArgTokenizer("/", rawargs.trim().substring(1)); + at.allowedOptions(); + Stream stream = argsOptionsToSnippets(state::snippets, sn -> true, at); + if (stream != null) { + // successfully parsed, rerun snippets + stream.forEach(sn -> rerunSnippet(sn)); + } } private void rerunSnippet(Snippet snippet) { diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties index f636404da0b..e67778189f6 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties @@ -50,7 +50,7 @@ jshell.err.file.filename = ''{0}'' requires a filename argument. jshell.err.startup.unexpected.exception = Unexpected exception reading start-up: {0} jshell.err.unexpected.exception = Unexpected exception: {0} -jshell.err.no.such.command.or.snippet.id = No such command or snippet id: {0} +jshell.err.invalid.command = Invalid command: {0} jshell.err.command.ambiguous = Command: ''{0}'' is ambiguous: {1} jshell.msg.set.restore = Setting new options and restoring state. jshell.msg.set.editor.set = Editor set to: {0} @@ -105,10 +105,13 @@ For example ''/help /list'' or ''/help intro''.\n\ Subjects:\n\ \n +jshell.err.no.snippet.with.id = No snippet with id: {0} +jshell.err.end.snippet.range.less.than.start = End of snippet range less than start: {0} - {1} +jshell.err.range.requires.id = Snippet ranges require snippet ids: {0} + jshell.err.drop.arg =\ In the /drop argument, please specify an import, variable, method, or class to drop.\n\ Specify by id or name. Use /list to see ids. Use /reset to reset all state. -jshell.err.drop.ambiguous = The argument references more than one import, variable, method, or class. jshell.err.failed = Failed. jshell.msg.native.method = Native Method jshell.msg.unknown.source = Unknown Source @@ -225,7 +228,11 @@ Show the source of snippets, prefaced with the snippet id.\n\ /list \n\t\ List snippets with the specified name (preference for active snippets)\n\n\ /list \n\t\ - List the snippet with the specified snippet id + List the snippet with the specified snippet id\n\n\ +/list ...\n\t\ + List the snippets with the specified snippet ids\n\n\ +/list -\n\t\ + List the snippets within the range of snippet ids help.edit.summary = edit a source entry referenced by name or id help.edit.args = @@ -238,6 +245,10 @@ If no editor has been set, a simple editor will be launched.\n\ Edit the snippet or snippets with the specified name (preference for active snippets)\n\n\ /edit \n\t\ Edit the snippet with the specified snippet id\n\n\ +/edit ...\n\t\ + Edit the snippets with the specified snippet ids\n\n\ +/edit -\n\t\ + Edit the snippets within the range of snippet ids\n\n\ /edit\n\t\ Edit the currently active snippets of code that you typed or read with /open @@ -249,7 +260,11 @@ Drop a snippet -- making it inactive.\n\ /drop \n\t\ Drop the snippet with the specified name\n\n\ /drop \n\t\ - Drop the snippet with the specified snippet id + Drop the snippet with the specified snippet id\n\n\ +/drop ...\n\t\ + Drop the snippets with the specified snippet ids\n\n\ +/drop -\n\t\ + Drop the snippets within the range of snippet ids help.save.summary = Save snippet source to a file. help.save.args = [-all|-history|-start] @@ -264,7 +279,13 @@ Save the specified snippets and/or commands to the specified file.\n\ /save -history \n\t\ Save the sequential history of all commands and snippets entered since jshell was launched.\n\n\ /save -start \n\t\ - Save the current start-up definitions to the file. + Save the current start-up definitions to the file.\n\n\ +/save \n\t\ + Save the snippet with the specified snippet id\n\n\ +/save ... \n\t\ + Save the snippets with the specified snippet ids\n\n\ +/save - \n\t\ + Save the snippets within the range of snippet ids help.open.summary = open a file as source input help.open.args = @@ -285,6 +306,10 @@ List the type, name, and value of jshell variables.\n\ List jshell variables with the specified name (preference for active variables)\n\n\ /vars \n\t\ List the jshell variable with the specified snippet id\n\n\ +/vars ... \n\t\ + List the jshell variables with the specified snippet ids\n\n\ +/vars - \n\t\ + List the jshell variables within the range of snippet ids\n\n\ /vars -start\n\t\ List the automatically added start-up jshell variables\n\n\ /vars -all\n\t\ @@ -301,6 +326,10 @@ List the name, parameter types, and return type of jshell methods.\n\ List jshell methods with the specified name (preference for active methods)\n\n\ /methods \n\t\ List the jshell method with the specified snippet id\n\n\ +/methods ... \n\t\ + List jshell methods with the specified snippet ids\n\n\ +/methods - \n\t\ + List jshell methods within the range of snippet ids\n\n\ /methods -start\n\t\ List the automatically added start-up jshell methods\n\n\ /methods -all\n\t\ @@ -317,6 +346,10 @@ List jshell classes, interfaces, and enums.\n\ List jshell types with the specified name (preference for active types)\n\n\ /types \n\t\ List the jshell type with the specified snippet id\n\n\ +/types ... \n\t\ + List jshell types with the specified snippet ids\n\n\ +/types - \n\t\ + List jshell types within the range of snippet ids\n\n\ /types -start\n\t\ List the automatically added start-up jshell types\n\n\ /types -all\n\t\ @@ -461,17 +494,24 @@ Display information about jshell (abbreviation for /help).\n\ /? \n\t\ Display information about the specified help subject. Example: /? intro -help.bang.summary = re-run last snippet +help.bang.summary = rerun last snippet -- see /help rerun help.bang.args = help.bang =\ Reevaluate the most recently entered snippet. -help.id.summary = re-run snippet by id +help.id.summary = rerun snippets by id or id range -- see /help rerun help.id.args = help.id =\ -Reevaluate the snippet specified by the id. +/ \n\ +\n\ +/-\n\ +\n\ +Reevaluate the snippets specified by the id or id range.\n\ +An id range is represented as a two ids separated by a hyphen, e.g.: 3-17\n\ +Start-up and error snippets maybe used, e.g.: s3-s9 or e1-e4\n\ +Any number of ids or id ranges may be used, e.g.: /3-7 s4 14-16 e2 -help.previous.summary = re-run n-th previous snippet +help.previous.summary = rerun n-th previous snippet -- see /help rerun help.previous.args = help.previous =\ Reevaluate the n-th most recently entered snippet. @@ -509,7 +549,7 @@ Shift- i\n\t\t\ then release and press "i", and jshell will propose possible imports\n\t\t\ which will resolve the identifier based on the content of the specified classpath. -help.context.summary = the evaluation context options for /env /reload and /reset +help.context.summary = a description of the evaluation context options for /env /reload and /reset help.context =\ These options configure the evaluation context, they can be specified when\n\ jshell is started: on the command-line, or restarted with the commands /env,\n\ @@ -540,6 +580,38 @@ They are:\n\t\ On the command-line these options must have two dashes, e.g.: --module-path\n\ On jshell commands they can have one or two dashes, e.g.: -module-path\n\ +help.rerun.summary = a description of ways to re-evaluate previously entered snippets +help.rerun =\ +There are four ways to re-evaluate previously entered snippets.\n\ +The last snippet can be re-evaluated using: /!\n\ +The n-th previous snippet can be re-evaluated by slash-minus and the digits of n, e.g.: /-4\n\ +For example:\n\ +\n\ + \tjshell> 2 + 2\n\ + \t$1 ==> 4\n\ +\n\ + \tjshell> /!\n\ + \t2 + 2\n\ + \t$2 ==> 4\n\ +\n\ + \tjshell> int z\n\ + \tz ==> 0\n\ +\n\ + \tjshell> /-1\n\ + \tint z;\n\ + \tz ==> 0\n\ +\n\ + \tjshell> /-4\n\ + \t2 + 2\n\ + \t$5 ==> 4\n\ +\n\ +The snippets to re-evaluate may be specified by snippet id or id range.\n\ +An id range is represented as a two ids separated by a hyphen, e.g.: 3-17\n\ +Start-up and error snippets maybe used, e.g.: s3-s9 or e1-e4\n\ +Any number of ids or id ranges may be used, e.g.: /3-7 s4 14-16 e2\n\ +\n\ +Finally, you can search backwards through history by entering ctrl-R followed by the string to search for. + help.set._retain = \ The '-retain' option saves a setting so that it is used in future sessions.\n\ The -retain option can be used on the following forms of /set:\n\n\t\ diff --git a/langtools/test/jdk/jshell/CommandCompletionTest.java b/langtools/test/jdk/jshell/CommandCompletionTest.java index 4424604fc23..535a9eb1c7e 100644 --- a/langtools/test/jdk/jshell/CommandCompletionTest.java +++ b/langtools/test/jdk/jshell/CommandCompletionTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8144095 8164825 8169818 8153402 8165405 8177079 8178013 + * @bug 8144095 8164825 8169818 8153402 8165405 8177079 8178013 8167554 * @summary Test Command Completion * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -162,13 +162,13 @@ public class CommandCompletionTest extends ReplToolTesting { "/edit ", "/env ", "/exit ", "/help ", "/history ", "/imports ", "/list ", "/methods ", "/open ", "/reload ", "/reset ", - "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "shortcuts "), + "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "rerun ", "shortcuts "), a -> assertCompletion(a, "/? |", false, "/! ", "/- ", "/ ", "/? ", "/drop ", "/edit ", "/env ", "/exit ", "/help ", "/history ", "/imports ", "/list ", "/methods ", "/open ", "/reload ", "/reset ", - "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "shortcuts "), + "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "rerun ", "shortcuts "), a -> assertCompletion(a, "/help /s|", false, "/save ", "/set "), a -> assertCompletion(a, "/help /set |", false, diff --git a/langtools/test/jdk/jshell/EditorTestBase.java b/langtools/test/jdk/jshell/EditorTestBase.java index 074b4a5bd14..927ebc6466e 100644 --- a/langtools/test/jdk/jshell/EditorTestBase.java +++ b/langtools/test/jdk/jshell/EditorTestBase.java @@ -73,7 +73,7 @@ public abstract class EditorTestBase extends ReplToolTesting { for (String edit : new String[] {"/ed", "/edit"}) { test(new String[]{"--no-startup"}, a -> assertCommandOutputStartsWith(a, edit + " 1", - "| No such snippet: 1"), + "| No snippet with id: 1"), a -> assertCommandOutputStartsWith(a, edit + " unknown", "| No such snippet: unknown") ); diff --git a/langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java b/langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java index 6a9dd82cf84..da74700b406 100644 --- a/langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java +++ b/langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java @@ -66,17 +66,17 @@ public class MergedTabShiftTabCommandTest extends UITesting { Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" + "\r\u0005/"); - inputSink.write("lis\011"); - waitOutput(out, "list $"); + inputSink.write("ed\011"); + waitOutput(out, "edit $"); inputSink.write("\011"); waitOutput(out, ".*-all.*" + "\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/"); inputSink.write("\011"); - waitOutput(out, Pattern.quote(getResource("help.list.summary")) + "\n\n" + - Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/list "); + waitOutput(out, Pattern.quote(getResource("help.edit.summary")) + "\n\n" + + Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/edit "); inputSink.write("\011"); - waitOutput(out, Pattern.quote(getResource("help.list").replaceAll("\t", " "))); + waitOutput(out, Pattern.quote(getResource("help.edit").replaceAll("\t", " "))); inputSink.write("\u0003/env \011"); waitOutput(out, "\u0005/env -\n" + diff --git a/langtools/test/jdk/jshell/ToolBasicTest.java b/langtools/test/jdk/jshell/ToolBasicTest.java index 93321fb58e8..be5bce056c8 100644 --- a/langtools/test/jdk/jshell/ToolBasicTest.java +++ b/langtools/test/jdk/jshell/ToolBasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714 8166649 8167643 8170162 8172102 8165405 8174796 8174797 8175304 + * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714 8166649 8167643 8170162 8172102 8165405 8174796 8174797 8175304 8167554 8180508 * @summary Tests for Basic tests for REPL tool * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -190,8 +190,8 @@ public class ToolBasicTest extends ReplToolTesting { public void testRerun() { test(false, new String[] {"--no-startup"}, - (a) -> assertCommand(a, "/0", "| No such command or snippet id: /0\n| Type /help for help."), - (a) -> assertCommand(a, "/5", "| No such command or snippet id: /5\n| Type /help for help.") + (a) -> assertCommand(a, "/0", "| No snippet with id: 0"), + (a) -> assertCommand(a, "/5", "| No snippet with id: 5") ); String[] codes = new String[] { "int a = 0;", // var @@ -252,9 +252,9 @@ public class ToolBasicTest extends ReplToolTesting { ); test(false, new String[] {"--no-startup"}, - (a) -> assertCommand(a, "/s1", "| No such command or snippet id: /s1\n| Type /help for help."), - (a) -> assertCommand(a, "/1", "| No such command or snippet id: /1\n| Type /help for help."), - (a) -> assertCommand(a, "/e1", "| No such command or snippet id: /e1\n| Type /help for help.") + (a) -> assertCommand(a, "/s1", "| No snippet with id: s1"), + (a) -> assertCommand(a, "/1", "| No snippet with id: 1"), + (a) -> assertCommand(a, "/e1", "| No snippet with id: e1") ); } @@ -481,17 +481,19 @@ public class ToolBasicTest extends ReplToolTesting { public void testSave() throws IOException { Compiler compiler = new Compiler(); Path path = compiler.getPath("testSave.repl"); - List list = Arrays.asList( - "int a;", - "class A { public String toString() { return \"A\"; } }" - ); - test( - (a) -> assertVariable(a, "int", "a"), - (a) -> assertCommand(a, "()", null, null, null, "", ""), - (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"), - (a) -> assertCommand(a, "/save " + path.toString(), "") - ); - assertEquals(Files.readAllLines(path), list); + { + List list = Arrays.asList( + "int a;", + "class A { public String toString() { return \"A\"; } }" + ); + test( + (a) -> assertVariable(a, "int", "a"), + (a) -> assertCommand(a, "()", null, null, null, "", ""), + (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"), + (a) -> assertCommand(a, "/save " + path.toString(), "") + ); + assertEquals(Files.readAllLines(path), list); + } { List output = new ArrayList<>(); test( @@ -499,28 +501,47 @@ public class ToolBasicTest extends ReplToolTesting { (a) -> assertCommand(a, "()", null, null, null, "", ""), (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"), (a) -> assertCommandCheckOutput(a, "/list -all", (out) -> - output.addAll(Stream.of(out.split("\n")) - .filter(str -> !str.isEmpty()) - .map(str -> str.substring(str.indexOf(':') + 2)) - .filter(str -> !str.startsWith("/")) - .collect(Collectors.toList()))), + output.addAll(Stream.of(out.split("\n")) + .filter(str -> !str.isEmpty()) + .map(str -> str.substring(str.indexOf(':') + 2)) + .filter(str -> !str.startsWith("/")) + .collect(Collectors.toList()))), (a) -> assertCommand(a, "/save -all " + path.toString(), "") ); assertEquals(Files.readAllLines(path), output); } - List output = new ArrayList<>(); - test( - (a) -> assertVariable(a, "int", "a"), - (a) -> assertCommand(a, "()", null, null, null, "", ""), - (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"), - (a) -> assertCommandCheckOutput(a, "/history", (out) -> - output.addAll(Stream.of(out.split("\n")) - .filter(str -> !str.isEmpty()) - .collect(Collectors.toList()))), - (a) -> assertCommand(a, "/save -history " + path.toString(), "") - ); - output.add("/save -history " + path.toString()); - assertEquals(Files.readAllLines(path), output); + { + List output = new ArrayList<>(); + test( + (a) -> assertCommand(a, "int a;", null), + (a) -> assertCommand(a, "int b;", null), + (a) -> assertCommand(a, "int c;", null), + (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"), + (a) -> assertCommandCheckOutput(a, "/list b c a A", (out) -> + output.addAll(Stream.of(out.split("\n")) + .filter(str -> !str.isEmpty()) + .map(str -> str.substring(str.indexOf(':') + 2)) + .filter(str -> !str.startsWith("/")) + .collect(Collectors.toList()))), + (a) -> assertCommand(a, "/save 2-3 1 4 " + path.toString(), "") + ); + assertEquals(Files.readAllLines(path), output); + } + { + List output = new ArrayList<>(); + test( + (a) -> assertVariable(a, "int", "a"), + (a) -> assertCommand(a, "()", null, null, null, "", ""), + (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"), + (a) -> assertCommandCheckOutput(a, "/history", (out) -> + output.addAll(Stream.of(out.split("\n")) + .filter(str -> !str.isEmpty()) + .collect(Collectors.toList()))), + (a) -> assertCommand(a, "/save -history " + path.toString(), "") + ); + output.add("/save -history " + path.toString()); + assertEquals(Files.readAllLines(path), output); + } } public void testStartRetain() { @@ -652,6 +673,64 @@ public class ToolBasicTest extends ReplToolTesting { ); } + public void testRerunIdRange() { + Compiler compiler = new Compiler(); + Path startup = compiler.getPath("rangeStartup"); + String[] startupSources = new String[] { + "boolean go = false", + "void println(String s) { if (go) System.out.println(s); }", + "void println(int i) { if (go) System.out.println(i); }", + "println(\"s4\")", + "println(\"s5\")", + "println(\"s6\")" + }; + String[] sources = new String[] { + "frog", + "go = true", + "println(2)", + "println(3)", + "println(4)", + "querty" + }; + compiler.writeToFile(startup, startupSources); + test(false, new String[]{"--startup", startup.toString()}, + a -> assertCommandOutputStartsWith(a, sources[0], "| Error:"), + a -> assertCommand(a, sources[1], "go ==> true", "", null, "", ""), + a -> assertCommand(a, sources[2], "", "", null, "2\n", ""), + a -> assertCommand(a, sources[3], "", "", null, "3\n", ""), + a -> assertCommand(a, sources[4], "", "", null, "4\n", ""), + a -> assertCommandOutputStartsWith(a, sources[5], "| Error:"), + a -> assertCommand(a, "/3", "println(3)", "", null, "3\n", ""), + a -> assertCommand(a, "/s4", "println(\"s4\")", "", null, "s4\n", ""), + a -> assertCommandOutputStartsWith(a, "/e1", "frog\n| Error:"), + a -> assertCommand(a, "/2-4", + "println(2)\nprintln(3)\nprintln(4)", + "", null, "2\n3\n4\n", ""), + a -> assertCommand(a, "/s4-s6", + startupSources[3] + "\n" +startupSources[4] + "\n" +startupSources[5], + "", null, "s4\ns5\ns6\n", ""), + a -> assertCommand(a, "/s4-4", null, + "", null, "s4\ns5\ns6\n2\n3\n4\n", ""), + a -> assertCommandCheckOutput(a, "/e1-e2", + s -> { + assertTrue(s.trim().startsWith("frog\n| Error:"), + "Output: \'" + s + "' does not start with: " + "| Error:"); + assertTrue(s.trim().lastIndexOf("| Error:") > 10, + "Output: \'" + s + "' does not have second: " + "| Error:"); + }), + a -> assertCommand(a, "/4 s4 2", + "println(4)\nprintln(\"s4\")\nprintln(2)", + "", null, "4\ns4\n2\n", ""), + a -> assertCommand(a, "/s5 2-4 3", + "println(\"s5\")\nprintln(2)\nprintln(3)\nprintln(4)\nprintln(3)", + "", null, "s5\n2\n3\n4\n3\n", ""), + a -> assertCommand(a, "/2 ff", "| No such snippet: ff"), + a -> assertCommand(a, "/4-2", "| End of snippet range less than start: 4 - 2"), + a -> assertCommand(a, "/s5-s3", "| End of snippet range less than start: s5 - s3"), + a -> assertCommand(a, "/4-s5", "| End of snippet range less than start: 4 - s5") + ); + } + @Test(enabled = false) // TODO 8158197 public void testHeadlessEditPad() { String prevHeadless = System.getProperty("java.awt.headless"); diff --git a/langtools/test/jdk/jshell/ToolLocaleMessageTest.java b/langtools/test/jdk/jshell/ToolLocaleMessageTest.java index dc45091a0c0..6111320f1af 100644 --- a/langtools/test/jdk/jshell/ToolLocaleMessageTest.java +++ b/langtools/test/jdk/jshell/ToolLocaleMessageTest.java @@ -117,7 +117,6 @@ public class ToolLocaleMessageTest extends ReplToolTesting { (a) -> assertCommandFail(a, "/drop rats"), (a) -> assertCommandOK(a, "void dup() {}"), (a) -> assertCommandOK(a, "int dup"), - (a) -> assertCommandFail(a, "/drop dup"), (a) -> assertCommandFail(a, "/edit zebra", "zebra"), (a) -> assertCommandFail(a, "/list zebra", "zebra", "No such snippet: zebra"), (a) -> assertCommandFail(a, "/open", "/open"), diff --git a/langtools/test/jdk/jshell/ToolSimpleTest.java b/langtools/test/jdk/jshell/ToolSimpleTest.java index 909318aaeff..647d0fdafcc 100644 --- a/langtools/test/jdk/jshell/ToolSimpleTest.java +++ b/langtools/test/jdk/jshell/ToolSimpleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079 + * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079 8180508 * @summary Simple jshell tool tests * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.function.Consumer; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -202,7 +203,7 @@ public class ToolSimpleTest extends ReplToolTesting { @Test public void testUnknownCommand() { test((a) -> assertCommand(a, "/unknown", - "| No such command or snippet id: /unknown\n" + + "| Invalid command: /unknown\n" + "| Type /help for help.")); } @@ -274,10 +275,26 @@ public class ToolSimpleTest extends ReplToolTesting { ); } + @Test + public void testDropRange() { + test(false, new String[]{"--no-startup"}, + a -> assertVariable(a, "int", "a"), + a -> assertMethod(a, "int b() { return 0; }", "()int", "b"), + a -> assertClass(a, "class A {}", "class", "A"), + a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"), + a -> assertCommand(a, "for (int i = 0; i < 10; ++i) {}", ""), + a -> assertCommand(a, "/drop 3-5 b 1", + "| dropped class A\n" + + "| dropped method b()\n" + + "| dropped variable a\n"), + a -> assertCommand(a, "/list", "") + ); + } + @Test public void testDropNegative() { test(false, new String[]{"--no-startup"}, - a -> assertCommandOutputStartsWith(a, "/drop 0", "| No such snippet: 0"), + a -> assertCommandOutputStartsWith(a, "/drop 0", "| No snippet with id: 0"), a -> assertCommandOutputStartsWith(a, "/drop a", "| No such snippet: a"), a -> assertCommandCheckOutput(a, "/drop", assertStartsWith("| In the /drop argument, please specify an import, variable, method, or class to drop.")), @@ -292,27 +309,23 @@ public class ToolSimpleTest extends ReplToolTesting { @Test public void testAmbiguousDrop() { - Consumer check = s -> { - assertTrue(s.startsWith("| The argument references more than one import, variable, method, or class"), s); - int lines = s.split("\n").length; - assertEquals(lines, 5, "Expected 3 ambiguous keys, but found: " + (lines - 2) + "\n" + s); - }; test( a -> assertVariable(a, "int", "a"), a -> assertMethod(a, "int a() { return 0; }", "()int", "a"), a -> assertClass(a, "class a {}", "class", "a"), - a -> assertCommandCheckOutput(a, "/drop a", check), - a -> assertCommandCheckOutput(a, "/vars", assertVariables()), - a -> assertCommandCheckOutput(a, "/methods", assertMethods()), - a -> assertCommandCheckOutput(a, "/types", assertClasses()), - a -> assertCommandCheckOutput(a, "/imports", assertImports()) + a -> assertCommand(a, "/drop a", + "| dropped variable a\n" + + "| dropped method a()\n" + + "| dropped class a") ); test( a -> assertMethod(a, "int a() { return 0; }", "()int", "a"), a -> assertMethod(a, "double a(int a) { return 0; }", "(int)double", "a"), a -> assertMethod(a, "double a(double a) { return 0; }", "(double)double", "a"), - a -> assertCommandCheckOutput(a, "/drop a", check), - a -> assertCommandCheckOutput(a, "/methods", assertMethods()) + a -> assertCommand(a, "/drop a", + "| dropped method a()\n" + + "| dropped method a(int)\n" + + "| dropped method a(double)\n") ); } @@ -402,12 +415,14 @@ public class ToolSimpleTest extends ReplToolTesting { String arg = "qqqq"; List startVarList = new ArrayList<>(START_UP); startVarList.add("int aardvark"); + startVarList.add("int weevil"); test( a -> assertCommandCheckOutput(a, "/list -all", s -> checkLineToList(s, START_UP)), a -> assertCommandOutputStartsWith(a, "/list " + arg, "| No such snippet: " + arg), a -> assertVariable(a, "int", "aardvark"), + a -> assertVariable(a, "int", "weevil"), a -> assertCommandOutputContains(a, "/list aardvark", "aardvark"), a -> assertCommandCheckOutput(a, "/list -start", s -> checkLineToList(s, START_UP)), @@ -415,6 +430,11 @@ public class ToolSimpleTest extends ReplToolTesting { s -> checkLineToList(s, startVarList)), a -> assertCommandOutputStartsWith(a, "/list s3", "s3 : import"), + a -> assertCommandCheckOutput(a, "/list 1-2 s3", + s -> { + assertTrue(Pattern.matches(".*aardvark.*\\R.*weevil.*\\R.*s3.*import.*", s.trim()), + "No match: " + s); + }), a -> assertCommandOutputStartsWith(a, "/list " + arg, "| No such snippet: " + arg) ); @@ -439,6 +459,8 @@ public class ToolSimpleTest extends ReplToolTesting { s -> checkLineToList(s, startVarList)), a -> assertCommandOutputStartsWith(a, "/vars -all", "| int aardvark = 0\n| int a = "), + a -> assertCommandOutputStartsWith(a, "/vars 1-4", + "| int aardvark = 0\n| int a = "), a -> assertCommandOutputStartsWith(a, "/vars f", "| This command does not accept the snippet 'f'"), a -> assertCommand(a, "/var " + arg, From 3bb25bd637963e1fff721e77d3b17f81bdfdbd10 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Thu, 18 May 2017 15:43:43 -0700 Subject: [PATCH 36/66] 8180391: move SerializationUtils to top level testlibrary Reviewed-by: psandoz --- .../jdk/test/lib/util/SerializationUtils.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test/lib/jdk/test/lib/util/SerializationUtils.java diff --git a/test/lib/jdk/test/lib/util/SerializationUtils.java b/test/lib/jdk/test/lib/util/SerializationUtils.java new file mode 100644 index 00000000000..3b6e65aefd7 --- /dev/null +++ b/test/lib/jdk/test/lib/util/SerializationUtils.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +/** + * Common library for various test serialization utility functions. + */ +public final class SerializationUtils { + /** + * Serialize an object into byte array. + */ + public static byte[] serialize(Object obj) throws IOException { + ByteArrayOutputStream bs = new ByteArrayOutputStream(); + try (ObjectOutputStream out = new ObjectOutputStream(bs)) { + out.writeObject(obj); + } + return bs.toByteArray(); + } + + /** + * Deserialize an object from byte array. + */ + public static Object deserialize(byte[] ba) throws IOException, ClassNotFoundException { + try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(ba))) { + return in.readObject(); + } + } + private SerializationUtils() {} +} From 834902117a211fd96b4f2f0e7bee6ae16d750717 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Fri, 19 May 2017 13:33:17 -0700 Subject: [PATCH 37/66] 8180644: move jdk.testlibrary.NetworkConfiguration to the top level test library Reviewed-by: psandoz --- .../jdk/test/lib/NetworkConfiguration.java | 272 ++++++++++++++++++ 1 file changed, 272 insertions(+) create mode 100644 test/lib/jdk/test/lib/NetworkConfiguration.java diff --git a/test/lib/jdk/test/lib/NetworkConfiguration.java b/test/lib/jdk/test/lib/NetworkConfiguration.java new file mode 100644 index 00000000000..b8a4720643a --- /dev/null +++ b/test/lib/jdk/test/lib/NetworkConfiguration.java @@ -0,0 +1,272 @@ +/* + * 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; + +import java.io.PrintStream; +import java.io.UncheckedIOException; +import java.io.IOException; +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import static java.net.NetworkInterface.getNetworkInterfaces; +import static java.util.Collections.list; + +/** + * Helper class for retrieving network interfaces and local addresses + * suitable for testing. + */ +public class NetworkConfiguration { + + private Map> ip4Interfaces; + private Map> ip6Interfaces; + + private NetworkConfiguration( + Map> ip4Interfaces, + Map> ip6Interfaces) { + this.ip4Interfaces = ip4Interfaces; + this.ip6Interfaces = ip6Interfaces; + } + + /** + * Returns a stream of interfaces suitable for functional tests. + */ + public Stream interfaces() { + return Stream.concat(ip4Interfaces(), ip6Interfaces()) + .distinct(); + } + + /** + * Returns a stream of interfaces suitable for IPv4 functional tests. + */ + public Stream ip4Interfaces() { + return ip4Interfaces.keySet() + .stream() + .filter(NetworkConfiguration::isNotExcludedInterface) + .filter(hasIp4Addresses); + } + + /** + * Returns a stream of interfaces suitable for IPv6 functional tests. + */ + public Stream ip6Interfaces() { + return ip6Interfaces.keySet() + .stream() + .filter(NetworkConfiguration::isNotExcludedInterface) + .filter(hasIp6Addresses); + } + + private static boolean isNotExcludedInterface(NetworkInterface nif) { + if (Platform.isOSX() && nif.getName().contains("awdl")) { + return false; + } + String dName = nif.getDisplayName(); + if (Platform.isWindows() && dName != null && dName.contains("Teredo")) { + return false; + } + return true; + } + + private final Predicate hasIp4Addresses = nif -> + ip4Interfaces.get(nif).stream().anyMatch(a -> !a.isAnyLocalAddress()); + + private final Predicate hasIp6Addresses = nif -> + ip6Interfaces.get(nif).stream().anyMatch(a -> !a.isAnyLocalAddress()); + + + /** + * Returns a stream of interfaces suitable for IPv4 multicast tests. + */ + public Stream ip4MulticastInterfaces() { + return ip4Interfaces().filter(supportsIp4Multicast); + } + + /** + * Returns a stream of interfaces suitable for IPv6 multicast tests. + */ + public Stream ip6MulticastInterfaces() { + return ip6Interfaces().filter(supportsIp6Multicast); + } + + private final Predicate supportsIp4Multicast = nif -> { + try { + if (!nif.supportsMulticast() || nif.isLoopback()) { + return false; + } + return hasIp4Addresses.test(nif); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }; + + private final Predicate supportsIp6Multicast = nif -> { + try { + if (!nif.supportsMulticast() || nif.isLoopback()) { + return false; + } + + return hasIp6Addresses.test(nif); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }; + + /** + * Returns all addresses on all "functional" interfaces. + */ + public Stream addresses(NetworkInterface nif) { + return Stream.concat(ip4Interfaces.get(nif).stream(), + ip6Interfaces.get(nif).stream()); + } + + /** + * Returns all IPv4 addresses on all "functional" interfaces. + */ + public Stream ip4Addresses() { + return ip4Interfaces().flatMap(this::ip4Addresses); + } + + /** + * Returns all IPv6 addresses on all "functional" interfaces. + */ + public Stream ip6Addresses() { + return ip6Interfaces().flatMap(this::ip6Addresses); + } + + /** + * Returns all IPv4 addresses the given interface. + */ + public Stream ip4Addresses(NetworkInterface nif) { + return ip4Interfaces.get(nif).stream(); + } + + /** + * Returns all IPv6 addresses for the given interface. + */ + public Stream ip6Addresses(NetworkInterface nif) { + return ip6Interfaces.get(nif).stream(); + } + + /** + * Return a NetworkConfiguration instance. + */ + public static NetworkConfiguration probe() throws IOException { + Map> ip4Interfaces = new HashMap<>(); + Map> ip6Interfaces = new HashMap<>(); + + List nifs = list(getNetworkInterfaces()); + for (NetworkInterface nif : nifs) { + // ignore interfaces that are down + if (!nif.isUp() || nif.isPointToPoint()) { + continue; + } + + List ip4Addresses = new LinkedList<>(); + List ip6Addresses = new LinkedList<>(); + ip4Interfaces.put(nif, ip4Addresses); + ip6Interfaces.put(nif, ip6Addresses); + for (InetAddress addr : list(nif.getInetAddresses())) { + if (addr instanceof Inet4Address) { + ip4Addresses.add((Inet4Address) addr); + } else if (addr instanceof Inet6Address) { + ip6Addresses.add((Inet6Address) addr); + } + } + } + return new NetworkConfiguration(ip4Interfaces, ip6Interfaces); + } + + @Override + public String toString() { + return interfaces().map(NetworkConfiguration::interfaceInformation) + .collect(Collectors.joining()); + } + + /** Returns detailed information for the given interface. */ + public static String interfaceInformation(NetworkInterface nif) { + StringBuilder sb = new StringBuilder(); + try { + sb.append("Display name: ") + .append(nif.getDisplayName()) + .append("\n"); + sb.append("Name: ") + .append(nif.getName()) + .append("\n"); + for (InetAddress inetAddress : list(nif.getInetAddresses())) { + sb.append("InetAddress: ") + .append(inetAddress) + .append("\n"); + } + sb.append("Up? ") + .append(nif.isUp()) + .append("\n"); + sb.append("Loopback? ") + .append(nif.isLoopback()) + .append("\n"); + sb.append("PointToPoint? ") + .append(nif.isPointToPoint()) + .append("\n"); + sb.append("Supports multicast? ") + .append(nif.supportsMulticast()) + .append("\n"); + sb.append("Virtual? ") + .append(nif.isVirtual()) + .append("\n"); + sb.append("Hardware address: ") + .append(Arrays.toString(nif.getHardwareAddress())) + .append("\n"); + sb.append("MTU: ") + .append(nif.getMTU()) + .append("\n"); + sb.append("Index: ") + .append(nif.getIndex()) + .append("\n"); + sb.append("\n"); + return sb.toString(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + /** Prints all the system interface information to the give stream. */ + public static void printSystemConfiguration(PrintStream out) { + try { + out.println("*** all system network interface configuration ***"); + for (NetworkInterface nif : list(getNetworkInterfaces())) { + out.print(interfaceInformation(nif)); + } + out.println("*** end ***"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } +} From 095e01f97067d10d107150ca11240ce4b00aea42 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 22 May 2017 15:50:09 +0200 Subject: [PATCH 38/66] 8180745: Add --release 10 as an alias for --release 9 Reviewed-by: mcimadamore --- .../com/sun/tools/javac/platform/JDKPlatformProvider.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java index 9cfb2eb8ddb..3ece0dd65f8 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java @@ -66,7 +66,7 @@ public class JDKPlatformProvider implements PlatformProvider { @Override public PlatformDescription getPlatform(String platformName, String options) { - return new PlatformDescriptionImpl(platformName); + return new PlatformDescriptionImpl(platformName.equals("10") ? "9" : platformName); } private static final String[] symbolFileLocation = { "lib", "ct.sym" }; @@ -93,6 +93,10 @@ public class JDKPlatformProvider implements PlatformProvider { } catch (IOException | ProviderNotFoundException ex) { } } + + if (SUPPORTED_JAVA_PLATFORM_VERSIONS.contains("9")) { + SUPPORTED_JAVA_PLATFORM_VERSIONS.add("10"); + } } private static String targetNumericVersion(Target target) { From b8f2a6edadf32f268dd4299df83e26076aa64cdc Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Mon, 22 May 2017 09:44:14 -0700 Subject: [PATCH 39/66] 8180720: method InferenceGraph.initNodes() can potentially add a trivial dependency of a node to itself Reviewed-by: mcimadamore --- .../share/classes/com/sun/tools/javac/comp/Infer.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java index a5cab459056..641283ab427 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java @@ -1889,10 +1889,13 @@ public class Infer { Type i = n_i.data.first(); for (Node n_j : nodes) { Type j = n_j.data.first(); - UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i); - if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) { - //update i's bound dependencies - n_i.addDependency(n_j); + // don't compare a variable to itself + if (i != j) { + UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i); + if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) { + //update i's bound dependencies + n_i.addDependency(n_j); + } } } } From 32e18391c5cc2adc1893812138233a7a3574adb9 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Mon, 22 May 2017 12:49:05 -0700 Subject: [PATCH 40/66] 8180660: missing LNT entry for finally block Co-authored-by: Maurizio Cimadamore Reviewed-by: mcimadamore, vromero --- .../classes/com/sun/tools/javac/jvm/Gen.java | 9 +- .../com/sun/tools/javac/tree/TreeInfo.java | 24 ++- .../InlinedFinallyConfuseDebuggersTest.java | 3 +- .../MissingLNTEntryForFinalizerTest.java | 180 ++++++++++++++++++ .../linenumbers/FinallyLineNumberTest.java | 15 +- 5 files changed, 220 insertions(+), 11 deletions(-) create mode 100644 langtools/test/tools/javac/T8180660/MissingLNTEntryForFinalizerTest.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java index 4d5af67f195..c8a63a2cc74 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -25,6 +25,7 @@ package com.sun.tools.javac.jvm; +import com.sun.tools.javac.tree.TreeInfo.PosKind; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.List; @@ -1399,12 +1400,16 @@ public class Gen extends JCTree.Visitor { catchallpc, 0); startseg = env.info.gaps.next().intValue(); } - code.statBegin(TreeInfo.finalizerPos(env.tree)); + code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.FIRST_STAT_POS)); code.markStatBegin(); Item excVar = makeTemp(syms.throwableType); excVar.store(); genFinalizer(env); + code.resolvePending(); + code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.END_POS)); + code.markStatBegin(); + excVar.load(); registerCatch(body.pos(), startseg, env.info.gaps.next().intValue(), @@ -1418,7 +1423,7 @@ public class Gen extends JCTree.Visitor { code.resolve(env.info.cont); // Mark statement line number - code.statBegin(TreeInfo.finalizerPos(env.tree)); + code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.FIRST_STAT_POS)); code.markStatBegin(); // Save return address. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java index b0f430b0862..1796c4dd890 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -46,6 +46,8 @@ import static com.sun.tools.javac.tree.JCTree.Tag.SYNCHRONIZED; import javax.tools.JavaFileObject; +import java.util.function.ToIntFunction; + import static com.sun.tools.javac.tree.JCTree.JCOperatorExpression.OperandPos.LEFT; import static com.sun.tools.javac.tree.JCTree.JCOperatorExpression.OperandPos.RIGHT; @@ -580,13 +582,29 @@ public class TreeInfo { }; } + public enum PosKind { + START_POS(TreeInfo::getStartPos), + FIRST_STAT_POS(TreeInfo::firstStatPos), + END_POS(TreeInfo::endPos); + + final ToIntFunction posFunc; + + PosKind(ToIntFunction posFunc) { + this.posFunc = posFunc; + } + + int toPos(JCTree tree) { + return posFunc.applyAsInt(tree); + } + } + /** The position of the finalizer of given try/synchronized statement. */ - public static int finalizerPos(JCTree tree) { + public static int finalizerPos(JCTree tree, PosKind posKind) { if (tree.hasTag(TRY)) { JCTry t = (JCTry) tree; Assert.checkNonNull(t.finalizer); - return firstStatPos(t.finalizer); + return posKind.toPos(t.finalizer); } else if (tree.hasTag(SYNCHRONIZED)) { return endPos(((JCSynchronized) tree).body); } else { diff --git a/langtools/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java b/langtools/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java index 9edfb58cc38..721e9f72002 100644 --- a/langtools/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java +++ b/langtools/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -72,6 +72,7 @@ public class InlinedFinallyConfuseDebuggersTest { {9, 21}, //System.out.println("finally"); {10, 29}, {9, 32}, //System.out.println("finally"); + {10, 41}, //} {11, 43}, }; diff --git a/langtools/test/tools/javac/T8180660/MissingLNTEntryForFinalizerTest.java b/langtools/test/tools/javac/T8180660/MissingLNTEntryForFinalizerTest.java new file mode 100644 index 00000000000..49e4026fd07 --- /dev/null +++ b/langtools/test/tools/javac/T8180660/MissingLNTEntryForFinalizerTest.java @@ -0,0 +1,180 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8180141 + * @summary Missing entry in LineNumberTable for break statement that jumps out of try-finally + * @modules jdk.jdeps/com.sun.tools.classfile + * jdk.compiler/com.sun.tools.javac.code + * jdk.compiler/com.sun.tools.javac.comp + * jdk.compiler/com.sun.tools.javac.file + * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.tree + * jdk.compiler/com.sun.tools.javac.util + * @compile -g MissingLNTEntryForFinalizerTest.java + * @run main MissingLNTEntryForFinalizerTest + */ + +import java.io.File; +import java.net.URI; + +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; + +import com.sun.tools.classfile.*; +import com.sun.tools.javac.comp.Attr; +import com.sun.tools.javac.comp.AttrContext; +import com.sun.tools.javac.comp.Env; +import com.sun.tools.javac.comp.Modules; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.main.JavaCompiler; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.*; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.List; + +import static com.sun.tools.javac.util.List.of; +import static com.sun.tools.javac.tree.JCTree.Tag.*; + +public class MissingLNTEntryForFinalizerTest { + protected ReusableJavaCompiler tool; + Context context; + + MissingLNTEntryForFinalizerTest() { + context = new Context(); + JavacFileManager.preRegister(context); + MyAttr.preRegister(context); + tool = new ReusableJavaCompiler(context); + } + + public static void main(String... args) throws Throwable { + new MissingLNTEntryForFinalizerTest().test(); + } + + void test() throws Throwable { + JavaSource source = new JavaSource("1"); + tool.clear(); + List inputs = of(source); + try { + tool.compile(inputs); + } catch (Throwable ex) { + throw new AssertionError(ex); + } + File testClasses = new File("."); + File file = new File(testClasses, "Test1.class"); + ClassFile classFile = ClassFile.read(file); + for (Method m : classFile.methods) { + if (classFile.constant_pool.getUTF8Value(m.name_index).equals("foo")) { + Code_attribute code = (Code_attribute)m.attributes.get(Attribute.Code); + LineNumberTable_attribute lnt = (LineNumberTable_attribute)code.attributes.get(Attribute.LineNumberTable); + checkLNT(lnt, MyAttr.lineNumber); + } + } + } + + void checkLNT(LineNumberTable_attribute lnt, int lineToCheckFor) { + for (LineNumberTable_attribute.Entry e: lnt.line_number_table) { + if (e.line_number == lineToCheckFor) { + return; + } + } + throw new AssertionError("seek line number not found in the LNT for method foo()"); + } + + class JavaSource extends SimpleJavaFileObject { + String id; + String template = + "import java.util.*;\n" + + "class Test#Id {\n" + + " void foo() {\n" + + " List l = null;\n" + + " String first = null;\n" + + " try {\n" + + " first = l.get(0);\n" + + " } finally {\n" + + " if (first != null) {\n" + + " System.out.println(\"finalizer\");\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; + + JavaSource(String id) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + this.id = id; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return template.replace("#Id", id); + } + } + + /* this class has been set up to do not depend on a fixed line number, this Attr subclass will + * look for 'break' or 'continue' statements in order to find the actual line number they occupy. + * This way the test can find if that line number appears in the LNT generated for a given class. + */ + static class MyAttr extends Attr { + static int lineNumber; + + static void preRegister(Context context) { + context.put(attrKey, (com.sun.tools.javac.util.Context.Factory) c -> new MyAttr(c)); + } + + MyAttr(Context context) { + super(context); + } + + @Override + public com.sun.tools.javac.code.Type attribStat(JCTree tree, Env env) { + com.sun.tools.javac.code.Type result = super.attribStat(tree, env); + if (tree.hasTag(TRY)) { + JCTry tryTree = (JCTry)tree; + lineNumber = env.toplevel.lineMap.getLineNumber(tryTree.finalizer.endpos); + } + return result; + } + } + + static class ReusableJavaCompiler extends JavaCompiler { + ReusableJavaCompiler(Context context) { + super(context); + } + + @Override + protected void checkReusable() { + // do nothing + } + + @Override + public void close() { + //do nothing + } + + void clear() { + newRound(); + Modules.instance(context).newRound(); + } + } +} diff --git a/langtools/test/tools/javac/linenumbers/FinallyLineNumberTest.java b/langtools/test/tools/javac/linenumbers/FinallyLineNumberTest.java index 892d36589b2..51946f63884 100644 --- a/langtools/test/tools/javac/linenumbers/FinallyLineNumberTest.java +++ b/langtools/test/tools/javac/linenumbers/FinallyLineNumberTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -36,7 +36,6 @@ import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.LineNumberTable_attribute; import com.sun.tools.classfile.LineNumberTable_attribute.Entry; -import java.io.File; import java.io.IOException; public class FinallyLineNumberTest { @@ -46,13 +45,13 @@ public class FinallyLineNumberTest { if (lines == null) { throw new Exception("finally line number table could not be loaded"); } - if (lines.length != 4) { + if (lines.length != 5) { // Help debug System.err.println("LineTable error, got lines:"); for (Entry e : lines) { System.err.println(e.line_number); } - throw new Exception("finally line number table incorrect: length=" + lines.length + " expected length=4"); + throw new Exception("finally line number table incorrect: length=" + lines.length + " expected length=5"); } // return null line, for the load null operation @@ -71,11 +70,17 @@ public class FinallyLineNumberTest { throw new Exception("finally line number table incorrect: got=" + current + " expected=" + first); } - // finally line, for when exception is thrown + // for when exception is thrown current = lines[3].line_number; if (current != first + 2) { throw new Exception("finally line number table incorrect: got=" + current + " expected=" + (first + 2)); } + + // the '}' closing the finally block + current = lines[4].line_number; + if (current != first + 3) { + throw new Exception("finally line number table incorrect: got=" + current + " expected=" + (first + 3)); + } } static Entry[] findEntries() throws IOException, ConstantPoolException { From d0b55c146f13c726cd909c46b50d51c9530aa5d8 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 21:11:26 +0000 Subject: [PATCH 41/66] Added tag jdk-10+7 for changeset e1b5a6c45d39 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index db39fa4e9d3..f2260b02f55 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -421,3 +421,4 @@ ba5b16c9c6d80632b61959a33d424b1c3398ce62 jdk-9+166 b25838a28195f4b6dab34668411eedd2d366a16c jdk-9+169 4d163ec59d989a9261ed7f848bc6303f90869af5 jdk-9+170 +aa3c97810d7c484c93a2fd75d3c76ff574deb6d8 jdk-10+7 From c056b9b52a701e279597788ade0680a33162849e Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 21:11:28 +0000 Subject: [PATCH 42/66] Added tag jdk-10+7 for changeset 6647a4cd5d00 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 673fe9bd8b6..c68c8cae98e 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -420,3 +420,4 @@ f260f1a2acf616509a4ee5a29bc7f2acca3853e3 jdk-9+167 bc21e5ba6bf1538551093f57fa0f1a6571be05cc jdk-9+168 0e522ff8b9f52a9d4929af9a6aa84110f4dcd81d jdk-9+169 18355c879c69a33167f1862896738a7b9a4da729 jdk-9+170 +85581ae8a97f20fd2f817a71eb3cd7b04e492722 jdk-10+7 From 19e83876e2efb5fa637bbc5ac05d1a88c84f2872 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 21:11:30 +0000 Subject: [PATCH 43/66] Added tag jdk-10+7 for changeset 9d896ba4a48b --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index d0c9ec26ac2..96d37c2dd66 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -423,3 +423,4 @@ ac7e572a6a6ba5bbd7e6aa94a289f88cc86256a4 jdk-10+4 2746716dcc5a8c28ccf41df0c8fb620b1a1e7098 jdk-9+168 912cf69806d518c5af7fba30b340c4cb5458dd22 jdk-9+169 e75d3abe579a7b39b762fc0a1a337c49eb072d82 jdk-9+170 +b0efae7df1dfa14926058baebaf999e4268c955c jdk-10+7 From f4f9fbcbd0cba598b9554e9dc0f562b8e42c15c7 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 21:11:34 +0000 Subject: [PATCH 44/66] Added tag jdk-10+7 for changeset 7546d531a619 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 088b9c458bc..32f11f47464 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -411,3 +411,4 @@ e118c818dbf84d15191414c453b77c089116fdc0 jdk-9+167 0f81cde5a1f75786f381dbfb59b9afbab70174c7 jdk-9+168 131e250080158e57ce45130560f5f987b92642b5 jdk-9+169 550bfc15779f8f339610793867fdc251125811b5 jdk-9+170 +7e9cb37e6d6edbe56fdf4d510e5110f797823f09 jdk-10+7 From 1a6fd96373cc6a7efc4d257773adeabd5ca0cbe2 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 21:11:37 +0000 Subject: [PATCH 45/66] Added tag jdk-10+7 for changeset 0eb9c6043275 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 1c7733efb46..e11a16947ee 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -420,3 +420,4 @@ ac697b2bdf486ef18caad2092bd24036e14946ac jdk-10+5 23a87f409371fb8ce7b764cccb3a74c3f6b29900 jdk-9+168 5d9d2a65fb26aa183019346c11d9314819621665 jdk-9+169 6e78f902f477a093afca85a1042f97410d01eb69 jdk-9+170 +09cae4c36242734f5450de739b8264523a030809 jdk-10+7 From 9d19fc55dd89ed8b8ba1a5ab44966de4b5ae1466 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 21:11:42 +0000 Subject: [PATCH 46/66] Added tag jdk-10+7 for changeset d554736d963e --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index bab340cbb49..9179fa6ba7a 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -420,3 +420,4 @@ d1436b2945383cef15edbdba9bb41ef1656c987b jdk-10+5 e78da9db6299b3fcba49300d52e2359e82fdd218 jdk-9+168 177436a54ca13730ffc725a6e5dbfcd9486f3da3 jdk-9+169 ef9954f6896bb0b95ac62bf769f68b59a7a56ccd jdk-9+170 +cbd65760a005766610583949b3b5c9ace92e74b3 jdk-10+7 From 42c08330fb53f9697f8cc8fd94c49a17cfaadcd3 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 21:11:49 +0000 Subject: [PATCH 47/66] Added tag jdk-10+7 for changeset a5c0bfac4b0b --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 8ef690e90f2..cd6f4b43194 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -420,3 +420,4 @@ c7358d703e1282af3dcd8af6c037dc4342de9054 jdk-10+6 03a2cc9c8a1e8f87924c9863e917bc8b91770d5f jdk-9+168 b2218d41edef02ee8f94bb438f885b2ba79bfa08 jdk-9+169 8a4ab3b0ab9a86df73d9a1e337134f2dbe006725 jdk-9+170 +aed5a4edc8275c1c50195503756ff92bfe0197f5 jdk-10+7 From 9f3f2de137d4aaa6899f255b62c40e37ab0505b1 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 21:11:50 +0000 Subject: [PATCH 48/66] Added tag jdk-10+7 for changeset f5053ff33fd4 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 011c2debf81..ea8f7b38c78 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -580,3 +580,4 @@ c92c6416ca03b1464d5ed99cf6201e52b5ba0a70 jdk-9+165 fbb9c802649585d19f6d7e81b4a519d44806225a jdk-9+168 16d692be099c5c38eb48cc9aca78b0c900910d5b jdk-9+169 38a240fd58a287acb1963920b92ed4d9c2fd39e3 jdk-9+170 +9d4746eca95aec3e5a344bf2520745dcc1d17eed jdk-10+7 From 42d34a7cbfff8c6568c56f4e6f100a749ec665a6 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 22:38:54 +0000 Subject: [PATCH 49/66] Added tag jdk-10+8 for changeset d7deaa5e4f97 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index f2260b02f55..bf64ef1712e 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -422,3 +422,4 @@ b25838a28195f4b6dab34668411eedd2d366a16c jdk-9+169 4d163ec59d989a9261ed7f848bc6303f90869af5 jdk-9+170 aa3c97810d7c484c93a2fd75d3c76ff574deb6d8 jdk-10+7 +df33ef1dc163f994177fd97d4d0e73a1e3cb5d85 jdk-10+8 From ab1cd91fde436921970e0c09755f31b9f2ed494d Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 22:38:55 +0000 Subject: [PATCH 50/66] Added tag jdk-10+8 for changeset 53876ff5a88a --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index e11a16947ee..45875ae185d 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -421,3 +421,4 @@ ac697b2bdf486ef18caad2092bd24036e14946ac jdk-10+5 5d9d2a65fb26aa183019346c11d9314819621665 jdk-9+169 6e78f902f477a093afca85a1042f97410d01eb69 jdk-9+170 09cae4c36242734f5450de739b8264523a030809 jdk-10+7 +856998840907b67b7e1fc49259f785ac085a189b jdk-10+8 From eba67fcdfda2f70a21aba3c127d2bf191e191434 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 22:38:56 +0000 Subject: [PATCH 51/66] Added tag jdk-10+8 for changeset 635cc02314e3 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 96d37c2dd66..1e510f647f7 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -424,3 +424,4 @@ ac7e572a6a6ba5bbd7e6aa94a289f88cc86256a4 jdk-10+4 912cf69806d518c5af7fba30b340c4cb5458dd22 jdk-9+169 e75d3abe579a7b39b762fc0a1a337c49eb072d82 jdk-9+170 b0efae7df1dfa14926058baebaf999e4268c955c jdk-10+7 +e705867d9989d00e4357f66f18b302c95e13b5e7 jdk-10+8 From 563c8385cb229adbd747e0de1cd3e8c93e853f9e Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 22:38:58 +0000 Subject: [PATCH 52/66] Added tag jdk-10+8 for changeset 25593a0aff77 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index ea8f7b38c78..368f851bf14 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -581,3 +581,4 @@ fbb9c802649585d19f6d7e81b4a519d44806225a jdk-9+168 16d692be099c5c38eb48cc9aca78b0c900910d5b jdk-9+169 38a240fd58a287acb1963920b92ed4d9c2fd39e3 jdk-9+170 9d4746eca95aec3e5a344bf2520745dcc1d17eed jdk-10+7 +f5ded0cf954c770deeecb80f2ba1ba6a05cd979b jdk-10+8 From 3d61e714f030790b577f85e142477b58849bf998 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 22:39:02 +0000 Subject: [PATCH 53/66] Added tag jdk-10+8 for changeset f0579c053626 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 9179fa6ba7a..3a58536ca86 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -421,3 +421,4 @@ e78da9db6299b3fcba49300d52e2359e82fdd218 jdk-9+168 177436a54ca13730ffc725a6e5dbfcd9486f3da3 jdk-9+169 ef9954f6896bb0b95ac62bf769f68b59a7a56ccd jdk-9+170 cbd65760a005766610583949b3b5c9ace92e74b3 jdk-10+7 +f0adc10ed8316e6cf316e3208c5ecf6835d22bc4 jdk-10+8 From 4b675c65c6b15f656996468eaba231d39da522e6 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 22:39:02 +0000 Subject: [PATCH 54/66] Added tag jdk-10+8 for changeset 38f7f9fa0ac1 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index cd6f4b43194..0fe545af082 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -421,3 +421,4 @@ c7358d703e1282af3dcd8af6c037dc4342de9054 jdk-10+6 b2218d41edef02ee8f94bb438f885b2ba79bfa08 jdk-9+169 8a4ab3b0ab9a86df73d9a1e337134f2dbe006725 jdk-9+170 aed5a4edc8275c1c50195503756ff92bfe0197f5 jdk-10+7 +648b0a00824eb29e71936bc3258d309a25e3b8c0 jdk-10+8 From b3cfbae65da56f9d5e5cbbe9513a4f1549b37aab Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 22:39:06 +0000 Subject: [PATCH 55/66] Added tag jdk-10+8 for changeset a0908e5be3bc --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index c68c8cae98e..3e74be3ac37 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -421,3 +421,4 @@ bc21e5ba6bf1538551093f57fa0f1a6571be05cc jdk-9+168 0e522ff8b9f52a9d4929af9a6aa84110f4dcd81d jdk-9+169 18355c879c69a33167f1862896738a7b9a4da729 jdk-9+170 85581ae8a97f20fd2f817a71eb3cd7b04e492722 jdk-10+7 +6d9a33d72d0647f3981c9d9c636a6f1290689895 jdk-10+8 From a26ee23e2f3c9712dd2ec163547e9a6383635ff7 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Tue, 23 May 2017 22:39:07 +0000 Subject: [PATCH 56/66] Added tag jdk-10+8 for changeset ba5bed4f71d4 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 32f11f47464..ef877223386 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -412,3 +412,4 @@ e118c818dbf84d15191414c453b77c089116fdc0 jdk-9+167 131e250080158e57ce45130560f5f987b92642b5 jdk-9+169 550bfc15779f8f339610793867fdc251125811b5 jdk-9+170 7e9cb37e6d6edbe56fdf4d510e5110f797823f09 jdk-10+7 +edb825e2dfb140c8e57a61b5d45de19edebccccf jdk-10+8 From 72aff46551ff08cfa91005cf8eb1e08a131082d6 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Wed, 24 May 2017 16:11:36 +0000 Subject: [PATCH 57/66] 8180856: Remove RecordType.java Reviewed-by: weijun --- .../classes/sun/security/ssl/RecordType.java | 122 ------------------ 1 file changed, 122 deletions(-) delete mode 100644 jdk/src/java.base/share/classes/sun/security/ssl/RecordType.java diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/RecordType.java b/jdk/src/java.base/share/classes/sun/security/ssl/RecordType.java deleted file mode 100644 index 1468802aeb0..00000000000 --- a/jdk/src/java.base/share/classes/sun/security/ssl/RecordType.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.ssl; - -/* - * enumation of record type - */ -enum RecordType { - - RECORD_CHANGE_CIPHER_SPEC (Record.ct_change_cipher_spec, - HandshakeMessage.ht_not_applicable), - RECORD_ALERT (Record.ct_alert, - HandshakeMessage.ht_not_applicable), - RECORD_HELLO_REQUEST (Record.ct_handshake, - HandshakeMessage.ht_hello_request), - RECORD_CLIENT_HELLO (Record.ct_handshake, - HandshakeMessage.ht_client_hello), - RECORD_SERVER_HELLO (Record.ct_handshake, - HandshakeMessage.ht_server_hello), - RECORD_HELLO_VERIFY_REQUEST (Record.ct_handshake, - HandshakeMessage.ht_hello_verify_request), - RECORD_NEW_SESSION_TICKET (Record.ct_handshake, - HandshakeMessage.ht_new_session_ticket), - RECORD_CERTIFICATE (Record.ct_handshake, - HandshakeMessage.ht_certificate), - RECORD_SERVER_KEY_EXCHANGE (Record.ct_handshake, - HandshakeMessage.ht_server_key_exchange), - RECORD_CERTIFICATE_REQUEST (Record.ct_handshake, - HandshakeMessage.ht_certificate_request), - RECORD_SERVER_HELLO_DONE (Record.ct_handshake, - HandshakeMessage.ht_server_hello_done), - RECORD_CERTIFICATE_VERIFY (Record.ct_handshake, - HandshakeMessage.ht_certificate_verify), - RECORD_CLIENT_KEY_EXCHANGE (Record.ct_handshake, - HandshakeMessage.ht_client_key_exchange), - RECORD_FINISHED (Record.ct_handshake, - HandshakeMessage.ht_finished), - RECORD_CERTIFICATE_URL (Record.ct_handshake, - HandshakeMessage.ht_certificate_url), - RECORD_CERTIFICATE_STATUS (Record.ct_handshake, - HandshakeMessage.ht_certificate_status), - RECORD_SUPPLIEMENTAL_DATA (Record.ct_handshake, - HandshakeMessage.ht_supplemental_data), - RECORD_APPLICATION_DATA (Record.ct_application_data, - HandshakeMessage.ht_not_applicable); - - byte contentType; - byte handshakeType; - - private RecordType(byte contentType, byte handshakeType) { - this.contentType = contentType; - this.handshakeType = handshakeType; - } - - static RecordType valueOf(byte contentType, byte handshakeType) { - if (contentType == Record.ct_change_cipher_spec) { - return RECORD_CHANGE_CIPHER_SPEC; - } else if (contentType == Record.ct_alert) { - return RECORD_ALERT; - } else if (contentType == Record.ct_application_data) { - return RECORD_APPLICATION_DATA; - } else if (handshakeType == HandshakeMessage.ht_hello_request) { - return RECORD_HELLO_REQUEST; - } else if (handshakeType == HandshakeMessage.ht_client_hello) { - return RECORD_CLIENT_HELLO; - } else if (handshakeType == HandshakeMessage.ht_server_hello) { - return RECORD_SERVER_HELLO; - } else if (handshakeType == HandshakeMessage.ht_hello_verify_request) { - return RECORD_HELLO_VERIFY_REQUEST; - } else if (handshakeType == HandshakeMessage.ht_new_session_ticket) { - return RECORD_NEW_SESSION_TICKET; - } else if (handshakeType == HandshakeMessage.ht_certificate) { - return RECORD_CERTIFICATE; - } else if (handshakeType == HandshakeMessage.ht_server_key_exchange) { - return RECORD_SERVER_KEY_EXCHANGE; - } else if (handshakeType == HandshakeMessage.ht_certificate_request) { - return RECORD_CERTIFICATE_REQUEST; - } else if (handshakeType == HandshakeMessage.ht_server_hello_done) { - return RECORD_SERVER_HELLO_DONE; - } else if (handshakeType == HandshakeMessage.ht_certificate_verify) { - return RECORD_CERTIFICATE_VERIFY; - } else if (handshakeType == HandshakeMessage.ht_client_key_exchange) { - return RECORD_CLIENT_KEY_EXCHANGE; - } else if (handshakeType == HandshakeMessage.ht_finished) { - return RECORD_FINISHED; - } else if (handshakeType == HandshakeMessage.ht_certificate_url) { - return RECORD_CERTIFICATE_URL; - } else if (handshakeType == HandshakeMessage.ht_certificate_status) { - return RECORD_CERTIFICATE_STATUS; - } else if (handshakeType == HandshakeMessage.ht_supplemental_data) { - return RECORD_SUPPLIEMENTAL_DATA; - } - - // otherwise, invalid record type - throw new IllegalArgumentException( - "Invalid record type (ContentType:" + contentType + - ", HandshakeType:" + handshakeType + ")"); - } -} From 6823a2068e0bc95b18cbdd46ddfaaa597cd3a17b Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Wed, 24 May 2017 13:53:44 -0700 Subject: [PATCH 58/66] 8180802: move jdk.testlibrary.management.ThreadMXBeanTool to top level testlibrary Reviewed-by: psandoz --- .../test/lib/management/ThreadMXBeanTool.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 test/lib/jdk/test/lib/management/ThreadMXBeanTool.java diff --git a/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java b/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java new file mode 100644 index 00000000000..eeb4297f500 --- /dev/null +++ b/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java @@ -0,0 +1,71 @@ +/* + * 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.management; + +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; + +/** + * A few utility methods to use ThreadMXBean. + */ +public final class ThreadMXBeanTool { + + /** + * Waits until {@link Thread} is in the certain {@link Thread.State} + * and blocking on {@code object}. + * + * @param state The thread state + * @param object The object to block on + */ + public static void waitUntilBlockingOnObject(Thread thread, Thread.State state, Object object) + throws InterruptedException { + String want = object == null ? null : object.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(object)); + ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); + while (thread.isAlive()) { + ThreadInfo ti = tmx.getThreadInfo(thread.getId()); + if (ti.getThreadState() == state + && (want == null || want.equals(ti.getLockName()))) { + return; + } + Thread.sleep(1); + } + } + + /** + * Waits until {@link Thread} is in native. + */ + public static void waitUntilInNative(Thread thread) throws InterruptedException { + ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); + while (thread.isAlive()) { + ThreadInfo ti = tmx.getThreadInfo(thread.getId()); + if (ti.isInNative()) { + return; + } + Thread.sleep(1); + } + } + +} From e238187859b9c77fac6503a4c4cb651163b33c98 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Wed, 24 May 2017 13:55:37 -0700 Subject: [PATCH 59/66] 8180802: move jdk.testlibrary.management.ThreadMXBeanTool to top level testlibrary Reviewed-by: psandoz --- .../management/ThreadMXBeanTool.java | 72 ------------------- 1 file changed, 72 deletions(-) delete mode 100644 jdk/test/lib/testlibrary/jdk/testlibrary/management/ThreadMXBeanTool.java diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/management/ThreadMXBeanTool.java b/jdk/test/lib/testlibrary/jdk/testlibrary/management/ThreadMXBeanTool.java deleted file mode 100644 index b3f4417a898..00000000000 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/management/ThreadMXBeanTool.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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.testlibrary.management; - -import java.lang.management.ManagementFactory; -import java.lang.management.ThreadInfo; -import java.lang.management.ThreadMXBean; -import java.util.concurrent.TimeoutException; - -/** - * A few utility methods to use ThreadMXBean. - */ -public final class ThreadMXBeanTool { - - /** - * Waits until {@link Thread} is in the certain {@link State} - * and blocking on {@code object}. - * - * @param state The thread state - * @param object The object to block on - */ - public static void waitUntilBlockingOnObject(Thread thread, Thread.State state, Object object) - throws InterruptedException { - String want = object == null ? null : object.getClass().getName() + '@' - + Integer.toHexString(System.identityHashCode(object)); - ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); - while (thread.isAlive()) { - ThreadInfo ti = tmx.getThreadInfo(thread.getId()); - if (ti.getThreadState() == state - && (want == null || want.equals(ti.getLockName()))) { - return; - } - Thread.sleep(1); - } - } - - /** - * Waits until {@link Thread} is in native. - */ - public static void waitUntilInNative(Thread thread) throws InterruptedException { - ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); - while (thread.isAlive()) { - ThreadInfo ti = tmx.getThreadInfo(thread.getId()); - if (ti.isInNative()) { - return; - } - Thread.sleep(1); - } - } - -} From 97a536003e44aeccf134c8cd64371e1c7fad95a0 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Wed, 24 May 2017 14:16:09 -0700 Subject: [PATCH 60/66] 8180724: move ModuleInfoMaker to the top level testlibrary Reviewed-by: psandoz, mchung --- jdk/test/lib/testlibrary/ModuleInfoMaker.java | 127 ------------------ jdk/test/tools/jmod/hashes/HashesTest.java | 37 ++--- .../AddExportsTestWarningError.java | 5 +- .../addreads/AddReadsTestWarningError.java | 6 +- 4 files changed, 24 insertions(+), 151 deletions(-) delete mode 100644 jdk/test/lib/testlibrary/ModuleInfoMaker.java diff --git a/jdk/test/lib/testlibrary/ModuleInfoMaker.java b/jdk/test/lib/testlibrary/ModuleInfoMaker.java deleted file mode 100644 index 5e4f15a6774..00000000000 --- a/jdk/test/lib/testlibrary/ModuleInfoMaker.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 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. - */ - -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Stream; - -import static org.testng.Assert.assertTrue; - -/** - * Utility class for creating test modules. - */ -public class ModuleInfoMaker { - private static String MODULE_INFO_JAVA = "module-info.java"; - private static Pattern MODULE_PATTERN = - Pattern.compile("module\\s+((?:\\w+\\.)*)"); - private static Pattern PACKAGE_PATTERN = - Pattern.compile("package\\s+(((?:\\w+\\.)*)(?:\\w+))"); - private static Pattern CLASS_PATTERN = - Pattern.compile("(?:public\\s+)?(?:class|enum|interface)\\s+(\\w+)"); - - private final Path dir; - public ModuleInfoMaker(Path dir) { - this.dir = dir; - } - - /** - * Create java source files of the given module - */ - public void writeJavaFiles(String module, String moduleInfoJava, String... contents) - throws IOException - { - Path msrc = dir.resolve(module); - new JavaSource(moduleInfoJava).write(msrc); - for (String c : contents) { - new JavaSource(c).write(msrc); - } - } - - /** - * Compile the module to the given destination. - */ - public void compile(String module, Path dest, String... options) - throws IOException - { - Path msrc = dir.resolve(module); - Stream args = - Stream.concat(Arrays.stream(options), - Stream.of("--module-source-path", - dir.toString())); - assertTrue(CompilerUtils.compile(msrc, dest, args.toArray(String[]::new)), - "Fail to compile " + module); - } - - static class JavaSource { - final String source; - JavaSource(String source) { - this.source = source; - } - - /** - * Writes the source code to a file in a specified directory. - * @param dir the directory - * @throws IOException if there is a problem writing the file - */ - public void write(Path dir) throws IOException { - Path file = dir.resolve(getJavaFileNameFromSource(source)); - Files.createDirectories(file.getParent()); - try (BufferedWriter out = Files.newBufferedWriter(file)) { - out.write(source.replace("\n", System.lineSeparator())); - } - } - - /** - * Extracts the Java file name from the class declaration. - * This method is intended for simple files and uses regular expressions, - * so comments matching the pattern can make the method fail. - */ - static String getJavaFileNameFromSource(String source) { - String packageName = null; - - Matcher matcher = MODULE_PATTERN.matcher(source); - if (matcher.find()) - return MODULE_INFO_JAVA; - - matcher = PACKAGE_PATTERN.matcher(source); - if (matcher.find()) - packageName = matcher.group(1).replace(".", "/"); - - matcher = CLASS_PATTERN.matcher(source); - if (matcher.find()) { - String className = matcher.group(1) + ".java"; - return (packageName == null) ? className : packageName + "/" + className; - } else if (packageName != null) { - return packageName + "/package-info.java"; - } else { - throw new Error("Could not extract the java class " + - "name from the provided source"); - } - } - } -} diff --git a/jdk/test/tools/jmod/hashes/HashesTest.java b/jdk/test/tools/jmod/hashes/HashesTest.java index 10680927c19..e71efe91bc5 100644 --- a/jdk/test/tools/jmod/hashes/HashesTest.java +++ b/jdk/test/tools/jmod/hashes/HashesTest.java @@ -25,13 +25,12 @@ * @test * @bug 8160286 * @summary Test the recording and checking of module hashes - * @library /lib/testlibrary + * @library /test/lib * @modules java.base/jdk.internal.misc * java.base/jdk.internal.module * jdk.compiler * jdk.jartool * jdk.jlink - * @build CompilerUtils ModuleInfoMaker * @run testng HashesTest */ @@ -62,6 +61,8 @@ import jdk.internal.module.ModuleInfo; import jdk.internal.module.ModuleHashes; import jdk.internal.module.ModulePath; +import jdk.test.lib.compiler.ModuleInfoMaker; + import org.testng.annotations.Test; import static org.testng.Assert.*; @@ -382,7 +383,7 @@ public class HashesTest { makeModule(mn, null, deps); } - private void makeModule(String mn, ModuleDescriptor.Requires.Modifier mod, String... deps) + private void makeModule(String mn, ModuleDescriptor.Requires.Modifier mod, String... deps) throws IOException { if (mod != null && mod != TRANSITIVE && mod != STATIC) { @@ -390,23 +391,23 @@ public class HashesTest { } StringBuilder sb = new StringBuilder(); - sb.append("module " + mn + " {").append("\n"); - Arrays.stream(deps).forEach(req -> { - sb.append(" requires "); - if (mod != null) { - sb.append(mod.toString().toLowerCase()).append(" "); - } - sb.append(req + ";\n"); - }); + sb.append("module ") + .append(mn) + .append(" {") + .append("\n"); + Arrays.stream(deps) + .forEach(req -> { + sb.append(" requires "); + if (mod != null) { + sb.append(mod.toString().toLowerCase()) + .append(" "); + } + sb.append(req) + .append(";\n"); + }); sb.append("}\n"); builder.writeJavaFiles(mn, sb.toString()); - - compileModule(mn, srcDir); - } - - private void compileModule(String moduleName, Path src) throws IOException { - Path msrc = src.resolve(moduleName); - assertTrue(CompilerUtils.compile(msrc, mods, "--module-source-path", src.toString())); + builder.compile(mn, mods); } private void jmodHashModules(String moduleName, String hashModulesPattern) { diff --git a/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java b/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java index 0a20fec711a..66c4930c0ca 100644 --- a/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java +++ b/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java @@ -25,9 +25,8 @@ * @test * @bug 8168836 * @summary Basic argument validation for --add-exports - * @library /lib/testlibrary + * @library /lib/testlibrary /test/lib * @modules jdk.compiler - * @build AddExportsTestWarningError CompilerUtils ModuleInfoMaker * @build jdk.testlibrary.* * @run testng AddExportsTestWarningError */ @@ -40,6 +39,7 @@ import java.nio.file.Paths; import java.util.Arrays; import java.util.stream.Stream; +import jdk.test.lib.compiler.ModuleInfoMaker; import jdk.testlibrary.OutputAnalyzer; import static jdk.testlibrary.ProcessTools.*; @@ -48,7 +48,6 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.testng.Assert.*; - @Test public class AddExportsTestWarningError { diff --git a/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java b/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java index 6c9ee5634eb..079acccf400 100644 --- a/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java +++ b/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java @@ -25,9 +25,9 @@ * @test * @bug 8168836 * @summary Basic argument validation for --add-reads - * @library /lib/testlibrary + * @library /lib/testlibrary /test/lib * @modules jdk.compiler - * @build AddReadsTestWarningError CompilerUtils ModuleInfoMaker + * @build AddReadsTestWarningError * @build jdk.testlibrary.* * @run testng AddReadsTestWarningError */ @@ -40,6 +40,7 @@ import java.nio.file.Paths; import java.util.Arrays; import java.util.stream.Stream; +import jdk.test.lib.compiler.ModuleInfoMaker; import jdk.testlibrary.OutputAnalyzer; import static jdk.testlibrary.ProcessTools.*; @@ -48,7 +49,6 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.testng.Assert.*; - @Test public class AddReadsTestWarningError { From 662fb55c953c5aed8030c59232f454cb9546f168 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Wed, 24 May 2017 14:16:20 -0700 Subject: [PATCH 61/66] 8180724: move ModuleInfoMaker to the top level testlibrary Reviewed-by: psandoz, mchung --- .../test/lib/compiler/ModuleInfoMaker.java | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 test/lib/jdk/test/lib/compiler/ModuleInfoMaker.java diff --git a/test/lib/jdk/test/lib/compiler/ModuleInfoMaker.java b/test/lib/jdk/test/lib/compiler/ModuleInfoMaker.java new file mode 100644 index 00000000000..f6438a678ca --- /dev/null +++ b/test/lib/jdk/test/lib/compiler/ModuleInfoMaker.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 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. + */ + +package jdk.test.lib.compiler; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Stream; + +/** + * Utility class for creating test modules. + */ +public class ModuleInfoMaker { + private static final String MODULE_INFO_JAVA = "module-info.java"; + private static final Pattern MODULE_PATTERN = + Pattern.compile("module\\s+((?:\\w+\\.)*)"); + private static final Pattern PACKAGE_PATTERN = + Pattern.compile("package\\s+(((?:\\w+\\.)*)(?:\\w+))"); + private static final Pattern CLASS_PATTERN = + Pattern.compile("(?:public\\s+)?(?:class|enum|interface)\\s+(\\w+)"); + + private final Path dir; + + public ModuleInfoMaker(Path dir) { + this.dir = dir; + } + + /** + * Create java source files of the given module + */ + public void writeJavaFiles(String module, String moduleInfoJava, String... contents) + throws IOException + { + Path msrc = dir.resolve(module); + new JavaSource(moduleInfoJava).write(msrc); + for (String c : contents) { + new JavaSource(c).write(msrc); + } + } + + /** + * Compile the module to the given destination. + */ + public void compile(String module, Path dest, String... options) + throws IOException + { + Path msrc = dir.resolve(module); + String[] args = + Stream.concat(Arrays.stream(options), + Stream.of("--module-source-path", + dir.toString())).toArray(String[]::new); + if (!CompilerUtils.compile(msrc, dest, args)) { + throw new Error("Fail to compile " + module); + } + } + + static class JavaSource { + final String source; + JavaSource(String source) { + this.source = source; + } + + /** + * Writes the source code to a file in a specified directory. + * @param dir the directory + * @throws IOException if there is a problem writing the file + */ + public void write(Path dir) throws IOException { + Path file = dir.resolve(getJavaFileNameFromSource(source)); + Files.createDirectories(file.getParent()); + try (BufferedWriter out = Files.newBufferedWriter(file)) { + out.write(source.replace("\n", System.lineSeparator())); + } + } + + /** + * Extracts the Java file name from the class declaration. + * This method is intended for simple files and uses regular expressions, + * so comments matching the pattern can make the method fail. + */ + static String getJavaFileNameFromSource(String source) { + String packageName = null; + + Matcher matcher = MODULE_PATTERN.matcher(source); + if (matcher.find()) + return MODULE_INFO_JAVA; + + matcher = PACKAGE_PATTERN.matcher(source); + if (matcher.find()) + packageName = matcher.group(1).replace(".", "/"); + + matcher = CLASS_PATTERN.matcher(source); + if (matcher.find()) { + String className = matcher.group(1) + ".java"; + return (packageName == null) ? className : packageName + "/" + className; + } else if (packageName != null) { + return packageName + "/package-info.java"; + } else { + throw new Error("Could not extract the java class " + + "name from the provided source"); + } + } + } +} From 88ef6ea270972292b33a16b71756b28fef93fc27 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Wed, 24 May 2017 15:21:14 -0700 Subject: [PATCH 62/66] 8180399: move jdk.testlibrary.LockFreeLogManager to the top level test library Reviewed-by: psandoz, mchung --- test/lib/jdk/test/lib/LockFreeLogger.java | 84 +++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 test/lib/jdk/test/lib/LockFreeLogger.java diff --git a/test/lib/jdk/test/lib/LockFreeLogger.java b/test/lib/jdk/test/lib/LockFreeLogger.java new file mode 100644 index 00000000000..4e96b9abccd --- /dev/null +++ b/test/lib/jdk/test/lib/LockFreeLogger.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2014, 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.Collection; +import java.util.Comparator; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +/** + * A logger designed specifically to allow collecting ordered log messages + * in a multi-threaded environment without involving any kind of locking. + *

    + * It is particularly useful in situations when one needs to assert various + * details about the tested thread state or the locks it hold while also wanting + * to produce diagnostic log messages. + *

    + * The logger does not provide any guarantees about the completness of the + * logs written from different threads - it is up to the caller to make sure + * {@code toString()} method is called only when all the activity has ceased + * and the per-thread logs contain all the necessary data. + * + * @author Jaroslav Bachorik + **/ +public class LockFreeLogger { + private final AtomicInteger logCntr = new AtomicInteger(0); + private final Collection> allRecords = new ConcurrentLinkedQueue<>(); + private final ThreadLocal> records = ThreadLocal.withInitial(ConcurrentHashMap::new); + + public LockFreeLogger() { + allRecords.add(records.get()); + } + + /** + * Log a message + * @param format Message format + * @param params Message parameters + */ + public void log(String format, Object ... params) { + int id = logCntr.getAndIncrement(); + records.get().put(id, String.format(format, params)); + } + + /** + * Will generate an aggregated log of chronologically ordered messages. + *

    + * Make sure that you call this method only when all the related threads + * have finished; otherwise you might get incomplete data. + * + * @return An aggregated log of chronologically ordered messages + */ + @Override + public String toString() { + return allRecords.stream() + .flatMap(m -> m.entrySet().stream()) + .sorted(Comparator.comparing(Map.Entry::getKey)) + .map(Map.Entry::getValue) + .collect(Collectors.joining()); + } +} From 2d7f46e91bca88d883533cdc4950050a6c9951cc Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Wed, 24 May 2017 15:24:40 -0700 Subject: [PATCH 63/66] 8180399: move jdk.testlibrary.LockFreeLogManager to the top level test library Reviewed-by: psandoz, mchung --- .../lang/Thread/ThreadStateController.java | 8 +- .../java/lang/Thread/ThreadStateTest.java | 1 + .../lang/management/ThreadMXBean/Locks.java | 20 ++--- .../ThreadMXBean/ThreadMXBeanStateTest.java | 1 + .../jdk/testlibrary/LockFreeLogManager.java | 90 ------------------- 5 files changed, 16 insertions(+), 104 deletions(-) delete mode 100644 jdk/test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java diff --git a/jdk/test/java/lang/Thread/ThreadStateController.java b/jdk/test/java/lang/Thread/ThreadStateController.java index c426d1b34b4..d644a1a9ece 100644 --- a/jdk/test/java/lang/Thread/ThreadStateController.java +++ b/jdk/test/java/lang/Thread/ThreadStateController.java @@ -27,7 +27,7 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.LockSupport; -import jdk.testlibrary.LockFreeLogManager; +import jdk.test.lib.LockFreeLogger; import jdk.testlibrary.Utils; /** @@ -100,7 +100,7 @@ public class ThreadStateController extends Thread { private final AtomicInteger iterations = new AtomicInteger(); private final AtomicInteger interrupted = new AtomicInteger(); - private final LockFreeLogManager logManager = new LockFreeLogManager(); + private final LockFreeLogger logger = new LockFreeLogger(); @Override public void run() { @@ -349,7 +349,7 @@ public class ThreadStateController extends Thread { } private void log(String msg, Object ... params) { - logManager.log(msg, params); + logger.log(msg, params); } /** @@ -361,6 +361,6 @@ public class ThreadStateController extends Thread { public String getLog() throws InterruptedException { this.join(); - return logManager.toString(); + return logger.toString(); } } diff --git a/jdk/test/java/lang/Thread/ThreadStateTest.java b/jdk/test/java/lang/Thread/ThreadStateTest.java index 843cfd7ddeb..6509e391099 100644 --- a/jdk/test/java/lang/Thread/ThreadStateTest.java +++ b/jdk/test/java/lang/Thread/ThreadStateTest.java @@ -31,6 +31,7 @@ import static java.lang.Thread.State.*; * * @author Mandy Chung * @library /lib/testlibrary + * @library /test/lib * @build jdk.testlibrary.* * @build ThreadStateTest ThreadStateController * @run main/othervm -Xmixed ThreadStateTest diff --git a/jdk/test/java/lang/management/ThreadMXBean/Locks.java b/jdk/test/java/lang/management/ThreadMXBean/Locks.java index fa7a5b63a6f..85761d23ed0 100644 --- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java +++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.java @@ -29,17 +29,17 @@ * @author Mandy Chung * @author Jaroslav Bachorik * - * @library /lib/testlibrary + * @library /test/lib * - * @build jdk.testlibrary.* * @run main/othervm Locks */ import java.lang.management.*; import java.util.Arrays; +import java.util.Objects; import java.util.Optional; import java.util.concurrent.Phaser; import java.util.function.Predicate; -import jdk.testlibrary.LockFreeLogManager; +import jdk.test.lib.LockFreeLogger; public class Locks { @@ -47,7 +47,7 @@ public class Locks { private static final Object OBJB = new Object(); private static final EnhancedWaiter OBJC = new EnhancedWaiter(); private static final ThreadMXBean TM = ManagementFactory.getThreadMXBean(); - private static final LockFreeLogManager LOGGER = new LockFreeLogManager(); + private static final LockFreeLogger LOGGER = new LockFreeLogger(); private static String getLockName(Object lock) { if (lock == null) return null; @@ -60,12 +60,12 @@ public class Locks { if (t == null) { return; } - Optional result = Arrays.asList( - TM.getThreadInfo(TM.getAllThreadIds(), true, true)). - stream(). - filter(tInfo -> (tInfo != null && tInfo.getLockOwnerName() != null) - ? tInfo.getLockOwnerName().equals(t.getName()) : false). - findAny(); + String name = t.getName(); + Optional result = Arrays.stream( + TM.getThreadInfo(TM.getAllThreadIds(), true, true)) + .filter(Objects::nonNull) + .filter(i -> name.equals(i.getLockOwnerName())) + .findAny(); if (result.isPresent()) { throw new RuntimeException("Thread " + t.getName() + " is not " + "supposed to be hold any lock. Currently owning lock : " diff --git a/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java b/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java index 6a9c9cacedf..fc94d4ab0ca 100644 --- a/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java +++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java @@ -31,6 +31,7 @@ * * @library ../../Thread * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* * @build ThreadMXBeanStateTest ThreadStateController diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java b/jdk/test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java deleted file mode 100644 index f895018be44..00000000000 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 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. - */ - -package jdk.testlibrary; - -import java.util.Collection; -import java.util.Formatter; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -/** - * A log manager designed specifically to allow collecting ordered log messages - * in a multi-threaded environment without involving any kind of locking. - *

    - * It is particularly useful in situations when one needs to assert various - * details about the tested thread state or the locks it hold while also wanting - * to produce diagnostic log messages. - *

    - * The log manager does not provide any guarantees about the completness of the - * logs written from different threads - it is up to the caller to make sure - * {@code toString()} method is called only when all the activity has ceased - * and the per-thread logs contain all the necessary data. - * - * @author Jaroslav Bachorik - **/ -public class LockFreeLogManager { - private final AtomicInteger logCntr = new AtomicInteger(0); - private final Collection> allRecords = new ConcurrentLinkedQueue<>(); - private final ThreadLocal> records = new ThreadLocal>() { - @Override - protected Map initialValue() { - Map m = new ConcurrentHashMap<>(); - allRecords.add(m); - return m; - } - - }; - - /** - * Log a message - * @param format Message format - * @param params Message parameters - */ - public void log(String format, Object ... params) { - int id = logCntr.getAndIncrement(); - try (Formatter formatter = new Formatter()) { - records.get().put(id, formatter.format(format, params).toString()); - } - } - - /** - * Will generate an aggregated log of chronologically ordered messages. - *

    - * Make sure that you call this method only when all the related threads - * have finished; otherwise you might get incomplete data. - * - * @return An aggregated log of chronologically ordered messages - */ - @Override - public String toString() { - return allRecords.stream() - .flatMap(m->m.entrySet().stream()) - .sorted((l, r)->l.getKey().compareTo(r.getKey())) - .map(e->e.getValue()) - .collect(Collectors.joining()); - } -} From da44748ec746b18ef3ca9ffc9b3f1e4ae8a9bba5 Mon Sep 17 00:00:00 2001 From: Adam Petcher Date: Thu, 25 May 2017 11:31:23 +0100 Subject: [PATCH 64/66] 8172244: AIOOBE in KeyStore.getCertificateAlias on Windows Reviewed-by: vinnie --- .../classes/sun/security/mscapi/KeyStore.java | 8 +- .../mscapi/KeyStoreEmptyCertChain.java | 81 +++++++++++++++++++ 2 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 jdk/test/sun/security/mscapi/KeyStoreEmptyCertChain.java diff --git a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java index c4888bf3049..16e99bbfd48 100644 --- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java +++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -513,7 +513,7 @@ abstract class KeyStore extends KeyStoreSpi { if (entry != null) { // Get end-entity certificate and remove from system cert store X509Certificate[] certChain = entry.getCertificateChain(); - if (certChain != null) { + if (certChain != null && certChain.length > 0) { try { @@ -629,7 +629,9 @@ abstract class KeyStore extends KeyStoreSpi { for (Map.Entry mapEntry : entries.entrySet()) { KeyEntry entry = mapEntry.getValue(); - if (entry.certChain != null && entry.certChain[0].equals(cert)) { + if (entry.certChain != null && + entry.certChain.length > 0 && + entry.certChain[0].equals(cert)) { return entry.getAlias(); } } diff --git a/jdk/test/sun/security/mscapi/KeyStoreEmptyCertChain.java b/jdk/test/sun/security/mscapi/KeyStoreEmptyCertChain.java new file mode 100644 index 00000000000..d603df9f1c8 --- /dev/null +++ b/jdk/test/sun/security/mscapi/KeyStoreEmptyCertChain.java @@ -0,0 +1,81 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8172244 + * @summary Verify that no exception is thrown with empty cert chain + * in MSCAPI. + * @requires os.family == "windows" + * @modules java.base/sun.security.tools.keytool java.base/sun.security.x509 + * @run main/othervm --add-opens java.base/java.security=ALL-UNNAMED + * KeyStoreEmptyCertChain + */ + +import java.security.KeyStore; +import java.security.cert.Certificate; +import sun.security.x509.X500Name; +import sun.security.tools.keytool.CertAndKeyGen; +import java.security.KeyPairGenerator; +import java.security.KeyPair; +import java.security.PrivateKey; +import java.security.KeyStoreSpi; +import java.lang.reflect.*; + +public class KeyStoreEmptyCertChain { + + public static void main(String[] args) { + + try { + + KeyStore keyStore = KeyStore.getInstance("Windows-MY", "SunMSCAPI"); + keyStore.load(null, null); + + // Generate a certificate to use for testing + CertAndKeyGen gen = new CertAndKeyGen("RSA", "SHA256withRSA"); + gen.generate(2048); + Certificate cert = + gen.getSelfCertificate(new X500Name("CN=test"), 3600); + String alias = "JDK-8172244"; + char[] password = "password".toCharArray(); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); + + // generate a private key for the certificate + kpg.initialize(2048); + KeyPair keyPair = kpg.generateKeyPair(); + PrivateKey privKey = keyPair.getPrivate(); + // need to bypass checks to store the private key without the cert + Field spiField = KeyStore.class.getDeclaredField("keyStoreSpi"); + spiField.setAccessible(true); + KeyStoreSpi spi = (KeyStoreSpi) spiField.get(keyStore); + spi.engineSetKeyEntry(alias, privKey, password, new Certificate[0]); + keyStore.store(null, null); + + keyStore.getCertificateAlias(cert); + keyStore.deleteEntry(alias); + // test passes if no exception is thrown + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } +} From fa2f54dbde776ae5ddb830c68c791c99216c158d Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 23:27:02 +0200 Subject: [PATCH 65/66] Added tag jdk-10+8 for changeset c42dc7b58b4d --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 9fd0a508429..4a41328ccfa 100644 --- a/.hgtags +++ b/.hgtags @@ -420,3 +420,4 @@ d1cab6c7e608479be4ebfad48a25b0ed48600f62 jdk-10+3 f113ce12fe24fbd24acf02711372d9f1e1c12426 jdk-10+5 1407b19a2ddf6baae162f5a1a5b96af473f4d7d1 jdk-10+6 30e75693ae99fd8e47fd2f5116527aff1b59aff9 jdk-10+7 +c42dc7b58b4d4301ea676a76326fd9bbd403d595 jdk-10+8 From fc47ba11e663863a450215e04e2200377886d741 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 23:28:56 +0200 Subject: [PATCH 66/66] Added tag jdk-9+170 for changeset 898cbe31fbda --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 69da0fb8aa2..cc30bedcf44 100644 --- a/.hgtags +++ b/.hgtags @@ -413,3 +413,4 @@ d3e973f1809606c67412361041ad197e50fe8cec jdk-9+166 8fd0a4569191f33c98ee90c2709174a342fefb0d jdk-9+167 fcabc74bd44e56c7419d111d59b95669ecb33c55 jdk-9+168 c7efde2b60fc1ec04630be769d9ad60efb39c39c jdk-9+169 +898cbe31fbdae2d25d141384fac746cc244a730c jdk-9+170

    Modules