# HG changeset patch
# User jwilhelm
# Date 1513353257 -3600
# Node ID 0c0b618a20b1c408c054f42d10965aea762a96e1
# Parent 474cec233fb2f405d899946ec42df3fe826ef3a2# Parent 626d11295f31f3b577dfabfdca9dfa2ce94eb5a2
Merge
diff -r 474cec233fb2 -r 0c0b618a20b1 .hgtags
--- a/.hgtags Fri Dec 15 11:23:50 2017 -0500
+++ b/.hgtags Fri Dec 15 16:54:17 2017 +0100
@@ -460,3 +460,5 @@
bbd692ad4fa300ecca7939ffbe3b1d5e52a28cc6 jdk-10+33
89deac44e51517841491ba86ff44aa82a5ca96b3 jdk-10+34
d8c634b016c628622c9abbdc6bf50509e5dedbec jdk-10+35
+0ee20aad71c4f33c426372b4c8bcc1235ce2ec08 jdk-11+0
+959f2f7cbaa6d2ee45d50029744efb219721576c jdk-10+36
diff -r 474cec233fb2 -r 0c0b618a20b1 ADDITIONAL_LICENSE_INFO
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ADDITIONAL_LICENSE_INFO Fri Dec 15 16:54:17 2017 +0100
@@ -0,0 +1,37 @@
+ ADDITIONAL INFORMATION ABOUT LICENSING
+
+Certain files distributed by Oracle America, Inc. and/or its affiliates are
+subject to the following clarification and special exception to the GPLv2,
+based on the GNU Project exception for its Classpath libraries, known as the
+GNU Classpath Exception.
+
+Note that Oracle includes multiple, independent programs in this software
+package. Some of those programs are provided under licenses deemed
+incompatible with the GPLv2 by the Free Software Foundation and others.
+For example, the package includes programs licensed under the Apache
+License, Version 2.0 and may include FreeType. Such programs are licensed
+to you under their original licenses.
+
+Oracle facilitates your further distribution of this package by adding the
+Classpath Exception to the necessary parts of its GPLv2 code, which permits
+you to use that code in combination with other independent modules not
+licensed under the GPLv2. However, note that this would not permit you to
+commingle code under an incompatible license with Oracle's GPLv2 licensed
+code by, for example, cutting and pasting such code into a file also
+containing Oracle's GPLv2 licensed code and then distributing the result.
+
+Additionally, if you were to remove the Classpath Exception from any of the
+files to which it applies and distribute the result, you would likely be
+required to license some or all of the other code in that distribution under
+the GPLv2 as well, and since the GPLv2 is incompatible with the license terms
+of some items included in the distribution by Oracle, removing the Classpath
+Exception could therefore effectively compromise your ability to further
+distribute the package.
+
+Failing to distribute notices associated with some files may also create
+unexpected legal consequences.
+
+Proceed with caution and we recommend that you obtain the advice of a lawyer
+skilled in open source matters before removing the Classpath Exception or
+making modifications to this package which may subsequently be redistributed
+and/or involve the use of third party software.
diff -r 474cec233fb2 -r 0c0b618a20b1 make/MacBundles.gmk
--- a/make/MacBundles.gmk Fri Dec 15 11:23:50 2017 -0500
+++ b/make/MacBundles.gmk Fri Dec 15 16:54:17 2017 +0100
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -41,7 +41,7 @@
BUNDLE_ID := $(MACOSX_BUNDLE_ID_BASE).$(VERSION_SHORT)
BUNDLE_NAME := $(MACOSX_BUNDLE_NAME_BASE) $(VERSION_SHORT)
BUNDLE_INFO := $(MACOSX_BUNDLE_NAME_BASE) $(VERSION_STRING)
- BUNDLE_PLATFORM_VERSION := $(VERSION_MAJOR).$(VERSION_MINOR)
+ BUNDLE_PLATFORM_VERSION := $(VERSION_FEATURE).$(VERSION_INTERIM)
BUNDLE_VERSION := $(VERSION_NUMBER)
ifeq ($(COMPANY_NAME), N/A)
BUNDLE_VENDOR := UNDEFINED
diff -r 474cec233fb2 -r 0c0b618a20b1 make/ReleaseFile.gmk
--- a/make/ReleaseFile.gmk Fri Dec 15 11:23:50 2017 -0500
+++ b/make/ReleaseFile.gmk Fri Dec 15 16:54:17 2017 +0100
@@ -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
@@ -48,6 +48,9 @@
$(call info-file-item, "SUN_ARCH_ABI", "$(JDK_ARCH_ABI_PROP_NAME)"))
$(call info-file-item, "SOURCE", "$(strip $(SOURCE_REVISION))")
$(call info-file-item, "IMPLEMENTOR", "$(COMPANY_NAME)")
+ $(if $(VENDOR_VERSION_STRING), \
+ $(call info-file-item, "IMPLEMENTOR_VERSION", "$(VENDOR_VERSION_STRING)"))
+ $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
$(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
$(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
endef
diff -r 474cec233fb2 -r 0c0b618a20b1 make/autoconf/flags.m4
--- a/make/autoconf/flags.m4 Fri Dec 15 11:23:50 2017 -0500
+++ b/make/autoconf/flags.m4 Fri Dec 15 16:54:17 2017 +0100
@@ -313,7 +313,7 @@
-D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
-D\"JDK_VER=\$(VERSION_NUMBER)\" \
-D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
- -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_MAJOR)\" \
+ -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_FEATURE)\" \
-D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
JVM_RCFLAGS="$JVM_RCFLAGS \
diff -r 474cec233fb2 -r 0c0b618a20b1 make/autoconf/generated-configure.sh
--- a/make/autoconf/generated-configure.sh Fri Dec 15 11:23:50 2017 -0500
+++ b/make/autoconf/generated-configure.sh Fri Dec 15 16:54:17 2017 +0100
@@ -887,6 +887,8 @@
BOOT_JDK
JAVA_CHECK
JAVAC_CHECK
+VENDOR_VERSION_STRING
+VERSION_DATE
VERSION_IS_GA
VERSION_SHORT
VERSION_STRING
@@ -896,9 +898,9 @@
VERSION_BUILD
VERSION_PRE
VERSION_PATCH
-VERSION_SECURITY
-VERSION_MINOR
-VERSION_MAJOR
+VERSION_UPDATE
+VERSION_INTERIM
+VERSION_FEATURE
MACOSX_BUNDLE_ID_BASE
MACOSX_BUNDLE_NAME_BASE
HOTSPOT_VM_DISTRO
@@ -1091,6 +1093,7 @@
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -1141,14 +1144,19 @@
with_update_version
with_user_release_suffix
with_build_number
+with_version_major
+with_version_minor
+with_version_security
with_version_string
with_version_pre
with_version_opt
with_version_build
-with_version_major
-with_version_minor
-with_version_security
+with_version_feature
+with_version_interim
+with_version_update
with_version_patch
+with_version_date
+with_vendor_version_string
with_boot_jdk
with_build_jdk
with_import_modules
@@ -1375,6 +1383,7 @@
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1627,6 +1636,15 @@
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1764,7 +1782,7 @@
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1917,6 +1935,7 @@
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -2058,6 +2077,12 @@
compatibility and is ignored
--with-build-number Deprecated. Option is kept for backwards
compatibility and is ignored
+ --with-version-major Deprecated. Option is kept for backwards
+ compatibility and is ignored
+ --with-version-minor Deprecated. Option is kept for backwards
+ compatibility and is ignored
+ --with-version-security Deprecated. Option is kept for backwards
+ compatibility and is ignored
--with-version-string Set version string [calculated]
--with-version-pre Set the base part of the version 'PRE' field
(pre-release identifier) ['internal']
@@ -2065,14 +2090,17 @@
[ A version number, {@code $VNUM}, is a non-empty sequence
- * of elements separated by period characters (U+002E). An element is
- * either zero, or an unsigned integer numeral without leading zeros. The
- * final element in a version number must not be zero. The format is:
- * A version number, {@code $VNUM}, is a non-empty sequence of
+ * elements separated by period characters (U+002E). An element is either
+ * zero, or an unsigned integer numeral without leading zeros. The final
+ * element in a version number must not be zero. When an element is
+ * incremented, all subsequent elements are removed. The format is: The sequence may be of arbitrary length but the first three
- * elements are assigned specific meanings, as follows: The sequence may be of arbitrary length but the first four elements
+ * are assigned specific meanings, as follows: {@code $MAJOR} --- The major version
- * number, incremented for a major release that contains significant new
- * features as specified in a new edition of the Java SE Platform
- * Specification, e.g., JSR 337 for
- * Java SE 8. Features may be removed in a major release, given
- * advance notice at least one major release ahead of time, and
- * incompatible changes may be made when justified. The {@code $MAJOR}
- * version number of JDK 8 is {@code 8}; the {@code $MAJOR} version
- * number of JDK 9 is {@code 9}. When {@code $MAJOR} is incremented,
- * all subsequent elements are removed. {@code $FEATURE} — The
+ * feature-release counter, incremented for every feature release
+ * regardless of release content. Features may be added in a feature
+ * release; they may also be removed, if advance notice was given at least
+ * one feature release ahead of time. Incompatible changes may be made
+ * when justified. {@code $MINOR} --- The minor version
- * number, incremented for a minor update release that may contain
- * compatible bug fixes, revisions to standard APIs mandated by a
- * Maintenance Release
- * of the relevant Platform Specification, and implementation features
- * outside the scope of that Specification such as new JDK-specific APIs,
- * additional service providers, new garbage collectors, and ports to new
- * hardware architectures. {@code $INTERIM} — The
+ * interim-release counter, incremented for non-feature releases that
+ * contain compatible bug fixes and enhancements but no incompatible
+ * changes, no feature removals, and no changes to standard APIs.
+ * {@code $SECURITY} --- The security
- * level, incremented for a security update release that contains critical
- * fixes including those necessary to improve security. {@code $SECURITY}
- * is not reset when {@code $MINOR} is incremented. A
- * higher value of {@code $SECURITY} for a given {@code $MAJOR} value,
- * therefore, always indicates a more secure release, regardless of the
- * value of {@code $MINOR}. {@code $UPDATE} — The update-release
+ * counter, incremented for compatible update releases that fix security
+ * issues, regressions, and bugs in newer features. {@code $PATCH} — The emergency
+ * patch-release counter, incremented only when it's necessary to produce
+ * an emergency release to fix a critical issue. The fourth and later elements of a version number are free for use
- * by downstream consumers of this code base. Such a consumer may,
- * e.g., use the fourth element to identify patch releases which
- * contain a small number of critical non-security fixes in addition to
- * the security fixes in the corresponding security release. The fifth and later elements of a version number are free for use by
+ * platform implementors, to identify implementor-specific patch
+ * releases. The version number does not include trailing zero elements;
- * i.e., {@code $SECURITY} is omitted if it has the value zero,
- * and {@code $MINOR} is omitted if both {@code $MINOR} and {@code
- * $SECURITY} have the value zero. A version number never has trailing zero elements. If an element
+ * and all those that follow it logically have the value zero then all of
+ * them are omitted. The sequence of numerals in a version number is compared to another
* such sequence in numerical, pointwise fashion; e.g., {@code
- * 9.9.1} is less than {@code 9.10.3}. If one sequence is shorter than
- * another then the missing elements of the shorter sequence are
- * considered to be less than the corresponding elements of the longer
- * sequence; e.g., {@code 9.1.2} is less than {@code 9.1.2.1}.
- * Version numbers
*
- *
*
- *
- * [1-9][0-9]*((\.0)*\.[1-9][0-9]*)*
+ * [1-9][0-9]*((\.0)*\.[1-9][0-9]*)*
*
*
*
- * $MAJOR.$MINOR.$SECURITY
+ * $FEATURE.$INTERIM.$UPDATE.$PATCH
*
*
- *
*
- *
A version string, {@code $VSTR}, consists of a version - * number {@code $VNUM}, as described above, optionally followed by - * pre-release and build information, in one of the following formats: - *
+ *A version string, {@code $VSTR}, is a version number {@code + * $VNUM}, as described above, optionally followed by pre-release and build + * information, in one of the following formats:
* ** $VNUM(-$PRE)?\+$BUILD(-$OPT)? @@ -986,19 +973,19 @@ ** *
* @@ -1082,7 +1069,7 @@ throw new NullPointerException(); // Shortcut to avoid initializing VersionPattern when creating - // major version constants during startup + // feature-version constants during startup if (isSimpleNumber(s)) { return new Version(List.of(Integer.parseInt(s)), Optional.empty(), Optional.empty(), Optional.empty()); @@ -1139,43 +1126,114 @@ } /** - * Returns the major version number. + * Returns the value of the feature element of + * the version number. * - * @return The major version number + * @return The value of the feature element + * + * @since 10 */ - public int major() { + public int feature() { return version.get(0); } /** - * Returns the minor version number or zero if it - * was not set. + * Returns the value of the interim element of + * the version number, or zero if it is absent. * - * @return The minor version number or zero if it was not set + * @return The value of the interim element, or zero + * + * @since 10 */ - public int minor() { + public int interim() { return (version.size() > 1 ? version.get(1) : 0); } /** - * Returns the security version number or zero - * if it was not set. + * Returns the value of the update element of the + * version number, or zero if it is absent. * - * @return The security version number or zero if it was not set + * @return The value of the update element, or zero + * + * @since 10 */ - public int security() { + public int update() { return (version.size() > 2 ? version.get(2) : 0); } /** - * Returns an unmodifiable {@link java.util.List List} of the - * integer numerals contained in the version - * number. The {@code List} always contains at least one - * element corresponding to the major version - * number. + * Returns the value of the patch element of the + * version number, or zero if it is absent. + * + * @return The value of the patch element, or zero + * + * @since 10 + */ + public int patch() { + return (version.size() > 3 ? version.get(3) : 0); + } + + /** + * Returns the value of the major element of the version number. + * + * @deprecated As of Java SE 10, the first element of a version + * number is not the major-release number but the feature-release + * counter, incremented for every time-based release. Use the {@link + * #feature()} method in preference to this method. For compatibility, + * this method returns the value of the feature + * element. + * + * @return The value of the feature element + */ + @Deprecated(since = "10") + public int major() { + return feature(); + } + + /** + * Returns the value of the minor element of the version number, or + * zero if it is absent. * - * @return An unmodifiable list of the integer numerals - * contained in the version number + * @deprecated As of Java SE 10, the second element of a version + * number is not the minor-release number but the interim-release + * counter, incremented for every interim release. Use the {@link + * #interim()} method in preference to this method. For compatibility, + * this method returns the value of the interim + * element, or zero if it is absent. + * + * @return The value of the interim element, or zero + */ + @Deprecated(since = "10") + public int minor() { + return interim(); + } + + /** + * Returns the value of the security element of the version number, or + * zero if it is absent. + * + * @deprecated As of Java SE 10, the third element of a version + * number is not the security level but the update-release counter, + * incremented for every update release. Use the {@link #update()} + * method in preference to this method. For compatibility, this method + * returns the value of the update element, or + * zero if it is absent. + * + * @return The value of the update element, or zero + */ + @Deprecated(since = "10") + public int security() { + return update(); + } + + /** + * Returns an unmodifiable {@link java.util.List List} of the integers + * represented in the version number. The {@code + * List} always contains at least one element corresponding to the feature version number. + * + * @return An unmodifiable list of the integers + * represented in the version number */ public List- + * — A pre-release identifier. Typically {@code ea}, for a + * potentially unstable early-access release under active development, or + * {@code internal}, for an internal developer build. * *
{@code $PRE}, matching {@code ([a-zA-Z0-9]+)} - * --- A pre-release identifier. Typically {@code ea}, for a - * potentially unstable early-access release under active development, - * or {@code internal}, for an internal developer build.
- * - *
{@code $BUILD}, matching {@code - * (0|[1-9][0-9]*)} --- The build number, incremented for each promoted + * (0|[1-9][0-9]*)} — The build number, incremented for each promoted * build. {@code $BUILD} is reset to {@code 1} when any portion of {@code * $VNUM} is incremented.
- + *
{@code $OPT}, matching {@code - * ([-a-zA-Z0-9.]+)} --- Additional build information, if desired. In - * the case of an {@code internal} build this will often contain the date - * and time of the build.
- * *
{@code $OPT}, matching {@code ([-a-zA-Z0-9.]+)} + * — Additional build information, if desired. In the case of an + * {@code internal} build this will often contain the date and time of the + * build.
version() { return version; diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/lang/System.java --- a/src/java.base/share/classes/java/lang/System.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/java/lang/System.java Fri Dec 15 16:54:17 2017 +0100 @@ -550,8 +550,10 @@ * System properties. The following properties are guaranteed to be defined: * *
- java.version
- Java version number + *
- java.version.date
- Java version date *
- java.vendor
- Java vendor specific string *
- java.vendor.url
- Java vendor URL + *
- java.vendor.version
- Java vendor version *
- java.home
- Java installation directory *
- java.class.version
- Java class version number *
- java.class.path
- Java classpath @@ -591,12 +593,18 @@ * * *
+ * - * java.version
Java Runtime Environment version which may be interpreted + * Java Runtime Environment version, which may be interpreted * as a {@link Runtime.Version} * + * java.version.date
Java Runtime Environment version date, in ISO-8601 YYYY-MM-DD + * format, which may be interpreted as a {@link + * java.time.LocalDate} * * java.vendor
Java Runtime Environment vendor + * * java.vendor.url
Java vendor URL * + * java.vendor.version
Java vendor version * * java.home
Java installation directory diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/lang/VersionProps.java.template --- a/src/java.base/share/classes/java/lang/VersionProps.java.template Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/java/lang/VersionProps.java.template Fri Dec 15 16:54:17 2017 +0100 @@ -32,13 +32,15 @@ class VersionProps { - private static final String launcher_name = "@@LAUNCHER_NAME@@"; private static final String java_version = "@@VERSION_SHORT@@"; + private static final String java_version_date = + "@@VERSION_DATE@@"; + private static final String java_runtime_name = "@@RUNTIME_NAME@@"; @@ -57,14 +59,27 @@ private static final String VERSION_OPT = "@@VERSION_OPT@@"; + private static final boolean isLTS = + "@@VERSION_OPT@@".startsWith("LTS"); + + private static final String VENDOR_VERSION_STRING = + "@@VENDOR_VERSION_STRING@@"; + + private static final String vendor_version = + (VENDOR_VERSION_STRING.length() > 0 + ? " " + VENDOR_VERSION_STRING : ""); + static { init(); } public static void init() { System.setProperty("java.version", java_version); + System.setProperty("java.version.date", java_version_date); System.setProperty("java.runtime.version", java_runtime_version); System.setProperty("java.runtime.name", java_runtime_name); + if (VENDOR_VERSION_STRING.length() > 0) + System.setProperty("java.vendor.version", VENDOR_VERSION_STRING); } private static int parseVersionNumber(String version, int prevIndex, int index) { @@ -162,31 +177,36 @@ /* First line: platform version. */ if (err) { - ps.println(launcher_name + " version \"" + java_version + "\""); + ps.println(launcher_name + " version \"" + java_version + "\"" + + " " + java_version_date + + (isLTS ? " LTS" : "")); } else { /* Use a format more in line with GNU conventions */ - ps.println(launcher_name + " " + java_version); + ps.println(launcher_name + " " + java_version + + " " + java_version_date + + (isLTS ? " LTS" : "")); } /* Second line: runtime version (ie, libraries). */ String jdk_debug_level = System.getProperty("jdk.debug", "release"); - /* Debug level is not printed for "release" builds */ if ("release".equals(jdk_debug_level)) { + /* Do not show debug level "release" builds */ jdk_debug_level = ""; } else { jdk_debug_level = jdk_debug_level + " "; } - ps.print(java_runtime_name + " (" + jdk_debug_level + "build " + java_runtime_version); - - ps.println(')'); + ps.println(java_runtime_name + vendor_version + + " (" + jdk_debug_level + "build " + java_runtime_version + ")"); /* Third line: JVM information. */ String java_vm_name = System.getProperty("java.vm.name"); String java_vm_version = System.getProperty("java.vm.version"); String java_vm_info = System.getProperty("java.vm.info"); - ps.println(java_vm_name + " (" + jdk_debug_level + "build " + java_vm_version + ", " + - java_vm_info + ")"); + ps.println(java_vm_name + vendor_version + + " (" + jdk_debug_level + "build " + java_vm_version + ", " + + java_vm_info + ")"); + } } diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/util/Optional.java --- a/src/java.base/share/classes/java/util/Optional.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/java/util/Optional.java Fri Dec 15 16:54:17 2017 +0100 @@ -32,8 +32,9 @@ /** * A container object which may or may not contain a non-{@code null} value. - * If a value is present, {@code isPresent()} returns {@code true} and - * {@code get()} returns the value. + * If a value is present, {@code isPresent()} returns {@code true}. If no + * value is present, the object is considered empty and + * {@code isPresent()} returns {@code false}. * * java.vm.specification.version
Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(Object) orElse()} @@ -137,14 +138,10 @@ * {@code NoSuchElementException}. * * @apiNote - * The methods {@link #orElse(Object) orElse} and - * {@link #orElseGet(Supplier) orElseGet} - * are generally preferable to this method, as they return a substitute - * value if the value is absent, instead of throwing an exception. + * The preferred alternative to this method is {@link #orElseThrow()}. * * @return the non-{@code null} value described by this {@code Optional} * @throws NoSuchElementException if no value is present - * @see Optional#isPresent() */ public T get() { if (value == null) { @@ -362,6 +359,21 @@ } /** + * If a value is present, returns the value, otherwise throws + * {@code NoSuchElementException}. + * + * @return the non-{@code null} value described by this {@code Optional} + * @throws NoSuchElementException if no value is present + * @since 10 + */ + public T orElseThrow() { + if (value == null) { + throw new NoSuchElementException("No value present"); + } + return value; + } + + /** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/util/OptionalDouble.java --- a/src/java.base/share/classes/java/util/OptionalDouble.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/java/util/OptionalDouble.java Fri Dec 15 16:54:17 2017 +0100 @@ -30,9 +30,10 @@ import java.util.stream.DoubleStream; /** - * A container object which may or may not contain a {@code double} value. If a - * value is present, {@code isPresent()} returns {@code true} and - * {@code getAsDouble()} returns the value. + * A container object which may or may not contain a {@code double} value. + * If a value is present, {@code isPresent()} returns {@code true}. If no + * value is present, the object is considered empty and + * {@code isPresent()} returns {@code false}. * *
Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(double) orElse()} @@ -117,14 +118,10 @@ * {@code NoSuchElementException}. * * @apiNote - * The methods {@link #orElse(double) orElse} and - * {@link #orElseGet(DoubleSupplier) orElseGet} - * are generally preferable to this method, as they return a substitute - * value if the value is absent, instead of throwing an exception. + * The preferred alternative to this method is {@link #orElseThrow()}. * * @return the value described by this {@code OptionalDouble} * @throws NoSuchElementException if no value is present - * @see OptionalDouble#isPresent() */ public double getAsDouble() { if (!isPresent) { @@ -226,6 +223,21 @@ } /** + * If a value is present, returns the value, otherwise throws + * {@code NoSuchElementException}. + * + * @return the value described by this {@code OptionalDouble} + * @throws NoSuchElementException if no value is present + * @since 10 + */ + public double orElseThrow() { + if (!isPresent) { + throw new NoSuchElementException("No value present"); + } + return value; + } + + /** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/util/OptionalInt.java --- a/src/java.base/share/classes/java/util/OptionalInt.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/java/util/OptionalInt.java Fri Dec 15 16:54:17 2017 +0100 @@ -30,9 +30,10 @@ import java.util.stream.IntStream; /** - * A container object which may or may not contain an {@code int} value. If a - * value is present, {@code isPresent()} returns {@code true} and - * {@code getAsInt()} returns the value. + * A container object which may or may not contain an {@code int} value. + * If a value is present, {@code isPresent()} returns {@code true}. If no + * value is present, the object is considered empty and + * {@code isPresent()} returns {@code false}. * *
Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(int) orElse()} @@ -117,14 +118,10 @@ * {@code NoSuchElementException}. * * @apiNote - * The methods {@link #orElse(int) orElse} and - * {@link #orElseGet(IntSupplier) orElseGet} - * are generally preferable to this method, as they return a substitute - * value if the value is absent, instead of throwing an exception. + * The preferred alternative to this method is {@link #orElseThrow()}. * * @return the value described by this {@code OptionalInt} * @throws NoSuchElementException if no value is present - * @see OptionalInt#isPresent() */ public int getAsInt() { if (!isPresent) { @@ -225,6 +222,21 @@ } /** + * If a value is present, returns the value, otherwise throws + * {@code NoSuchElementException}. + * + * @return the value described by this {@code OptionalInt} + * @throws NoSuchElementException if no value is present + * @since 10 + */ + public int orElseThrow() { + if (!isPresent) { + throw new NoSuchElementException("No value present"); + } + return value; + } + + /** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/util/OptionalLong.java --- a/src/java.base/share/classes/java/util/OptionalLong.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/java/util/OptionalLong.java Fri Dec 15 16:54:17 2017 +0100 @@ -30,9 +30,10 @@ import java.util.stream.LongStream; /** - * A container object which may or may not contain a {@code long} value. If a - * value is present, {@code isPresent()} returns {@code true} and - * {@code getAsLong()} returns the value. + * A container object which may or may not contain a {@code long} value. + * If a value is present, {@code isPresent()} returns {@code true}. If no + * value is present, the object is considered empty and + * {@code isPresent()} returns {@code false}. * *
Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(long) orElse()} @@ -117,14 +118,10 @@ * {@code NoSuchElementException}. * * @apiNote - * The methods {@link #orElse(long) orElse} and - * {@link #orElseGet(LongSupplier) orElseGet} - * are generally preferable to this method, as they return a substitute - * value if the value is absent, instead of throwing an exception. + * The preferred alternative to this method is {@link #orElseThrow()}. * * @return the value described by this {@code OptionalLong} * @throws NoSuchElementException if no value is present - * @see OptionalLong#isPresent() */ public long getAsLong() { if (!isPresent) { @@ -225,6 +222,21 @@ } /** + * If a value is present, returns the value, otherwise throws + * {@code NoSuchElementException}. + * + * @return the value described by this {@code OptionalLong} + * @throws NoSuchElementException if no value is present + * @since 10 + */ + public long orElseThrow() { + if (!isPresent) { + throw new NoSuchElementException("No value present"); + } + return value; + } + + /** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/util/jar/JarFile.java --- a/src/java.base/share/classes/java/util/jar/JarFile.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/java/util/jar/JarFile.java Fri Dec 15 16:54:17 2017 +0100 @@ -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 @@ -112,9 +112,9 @@ *
- * {@code jdk.util.jar.version} can be assigned a value that is the * {@code String} representation of a non-negative integer - * {@code <= Runtime.version().major()}. The value is used to set the effective + * {@code <= Runtime.version().feature()}. The value is used to set the effective * runtime version to something other than the default value obtained by - * evaluating {@code Runtime.version().major()}. The effective runtime version + * evaluating {@code Runtime.version().feature()}. The effective runtime version * is the version that the {@link JarFile#JarFile(File, boolean, int, Runtime.Version)} * constructor uses when the value of the last argument is * {@code JarFile.runtimeVersion()}. @@ -143,7 +143,7 @@ public class JarFile extends ZipFile { private final static Runtime.Version BASE_VERSION; - private final static int BASE_VERSION_MAJOR; + private final static int BASE_VERSION_FEATURE; private final static Runtime.Version RUNTIME_VERSION; private final static boolean MULTI_RELEASE_ENABLED; private final static boolean MULTI_RELEASE_FORCED; @@ -153,7 +153,7 @@ private boolean jvInitialized; private boolean verify; private final Runtime.Version version; // current version - private final int versionMajor; // version.major() + private final int versionFeature; // version.feature() private boolean isMultiRelease; // is jar multi-release? // indicates if Class-Path attribute present @@ -170,14 +170,14 @@ JUZFA = jdk.internal.misc.SharedSecrets.getJavaUtilZipFileAccess(); // multi-release jar file versions >= 9 BASE_VERSION = Runtime.Version.parse(Integer.toString(8)); - BASE_VERSION_MAJOR = BASE_VERSION.major(); + BASE_VERSION_FEATURE = BASE_VERSION.feature(); String jarVersion = GetPropertyAction.privilegedGetProperty("jdk.util.jar.version"); - int runtimeVersion = Runtime.version().major(); + int runtimeVersion = Runtime.version().feature(); if (jarVersion != null) { int jarVer = Integer.parseInt(jarVersion); runtimeVersion = (jarVer > runtimeVersion) ? runtimeVersion - : Math.max(jarVer, BASE_VERSION_MAJOR); + : Math.max(jarVer, BASE_VERSION_FEATURE); } RUNTIME_VERSION = Runtime.Version.parse(Integer.toString(runtimeVersion)); String enableMultiRelease = GetPropertyAction @@ -224,10 +224,10 @@ * Returns the version that represents the effective runtime versioned * configuration of a multi-release jar file. *
- * By default the major version number of the returned {@code Version} will - * be equal to the major version number of {@code Runtime.version()}. + * By default the feature version number of the returned {@code Version} will + * be equal to the feature version number of {@code Runtime.version()}. * However, if the {@code jdk.util.jar.version} property is set, the - * returned {@code Version} is derived from that property and major version + * returned {@code Version} is derived from that property and feature version * numbers may not be equal. * * @return the version that represents the runtime versioned configuration @@ -322,7 +322,7 @@ *
* The canonical form derived from the version parameter is * {@code Runtime.Version.parse(Integer.toString(n))} where {@code n} is - * {@code Math.max(version.major(), JarFile.baseVersion().major())}. + * {@code Math.max(version.feature(), JarFile.baseVersion().feature())}. * * @param file the jar file to be opened for reading * @param verify whether or not to verify the jar file if @@ -341,17 +341,17 @@ super(file, mode); this.verify = verify; Objects.requireNonNull(version); - if (MULTI_RELEASE_FORCED || version.major() == RUNTIME_VERSION.major()) { + if (MULTI_RELEASE_FORCED || version.feature() == RUNTIME_VERSION.feature()) { // This deals with the common case where the value from JarFile.runtimeVersion() is passed this.version = RUNTIME_VERSION; - } else if (version.major() <= BASE_VERSION_MAJOR) { + } else if (version.feature() <= BASE_VERSION_FEATURE) { // This also deals with the common case where the value from JarFile.baseVersion() is passed this.version = BASE_VERSION; } else { // Canonicalize - this.version = Runtime.Version.parse(Integer.toString(version.major())); + this.version = Runtime.Version.parse(Integer.toString(version.feature())); } - this.versionMajor = this.version.major(); + this.versionFeature = this.version.feature(); } /** @@ -579,7 +579,7 @@ // filter out dir META-INF/versions/ and META-INF/versions/*/ // and any entry with version > 'version' if (index == -1 || index == (name.length() - 1) || - Integer.parseInt(name, off, index, 10) > versionMajor) { + Integer.parseInt(name, off, index, 10) > versionFeature) { return null; } } catch (NumberFormatException x) { @@ -592,11 +592,11 @@ } private JarEntry getVersionedEntry(String name, JarEntry je) { - if (BASE_VERSION_MAJOR < versionMajor) { + if (BASE_VERSION_FEATURE < versionFeature) { if (!name.startsWith(META_INF)) { // search for versioned entry - int v = versionMajor; - while (v > BASE_VERSION_MAJOR) { + int v = versionFeature; + while (v > BASE_VERSION_FEATURE) { JarFileEntry vje = getEntry0(META_INF_VERSIONS + v + "/" + name); if (vje != null) { return vje.withBasename(name); @@ -673,7 +673,7 @@ } JarFileEntry realEntry() { - if (isMultiRelease() && versionMajor != BASE_VERSION_MAJOR) { + if (isMultiRelease() && versionFeature != BASE_VERSION_FEATURE) { String entryName = super.getName(); return entryName == basename || entryName.equals(basename) ? this : new JarFileEntry(entryName, this); diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/util/zip/Deflater.java --- a/src/java.base/share/classes/java/util/zip/Deflater.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/java/util/zip/Deflater.java Fri Dec 15 16:54:17 2017 +0100 @@ -25,6 +25,9 @@ package java.util.zip; +import java.lang.ref.Cleaner.Cleanable; +import jdk.internal.ref.CleanerFactory; + /** * This class provides support for general purpose compression using the * popular ZLIB compression library. The ZLIB compression library was @@ -88,7 +91,7 @@ public class Deflater { - private final ZStreamRef zsRef; + private final DeflaterZStreamRef zsRef; private byte[] buf = new byte[0]; private int off, len; private int level, strategy; @@ -183,9 +186,8 @@ public Deflater(int level, boolean nowrap) { this.level = level; this.strategy = DEFAULT_STRATEGY; - this.zsRef = ZStreamRef.get(this, - () -> init(level, DEFAULT_STRATEGY, nowrap), - Deflater::end); + this.zsRef = DeflaterZStreamRef.get(this, + init(level, DEFAULT_STRATEGY, nowrap)); } /** @@ -591,4 +593,75 @@ private static native int getAdler(long addr); private static native void reset(long addr); private static native void end(long addr); + + /** + * A reference to the native zlib's z_stream structure. It also + * serves as the "cleaner" to clean up the native resource when + * the Deflater is ended, closed or cleaned. + */ + static class DeflaterZStreamRef implements Runnable { + + private long address; + private final Cleanable cleanable; + + private DeflaterZStreamRef(Deflater owner, long addr) { + this.cleanable = (owner != null) ? CleanerFactory.cleaner().register(owner, this) : null; + this.address = addr; + } + + long address() { + return address; + } + + void clean() { + cleanable.clean(); + } + + public synchronized void run() { + long addr = address; + address = 0; + if (addr != 0) { + end(addr); + } + } + + /* + * If {@code Deflater} has been subclassed and the {@code end} method is + * overridden, uses {@code finalizer} mechanism for resource cleanup. So + * {@code end} method can be called when the {@code Deflater} is unreachable. + * This mechanism will be removed when the {@code finalize} method is + * removed from {@code Deflater}. + */ + static DeflaterZStreamRef get(Deflater owner, long addr) { + Class> clz = owner.getClass(); + while (clz != Deflater.class) { + try { + clz.getDeclaredMethod("end"); + return new FinalizableZStreamRef(owner, addr); + } catch (NoSuchMethodException nsme) {} + clz = clz.getSuperclass(); + } + return new DeflaterZStreamRef(owner, addr); + } + + private static class FinalizableZStreamRef extends DeflaterZStreamRef { + final Deflater owner; + + FinalizableZStreamRef (Deflater owner, long addr) { + super(null, addr); + this.owner = owner; + } + + @Override + void clean() { + run(); + } + + @Override + @SuppressWarnings("deprecation") + protected void finalize() { + owner.end(); + } + } + } } diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/util/zip/Inflater.java --- a/src/java.base/share/classes/java/util/zip/Inflater.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/java/util/zip/Inflater.java Fri Dec 15 16:54:17 2017 +0100 @@ -25,8 +25,8 @@ package java.util.zip; -import java.util.function.LongConsumer; -import java.util.function.LongSupplier; +import java.lang.ref.Cleaner.Cleanable; +import jdk.internal.ref.CleanerFactory; /** * This class provides support for general purpose decompression using the @@ -91,7 +91,7 @@ public class Inflater { - private final ZStreamRef zsRef; + private final InflaterZStreamRef zsRef; private byte[] buf = defaultBuf; private int off, len; private boolean finished; @@ -118,20 +118,7 @@ * @param nowrap if true then support GZIP compatible compression */ public Inflater(boolean nowrap) { - this.zsRef = ZStreamRef.get(this, - // Desugared for startup purposes. - new LongSupplier() { - @Override - public long getAsLong() { - return init(nowrap); - } - }, - new LongConsumer() { - @Override - public void accept(long value) { - end(); - } - }); + this.zsRef = InflaterZStreamRef.get(this, init(nowrap)); } /** @@ -444,4 +431,75 @@ private static native int getAdler(long addr); private static native void reset(long addr); private static native void end(long addr); + + /** + * A reference to the native zlib's z_stream structure. It also + * serves as the "cleaner" to clean up the native resource when + * the Inflater is ended, closed or cleaned. + */ + static class InflaterZStreamRef implements Runnable { + + private long address; + private final Cleanable cleanable; + + private InflaterZStreamRef(Inflater owner, long addr) { + this.cleanable = (owner != null) ? CleanerFactory.cleaner().register(owner, this) : null; + this.address = addr; + } + + long address() { + return address; + } + + void clean() { + cleanable.clean(); + } + + public synchronized void run() { + long addr = address; + address = 0; + if (addr != 0) { + end(addr); + } + } + + /* + * If {@code Inflater} has been subclassed and the {@code end} method is + * overridden, uses {@code finalizer} mechanism for resource cleanup. So + * {@code end} method can be called when the {@code Inflater} is unreachable. + * This mechanism will be removed when the {@code finalize} method is + * removed from {@code Inflater}. + */ + static InflaterZStreamRef get(Inflater owner, long addr) { + Class> clz = owner.getClass(); + while (clz != Inflater.class) { + try { + clz.getDeclaredMethod("end"); + return new FinalizableZStreamRef(owner, addr); + } catch (NoSuchMethodException nsme) {} + clz = clz.getSuperclass(); + } + return new InflaterZStreamRef(owner, addr); + } + + private static class FinalizableZStreamRef extends InflaterZStreamRef { + final Inflater owner; + + FinalizableZStreamRef(Inflater owner, long addr) { + super(null, addr); + this.owner = owner; + } + + @Override + void clean() { + run(); + } + + @Override + @SuppressWarnings("deprecation") + protected void finalize() { + owner.end(); + } + } + } } diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/util/zip/ZStreamRef.java --- a/src/java.base/share/classes/java/util/zip/ZStreamRef.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. - * 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 java.util.zip; - -import java.util.function.LongConsumer; -import java.util.function.LongSupplier; -import java.lang.ref.Cleaner.Cleanable; -import jdk.internal.ref.CleanerFactory; - -/** - * A reference to the native zlib's z_stream structure. It also - * serves as the "cleaner" to clean up the native resource when - * the deflater or infalter is ended, closed or cleaned. - */ -class ZStreamRef implements Runnable { - - private LongConsumer end; - private long address; - private final Cleanable cleanable; - - private ZStreamRef (Object owner, LongSupplier addr, LongConsumer end) { - this.cleanable = CleanerFactory.cleaner().register(owner, this); - this.end = end; - this.address = addr.getAsLong(); - } - - long address() { - return address; - } - - void clean() { - cleanable.clean(); - } - - public synchronized void run() { - long addr = address; - address = 0; - if (addr != 0) { - end.accept(addr); - } - } - - private ZStreamRef (LongSupplier addr, LongConsumer end) { - this.cleanable = null; - this.end = end; - this.address = addr.getAsLong(); - } - - /* - * If {@code Inflater/Deflater} has been subclassed and the {@code end} method - * is overridden, uses {@code finalizer} mechanism for resource cleanup. So - * {@code end} method can be called when the {@code Inflater/Deflater} is - * unreachable. This mechanism will be removed when the {@code finalize} method - * is removed from {@code Inflater/Deflater}. - */ - static ZStreamRef get(Object owner, LongSupplier addr, LongConsumer end) { - Class> clz = owner.getClass(); - while (clz != Deflater.class && clz != Inflater.class) { - try { - clz.getDeclaredMethod("end"); - return new FinalizableZStreamRef(owner, addr, end); - } catch (NoSuchMethodException nsme) {} - clz = clz.getSuperclass(); - } - return new ZStreamRef(owner, addr, end); - } - - private static class FinalizableZStreamRef extends ZStreamRef { - final Object owner; - - FinalizableZStreamRef (Object owner, LongSupplier addr, LongConsumer end) { - super(addr, end); - this.owner = owner; - } - - @Override - void clean() { - run(); - } - - @Override - @SuppressWarnings("deprecation") - protected void finalize() { - if (owner instanceof Inflater) - ((Inflater)owner).end(); - else - ((Deflater)owner).end(); - } - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/java/util/zip/ZipFile.java --- a/src/java.base/share/classes/java/util/zip/ZipFile.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/java/util/zip/ZipFile.java Fri Dec 15 16:54:17 2017 +0100 @@ -412,6 +412,21 @@ } } + private static class InflaterCleanupAction implements Runnable { + private final Inflater inf; + private final CleanableResource res; + + InflaterCleanupAction(Inflater inf, CleanableResource res) { + this.inf = inf; + this.res = res; + } + + @Override + public void run() { + res.releaseInflater(inf); + } + } + private class ZipFileInflaterInputStream extends InflaterInputStream { private volatile boolean closeRequested; private boolean eof = false; @@ -427,13 +442,8 @@ Inflater inf, int size) { super(zfin, inf, size); this.cleanable = CleanerFactory.cleaner().register(this, - new Runnable() { - @Override - public void run() { - res.releaseInflater(inf); - } - }); - } + new InflaterCleanupAction(inf, res)); + } public void close() throws IOException { if (closeRequested) diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/classes/sun/security/tools/keytool/Main.java --- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java Fri Dec 15 16:54:17 2017 +0100 @@ -1058,11 +1058,6 @@ System.err.println(form.format(source)); keyPass = storePass; } - if (newPass != null && !Arrays.equals(storePass, newPass)) { - Object[] source = {"-new"}; - System.err.println(form.format(source)); - newPass = storePass; - } if (destKeyPass != null && !Arrays.equals(storePass, destKeyPass)) { Object[] source = {"-destkeypass"}; System.err.println(form.format(source)); @@ -1243,10 +1238,7 @@ doSelfCert(alias, dname, sigAlgName); kssave = true; } else if (command == STOREPASSWD) { - storePassNew = newPass; - if (storePassNew == null) { - storePassNew = getNewPasswd("keystore password", storePass); - } + doChangeStorePasswd(); kssave = true; } else if (command == GENCERT) { if (alias == null) { @@ -2258,8 +2250,9 @@ newPass = destKeyPass; pp = new PasswordProtection(destKeyPass); } else if (objs.snd != null) { - newPass = objs.snd; - pp = new PasswordProtection(objs.snd); + newPass = P12KEYSTORE.equalsIgnoreCase(storetype) ? + storePass : objs.snd; + pp = new PasswordProtection(newPass); } try { @@ -2762,6 +2755,28 @@ } } } + + private void doChangeStorePasswd() throws Exception { + storePassNew = newPass; + if (storePassNew == null) { + storePassNew = getNewPasswd("keystore password", storePass); + } + if (P12KEYSTORE.equalsIgnoreCase(storetype)) { + // When storetype is PKCS12, we need to change all keypass as well + for (String alias : Collections.list(keyStore.aliases())) { + if (!keyStore.isCertificateEntry(alias)) { + // keyPass should be either null or same with storePass, + // but keep it in case one day we want to "normalize" + // a PKCS12 keystore having different passwords. + Pair
objs + = recoverEntry(keyStore, alias, storePass, keyPass); + keyStore.setEntry(alias, objs.fst, + new PasswordProtection(storePassNew)); + } + } + } + } + /** * Creates a self-signed certificate, and stores it as a single-element * certificate chain. diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.base/share/native/libjava/jdk_util.c --- a/src/java.base/share/native/libjava/jdk_util.c Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.base/share/native/libjava/jdk_util.c Fri Dec 15 16:54:17 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, 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 @@ -34,9 +34,9 @@ JNIEXPORT void JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) { /* These VERSION_* macros are given by the build system */ - const unsigned int version_major = VERSION_MAJOR; - const unsigned int version_minor = VERSION_MINOR; - const unsigned int version_security = VERSION_SECURITY; + const unsigned int version_major = VERSION_FEATURE; + const unsigned int version_minor = VERSION_INTERIM; + const unsigned int version_security = VERSION_UPDATE; const unsigned int version_patch = VERSION_PATCH; const unsigned int version_build = VERSION_BUILD; diff -r 474cec233fb2 -r 0c0b618a20b1 src/java.compiler/share/classes/javax/lang/model/SourceVersion.java --- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java Fri Dec 15 16:54:17 2017 +0100 @@ -56,7 +56,7 @@ * 1.7: diamond syntax, try-with-resources, etc. * 1.8: lambda expressions and default methods * 9: modules, small cleanups to 1.7 and 1.8 changes - * 10: to-be-determined changes + * 10: local-variable type inference (var) */ /** @@ -157,6 +157,9 @@ * The version recognized by the Java Platform, Standard Edition * 10. * + * Additions in this release include local-variable type inference + * ({@code var}). + * * @since 10 */ RELEASE_10; diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/Gen.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/Gen.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,383 +0,0 @@ -/* - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -import java.io.ByteArrayOutputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.nio.file.NoSuchFileException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.Stack; - -import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.Elements; -import javax.lang.model.util.Types; -import javax.tools.FileObject; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; -import javax.tools.StandardLocation; - -/** - * An abstraction for generating support files required by native methods. - * Subclasses are for specific native interfaces. At the time of its - * original writing, this interface is rich enough to support JNI and the - * old 1.0-style native method interface. - * - * 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.
- * - * @author Sucheta Dambalkar(Revised) - */ -public abstract class Gen { - protected String lineSep = System.getProperty("line.separator"); - - protected ProcessingEnvironment processingEnvironment; - protected Types types; - protected Elements elems; - protected Mangle mangler; - protected Util util; - - protected Gen(Util util) { - this.util = util; - } - - /* - * List of classes for which we must generate output. - */ - protected Setclasses; - static private final boolean isWindows = - System.getProperty("os.name").startsWith("Windows"); - - - /** - * Override this abstract method, generating content for the named - * class into the outputstream. - */ - protected abstract void write(OutputStream o, TypeElement clazz) throws Util.Exit; - - /** - * Override this method to provide a list of #include statements - * required by the native interface. - */ - protected abstract String getIncludes(); - - /* - * Output location. - */ - protected JavaFileManager fileManager; - protected JavaFileObject outFile; - - public void setFileManager(JavaFileManager fm) { - fileManager = fm; - } - - public void setOutFile(JavaFileObject outFile) { - this.outFile = outFile; - } - - - public void setClasses(Set classes) { - this.classes = classes; - } - - void setProcessingEnvironment(ProcessingEnvironment pEnv) { - processingEnvironment = pEnv; - elems = pEnv.getElementUtils(); - types = pEnv.getTypeUtils(); - mangler = new Mangle(elems, types); - } - - /* - * Smartness with generated files. - */ - protected boolean force = false; - - public void setForce(boolean state) { - force = state; - } - - /** - * We explicitly need to write ASCII files because that is what C - * compilers understand. - */ - protected PrintWriter wrapWriter(OutputStream o) throws Util.Exit { - try { - return new PrintWriter(new OutputStreamWriter(o, "ISO8859_1"), true); - } catch (UnsupportedEncodingException use) { - util.bug("encoding.iso8859_1.not.found"); - return null; /* dead code */ - } - } - - /** - * After initializing state of an instance, use this method to start - * processing. - * - * Buffer size chosen as an approximation from a single sampling of: - * expr `du -sk` / `ls *.h | wc -l` - */ - public void run() throws IOException, ClassNotFoundException, Util.Exit { - int i = 0; - if (outFile != null) { - /* Everything goes to one big file... */ - ByteArrayOutputStream bout = new ByteArrayOutputStream(8192); - writeFileTop(bout); /* only once */ - - for (TypeElement t: classes) { - write(bout, t); - } - - writeIfChanged(bout.toByteArray(), outFile); - } else { - /* Each class goes to its own file... */ - for (TypeElement t: classes) { - ByteArrayOutputStream bout = new ByteArrayOutputStream(8192); - writeFileTop(bout); - write(bout, t); - writeIfChanged(bout.toByteArray(), getFileObject(t.getQualifiedName())); - } - } - } - - /* - * Write the contents of byte[] b to a file named file. Writing - * is done if either the file doesn't exist or if the contents are - * different. - */ - private void writeIfChanged(byte[] b, FileObject file) throws IOException { - boolean mustWrite = false; - String event = "[No need to update file "; - - if (force) { - mustWrite = true; - event = "[Forcefully writing file "; - } else { - InputStream in; - byte[] a; - try { - // regrettably, there's no API to get the length in bytes - // for a FileObject, so we can't short-circuit reading the - // file here - in = file.openInputStream(); - a = readBytes(in); - if (!Arrays.equals(a, b)) { - mustWrite = true; - event = "[Overwriting file "; - - } - } catch (FileNotFoundException | NoSuchFileException e) { - mustWrite = true; - event = "[Creating file "; - } - } - - if (util.verbose) - util.log(event + file + "]"); - - if (mustWrite) { - OutputStream out = file.openOutputStream(); - out.write(b); /* No buffering, just one big write! */ - out.close(); - } - } - - protected byte[] readBytes(InputStream in) throws IOException { - try { - byte[] array = new byte[in.available() + 1]; - int offset = 0; - int n; - while ((n = in.read(array, offset, array.length - offset)) != -1) { - offset += n; - if (offset == array.length) - array = Arrays.copyOf(array, array.length * 2); - } - - return Arrays.copyOf(array, offset); - } finally { - in.close(); - } - } - - protected String defineForStatic(TypeElement c, VariableElement f) - throws Util.Exit { - CharSequence cnamedoc = c.getQualifiedName(); - CharSequence fnamedoc = f.getSimpleName(); - - String cname = mangler.mangle(cnamedoc, Mangle.Type.CLASS); - String fname = mangler.mangle(fnamedoc, Mangle.Type.FIELDSTUB); - - if (!f.getModifiers().contains(Modifier.STATIC)) - util.bug("tried.to.define.non.static"); - - if (f.getModifiers().contains(Modifier.FINAL)) { - Object value = null; - - value = f.getConstantValue(); - - if (value != null) { /* so it is a ConstantExpression */ - String constString = null; - if ((value instanceof Integer) - || (value instanceof Byte) - || (value instanceof Short)) { - /* covers byte, short, int */ - constString = value.toString() + "L"; - } else if (value instanceof Boolean) { - constString = ((Boolean) value) ? "1L" : "0L"; - } else if (value instanceof Character) { - Character ch = (Character) value; - constString = String.valueOf(((int) ch) & 0xffff) + "L"; - } else if (value instanceof Long) { - // Visual C++ supports the i64 suffix, not LL. - if (isWindows) - constString = value.toString() + "i64"; - else - constString = value.toString() + "LL"; - } else if (value instanceof Float) { - /* bug for bug */ - float fv = ((Float)value).floatValue(); - if (Float.isInfinite(fv)) - constString = ((fv < 0) ? "-" : "") + "Inff"; - else - constString = value.toString() + "f"; - } else if (value instanceof Double) { - /* bug for bug */ - double d = ((Double)value).doubleValue(); - if (Double.isInfinite(d)) - constString = ((d < 0) ? "-" : "") + "InfD"; - else - constString = value.toString(); - } - if (constString != null) { - StringBuilder s = new StringBuilder("#undef "); - s.append(cname); s.append("_"); s.append(fname); s.append(lineSep); - s.append("#define "); s.append(cname); s.append("_"); - s.append(fname); s.append(" "); s.append(constString); - return s.toString(); - } - - } - } - return null; - } - - /* - * Deal with the C pre-processor. - */ - protected String cppGuardBegin() { - return "#ifdef __cplusplus" + lineSep + "extern \"C\" {" + lineSep + "#endif"; - } - - protected String cppGuardEnd() { - return "#ifdef __cplusplus" + lineSep + "}" + lineSep + "#endif"; - } - - protected String guardBegin(String cname) { - return "/* Header for class " + cname + " */" + lineSep + lineSep + - "#ifndef _Included_" + cname + lineSep + - "#define _Included_" + cname; - } - - protected String guardEnd(String cname) { - return "#endif"; - } - - /* - * File name and file preamble related operations. - */ - protected void writeFileTop(OutputStream o) throws Util.Exit { - PrintWriter pw = wrapWriter(o); - pw.println("/* DO NOT EDIT THIS FILE - it is machine generated */" + lineSep + - getIncludes()); - } - - protected String baseFileName(CharSequence className) { - return mangler.mangle(className, Mangle.Type.CLASS); - } - - protected FileObject getFileObject(CharSequence className) throws IOException { - String name = baseFileName(className) + getFileSuffix(); - return fileManager.getFileForOutput(StandardLocation.SOURCE_OUTPUT, "", name, null); - } - - protected String getFileSuffix() { - return ".h"; - } - - /** - * Including super classes' fields. - */ - - List getAllFields(TypeElement subclazz) { - List fields = new ArrayList<>(); - TypeElement cd = null; - Stack s = new Stack<>(); - - cd = subclazz; - while (true) { - s.push(cd); - TypeElement c = (TypeElement) (types.asElement(cd.getSuperclass())); - if (c == null) - break; - cd = c; - } - - while (!s.empty()) { - cd = s.pop(); - fields.addAll(ElementFilter.fieldsIn(cd.getEnclosedElements())); - } - - return fields; - } - - // c.f. MethodDoc.signature - String signature(ExecutableElement e) { - StringBuilder sb = new StringBuilder("("); - String sep = ""; - for (VariableElement p: e.getParameters()) { - sb.append(sep); - sb.append(types.erasure(p.asType()).toString()); - sep = ","; - } - sb.append(")"); - return sb.toString(); - } -} - diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/InternalError.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/InternalError.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -/** - * 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. - */ -public class InternalError extends Error { - private static final long serialVersionUID = 8411861562497165022L; - InternalError(String msg, Throwable cause) { - super("Internal error: " + msg); - initCause(cause); - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/JNI.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/JNI.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -import java.io.OutputStream; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.ArrayType; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; - - -/** - * Header file generator for JNI. - * - *
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.
- * - * @author Sucheta Dambalkar(Revised) - */ -public class JNI extends Gen { - JNI(Util util) { - super(util); - } - - public String getIncludes() { - return "#include"; - } - - public void write(OutputStream o, TypeElement clazz) throws Util.Exit { - try { - String cname = mangler.mangle(clazz.getQualifiedName(), Mangle.Type.CLASS); - PrintWriter pw = wrapWriter(o); - pw.println(guardBegin(cname)); - pw.println(cppGuardBegin()); - - /* Write statics. */ - List classfields = getAllFields(clazz); - - for (VariableElement v: classfields) { - if (!v.getModifiers().contains(Modifier.STATIC)) - continue; - String s = null; - s = defineForStatic(clazz, v); - if (s != null) { - pw.println(s); - } - } - - /* Write methods. */ - List classmethods = ElementFilter.methodsIn(clazz.getEnclosedElements()); - for (ExecutableElement md: classmethods) { - if(md.getModifiers().contains(Modifier.NATIVE)){ - TypeMirror mtr = types.erasure(md.getReturnType()); - String sig = signature(md); - TypeSignature newtypesig = new TypeSignature(elems); - CharSequence methodName = md.getSimpleName(); - boolean longName = false; - for (ExecutableElement md2: classmethods) { - if ((md2 != md) - && (methodName.equals(md2.getSimpleName())) - && (md2.getModifiers().contains(Modifier.NATIVE))) - longName = true; - - } - pw.println("/*"); - pw.println(" * Class: " + cname); - pw.println(" * Method: " + - mangler.mangle(methodName, Mangle.Type.FIELDSTUB)); - pw.println(" * Signature: " + newtypesig.getTypeSignature(sig, mtr)); - pw.println(" */"); - pw.println("JNIEXPORT " + jniType(mtr) + - " JNICALL " + - mangler.mangleMethod(md, clazz, - (longName) ? - Mangle.Type.METHOD_JNI_LONG : - Mangle.Type.METHOD_JNI_SHORT)); - pw.print(" (JNIEnv *, "); - List extends VariableElement> paramargs = md.getParameters(); - List args = new ArrayList<>(); - for (VariableElement p: paramargs) { - args.add(types.erasure(p.asType())); - } - if (md.getModifiers().contains(Modifier.STATIC)) - pw.print("jclass"); - else - pw.print("jobject"); - - for (TypeMirror arg: args) { - pw.print(", "); - pw.print(jniType(arg)); - } - pw.println(");" + lineSep); - } - } - pw.println(cppGuardEnd()); - pw.println(guardEnd(cname)); - } catch (TypeSignature.SignatureException e) { - util.error("jni.sigerror", e.getMessage()); - } - } - - - protected final String jniType(TypeMirror t) throws Util.Exit { - TypeElement throwable = elems.getTypeElement("java.lang.Throwable"); - TypeElement jClass = elems.getTypeElement("java.lang.Class"); - TypeElement jString = elems.getTypeElement("java.lang.String"); - Element tclassDoc = types.asElement(t); - - - switch (t.getKind()) { - case ARRAY: { - TypeMirror ct = ((ArrayType) t).getComponentType(); - switch (ct.getKind()) { - case BOOLEAN: return "jbooleanArray"; - case BYTE: return "jbyteArray"; - case CHAR: return "jcharArray"; - case SHORT: return "jshortArray"; - case INT: return "jintArray"; - case LONG: return "jlongArray"; - case FLOAT: return "jfloatArray"; - case DOUBLE: return "jdoubleArray"; - case ARRAY: - case DECLARED: return "jobjectArray"; - default: throw new Error(ct.toString()); - } - } - - case VOID: return "void"; - case BOOLEAN: return "jboolean"; - case BYTE: return "jbyte"; - case CHAR: return "jchar"; - case SHORT: return "jshort"; - case INT: return "jint"; - case LONG: return "jlong"; - case FLOAT: return "jfloat"; - case DOUBLE: return "jdouble"; - - case DECLARED: { - if (tclassDoc.equals(jString)) - return "jstring"; - else if (types.isAssignable(t, throwable.asType())) - return "jthrowable"; - else if (types.isAssignable(t, jClass.asType())) - return "jclass"; - else - return "jobject"; - } - } - - util.bug("jni.unknown.type"); - return null; /* dead code. */ - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/JavahFileManager.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/JavahFileManager.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -import java.io.PrintWriter; -import java.nio.charset.Charset; -import javax.tools.DiagnosticListener; -import javax.tools.JavaFileObject; - -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.util.Context; - -/** - * javah's implementation of JavaFileManager. - * - * 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. - */ -class JavahFileManager extends JavacFileManager { - private JavahFileManager(Context context, Charset charset) { - super(context, true, charset); - setSymbolFileEnabled(false); - } - - static JavahFileManager create(final DiagnosticListener super JavaFileObject> dl, PrintWriter log) { - Context javac_context = new Context(); - - if (dl != null) - javac_context.put(DiagnosticListener.class, dl); - javac_context.put(com.sun.tools.javac.util.Log.errKey, log); - - return new JavahFileManager(javac_context, null); - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,775 +0,0 @@ -/* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.io.Writer; -import java.nio.file.NoSuchFileException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.Objects; -import java.util.ResourceBundle; -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.Messager; -import javax.annotation.processing.ProcessingEnvironment; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.ArrayType; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.type.TypeVisitor; -import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.SimpleTypeVisitor9; -import javax.lang.model.util.Types; -import javax.tools.Diagnostic; -import javax.tools.DiagnosticListener; -import javax.tools.JavaCompiler; -import javax.tools.JavaCompiler.CompilationTask; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.StandardLocation; -import javax.tools.ToolProvider; - -import com.sun.tools.javac.code.Symbol.CompletionFailure; -import com.sun.tools.javac.main.CommandLine; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; - -import static javax.tools.Diagnostic.Kind.*; - - -/** - * Javah generates support files for native methods. - * Parse commandline options and invokes javadoc to execute those commands. - * - *
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.
- * - * @author Sucheta Dambalkar - * @author Jonathan Gibbons - */ -public class JavahTask implements NativeHeaderTool.NativeHeaderTask { - public class BadArgs extends Exception { - private static final long serialVersionUID = 1479361270874789045L; - BadArgs(String key, Object... args) { - super(JavahTask.this.getMessage(key, args)); - this.key = key; - this.args = args; - } - - BadArgs showUsage(boolean b) { - showUsage = b; - return this; - } - - final String key; - final Object[] args; - boolean showUsage; - } - - static abstract class Option { - Option(boolean hasArg, String... aliases) { - this.hasArg = hasArg; - this.aliases = aliases; - } - - boolean isHidden() { - return false; - } - - boolean matches(String opt) { - for (String a: aliases) { - if (a.equals(opt)) - return true; - } - return false; - } - - boolean ignoreRest() { - return false; - } - - abstract void process(JavahTask task, String opt, String arg) throws BadArgs; - - final boolean hasArg; - final String[] aliases; - } - - static abstract class HiddenOption extends Option { - HiddenOption(boolean hasArg, String... aliases) { - super(hasArg, aliases); - } - - @Override - boolean isHidden() { - return true; - } - } - - static final Option[] recognizedOptions = { - new Option(true, "-o") { - void process(JavahTask task, String opt, String arg) { - task.ofile = new File(arg); - } - }, - - new Option(true, "-d") { - void process(JavahTask task, String opt, String arg) { - task.odir = new File(arg); - } - }, - - new HiddenOption(true, "-td") { - void process(JavahTask task, String opt, String arg) { - // ignored; for backwards compatibility - } - }, - - new Option(false, "-v", "-verbose") { - void process(JavahTask task, String opt, String arg) { - task.verbose = true; - } - }, - - new Option(false, "-h", "-help", "--help", "-?") { - void process(JavahTask task, String opt, String arg) { - task.help = true; - } - }, - - new HiddenOption(false, "-trace") { - void process(JavahTask task, String opt, String arg) { - task.trace = true; - } - }, - - new Option(false, "-version") { - void process(JavahTask task, String opt, String arg) { - task.version = true; - } - }, - - new HiddenOption(false, "-fullversion") { - void process(JavahTask task, String opt, String arg) { - task.fullVersion = true; - } - }, - - new Option(false, "-jni") { - void process(JavahTask task, String opt, String arg) { - task.jni = true; - } - }, - - new Option(false, "-force") { - void process(JavahTask task, String opt, String arg) { - task.force = true; - } - }, - - new HiddenOption(false, "-Xnew") { - void process(JavahTask task, String opt, String arg) { - // we're already using the new javah - } - }, - - new HiddenOption(false, "-llni", "-Xllni") { - void process(JavahTask task, String opt, String arg) { - task.llni = true; - } - }, - - new HiddenOption(false, "-llnidouble") { - void process(JavahTask task, String opt, String arg) { - task.llni = true; - task.doubleAlign = true; - } - }, - - new HiddenOption(false) { - boolean matches(String opt) { - return opt.startsWith("-XD"); - } - void process(JavahTask task, String opt, String arg) { - task.javac_extras.add(opt); - } - }, - }; - - JavahTask() { - } - - JavahTask(Writer out, - JavaFileManager fileManager, - DiagnosticListener super JavaFileObject> diagnosticListener, - Iterableoptions, - Iterable classes) { - this(); - this.log = getPrintWriterForWriter(out); - this.fileManager = fileManager; - this.diagnosticListener = diagnosticListener; - - try { - handleOptions(options, false); - } catch (BadArgs e) { - throw new IllegalArgumentException(e.getMessage()); - } - - this.classes = new ArrayList<>(); - if (classes != null) { - for (String classname: classes) { - Objects.requireNonNull(classname); - this.classes.add(classname); - } - } - } - - public void setLocale(Locale locale) { - if (locale == null) - locale = Locale.getDefault(); - task_locale = locale; - } - - public void setLog(PrintWriter log) { - this.log = log; - } - - public void setLog(OutputStream s) { - setLog(getPrintWriterForStream(s)); - } - - static PrintWriter getPrintWriterForStream(OutputStream s) { - return new PrintWriter(s, true); - } - - static PrintWriter getPrintWriterForWriter(Writer w) { - if (w == null) - return getPrintWriterForStream(null); - else if (w instanceof PrintWriter) - return (PrintWriter) w; - else - return new PrintWriter(w, true); - } - - public void setDiagnosticListener(DiagnosticListener super JavaFileObject> dl) { - diagnosticListener = dl; - } - - public void setDiagnosticListener(OutputStream s) { - setDiagnosticListener(getDiagnosticListenerForStream(s)); - } - - private DiagnosticListener getDiagnosticListenerForStream(OutputStream s) { - return getDiagnosticListenerForWriter(getPrintWriterForStream(s)); - } - - private DiagnosticListener getDiagnosticListenerForWriter(Writer w) { - final PrintWriter pw = getPrintWriterForWriter(w); - return diagnostic -> { - if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { - pw.print(getMessage("err.prefix")); - pw.print(" "); - } - pw.println(diagnostic.getMessage(null)); - }; - } - - int run(String[] args) { - try { - handleOptions(args); - boolean ok = run(); - return ok ? 0 : 1; - } catch (BadArgs e) { - diagnosticListener.report(createDiagnostic(e.key, e.args)); - return 1; - } catch (InternalError e) { - diagnosticListener.report(createDiagnostic("err.internal.error", e.getMessage())); - return 1; - } catch (Util.Exit e) { - return e.exitValue; - } finally { - log.flush(); - } - } - - public void handleOptions(String[] args) throws BadArgs { - handleOptions(Arrays.asList(args), true); - } - - private void handleOptions(Iterable args, boolean allowClasses) throws BadArgs { - if (log == null) { - log = getPrintWriterForStream(System.out); - if (diagnosticListener == null) - diagnosticListener = getDiagnosticListenerForStream(System.err); - } else { - if (diagnosticListener == null) - diagnosticListener = getDiagnosticListenerForWriter(log); - } - - if (fileManager == null) - fileManager = getDefaultFileManager(diagnosticListener, log); - - Iterator iter = expandAtArgs(args).iterator(); - noArgs = !iter.hasNext(); - - while (iter.hasNext()) { - String arg = iter.next(); - if (arg.startsWith("-")) - handleOption(arg, iter); - else if (allowClasses) { - if (classes == null) - classes = new ArrayList<>(); - classes.add(arg); - while (iter.hasNext()) - classes.add(iter.next()); - } else - throw new BadArgs("err.unknown.option", arg).showUsage(true); - } - - if ((classes == null || classes.size() == 0) && - !(noArgs || help || version || fullVersion)) { - throw new BadArgs("err.no.classes.specified"); - } - - if (jni && llni) - throw new BadArgs("jni.llni.mixed"); - - if (odir != null && ofile != null) - throw new BadArgs("dir.file.mixed"); - } - - private void handleOption(String name, Iterator rest) throws BadArgs { - for (Option o: recognizedOptions) { - if (o.matches(name)) { - if (o.hasArg) { - if (rest.hasNext()) - o.process(this, name, rest.next()); - else - throw new BadArgs("err.missing.arg", name).showUsage(true); - } else - o.process(this, name, null); - - if (o.ignoreRest()) { - while (rest.hasNext()) - rest.next(); - } - return; - } - } - - if (fileManager.handleOption(name, rest)) - return; - - throw new BadArgs("err.unknown.option", name).showUsage(true); - } - - private Iterable expandAtArgs(Iterable args) throws BadArgs { - try { - List l = new ArrayList<>(); - for (String arg: args) l.add(arg); - return Arrays.asList(CommandLine.parse(l.toArray(new String[l.size()]))); - } catch (FileNotFoundException | NoSuchFileException e) { - throw new BadArgs("at.args.file.not.found", e.getLocalizedMessage()); - } catch (IOException e) { - throw new BadArgs("at.args.io.exception", e.getLocalizedMessage()); - } - } - - public Boolean call() { - return run(); - } - - public boolean run() throws Util.Exit { - - if (!javac_extras.contains("-XDsuppress-tool-removal-message")) { - log.println(getMessage("javah.misc.Deprecation")); - } - - Util util = new Util(log, diagnosticListener); - - if (noArgs || help) { - showHelp(); - return help; // treat noArgs as an error for purposes of exit code - } - - if (version || fullVersion) { - showVersion(fullVersion); - return true; - } - - util.verbose = verbose; - - Gen g; - - if (llni) - g = new LLNI(doubleAlign, util); - else { - g = new JNI(util); - } - - if (ofile != null) { - if (!(fileManager instanceof StandardJavaFileManager)) { - diagnosticListener.report(createDiagnostic("err.cant.use.option.for.fm", "-o")); - return false; - } - Iterable extends JavaFileObject> iter = - ((StandardJavaFileManager) fileManager).getJavaFileObjectsFromFiles(Collections.singleton(ofile)); - JavaFileObject fo = iter.iterator().next(); - g.setOutFile(fo); - } else { - if (odir != null) { - if (!(fileManager instanceof StandardJavaFileManager)) { - diagnosticListener.report(createDiagnostic("err.cant.use.option.for.fm", "-d")); - return false; - } - - if (!odir.exists()) - if (!odir.mkdirs()) - util.error("cant.create.dir", odir.toString()); - try { - ((StandardJavaFileManager) fileManager).setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(odir)); - } catch (IOException e) { - Object msg = e.getLocalizedMessage(); - if (msg == null) { - msg = e; - } - diagnosticListener.report(createDiagnostic("err.ioerror", odir, msg)); - return false; - } - } - g.setFileManager(fileManager); - } - - /* - * Force set to false will turn off smarts about checking file - * content before writing. - */ - g.setForce(force); - - if (fileManager instanceof JavahFileManager) - ((JavahFileManager) fileManager).setSymbolFileEnabled(false); - - JavaCompiler c = ToolProvider.getSystemJavaCompiler(); - List opts = new ArrayList<>(); - opts.add("-proc:only"); - opts.addAll(javac_extras); - - CompilationTask t; - try { - t = c.getTask(log, fileManager, diagnosticListener, opts, classes, null); - } catch (IllegalArgumentException e) { - util.error("bad.arg", e.getMessage()); - return false; - } - - JavahProcessor p = new JavahProcessor(g); - t.setProcessors(Collections.singleton(p)); - - boolean ok = t.call(); - if (p.exit != null) - throw new Util.Exit(p.exit); - return ok; - - } - - static StandardJavaFileManager getDefaultFileManager(final DiagnosticListener super JavaFileObject> dl, PrintWriter log) { - return JavahFileManager.create(dl, log); - } - - private void showHelp() { - log.println(getMessage("main.usage", progname)); - - for (Option o: recognizedOptions) { - if (o.isHidden()) - continue; - String name = o.aliases[0].substring(1); // there must always be at least one name - log.println(getMessage("main.opt." + name)); - } - - String[] fmOptions = { - "--module-path", "--system", - "--class-path", "-classpath", "-cp", - "-bootclasspath" - }; - - for (String o: fmOptions) { - if (fileManager.isSupportedOption(o) == -1) - continue; - String name = o.replaceAll("^-+", "").replaceAll("-+", "_"); - log.println(getMessage("main.opt." + name)); - } - - log.println(getMessage("main.usage.foot")); - } - - private void showVersion(boolean full) { - log.println(version(full)); - } - - private static final String versionRBName = "com.sun.tools.javah.resources.version"; - private static ResourceBundle versionRB; - - private String version(boolean full) { - String msgKey = (full ? "javah.fullVersion" : "javah.version"); - String versionKey = (full ? "full" : "release"); - // versionKey=product: mm.nn.oo[-milestone] - // versionKey=full: mm.mm.oo[-milestone]-build - if (versionRB == null) { - try { - versionRB = ResourceBundle.getBundle(versionRBName); - } catch (MissingResourceException e) { - return getMessage("version.resource.missing", System.getProperty("java.version")); - } - } - try { - return getMessage(msgKey, "javah", versionRB.getString(versionKey)); - } - catch (MissingResourceException e) { - return getMessage("version.unknown", System.getProperty("java.version")); - } - } - - private Diagnostic createDiagnostic(final String key, final Object... args) { - return new Diagnostic () { - @DefinedBy(Api.COMPILER) - public Kind getKind() { - return Diagnostic.Kind.ERROR; - } - - @DefinedBy(Api.COMPILER) - public JavaFileObject getSource() { - return null; - } - - @DefinedBy(Api.COMPILER) - public long getPosition() { - return Diagnostic.NOPOS; - } - - @DefinedBy(Api.COMPILER) - public long getStartPosition() { - return Diagnostic.NOPOS; - } - - @DefinedBy(Api.COMPILER) - public long getEndPosition() { - return Diagnostic.NOPOS; - } - - @DefinedBy(Api.COMPILER) - public long getLineNumber() { - return Diagnostic.NOPOS; - } - - @DefinedBy(Api.COMPILER) - public long getColumnNumber() { - return Diagnostic.NOPOS; - } - - @DefinedBy(Api.COMPILER) - public String getCode() { - return key; - } - - @DefinedBy(Api.COMPILER) - public String getMessage(Locale locale) { - return JavahTask.this.getMessage(locale, key, args); - } - - }; - } - - private String getMessage(String key, Object... args) { - return getMessage(task_locale, key, args); - } - - private String getMessage(Locale locale, String key, Object... args) { - if (bundles == null) { - // could make this a HashMap > - // and for efficiency, keep a hard reference to the bundle for the task - // locale - bundles = new HashMap<>(); - } - - if (locale == null) - locale = Locale.getDefault(); - - ResourceBundle b = bundles.get(locale); - if (b == null) { - try { - b = ResourceBundle.getBundle("com.sun.tools.javah.resources.l10n", locale); - bundles.put(locale, b); - } catch (MissingResourceException e) { - throw new InternalError("Cannot find javah resource bundle for locale " + locale, e); - } - } - - try { - return MessageFormat.format(b.getString(key), args); - } catch (MissingResourceException e) { - return key; - //throw new InternalError(e, key); - } - } - - File ofile; - File odir; - String bootcp; - String usercp; - List classes; - boolean verbose; - boolean noArgs; - boolean help; - boolean trace; - boolean version; - boolean fullVersion; - boolean jni; - boolean llni; - boolean doubleAlign; - boolean force; - Set javac_extras = new LinkedHashSet<>(); - - PrintWriter log; - JavaFileManager fileManager; - DiagnosticListener super JavaFileObject> diagnosticListener; - Locale task_locale; - Map bundles; - - private static final String progname = "javah"; - - @SupportedAnnotationTypes("*") - class JavahProcessor extends AbstractProcessor { - private Messager messager; - - JavahProcessor(Gen g) { - this.g = g; - } - - @Override @DefinedBy(Api.ANNOTATION_PROCESSING) - public SourceVersion getSupportedSourceVersion() { - // since this is co-bundled with javac, we can assume it supports - // the latest source version - return SourceVersion.latest(); - } - - @Override @DefinedBy(Api.ANNOTATION_PROCESSING) - public void init(ProcessingEnvironment pEnv) { - super.init(pEnv); - messager = processingEnv.getMessager(); - } - - @DefinedBy(Api.ANNOTATION_PROCESSING) - public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) { - try { - Set classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements())); - if (classes.size() > 0) { - checkMethodParameters(classes); - g.setProcessingEnvironment(processingEnv); - g.setClasses(classes); - g.run(); - } - } catch (CompletionFailure cf) { - messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString())); - } catch (ClassNotFoundException cnfe) { - messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage())); - } catch (IOException ioe) { - messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage())); - } catch (Util.Exit e) { - exit = e; - } - - return true; - } - - private Set getAllClasses(Set extends TypeElement> classes) { - Set allClasses = new LinkedHashSet<>(); - getAllClasses0(classes, allClasses); - return allClasses; - } - - private void getAllClasses0(Iterable extends TypeElement> classes, Set allClasses) { - for (TypeElement c: classes) { - allClasses.add(c); - getAllClasses0(ElementFilter.typesIn(c.getEnclosedElements()), allClasses); - } - } - - // 4942232: - // check that classes exist for all the parameters of native methods - private void checkMethodParameters(Set classes) { - Types types = processingEnv.getTypeUtils(); - for (TypeElement te: classes) { - for (ExecutableElement ee: ElementFilter.methodsIn(te.getEnclosedElements())) { - for (VariableElement ve: ee.getParameters()) { - TypeMirror tm = ve.asType(); - checkMethodParametersVisitor.visit(tm, types); - } - } - } - } - - private TypeVisitor checkMethodParametersVisitor = - new SimpleTypeVisitor9 () { - @Override @DefinedBy(Api.LANGUAGE_MODEL) - public Void visitArray(ArrayType t, Types types) { - visit(t.getComponentType(), types); - return null; - } - @Override @DefinedBy(Api.LANGUAGE_MODEL) - public Void visitDeclared(DeclaredType t, Types types) { - t.asElement().getKind(); // ensure class exists - for (TypeMirror st: types.directSupertypes(t)) - visit(st, types); - return null; - } - }; - - private Gen g; - private Util.Exit exit; - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTool.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTool.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Writer; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.EnumSet; -import java.util.Locale; -import java.util.Set; -import javax.lang.model.SourceVersion; -import javax.tools.DiagnosticListener; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; - -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; - -/* - * 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.
- */ -public class JavahTool implements NativeHeaderTool { - - public NativeHeaderTask getTask(Writer out, - JavaFileManager fileManager, - DiagnosticListener super JavaFileObject> diagnosticListener, - Iterableoptions, - Iterable classes) { - return new JavahTask(out, fileManager, diagnosticListener, options, classes); - } - - public StandardJavaFileManager getStandardFileManager(DiagnosticListener super JavaFileObject> diagnosticListener, Locale locale, Charset charset) { - return JavahTask.getDefaultFileManager(diagnosticListener, null); - } - - @DefinedBy(Api.COMPILER) - public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { - JavahTask t = new JavahTask( - JavahTask.getPrintWriterForStream(out), - null, - null, - Arrays.asList(arguments), - null); - return (t.run() ? 0 : 1); - } - - @DefinedBy(Api.COMPILER) - public Set getSourceVersions() { - return EnumSet.allOf(SourceVersion.class); - } - - @DefinedBy(Api.COMPILER) - public int isSupportedOption(String option) { - for (JavahTask.Option opt : JavahTask.recognizedOptions) { - if (opt.matches(option)) - return (opt.hasArg ? 1 : 0); - } - return -1; - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/LLNI.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/LLNI.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,685 +0,0 @@ -/* - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -import java.io.OutputStream; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import java.util.Set; -import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.Name; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.ArrayType; -import javax.lang.model.type.PrimitiveType; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.type.TypeVisitor; -import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.SimpleTypeVisitor9; - -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; - -/* - * 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.
- * - * @author Sucheta Dambalkar(Revised) - */ -public class LLNI extends Gen { - - protected final char innerDelim = '$'; /* For inner classes */ - protected SetdoneHandleTypes; - List fields; - List methods; - private boolean doubleAlign; - private int padFieldNum = 0; - - LLNI(boolean doubleAlign, Util util) { - super(util); - this.doubleAlign = doubleAlign; - } - - protected String getIncludes() { - return ""; - } - - protected void write(OutputStream o, TypeElement clazz) throws Util.Exit { - try { - String cname = mangleClassName(clazz.getQualifiedName().toString()); - PrintWriter pw = wrapWriter(o); - fields = ElementFilter.fieldsIn(clazz.getEnclosedElements()); - methods = ElementFilter.methodsIn(clazz.getEnclosedElements()); - generateDeclsForClass(pw, clazz, cname); - // FIXME check if errors occurred on the PrintWriter and throw exception if so - } catch (TypeSignature.SignatureException e) { - util.error("llni.sigerror", e.getMessage()); - } - } - - protected void generateDeclsForClass(PrintWriter pw, - TypeElement clazz, String cname) - throws TypeSignature.SignatureException, Util.Exit { - doneHandleTypes = new HashSet<>(); - /* The following handle types are predefined in "typedefs.h". Suppress - inclusion in the output by generating them "into the blue" here. */ - genHandleType(null, "java.lang.Class"); - genHandleType(null, "java.lang.ClassLoader"); - genHandleType(null, "java.lang.Object"); - genHandleType(null, "java.lang.String"); - genHandleType(null, "java.lang.Thread"); - genHandleType(null, "java.lang.ThreadGroup"); - genHandleType(null, "java.lang.Throwable"); - - pw.println("/* LLNI Header for class " + clazz.getQualifiedName() + " */" + lineSep); - pw.println("#ifndef _Included_" + cname); - pw.println("#define _Included_" + cname); - pw.println("#include \"typedefs.h\""); - pw.println("#include \"llni.h\""); - pw.println("#include \"jni.h\"" + lineSep); - - forwardDecls(pw, clazz); - structSectionForClass(pw, clazz, cname); - methodSectionForClass(pw, clazz, cname); - pw.println("#endif"); - } - - protected void genHandleType(PrintWriter pw, String clazzname) { - String cname = mangleClassName(clazzname); - if (!doneHandleTypes.contains(cname)) { - doneHandleTypes.add(cname); - if (pw != null) { - pw.println("#ifndef DEFINED_" + cname); - pw.println(" #define DEFINED_" + cname); - pw.println(" GEN_HANDLE_TYPES(" + cname + ");"); - pw.println("#endif" + lineSep); - } - } - } - - protected String mangleClassName(String s) { - return s.replace('.', '_') - .replace('/', '_') - .replace(innerDelim, '_'); - } - - protected void forwardDecls(PrintWriter pw, TypeElement clazz) - throws TypeSignature.SignatureException { - TypeElement object = elems.getTypeElement("java.lang.Object"); - if (clazz.equals(object)) - return; - - genHandleType(pw, clazz.getQualifiedName().toString()); - TypeElement superClass = (TypeElement) (types.asElement(clazz.getSuperclass())); - - if (superClass != null) { - String superClassName = superClass.getQualifiedName().toString(); - forwardDecls(pw, superClass); - } - - for (VariableElement field: fields) { - - if (!field.getModifiers().contains(Modifier.STATIC)) { - TypeMirror t = types.erasure(field.asType()); - TypeSignature newTypeSig = new TypeSignature(elems); - String tname = newTypeSig.qualifiedTypeName(t); - String sig = newTypeSig.getTypeSignature(tname); - - if (sig.charAt(0) != '[') - forwardDeclsFromSig(pw, sig); - } - } - - for (ExecutableElement method: methods) { - - if (method.getModifiers().contains(Modifier.NATIVE)) { - TypeMirror retType = types.erasure(method.getReturnType()); - String typesig = signature(method); - TypeSignature newTypeSig = new TypeSignature(elems); - String sig = newTypeSig.getTypeSignature(typesig, retType); - - if (sig.charAt(0) != '[') - forwardDeclsFromSig(pw, sig); - - } - } - } - - protected void forwardDeclsFromSig(PrintWriter pw, String sig) { - int len = sig.length(); - int i = sig.charAt(0) == '(' ? 1 : 0; - - /* Skip the initial "(". */ - while (i < len) { - if (sig.charAt(i) == 'L') { - int j = i + 1; - while (sig.charAt(j) != ';') j++; - genHandleType(pw, sig.substring(i + 1, j)); - i = j + 1; - } else { - i++; - } - } - } - - protected void structSectionForClass(PrintWriter pw, - TypeElement jclazz, String cname) { - - String jname = jclazz.getQualifiedName().toString(); - - if (cname.equals("java_lang_Object")) { - pw.println("/* struct java_lang_Object is defined in typedefs.h. */"); - pw.println(); - return; - } - pw.println("#if !defined(__i386)"); - pw.println("#pragma pack(4)"); - pw.println("#endif"); - pw.println(); - pw.println("struct " + cname + " {"); - pw.println(" ObjHeader h;"); - pw.print(fieldDefs(jclazz, cname)); - - if (jname.equals("java.lang.Class")) - pw.println(" Class *LLNI_mask(cClass);" + - " /* Fake field; don't access (see oobj.h) */"); - pw.println("};" + lineSep + lineSep + "#pragma pack()"); - pw.println(); - return; - } - - private static class FieldDefsRes { - public String className; /* Name of the current class. */ - public FieldDefsRes parent; - public String s; - public int byteSize; - public boolean bottomMost; - public boolean printedOne = false; - - FieldDefsRes(TypeElement clazz, FieldDefsRes parent, boolean bottomMost) { - this.className = clazz.getQualifiedName().toString(); - this.parent = parent; - this.bottomMost = bottomMost; - int byteSize = 0; - if (parent == null) this.s = ""; - else this.s = parent.s; - } - } - - /* Returns "true" iff added a field. */ - private boolean doField(FieldDefsRes res, VariableElement field, - String cname, boolean padWord) { - - String fieldDef = addStructMember(field, cname, padWord); - if (fieldDef != null) { - if (!res.printedOne) { /* add separator */ - if (res.bottomMost) { - if (res.s.length() != 0) - res.s = res.s + " /* local members: */" + lineSep; - } else { - res.s = res.s + " /* inherited members from " + - res.className + ": */" + lineSep; - } - res.printedOne = true; - } - res.s = res.s + fieldDef; - return true; - } - - // Otherwise. - return false; - } - - private int doTwoWordFields(FieldDefsRes res, TypeElement clazz, - int offset, String cname, boolean padWord) { - boolean first = true; - List fields = ElementFilter.fieldsIn(clazz.getEnclosedElements()); - - for (VariableElement field: fields) { - TypeKind tk = field.asType().getKind(); - boolean twoWords = (tk == TypeKind.LONG || tk == TypeKind.DOUBLE); - if (twoWords && doField(res, field, cname, first && padWord)) { - offset += 8; first = false; - } - } - return offset; - } - - String fieldDefs(TypeElement clazz, String cname) { - FieldDefsRes res = fieldDefs(clazz, cname, true); - return res.s; - } - - FieldDefsRes fieldDefs(TypeElement clazz, String cname, - boolean bottomMost){ - FieldDefsRes res; - int offset; - boolean didTwoWordFields = false; - - TypeElement superclazz = (TypeElement) types.asElement(clazz.getSuperclass()); - - if (superclazz != null) { - String supername = superclazz.getQualifiedName().toString(); - res = new FieldDefsRes(clazz, - fieldDefs(superclazz, cname, false), - bottomMost); - offset = res.parent.byteSize; - } else { - res = new FieldDefsRes(clazz, null, bottomMost); - offset = 0; - } - - List fields = ElementFilter.fieldsIn(clazz.getEnclosedElements()); - - for (VariableElement field: fields) { - - if (doubleAlign && !didTwoWordFields && (offset % 8) == 0) { - offset = doTwoWordFields(res, clazz, offset, cname, false); - didTwoWordFields = true; - } - - TypeKind tk = field.asType().getKind(); - boolean twoWords = (tk == TypeKind.LONG || tk == TypeKind.DOUBLE); - - if (!doubleAlign || !twoWords) { - if (doField(res, field, cname, false)) offset += 4; - } - - } - - if (doubleAlign && !didTwoWordFields) { - if ((offset % 8) != 0) offset += 4; - offset = doTwoWordFields(res, clazz, offset, cname, true); - } - - res.byteSize = offset; - return res; - } - - /* OVERRIDE: This method handles instance fields */ - protected String addStructMember(VariableElement member, String cname, - boolean padWord) { - String res = null; - - if (member.getModifiers().contains(Modifier.STATIC)) { - res = addStaticStructMember(member, cname); - // if (res == null) /* JNI didn't handle it, print comment. */ - // res = " /* Inaccessible static: " + member + " */" + lineSep; - } else { - TypeMirror mt = types.erasure(member.asType()); - if (padWord) res = " java_int padWord" + padFieldNum++ + ";" + lineSep; - res = " " + llniType(mt, false, false) + " " + llniFieldName(member); - if (isLongOrDouble(mt)) res = res + "[2]"; - res = res + ";" + lineSep; - } - return res; - } - - static private final boolean isWindows = - System.getProperty("os.name").startsWith("Windows"); - - /* - * This method only handles static final fields. - */ - protected String addStaticStructMember(VariableElement field, String cname) { - String res = null; - Object exp = null; - - if (!field.getModifiers().contains(Modifier.STATIC)) - return res; - if (!field.getModifiers().contains(Modifier.FINAL)) - return res; - - exp = field.getConstantValue(); - - if (exp != null) { - /* Constant. */ - - String cn = cname + "_" + field.getSimpleName(); - String suffix = null; - long val = 0; - /* Can only handle int, long, float, and double fields. */ - if (exp instanceof Byte - || exp instanceof Short - || exp instanceof Integer) { - suffix = "L"; - val = ((Number)exp).intValue(); - } - else if (exp instanceof Long) { - // Visual C++ supports the i64 suffix, not LL - suffix = isWindows ? "i64" : "LL"; - val = ((Long)exp).longValue(); - } - else if (exp instanceof Float) suffix = "f"; - else if (exp instanceof Double) suffix = ""; - else if (exp instanceof Character) { - suffix = "L"; - Character ch = (Character) exp; - val = ((int) ch) & 0xffff; - } - if (suffix != null) { - // Some compilers will generate a spurious warning - // for the integer constants for Integer.MIN_VALUE - // and Long.MIN_VALUE so we handle them specially. - if ((suffix.equals("L") && (val == Integer.MIN_VALUE)) || - (suffix.equals("LL") && (val == Long.MIN_VALUE))) { - res = " #undef " + cn + lineSep - + " #define " + cn - + " (" + (val + 1) + suffix + "-1)" + lineSep; - } else if (suffix.equals("L") || suffix.endsWith("LL")) { - res = " #undef " + cn + lineSep - + " #define " + cn + " " + val + suffix + lineSep; - } else { - res = " #undef " + cn + lineSep - + " #define " + cn + " " + exp + suffix + lineSep; - } - } - } - return res; - } - - protected void methodSectionForClass(PrintWriter pw, - TypeElement clazz, String cname) - throws TypeSignature.SignatureException, Util.Exit { - String methods = methodDecls(clazz, cname); - - if (methods.length() != 0) { - pw.println("/* Native method declarations: */" + lineSep); - pw.println("#ifdef __cplusplus"); - pw.println("extern \"C\" {"); - pw.println("#endif" + lineSep); - pw.println(methods); - pw.println("#ifdef __cplusplus"); - pw.println("}"); - pw.println("#endif"); - } - } - - protected String methodDecls(TypeElement clazz, String cname) - throws TypeSignature.SignatureException, Util.Exit { - - String res = ""; - for (ExecutableElement method: methods) { - if (method.getModifiers().contains(Modifier.NATIVE)) - res = res + methodDecl(method, clazz, cname); - } - return res; - } - - protected String methodDecl(ExecutableElement method, - TypeElement clazz, String cname) - throws TypeSignature.SignatureException, Util.Exit { - String res = null; - - TypeMirror retType = types.erasure(method.getReturnType()); - String typesig = signature(method); - TypeSignature newTypeSig = new TypeSignature(elems); - String sig = newTypeSig.getTypeSignature(typesig, retType); - boolean longName = needLongName(method, clazz); - - if (sig.charAt(0) != '(') - util.error("invalid.method.signature", sig); - - - res = "JNIEXPORT " + jniType(retType) + " JNICALL" + lineSep + jniMethodName(method, cname, longName) - + "(JNIEnv *, " + cRcvrDecl(method, cname); - List extends VariableElement> params = method.getParameters(); - List argTypes = new ArrayList<>(); - for (VariableElement p: params){ - argTypes.add(types.erasure(p.asType())); - } - - /* It would have been nice to include the argument names in the - declaration, but there seems to be a bug in the "BinaryField" - class, causing the getArguments() method to return "null" for - most (non-constructor) methods. */ - for (TypeMirror argType: argTypes) - res = res + ", " + jniType(argType); - res = res + ");" + lineSep; - return res; - } - - protected final boolean needLongName(ExecutableElement method, - TypeElement clazz) { - Name methodName = method.getSimpleName(); - for (ExecutableElement memberMethod: methods) { - if ((memberMethod != method) && - memberMethod.getModifiers().contains(Modifier.NATIVE) && - (methodName.equals(memberMethod.getSimpleName()))) - return true; - } - return false; - } - - protected final String jniMethodName(ExecutableElement method, String cname, - boolean longName) - throws TypeSignature.SignatureException { - String res = "Java_" + cname + "_" + method.getSimpleName(); - - if (longName) { - TypeMirror mType = types.erasure(method.getReturnType()); - List extends VariableElement> params = method.getParameters(); - List argTypes = new ArrayList<>(); - for (VariableElement param: params) { - argTypes.add(types.erasure(param.asType())); - } - - res = res + "__"; - for (TypeMirror t: argTypes) { - String tname = t.toString(); - TypeSignature newTypeSig = new TypeSignature(elems); - String sig = newTypeSig.getTypeSignature(tname); - res = res + nameToIdentifier(sig); - } - } - return res; - } - - // copied from JNI.java - protected final String jniType(TypeMirror t) throws Util.Exit { - TypeElement throwable = elems.getTypeElement("java.lang.Throwable"); - TypeElement jClass = elems.getTypeElement("java.lang.Class"); - TypeElement jString = elems.getTypeElement("java.lang.String"); - Element tclassDoc = types.asElement(t); - - switch (t.getKind()) { - case ARRAY: { - TypeMirror ct = ((ArrayType) t).getComponentType(); - switch (ct.getKind()) { - case BOOLEAN: return "jbooleanArray"; - case BYTE: return "jbyteArray"; - case CHAR: return "jcharArray"; - case SHORT: return "jshortArray"; - case INT: return "jintArray"; - case LONG: return "jlongArray"; - case FLOAT: return "jfloatArray"; - case DOUBLE: return "jdoubleArray"; - case ARRAY: - case DECLARED: return "jobjectArray"; - default: throw new Error(ct.toString()); - } - } - - case VOID: return "void"; - case BOOLEAN: return "jboolean"; - case BYTE: return "jbyte"; - case CHAR: return "jchar"; - case SHORT: return "jshort"; - case INT: return "jint"; - case LONG: return "jlong"; - case FLOAT: return "jfloat"; - case DOUBLE: return "jdouble"; - - case DECLARED: { - if (tclassDoc.equals(jString)) - return "jstring"; - else if (types.isAssignable(t, throwable.asType())) - return "jthrowable"; - else if (types.isAssignable(t, jClass.asType())) - return "jclass"; - else - return "jobject"; - } - } - - util.bug("jni.unknown.type"); - return null; /* dead code. */ - } - - protected String llniType(TypeMirror t, boolean handleize, boolean longDoubleOK) { - String res = null; - - switch (t.getKind()) { - case ARRAY: { - TypeMirror ct = ((ArrayType) t).getComponentType(); - switch (ct.getKind()) { - case BOOLEAN: res = "IArrayOfBoolean"; break; - case BYTE: res = "IArrayOfByte"; break; - case CHAR: res = "IArrayOfChar"; break; - case SHORT: res = "IArrayOfShort"; break; - case INT: res = "IArrayOfInt"; break; - case LONG: res = "IArrayOfLong"; break; - case FLOAT: res = "IArrayOfFloat"; break; - case DOUBLE: res = "IArrayOfDouble"; break; - case ARRAY: - case DECLARED: res = "IArrayOfRef"; break; - default: throw new Error(ct.getKind() + " " + ct); - } - if (!handleize) res = "DEREFERENCED_" + res; - break; - } - - case VOID: - res = "void"; - break; - - case BOOLEAN: - case BYTE: - case CHAR: - case SHORT: - case INT: - res = "java_int" ; - break; - - case LONG: - res = longDoubleOK ? "java_long" : "val32 /* java_long */"; - break; - - case FLOAT: - res = "java_float"; - break; - - case DOUBLE: - res = longDoubleOK ? "java_double" : "val32 /* java_double */"; - break; - - case DECLARED: - TypeElement e = (TypeElement) types.asElement(t); - res = "I" + mangleClassName(e.getQualifiedName().toString()); - if (!handleize) res = "DEREFERENCED_" + res; - break; - - default: - throw new Error(t.getKind() + " " + t); // FIXME - } - - return res; - } - - protected final String cRcvrDecl(Element field, String cname) { - return (field.getModifiers().contains(Modifier.STATIC) ? "jclass" : "jobject"); - } - - protected String maskName(String s) { - return "LLNI_mask(" + s + ")"; - } - - protected String llniFieldName(VariableElement field) { - return maskName(field.getSimpleName().toString()); - } - - protected final boolean isLongOrDouble(TypeMirror t) { - TypeVisitor v = new SimpleTypeVisitor9 () { - @DefinedBy(Api.LANGUAGE_MODEL) - public Boolean defaultAction(TypeMirror t, Void p){ - return false; - } - @DefinedBy(Api.LANGUAGE_MODEL) - public Boolean visitArray(ArrayType t, Void p) { - return visit(t.getComponentType(), p); - } - @DefinedBy(Api.LANGUAGE_MODEL) - public Boolean visitPrimitive(PrimitiveType t, Void p) { - TypeKind tk = t.getKind(); - return (tk == TypeKind.LONG || tk == TypeKind.DOUBLE); - } - }; - return v.visit(t, null); - } - - /* Do unicode to ansi C identifier conversion. - %%% This may not be right, but should be called more often. */ - protected final String nameToIdentifier(String name) { - int len = name.length(); - StringBuilder buf = new StringBuilder(len); - for (int i = 0; i < len; i++) { - char c = name.charAt(i); - if (isASCIILetterOrDigit(c)) - buf.append(c); - else if (c == '/') - buf.append('_'); - else if (c == '.') - buf.append('_'); - else if (c == '_') - buf.append("_1"); - else if (c == ';') - buf.append("_2"); - else if (c == '[') - buf.append("_3"); - else - buf.append("_0" + ((int)c)); - } - return new String(buf); - } - - protected final boolean isASCIILetterOrDigit(char c) { - if (((c >= 'A') && (c <= 'Z')) || - ((c >= 'a') && (c <= 'z')) || - ((c >= '0') && (c <= '9'))) - return true; - else - return false; - } -} - diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/Main.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/Main.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -import java.io.PrintWriter; - -/** - * Main entry point. - * - * 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. - */ -public class Main { - /** - * Main entry point for the launcher. - * Note: This method calls System.exit. - * @param args command line arguments - */ - public static void main(String[] args) { - JavahTask t = new JavahTask(); - int rc = t.run(args); - System.exit(rc); - } - - /** - * Entry point that does not call System.exit. - * @param args command line arguments - * @param out output stream - * @return an exit code. 0 means success, non-zero means an error occurred. - */ - public static int run(String[] args, PrintWriter out) { - JavahTask t = new JavahTask(); - t.setLog(out); - return t.run(args); - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/Mangle.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/Mangle.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.util.Elements; -import javax.lang.model.util.Types; - -/** - * A utility for mangling java identifiers into C names. Should make - * this more fine grained and distribute the functionality to the - * generators. - * - *
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.
- * - * @author Sucheta Dambalkar(Revised) - */ -public class Mangle { - - public static class Type { - public static final int CLASS = 1; - public static final int FIELDSTUB = 2; - public static final int FIELD = 3; - public static final int JNI = 4; - public static final int SIGNATURE = 5; - public static final int METHOD_JDK_1 = 6; - public static final int METHOD_JNI_SHORT = 7; - public static final int METHOD_JNI_LONG = 8; - } - - private Elements elems; - private Types types; - - Mangle(Elements elems, Types types) { - this.elems = elems; - this.types = types; - } - - public final String mangle(CharSequence name, int mtype) { - StringBuilder result = new StringBuilder(100); - int length = name.length(); - - for (int i = 0; i < length; i++) { - char ch = name.charAt(i); - if (isalnum(ch)) { - result.append(ch); - } else if ((ch == '.') && - mtype == Mangle.Type.CLASS) { - result.append('_'); - } else if (( ch == '$') && - mtype == Mangle.Type.CLASS) { - result.append('_'); - result.append('_'); - } else if (ch == '_' && mtype == Mangle.Type.FIELDSTUB) { - result.append('_'); - } else if (ch == '_' && mtype == Mangle.Type.CLASS) { - result.append('_'); - } else if (mtype == Mangle.Type.JNI) { - String esc = null; - if (ch == '_') - esc = "_1"; - else if (ch == '.') - esc = "_"; - else if (ch == ';') - esc = "_2"; - else if (ch == '[') - esc = "_3"; - if (esc != null) { - result.append(esc); - } else { - result.append(mangleChar(ch)); - } - } else if (mtype == Mangle.Type.SIGNATURE) { - if (isprint(ch)) { - result.append(ch); - } else { - result.append(mangleChar(ch)); - } - } else { - result.append(mangleChar(ch)); - } - } - - return result.toString(); - } - - public String mangleMethod(ExecutableElement method, TypeElement clazz, - int mtype) throws TypeSignature.SignatureException { - StringBuilder result = new StringBuilder(100); - result.append("Java_"); - - if (mtype == Mangle.Type.METHOD_JDK_1) { - result.append(mangle(clazz.getQualifiedName(), Mangle.Type.CLASS)); - result.append('_'); - result.append(mangle(method.getSimpleName(), - Mangle.Type.FIELD)); - result.append("_stub"); - return result.toString(); - } - - /* JNI */ - result.append(mangle(getInnerQualifiedName(clazz), Mangle.Type.JNI)); - result.append('_'); - result.append(mangle(method.getSimpleName(), - Mangle.Type.JNI)); - if (mtype == Mangle.Type.METHOD_JNI_LONG) { - result.append("__"); - String typesig = signature(method); - TypeSignature newTypeSig = new TypeSignature(elems); - String sig = newTypeSig.getTypeSignature(typesig, method.getReturnType()); - sig = sig.substring(1); - sig = sig.substring(0, sig.lastIndexOf(')')); - sig = sig.replace('/', '.'); - result.append(mangle(sig, Mangle.Type.JNI)); - } - - return result.toString(); - } - //where - private String getInnerQualifiedName(TypeElement clazz) { - return elems.getBinaryName(clazz).toString(); - } - - public final String mangleChar(char ch) { - String s = Integer.toHexString(ch); - int nzeros = 5 - s.length(); - char[] result = new char[6]; - result[0] = '_'; - for (int i = 1; i <= nzeros; i++) - result[i] = '0'; - for (int i = nzeros+1, j = 0; i < 6; i++, j++) - result[i] = s.charAt(j); - return new String(result); - } - - // Warning: duplicated in Gen - private String signature(ExecutableElement e) { - StringBuilder sb = new StringBuilder(); - String sep = "("; - for (VariableElement p: e.getParameters()) { - sb.append(sep); - sb.append(types.erasure(p.asType()).toString()); - sep = ","; - } - sb.append(")"); - return sb.toString(); - } - - /* Warning: Intentional ASCII operation. */ - private static boolean isalnum(char ch) { - return ch <= 0x7f && /* quick test */ - ((ch >= 'A' && ch <= 'Z') || - (ch >= 'a' && ch <= 'z') || - (ch >= '0' && ch <= '9')); - } - - /* Warning: Intentional ASCII operation. */ - private static boolean isprint(char ch) { - return ch >= 32 && ch <= 126; - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/NativeHeaderTool.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/NativeHeaderTool.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; //javax.tools; - -import java.io.Writer; -import java.nio.charset.Charset; -import java.util.Locale; -import java.util.concurrent.Callable; -import javax.tools.Diagnostic; -import javax.tools.DiagnosticListener; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; -import javax.tools.OptionChecker; -import javax.tools.StandardJavaFileManager; -import javax.tools.StandardLocation; -import javax.tools.Tool; - -/** - * This class is intended to be put in javax.tools. - * - * @see DiagnosticListener - * @see Diagnostic - * @see JavaFileManager - * @since 1.7 - * - *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. - */ -public interface NativeHeaderTool extends Tool, OptionChecker { - - /** - * Creates a future for a native header task with the given - * components and arguments. The task might not have - * completed as described in the NativeHeaderTask interface. - * - *
If a file manager is provided, it must be able to handle all - * locations defined in {@link StandardLocation}. - * - * @param out a Writer for additional output from the task; - * use {@code System.err} if {@code null} - * @param fileManager a file manager; if {@code null} use the - * task's standard filemanager - * @param diagnosticListener a diagnostic listener; if {@code - * null} use the compiler's default method for reporting - * diagnostics - * @param options task options, {@code null} means no options - * @param classes class names for which native headers should be generated - * @return an object representing the task to be done - * @throws RuntimeException if an unrecoverable error - * occurred in a user supplied component. The - * {@linkplain Throwable#getCause() cause} will be the error in - * user code. - * @throws IllegalArgumentException if any of the given - * compilation units are of other kind than - * {@linkplain JavaFileObject.Kind#SOURCE source} - */ - NativeHeaderTask getTask(Writer out, - JavaFileManager fileManager, - DiagnosticListener super JavaFileObject> diagnosticListener, - Iterable
options, - Iterable classes); - - /** - * Returns a new instance of the standard file manager implementation - * for this tool. The file manager will use the given diagnostic - * listener for producing any non-fatal diagnostics. Fatal errors - * will be signalled with the appropriate exceptions. - * - * The standard file manager will be automatically reopened if - * it is accessed after calls to {@code flush} or {@code close}. - * The standard file manager must be usable with other tools. - * - * @param diagnosticListener a diagnostic listener for non-fatal - * diagnostics; if {@code null} use the tool's default method - * for reporting diagnostics - * @param locale the locale to apply when formatting diagnostics; - * {@code null} means the {@linkplain Locale#getDefault() default locale}. - * @param charset the character set used for decoding bytes; if - * {@code null} use the platform default - * @return the standard file manager - */ - StandardJavaFileManager getStandardFileManager( - DiagnosticListener super JavaFileObject> diagnosticListener, - Locale locale, - Charset charset); - - /** - * Interface representing a future for a native header task. The - * task has not yet started. To start the task, call - * the {@linkplain #call call} method. - * - *
Before calling the call method, additional aspects of the - * task can be configured, for example, by calling the - * {@linkplain #setLocale setLocale} method. - */ - interface NativeHeaderTask extends Callable
{ - - /** - * Set the locale to be applied when formatting diagnostics and - * other localized data. - * - * @param locale the locale to apply; {@code null} means apply no - * locale - * @throws IllegalStateException if the task has started - */ - void setLocale(Locale locale); - - /** - * Performs this native header task. The task may only - * be performed once. Subsequent calls to this method throw - * IllegalStateException. - * - * @return true if and only all the files were processed without errors; - * false otherwise - * - * @throws RuntimeException if an unrecoverable error occurred - * in a user-supplied component. The - * {@linkplain Throwable#getCause() cause} will be the error - * in user code. - * @throws IllegalStateException if called more than once - */ - Boolean call(); - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/TypeSignature.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/TypeSignature.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,283 +0,0 @@ -/* - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -import java.util.*; -import javax.lang.model.element.Name; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.ArrayType; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.NoType; -import javax.lang.model.type.PrimitiveType; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.type.TypeVariable; -import javax.lang.model.type.TypeVisitor; -import javax.lang.model.util.Elements; -import javax.lang.model.util.SimpleTypeVisitor9; - -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; - -/** - * Returns internal type signature. - * - * 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.
- * - * @author Sucheta Dambalkar - */ - -public class TypeSignature { - static class SignatureException extends Exception { - private static final long serialVersionUID = 1L; - SignatureException(String reason) { - super(reason); - } - } - - Elements elems; - - /* Signature Characters */ - - private static final String SIG_VOID = "V"; - private static final String SIG_BOOLEAN = "Z"; - private static final String SIG_BYTE = "B"; - private static final String SIG_CHAR = "C"; - private static final String SIG_SHORT = "S"; - private static final String SIG_INT = "I"; - private static final String SIG_LONG = "J"; - private static final String SIG_FLOAT = "F"; - private static final String SIG_DOUBLE = "D"; - private static final String SIG_ARRAY = "["; - private static final String SIG_CLASS = "L"; - - - - public TypeSignature(Elements elems){ - this.elems = elems; - } - - /* - * Returns the type signature of a field according to JVM specs - */ - public String getTypeSignature(String javasignature) throws SignatureException { - return getParamJVMSignature(javasignature); - } - - /* - * Returns the type signature of a method according to JVM specs - */ - public String getTypeSignature(String javasignature, TypeMirror returnType) - throws SignatureException { - String signature = null; //Java type signature. - String typeSignature = null; //Internal type signature. - Listparams = new ArrayList<>(); //List of parameters. - String paramsig = null; //Java parameter signature. - String paramJVMSig = null; //Internal parameter signature. - String returnSig = null; //Java return type signature. - String returnJVMType = null; //Internal return type signature. - int dimensions = 0; //Array dimension. - - int startIndex = -1; - int endIndex = -1; - StringTokenizer st = null; - int i = 0; - - // Gets the actual java signature without parentheses. - if (javasignature != null) { - startIndex = javasignature.indexOf("("); - endIndex = javasignature.indexOf(")"); - } - - if (((startIndex != -1) && (endIndex != -1)) - &&(startIndex+1 < javasignature.length()) - &&(endIndex < javasignature.length())) { - signature = javasignature.substring(startIndex+1, endIndex); - } - - // Separates parameters. - if (signature != null) { - if (signature.contains(",")) { - st = new StringTokenizer(signature, ","); - if (st != null) { - while (st.hasMoreTokens()) { - params.add(st.nextToken()); - } - } - } else { - params.add(signature); - } - } - - /* JVM type signature. */ - typeSignature = "("; - - // Gets indivisual internal parameter signature. - while (params.isEmpty() != true) { - paramsig = params.remove(i).trim(); - paramJVMSig = getParamJVMSignature(paramsig); - if (paramJVMSig != null) { - typeSignature += paramJVMSig; - } - } - - typeSignature += ")"; - - // Get internal return type signature. - - returnJVMType = ""; - if (returnType != null) { - dimensions = dimensions(returnType); - } - - //Gets array dimension of return type. - while (dimensions-- > 0) { - returnJVMType += "["; - } - if (returnType != null) { - returnSig = qualifiedTypeName(returnType); - returnJVMType += getComponentType(returnSig); - } else { - System.out.println("Invalid return type."); - } - - typeSignature += returnJVMType; - - return typeSignature; - } - - /* - * Returns internal signature of a parameter. - */ - private String getParamJVMSignature(String paramsig) throws SignatureException { - String paramJVMSig = ""; - String componentType =""; - - if(paramsig != null){ - - if(paramsig.contains("[]")) { - // Gets array dimension. - int endindex = paramsig.indexOf("[]"); - componentType = paramsig.substring(0, endindex); - String dimensionString = paramsig.substring(endindex); - if(dimensionString != null){ - while(dimensionString.contains("[]")){ - paramJVMSig += "["; - int beginindex = dimensionString.indexOf("]") + 1; - if(beginindex < dimensionString.length()){ - dimensionString = dimensionString.substring(beginindex); - }else - dimensionString = ""; - } - } - } else componentType = paramsig; - - paramJVMSig += getComponentType(componentType); - } - return paramJVMSig; - } - - /* - * Returns internal signature of a component. - */ - private String getComponentType(String componentType) throws SignatureException { - - String JVMSig = ""; - - if(componentType != null){ - switch (componentType) { - case "void": JVMSig += SIG_VOID; break; - case "boolean": JVMSig += SIG_BOOLEAN; break; - case "byte": JVMSig += SIG_BYTE; break; - case "char": JVMSig += SIG_CHAR; break; - case "short": JVMSig += SIG_SHORT; break; - case "int": JVMSig += SIG_INT; break; - case "long": JVMSig += SIG_LONG; break; - case "float": JVMSig += SIG_FLOAT; break; - case "double": JVMSig += SIG_DOUBLE; break; - default: - if (!componentType.equals("")) { - TypeElement classNameDoc = elems.getTypeElement(componentType); - - if (classNameDoc == null) { - throw new SignatureException(componentType); - } - else { - String classname = classNameDoc.getQualifiedName().toString(); - String newclassname = classname.replace('.', '/'); - JVMSig += "L"; - JVMSig += newclassname; - JVMSig += ";"; - } - } - break; - } - } - return JVMSig; - } - - int dimensions(TypeMirror t) { - if (t.getKind() != TypeKind.ARRAY) - return 0; - return 1 + dimensions(((ArrayType) t).getComponentType()); - } - - - String qualifiedTypeName(TypeMirror type) { - TypeVisitor v = new SimpleTypeVisitor9 () { - @Override @DefinedBy(Api.LANGUAGE_MODEL) - public Name visitArray(ArrayType t, Void p) { - return t.getComponentType().accept(this, p); - } - - @Override @DefinedBy(Api.LANGUAGE_MODEL) - public Name visitDeclared(DeclaredType t, Void p) { - return ((TypeElement) t.asElement()).getQualifiedName(); - } - - @Override @DefinedBy(Api.LANGUAGE_MODEL) - public Name visitPrimitive(PrimitiveType t, Void p) { - return elems.getName(t.toString()); - } - - @Override @DefinedBy(Api.LANGUAGE_MODEL) - public Name visitNoType(NoType t, Void p) { - if (t.getKind() == TypeKind.VOID) - return elems.getName("void"); - return defaultAction(t, p); - } - - @Override @DefinedBy(Api.LANGUAGE_MODEL) - public Name visitTypeVariable(TypeVariable t, Void p) { - return t.getUpperBound().accept(this, p); - } - }; - return v.visit(type).toString(); - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/Util.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/Util.java Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javah; - -import java.io.PrintWriter; -import java.text.MessageFormat; -import java.util.Locale; -import java.util.ResourceBundle; -import java.util.MissingResourceException; -import javax.tools.Diagnostic; -import javax.tools.Diagnostic.Kind; -import javax.tools.DiagnosticListener; -import javax.tools.JavaFileObject; - -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; - -/** - * Messages, verbose and error handling support. - * - * For errors, the failure modes are: - * error -- User did something wrong - * bug -- Bug has occurred in javah - * fatal -- We can't even find resources, so bail fast, don't localize - * - * 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.
- */ -public class Util { - /** Exit is used to replace the use of System.exit in the original javah. - */ - public static class Exit extends Error { - private static final long serialVersionUID = 430820978114067221L; - Exit(int exitValue) { - this(exitValue, null); - } - - Exit(int exitValue, Throwable cause) { - super(cause); - this.exitValue = exitValue; - this.cause = cause; - } - - Exit(Exit e) { - this(e.exitValue, e.cause); - } - - public final int exitValue; - public final Throwable cause; - } - - /* - * Help for verbosity. - */ - public boolean verbose = false; - - public PrintWriter log; - public DiagnosticListener super JavaFileObject> dl; - - Util(PrintWriter log, DiagnosticListener super JavaFileObject> dl) { - this.log = log; - this.dl = dl; - } - - public void log(String s) { - log.println(s); - } - - /* - * Help for loading localized messages. - */ - private ResourceBundle m; - - private void initMessages() throws Exit { - try { - m = ResourceBundle.getBundle("com.sun.tools.javah.resources.l10n"); - } catch (MissingResourceException mre) { - fatal("Error loading resources. Please file a bug report.", mre); - } - } - - private String getText(String key, Object... args) throws Exit { - if (m == null) - initMessages(); - try { - return MessageFormat.format(m.getString(key), args); - } catch (MissingResourceException e) { - fatal("Key " + key + " not found in resources.", e); - } - return null; /* dead code */ - } - - /* - * Failure modes. - */ - public void bug(String key) throws Exit { - bug(key, null); - } - - public void bug(String key, Exception e) throws Exit { - dl.report(createDiagnostic(Diagnostic.Kind.ERROR, key)); - dl.report(createDiagnostic(Diagnostic.Kind.NOTE, "bug.report")); - throw new Exit(11, e); - } - - public void error(String key, Object... args) throws Exit { - dl.report(createDiagnostic(Diagnostic.Kind.ERROR, key, args)); - throw new Exit(15); - } - - private void fatal(String msg, Exception e) throws Exit { - dl.report(createDiagnostic(Diagnostic.Kind.ERROR, "", msg)); - throw new Exit(10, e); - } - - private DiagnosticcreateDiagnostic( - final Diagnostic.Kind kind, final String code, final Object... args) { - return new Diagnostic () { - @DefinedBy(Api.COMPILER) - public String getCode() { - return code; - } - @DefinedBy(Api.COMPILER) - public long getColumnNumber() { - return Diagnostic.NOPOS; - } - @DefinedBy(Api.COMPILER) - public long getEndPosition() { - return Diagnostic.NOPOS; - } - @DefinedBy(Api.COMPILER) - public Kind getKind() { - return kind; - } - @DefinedBy(Api.COMPILER) - public long getLineNumber() { - return Diagnostic.NOPOS; - } - @DefinedBy(Api.COMPILER) - public String getMessage(Locale locale) { - if (code.length() == 0) - return (String) args[0]; - return getText(code, args); // FIXME locale - } - @DefinedBy(Api.COMPILER) - public long getPosition() { - return Diagnostic.NOPOS; - } - @DefinedBy(Api.COMPILER) - public JavaFileObject getSource() { - return null; - } - @DefinedBy(Api.COMPILER) - public long getStartPosition() { - return Diagnostic.NOPOS; - } - }; - } -} diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n.properties --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n.properties Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,178 +0,0 @@ -# -# Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# User errors, command line errors. -# -cant.create.dir=\ - The directory {0} could not be create for output. -at.args.cant.read=\ - Can''t read command line arguments from file {1}. -at.args.file.not.found=\ - Can''t find file {0}. -at.args.io.exception=\ - The following I/O problem was encountered when processing an @ \ - argument on the command line: {0}. -bad.arg=\ - Bad argument: {0} -old.jni.mixed=\ - Can''t mix options -jni and -old. Try -help. -old.llni.mixed=\ - Can''t mix options -old and -llni. Try -help. -old.not.supported=\ - Option -old not supported by this version of javah. -invalid.method.signature=\ - Invalid method signature: {0} -jni.llni.mixed=\ - Can''t mix options -jni and -llni. Try -help. -jni.no.stubs=\ - JNI does not require stubs, please refer to the JNI documentation. -jni.sigerror=\ - Cannot determine signature for {0} -dir.file.mixed=\ - Can''t mix options -d and -o. Try -help. -no.classes.specified=\ - No classes were specified on the command line. Try -help. -no.outputfile.specified=\ - No outputfile was specified on the command line. Try -help. -no.outputdir.specified=\ - No output directory was specified on the command line. Try -help. -no.classpath.specified=\ - No classpath was specified on the command line. Try -help. -no.bootclasspath.specified=\ - No bootclasspath was specified on the command line. Try -help. -unknown.option=\ - {0} is an illegal argument\n -tracing.not.supported=\ - Warning: Tracing is no longer supported. Instead, use\ - -verbose:jni option of the virtual machine. - -main.usage=\ -Usage: \n\ -\ javah [options] \n\ -where [options] include: - -main.opt.o=\ -\ -o Output file (only one of -d or -o may be used) - -main.opt.d=\ -\ -d Output directory - -main.opt.v=\ -\ -v -verbose Enable verbose output - -main.opt.h=\ -\ -h --help -? Print this message - -main.opt.version=\ -\ -version Print version information - -main.opt.jni=\ -\ -jni Generate JNI-style header file (default) - -main.opt.force=\ -\ -force Always write output files - -main.opt.module_path=\ -\ --module-path Path from which to load application modules - -main.opt.upgrade_module_path=\ -\ --upgrade_module-path Path from which to load application modules - -main.opt.classpath=\ -\ -classpath Path from which to load classes - -main.opt.class_path=\ -\ --class-path Path from which to load classes - -main.opt.cp=\ -\ -cp Path from which to load classes - -main.opt.bootclasspath=\ -\ -bootclasspath Path from which to load bootstrap classes - -main.opt.system=\ -\ --system Specify where to find system modules - -main.usage.foot=\n\ -GNU-style options may use '=' instead whitespace to separate the name of an option\n\ -from its value.\n\ -\n\ -Each class must be specified by its fully qualified names, optionally\n\ -prefixed by a module name followed by '/'. Examples:\n\ -\ java.lang.Object\n\ -\ java.base/java.io.File\n\ - -# -# Version string. -# -javah.version={0} version "{1}" -javah.fullVersion={0} full version "{1}" - -# -# These should have better diagnostics. -# -super.class.not.found=\ - A required super class {0} could not be found. -class.not.found=\ - Class {0} could not be found. -io.exception=\ - Can''t recover from an I/O error with the following message: \ - {0}. - -# -# Problems in the guts of javah. -# -encoding.iso8859_1.not.found=\ - ISO8859_1 converter was not found for output. This is \ - probably due to an error in the installation installation. -tried.to.define.non.static=\ - Tried to generate #define for non-static field. -jni.unknown.type=\ - An unknown type encountered (JNI). -unknown.array.type=\ - An unknown array type encountered when generating old style headers. -unknown.type.for.field=\ - An unknown type encountered when generating old style headers. -unknown.type.in.method.signature=\ - An unknown type eccountered when generating old style stubs. - - -err.prefix=Error: -err.cant.use.option.for.fm=Can't use {0} option with given file manager -err.internal.error=Internal error: {0} -err.ioerror=IO error: {0} -err.missing.arg=value missing for {0} -err.no.classes.specified=no classes specified -err.unknown.option=unknown option: {0} - -# -# miscellaneous strings -# -javah.misc.Deprecation=\ - \nWarning:\u0020The javah tool is planned to be removed in the next major\n\ - JDK release. The tool has been superseded by the ''-h'' option added\n\ - to javac in JDK 8. Users are recommended to migrate to using the\n\ - javac ''-h'' option; see the javac man page for more information.\n diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n_ja.properties --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n_ja.properties Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -# -# Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# User errors, command line errors. -# -cant.create.dir=\u51FA\u529B\u7528\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002 -at.args.cant.read=\u30D5\u30A1\u30A4\u30EB{1}\u304B\u3089\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u5F15\u6570\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3002 -at.args.file.not.found=\u30D5\u30A1\u30A4\u30EB{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 -at.args.io.exception=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u306E@\u5F15\u6570\u306E\u51E6\u7406\u4E2D\u306B\u3001\u6B21\u306E\u5165\u51FA\u529B\u306E\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {0}\u3002 -bad.arg=\u7121\u52B9\u306A\u5F15\u6570: {0} -old.jni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-jni\u3068-old\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -old.llni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-old\u3068-llni\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -old.not.supported=\u3053\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u306Ejavah\u3067\u306F\u30AA\u30D7\u30B7\u30E7\u30F3-old\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002 -invalid.method.signature=\u7121\u52B9\u306A\u30E1\u30BD\u30C3\u30C9\u30FB\u30B7\u30B0\u30CB\u30C1\u30E3: {0} -jni.llni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-jni\u3068-llni\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -jni.no.stubs=JNI\u306F\u30B9\u30BF\u30D6\u3092\u5FC5\u8981\u3068\u3057\u307E\u305B\u3093\u3002JNI\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -jni.sigerror={0}\u306E\u7F72\u540D\u3092\u5224\u5B9A\u3067\u304D\u307E\u305B\u3093 -dir.file.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-d\u3068-o\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -no.classes.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -no.outputfile.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -no.outputdir.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -no.classpath.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u30AF\u30E9\u30B9\u30D1\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -no.bootclasspath.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -unknown.option={0}\u306F\u4E0D\u6B63\u306A\u5F15\u6570\u3067\u3059\n -tracing.not.supported=\u8B66\u544A: \u30C8\u30EC\u30FC\u30B9\u306F\u73FE\u5728\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u304B\u308F\u308A\u306B\u3001Virtual Machine\u306E-verbose:jni\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002 - -main.usage=\u4F7F\u7528\u65B9\u6CD5: \n javah [options] \n[options]\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002 - -main.opt.o=\ -o \u51FA\u529B\u30D5\u30A1\u30A4\u30EB(-d\u304B-o\u306E\u3069\u3061\u3089\u304B\u4E00\u65B9\u3092\u4F7F\u7528\u3059\u308B) - -main.opt.d=\ -d \u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA - -main.opt.v=\ -v -verbose \u8A73\u7D30\u306A\u51FA\u529B\u3092\u884C\u3046 - -main.opt.h=\ -h --help -? \u3053\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3059\u308B - -main.opt.version=\ -version \u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3059\u308B - -main.opt.jni=\ -jni JNI\u5F62\u5F0F\u306E\u30D8\u30C3\u30C0\u30FC\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3059\u308B(\u30C7\u30D5\u30A9\u30EB\u30C8) - -main.opt.force=\ -force \u5E38\u306B\u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u3092\u66F8\u304D\u8FBC\u3080 - -main.opt.module_path=\ --module-path \u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u30FB\u30E2\u30B8\u30E5\u30FC\u30EB\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9 - -main.opt.upgrade_module_path=\ --upgrade_module-path \u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u30FB\u30E2\u30B8\u30E5\u30FC\u30EB\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9 - -main.opt.classpath=\ -classpath \u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9 - -main.opt.class_path=\ --class-path \u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9 - -main.opt.cp=\ -cp \u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9 - -main.opt.bootclasspath=\ -bootclasspath \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9 - -main.opt.system=\ --system \u30B7\u30B9\u30C6\u30E0\u30FB\u30E2\u30B8\u30E5\u30FC\u30EB\u3092\u691C\u7D22\u3059\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B - -main.usage.foot=\nGNU\u30B9\u30BF\u30A4\u30EB\u30FB\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u306F\u3001\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u540D\u524D\u3068\u305D\u306E\u5024\u3092\u533A\u5207\u308B\u305F\u3081\u306B\u7A7A\u767D\u3067\u306F\u306A\u304F'='\u3092\n\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002\n\n\u5404\u30AF\u30E9\u30B9\u306F\u3001\u305D\u306E\u5B8C\u5168\u4FEE\u98FE\u540D\u3067\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u3001\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u30E2\u30B8\u30E5\u30FC\u30EB\u540D\u306E\n\u63A5\u982D\u8F9E\u306B\u7D9A\u3051\u3066'/'\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002\u4F8B:\n java.lang.Object\n java.base/java.io.File\n -# -# Version string. -# -javah.version={0}\u30D0\u30FC\u30B8\u30E7\u30F3"{1}" -javah.fullVersion={0}\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"{1}" - -# -# These should have better diagnostics. -# -super.class.not.found=\u8981\u6C42\u3055\u308C\u305F\u30B9\u30FC\u30D1\u30FC\u30FB\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 -class.not.found=\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 -io.exception=\u30E1\u30C3\u30BB\u30FC\u30B8{0}\u306E\u5165\u51FA\u529B\u30A8\u30E9\u30FC\u304B\u3089\u56DE\u5FA9\u3067\u304D\u307E\u305B\u3093\u3002 - -# -# Problems in the guts of javah. -# -encoding.iso8859_1.not.found=\u51FA\u529B\u7528\u306EISO8859_1\u30B3\u30F3\u30D0\u30FC\u30BF\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306B\u30A8\u30E9\u30FC\u304C\u3042\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002 -tried.to.define.non.static=static\u3067\u306A\u3044\u30D5\u30A3\u30FC\u30EB\u30C9\u306B#define\u3092\u751F\u6210\u3057\u3088\u3046\u3068\u3057\u307E\u3057\u305F\u3002 -jni.unknown.type=\u4E0D\u660E\u306A\u578B\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F(JNI)\u3002 -unknown.array.type=\u53E4\u3044\u5F62\u5F0F\u306E\u30D8\u30C3\u30C0\u30FC\u3092\u751F\u6210\u3057\u3066\u3044\u308B\u3068\u304D\u306B\u4E0D\u660E\u306A\u914D\u5217\u306E\u578B\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002 -unknown.type.for.field=\u53E4\u3044\u5F62\u5F0F\u306E\u30D8\u30C3\u30C0\u30FC\u3092\u751F\u6210\u3057\u3066\u3044\u308B\u3068\u304D\u306B\u4E0D\u660E\u306A\u578B\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002 -unknown.type.in.method.signature=\u53E4\u3044\u5F62\u5F0F\u306E\u30B9\u30BF\u30D6\u3092\u751F\u6210\u3057\u3066\u3044\u308B\u3068\u304D\u306B\u4E0D\u660E\u306A\u578B\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002 - - -err.prefix=\u30A8\u30E9\u30FC: -err.cant.use.option.for.fm=\u6307\u5B9A\u3055\u308C\u305F\u30D5\u30A1\u30A4\u30EB\u30FB\u30DE\u30CD\u30FC\u30B8\u30E3\u3067{0}\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093 -err.internal.error=\u5185\u90E8\u30A8\u30E9\u30FC: {0} -err.ioerror=\u5165\u51FA\u529B\u30A8\u30E9\u30FC: {0} -err.missing.arg={0}\u306E\u5024\u304C\u3042\u308A\u307E\u305B\u3093 -err.no.classes.specified=\u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 -err.unknown.option=\u4E0D\u660E\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0} - -# -# miscellaneous strings -# -javah.misc.Deprecation=\n\u8B66\u544A: javah\u30C4\u30FC\u30EB\u306F\u6B21\u56DE\u306EJDK\u30E1\u30B8\u30E3\u30FC\u30FB\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u4E88\u5B9A\u3067\u3059\u3002\n\u3053\u306E\u30C4\u30FC\u30EB\u306FJDK 8\u3067javac\u306B\u8FFD\u52A0\u3055\u308C\u305F''-h''\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u3088\u3063\u3066\u7F6E\u304D\u63DB\u3048\u3089\u308C\u307E\u3057\u305F\u3002\n\u30E6\u30FC\u30B6\u30FC\u306Fjavac ''-h''\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u4F7F\u7528\u306B\u79FB\u884C\u3059\u308B\u3053\u3068\u3092\u304A\u85A6\u3081\u3057\u307E\u3059\u3002\n\u8A73\u7D30\u306F\u3001javac man\u30DA\u30FC\u30B8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -# -# Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# User errors, command line errors. -# -cant.create.dir=\u65E0\u6CD5\u4E3A\u8F93\u51FA\u521B\u5EFA\u76EE\u5F55 {0}\u3002 -at.args.cant.read=\u65E0\u6CD5\u4ECE\u6587\u4EF6{1}\u4E2D\u8BFB\u53D6\u547D\u4EE4\u884C\u53C2\u6570\u3002 -at.args.file.not.found=\u627E\u4E0D\u5230\u6587\u4EF6{0}\u3002 -at.args.io.exception=\u5904\u7406\u547D\u4EE4\u884C\u4E2D\u7684 @ \u53C2\u6570\u65F6, \u9047\u5230\u4EE5\u4E0B I/O \u95EE\u9898: {0}\u3002 -bad.arg=\u9519\u8BEF\u53C2\u6570: {0} -old.jni.mixed=\u4E0D\u80FD\u6DF7\u7528\u9009\u9879 -jni \u548C -old\u3002\u8BF7\u5C1D\u8BD5\u4F7F\u7528 -help\u3002 -old.llni.mixed=\u4E0D\u80FD\u6DF7\u7528\u9009\u9879 -old \u548C -llni\u3002\u8BF7\u5C1D\u8BD5\u4F7F\u7528 -help\u3002 -old.not.supported=\u6B64\u7248\u672C\u7684 javah \u4E0D\u652F\u6301\u9009\u9879 -old\u3002 -invalid.method.signature=\u65E0\u6548\u7684\u65B9\u6CD5\u7B7E\u540D: {0} -jni.llni.mixed=\u4E0D\u80FD\u6DF7\u7528\u9009\u9879 -jni \u548C -llni\u3002\u8BF7\u5C1D\u8BD5\u4F7F\u7528 -help\u3002 -jni.no.stubs=JNI \u4E0D\u9700\u8981\u5B58\u6839, \u8BF7\u53C2\u9605 JNI \u6587\u6863\u3002 -jni.sigerror=\u65E0\u6CD5\u786E\u5B9A{0}\u7684\u7B7E\u540D -dir.file.mixed=\u4E0D\u80FD\u6DF7\u7528\u9009\u9879 -d \u548C -o\u3002\u8BF7\u5C1D\u8BD5\u4F7F\u7528 -help\u3002 -no.classes.specified=\u672A\u5728\u547D\u4EE4\u884C\u4E2D\u6307\u5B9A\u4EFB\u4F55\u7C7B\u3002\u8BF7\u5C1D\u8BD5\u4F7F\u7528 -help\u3002 -no.outputfile.specified=\u672A\u5728\u547D\u4EE4\u884C\u4E2D\u6307\u5B9A\u4EFB\u4F55\u8F93\u51FA\u6587\u4EF6\u3002\u8BF7\u5C1D\u8BD5\u4F7F\u7528 -help\u3002 -no.outputdir.specified=\u672A\u5728\u547D\u4EE4\u884C\u4E2D\u6307\u5B9A\u4EFB\u4F55\u8F93\u51FA\u76EE\u5F55\u3002\u8BF7\u5C1D\u8BD5\u4F7F\u7528 -help\u3002 -no.classpath.specified=\u672A\u5728\u547D\u4EE4\u884C\u4E2D\u6307\u5B9A\u4EFB\u4F55\u7C7B\u8DEF\u5F84\u3002\u8BF7\u5C1D\u8BD5\u4F7F\u7528 -help\u3002 -no.bootclasspath.specified=\u672A\u5728\u547D\u4EE4\u884C\u4E2D\u6307\u5B9A\u4EFB\u4F55\u5F15\u5BFC\u7C7B\u8DEF\u5F84\u3002\u8BF7\u5C1D\u8BD5\u4F7F\u7528 -help\u3002 -unknown.option={0}\u662F\u975E\u6CD5\u53C2\u6570\n -tracing.not.supported=\u8B66\u544A: \u4E0D\u518D\u652F\u6301\u8DDF\u8E2A\u3002\u8BF7\u4F7F\u7528\u865A\u62DF\u673A\u7684 -verbose:jni \u9009\u9879\u3002 - -main.usage=\u7528\u6CD5: \n javah [options] \n\u5176\u4E2D, [options] \u5305\u62EC: - -main.opt.o=\ -o \u8F93\u51FA\u6587\u4EF6 (\u53EA\u80FD\u4F7F\u7528 -d \u6216 -o \u4E4B\u4E00) - -main.opt.d=\ -d \u8F93\u51FA\u76EE\u5F55 - -main.opt.v=\ -v -verbose \u542F\u7528\u8BE6\u7EC6\u8F93\u51FA - -main.opt.h=\ -h --help -? \u8F93\u51FA\u6B64\u6D88\u606F - -main.opt.version=\ -version \u8F93\u51FA\u7248\u672C\u4FE1\u606F - -main.opt.jni=\ -jni \u751F\u6210 JNI \u6837\u5F0F\u7684\u6807\u5934\u6587\u4EF6 (\u9ED8\u8BA4\u503C) - -main.opt.force=\ -force \u59CB\u7EC8\u5199\u5165\u8F93\u51FA\u6587\u4EF6 - -main.opt.module_path=\ --module-path <\u8DEF\u5F84> \u4ECE\u4E2D\u52A0\u8F7D\u5E94\u7528\u7A0B\u5E8F\u6A21\u5757\u7684\u8DEF\u5F84 - -main.opt.upgrade_module_path=\ --upgrade_module-path <\u8DEF\u5F84> \u4ECE\u4E2D\u52A0\u8F7D\u5E94\u7528\u7A0B\u5E8F\u6A21\u5757\u7684\u8DEF\u5F84 - -main.opt.classpath=\ -classpath \u4ECE\u4E2D\u52A0\u8F7D\u7C7B\u7684\u8DEF\u5F84 - -main.opt.class_path=\ --class-path <\u8DEF\u5F84> \u4ECE\u4E2D\u52A0\u8F7D\u7C7B\u7684\u8DEF\u5F84 - -main.opt.cp=\ -cp \u4ECE\u4E2D\u52A0\u8F7D\u7C7B\u7684\u8DEF\u5F84 - -main.opt.bootclasspath=\ -bootclasspath \u4ECE\u4E2D\u52A0\u8F7D\u5F15\u5BFC\u7C7B\u7684\u8DEF\u5F84 - -main.opt.system=\ --system \u6307\u5B9A\u67E5\u627E\u7CFB\u7EDF\u6A21\u5757\u7684\u4F4D\u7F6E - -main.usage.foot=\nGNU \u6837\u5F0F\u7684\u9009\u9879\u53EF\u4F7F\u7528 '=' (\u800C\u975E\u7A7A\u767D) \u6765\u5206\u9694\u9009\u9879\u540D\u79F0\n\u53CA\u5176\u503C\u3002\n\n\u6BCF\u4E2A\u7C7B\u5FC5\u987B\u7531\u5176\u5168\u9650\u5B9A\u540D\u79F0\u6307\u5B9A, \n\u53EF\u4EE5\u9009\u62E9\u6027\u5730\u4F7F\u7528\u6A21\u5757\u540D\u540E\u8DDF '/' \u4F5C\u4E3A\u524D\u7F00\u3002\u793A\u4F8B:\n java.lang.Object\n java.base/java.io.File\n -# -# Version string. -# -javah.version={0}\u7248\u672C "{1}" -javah.fullVersion={0}\u5B8C\u6574\u7248\u672C "{1}" - -# -# These should have better diagnostics. -# -super.class.not.found=\u627E\u4E0D\u5230\u6240\u9700\u7684\u8D85\u7C7B{0}\u3002 -class.not.found=\u627E\u4E0D\u5230\u7C7B{0}\u3002 -io.exception=\u65E0\u6CD5\u4ECE I/O \u9519\u8BEF\u4E2D\u6062\u590D, \u6D88\u606F\u4E3A: {0}\u3002 - -# -# Problems in the guts of javah. -# -encoding.iso8859_1.not.found=\u627E\u4E0D\u5230\u7528\u4E8E\u8F93\u51FA\u7684 ISO8859_1 \u8F6C\u6362\u5668\u3002\u8FD9\u53EF\u80FD\u662F\u56E0\u4E3A\u5B89\u88C5\u8FC7\u7A0B\u4E2D\u51FA\u73B0\u4E86\u9519\u8BEF\u3002 -tried.to.define.non.static=\u5C1D\u8BD5\u4E3A\u975E\u9759\u6001\u5B57\u6BB5\u751F\u6210 #define\u3002 -jni.unknown.type=\u9047\u5230\u672A\u77E5\u7C7B\u578B (JNI)\u3002 -unknown.array.type=\u751F\u6210\u65E7\u6837\u5F0F\u7684\u6807\u5934\u65F6\u9047\u5230\u672A\u77E5\u7684\u6570\u7EC4\u7C7B\u578B\u3002 -unknown.type.for.field=\u751F\u6210\u65E7\u6837\u5F0F\u7684\u6807\u5934\u65F6\u9047\u5230\u672A\u77E5\u7684\u7C7B\u578B\u3002 -unknown.type.in.method.signature=\u751F\u6210\u65E7\u6837\u5F0F\u7684\u5B58\u6839\u65F6\u9047\u5230\u672A\u77E5\u7684\u7C7B\u578B\u3002 - - -err.prefix=\u9519\u8BEF: -err.cant.use.option.for.fm=\u4E0D\u80FD\u5C06{0}\u9009\u9879\u4E0E\u7ED9\u5B9A\u7684\u6587\u4EF6\u7BA1\u7406\u5668\u4E00\u8D77\u4F7F\u7528 -err.internal.error=\u5185\u90E8\u9519\u8BEF: {0} -err.ioerror=IO \u9519\u8BEF: {0} -err.missing.arg={0}\u7F3A\u5C11\u503C -err.no.classes.specified=\u672A\u6307\u5B9A\u7C7B -err.unknown.option=\u672A\u77E5\u9009\u9879: {0} - -# -# miscellaneous strings -# -javah.misc.Deprecation=\n\u8B66\u544A: \u5DF2\u8BA1\u5212\u5728\u4E0B\u4E00\u4E2A JDK \u4E3B\u53D1\u884C\u7248\u4E2D\u5220\u9664 javah\n\u5DE5\u5177\u3002\u8BE5\u5DE5\u5177\u5728 JDK 8 \u4E2D\u5DF2\u7531\u6DFB\u52A0\u5230 javac \u7684\n''-h'' \u9009\u9879\u53D6\u4EE3\u3002\u5EFA\u8BAE\u7528\u6237\u6539\u4E3A\u4F7F\u7528 javac ''-h''\n\u9009\u9879; \u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u67E5\u770B javac \u5E2E\u52A9\u9875\u3002\n diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/com/sun/tools/javah/resources/version.properties-template --- a/src/jdk.compiler/share/classes/com/sun/tools/javah/resources/version.properties-template Fri Dec 15 11:23:50 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -# -# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. 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. -# - -jdk=$(JDK_VERSION) -full=$(FULL_VERSION) -release=$(RELEASE) diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.compiler/share/classes/module-info.java --- a/src/jdk.compiler/share/classes/module-info.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/jdk.compiler/share/classes/module-info.java Fri Dec 15 16:54:17 2017 +0100 @@ -26,8 +26,7 @@ /** * Defines the implementation of the * {@linkplain javax.tools.ToolProvider#getSystemJavaCompiler system Java compiler} - * and its command line equivalent, {@index javac javac tool}, - * as well as {@index javah javah tool}. + * and its command line equivalent, {@index javac javac tool}. * * javac
* @@ -56,17 +55,9 @@ * {@code jdk.zipfs} module, must be available if the compiler is to be able * to read JAR files. * - *javah
- * - *- * javah only exists as a command line tool, and does not provide any - * direct API. As of JDK 9, it has been deprecated. - * Use the {@code -h} option in javac instead.
- * **
* * @provides java.util.spi.ToolProvider diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java Fri Dec 15 16:54:17 2017 +0100 @@ -96,6 +96,7 @@ public final Content errors; public final Content exception; public final Content exceptions; + public final Content exportedTo; public final Content fieldLabel; public final Content fieldDetailsLabel; public final Content fieldSummaryLabel; @@ -147,6 +148,7 @@ public final Content noFramesLabel; public final Content noScriptMessage; public final Content openModuleLabel; + public final Content openedTo; public final Content overridesLabel; public final Content overviewLabel; public final Content packageHierarchies; @@ -229,6 +231,7 @@ errors = getContent("doclet.Errors"); exception = getContent("doclet.Exception"); exceptions = getContent("doclet.Exceptions"); + exportedTo = getContent("doclet.ExportedTo"); fieldDetailsLabel = getContent("doclet.Field_Detail"); fieldSummaryLabel = getContent("doclet.Field_Summary"); fieldLabel = getContent("doclet.Field"); @@ -279,6 +282,7 @@ nextPackageLabel = getNonBreakContent("doclet.Next_Package"); noFramesLabel = getNonBreakContent("doclet.No_Frames"); noScriptMessage = getContent("doclet.No_Script_Message"); + openedTo = getContent("doclet.OpenedTo"); openModuleLabel = getContent("doclet.Open_Module"); overridesLabel = getContent("doclet.Overrides"); overviewLabel = getContent("doclet.Overview"); diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Fri Dec 15 16:54:17 2017 +0100 @@ -106,21 +106,34 @@ = new TreeMap<>(utils.makeModuleComparator()); /** - * Map of packages exported by this module and the modules it has been exported to. + * Details about a package in a module. + * A package may be not exported, or exported to some modules, or exported to all modules. + * A package may be not opened, or opened to some modules, or opened to all modules. + * A package that is neither exported or opened to any modules is a concealed package. + * An open module opens all its packages to all modules. */ - private final Map- Tool Guides: - *
- {@extLink javac_tool_reference javac}, - * {@extLink javah_tool_reference javah} + *
- {@extLink javac_tool_reference javac} *
> exportedPackages - = new TreeMap<>(utils.makePackageComparator()); + class PackageEntry { + /** + * Summary of package exports: + * If null, the package is not exported to any modules; + * if empty, the package is exported to all modules; + * otherwise, the package is exported to these modules. + */ + Set exportedTo; + + /** + * Summary of package opens: + * If null, the package is not opened to any modules; + * if empty, the package is opened to all modules; + * otherwise, the package is opened to these modules. + */ + Set openedTo; + } /** - * Map of opened packages by this module and the modules it has been opened to. + * Map of packages of this module, and details of whether they are exported or opened. */ - private final Map > openedPackages - = new TreeMap<>(utils.makePackageComparator()); - - /** - * Set of concealed packages of this module. - */ - private final SortedSet concealedPackages = new TreeSet<>(utils.makePackageComparator()); + private final Map packages = new TreeMap<>(utils.makePackageComparator()); /** * Map of indirect modules (transitive closure) and their exported packages. @@ -284,51 +297,52 @@ } }); - // Get all packages for the module and put it in the concealed packages set. - utils.getModulePackageMap().getOrDefault(mdle, Collections.emptySet()).forEach((pkg) -> { - if (shouldDocument(pkg) && moduleMode == ModuleMode.ALL) { - concealedPackages.add(pkg); + // Get all packages if module is open or if displaying concealed modules + for (PackageElement pkg : utils.getModulePackageMap().getOrDefault(mdle, Collections.emptySet())) { + if (shouldDocument(pkg) && (mdle.isOpen() || moduleMode == ModuleMode.ALL)) { + PackageEntry e = new PackageEntry(); + if (mdle.isOpen()) { + e.openedTo = Collections.emptySet(); + } + packages.put(pkg, e); } - }); + }; - // Get all exported packages for the module using the exports directive for the module. - (ElementFilter.exportsIn(mdle.getDirectives())).forEach((directive) -> { + // Get all exported packages for the module, using the exports directive for the module. + for (ModuleElement.ExportsDirective directive : ElementFilter.exportsIn(mdle.getDirectives())) { PackageElement p = directive.getPackage(); if (shouldDocument(p)) { - SortedSet mdleList = new TreeSet<>(utils.makeModuleComparator()); List extends ModuleElement> targetMdles = directive.getTargetModules(); - if (targetMdles != null) { - mdleList.addAll(targetMdles); - } - // Qualified exports should not be displayed in the api mode. So if mdleList is empty, - // its exported to all modules and hence can be added. - if (moduleMode == ModuleMode.ALL || mdleList.isEmpty()) { - exportedPackages.put(p, mdleList); - } - if (moduleMode == ModuleMode.ALL) { - concealedPackages.remove(p); + // Include package if in details mode, or exported to all (i.e. targetModules == null) + if (moduleMode == ModuleMode.ALL || targetMdles == null) { + PackageEntry packageEntry = packages.computeIfAbsent(p, pkg -> new PackageEntry()); + SortedSet mdleList = new TreeSet<>(utils.makeModuleComparator()); + if (targetMdles != null) { + mdleList.addAll(targetMdles); + } + packageEntry.exportedTo = mdleList; } } - }); - // Get all opened packages for the module using the opens directive for the module. - (ElementFilter.opensIn(mdle.getDirectives())).forEach((directive) -> { + } + + // Get all opened packages for the module, using the opens directive for the module. + // If it is an open module, there will be no separate opens directives. + for (ModuleElement.OpensDirective directive : ElementFilter.opensIn(mdle.getDirectives())) { PackageElement p = directive.getPackage(); if (shouldDocument(p)) { - SortedSet mdleList = new TreeSet<>(utils.makeModuleComparator()); List extends ModuleElement> targetMdles = directive.getTargetModules(); - if (targetMdles != null) { - mdleList.addAll(targetMdles); - } - // Qualified opens should not be displayed in the api mode. So if mdleList is empty, - // it is opened to all modules and hence can be added. - if (moduleMode == ModuleMode.ALL || mdleList.isEmpty()) { - openedPackages.put(p, mdleList); - } - if (moduleMode == ModuleMode.ALL) { - concealedPackages.remove(p); + // Include package if in details mode, or opened to all (i.e. targetModules == null) + if (moduleMode == ModuleMode.ALL || targetMdles == null) { + PackageEntry packageEntry = packages.computeIfAbsent(p, pkg -> new PackageEntry()); + SortedSet mdleList = new TreeSet<>(utils.makeModuleComparator()); + if (targetMdles != null) { + mdleList.addAll(targetMdles); + } + packageEntry.openedTo = mdleList; } } - }); + } + // Get all the exported and opened packages, for the transitive closure of the module, to be displayed in // the indirect packages tables. dependentModules.forEach((module, mod) -> { @@ -348,15 +362,19 @@ indirectPackages.put(module, exportPkgList); } SortedSet openPkgList = new TreeSet<>(utils.makePackageComparator()); - (ElementFilter.opensIn(module.getDirectives())).forEach((directive) -> { - PackageElement pkg = directive.getPackage(); - if (shouldDocument(pkg)) { - // Qualified opens are not displayed in API mode - if (moduleMode == ModuleMode.ALL || directive.getTargetModules() == null) { - openPkgList.add(pkg); + if (module.isOpen()) { + openPkgList.addAll(utils.getModulePackageMap().getOrDefault(module, Collections.emptySet())); + } else { + (ElementFilter.opensIn(module.getDirectives())).forEach((directive) -> { + PackageElement pkg = directive.getPackage(); + if (shouldDocument(pkg)) { + // Qualified opens are not displayed in API mode + if (moduleMode == ModuleMode.ALL || directive.getTargetModules() == null) { + openPkgList.add(pkg); + } } - } - }); + }); + } // If none of the indirect modules have opened packages to be displayed, we should not be // displaying the table and so it should not be added to the map. if (!openPkgList.isEmpty()) { @@ -556,13 +574,13 @@ @Override public void addPackagesSummary(Content summaryContentTree) { - if (display(exportedPackages) || display(openedPackages) || display(concealedPackages) + if (display(packages) || display(indirectPackages) || display(indirectOpenPackages)) { HtmlTree li = new HtmlTree(HtmlTag.LI); li.setStyle(HtmlStyle.blockList); addSummaryHeader(HtmlConstants.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES, contents.navPackages, li); - if (display(exportedPackages) || display(openedPackages) || display(concealedPackages)) { + if (display(packages)) { String tableSummary = resources.getText("doclet.Member_Table_Summary", resources.getText("doclet.Packages_Summary"), resources.getText("doclet.packages")); @@ -607,77 +625,115 @@ Table table = new Table(configuration.htmlVersion, HtmlStyle.packagesSummary) .setSummary(tableSummary) .setDefaultTab(resources.getText("doclet.All_Packages")) - .addTab(resources.getText("doclet.Exported_Packages_Summary"), - e -> exportedPackages.containsKey((PackageElement) e)) - .addTab(resources.getText("doclet.Opened_Packages_Summary"), - e -> openedPackages.containsKey((PackageElement) e)) - .addTab(resources.getText("doclet.Concealed_Packages_Summary"), - e -> concealedPackages.contains((PackageElement) e)) + .addTab(resources.getText("doclet.Exported_Packages_Summary"), this::isExported) + .addTab(resources.getText("doclet.Opened_Packages_Summary"), this::isOpened) + .addTab(resources.getText("doclet.Concealed_Packages_Summary"), this::isConcealed) .setTabScript(i -> String.format("showPkgs(%d);", i)) .setTabScriptVariable("packages"); - if (configuration.docEnv.getModuleMode() == ModuleMode.API) { - table.setHeader(new TableHeader(contents.packageLabel, contents.descriptionLabel)) - .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); - } else { - table.setHeader(new TableHeader(contents.packageLabel, contents.moduleLabel, contents.descriptionLabel)) - .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast); + // Determine whether to show the "Exported To" and "Opened To" columns, + // based on whether such columns would provide "useful" info. + int numExports = 0; + int numUnqualifiedExports = 0; + int numOpens = 0; + int numUnqualifiedOpens = 0; + + for (PackageEntry e : packages.values()) { + if (e.exportedTo != null) { + numExports++; + if (e.exportedTo.isEmpty()) { + numUnqualifiedExports++; + } + } + if (e.openedTo != null) { + numOpens++; + if (e.openedTo.isEmpty()) { + numUnqualifiedOpens++; + } + } } - addPackageTableRows(table); + boolean showExportedTo = numExports > 0 && (numOpens > 0 || numUnqualifiedExports < packages.size()); + boolean showOpenedTo = numOpens > 0 && (numExports > 0 || numUnqualifiedOpens < packages.size()); + + // Create the table header and column styles. + List colHeaders = new ArrayList<>(); + List colStyles = new ArrayList<>(); + colHeaders.add(contents.packageLabel); + colStyles.add(HtmlStyle.colFirst); + + if (showExportedTo) { + colHeaders.add(contents.exportedTo); + colStyles.add(HtmlStyle.colSecond); + } + + if (showOpenedTo) { + colHeaders.add(contents.openedTo); + colStyles.add(HtmlStyle.colSecond); + } + + colHeaders.add(contents.descriptionLabel); + colStyles.add(HtmlStyle.colLast); + + table.setHeader(new TableHeader(colHeaders).styles(colStyles)) + .setColumnStyles(colStyles); + + // Add the table rows, based on the "packages" map. + for (Map.Entry e : packages.entrySet()) { + PackageElement pkg = e.getKey(); + PackageEntry entry = e.getValue(); + List row = new ArrayList<>(); + Content pkgLinkContent = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); + row.add(pkgLinkContent); + + if (showExportedTo) { + row.add(getPackageExportOpensTo(entry.exportedTo)); + } + if (showOpenedTo) { + row.add(getPackageExportOpensTo(entry.openedTo)); + } + Content summary = new ContentBuilder(); + addSummaryComment(pkg, summary); + row.add(summary); + + table.addRow(pkg, row); + } + li.addContent(table.toContent()); if (table.needsScript()) { mainBodyScript.append(table.getScript()); } } - /** - * Get the package table rows. - * - * @return a content object - */ - private void addPackageTableRows(Table table) { - addPackageTableRows(table, exportedPackages); - addPackageTableRows(table, openedPackages); - // Show concealed packages only in "all" mode. - if (moduleMode == ModuleMode.ALL) { - for (PackageElement pkg : concealedPackages) { - Content pkgLinkContent = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); - Content noModules = new StringContent(resources.getText("doclet.None")); - Content summary = new ContentBuilder(); - addSummaryComment(pkg, summary); - table.addRow(pkg, pkgLinkContent, noModules, summary); - } - } + private boolean isExported(Element e) { + PackageEntry entry = packages.get((PackageElement) e); + return (entry != null) && (entry.exportedTo != null); + } + + private boolean isOpened(Element e) { + PackageEntry entry = packages.get((PackageElement) e); + return (entry != null) && (entry.openedTo != null); + } + + private boolean isConcealed(Element e) { + PackageEntry entry = packages.get((PackageElement) e); + return (entry != null) && (entry.exportedTo == null) && (entry.openedTo == null); } - private void addPackageTableRows(Table table, Map > ap) { - for (Map.Entry > entry : ap.entrySet()) { - List row = new ArrayList<>(); - PackageElement pkg = entry.getKey(); - SortedSet mdleList = entry.getValue(); - Content pkgLinkContent = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); - row.add(pkgLinkContent); - - if (moduleMode == ModuleMode.ALL) { - Content modules = new ContentBuilder(); - if (!mdleList.isEmpty()) { - for (ModuleElement m : mdleList) { - if (!modules.isEmpty()) { - modules.addContent(new HtmlTree(HtmlTag.BR)); - } - modules.addContent(getModuleLink(m, new StringContent(m.getQualifiedName()))); - } - } else { - Content allModules = new StringContent(resources.getText("doclet.All_Modules")); - modules.addContent(allModules); + private Content getPackageExportOpensTo(Set modules) { + if (modules == null) { + return new StringContent(resources.getText("doclet.None")); + } else if (modules.isEmpty()) { + return new StringContent(resources.getText("doclet.All_Modules")); + } else { + Content list = new ContentBuilder(); + for (ModuleElement m : modules) { + if (!list.isEmpty()) { + list.addContent(new StringContent(", ")); } - row.add(modules); + list.addContent(getModuleLink(m, new StringContent(m.getQualifiedName()))); } - Content summary = new ContentBuilder(); - addSummaryComment(pkg, summary); - row.add(summary); - table.addRow(pkg, row); + return list; } } @@ -692,14 +748,14 @@ ModuleElement m = entry.getKey(); SortedSet pkgList = entry.getValue(); Content moduleLinkContent = getModuleLink(m, new StringContent(m.getQualifiedName())); - Content packages = new ContentBuilder(); + Content list = new ContentBuilder(); String sep = ""; for (PackageElement pkg : pkgList) { - packages.addContent(sep); - packages.addContent(getPackageLink(pkg, new StringContent(utils.getPackageName(pkg)))); + list.addContent(sep); + list.addContent(getPackageLink(pkg, new StringContent(utils.getPackageName(pkg)))); sep = " "; } - table.addRow(moduleLinkContent, packages); + table.addRow(moduleLinkContent, list); } } @@ -898,7 +954,7 @@ ? Links.createLink(SectionName.MODULES, contents.navModules) : contents.navModules); addNavGap(liNav); - liNav.addContent((display(exportedPackages) || display(openedPackages) || display(concealedPackages) + liNav.addContent((display(packages) || display(indirectPackages) || display(indirectOpenPackages)) ? Links.createLink(SectionName.PACKAGES, contents.navPackages) : contents.navPackages); diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/TableHeader.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/TableHeader.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/TableHeader.java Fri Dec 15 16:54:17 2017 +0100 @@ -77,6 +77,14 @@ } /** + * Creates a header row, with specified content for each cell. + * @param headerCellContents a content object for each header cell + */ + public TableHeader(List headerCellContents) { + this.cellContents = headerCellContents; + } + + /** * Set the style class names for each header cell. * The number of names must match the number of cells given to the constructor. * @param styles the style class names @@ -91,6 +99,20 @@ } /** + * Set the style class names for each header cell. + * The number of names must match the number of cells given to the constructor. + * @param styles the style class names + * @return this object + */ + public TableHeader styles(List styles) { + if (styles.size() != cellContents.size()) { + throw new IllegalStateException(); + } + this.styles = styles; + return this; + } + + /** * Converts this header to a {@link Content} object, for use in an {@link HtmlTree}. * @return a Content object */ diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties Fri Dec 15 11:23:50 2017 -0500 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties Fri Dec 15 16:54:17 2017 +0100 @@ -145,6 +145,8 @@ doclet.Exception=Exception doclet.exception=exception doclet.exceptions=exceptions +doclet.ExportedTo=Exported To Modules +doclet.OpenedTo=Opened To Modules doclet.Package_private=(package private) doclet.Nested_Classes_Interfaces_Inherited_From_Class=Nested classes/interfaces inherited from class doclet.Nested_Classes_Interfaces_Inherited_From_Interface=Nested classes/interfaces inherited from interface diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java --- a/src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java Fri Dec 15 16:54:17 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -181,7 +181,7 @@ } private static String getOnlineDocUrl() { - String version = Integer.toString(Runtime.version().major()); + String version = Integer.toString(Runtime.version().feature()); return Resources.format(Messages.HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL, version); } diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java Fri Dec 15 11:23:50 2017 -0500 +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java Fri Dec 15 16:54:17 2017 +0100 @@ -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 @@ -45,14 +45,14 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; -import static javax.lang.model.SourceVersion.RELEASE_9; +import static javax.lang.model.SourceVersion.RELEASE_10; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; import javax.lang.model.element.PackageElement; import javax.tools.Diagnostic; -@SupportedSourceVersion(RELEASE_9) +@SupportedSourceVersion(RELEASE_10) @SupportedAnnotationTypes("*") public class TraverseProc extends AbstractProcessor { Elements elements; diff -r 474cec233fb2 -r 0c0b618a20b1 src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md Fri Dec 15 11:23:50 2017 -0500 +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md Fri Dec 15 16:54:17 2017 +0100 @@ -1,6 +1,6 @@