This commit is contained in:
Jesper Wilhelmsson 2017-12-15 16:54:17 +01:00
commit 4db5d786b7
133 changed files with 2370 additions and 11018 deletions

View File

@ -460,3 +460,5 @@ a2008587c13fa05fa2dbfcb09fe987576fbedfd1 jdk-10+32
bbd692ad4fa300ecca7939ffbe3b1d5e52a28cc6 jdk-10+33
89deac44e51517841491ba86ff44aa82a5ca96b3 jdk-10+34
d8c634b016c628622c9abbdc6bf50509e5dedbec jdk-10+35
0ee20aad71c4f33c426372b4c8bcc1235ce2ec08 jdk-11+0
959f2f7cbaa6d2ee45d50029744efb219721576c jdk-10+36

37
ADDITIONAL_LICENSE_INFO Normal file
View File

@ -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.

View File

@ -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 @@ ifeq ($(OPENJDK_TARGET_OS), macosx)
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

View File

@ -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 @@ define create-info-file
$(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

View File

@ -313,7 +313,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
-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 \

View File

@ -887,6 +887,8 @@ JAVA
BOOT_JDK
JAVA_CHECK
JAVAC_CHECK
VENDOR_VERSION_STRING
VERSION_DATE
VERSION_IS_GA
VERSION_SHORT
VERSION_STRING
@ -896,9 +898,9 @@ VERSION_OPT
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 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
@ -1141,14 +1144,19 @@ with_milestone
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 @@ datadir='${datarootdir}'
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 @@ do
| -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 @@ fi
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 @@ Fine tuning of the installation directories:
--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 @@ Optional Packages:
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 @@ Optional Packages:
[<timestamp>.<user>.<dirname>]
--with-version-build Set version 'BUILD' field (build number) [not
specified]
--with-version-major Set version 'MAJOR' field (first number) [current
--with-version-feature Set version 'FEATURE' field (first number) [current
source value]
--with-version-minor Set version 'MINOR' field (second number) [current
--with-version-interim Set version 'INTERIM' field (second number) [current
source value]
--with-version-security Set version 'SECURITY' field (third number) [current
--with-version-update Set version 'UPDATE' field (third number) [current
source value]
--with-version-patch Set version 'PATCH' field (fourth number) [not
specified]
--with-version-date Set version date [current source value]
--with-vendor-version-string
Set vendor version string [not specified]
--with-boot-jdk path to Boot JDK (used to bootstrap build) [probed]
--with-build-jdk path to JDK of same version as is being built[the
newly built JDK]
@ -4447,7 +4475,7 @@ VALID_JVM_VARIANTS="server client minimal core zero custom"
#
# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -5157,7 +5185,7 @@ VS_SDK_PLATFORM_NAME_2013=
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
DATE_WHEN_GENERATED=1512638287
DATE_WHEN_GENERATED=1513206608
###############################################################################
#
@ -24988,6 +25016,33 @@ fi
# Check whether --with-version-major was given.
if test "${with_version_major+set}" = set; then :
withval=$with_version_major; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --with-version-major is deprecated and will be ignored." >&5
$as_echo "$as_me: WARNING: Option --with-version-major is deprecated and will be ignored." >&2;}
fi
# Check whether --with-version-minor was given.
if test "${with_version_minor+set}" = set; then :
withval=$with_version_minor; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --with-version-minor is deprecated and will be ignored." >&5
$as_echo "$as_me: WARNING: Option --with-version-minor is deprecated and will be ignored." >&2;}
fi
# Check whether --with-version-security was given.
if test "${with_version_security+set}" = set; then :
withval=$with_version_security; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --with-version-security is deprecated and will be ignored." >&5
$as_echo "$as_me: WARNING: Option --with-version-security is deprecated and will be ignored." >&2;}
fi
# Source the version numbers file
. $AUTOCONF_DIR/version-numbers
@ -25016,20 +25071,20 @@ fi
elif test "x$with_version_string" != x; then
# Additional [] needed to keep m4 from mangling shell constructs.
if [[ $with_version_string =~ ^([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(-([a-zA-Z]+))?((\+)([0-9]+)?(-([-a-zA-Z0-9.]+))?)?$ ]] ; then
VERSION_MAJOR=${BASH_REMATCH[1]}
VERSION_MINOR=${BASH_REMATCH[3]}
VERSION_SECURITY=${BASH_REMATCH[5]}
VERSION_FEATURE=${BASH_REMATCH[1]}
VERSION_INTERIM=${BASH_REMATCH[3]}
VERSION_UPDATE=${BASH_REMATCH[5]}
VERSION_PATCH=${BASH_REMATCH[7]}
VERSION_PRE=${BASH_REMATCH[9]}
version_plus_separator=${BASH_REMATCH[11]}
VERSION_BUILD=${BASH_REMATCH[12]}
VERSION_OPT=${BASH_REMATCH[14]}
# Unspecified numerical fields are interpreted as 0.
if test "x$VERSION_MINOR" = x; then
VERSION_MINOR=0
if test "x$VERSION_INTERIM" = x; then
VERSION_INTERIM=0
fi
if test "x$VERSION_SECURITY" = x; then
VERSION_SECURITY=0
if test "x$VERSION_UPDATE" = x; then
VERSION_UPDATE=0
fi
if test "x$VERSION_PATCH" = x; then
VERSION_PATCH=0
@ -25158,22 +25213,22 @@ $as_echo "$as_me: WARNING: Value for VERSION_BUILD has been sanitized from '$wit
fi
# Check whether --with-version-major was given.
if test "${with_version_major+set}" = set; then :
withval=$with_version_major; with_version_major_present=true
# Check whether --with-version-feature was given.
if test "${with_version_feature+set}" = set; then :
withval=$with_version_feature; with_version_feature_present=true
else
with_version_major_present=false
with_version_feature_present=false
fi
if test "x$with_version_major_present" = xtrue; then
if test "x$with_version_major" = xyes; then
as_fn_error $? "--with-version-major must have a value" "$LINENO" 5
if test "x$with_version_feature_present" = xtrue; then
if test "x$with_version_feature" = xyes; then
as_fn_error $? "--with-version-feature must have a value" "$LINENO" 5
else
# Additional [] needed to keep m4 from mangling shell constructs.
if ! [[ "$with_version_major" =~ ^0*([1-9][0-9]*)|(0)$ ]] ; then
as_fn_error $? "\"$with_version_major\" is not a valid numerical value for VERSION_MAJOR" "$LINENO" 5
if ! [[ "$with_version_feature" =~ ^0*([1-9][0-9]*)|(0)$ ]] ; then
as_fn_error $? "\"$with_version_feature\" is not a valid numerical value for VERSION_FEATURE" "$LINENO" 5
fi
# Extract the version number without leading zeros.
cleaned_value=${BASH_REMATCH[1]}
@ -25183,44 +25238,44 @@ fi
fi
if test $cleaned_value -gt 255; then
as_fn_error $? "VERSION_MAJOR is given as $with_version_major. This is greater than 255 which is not allowed." "$LINENO" 5
as_fn_error $? "VERSION_FEATURE is given as $with_version_feature. This is greater than 255 which is not allowed." "$LINENO" 5
fi
if test "x$cleaned_value" != "x$with_version_major"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_MAJOR has been sanitized from '$with_version_major' to '$cleaned_value'" >&5
$as_echo "$as_me: WARNING: Value for VERSION_MAJOR has been sanitized from '$with_version_major' to '$cleaned_value'" >&2;}
if test "x$cleaned_value" != "x$with_version_feature"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_FEATURE has been sanitized from '$with_version_feature' to '$cleaned_value'" >&5
$as_echo "$as_me: WARNING: Value for VERSION_FEATURE has been sanitized from '$with_version_feature' to '$cleaned_value'" >&2;}
fi
VERSION_MAJOR=$cleaned_value
VERSION_FEATURE=$cleaned_value
fi
else
if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
# Default is to get value from version-numbers
VERSION_MAJOR="$DEFAULT_VERSION_MAJOR"
VERSION_FEATURE="$DEFAULT_VERSION_FEATURE"
fi
fi
# Check whether --with-version-minor was given.
if test "${with_version_minor+set}" = set; then :
withval=$with_version_minor; with_version_minor_present=true
# Check whether --with-version-interim was given.
if test "${with_version_interim+set}" = set; then :
withval=$with_version_interim; with_version_interim_present=true
else
with_version_minor_present=false
with_version_interim_present=false
fi
if test "x$with_version_minor_present" = xtrue; then
if test "x$with_version_minor" = xyes; then
as_fn_error $? "--with-version-minor must have a value" "$LINENO" 5
elif test "x$with_version_minor" = xno; then
if test "x$with_version_interim_present" = xtrue; then
if test "x$with_version_interim" = xyes; then
as_fn_error $? "--with-version-interim must have a value" "$LINENO" 5
elif test "x$with_version_interim" = xno; then
# Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
VERSION_MINOR=0
elif test "x$with_version_minor" = x; then
VERSION_MINOR=0
VERSION_INTERIM=0
elif test "x$with_version_interim" = x; then
VERSION_INTERIM=0
else
# Additional [] needed to keep m4 from mangling shell constructs.
if ! [[ "$with_version_minor" =~ ^0*([1-9][0-9]*)|(0)$ ]] ; then
as_fn_error $? "\"$with_version_minor\" is not a valid numerical value for VERSION_MINOR" "$LINENO" 5
if ! [[ "$with_version_interim" =~ ^0*([1-9][0-9]*)|(0)$ ]] ; then
as_fn_error $? "\"$with_version_interim\" is not a valid numerical value for VERSION_INTERIM" "$LINENO" 5
fi
# Extract the version number without leading zeros.
cleaned_value=${BASH_REMATCH[1]}
@ -25230,44 +25285,44 @@ fi
fi
if test $cleaned_value -gt 255; then
as_fn_error $? "VERSION_MINOR is given as $with_version_minor. This is greater than 255 which is not allowed." "$LINENO" 5
as_fn_error $? "VERSION_INTERIM is given as $with_version_interim. This is greater than 255 which is not allowed." "$LINENO" 5
fi
if test "x$cleaned_value" != "x$with_version_minor"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_MINOR has been sanitized from '$with_version_minor' to '$cleaned_value'" >&5
$as_echo "$as_me: WARNING: Value for VERSION_MINOR has been sanitized from '$with_version_minor' to '$cleaned_value'" >&2;}
if test "x$cleaned_value" != "x$with_version_interim"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_INTERIM has been sanitized from '$with_version_interim' to '$cleaned_value'" >&5
$as_echo "$as_me: WARNING: Value for VERSION_INTERIM has been sanitized from '$with_version_interim' to '$cleaned_value'" >&2;}
fi
VERSION_MINOR=$cleaned_value
VERSION_INTERIM=$cleaned_value
fi
else
if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
# Default is 0, if unspecified
VERSION_MINOR=$DEFAULT_VERSION_MINOR
VERSION_INTERIM=$DEFAULT_VERSION_INTERIM
fi
fi
# Check whether --with-version-security was given.
if test "${with_version_security+set}" = set; then :
withval=$with_version_security; with_version_security_present=true
# Check whether --with-version-update was given.
if test "${with_version_update+set}" = set; then :
withval=$with_version_update; with_version_update_present=true
else
with_version_security_present=false
with_version_update_present=false
fi
if test "x$with_version_security_present" = xtrue; then
if test "x$with_version_security" = xyes; then
as_fn_error $? "--with-version-security must have a value" "$LINENO" 5
elif test "x$with_version_security" = xno; then
if test "x$with_version_update_present" = xtrue; then
if test "x$with_version_update" = xyes; then
as_fn_error $? "--with-version-update must have a value" "$LINENO" 5
elif test "x$with_version_update" = xno; then
# Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
VERSION_SECURITY=0
elif test "x$with_version_security" = x; then
VERSION_SECURITY=0
VERSION_UPDATE=0
elif test "x$with_version_update" = x; then
VERSION_UPDATE=0
else
# Additional [] needed to keep m4 from mangling shell constructs.
if ! [[ "$with_version_security" =~ ^0*([1-9][0-9]*)|(0)$ ]] ; then
as_fn_error $? "\"$with_version_security\" is not a valid numerical value for VERSION_SECURITY" "$LINENO" 5
if ! [[ "$with_version_update" =~ ^0*([1-9][0-9]*)|(0)$ ]] ; then
as_fn_error $? "\"$with_version_update\" is not a valid numerical value for VERSION_UPDATE" "$LINENO" 5
fi
# Extract the version number without leading zeros.
cleaned_value=${BASH_REMATCH[1]}
@ -25277,19 +25332,19 @@ fi
fi
if test $cleaned_value -gt 255; then
as_fn_error $? "VERSION_SECURITY is given as $with_version_security. This is greater than 255 which is not allowed." "$LINENO" 5
as_fn_error $? "VERSION_UPDATE is given as $with_version_update. This is greater than 255 which is not allowed." "$LINENO" 5
fi
if test "x$cleaned_value" != "x$with_version_security"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_SECURITY has been sanitized from '$with_version_security' to '$cleaned_value'" >&5
$as_echo "$as_me: WARNING: Value for VERSION_SECURITY has been sanitized from '$with_version_security' to '$cleaned_value'" >&2;}
if test "x$cleaned_value" != "x$with_version_update"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_UPDATE has been sanitized from '$with_version_update' to '$cleaned_value'" >&5
$as_echo "$as_me: WARNING: Value for VERSION_UPDATE has been sanitized from '$with_version_update' to '$cleaned_value'" >&2;}
fi
VERSION_SECURITY=$cleaned_value
VERSION_UPDATE=$cleaned_value
fi
else
if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
# Default is 0, if unspecified
VERSION_SECURITY=$DEFAULT_VERSION_SECURITY
VERSION_UPDATE=$DEFAULT_VERSION_UPDATE
fi
fi
@ -25350,7 +25405,7 @@ $as_echo "$as_me: WARNING: Value for VERSION_PATCH has been sanitized from '$wit
fi
# VERSION_NUMBER but always with exactly 4 positions, with 0 for empty positions.
VERSION_NUMBER_FOUR_POSITIONS=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_SECURITY.$VERSION_PATCH
VERSION_NUMBER_FOUR_POSITIONS=$VERSION_FEATURE.$VERSION_INTERIM.$VERSION_UPDATE.$VERSION_PATCH
stripped_version_number=$VERSION_NUMBER_FOUR_POSITIONS
# Strip trailing zeroes from stripped_version_number
@ -25368,6 +25423,40 @@ $as_echo "$as_me: WARNING: Value for VERSION_PATCH has been sanitized from '$wit
# The short version string, just VERSION_NUMBER and PRE, if present.
VERSION_SHORT=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE}
# The version date
# Check whether --with-version-date was given.
if test "${with_version_date+set}" = set; then :
withval=$with_version_date;
fi
if test "x$with_version_date" = xyes; then
as_fn_error $? "--with-version-date must have a value" "$LINENO" 5
elif test "x$with_version_date" != x; then
if ! [[ $with_version_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] ; then
as_fn_error $? "\"$with_version_date\" is not a valid version date" "$LINENO" 5
else
VERSION_DATE="$with_version_date"
fi
else
VERSION_DATE="$DEFAULT_VERSION_DATE"
fi
# The vendor version string, if any
# Check whether --with-vendor-version-string was given.
if test "${with_vendor_version_string+set}" = set; then :
withval=$with_vendor_version_string;
fi
if test "x$with_vendor_version_string" = xyes; then
as_fn_error $? "--with-vendor-version-string must have a value" "$LINENO" 5
elif ! [[ $with_vendor_version_string =~ ^[[:graph:]]*$ ]] ; then
as_fn_error $? "--with--vendor-version-string contains non-graphical characters: $with_vendor_version_string" "$LINENO" 5
else
VENDOR_VERSION_STRING="$with_vendor_version_string"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for version string" >&5
$as_echo_n "checking for version string... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $VERSION_STRING" >&5
@ -25387,6 +25476,8 @@ $as_echo "$VERSION_STRING" >&6; }
###############################################################################
#
# Setup BootJDK, used to bootstrap the build.
@ -50653,7 +50744,7 @@ $as_echo "no" >&6; }
-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 \

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -62,6 +62,9 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS],
BASIC_DEPRECATED_ARG_WITH([update-version])
BASIC_DEPRECATED_ARG_WITH([user-release-suffix])
BASIC_DEPRECATED_ARG_WITH([build-number])
BASIC_DEPRECATED_ARG_WITH([version-major])
BASIC_DEPRECATED_ARG_WITH([version-minor])
BASIC_DEPRECATED_ARG_WITH([version-security])
# Source the version numbers file
. $AUTOCONF_DIR/version-numbers
@ -87,20 +90,20 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS],
elif test "x$with_version_string" != x; then
# Additional [] needed to keep m4 from mangling shell constructs.
if [ [[ $with_version_string =~ ^([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(-([a-zA-Z]+))?((\+)([0-9]+)?(-([-a-zA-Z0-9.]+))?)?$ ]] ]; then
VERSION_MAJOR=${BASH_REMATCH[[1]]}
VERSION_MINOR=${BASH_REMATCH[[3]]}
VERSION_SECURITY=${BASH_REMATCH[[5]]}
VERSION_FEATURE=${BASH_REMATCH[[1]]}
VERSION_INTERIM=${BASH_REMATCH[[3]]}
VERSION_UPDATE=${BASH_REMATCH[[5]]}
VERSION_PATCH=${BASH_REMATCH[[7]]}
VERSION_PRE=${BASH_REMATCH[[9]]}
version_plus_separator=${BASH_REMATCH[[11]]}
VERSION_BUILD=${BASH_REMATCH[[12]]}
VERSION_OPT=${BASH_REMATCH[[14]]}
# Unspecified numerical fields are interpreted as 0.
if test "x$VERSION_MINOR" = x; then
VERSION_MINOR=0
if test "x$VERSION_INTERIM" = x; then
VERSION_INTERIM=0
fi
if test "x$VERSION_SECURITY" = x; then
VERSION_SECURITY=0
if test "x$VERSION_UPDATE" = x; then
VERSION_UPDATE=0
fi
if test "x$VERSION_PATCH" = x; then
VERSION_PATCH=0
@ -191,64 +194,64 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS],
fi
fi
AC_ARG_WITH(version-major, [AS_HELP_STRING([--with-version-major],
[Set version 'MAJOR' field (first number) @<:@current source value@:>@])],
[with_version_major_present=true], [with_version_major_present=false])
AC_ARG_WITH(version-feature, [AS_HELP_STRING([--with-version-feature],
[Set version 'FEATURE' field (first number) @<:@current source value@:>@])],
[with_version_feature_present=true], [with_version_feature_present=false])
if test "x$with_version_major_present" = xtrue; then
if test "x$with_version_major" = xyes; then
AC_MSG_ERROR([--with-version-major must have a value])
if test "x$with_version_feature_present" = xtrue; then
if test "x$with_version_feature" = xyes; then
AC_MSG_ERROR([--with-version-feature must have a value])
else
JDKVER_CHECK_AND_SET_NUMBER(VERSION_MAJOR, $with_version_major)
JDKVER_CHECK_AND_SET_NUMBER(VERSION_FEATURE, $with_version_feature)
fi
else
if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
# Default is to get value from version-numbers
VERSION_MAJOR="$DEFAULT_VERSION_MAJOR"
VERSION_FEATURE="$DEFAULT_VERSION_FEATURE"
fi
fi
AC_ARG_WITH(version-minor, [AS_HELP_STRING([--with-version-minor],
[Set version 'MINOR' field (second number) @<:@current source value@:>@])],
[with_version_minor_present=true], [with_version_minor_present=false])
AC_ARG_WITH(version-interim, [AS_HELP_STRING([--with-version-interim],
[Set version 'INTERIM' field (second number) @<:@current source value@:>@])],
[with_version_interim_present=true], [with_version_interim_present=false])
if test "x$with_version_minor_present" = xtrue; then
if test "x$with_version_minor" = xyes; then
AC_MSG_ERROR([--with-version-minor must have a value])
elif test "x$with_version_minor" = xno; then
if test "x$with_version_interim_present" = xtrue; then
if test "x$with_version_interim" = xyes; then
AC_MSG_ERROR([--with-version-interim must have a value])
elif test "x$with_version_interim" = xno; then
# Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
VERSION_MINOR=0
elif test "x$with_version_minor" = x; then
VERSION_MINOR=0
VERSION_INTERIM=0
elif test "x$with_version_interim" = x; then
VERSION_INTERIM=0
else
JDKVER_CHECK_AND_SET_NUMBER(VERSION_MINOR, $with_version_minor)
JDKVER_CHECK_AND_SET_NUMBER(VERSION_INTERIM, $with_version_interim)
fi
else
if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
# Default is 0, if unspecified
VERSION_MINOR=$DEFAULT_VERSION_MINOR
VERSION_INTERIM=$DEFAULT_VERSION_INTERIM
fi
fi
AC_ARG_WITH(version-security, [AS_HELP_STRING([--with-version-security],
[Set version 'SECURITY' field (third number) @<:@current source value@:>@])],
[with_version_security_present=true], [with_version_security_present=false])
AC_ARG_WITH(version-update, [AS_HELP_STRING([--with-version-update],
[Set version 'UPDATE' field (third number) @<:@current source value@:>@])],
[with_version_update_present=true], [with_version_update_present=false])
if test "x$with_version_security_present" = xtrue; then
if test "x$with_version_security" = xyes; then
AC_MSG_ERROR([--with-version-security must have a value])
elif test "x$with_version_security" = xno; then
if test "x$with_version_update_present" = xtrue; then
if test "x$with_version_update" = xyes; then
AC_MSG_ERROR([--with-version-update must have a value])
elif test "x$with_version_update" = xno; then
# Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
VERSION_SECURITY=0
elif test "x$with_version_security" = x; then
VERSION_SECURITY=0
VERSION_UPDATE=0
elif test "x$with_version_update" = x; then
VERSION_UPDATE=0
else
JDKVER_CHECK_AND_SET_NUMBER(VERSION_SECURITY, $with_version_security)
JDKVER_CHECK_AND_SET_NUMBER(VERSION_UPDATE, $with_version_update)
fi
else
if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
# Default is 0, if unspecified
VERSION_SECURITY=$DEFAULT_VERSION_SECURITY
VERSION_UPDATE=$DEFAULT_VERSION_UPDATE
fi
fi
@ -284,7 +287,7 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS],
fi
# VERSION_NUMBER but always with exactly 4 positions, with 0 for empty positions.
VERSION_NUMBER_FOUR_POSITIONS=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_SECURITY.$VERSION_PATCH
VERSION_NUMBER_FOUR_POSITIONS=$VERSION_FEATURE.$VERSION_INTERIM.$VERSION_UPDATE.$VERSION_PATCH
stripped_version_number=$VERSION_NUMBER_FOUR_POSITIONS
# Strip trailing zeroes from stripped_version_number
@ -302,12 +305,38 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS],
# The short version string, just VERSION_NUMBER and PRE, if present.
VERSION_SHORT=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE}
# The version date
AC_ARG_WITH(version-date, [AS_HELP_STRING([--with-version-date],
[Set version date @<:@current source value@:>@])])
if test "x$with_version_date" = xyes; then
AC_MSG_ERROR([--with-version-date must have a value])
elif test "x$with_version_date" != x; then
if [ ! [[ $with_version_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] ]; then
AC_MSG_ERROR(["$with_version_date" is not a valid version date])
else
VERSION_DATE="$with_version_date"
fi
else
VERSION_DATE="$DEFAULT_VERSION_DATE"
fi
# The vendor version string, if any
AC_ARG_WITH(vendor-version-string, [AS_HELP_STRING([--with-vendor-version-string],
[Set vendor version string @<:@not specified@:>@])])
if test "x$with_vendor_version_string" = xyes; then
AC_MSG_ERROR([--with-vendor-version-string must have a value])
elif [ ! [[ $with_vendor_version_string =~ ^[[:graph:]]*$ ]] ]; then
AC_MSG_ERROR([--with--vendor-version-string contains non-graphical characters: $with_vendor_version_string])
else
VENDOR_VERSION_STRING="$with_vendor_version_string"
fi
AC_MSG_CHECKING([for version string])
AC_MSG_RESULT([$VERSION_STRING])
AC_SUBST(VERSION_MAJOR)
AC_SUBST(VERSION_MINOR)
AC_SUBST(VERSION_SECURITY)
AC_SUBST(VERSION_FEATURE)
AC_SUBST(VERSION_INTERIM)
AC_SUBST(VERSION_UPDATE)
AC_SUBST(VERSION_PATCH)
AC_SUBST(VERSION_PRE)
AC_SUBST(VERSION_BUILD)
@ -317,4 +346,6 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS],
AC_SUBST(VERSION_STRING)
AC_SUBST(VERSION_SHORT)
AC_SUBST(VERSION_IS_GA)
AC_SUBST(VERSION_DATE)
AC_SUBST(VENDOR_VERSION_STRING)
])

View File

@ -143,10 +143,9 @@ COPYRIGHT_YEAR:=@COPYRIGHT_YEAR@
## Building blocks of the version string
# First three version numbers, with well-specified meanings (numerical)
VERSION_MAJOR := @VERSION_MAJOR@
VERSION_MINOR := @VERSION_MINOR@
VERSION_SECURITY := @VERSION_SECURITY@
# Optional fourth element for use by OpenJDK consumers (numerical)
VERSION_FEATURE := @VERSION_FEATURE@
VERSION_INTERIM := @VERSION_INTERIM@
VERSION_UPDATE := @VERSION_UPDATE@
VERSION_PATCH := @VERSION_PATCH@
# The pre-release identifier (string)
VERSION_PRE := @VERSION_PRE@
@ -164,17 +163,23 @@ VERSION_NUMBER_FOUR_POSITIONS := @VERSION_NUMBER_FOUR_POSITIONS@
VERSION_STRING := @VERSION_STRING@
# The short version string, without trailing zeroes and just PRE, if present.
VERSION_SHORT := @VERSION_SHORT@
# The Java specification version. It usually equals the major version number.
VERSION_SPECIFICATION := @VERSION_MAJOR@
# The Java specification version. It usually equals the feature version number.
VERSION_SPECIFICATION := @VERSION_FEATURE@
# A GA version is defined by the PRE string being empty. Rather than testing for
# that, this variable defines it with true/false.
VERSION_IS_GA := @VERSION_IS_GA@
# Version date
VERSION_DATE := @VERSION_DATE@
# Vendor version string
VENDOR_VERSION_STRING := @VENDOR_VERSION_STRING@
# Convenience CFLAGS settings for passing version information into native programs.
VERSION_CFLAGS := \
-DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) \
-DVERSION_SECURITY=$(VERSION_SECURITY) \
-DVERSION_FEATURE=$(VERSION_FEATURE) \
-DVERSION_INTERIM=$(VERSION_INTERIM) \
-DVERSION_UPDATE=$(VERSION_UPDATE) \
-DVERSION_PATCH=$(VERSION_PATCH) \
-DVERSION_PRE='"$(VERSION_PRE)"' \
-DVERSION_BUILD=$(VERSION_BUILD) \
@ -183,6 +188,8 @@ VERSION_CFLAGS := \
-DVERSION_STRING='"$(VERSION_STRING)"' \
-DVERSION_SHORT='"$(VERSION_SHORT)"' \
-DVERSION_SPECIFICATION='"$(VERSION_SPECIFICATION)"' \
-DVERSION_DATE='"$(VERSION_DATE)"' \
-DVENDOR_VERSION_STRING='"$(VENDOR_VERSION_STRING)"' \
#
# Platform naming variables

View File

@ -25,10 +25,11 @@
# Default version numbers to use unless overridden by configure
DEFAULT_VERSION_MAJOR=10
DEFAULT_VERSION_MINOR=0
DEFAULT_VERSION_SECURITY=0
DEFAULT_VERSION_FEATURE=10
DEFAULT_VERSION_INTERIM=0
DEFAULT_VERSION_UPDATE=0
DEFAULT_VERSION_PATCH=0
DEFAULT_VERSION_DATE=2018-03-20
LAUNCHER_NAME=openjdk
PRODUCT_NAME=OpenJDK

View File

@ -1050,17 +1050,17 @@ var concatObjects = function (o1, o2) {
* Constructs the numeric version string from reading the
* make/autoconf/version-numbers file and removing all trailing ".0".
*
* @param major Override major version
* @param minor Override minor version
* @param security Override security version
* @param feature Override feature version
* @param interim Override interim version
* @param update Override update version
* @param patch Override patch version
* @returns {String} The numeric version string
*/
var getVersion = function (major, minor, security, patch) {
var getVersion = function (feature, interim, update, patch) {
var version_numbers = getVersionNumbers();
var version = (major != null ? major : version_numbers.get("DEFAULT_VERSION_MAJOR"))
+ "." + (minor != null ? minor : version_numbers.get("DEFAULT_VERSION_MINOR"))
+ "." + (security != null ? security : version_numbers.get("DEFAULT_VERSION_SECURITY"))
var version = (feature != null ? feature : version_numbers.get("DEFAULT_VERSION_FEATURE"))
+ "." + (interim != null ? interim : version_numbers.get("DEFAULT_VERSION_INTERIM"))
+ "." + (update != null ? update : version_numbers.get("DEFAULT_VERSION_UPDATE"))
+ "." + (patch != null ? patch : version_numbers.get("DEFAULT_VERSION_PATCH"));
while (version.match(".*\\.0$")) {
version = version.substring(0, version.length - 2);

View File

@ -219,9 +219,10 @@ endif
# different license.
JDK_LICENSE ?= $(wildcard $(TOPDIR)/LICENSE)
JDK_NOTICE ?= $(wildcard $(TOPDIR)/ASSEMBLY_EXCEPTION)
JDK_ADDITIONAL_LICENSE_INFO ?= $(wildcard $(TOPDIR)/ADDITIONAL_LICENSE_INFO)
$(eval $(call SetupCopyFiles, COPY_JDK_NOTICES, \
FILES := $(JDK_LICENSE) $(JDK_NOTICE), \
FILES := $(JDK_LICENSE) $(JDK_NOTICE) $(JDK_ADDITIONAL_LICENSE_INFO), \
DEST := $(LEGAL_DST_DIR), \
FLATTEN := true, \
))

View File

@ -38,7 +38,9 @@ $(eval $(call SetupTextFileProcessing, BUILD_VERSION_JAVA, \
@@VERSION_NUMBER@@ => $(VERSION_NUMBER) ; \
@@VERSION_PRE@@ => $(VERSION_PRE) ; \
@@VERSION_BUILD@@ => $(VERSION_BUILD) ; \
@@VERSION_OPT@@ => $(VERSION_OPT), \
@@VERSION_OPT@@ => $(VERSION_OPT) ; \
@@VERSION_DATE@@ => $(VERSION_DATE) ; \
@@VENDOR_VERSION_STRING@@ => $(VENDOR_VERSION_STRING), \
))
GENSRC_JAVA_BASE += $(BUILD_VERSION_JAVA)

View File

@ -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
@ -31,11 +31,6 @@ $(eval $(call SetupBuildLauncher, javac, \
CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \
))
$(eval $(call SetupBuildLauncher, javah, \
MAIN_CLASS := com.sun.tools.javah.Main, \
CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \
))
$(eval $(call SetupBuildLauncher, serialver, \
MAIN_CLASS := sun.tools.serialver.SerialVer, \
CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \

View File

@ -36,6 +36,7 @@
#include "gc/shared/cardTableModRefBS.hpp"
#include "nativeInst_ppc.hpp"
#include "oops/objArrayKlass.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#define __ _masm->
@ -1314,11 +1315,10 @@ void LIR_Assembler::return_op(LIR_Opr result) {
__ pop_frame();
}
if (LoadPollAddressFromThread) {
// TODO: PPC port __ ld(polling_page, in_bytes(JavaThread::poll_address_offset()), R16_thread);
Unimplemented();
if (SafepointMechanism::uses_thread_local_poll()) {
__ ld(polling_page, in_bytes(Thread::polling_page_offset()), R16_thread);
} else {
__ load_const_optimized(polling_page, (long)(address) os::get_polling_page(), R0); // TODO: PPC port: get_standard_polling_page()
__ load_const_optimized(polling_page, (long)(address) os::get_polling_page(), R0);
}
// Restore return pc relative to callers' sp.
@ -1341,26 +1341,18 @@ void LIR_Assembler::return_op(LIR_Opr result) {
int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
if (LoadPollAddressFromThread) {
const Register poll_addr = tmp->as_register();
// TODO: PPC port __ ld(poll_addr, in_bytes(JavaThread::poll_address_offset()), R16_thread);
Unimplemented();
__ relocate(relocInfo::poll_type); // XXX
guarantee(info != NULL, "Shouldn't be NULL");
int offset = __ offset();
add_debug_info_for_branch(info);
__ load_from_polling_page(poll_addr);
return offset;
const Register poll_addr = tmp->as_register();
if (SafepointMechanism::uses_thread_local_poll()) {
__ ld(poll_addr, in_bytes(Thread::polling_page_offset()), R16_thread);
} else {
__ load_const_optimized(poll_addr, (intptr_t)os::get_polling_page(), R0);
}
__ load_const_optimized(tmp->as_register(), (intptr_t)os::get_polling_page(), R0); // TODO: PPC port: get_standard_polling_page()
if (info != NULL) {
add_debug_info_for_branch(info);
}
int offset = __ offset();
__ relocate(relocInfo::poll_type);
__ load_from_polling_page(tmp->as_register());
__ load_from_polling_page(poll_addr);
return offset;
}

View File

@ -54,4 +54,6 @@ const bool CCallingConventionRequiresIntsAsLongs = true;
#define SUPPORT_RESERVED_STACK_AREA
#define THREAD_LOCAL_POLL
#endif // CPU_PPC_VM_GLOBALDEFINITIONS_PPC_HPP

View File

@ -83,7 +83,7 @@ define_pd_global(bool, CompactStrings, true);
// 2x unrolled loop is shorter with more than 9 HeapWords.
define_pd_global(intx, InitArrayShortSize, 9*BytesPerLong);
define_pd_global(bool, ThreadLocalHandshakes, false);
define_pd_global(bool, ThreadLocalHandshakes, true);
// Platform dependent flag handling: flags only defined on this platform.
#define ARCH_FLAGS(develop, \
@ -95,12 +95,6 @@ define_pd_global(bool, ThreadLocalHandshakes, false);
constraint, \
writeable) \
\
/* Load poll address from thread. This is used to implement per-thread */ \
/* safepoints on platforms != IA64. */ \
product(bool, LoadPollAddressFromThread, false, \
"Load polling page address from thread object (required for " \
"per-thread safepoints on platforms != IA64)") \
\
product(uintx, PowerArchitecturePPC64, 0, \
"CPU Version: x for PowerX. Currently recognizes Power5 to " \
"Power8. Default is 0. Newer CPUs will be recognized as Power8.") \

View File

@ -57,10 +57,10 @@ class InterpreterMacroAssembler: public MacroAssembler {
static const Address d_tmp;
// dispatch routines
void dispatch_next(TosState state, int step = 0);
void dispatch_next(TosState state, int step = 0, bool generate_poll = false);
void dispatch_via (TosState state, address* table);
void load_dispatch_table(Register dst, address* table);
void dispatch_Lbyte_code(TosState state, Register bytecode, address* table, bool verify = false);
void dispatch_Lbyte_code(TosState state, Register bytecode, address* table, bool generate_poll = false);
// Called by shared interpreter generator.
void dispatch_prolog(TosState state, int step = 0);

View File

@ -29,6 +29,7 @@
#include "interp_masm_ppc.hpp"
#include "interpreter/interpreterRuntime.hpp"
#include "prims/jvmtiThreadState.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/sharedRuntime.hpp"
#ifdef PRODUCT
@ -53,7 +54,7 @@ void InterpreterMacroAssembler::jump_to_entry(address entry, Register Rscratch)
}
}
void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr) {
void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr, bool generate_poll) {
Register bytecode = R12_scratch2;
if (bcp_incr != 0) {
lbzu(bytecode, bcp_incr, R14_bcp);
@ -61,7 +62,7 @@ void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr) {
lbz(bytecode, 0, R14_bcp);
}
dispatch_Lbyte_code(state, bytecode, Interpreter::dispatch_table(state));
dispatch_Lbyte_code(state, bytecode, Interpreter::dispatch_table(state), generate_poll);
}
void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
@ -203,16 +204,26 @@ void InterpreterMacroAssembler::load_dispatch_table(Register dst, address* table
}
void InterpreterMacroAssembler::dispatch_Lbyte_code(TosState state, Register bytecode,
address* table, bool verify) {
if (verify) {
unimplemented("dispatch_Lbyte_code: verify"); // See Sparc Implementation to implement this
}
address* table, bool generate_poll) {
assert_different_registers(bytecode, R11_scratch1);
// Calc dispatch table address.
load_dispatch_table(R11_scratch1, table);
if (SafepointMechanism::uses_thread_local_poll() && generate_poll) {
address *sfpt_tbl = Interpreter::safept_table(state);
if (table != sfpt_tbl) {
Label dispatch;
ld(R0, in_bytes(Thread::polling_page_offset()), R16_thread);
// Armed page has poll_bit set, if poll bit is cleared just continue.
andi_(R0, R0, SafepointMechanism::poll_bit());
beq(CCR0, dispatch);
load_dispatch_table(R11_scratch1, sfpt_tbl);
align(32, 16);
bind(dispatch);
}
}
sldi(R12_scratch2, bytecode, LogBytesPerWord);
ldx(R11_scratch1, R11_scratch1, R12_scratch2);

View File

@ -37,6 +37,8 @@
#include "runtime/interfaceSupport.hpp"
#include "runtime/objectMonitor.hpp"
#include "runtime/os.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubRoutines.hpp"
#include "utilities/macros.hpp"
@ -3019,6 +3021,18 @@ void MacroAssembler::serialize_memory(Register thread, Register tmp1, Register t
stwx(R0, tmp1, tmp2);
}
void MacroAssembler::safepoint_poll(Label& slow_path, Register temp_reg) {
if (SafepointMechanism::uses_thread_local_poll()) {
ld(temp_reg, in_bytes(Thread::polling_page_offset()), R16_thread);
// Armed page has poll_bit set.
andi_(temp_reg, temp_reg, SafepointMechanism::poll_bit());
} else {
lwz(temp_reg, (RegisterOrConstant)(intptr_t)SafepointSynchronize::address_of_state());
cmpwi(CCR0, temp_reg, SafepointSynchronize::_not_synchronized);
}
bne(CCR0, slow_path);
}
// GC barrier helper macros

View File

@ -647,6 +647,9 @@ class MacroAssembler: public Assembler {
// Support for serializing memory accesses between threads
void serialize_memory(Register thread, Register tmp1, Register tmp2);
// Check if safepoint requested and if so branch
void safepoint_poll(Label& slow_path, Register temp_reg);
// GC barrier support.
void card_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp);
void card_table_write(jbyte* byte_map_base, Register Rtmp, Register Robj);

View File

@ -1577,11 +1577,10 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
}
if (method_needs_polling) {
if (LoadPollAddressFromThread) {
// TODO: PPC port __ ld(polling_page, in_bytes(JavaThread::poll_address_offset()), R16_thread);
Unimplemented();
if (SafepointMechanism::uses_thread_local_poll()) {
__ ld(polling_page, in_bytes(JavaThread::polling_page_offset()), R16_thread);
} else {
__ load_const_optimized(polling_page, (long)(address) os::get_polling_page()); // TODO: PPC port: get_standard_polling_page()
__ load_const_optimized(polling_page, (long)(address) os::get_polling_page());
}
}
@ -14147,7 +14146,6 @@ instruct repl2L_immIminus1(vecX dst, immI_minus1 src) %{
instruct safePoint_poll(iRegPdst poll) %{
match(SafePoint poll);
predicate(LoadPollAddressFromThread);
// It caused problems to add the effect that r0 is killed, but this
// effect no longer needs to be mentioned, since r0 is not contained
@ -14159,24 +14157,6 @@ instruct safePoint_poll(iRegPdst poll) %{
ins_pipe(pipe_class_default);
%}
// Safepoint without per-thread support. Load address of page to poll
// as constant.
// Rscratch2RegP is R12.
// LoadConPollAddr node is added in pd_post_matching_hook(). It must be
// a seperate node so that the oop map is at the right location.
instruct safePoint_poll_conPollAddr(rscratch2RegP poll) %{
match(SafePoint poll);
predicate(!LoadPollAddressFromThread);
// It caused problems to add the effect that r0 is killed, but this
// effect no longer needs to be mentioned, since r0 is not contained
// in a reg_class.
format %{ "LD R0, #0, R12 \t// Safepoint poll for GC" %}
ins_encode( enc_poll(0x0, poll) );
ins_pipe(pipe_class_default);
%}
// ============================================================================
// Call Instructions

View File

@ -214,6 +214,7 @@ OopMap* RegisterSaver::push_frame_reg_args_and_save_live_registers(MacroAssemble
// StackFrameStream construction (needed for deoptimization; see
// compiledVFrame::create_stack_value).
// If return_pc_adjustment != 0 adjust the return pc by return_pc_adjustment.
// Updated return pc is returned in R31 (if not return_pc_is_pre_saved).
int i;
int offset;
@ -233,16 +234,17 @@ OopMap* RegisterSaver::push_frame_reg_args_and_save_live_registers(MacroAssemble
BLOCK_COMMENT("push_frame_reg_args_and_save_live_registers {");
// Save r31 in the last slot of the not yet pushed frame so that we
// can use it as scratch reg.
__ std(R31, -reg_size, R1_SP);
// Save some registers in the last slots of the not yet pushed frame so that we
// can use them as scratch regs.
__ std(R31, - reg_size, R1_SP);
__ std(R30, -2*reg_size, R1_SP);
assert(-reg_size == register_save_offset - frame_size_in_bytes + ((regstosave_num-1)*reg_size),
"consistency check");
// save the flags
// Do the save_LR_CR by hand and adjust the return pc if requested.
__ mfcr(R31);
__ std(R31, _abi(cr), R1_SP);
__ mfcr(R30);
__ std(R30, _abi(cr), R1_SP);
switch (return_pc_location) {
case return_pc_is_lr: __ mflr(R31); break;
case return_pc_is_pre_saved: assert(return_pc_adjustment == 0, "unsupported"); break;
@ -257,7 +259,7 @@ OopMap* RegisterSaver::push_frame_reg_args_and_save_live_registers(MacroAssemble
}
// push a new frame
__ push_frame(frame_size_in_bytes, R31);
__ push_frame(frame_size_in_bytes, R30);
// save all registers (ints and floats)
offset = register_save_offset;
@ -267,7 +269,7 @@ OopMap* RegisterSaver::push_frame_reg_args_and_save_live_registers(MacroAssemble
switch (reg_type) {
case RegisterSaver::int_reg: {
if (reg_num != 31) { // We spilled R31 right at the beginning.
if (reg_num < 30) { // We spilled R30-31 right at the beginning.
__ std(as_Register(reg_num), offset, R1_SP);
}
break;
@ -278,8 +280,8 @@ OopMap* RegisterSaver::push_frame_reg_args_and_save_live_registers(MacroAssemble
}
case RegisterSaver::special_reg: {
if (reg_num == SR_CTR_SpecialRegisterEnumValue) {
__ mfctr(R31);
__ std(R31, offset, R1_SP);
__ mfctr(R30);
__ std(R30, offset, R1_SP);
} else {
Unimplemented();
}
@ -2364,23 +2366,14 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
Register sync_state = r_temp_5;
Register suspend_flags = r_temp_6;
__ load_const(sync_state_addr, SafepointSynchronize::address_of_state(), /*temp*/ sync_state);
// TODO: PPC port assert(4 == SafepointSynchronize::sz_state(), "unexpected field size");
__ lwz(sync_state, 0, sync_state_addr);
// No synchronization in progress nor yet synchronized
// (cmp-br-isync on one path, release (same as acquire on PPC64) on the other path).
__ safepoint_poll(sync, sync_state);
// Not suspended.
// TODO: PPC port assert(4 == Thread::sz_suspend_flags(), "unexpected field size");
__ lwz(suspend_flags, thread_(suspend_flags));
__ acquire();
Label do_safepoint;
// No synchronization in progress nor yet synchronized.
__ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
// Not suspended.
__ cmpwi(CCR1, suspend_flags, 0);
__ bne(CCR0, sync);
__ beq(CCR1, no_block);
// Block. Save any potential method result value before the operation and
@ -2388,6 +2381,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
// lets us share the oopMap we used when we went native rather than create
// a distinct one for this pc.
__ bind(sync);
__ isync();
address entry_point = is_critical_native
? CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans_and_transition)
@ -2410,7 +2404,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
// Transition from _thread_in_native_trans to _thread_in_Java.
__ li(R0, _thread_in_Java);
__ release();
__ lwsync(); // Acquire safepoint and suspend state, release thread state.
// TODO: PPC port assert(4 == JavaThread::sz_thread_state(), "unexpected field size");
__ stw(R0, thread_(thread_state));
__ bind(after_transition);
@ -3093,7 +3087,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
return_pc_location = RegisterSaver::return_pc_is_thread_saved_exception_pc;
}
// Save registers, fpu state, and flags.
// Save registers, fpu state, and flags. Set R31 = return pc.
map = RegisterSaver::push_frame_reg_args_and_save_live_registers(masm,
&frame_size_in_bytes,
/*generate_oop_map=*/ true,
@ -3142,6 +3136,19 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
// No exception case.
__ BIND(noException);
if (SafepointMechanism::uses_thread_local_poll() && !cause_return) {
Label no_adjust;
// If our stashed return pc was modified by the runtime we avoid touching it
__ ld(R0, frame_size_in_bytes + _abi(lr), R1_SP);
__ cmpd(CCR0, R0, R31);
__ bne(CCR0, no_adjust);
// Adjust return pc forward to step over the safepoint poll instruction
__ addi(R31, R31, 4);
__ std(R31, frame_size_in_bytes + _abi(lr), R1_SP);
__ bind(no_adjust);
}
// Normal exit, restore registers and exit.
RegisterSaver::restore_live_registers_and_pop_frame(masm,

View File

@ -1535,23 +1535,17 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
// Acquire isn't strictly necessary here because of the fence, but
// sync_state is declared to be volatile, so we do it anyway
// (cmp-br-isync on one path, release (same as acquire on PPC64) on the other path).
int sync_state_offs = __ load_const_optimized(sync_state_addr, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
// TODO PPC port assert(4 == SafepointSynchronize::sz_state(), "unexpected field size");
__ lwz(sync_state, sync_state_offs, sync_state_addr);
Label do_safepoint, sync_check_done;
// No synchronization in progress nor yet synchronized.
__ safepoint_poll(do_safepoint, sync_state);
// Not suspended.
// TODO PPC port assert(4 == Thread::sz_suspend_flags(), "unexpected field size");
__ lwz(suspend_flags, thread_(suspend_flags));
Label sync_check_done;
Label do_safepoint;
// No synchronization in progress nor yet synchronized.
__ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
// Not suspended.
__ cmpwi(CCR1, suspend_flags, 0);
__ bne(CCR0, do_safepoint);
__ beq(CCR1, sync_check_done);
__ bind(do_safepoint);
__ isync();
// Block. We do the call directly and leave the current
@ -1592,7 +1586,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
// we don't want the current thread to continue until all our prior memory
// accesses (including the new thread state) are visible to other threads.
__ li(R0/*thread_state*/, _thread_in_Java);
__ release();
__ lwsync(); // Acquire safepoint and suspend state, release thread state.
__ stw(R0/*thread_state*/, thread_(thread_state));
if (CheckJNICalls) {
@ -1858,10 +1852,7 @@ address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
// Safepoint check
const Register sync_state = R11_scratch1;
int sync_state_offs = __ load_const_optimized(sync_state, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
__ lwz(sync_state, sync_state_offs, sync_state);
__ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
__ bne(CCR0, slow_path);
__ safepoint_poll(slow_path, sync_state);
// We don't generate local frame and don't align stack because
// we not even call stub code (we generate the code inline)
@ -1918,10 +1909,7 @@ address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractI
// Safepoint check
const Register sync_state = R11_scratch1;
int sync_state_offs = __ load_const_optimized(sync_state, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
__ lwz(sync_state, sync_state_offs, sync_state);
__ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
__ bne(CCR0, slow_path);
__ safepoint_poll(slow_path, sync_state);
// We don't generate local frame and don't align stack because
// we not even call stub code (we generate the code inline)

View File

@ -1630,7 +1630,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
// Push returnAddress for "ret" on stack.
__ push_ptr(R17_tos);
// And away we go!
__ dispatch_next(vtos);
__ dispatch_next(vtos, 0 ,true);
return;
}
@ -1643,7 +1643,6 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
const bool increment_invocation_counter_for_backward_branches = UseCompiler && UseLoopCounter;
if (increment_invocation_counter_for_backward_branches) {
Label Lforward;
__ dispatch_prolog(vtos);
// Check branch direction.
__ cmpdi(CCR0, Rdisp, 0);
@ -1744,11 +1743,8 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
}
__ bind(Lforward);
__ dispatch_epilog(vtos);
} else {
__ dispatch_next(vtos);
}
__ dispatch_next(vtos, 0, true);
}
// Helper function for if_cmp* methods below.
@ -1829,7 +1825,7 @@ void TemplateTable::ret() {
__ ld(R11_scratch1, in_bytes(Method::const_offset()), R19_method);
__ add(R11_scratch1, R17_tos, R11_scratch1);
__ addi(R14_bcp, R11_scratch1, in_bytes(ConstMethod::codes_offset()));
__ dispatch_next(vtos);
__ dispatch_next(vtos, 0, true);
}
void TemplateTable::wide_ret() {
@ -1846,7 +1842,7 @@ void TemplateTable::wide_ret() {
__ ld(Rscratch1, in_bytes(Method::const_offset()), R19_method);
__ addi(Rscratch2, R17_tos, in_bytes(ConstMethod::codes_offset()));
__ add(R14_bcp, Rscratch1, Rscratch2);
__ dispatch_next(vtos);
__ dispatch_next(vtos, 0, true);
}
void TemplateTable::tableswitch() {
@ -1896,7 +1892,7 @@ void TemplateTable::tableswitch() {
__ bind(Ldispatch);
__ add(R14_bcp, Roffset, R14_bcp);
__ dispatch_next(vtos);
__ dispatch_next(vtos, 0, true);
}
void TemplateTable::lookupswitch() {
@ -1960,7 +1956,7 @@ void TemplateTable::fast_linearswitch() {
__ bind(Lcontinue_execution);
__ add(R14_bcp, Roffset, R14_bcp);
__ dispatch_next(vtos);
__ dispatch_next(vtos, 0, true);
}
// Table switch using binary search (value/offset pairs are ordered).
@ -2093,7 +2089,7 @@ void TemplateTable::fast_binaryswitch() {
__ extsw(Rj, Rj);
__ add(R14_bcp, Rj, R14_bcp);
__ dispatch_next(vtos);
__ dispatch_next(vtos, 0 , true);
}
void TemplateTable::_return(TosState state) {
@ -2124,6 +2120,17 @@ void TemplateTable::_return(TosState state) {
__ bind(Lskip_register_finalizer);
}
if (SafepointMechanism::uses_thread_local_poll() && _desc->bytecode() != Bytecodes::_return_register_finalizer) {
Label no_safepoint;
__ ld(R11_scratch1, in_bytes(Thread::polling_page_offset()), R16_thread);
__ andi_(R11_scratch1, R11_scratch1, SafepointMechanism::poll_bit());
__ beq(CCR0, no_safepoint);
__ push(state);
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint));
__ pop(state);
__ bind(no_safepoint);
}
// Move the result value into the correct register and remove memory stack frame.
__ remove_activation(state, /* throw_monitor_exception */ true);
// Restoration of lr done by remove_activation.

View File

@ -1459,6 +1459,10 @@ class Assembler : public AbstractAssembler {
bcondLogNotZero = bcondLogNotZero_Carry | bcondLogNotZero_NoCarry,
bcondLogCarry = bcondLogZero_Carry | bcondLogNotZero_Carry,
bcondLogBorrow = /* bcondLogZero_Borrow | */ bcondLogNotZero_Borrow,
// Vector compare instructions
bcondVAlltrue = 8, // All vector elements evaluate true
bcondVMixed = 4, // Some vector elements evaluate true, some false
bcondVAllfalse = 1, // All vector elements evaluate false
// string search instructions
bcondFound = 4,
bcondNotFound = 2,
@ -3022,6 +3026,12 @@ class Assembler : public AbstractAssembler {
inline void z_btrue( Label& L);
inline void z_bfalse(Label& L);
inline void z_bvat(Label& L); // all true
inline void z_bvnt(Label& L); // not all true (mixed or all false)
inline void z_bvmix(Label& L); // mixed true and false
inline void z_bvaf(Label& L); // not all false (mixed or all true)
inline void z_bvnf(Label& L); // all false
inline void z_brno( Label& L);

View File

@ -1315,23 +1315,28 @@ inline void Assembler::z_br(Register r2) { assert(r2 != Z_R0, "nop if target is
inline void Assembler::z_exrl(Register r1, Label& L) { z_exrl(r1, target(L)); } // z10
inline void Assembler::z_larl(Register r1, Label& L) { z_larl(r1, target(L)); }
inline void Assembler::z_bru( Label& L) { z_brc(bcondAlways,target(L)); }
inline void Assembler::z_brul( Label& L) { z_brcl(bcondAlways,target(L)); }
inline void Assembler::z_brul( address a) { z_brcl(bcondAlways,a); }
inline void Assembler::z_brh( Label& L) { z_brc(bcondHigh,target(L)); }
inline void Assembler::z_brl( Label& L) { z_brc(bcondLow,target(L)); }
inline void Assembler::z_bre( Label& L) { z_brc(bcondEqual,target(L)); }
inline void Assembler::z_brnh( Label& L) { z_brc(bcondNotHigh,target(L)); }
inline void Assembler::z_brnl( Label& L) { z_brc(bcondNotLow,target(L)); }
inline void Assembler::z_brne( Label& L) { z_brc(bcondNotEqual,target(L)); }
inline void Assembler::z_brz( Label& L) { z_brc(bcondZero,target(L)); }
inline void Assembler::z_brnz( Label& L) { z_brc(bcondNotZero,target(L)); }
inline void Assembler::z_braz( Label& L) { z_brc(bcondAllZero,target(L)); }
inline void Assembler::z_brnaz( Label& L) { z_brc(bcondNotAllZero,target(L)); }
inline void Assembler::z_bru( Label& L) { z_brc(bcondAlways, target(L)); }
inline void Assembler::z_brul( Label& L) { z_brcl(bcondAlways, target(L)); }
inline void Assembler::z_brul( address a) { z_brcl(bcondAlways,a ); }
inline void Assembler::z_brh( Label& L) { z_brc(bcondHigh, target(L)); }
inline void Assembler::z_brl( Label& L) { z_brc(bcondLow, target(L)); }
inline void Assembler::z_bre( Label& L) { z_brc(bcondEqual, target(L)); }
inline void Assembler::z_brnh( Label& L) { z_brc(bcondNotHigh, target(L)); }
inline void Assembler::z_brnl( Label& L) { z_brc(bcondNotLow, target(L)); }
inline void Assembler::z_brne( Label& L) { z_brc(bcondNotEqual, target(L)); }
inline void Assembler::z_brz( Label& L) { z_brc(bcondZero, target(L)); }
inline void Assembler::z_brnz( Label& L) { z_brc(bcondNotZero, target(L)); }
inline void Assembler::z_braz( Label& L) { z_brc(bcondAllZero, target(L)); }
inline void Assembler::z_brnaz( Label& L) { z_brc(bcondNotAllZero, target(L)); }
inline void Assembler::z_brnp( Label& L) { z_brc( bcondNotPositive, target( L)); }
inline void Assembler::z_btrue( Label& L) { z_brc(bcondAllOne,target(L)); }
inline void Assembler::z_bfalse(Label& L) { z_brc(bcondAllZero,target(L)); }
inline void Assembler::z_brno( Label& L) { z_brc(bcondNotOrdered,target(L)); }
inline void Assembler::z_btrue( Label& L) { z_brc(bcondAllOne, target(L)); }
inline void Assembler::z_bfalse(Label& L) { z_brc(bcondAllZero, target(L)); }
inline void Assembler::z_bvat( Label& L) { z_brc(bcondVAlltrue, target(L)); }
inline void Assembler::z_bvnt( Label& L) { z_brc((Assembler::branch_condition)(bcondVMixed | bcondVAllfalse), target(L)); }
inline void Assembler::z_bvmix( Label& L) { z_brc(bcondVMixed, target(L)); }
inline void Assembler::z_bvaf( Label& L) { z_brc(bcondVAllfalse, target(L)); }
inline void Assembler::z_bvnf( Label& L) { z_brc((Assembler::branch_condition)(bcondVMixed | bcondVAlltrue), target(L)); }
inline void Assembler::z_brno( Label& L) { z_brc(bcondNotOrdered, target(L)); }
inline void Assembler::z_brc( branch_condition m, Label& L) { z_brc(m, target(L)); }
inline void Assembler::z_brcl(branch_condition m, Label& L) { z_brcl(m, target(L)); }

View File

@ -36,6 +36,7 @@
#include "gc/shared/cardTableModRefBS.hpp"
#include "nativeInst_s390.hpp"
#include "oops/objArrayKlass.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#include "vmreg_s390.inline.hpp"
@ -1135,8 +1136,12 @@ void LIR_Assembler::return_op(LIR_Opr result) {
(result->is_single_fpu() && result->as_float_reg() == Z_F0) ||
(result->is_double_fpu() && result->as_double_reg() == Z_F0), "convention");
AddressLiteral pp(os::get_polling_page());
__ load_const_optimized(Z_R1_scratch, pp);
if (SafepointMechanism::uses_thread_local_poll()) {
__ z_lg(Z_R1_scratch, Address(Z_thread, Thread::polling_page_offset()));
} else {
AddressLiteral pp(os::get_polling_page());
__ load_const_optimized(Z_R1_scratch, pp);
}
// Pop the frame before the safepoint code.
__ pop_frame_restore_retPC(initial_frame_size_in_bytes());
@ -1154,13 +1159,18 @@ void LIR_Assembler::return_op(LIR_Opr result) {
}
int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
AddressLiteral pp(os::get_polling_page());
__ load_const_optimized(tmp->as_register_lo(), pp);
const Register poll_addr = tmp->as_register_lo();
if (SafepointMechanism::uses_thread_local_poll()) {
__ z_lg(poll_addr, Address(Z_thread, Thread::polling_page_offset()));
} else {
AddressLiteral pp(os::get_polling_page());
__ load_const_optimized(poll_addr, pp);
}
guarantee(info != NULL, "Shouldn't be NULL");
add_debug_info_for_branch(info);
int offset = __ offset();
__ relocate(relocInfo::poll_type);
__ load_from_polling_page(tmp->as_register_lo());
__ load_from_polling_page(poll_addr);
return offset;
}

View File

@ -54,4 +54,6 @@ const bool CCallingConventionRequiresIntsAsLongs = true;
#define SUPPORT_RESERVED_STACK_AREA
#define THREAD_LOCAL_POLL
#endif // CPU_S390_VM_GLOBALDEFINITIONS_S390_HPP

View File

@ -85,7 +85,7 @@ define_pd_global(bool, CompactStrings, true);
// 8146801 (Short Array Allocation): No performance work done here yet.
define_pd_global(intx, InitArrayShortSize, 1*BytesPerLong);
define_pd_global(bool, ThreadLocalHandshakes, false);
define_pd_global(bool, ThreadLocalHandshakes, true);
#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint, writeable) \
\

View File

@ -36,6 +36,7 @@
#include "prims/jvmtiThreadState.hpp"
#include "runtime/basicLock.hpp"
#include "runtime/biasedLocking.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/thread.inline.hpp"
@ -74,16 +75,16 @@ void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) {
dispatch_next(state, step);
}
void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr) {
void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr, bool generate_poll) {
z_llgc(Z_bytecode, bcp_incr, Z_R0, Z_bcp); // Load next bytecode.
add2reg(Z_bcp, bcp_incr); // Advance bcp. Add2reg produces optimal code.
dispatch_base(state, Interpreter::dispatch_table(state));
dispatch_base(state, Interpreter::dispatch_table(state), generate_poll);
}
// Common code to dispatch and dispatch_only.
// Dispatch value in Lbyte_code and increment Lbcp.
void InterpreterMacroAssembler::dispatch_base(TosState state, address* table) {
void InterpreterMacroAssembler::dispatch_base(TosState state, address* table, bool generate_poll) {
verify_FPU(1, state);
#ifdef ASSERT
@ -109,7 +110,20 @@ void InterpreterMacroAssembler::dispatch_base(TosState state, address* table) {
verify_oop(Z_tos, state);
// Dispatch table to use.
load_absolute_address(Z_tmp_1, (address) table); // Z_tmp_1 = table;
load_absolute_address(Z_tmp_1, (address)table); // Z_tmp_1 = table;
if (SafepointMechanism::uses_thread_local_poll() && generate_poll) {
address *sfpt_tbl = Interpreter::safept_table(state);
if (table != sfpt_tbl) {
Label dispatch;
const Address poll_byte_addr(Z_thread, in_bytes(Thread::polling_page_offset()) + 7 /* Big Endian */);
// Armed page has poll_bit set, if poll bit is cleared just continue.
z_tm(poll_byte_addr, SafepointMechanism::poll_bit());
z_braz(dispatch);
load_absolute_address(Z_tmp_1, (address)sfpt_tbl); // Z_tmp_1 = table;
bind(dispatch);
}
}
// 0 <= Z_bytecode < 256 => Use a 32 bit shift, because it is shorter than sllg.
// Z_bytecode must have been loaded zero-extended for this approach to be correct.
@ -119,8 +133,8 @@ void InterpreterMacroAssembler::dispatch_base(TosState state, address* table) {
z_br(Z_tmp_1);
}
void InterpreterMacroAssembler::dispatch_only(TosState state) {
dispatch_base(state, Interpreter::dispatch_table(state));
void InterpreterMacroAssembler::dispatch_only(TosState state, bool generate_poll) {
dispatch_base(state, Interpreter::dispatch_table(state), generate_poll);
}
void InterpreterMacroAssembler::dispatch_only_normal(TosState state) {

View File

@ -49,7 +49,7 @@ class InterpreterMacroAssembler: public MacroAssembler {
bool check_exceptions);
// Base routine for all dispatches.
void dispatch_base(TosState state, address* table);
void dispatch_base(TosState state, address* table, bool generate_poll = false);
public:
InterpreterMacroAssembler(CodeBuffer* c)
@ -78,11 +78,11 @@ class InterpreterMacroAssembler: public MacroAssembler {
// dispatch routines
void dispatch_prolog(TosState state, int step = 0);
void dispatch_epilog(TosState state, int step = 0);
void dispatch_only(TosState state);
void dispatch_only(TosState state, bool generate_poll = false);
// Dispatch normal table via Z_bytecode (assume Z_bytecode is loaded already).
void dispatch_only_normal(TosState state);
void dispatch_normal(TosState state);
void dispatch_next(TosState state, int step = 0);
void dispatch_next(TosState state, int step = 0, bool generate_poll = false);
void dispatch_next_noverify_oop(TosState state, int step = 0);
void dispatch_via(TosState state, address* table);

View File

@ -43,6 +43,8 @@
#include "runtime/interfaceSupport.hpp"
#include "runtime/objectMonitor.hpp"
#include "runtime/os.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubRoutines.hpp"
#include "utilities/events.hpp"
@ -2019,6 +2021,15 @@ address MacroAssembler::get_PC(Register result, int64_t offset) {
return here + offset;
}
void MacroAssembler::instr_size(Register size, Register pc) {
// Extract 2 most significant bits of current instruction.
z_llgc(size, Address(pc));
z_srl(size, 6);
// Compute (x+3)&6 which translates 0->2, 1->4, 2->4, 3->6.
z_ahi(size, 3);
z_nill(size, 6);
}
// Resize_frame with SP(new) = SP(old) - [offset].
void MacroAssembler::resize_frame_sub(Register offset, Register fp, bool load_fp)
{
@ -2705,6 +2716,19 @@ void MacroAssembler::serialize_memory(Register thread, Register tmp1, Register t
z_st(Z_R0, 0, tmp2, tmp1);
}
void MacroAssembler::safepoint_poll(Label& slow_path, Register temp_reg) {
if (SafepointMechanism::uses_thread_local_poll()) {
const Address poll_byte_addr(Z_thread, in_bytes(Thread::polling_page_offset()) + 7 /* Big Endian */);
// Armed page has poll_bit set.
z_tm(poll_byte_addr, SafepointMechanism::poll_bit());
z_brnaz(slow_path);
} else {
load_const_optimized(temp_reg, SafepointSynchronize::address_of_state());
z_cli(/*SafepointSynchronize::sz_state()*/4-1, temp_reg, SafepointSynchronize::_not_synchronized);
z_brne(slow_path);
}
}
// Don't rely on register locking, always use Z_R1 as scratch register instead.
void MacroAssembler::bang_stack_with_offset(int offset) {
// Stack grows down, caller passes positive offset.
@ -4914,13 +4938,14 @@ unsigned int MacroAssembler::CopyRawMemory_AlignedDisjoint(Register src_reg, Reg
// The result is the number of characters copied before the first incompatible character was found.
// If precise is true, the processing stops exactly at this point. Otherwise, the result may be off
// by a few bytes. The result always indicates the number of copied characters.
// When used as a character index, the returned value points to the first incompatible character.
//
// Note: Does not behave exactly like package private StringUTF16 compress java implementation in case of failure:
// - Different number of characters may have been written to dead array (if precise is false).
// - Returns a number <cnt instead of 0. (Result gets compared with cnt.)
unsigned int MacroAssembler::string_compress(Register result, Register src, Register dst, Register cnt,
Register tmp, bool precise) {
assert_different_registers(Z_R0, Z_R1, src, dst, cnt, tmp);
assert_different_registers(Z_R0, Z_R1, result, src, dst, cnt, tmp);
if (precise) {
BLOCK_COMMENT("encode_iso_array {");
@ -5027,7 +5052,7 @@ unsigned int MacroAssembler::string_compress(Register result, Register src, Regi
z_vo(Vtmp1, Vtmp1, Vtmp2);
z_vn(Vtmp1, Vtmp1, Vmask);
z_vceqhs(Vtmp1, Vtmp1, Vzero); // high half of all chars must be zero for successful compress.
z_brne(VectorBreak); // break vector loop, incompatible character found.
z_bvnt(VectorBreak); // break vector loop if not all vector elements compare eq -> incompatible character found.
// re-process data from current iteration in break handler.
//---< pack & store characters >---
@ -5094,24 +5119,28 @@ unsigned int MacroAssembler::string_compress(Register result, Register src, Regi
z_tmll(Rcnt, min_cnt-1);
z_brnaz(ScalarShortcut); // if all bits zero, there is nothing left to do for scalar loop.
// Rix == 0 in all cases.
z_sllg(Z_R1, Rcnt, 1); // # src bytes already processed. Only lower 32 bits are valid!
// Z_R1 contents must be treated as unsigned operand! For huge strings,
// (Rcnt >= 2**30), the value may spill into the sign bit by sllg.
z_lgfr(result, Rcnt); // all characters processed.
z_sgfr(Rdst, Rcnt); // restore ptr
z_sgfr(Rsrc, Rcnt); // restore ptr, double the element count for Rsrc restore
z_sgfr(Rsrc, Rcnt);
z_slgfr(Rdst, Rcnt); // restore ptr
z_slgfr(Rsrc, Z_R1); // restore ptr, double the element count for Rsrc restore
z_bru(AllDone);
bind(UnrolledBreak);
z_lgfr(Z_R0, Rcnt); // # chars processed in total after unrolled loop
z_nilf(Z_R0, ~(min_cnt-1));
z_sll(Rix, log_min_cnt); // # chars processed so far in UnrolledLoop, excl. current iteration.
z_sr(Z_R0, Rix); // correct # chars processed in total.
z_sll(Rix, log_min_cnt); // # chars not yet processed in UnrolledLoop (due to break), broken iteration not included.
z_sr(Z_R0, Rix); // fix # chars processed OK so far.
if (!precise) {
z_lgfr(result, Z_R0);
z_sllg(Z_R1, Z_R0, 1); // # src bytes already processed. Only lower 32 bits are valid!
// Z_R1 contents must be treated as unsigned operand! For huge strings,
// (Rcnt >= 2**30), the value may spill into the sign bit by sllg.
z_aghi(result, min_cnt/2); // min_cnt/2 characters have already been written
// but ptrs were not updated yet.
z_sgfr(Rdst, Z_R0); // restore ptr
z_sgfr(Rsrc, Z_R0); // restore ptr, double the element count for Rsrc restore
z_sgfr(Rsrc, Z_R0);
z_slgfr(Rdst, Z_R0); // restore ptr
z_slgfr(Rsrc, Z_R1); // restore ptr, double the element count for Rsrc restore
z_bru(AllDone);
}
bind(UnrolledDone);
@ -5165,7 +5194,7 @@ unsigned int MacroAssembler::string_compress(Register result, Register src, Regi
z_sr(Rix, Z_R0);
}
z_lgfr(result, Rcnt); // # processed characters (if all runs ok).
z_brz(ScalarDone);
z_brz(ScalarDone); // uses CC from Rix calculation
bind(ScalarLoop);
z_llh(Z_R1, 0, Z_R0, Rsrc);
@ -6452,27 +6481,6 @@ void MacroAssembler::translate_tt(Register r1, Register r2, uint m3) {
Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
}
void MacroAssembler::generate_safepoint_check(Label& slow_path, Register scratch, bool may_relocate) {
if (scratch == noreg) scratch = Z_R1;
address Astate = SafepointSynchronize::address_of_state();
BLOCK_COMMENT("safepoint check:");
if (may_relocate) {
ptrdiff_t total_distance = Astate - this->pc();
if (RelAddr::is_in_range_of_RelAddr32(total_distance)) {
RelocationHolder rspec = external_word_Relocation::spec(Astate);
(this)->relocate(rspec, relocInfo::pcrel_addr_format);
load_absolute_address(scratch, Astate);
} else {
load_const_optimized(scratch, Astate);
}
} else {
load_absolute_address(scratch, Astate);
}
z_cli(/*SafepointSynchronize::sz_state()*/4-1, scratch, SafepointSynchronize::_not_synchronized);
z_brne(slow_path);
}
void MacroAssembler::generate_type_profiling(const Register Rdata,
const Register Rreceiver_klass,

View File

@ -260,8 +260,6 @@ class MacroAssembler: public Assembler {
//
// Constants, loading constants, TOC support
//
// Safepoint check factored out.
void generate_safepoint_check(Label& slow_path, Register scratch = noreg, bool may_relocate = true);
// Load generic address: d <- base(a) + index(a) + disp(a).
inline void load_address(Register d, const Address &a);
@ -443,6 +441,9 @@ class MacroAssembler: public Assembler {
// Get current PC + offset. Offset given in bytes, must be even!
address get_PC(Register result, int64_t offset);
// Get size of instruction at pc (which must point to valid code).
void instr_size(Register size, Register pc);
// Accessing, and in particular modifying, a stack location is only safe if
// the stack pointer (Z_SP) is set such that the accessed stack location is
// in the reserved range.
@ -641,6 +642,9 @@ class MacroAssembler: public Assembler {
// Support for serializing memory accesses between threads.
void serialize_memory(Register thread, Register tmp1, Register tmp2);
// Check if safepoint requested and if so branch
void safepoint_poll(Label& slow_path, Register temp_reg);
// Stack overflow checking
void bang_stack_with_offset(int offset);

View File

@ -919,8 +919,12 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
// Touch the polling page.
if (need_polling) {
AddressLiteral pp(os::get_polling_page());
__ load_const_optimized(Z_R1_scratch, pp);
if (SafepointMechanism::uses_thread_local_poll()) {
__ z_lg(Z_R1_scratch, Address(Z_thread, Thread::polling_page_offset()));
} else {
AddressLiteral pp(os::get_polling_page());
__ load_const_optimized(Z_R1_scratch, pp);
}
// We need to mark the code position where the load from the safepoint
// polling page was emitted as relocInfo::poll_return_type here.
__ relocate(relocInfo::poll_return_type);

View File

@ -2165,7 +2165,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
__ serialize_memory(Z_thread, Z_R1, Z_R2);
}
}
__ generate_safepoint_check(sync, Z_R1, true);
__ safepoint_poll(sync, Z_R1);
__ load_and_test_int(Z_R0, Address(Z_thread, JavaThread::suspend_flags_offset()));
__ z_bre(no_block);
@ -3190,12 +3190,18 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
bool cause_return = (poll_type == POLL_AT_RETURN);
// Make room for return address (or push it again)
if (!cause_return)
if (!cause_return) {
__ z_lg(Z_R14, Address(Z_thread, JavaThread::saved_exception_pc_offset()));
}
// Save registers, fpu state, and flags
map = RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers);
if (SafepointMechanism::uses_thread_local_poll() && !cause_return) {
// Keep a copy of the return pc to detect if it gets modified.
__ z_lgr(Z_R6, Z_R14);
}
// The following is basically a call_VM. However, we need the precise
// address of the call in order to generate an oopmap. Hence, we do all the
// work outselves.
@ -3231,6 +3237,21 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
// No exception case
__ bind(noException);
if (SafepointMechanism::uses_thread_local_poll() && !cause_return) {
Label no_adjust;
// If our stashed return pc was modified by the runtime we avoid touching it
const int offset_of_return_pc = _z_abi16(return_pc) + RegisterSaver::live_reg_frame_size(RegisterSaver::all_registers);
__ z_cg(Z_R6, offset_of_return_pc, Z_SP);
__ z_brne(no_adjust);
// Adjust return pc forward to step over the safepoint poll instruction
__ instr_size(Z_R1_scratch, Z_R6);
__ z_agr(Z_R6, Z_R1_scratch);
__ z_stg(Z_R6, offset_of_return_pc, Z_SP);
__ bind(no_adjust);
}
// Normal exit, restore registers and exit.
RegisterSaver::restore_live_registers(masm, RegisterSaver::all_registers);

View File

@ -1633,7 +1633,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
// Check for safepoint operation in progress and/or pending suspend requests.
{
Label Continue, do_safepoint;
__ generate_safepoint_check(do_safepoint, Z_R1, true);
__ safepoint_poll(do_safepoint, Z_R1);
// Check for suspend.
__ load_and_test_int(Z_R0/*suspend_flags*/, thread_(suspend_flags));
__ z_bre(Continue); // 0 -> no flag set -> not suspended
@ -1937,7 +1937,7 @@ address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
Label slow_path;
// If we need a safepoint check, generate full interpreter entry.
__ generate_safepoint_check(slow_path, Z_R1, false);
__ safepoint_poll(slow_path, Z_R1);
BLOCK_COMMENT("CRC32_update {");
@ -1990,7 +1990,7 @@ address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractI
Label slow_path;
// If we need a safepoint check, generate full interpreter entry.
__ generate_safepoint_check(slow_path, Z_R1, false);
__ safepoint_poll(slow_path, Z_R1);
// We don't generate local frame and don't align stack because
// we call stub code and there is no safepoint on this path.

View File

@ -1853,7 +1853,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
// Push return address for "ret" on stack.
__ push_ptr(Z_tos);
// And away we go!
__ dispatch_next(vtos);
__ dispatch_next(vtos, 0 , true);
return;
}
@ -1961,7 +1961,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
// Z_tos: Return bci for jsr's, unused otherwise.
// Z_bytecode: target bytecode
// Z_bcp: target bcp
__ dispatch_only(vtos);
__ dispatch_only(vtos, true);
// Out-of-line code runtime calls.
if (UseLoopCounter) {
@ -2072,7 +2072,7 @@ void TemplateTable::ret() {
__ get_method(Z_tos);
__ mem2reg_opt(Z_R1_scratch, Address(Z_tos, Method::const_offset()));
__ load_address(Z_bcp, Address(Z_R1_scratch, Z_tmp_1, ConstMethod::codes_offset()));
__ dispatch_next(vtos);
__ dispatch_next(vtos, 0 , true);
}
void TemplateTable::wide_ret() {
@ -2085,7 +2085,7 @@ void TemplateTable::wide_ret() {
__ get_method(Z_tos);
__ mem2reg_opt(Z_R1_scratch, Address(Z_tos, Method::const_offset()));
__ load_address(Z_bcp, Address(Z_R1_scratch, Z_tmp_1, ConstMethod::codes_offset()));
__ dispatch_next(vtos);
__ dispatch_next(vtos, 0, true);
}
void TemplateTable::tableswitch () {
@ -2129,7 +2129,7 @@ void TemplateTable::tableswitch () {
// Load next bytecode.
__ z_llgc(Z_bytecode, Address(Z_bcp, index));
__ z_agr(Z_bcp, index); // Advance bcp.
__ dispatch_only(vtos);
__ dispatch_only(vtos, true);
// Handle default.
__ bind(default_case);
@ -2193,7 +2193,7 @@ void TemplateTable::fast_linearswitch () {
// Load next bytecode.
__ z_llgc(Z_bytecode, Address(Z_bcp, offset, 0));
__ z_agr(Z_bcp, offset); // Advance bcp.
__ dispatch_only(vtos);
__ dispatch_only(vtos, true);
}
@ -2302,7 +2302,7 @@ void TemplateTable::fast_binaryswitch() {
// Load next bytecode.
__ z_llgc(Z_bytecode, Address(Z_bcp, j));
__ z_agr(Z_bcp, j); // Advance bcp.
__ dispatch_only(vtos);
__ dispatch_only(vtos, true);
// default case -> j = default offset
__ bind(default_case);
@ -2312,7 +2312,7 @@ void TemplateTable::fast_binaryswitch() {
// Load next bytecode.
__ z_llgc(Z_bytecode, Address(Z_bcp, j));
__ z_agr(Z_bcp, j); // Advance bcp.
__ dispatch_only(vtos);
__ dispatch_only(vtos, true);
}
void TemplateTable::_return(TosState state) {
@ -2333,6 +2333,17 @@ void TemplateTable::_return(TosState state) {
__ bind(skip_register_finalizer);
}
if (SafepointMechanism::uses_thread_local_poll() && _desc->bytecode() != Bytecodes::_return_register_finalizer) {
Label no_safepoint;
const Address poll_byte_addr(Z_thread, in_bytes(Thread::polling_page_offset()) + 7 /* Big Endian */);
__ z_tm(poll_byte_addr, SafepointMechanism::poll_bit());
__ z_braz(no_safepoint);
__ push(state);
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint));
__ pop(state);
__ bind(no_safepoint);
}
if (state == itos) {
// Narrow result if state is itos but result type is smaller.
// Need to narrow in the return bytecode rather than in generate_return_entry

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -48,14 +48,14 @@ unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0;
#error HOTSPOT_VERSION_STRING must be defined
#endif
#ifndef VERSION_MAJOR
#error VERSION_MAJOR must be defined
#ifndef VERSION_FEATURE
#error VERSION_FEATURE must be defined
#endif
#ifndef VERSION_MINOR
#error VERSION_MINOR must be defined
#ifndef VERSION_INTERIM
#error VERSION_INTERIM must be defined
#endif
#ifndef VERSION_SECURITY
#error VERSION_SECURITY must be defined
#ifndef VERSION_UPDATE
#error VERSION_UPDATE must be defined
#endif
#ifndef VERSION_PATCH
#error VERSION_PATCH must be defined
@ -76,9 +76,9 @@ unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0;
// HOTSPOT_VERSION_STRING equals the JDK VERSION_STRING (unless overridden
// in a standalone build).
int Abstract_VM_Version::_vm_major_version = VERSION_MAJOR;
int Abstract_VM_Version::_vm_minor_version = VERSION_MINOR;
int Abstract_VM_Version::_vm_security_version = VERSION_SECURITY;
int Abstract_VM_Version::_vm_major_version = VERSION_FEATURE;
int Abstract_VM_Version::_vm_minor_version = VERSION_INTERIM;
int Abstract_VM_Version::_vm_security_version = VERSION_UPDATE;
int Abstract_VM_Version::_vm_patch_version = VERSION_PATCH;
int Abstract_VM_Version::_vm_build_number = VERSION_BUILD;
unsigned int Abstract_VM_Version::_parallel_worker_threads = 0;

View File

@ -899,81 +899,68 @@ public class Runtime {
*
* <h2><a id="verNum">Version numbers</a></h2>
*
* <p> A <em>version number</em>, {@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:
* </p>
* <p> A <em>version number</em>, {@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: </p>
*
* <blockquote><pre>
* [1-9][0-9]*((\.0)*\.[1-9][0-9]*)*
* [1-9][0-9]*((\.0)*\.[1-9][0-9]*)*
* </pre></blockquote>
*
* <p> The sequence may be of arbitrary length but the first three
* elements are assigned specific meanings, as follows:</p>
* <p> The sequence may be of arbitrary length but the first four elements
* are assigned specific meanings, as follows:</p>
*
* <blockquote><pre>
* $MAJOR.$MINOR.$SECURITY
* $FEATURE.$INTERIM.$UPDATE.$PATCH
* </pre></blockquote>
*
* <ul>
*
* <li><p> <a id="major">{@code $MAJOR}</a> --- The major version
* number, incremented for a major release that contains significant new
* features as specified in a new edition of the Java&#160;SE Platform
* Specification, <em>e.g.</em>, <a
* href="https://jcp.org/en/jsr/detail?id=337">JSR 337</a> for
* Java&#160;SE&#160;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&#160;8 is {@code 8}; the {@code $MAJOR} version
* number of JDK&#160;9 is {@code 9}. When {@code $MAJOR} is incremented,
* all subsequent elements are removed. </p></li>
* <li><p> <a id="FEATURE">{@code $FEATURE}</a> &#x2014; 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. </p></li>
*
* <li><p> <a id="minor">{@code $MINOR}</a> --- The minor version
* number, incremented for a minor update release that may contain
* compatible bug fixes, revisions to standard APIs mandated by a
* <a href="https://jcp.org/en/procedures/jcp2#5.3">Maintenance Release</a>
* 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. </p></li>
* <li><p> <a id="INTERIM">{@code $INTERIM}</a> &#x2014; 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.
* </p></li>
*
* <li><p> <a id="security">{@code $SECURITY}</a> --- The security
* level, incremented for a security update release that contains critical
* fixes including those necessary to improve security. {@code $SECURITY}
* is <strong>not</strong> 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}. </p></li>
* <li><p> <a id="UPDATE">{@code $UPDATE}</a> &#x2014; The update-release
* counter, incremented for compatible update releases that fix security
* issues, regressions, and bugs in newer features. </p></li>
*
* <li><p> <a id="PATCH">{@code $PATCH}</a> &#x2014; The emergency
* patch-release counter, incremented only when it's necessary to produce
* an emergency release to fix a critical issue. </p></li>
*
* </ul>
*
* <p> The fourth and later elements of a version number are free for use
* by downstream consumers of this code base. Such a consumer may,
* <em>e.g.</em>, 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. </p>
* <p> The fifth and later elements of a version number are free for use by
* platform implementors, to identify implementor-specific patch
* releases. </p>
*
* <p> The version number does not include trailing zero elements;
* <em>i.e.</em>, {@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. </p>
* <p> 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. </p>
*
* <p> The sequence of numerals in a version number is compared to another
* such sequence in numerical, pointwise fashion; <em>e.g.</em>, {@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; <em>e.g.</em>, {@code 9.1.2} is less than {@code 9.1.2.1}.
* </p>
* 10.0.4} is less than {@code 10.1.2}. 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;
* <em>e.g.</em>, {@code 10.0.2} is less than {@code 10.0.2.1}. </p>
*
* <h2><a id="verStr">Version strings</a></h2>
*
* <p> A <em>version string</em>, {@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:
* </p>
* <p> A <em>version string</em>, {@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: </p>
*
* <blockquote><pre>
* $VNUM(-$PRE)?\+$BUILD(-$OPT)?
@ -986,19 +973,19 @@ public class Runtime {
* <ul>
*
* <li><p> <a id="pre">{@code $PRE}</a>, 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. </p></li>
* &#x2014; 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. </p></li>
*
* <li><p> <a id="build">{@code $BUILD}</a>, matching {@code
* (0|[1-9][0-9]*)} --- The build number, incremented for each promoted
* (0|[1-9][0-9]*)} &#x2014; The build number, incremented for each promoted
* build. {@code $BUILD} is reset to {@code 1} when any portion of {@code
* $VNUM} is incremented. </p></li>
*
* <li><p> <a id="opt">{@code $OPT}</a>, 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. </p></li>
* <li><p> <a id="opt">{@code $OPT}</a>, matching {@code ([-a-zA-Z0-9.]+)}
* &#x2014; Additional build information, if desired. In the case of an
* {@code internal} build this will often contain the date and time of the
* build. </p></li>
*
* </ul>
*
@ -1082,7 +1069,7 @@ public class Runtime {
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 @@ public class Runtime {
}
/**
* Returns the <a href="#major">major</a> version number.
* Returns the value of the <a href="#FEATURE">feature</a> 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 <a href="#minor">minor</a> version number or zero if it
* was not set.
* Returns the value of the <a href="#INTERIM">interim</a> 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 <a href="#security">security</a> version number or zero
* if it was not set.
* Returns the value of the <a href="#UPDATE">update</a> 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 <a href="#verNum">version
* number</a>. The {@code List} always contains at least one
* element corresponding to the <a href="#major">major version
* number</a>.
* Returns the value of the <a href="#PATCH">patch</a> element of the
* version number, or zero if it is absent.
*
* @return An unmodifiable list of the integer numerals
* contained in the version number
* @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&nbsp;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 <a href="FEATURE">feature</a>
* 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.
*
* @deprecated As of Java&nbsp;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 <a href="INTERIM">interim</a>
* 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&nbsp;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 <a href="UPDATE">update</a> 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 <a href="#verNum">version number</a>. The {@code
* List} always contains at least one element corresponding to the <a
* href="#feature">feature version number</a>.
*
* @return An unmodifiable list of the integers
* represented in the version number
*/
public List<Integer> version() {
return version;

View File

@ -550,8 +550,10 @@ public final class System {
* System properties. The following properties are guaranteed to be defined:
* <dl>
* <dt>java.version <dd>Java version number
* <dt>java.version.date <dd>Java version date
* <dt>java.vendor <dd>Java vendor specific string
* <dt>java.vendor.url <dd>Java vendor URL
* <dt>java.vendor.version <dd>Java vendor version
* <dt>java.home <dd>Java installation directory
* <dt>java.class.version <dd>Java class version number
* <dt>java.class.path <dd>Java classpath
@ -591,12 +593,18 @@ public final class System {
* </thead>
* <tbody>
* <tr><th scope="row"><code>java.version</code></th>
* <td>Java Runtime Environment version which may be interpreted
* <td>Java Runtime Environment version, which may be interpreted
* as a {@link Runtime.Version}</td></tr>
* <tr><th scope="row"><code>java.version.date</code></th>
* <td>Java Runtime Environment version date, in ISO-8601 YYYY-MM-DD
* format, which may be interpreted as a {@link
* java.time.LocalDate}</td></tr>
* <tr><th scope="row"><code>java.vendor</code></th>
* <td>Java Runtime Environment vendor</td></tr>
* <tr><th scope="row"><code>java.vendor.url</code></th>
* <td>Java vendor URL</td></tr>
* <tr><th scope="row"><code>java.vendor.version</code></th>
* <td>Java vendor version</td></tr>
* <tr><th scope="row"><code>java.home</code></th>
* <td>Java installation directory</td></tr>
* <tr><th scope="row"><code>java.vm.specification.version</code></th>

View File

@ -32,13 +32,15 @@ import java.util.Optional;
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 @@ class VersionProps {
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 @@ class VersionProps {
/* 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 + ")");
}
}

View File

@ -32,8 +32,9 @@ import java.util.stream.Stream;
/**
* 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 <i>empty</i> and
* {@code isPresent()} returns {@code false}.
*
* <p>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 @@ public final class Optional<T> {
* {@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) {
@ -361,6 +358,21 @@ public final class Optional<T> {
return value != null ? value : supplier.get();
}
/**
* 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.

View File

@ -30,9 +30,10 @@ import java.util.function.Supplier;
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 <i>empty</i> and
* {@code isPresent()} returns {@code false}.
*
* <p>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 @@ public final class OptionalDouble {
* {@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) {
@ -225,6 +222,21 @@ public final class OptionalDouble {
return isPresent ? value : supplier.getAsDouble();
}
/**
* 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.

View File

@ -30,9 +30,10 @@ import java.util.function.Supplier;
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 <i>empty</i> and
* {@code isPresent()} returns {@code false}.
*
* <p>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 @@ public final class OptionalInt {
* {@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) {
@ -224,6 +221,21 @@ public final class OptionalInt {
return isPresent ? value : supplier.getAsInt();
}
/**
* 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.

View File

@ -30,9 +30,10 @@ import java.util.function.Supplier;
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 <i>empty</i> and
* {@code isPresent()} returns {@code false}.
*
* <p>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 @@ public final class OptionalLong {
* {@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) {
@ -224,6 +221,21 @@ public final class OptionalLong {
return isPresent ? value : supplier.getAsLong();
}
/**
* 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.

View File

@ -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 @@ import java.util.zip.ZipFile;
* <li>
* {@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 @@ import java.util.zip.ZipFile;
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 @@ class JarFile extends ZipFile {
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 @@ class JarFile extends ZipFile {
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 @@ class JarFile extends ZipFile {
* Returns the version that represents the effective runtime versioned
* configuration of a multi-release jar file.
* <p>
* 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 @@ class JarFile extends ZipFile {
* <p>
* 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 @@ class JarFile extends ZipFile {
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 @@ class JarFile extends ZipFile {
// 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 @@ class JarFile extends ZipFile {
}
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 @@ class JarFile extends ZipFile {
}
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);

View File

@ -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 @@ package java.util.zip;
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 class Deflater {
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 @@ public class Deflater {
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();
}
}
}
}

View File

@ -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 @@ import java.util.function.LongSupplier;
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 @@ public class Inflater {
* @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 @@ public class Inflater {
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();
}
}
}
}

View File

@ -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();
}
}
}

View File

@ -412,6 +412,21 @@ class ZipFile implements ZipConstants, Closeable {
}
}
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 @@ class ZipFile implements ZipConstants, Closeable {
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)

View File

@ -1058,11 +1058,6 @@ public final class Main {
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 @@ public final class Main {
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 @@ public final class Main {
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 @@ public final class Main {
}
}
}
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<Entry, char[]> 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.

View File

@ -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;

View File

@ -56,7 +56,7 @@ public enum SourceVersion {
* 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 @@ public enum SourceVersion {
* 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;

View File

@ -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.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*
* @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 Set<TypeElement> classes;
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<TypeElement> 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<VariableElement> getAllFields(TypeElement subclazz) {
List<VariableElement> fields = new ArrayList<>();
TypeElement cd = null;
Stack<TypeElement> 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();
}
}

View File

@ -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;
/**
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
public class InternalError extends Error {
private static final long serialVersionUID = 8411861562497165022L;
InternalError(String msg, Throwable cause) {
super("Internal error: " + msg);
initCause(cause);
}
}

View File

@ -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.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*
* @author Sucheta Dambalkar(Revised)
*/
public class JNI extends Gen {
JNI(Util util) {
super(util);
}
public String getIncludes() {
return "#include <jni.h>";
}
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<VariableElement> 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<ExecutableElement> 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<TypeMirror> 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. */
}
}

View File

@ -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.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
class 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);
}
}

View File

@ -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.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*
* @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,
Iterable<String> options,
Iterable<String> 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<JavaFileObject> getDiagnosticListenerForStream(OutputStream s) {
return getDiagnosticListenerForWriter(getPrintWriterForStream(s));
}
private DiagnosticListener<JavaFileObject> 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<String> 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<String> 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<String> 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<String> expandAtArgs(Iterable<String> args) throws BadArgs {
try {
List<String> 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<String> 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<JavaFileObject> createDiagnostic(final String key, final Object... args) {
return new Diagnostic<JavaFileObject>() {
@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<Locale,SoftReference<ResourceBundle>>
// 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<String> classes;
boolean verbose;
boolean noArgs;
boolean help;
boolean trace;
boolean version;
boolean fullVersion;
boolean jni;
boolean llni;
boolean doubleAlign;
boolean force;
Set<String> javac_extras = new LinkedHashSet<>();
PrintWriter log;
JavaFileManager fileManager;
DiagnosticListener<? super JavaFileObject> diagnosticListener;
Locale task_locale;
Map<Locale, ResourceBundle> 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<TypeElement> 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<TypeElement> getAllClasses(Set<? extends TypeElement> classes) {
Set<TypeElement> allClasses = new LinkedHashSet<>();
getAllClasses0(classes, allClasses);
return allClasses;
}
private void getAllClasses0(Iterable<? extends TypeElement> classes, Set<TypeElement> 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<TypeElement> 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<Void,Types> checkMethodParametersVisitor =
new SimpleTypeVisitor9<Void,Types>() {
@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;
}
}

View File

@ -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;
/*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
public class JavahTool implements NativeHeaderTool {
public NativeHeaderTask getTask(Writer out,
JavaFileManager fileManager,
DiagnosticListener<? super JavaFileObject> diagnosticListener,
Iterable<String> options,
Iterable<String> 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<SourceVersion> 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;
}
}

View File

@ -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;
/*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*
* @author Sucheta Dambalkar(Revised)
*/
public class LLNI extends Gen {
protected final char innerDelim = '$'; /* For inner classes */
protected Set<String> doneHandleTypes;
List<VariableElement> fields;
List<ExecutableElement> 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<VariableElement> 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<VariableElement> 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<TypeMirror> 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<TypeMirror> 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<Boolean,Void> v = new SimpleTypeVisitor9<Boolean,Void>() {
@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;
}
}

View File

@ -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.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
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 <i>not</i> 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);
}
}

View File

@ -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.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*
* @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;
}
}

View File

@ -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
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
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.
*
* <p>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<String> options,
Iterable<String> 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.
*
* <p>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.
*
* <p>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<Boolean> {
/**
* 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();
}
}

View File

@ -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.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*
* @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.
List<String> params = 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<Name, Void> v = new SimpleTypeVisitor9<Name, Void>() {
@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();
}
}

View File

@ -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
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
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 Diagnostic<JavaFileObject> createDiagnostic(
final Diagnostic.Kind kind, final String code, final Object... args) {
return new Diagnostic<JavaFileObject>() {
@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;
}
};
}
}

View File

@ -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] <classes>\n\
where [options] include:
main.opt.o=\
\ -o <file> Output file (only one of -d or -o may be used)
main.opt.d=\
\ -d <dir> 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> Path from which to load application modules
main.opt.upgrade_module_path=\
\ --upgrade_module-path <path> Path from which to load application modules
main.opt.classpath=\
\ -classpath <path> Path from which to load classes
main.opt.class_path=\
\ --class-path <path> Path from which to load classes
main.opt.cp=\
\ -cp <path> Path from which to load classes
main.opt.bootclasspath=\
\ -bootclasspath <path> Path from which to load bootstrap classes
main.opt.system=\
\ --system <jdk> 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

View File

@ -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] <classes>\n[options]\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002
main.opt.o=\ -o <file> \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 <dir> \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 <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 <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 <path> \u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9
main.opt.class_path=\ --class-path <path> \u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9
main.opt.cp=\ -cp <path> \u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9
main.opt.bootclasspath=\ -bootclasspath <path> \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9
main.opt.system=\ --system <jdk> \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

View File

@ -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] <classes>\n\u5176\u4E2D, [options] \u5305\u62EC:
main.opt.o=\ -o <file> \u8F93\u51FA\u6587\u4EF6 (\u53EA\u80FD\u4F7F\u7528 -d \u6216 -o \u4E4B\u4E00)
main.opt.d=\ -d <dir> \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 <path> \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 <path> \u4ECE\u4E2D\u52A0\u8F7D\u7C7B\u7684\u8DEF\u5F84
main.opt.bootclasspath=\ -bootclasspath <path> \u4ECE\u4E2D\u52A0\u8F7D\u5F15\u5BFC\u7C7B\u7684\u8DEF\u5F84
main.opt.system=\ --system <jdk> \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

View File

@ -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)

View File

@ -26,8 +26,7 @@
/**
* Defines the implementation of the
* {@linkplain javax.tools.ToolProvider#getSystemJavaCompiler system Java compiler}
* and its command line equivalent, <em>{@index javac javac tool}</em>,
* as well as <em>{@index javah javah tool}</em>.
* and its command line equivalent, <em>{@index javac javac tool}</em>.
*
* <h2 style="font-family:'DejaVu Sans Mono', monospace; font-style:italic">javac</h2>
*
@ -56,17 +55,9 @@
* {@code jdk.zipfs} module, must be available if the compiler is to be able
* to read JAR files.
*
* <h2 style="font-family:'DejaVu Sans Mono', monospace; font-style:italic">javah</h2>
*
* <p>
* <em>javah</em> 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 <em>javac</em> instead.</p>
*
* <dl style="font-family:'DejaVu Sans', Arial, Helvetica, sans serif">
* <dt class="simpleTagLabel">Tool Guides:
* <dd>{@extLink javac_tool_reference javac},
* {@extLink javah_tool_reference javah}
* <dd>{@extLink javac_tool_reference javac}
* </dl>
*
* @provides java.util.spi.ToolProvider

View File

@ -96,6 +96,7 @@ public class Contents {
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 class Contents {
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 @@ public class Contents {
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 @@ public class Contents {
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");

View File

@ -106,21 +106,34 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
= 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<PackageElement, SortedSet<ModuleElement>> 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<ModuleElement> 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<ModuleElement> 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<PackageElement, SortedSet<ModuleElement>> openedPackages
= new TreeMap<>(utils.makePackageComparator());
/**
* Set of concealed packages of this module.
*/
private final SortedSet<PackageElement> concealedPackages = new TreeSet<>(utils.makePackageComparator());
private final Map<PackageElement, PackageEntry> packages = new TreeMap<>(utils.makePackageComparator());
/**
* Map of indirect modules (transitive closure) and their exported packages.
@ -284,51 +297,52 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
}
});
// 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<ModuleElement> 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<ModuleElement> 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<ModuleElement> 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<ModuleElement> 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 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
indirectPackages.put(module, exportPkgList);
}
SortedSet<PackageElement> 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 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
@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 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
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++;
}
}
}
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<Content> colHeaders = new ArrayList<>();
List<HtmlStyle> 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<PackageElement, PackageEntry> e : packages.entrySet()) {
PackageElement pkg = e.getKey();
PackageEntry entry = e.getValue();
List<Content> 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);
}
addPackageTableRows(table);
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 void addPackageTableRows(Table table, Map<PackageElement,SortedSet<ModuleElement>> ap) {
for (Map.Entry<PackageElement, SortedSet<ModuleElement>> entry : ap.entrySet()) {
List<Content> row = new ArrayList<>();
PackageElement pkg = entry.getKey();
SortedSet<ModuleElement> mdleList = entry.getValue();
Content pkgLinkContent = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg)));
row.add(pkgLinkContent);
private boolean isOpened(Element e) {
PackageEntry entry = packages.get((PackageElement) e);
return (entry != null) && (entry.openedTo != null);
}
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 boolean isConcealed(Element e) {
PackageEntry entry = packages.get((PackageElement) e);
return (entry != null) && (entry.exportedTo == null) && (entry.openedTo == null);
}
private Content getPackageExportOpensTo(Set<ModuleElement> 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 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
ModuleElement m = entry.getKey();
SortedSet<PackageElement> 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 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
? 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);

View File

@ -76,6 +76,14 @@ public class TableHeader {
this.cellContents = Arrays.asList(headerCellContents);
}
/**
* Creates a header row, with specified content for each cell.
* @param headerCellContents a content object for each header cell
*/
public TableHeader(List<Content> 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.
@ -90,6 +98,20 @@ public class TableHeader {
return this;
}
/**
* 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<HtmlStyle> 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

View File

@ -145,6 +145,8 @@ doclet.errors=errors
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

View File

@ -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 @@ public class AboutDialog extends InternalDialog {
}
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);
}

View File

@ -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.ModuleElement;
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;

View File

@ -1,6 +1,6 @@
<!--
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
@ -62,7 +62,7 @@ JDeprScan Tool Command Reference
Prints out the set of deprecated APIs.
--release 6|7|8|9
--release 6|7|8|9|10
Specifies the Java SE release that is the source of
the list of deprecated APIs. If no --release option is

View File

@ -7,7 +7,7 @@ options:\n\
\ --full-version\n\
\ -h --help\n\
\ -l --list\n\
\ --release 6|7|8|9\n\
\ --release 6|7|8|9|10\n\
\ -v --verbose\n\
\ --version

View File

@ -448,13 +448,14 @@ public class JlinkTask {
// java.base version is different than the current runtime version
version = Runtime.Version.parse(v.toString());
if (Runtime.version().major() != version.major() ||
Runtime.version().minor() != version.minor()) {
if (Runtime.version().feature() != version.feature() ||
Runtime.version().interim() != version.interim())
{
// jlink version and java.base version do not match.
// We do not (yet) support this mode.
throw new IllegalArgumentException(taskHelper.getMessage("err.jlink.version.mismatch",
Runtime.version().major(), Runtime.version().minor(),
version.major(), version.minor()));
Runtime.version().feature(), Runtime.version().interim(),
version.feature(), version.interim()));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -299,7 +299,7 @@ public final class Main extends Shell {
private static String JAVADOC_BASE = "https://docs.oracle.com/javase/%d/docs/api/";
private static void openBrowserForJavadoc(ScriptFunction browse, String relativeUrl) {
try {
final URI uri = new URI(String.format(JAVADOC_BASE, Runtime.version().major()) + relativeUrl);
final URI uri = new URI(String.format(JAVADOC_BASE, Runtime.version().feature()) + relativeUrl);
ScriptRuntime.apply(browse, null, uri);
} catch (Exception ignored) {
}

View File

@ -796,7 +796,7 @@ final class AssignSymbols extends SimpleNodeVisitor implements Loggable {
args.add(strictFlagNode);
} else {
return LiteralNode.newInstance(unaryNode, true);
throw new AssertionError("Unexpected delete with " + rhs.getClass().getName() + " expression");
}
return new RuntimeNode(unaryNode, request, args);
}

View File

@ -228,6 +228,16 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Lo
return super.leaveIndexNode(indexNode);
}
@Override
public Node leaveDELETE(final UnaryNode delete) {
final Expression expression = delete.getExpression();
if (expression instanceof IdentNode || expression instanceof BaseNode) {
return delete;
}
return new BinaryNode(Token.recast(delete.getToken(), TokenType.COMMARIGHT), expression,
LiteralNode.newInstance(delete.getToken(), delete.getFinish(), true));
}
// If expression is a primitive literal that is not an array index and does return its string value. Else return null.
private static String getConstantPropertyName(final Expression expression) {
if (expression instanceof LiteralNode.PrimitiveLiteralNode) {

View File

@ -43,6 +43,7 @@ import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime;
import jdk.nashorn.internal.runtime.UnwarrantedOptimismException;
import jdk.nashorn.internal.runtime.WithObject;
import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
/**
@ -106,10 +107,35 @@ public final class NativeJavaImporter extends ScriptObject {
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object __noSuchProperty__(final Object self, final Object name) {
if (! (self instanceof NativeJavaImporter)) {
throw typeError("not.a.java.importer", ScriptRuntime.safeToString(self));
final NativeJavaImporter javaImporter = getJavaImporter(self);
if (javaImporter != null) {
return javaImporter.createProperty(JSType.toString(name));
}
return ((NativeJavaImporter)self).createProperty(JSType.toString(name));
throw typeError("not.a.java.importer", ScriptRuntime.safeToString(self));
}
private static NativeJavaImporter getJavaImporter(Object self) {
final NativeJavaImporter expression;
if (self instanceof NativeJavaImporter) {
expression = (NativeJavaImporter)self;
} else if (self instanceof ScriptObject) {
expression = getJavaImporterInScope((ScriptObject)self);
} else {
expression = null;
}
return expression;
}
private static NativeJavaImporter getJavaImporterInScope(ScriptObject self) {
for (ScriptObject obj = self; obj != null; obj = obj.getProto()) {
if (obj instanceof WithObject) {
final ScriptObject expression = ((WithObject)obj).getExpression();
if (expression instanceof NativeJavaImporter) {
return (NativeJavaImporter)expression;
}
}
}
return null;
}
/**

View File

@ -4404,15 +4404,6 @@ public class Parser extends AbstractParser implements Loggable {
final long unaryToken = token;
switch (type) {
case DELETE: {
next();
final Expression expr = unaryExpression();
if (expr instanceof BaseNode || expr instanceof IdentNode) {
return new UnaryNode(unaryToken, expr);
}
appendStatement(new ExpressionStatement(unaryLine, unaryToken, finish, expr));
return LiteralNode.newInstance(unaryToken, finish, true);
}
case ADD:
case SUB: {
final TokenType opType = type;
@ -4420,6 +4411,7 @@ public class Parser extends AbstractParser implements Loggable {
final Expression expr = unaryExpression();
return new UnaryNode(Token.recast(unaryToken, (opType == TokenType.ADD) ? TokenType.POS : TokenType.NEG), expr);
}
case DELETE:
case VOID:
case TYPEOF:
case BIT_NOT:

View File

@ -70,14 +70,14 @@ class JarFileSystem extends ZipFileSystem {
if (o instanceof String) {
String s = (String)o;
if (s.equals("runtime")) {
version = Runtime.version().major();
version = Runtime.version().feature();
} else {
version = Integer.parseInt(s);
}
} else if (o instanceof Integer) {
version = (Integer)o;
} else if (o instanceof Version) {
version = ((Version)o).major();
version = ((Version)o).feature();
} else {
throw new IllegalArgumentException("env parameter must be String, Integer, "
+ "or Version");

View File

@ -38,6 +38,7 @@ import java.util.stream.Collectors;
import static java.lang.System.out;
public class Basic {
private static final Class<? extends Throwable> IAE
= IllegalArgumentException.class;
private static final Class<? extends Throwable> NPE
@ -51,17 +52,19 @@ public class Basic {
public static void main(String ... args) {
//// Tests for parse(), major(), minor(), security(), pre(),
//// build(), optional(), version(), toString()
// v M m sec pre bld opt
//// Tests for parse(), feature(), interim(), update(), patch(),
//// pre(), build(), optional(), version(), and toString()
// v f i u p pre bld opt
// $VNUM
test("9", 9, 0, 0, "", 0, "");
test("9.1", 9, 1, 0, "", 0, "");
test("9.0.1", 9, 0, 1, "", 0, "");
test("404.1.2", 404, 1, 2, "", 0, "");
test("9.1.2.3", 9, 1, 2, "", 0, "");
test("1000.0.0.0.0.0.99999999", 1000, 0, 0, "", 0, "");
test("9", 9, 0, 0, 0, "", 0, "");
test("9.1", 9, 1, 0, 0, "", 0, "");
test("9.0.1", 9, 0, 1, 0, "", 0, "");
test("9.0.0.1", 9, 0, 0, 1, "", 0, "");
test("9.0.0.0.1", 9, 0, 0, 0, "", 0, "");
test("404.1.2", 404, 1, 2, 0, "", 0, "");
test("9.1.2.3", 9, 1, 2, 3, "", 0, "");
test("1000.0.0.0.0.0.99999999", 1000, 0, 0, 0, "", 0, "");
tryCatch(null, NPE);
tryCatch("", IAE);
@ -75,23 +78,23 @@ public class Basic {
tryCatch(TOO_BIG_STR, NFE);
// $PRE
test("9-ea", 9, 0, 0, "ea", 0, "");
test("9-internal", 9, 0, 0, "internal", 0, "");
test("9-0", 9, 0, 0, "0", 0, "");
test("9.2.7-8", 9, 2, 7, "8", 0, "");
test("1-ALL", 1, 0, 0, "ALL", 0, "");
test("2.3.4.5-1a", 2, 3, 4, "1a", 0, "");
test("1-" + TOO_BIG_STR, 1, 0, 0, TOO_BIG_STR, 0, "");
test("9-ea", 9, 0, 0, 0, "ea", 0, "");
test("9-internal", 9, 0, 0, 0, "internal", 0, "");
test("9-0", 9, 0, 0, 0, "0", 0, "");
test("9.2.7-8", 9, 2, 7, 0, "8", 0, "");
test("1-ALL", 1, 0, 0, 0, "ALL", 0, "");
test("2.3.4.5-1a", 2, 3, 4, 5, "1a", 0, "");
test("1-" + TOO_BIG_STR, 1, 0, 0, 0, TOO_BIG_STR, 0, "");
tryCatch("9:-ea", IAE);
tryCatch("3.14159-", IAE);
tryCatch("3.14159-%", IAE);
// $BUILD
test("9+0", 9, 0, 0, "", 0, "");
test("3.14+9999900", 3, 14, 0, "", 9999900, "");
test("9-pre+105", 9, 0, 0, "pre", 105, "");
test("6.0.42-8beta+4", 6, 0, 42, "8beta", 4, "");
test("9+0", 9, 0, 0, 0, "", 0, "");
test("3.14+9999900", 3, 14, 0, 0, "", 9999900, "");
test("9-pre+105", 9, 0, 0, 0, "pre", 105, "");
test("6.0.42-8beta+4", 6, 0, 42, 0, "8beta", 4, "");
tryCatch("9+", IAE);
tryCatch("7+a", IAE);
@ -101,13 +104,13 @@ public class Basic {
tryCatch("1+" + TOO_BIG_STR, NFE);
// $OPT
test("9+-foo", 9, 0, 0, "", 0, "foo");
test("9-pre-opt", 9, 0, 0, "pre", 0, "opt");
test("42+---bar", 42, 0, 0, "", 0, "--bar");
test("2.91+-8061493-", 2, 91, 0, "", 0, "8061493-");
test("24+-foo.bar", 24, 0, 0, "", 0, "foo.bar");
test("9-ribbit+17-...", 9, 0, 0, "ribbit", 17, "...");
test("7+1-" + TOO_BIG_STR, 7,0, 0, "", 1, TOO_BIG_STR);
test("9+-foo", 9, 0, 0, 0, "", 0, "foo");
test("9-pre-opt", 9, 0, 0, 0, "pre", 0, "opt");
test("42+---bar", 42, 0, 0, 0, "", 0, "--bar");
test("2.91+-8061493-", 2, 91, 0, 0, "", 0, "8061493-");
test("24+-foo.bar", 24, 0, 0, 0, "", 0, "foo.bar");
test("9-ribbit+17-...", 9, 0, 0, 0, "ribbit", 17, "...");
test("7+1-" + TOO_BIG_STR, 7,0, 0, 0, "", 1, TOO_BIG_STR);
tryCatch("9-pre+-opt", IAE);
tryCatch("1.4142+-", IAE);
@ -127,6 +130,8 @@ public class Basic {
testEHC("9", "8", false, false, 1, 1);
testEHC("10.512.1", "10.512.2", false, false, -1, -1);
testEHC("10.512.0.1", "10.512.0.2", false, false, -1, -1);
testEHC("10.512.0.0.1", "10.512.0.0.2", false, false, -1, -1);
testEHC("512.10.1", "512.11.1", false, false, -1, -1);
// $OPT comparison
@ -164,17 +169,21 @@ public class Basic {
}
private static void test(String s, Integer major, Integer minor,
Integer sec, String pre, Integer build,
String opt)
private static void test(String s, Integer feature, Integer interim,
Integer update, Integer patch,
String pre, Integer build, String opt)
{
Version v = testParse(s);
testStr(v.toString(), s);
testInt(v.major(), major);
testInt(v.minor(), minor);
testInt(v.security(), sec);
testInt(v.feature(), feature);
testInt(v.major(), feature);
testInt(v.interim(), interim);
testInt(v.minor(), interim);
testInt(v.update(), update);
testInt(v.security(), update);
testInt(v.patch(), patch);
testStr((v.pre().isPresent() ? v.pre().get() : ""), pre);
testInt((v.build().isPresent() ? v.build().get() : 0), build);
testStr((v.optional().isPresent() ? v.optional().get() : ""), opt);
@ -381,4 +390,5 @@ public class Basic {
first = x;
}
}
}

View File

@ -132,6 +132,13 @@ public class Basic {
Boolean got = empty.orElseThrow(ObscureException::new);
}
@Test(expectedExceptions=NoSuchElementException.class)
public void testEmptyOrElseThrowNoArg() throws Exception {
Optional<Boolean> empty = Optional.empty();
Boolean got = empty.orElseThrow();
}
@Test(groups = "unit")
public void testPresent() {
Optional<Boolean> empty = Optional.empty();
@ -147,6 +154,7 @@ public class Basic {
assertTrue(!present.toString().equals(presentEmptyString.toString()));
assertTrue(-1 != present.toString().indexOf(Boolean.TRUE.toString()));
assertSame(Boolean.TRUE, present.get());
assertSame(Boolean.TRUE, present.orElseThrow());
AtomicBoolean presentCheck = new AtomicBoolean();
present.ifPresent(v -> presentCheck.set(true));
@ -191,6 +199,7 @@ public class Basic {
instance = Optional.ofNullable("Duke");
assertTrue(instance.isPresent());
assertEquals(instance.get(), "Duke");
assertEquals(instance.orElseThrow(), "Duke");
}
@Test(groups = "unit")
@ -214,11 +223,13 @@ public class Basic {
result = duke.filter(s -> s.startsWith("D"));
assertTrue(result.isPresent());
assertEquals(result.get(), "Duke");
assertEquals(result.orElseThrow(), "Duke");
Optional<String> emptyString = Optional.of("");
result = emptyString.filter(String::isEmpty);
assertTrue(result.isPresent());
assertEquals(result.get(), "");
assertEquals(result.orElseThrow(), "");
}
@Test(groups = "unit")
@ -287,6 +298,7 @@ public class Basic {
l = duke.flatMap(s -> Optional.of(s.length()));
assertTrue(l.isPresent());
assertEquals(l.get().intValue(), 4);
assertEquals(l.orElseThrow().intValue(), 4);
// Verify same instance
l = duke.flatMap(s -> fixture);

View File

@ -124,6 +124,13 @@ public class BasicDouble {
double got = empty.orElseThrow(ObscureException::new);
}
@Test(expectedExceptions=NoSuchElementException.class)
public void testEmptyOrElseThrowNoArg() throws Exception {
OptionalDouble empty = OptionalDouble.empty();
double got = empty.orElseThrow();
}
@Test(groups = "unit")
public void testPresent() {
OptionalDouble empty = OptionalDouble.empty();
@ -137,7 +144,9 @@ public class BasicDouble {
assertTrue(Double.hashCode(1.0) == present.hashCode());
assertFalse(present.toString().isEmpty());
assertTrue(-1 != present.toString().indexOf(Double.toString(present.getAsDouble()).toString()));
assertTrue(-1 != present.toString().indexOf(Double.toString(present.orElseThrow()).toString()));
assertEquals(1.0, present.getAsDouble());
assertEquals(1.0, present.orElseThrow());
AtomicBoolean presentCheck = new AtomicBoolean();
present.ifPresent(v -> presentCheck.set(true));

View File

@ -124,6 +124,13 @@ public class BasicInt {
int got = empty.orElseThrow(ObscureException::new);
}
@Test(expectedExceptions=NoSuchElementException.class)
public void testEmptyOrElseThrowNoArg() throws Exception {
OptionalInt empty = OptionalInt.empty();
int got = empty.orElseThrow();
}
@Test(groups = "unit")
public void testPresent() {
OptionalInt empty = OptionalInt.empty();
@ -137,7 +144,9 @@ public class BasicInt {
assertTrue(Integer.hashCode(1) == present.hashCode());
assertFalse(present.toString().isEmpty());
assertTrue(-1 != present.toString().indexOf(Integer.toString(present.getAsInt()).toString()));
assertTrue(-1 != present.toString().indexOf(Integer.toString(present.orElseThrow()).toString()));
assertEquals(1, present.getAsInt());
assertEquals(1, present.orElseThrow());
AtomicBoolean presentCheck = new AtomicBoolean();
present.ifPresent(v -> presentCheck.set(true));

View File

@ -124,6 +124,13 @@ public class BasicLong {
long got = empty.orElseThrow(ObscureException::new);
}
@Test(expectedExceptions=NoSuchElementException.class)
public void testEmptyOrElseThrowNoArg() throws Exception {
OptionalLong empty = OptionalLong.empty();
long got = empty.orElseThrow();
}
@Test(groups = "unit")
public void testPresent() {
OptionalLong empty = OptionalLong.empty();
@ -137,7 +144,9 @@ public class BasicLong {
assertTrue(Long.hashCode(1) == present.hashCode());
assertFalse(present.toString().isEmpty());
assertTrue(-1 != present.toString().indexOf(Long.toString(present.getAsLong()).toString()));
assertTrue(-1 != present.toString().indexOf(Long.toString(present.orElseThrow()).toString()));
assertEquals(1L, present.getAsLong());
assertEquals(1L, present.orElseThrow());
AtomicBoolean presentCheck = new AtomicBoolean();
present.ifPresent(v -> presentCheck.set(true));

View File

@ -0,0 +1,119 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8010125 8192988
* @summary keytool should support -storepasswd for pkcs12 keystores
* @library /test/lib
* @build jdk.test.lib.SecurityTools
* jdk.test.lib.Utils
* jdk.test.lib.Asserts
* jdk.test.lib.JDKToolFinder
* jdk.test.lib.JDKToolLauncher
* jdk.test.lib.Platform
* jdk.test.lib.process.*
* @run main JKStoPKCS12
*/
import jdk.test.lib.Asserts;
import jdk.test.lib.SecurityTools;
import jdk.test.lib.process.OutputAnalyzer;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyStore;
import java.util.Collections;
public class JKStoPKCS12 {
static String srcStorePass, srcKeyPass;
public static void main(String[] args) throws Exception {
// Part 1: JKS keystore with same storepass and keypass
genJKS("pass1111", "pass1111");
// Change storepass, keypass also changes
convert("pass2222", null);
// You can keep storepass unchanged
convert("pass1111", null);
// Or change storepass and keypass both, explicitly
convert("pass2222", "pass2222");
// Part 2: JKS keystore with different storepass and keypass
Files.delete(Paths.get("jks"));
genJKS("pass1111", "pass2222");
// Can use old keypass as new storepass so new storepass and keypass are same
convert("pass2222", null);
// Or specify both storepass and keypass to brand new ones
convert("pass3333", "pass3333");
// Or change storepass, keypass also changes. Remember to provide srckeypass
convert("pass1111", null);
}
// Generate JKS keystore with srcStorePass and srcKeyPass
static void genJKS(String storePass, String keyPass)
throws Exception {
srcStorePass = storePass;
srcKeyPass = keyPass;
kt("-genkeypair -keystore jks -storetype jks "
+ "-alias me -dname CN=Me -keyalg rsa "
+ "-storepass " + srcStorePass + " -keypass " + srcKeyPass)
.shouldHaveExitValue(0);
}
// Convert JKS to PKCS12 with destStorePass and destKeyPass (optional)
static void convert(String destStorePass, String destKeyPass)
throws Exception {
String cmd = "-importkeystore -noprompt"
+ " -srcstoretype jks -srckeystore jks"
+ " -destkeystore p12 -deststoretype pkcs12"
+ " -srcstorepass " + srcStorePass
+ " -deststorepass " + destStorePass;
// Must import by alias (-srckeypass not available when importing all)
if (!srcStorePass.equals(srcKeyPass)) {
cmd += " -srcalias me";
cmd += " -srckeypass " + srcKeyPass;
}
if (destKeyPass != null) {
cmd += " -destkeypass " + destKeyPass;
}
kt(cmd).shouldHaveExitValue(0);
// Confirms the storepass and keypass are all correct
KeyStore.getInstance(new File("p12"), destStorePass.toCharArray())
.getKey("me", destStorePass.toCharArray());
Files.delete(Paths.get("p12"));
}
static OutputAnalyzer kt(String arg) throws Exception {
return SecurityTools.keytool(arg);
}
}

View File

@ -0,0 +1,163 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8192988
* @summary keytool should support -storepasswd for pkcs12 keystores
* @library /test/lib
* @build jdk.test.lib.SecurityTools
* jdk.test.lib.Utils
* jdk.test.lib.Asserts
* jdk.test.lib.JDKToolFinder
* jdk.test.lib.JDKToolLauncher
* jdk.test.lib.Platform
* jdk.test.lib.process.*
* @run main PKCS12Passwd
*/
import jdk.test.lib.Asserts;
import jdk.test.lib.SecurityTools;
import jdk.test.lib.process.OutputAnalyzer;
import java.io.File;
import java.security.KeyStore;
import java.util.Collections;
public class PKCS12Passwd {
public static void main(String[] args) throws Exception {
// A PrivateKeyEntry
kt("-genkeypair -alias a -dname CN=A")
.shouldHaveExitValue(0);
// A TrustedCertificateEntry (genkeypair, export, delete, import)
kt("-genkeypair -alias b -dname CN=B")
.shouldHaveExitValue(0);
kt("-exportcert -alias b -file b.cert")
.shouldHaveExitValue(0);
kt("-delete -alias b")
.shouldHaveExitValue(0);
kt("-list -alias b")
.shouldHaveExitValue(1);
kt("-importcert -alias b -file b.cert -noprompt")
.shouldHaveExitValue(0);
// A SecretKeyEntry
kt("-genseckey -keyalg AES -keysize 256 -alias c")
.shouldHaveExitValue(0);
// Change password
// 1. Using -importkeystore
ktFull("-importkeystore -srckeystore ks -destkeystore ks2 "
+ "-srcstoretype pkcs12 -deststoretype pkcs12 "
+ "-srcstorepass changeit -deststorepass newpass")
.shouldHaveExitValue(0);
check("ks2", "newpass", "newpass");
// 2. Using -storepasswd
kt("-storepasswd -new newpass")
.shouldHaveExitValue(0)
.shouldNotContain("Ignoring user-specified");
check("ks", "newpass", "newpass");
// Other facts. Not necessarily the correct thing.
// A PKCS12 keystore can be loaded as a JKS, and it follows JKS rules
// which means the storepass and keypass can be changed separately!
ktFull("-genkeypair -alias a -dname CN=A -storetype pkcs12 "
+ "-storepass changeit -keypass changeit -keystore p12")
.shouldHaveExitValue(0);
// Only storepass is changed
ktFull("-storepasswd -storepass changeit -new newpass "
+ "-keystore p12 -storetype jks")
.shouldHaveExitValue(0);
check("p12", "newpass", "changeit");
// Only keypass is changed
ktFull("-keypasswd -storepass newpass -keypass changeit -new newpass "
+ "-keystore p12 -storetype jks -alias a")
.shouldHaveExitValue(0);
check("p12", "newpass", "newpass");
// Conversely, a JKS keystore can be laoded as a PKCS12, and it follows
// PKCS12 rules that both passwords are changed at the same time and
// some commands are rejected.
ktFull("-genkeypair -alias a -dname CN=A -storetype jks "
+ "-storepass changeit -keypass changeit -keystore jks")
.shouldHaveExitValue(0);
// Both storepass and keypass changed.
ktFull("-storepasswd -storepass changeit -new newpass "
+ "-keystore jks -storetype pkcs12")
.shouldHaveExitValue(0);
check("jks", "newpass", "newpass");
// -keypasswd is not available for pkcs12
ktFull("-keypasswd -storepass newpass -keypass newpass -new newerpass "
+ "-keystore jks -storetype pkcs12 -alias a")
.shouldHaveExitValue(1);
// but available for JKS
ktFull("-keypasswd -storepass newpass -keypass newpass -new newerpass "
+ "-keystore jks -alias a")
.shouldHaveExitValue(0);
check("jks", "newpass", "newerpass");
}
// Makes sure we can load entries in a keystore
static void check(String file, String storePass, String keyPass)
throws Exception {
KeyStore ks = KeyStore.getInstance(
new File(file), storePass.toCharArray());
for (String a : Collections.list(ks.aliases())) {
if (ks.isCertificateEntry(a)) {
ks.getCertificate(a);
} else {
ks.getEntry(a,
new KeyStore.PasswordProtection(keyPass.toCharArray()));
}
}
}
static OutputAnalyzer kt(String arg) throws Exception {
return ktFull("-keystore ks -storepass changeit " + arg);
}
static OutputAnalyzer ktFull(String arg) throws Exception {
return SecurityTools.keytool("-debug " + arg);
}
}

View File

@ -1,118 +0,0 @@
#
# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 8010125
# @summary keytool -importkeystore could create a pkcs12 keystore with
# different storepass and keypass
#
if [ "${TESTJAVA}" = "" ] ; then
JAVAC_CMD=`which javac`
TESTJAVA=`dirname $JAVAC_CMD`/..
fi
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
Windows_* )
FS="\\"
;;
* )
FS="/"
;;
esac
LANG=C
KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS}"
# Part 1: JKS keystore with same storepass and keypass
rm jks 2> /dev/null
$KT -genkeypair -keystore jks -storetype jks -alias me -dname CN=Me \
-keyalg rsa -storepass pass1111 -keypass pass1111 || exit 11
# Cannot only change storepass
rm p12 2> /dev/null
$KT -importkeystore -noprompt \
-srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
-srcstorepass pass1111 \
-deststorepass pass2222 \
&& exit 12
# You can keep storepass unchanged
rm p12 2> /dev/null
$KT -importkeystore -noprompt \
-srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
-srcstorepass pass1111 \
-deststorepass pass1111 \
|| exit 13
$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
-storepass pass1111 -keypass pass1111 || exit 14
# Or change storepass and keypass both
rm p12 2> /dev/null
$KT -importkeystore -noprompt \
-srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
-srcstorepass pass1111 \
-deststorepass pass2222 -destkeypass pass2222 \
|| exit 15
$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
-storepass pass2222 -keypass pass2222 || exit 16
# Part 2: JKS keystore with different storepass and keypass
# Must import by alias (-srckeypass is not available when importing all)
rm jks 2> /dev/null
$KT -genkeypair -keystore jks -storetype jks -alias me -dname CN=Me \
-keyalg rsa -storepass pass1111 -keypass pass2222 || exit 21
# Can use old keypass as new storepass so new storepass and keypass are same
rm p12 2> /dev/null
$KT -importkeystore -noprompt -srcalias me \
-srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
-srcstorepass pass1111 -srckeypass pass2222 \
-deststorepass pass2222 \
|| exit 22
$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
-storepass pass2222 -keypass pass2222 || exit 23
# Or specify both storepass and keypass to brand new ones
rm p12 2> /dev/null
$KT -importkeystore -noprompt -srcalias me \
-srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
-srcstorepass pass1111 -srckeypass pass2222 \
-deststorepass pass3333 -destkeypass pass3333 \
|| exit 24
$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
-storepass pass3333 -keypass pass3333 || exit 25
# Anyway you cannot make new storepass and keypass different
rm p12 2> /dev/null
$KT -importkeystore -noprompt -srcalias me \
-srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
-srcstorepass pass1111 -srckeypass pass2222 \
-deststorepass pass1111 \
&& exit 26
exit 0

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
@ -24,7 +24,7 @@
/*
* @test
* @bug 8002091
* @summary Test options patterns for javac,javah,javap and javadoc using
* @summary Test options patterns for javac,javap and javadoc using
* javac as a test launcher. Create a dummy javac and intercept options to check
* reception of options as passed through the launcher without having to launch
* javac. Only -J and -cp ./* options should be consumed by the launcher.

View File

@ -236,6 +236,9 @@ public abstract class JavadocTester {
/** The current run of javadoc. Incremented when javadoc is called. */
private int javadocRunNum = 0;
/** The current subtest number for this run of javadoc. Incremented when checking(...) is called. */
private int javadocTestNum = 0;
/** Marker annotation for test methods to be invoked by runTests. */
@Retention(RetentionPolicy.RUNTIME)
@interface Test { }
@ -295,11 +298,11 @@ public abstract class JavadocTester {
fileContentCache.clear();
javadocRunNum++;
javadocTestNum = 0; // reset counter for this run of javadoc
if (javadocRunNum == 1) {
out.println("Running javadoc...");
} else {
out.println("Running javadoc (run "
+ javadocRunNum + ")...");
out.println("Running javadoc (run "+ javadocRunNum + ")...");
}
outputDir = new File(".");
@ -441,8 +444,7 @@ public abstract class JavadocTester {
* Check for content in (or not in) the generated output.
* Within the search strings, the newline character \n
* will be translated to the platform newline character sequence.
* @param path a path within the most recent output directory
* or the name of one of the output buffers, identifying
* @param path a path within the most recent output directory, identifying
* where to look for the search strings.
* @param expectedFound true if all of the search strings are expected
* to be found, or false if all of the strings are expected to be
@ -451,15 +453,13 @@ public abstract class JavadocTester {
*/
public void checkOutput(String path, boolean expectedFound, String... strings) {
// Read contents of file
String fileString;
try {
fileString = readFile(outputDir, path);
String fileString = readFile(outputDir, path);
checkOutput(new File(outputDir, path).getPath(), fileString, expectedFound, strings);
} catch (Error e) {
checking("Read file");
failed("Error reading file: " + e);
return;
}
checkOutput(path, fileString, expectedFound, strings);
}
/**
@ -476,6 +476,7 @@ public abstract class JavadocTester {
checkOutput(output.toString(), outputMap.get(output), expectedFound, strings);
}
// NOTE: path may be the name of an Output stream as well as a file path
private void checkOutput(String path, String fileString, boolean expectedFound, String... strings) {
for (String stringToFind : strings) {
// log.logCheckOutput(path, expectedFound, stringToFind);
@ -484,25 +485,27 @@ public abstract class JavadocTester {
boolean isFound = findString(fileString, stringToFind);
if (isFound == expectedFound) {
passed(path + ": following text " + (isFound ? "found:" : "not found:") + "\n"
+ stringToFind + "\n");
+ stringToFind);
} else {
failed(path + ": following text " + (isFound ? "found:" : "not found:") + "\n"
+ stringToFind + "\n");
+ stringToFind);
}
}
}
/**
* Get the content of the one of the output streams written by
* javadoc.
* Get the content of the one of the output streams written by javadoc.
* @param output the name of the output stream
* @return the content of the output stream
*/
public String getOutput(Output output) {
return outputMap.get(output);
}
/**
* Get the content of the one of the output streams written by
* javadoc.
* Get the content of the one of the output streams written by javadoc.
* @param output the name of the output stream
* @return the content of the output stream, as a line of lines
*/
public List<String> getOutputLines(Output output) {
String text = outputMap.get(output);
@ -534,9 +537,9 @@ public abstract class JavadocTester {
File file = new File(outputDir, path);
boolean isFound = file.exists();
if (isFound == expectedFound) {
passed(path + ": file " + (isFound ? "found:" : "not found:") + "\n");
passed(file, "file " + (isFound ? "found:" : "not found:") + "\n");
} else {
failed(path + ": file " + (isFound ? "found:" : "not found:") + "\n");
failed(file, "file " + (isFound ? "found:" : "not found:") + "\n");
}
}
}
@ -548,20 +551,21 @@ public abstract class JavadocTester {
* @param strings the strings whose order to check
*/
public void checkOrder(String path, String... strings) {
File file = new File(outputDir, path);
String fileString = readOutputFile(path);
int prevIndex = -1;
for (String s : strings) {
s = s.replace("\n", NL); // normalize new lines
int currentIndex = fileString.indexOf(s, prevIndex + 1);
checking(s + " at index " + currentIndex);
checking("file: " + file + ": " + s + " at index " + currentIndex);
if (currentIndex == -1) {
failed(s + " not found.");
failed(file, s + " not found.");
continue;
}
if (currentIndex > prevIndex) {
passed(s + " is in the correct order");
passed(file, s + " is in the correct order");
} else {
failed("file: " + path + ": " + s + " is in the wrong order.");
failed(file, s + " is in the wrong order.");
}
prevIndex = currentIndex;
}
@ -575,19 +579,20 @@ public abstract class JavadocTester {
* @param strings ensure each are unique
*/
public void checkUnique(String path, String... strings) {
File file = new File(outputDir, path);
String fileString = readOutputFile(path);
for (String s : strings) {
int currentIndex = fileString.indexOf(s);
checking(s + " at index " + currentIndex);
if (currentIndex == -1) {
failed(s + " not found.");
failed(file, s + " not found.");
continue;
}
int nextindex = fileString.indexOf(s, currentIndex + s.length());
if (nextindex == -1) {
passed(s + " is unique");
passed(file, s + " is unique");
} else {
failed(s + " is not unique, found at " + nextindex);
failed(file, s + " is not unique, found at " + nextindex);
}
}
}
@ -702,16 +707,35 @@ public abstract class JavadocTester {
protected void checking(String message) {
numTestsRun++;
print("Starting subtest " + numTestsRun, message);
javadocTestNum++;
print("Starting subtest " + javadocRunNum + "." + javadocTestNum, message);
}
protected void passed(File file, String message) {
passed(file + ": " + message);
}
protected void passed(String message) {
numTestsPassed++;
print("Passed", message);
out.println();
}
protected void failed(File file, String message) {
failed(file + ": " + message);
}
protected void failed(String message) {
print("FAILED", message);
StackWalker.getInstance().walk(s -> {
s.dropWhile(f -> f.getMethodName().equals("failed"))
.takeWhile(f -> !f.getMethodName().equals("runTests"))
.forEach(f -> out.println(" at "
+ f.getClassName() + "." + f.getMethodName()
+ "(" + f.getFileName() + ":" + f.getLineNumber() + ")"));
return null;
});
out.println();
}
private void print(String prefix, String message) {
@ -720,7 +744,10 @@ public abstract class JavadocTester {
else {
out.print(prefix);
out.print(": ");
out.println(message.replace("\n", NL));
out.print(message.replace("\n", NL));
if (!(message.endsWith("\n") || message.endsWith(NL))) {
out.println();
}
}
}

View File

@ -0,0 +1,488 @@
/*
* 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8178070
* @summary Test packages table in module summary pages
* @library /tools/lib ../lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.javadoc/jdk.javadoc.internal.tool
* @build toolbox.ModuleBuilder toolbox.ToolBox JavadocTester
* @run main TestModulePackages
*/
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Set;
import toolbox.ModuleBuilder;
import toolbox.ToolBox;
public class TestModulePackages extends JavadocTester {
enum TabKind { EXPORTS, OPENS, CONCEALED };
enum ColKind { EXPORTED_TO, OPENED_TO };
public static void main(String... args) throws Exception {
TestModulePackages tester = new TestModulePackages();
tester.runTests(m -> new Object[] { Paths.get(m.getName()) });
}
private final ToolBox tb;
public TestModulePackages() {
tb = new ToolBox();
}
// @Test: See: https://bugs.openjdk.java.net/browse/JDK-8193107
public void empty(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, "m")
.comment("empty module")
.write(src);
javadoc("-d", base.resolve("out").toString(),
"-quiet",
"-noindex",
"--module-source-path", src.toString(),
"--module", "m");
checkExit(Exit.OK);
checkOutput("m-summary.html", false,
"<h3>Packages</h3>\n"
+ "<table class=\"packagesSummary\" summary=\"Packages table, "
+ "listing packages, and an explanation\">");
}
@Test
public void exportSingle(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, "m")
.comment("exports single package to all")
.exports("p")
.classes("package p; public class C { }")
.write(src);
javadoc("-d", base.resolve("out").toString(),
"-quiet",
"-noindex",
"--module-source-path", src.toString(),
"--module", "m");
checkExit(Exit.OK);
checkCaption("m", TabKind.EXPORTS);
checkTableHead("m");
checkPackageRow("m", "p", "i0", null, null, "&nbsp;");
}
@Test
public void exportMultiple(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, "m")
.comment("exports multiple packages to all")
.exports("p")
.exports("q")
.classes("package p; public class C { }")
.classes("package q; public class D { }")
.write(src);
javadoc("-d", base.resolve("out").toString(),
"-quiet",
"-noindex",
"--module-source-path", src.toString(),
"--module", "m");
checkExit(Exit.OK);
checkCaption("m", TabKind.EXPORTS);
checkTableHead("m");
checkPackageRow("m", "p", "i0", null, null, "&nbsp;");
checkPackageRow("m", "q", "i1", null, null, "&nbsp;");
}
@Test
public void exportSomeQualified(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, "m")
.comment("exports multiple packages, some qualified")
.exports("p")
.exportsTo("q", "other")
.classes("package p; public class C { }")
.classes("package q; public class D { }")
.write(src);
new ModuleBuilder(tb, "other")
.comment("dummy module for target of export")
.write(src);
javadoc("-d", base.resolve("out-api").toString(),
"-quiet",
"-noindex",
"--module-source-path", src.toString(),
"--module", "m,other");
checkExit(Exit.OK);
checkCaption("m", TabKind.EXPORTS);
checkTableHead("m");
checkPackageRow("m", "p", "i0", null, null, "&nbsp;");
javadoc("-d", base.resolve("out-all").toString(),
"-quiet",
"-noindex",
"--show-module-contents", "all",
"--module-source-path", src.toString(),
"--module", "m,other");
checkExit(Exit.OK);
checkCaption("m", TabKind.EXPORTS);
checkTableHead("m", ColKind.EXPORTED_TO);
checkPackageRow("m", "p", "i0", "All Modules", null, "&nbsp;");
checkPackageRow("m", "q", "i1",
"<a href=\"other-summary.html\">other</a>", null, "&nbsp;");
}
@Test
public void exportWithConcealed(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, "m")
.comment("exports package, has concealed package")
.exports("p")
.classes("package p; public class C { }")
.classes("package q; public class D { }")
.write(src);
javadoc("-d", base.resolve("out-api").toString(),
"-quiet",
"-noindex",
"--module-source-path", src.toString(),
"--module", "m");
checkExit(Exit.OK);
checkCaption("m", TabKind.EXPORTS);
checkTableHead("m");
checkPackageRow("m", "p", "i0", null, null, "&nbsp;");
javadoc("-d", base.resolve("out-all").toString(),
"-quiet",
"-noindex",
"--show-module-contents", "all",
"--show-packages", "all",
"--module-source-path", src.toString(),
"--module", "m");
checkExit(Exit.OK);
checkCaption("m", TabKind.EXPORTS, TabKind.CONCEALED);
checkTableHead("m", ColKind.EXPORTED_TO);
checkPackageRow("m", "p", "i0", "All Modules", null, "&nbsp;");
checkPackageRow("m", "q", "i1", "None", null, "&nbsp;");
}
@Test
public void exportOpenWithConcealed(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, "m")
.comment("exports and opens qual and unqual, with concealed")
.exports("e.all")
.exportsTo("e.other", "other")
.opens("o.all")
.opensTo("o.other", "other")
.exports("eo")
.opens("eo")
.classes("package e.all; public class CEAll { }")
.classes("package e.other; public class CEOther { }")
.classes("package o.all; public class COAll { }")
.classes("package o.other; public class COOther { }")
.classes("package eo; public class CEO { }")
.classes("package c; public class C { }")
.write(src);
new ModuleBuilder(tb, "other")
.comment("dummy module for target of export and open")
.write(src);
javadoc("-d", base.resolve("out-api").toString(),
"-quiet",
"-noindex",
"--module-source-path", src.toString(),
"--module", "m,other");
checkExit(Exit.OK);
checkCaption("m", TabKind.EXPORTS, TabKind.OPENS);
checkTableHead("m", ColKind.EXPORTED_TO, ColKind.OPENED_TO);
checkPackageRow("m", "e.all", "i0", "All Modules", "None", "&nbsp;");
checkPackageRow("m", "eo", "i1", "All Modules", "All Modules", "&nbsp;");
javadoc("-d", base.resolve("out-all").toString(),
"-quiet",
"-noindex",
"--show-module-contents", "all",
"--show-packages", "all",
"--module-source-path", src.toString(),
"--module", "m,other");
checkExit(Exit.OK);
checkCaption("m", TabKind.EXPORTS, TabKind.OPENS, TabKind.CONCEALED);
checkTableHead("m", ColKind.EXPORTED_TO, ColKind.OPENED_TO);
checkPackageRow("m", "c", "i0", "None", "None", "&nbsp;");
checkPackageRow("m", "e.all", "i1", "All Modules", "None", "&nbsp;");
checkPackageRow("m", "e.other", "i2",
"<a href=\"other-summary.html\">other</a>", "None", "&nbsp;");
checkPackageRow("m", "eo", "i3", "All Modules", "All Modules", "&nbsp;");
checkPackageRow("m", "o.all", "i4", "None", "All Modules", "&nbsp;");
checkPackageRow("m", "o.other", "i5", "None",
"<a href=\"other-summary.html\">other</a>", "&nbsp;");
}
@Test
public void openModule(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, true, "m")
.comment("open module")
.classes("/** implicitly open package */ package p;")
.classes("package p; public class C { } ")
.classes("/** implicitly open package */ package q;")
.classes("package q; public class D { }")
.write(src);
javadoc("-d", base.resolve("out").toString(),
"-quiet",
"-noindex",
"--show-packages", "all", // required, to show open packages; see JDK-8193107
"--module-source-path", src.toString(),
"--module", "m");
checkExit(Exit.OK);
checkCaption("m", TabKind.OPENS);
checkTableHead("m");
checkPackageRow("m", "p", "i0", null, null,
"\n<div class=\"block\">implicitly open package</div>\n");
checkPackageRow("m", "q", "i1", null, null,
"\n<div class=\"block\">implicitly open package</div>\n");
}
@Test
public void openSingle(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, "m")
.comment("opens single package to all")
.opens("p")
.classes("package p; public class C { }")
.write(src);
javadoc("-d", base.resolve("out").toString(),
"-quiet",
"-noindex",
"--show-packages", "all", // required, to show open packages; see JDK-8193107
"--module-source-path", src.toString(),
"--module", "m");
checkExit(Exit.OK);
checkCaption("m", TabKind.OPENS);
checkTableHead("m");
checkPackageRow("m", "p", "i0", null, null, "&nbsp;");
}
@Test
public void openMultiple(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, "m")
.comment("opens multiple packages to all")
.opens("p")
.opens("q")
.classes("package p; public class C { }")
.classes("package q; public class D { }")
.write(src);
javadoc("-d", base.resolve("out").toString(),
"-quiet",
"-noindex",
"--show-packages", "all", // required, to show open packages; see JDK-8193107
"--module-source-path", src.toString(),
"--module", "m");
checkExit(Exit.OK);
checkCaption("m", TabKind.OPENS);
checkTableHead("m");
checkPackageRow("m", "p", "i0", null, null, "&nbsp;");
checkPackageRow("m", "q", "i1", null, null, "&nbsp;");
}
@Test
public void openSomeQualified(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, "m")
.comment("opens multiple packages, some qualified")
.opens("p")
.opensTo("q", "other")
.classes("package p; public class C { }")
.classes("package q; public class D { }")
.write(src);
new ModuleBuilder(tb, "other")
.comment("dummy module for target of export")
.write(src);
javadoc("-d", base.resolve("out-api").toString(),
"-quiet",
"-noindex",
"--show-packages", "all", // required, to show open packages; see JDK-8193107
"--module-source-path", src.toString(),
"--module", "m,other");
checkExit(Exit.OK);
checkCaption("m", TabKind.OPENS);
checkTableHead("m");
checkPackageRow("m", "p", "i0", null, null, "&nbsp;");
javadoc("-d", base.resolve("out-all").toString(),
"-quiet",
"-noindex",
"--show-packages", "all", // required, to show open packages; see JDK-8193107
"--show-module-contents", "all",
"--module-source-path", src.toString(),
"--module", "m,other");
checkExit(Exit.OK);
checkCaption("m", TabKind.OPENS);
checkTableHead("m", ColKind.OPENED_TO);
checkPackageRow("m", "p", "i0", null, "All Modules", "&nbsp;");
checkPackageRow("m", "q", "i1", null,
"<a href=\"other-summary.html\">other</a>", "&nbsp;");
}
@Test
public void openWithConcealed(Path base) throws Exception {
Path src = base.resolve("src");
new ModuleBuilder(tb, "m")
.comment("opens package, has concealed package")
.opens("p")
.classes("package p; public class C { }")
.classes("package q; public class D { }")
.write(src);
javadoc("-d", base.resolve("out-api").toString(),
"-quiet",
"-noindex",
"--show-packages", "all", // required, to show open packages; see JDK-8193107
"--module-source-path", src.toString(),
"--module", "m");
checkExit(Exit.OK);
checkCaption("m", TabKind.OPENS);
checkTableHead("m");
checkPackageRow("m", "p", "i0", null, null, "&nbsp;");
javadoc("-d", base.resolve("out-all").toString(),
"-quiet",
"-noindex",
"--show-module-contents", "all",
"--show-packages", "all",
"--module-source-path", src.toString(),
"--module", "m");
checkExit(Exit.OK);
checkCaption("m", TabKind.OPENS, TabKind.CONCEALED);
checkTableHead("m", ColKind.OPENED_TO);
checkPackageRow("m", "p", "i0", null, "All Modules", "&nbsp;");
checkPackageRow("m", "q", "i1", null, "None", "&nbsp;");
}
private void checkCaption(String moduleName, TabKind... kinds) {
String expect;
if (kinds.length > 1) {
Set<TabKind> kindSet = Set.of(kinds);
StringBuilder sb = new StringBuilder();
sb.append("<caption>"
+ "<span id=\"t0\" class=\"activeTableTab\">"
+ "<span>All Packages</span>"
+ "<span class=\"tabEnd\">&nbsp;</span></span>");
if (kindSet.contains(TabKind.EXPORTS)) {
sb.append("<span id=\"t1\" class=\"tableTab\">"
+ "<span><a href=\"javascript:showPkgs(1);\">Exports</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span></span>");
}
if (kindSet.contains(TabKind.OPENS)) {
sb.append("<span id=\"t2\" class=\"tableTab\">"
+ "<span><a href=\"javascript:showPkgs(2);\">Opens</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span></span>");
}
if (kindSet.contains(TabKind.CONCEALED)) {
sb.append("<span id=\"t3\" class=\"tableTab\"><span>"
+ "<a href=\"javascript:showPkgs(4);\">Concealed</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span></span>");
}
sb.append("</caption>");
expect = sb.toString();
} else {
TabKind k = kinds[0];
String name = k.toString().charAt(0) + k.toString().substring(1).toLowerCase();
expect = "<caption>"
+ "<span>" + name + "</span>"
+ "<span class=\"tabEnd\">&nbsp;</span>"
+ "</caption>";
}
checkOutput(moduleName + "-summary.html", true, expect);
}
private void checkTableHead(String moduleName, ColKind... kinds) {
Set<ColKind> kindSet = Set.of(kinds);
StringBuilder sb = new StringBuilder();
sb.append("<tr>\n"
+ "<th class=\"colFirst\" scope=\"col\">Package</th>\n");
if (kindSet.contains(ColKind.EXPORTED_TO)) {
sb.append("<th class=\"colSecond\" scope=\"col\">Exported To Modules</th>\n");
}
if (kindSet.contains(ColKind.OPENED_TO)) {
sb.append("<th class=\"colSecond\" scope=\"col\">Opened To Modules</th>\n");
}
sb.append("<th class=\"colLast\" scope=\"col\">Description</th>\n"
+ "</tr>");
checkOutput(moduleName + "-summary.html", true, sb.toString());
}
private void checkPackageRow(String moduleName, String packageName,
String id, String exportedTo, String openedTo, String desc) {
StringBuilder sb = new StringBuilder();
int idNum = Integer.parseInt(id.substring(1));
String color = (idNum % 2 == 1 ? "rowColor" : "altColor");
sb.append("<tr class=\"" + color + "\" id=\"" + id + "\">\n"
+ "<th class=\"colFirst\" scope=\"row\">"
+ "<a href=\"" + packageName.replace('.', '/') + "/package-summary.html\">"
+ packageName + "</a></th>\n");
if (exportedTo != null) {
sb.append("<td class=\"colSecond\">" + exportedTo + "</td>\n");
}
if (openedTo != null) {
sb.append("<td class=\"colSecond\">" + openedTo + "</td>\n");
}
sb.append("<td class=\"colLast\">" + desc + "</td>");
checkOutput(moduleName + "-summary.html", true, sb.toString());
}
}

View File

@ -994,7 +994,7 @@ public class TestModules extends JavadocTester {
+ "</tr>\n"
+ "</tbody>\n"
+ "</table>");
checkOutput("moduletags-summary.html", found,
checkOutput("moduletags-summary.html", true,
"<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdltags/package-summary.html\">testpkgmdltags</a></th>\n"
+ "<td class=\"colLast\">&nbsp;</td>");
}
@ -1025,6 +1025,7 @@ public class TestModules extends JavadocTester {
"<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a href=\"#modules.summary\">"
+ "Modules</a>&nbsp;|&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;<a href=\"#services.summary\">Services</a></li>",
"<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlB/package-summary.html\">testpkgmdlB</a></th>\n"
+ "<td class=\"colSecond\">None</td>\n"
+ "<td class=\"colSecond\">All Modules</td>\n"
+ "<td class=\"colLast\">&nbsp;</td>",
"<td class=\"colFirst\"> </td>\n"
@ -1045,12 +1046,11 @@ public class TestModules extends JavadocTester {
"<caption><span>Exports</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
+ "<tr>\n"
+ "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
+ "<th class=\"colSecond\" scope=\"col\">Module</th>\n"
+ "<th class=\"colSecond\" scope=\"col\">Exported To Modules</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Description</th>\n"
+ "</tr>");
checkOutput("moduletags-summary.html", found,
checkOutput("moduletags-summary.html", true,
"<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdltags/package-summary.html\">testpkgmdltags</a></th>\n"
+ "<td class=\"colSecond\">All Modules</td>\n"
+ "<td class=\"colLast\">&nbsp;</td>");
}

View File

@ -1,79 +0,0 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8152360
* @summary deprecate javah
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.compiler/com.sun.tools.javah
* @build toolbox.ToolBox toolbox.JavahTask
* @run main DeprecateJavahTest
*/
import toolbox.JavahTask;
import toolbox.Task;
import toolbox.ToolBox;
public class DeprecateJavahTest {
public static void main(String... args) throws Exception {
new DeprecateJavahTest().run();
}
ToolBox tb = new ToolBox();
void printDeprecationWarning() throws Exception {
String output = new JavahTask(tb)
.options("-version")
.run()
.writeAll()
.getOutput(Task.OutputKind.DIRECT);
if (!output.contains(
"Warning: The 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.")) {
throw new Exception("test failed");
}
}
void dontPrintDeprecationWarning() throws Exception {
String output = new JavahTask(tb)
.options("-version", "-XDsuppress-tool-removal-message")
.run()
.writeAll()
.getOutput(Task.OutputKind.DIRECT);
if (!output.startsWith("javah version")) {
throw new Exception("test failed");
}
}
void run() throws Exception {
printDeprecationWarning();
dontPrintDeprecationWarning();
}
}

View File

@ -1,170 +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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7150368 8003412 8000407 8031545
* @summary javac should include basic ability to generate native headers
* @modules jdk.compiler/com.sun.tools.javah
*/
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class CompareTest {
public static void main(String... args) throws Exception {
new CompareTest().run();
}
void run() throws Exception {
File srcDir = new File(System.getProperty("test.src"));
File classesDir = new File("classes");
classesDir.mkdirs();
File javacHeaders = new File("headers.javac");
javacHeaders.mkdirs();
File javahHeaders = new File("headers.javah");
javahHeaders.mkdirs();
List<String> javacArgs = new ArrayList<String>();
javacArgs.add("-d");
javacArgs.add(classesDir.getPath());
javacArgs.add("-h");
javacArgs.add(javacHeaders.getPath());
javacArgs.add("-XDjavah:full");
for (File f: srcDir.listFiles()) {
if (f.getName().matches("TestClass[0-9]+\\.java")) {
sourceFileCount++;
javacArgs.add(f.getPath());
}
}
int rc = com.sun.tools.javac.Main.compile(javacArgs.toArray(new String[javacArgs.size()]));
if (rc != 0)
throw new Exception("javac failed; rc=" + rc);
List<String> javahArgs = new ArrayList<String>();
javahArgs.add("-d");
javahArgs.add(javahHeaders.getPath());
for (File f: classesDir.listFiles()) {
if (f.getName().endsWith(".class")) {
javahArgs.add(inferBinaryName(f));
}
}
PrintWriter pw = new PrintWriter(System.out, true);
rc = com.sun.tools.javah.Main.run(javahArgs.toArray(new String[javahArgs.size()]), pw);
if (rc != 0)
throw new Exception("javah failed; rc=" + rc);
compare(javahHeaders, javacHeaders);
int javahHeaderCount = javahHeaders.list().length;
int javacHeaderCount = javacHeaders.list().length;
System.out.println(sourceFileCount + " .java files found");
System.out.println(javacHeaderCount + " .h files generated by javac");
System.out.println(javahHeaderCount + " .h files generated by javah");
System.out.println(compareCount + " header files compared");
if (javacHeaderCount != javahHeaderCount || javacHeaderCount != compareCount)
error("inconsistent counts");
if (errors > 0)
throw new Exception(errors + " errors occurred");
}
String inferBinaryName(File file) {
String name = file.getName();
return name.substring(0, name.length() - ".class".length()).replace("$", ".");
}
/** Compare two directories.
* @param f1 The golden directory
* @param f2 The directory to be compared
*/
void compare(File f1, File f2) {
compare(f1, f2, null);
}
/** Compare two files or directories
* @param f1 The golden directory
* @param f2 The directory to be compared
* @param p An optional path identifying a file within the two directories
*/
void compare(File f1, File f2, String p) {
File f1p = (p == null ? f1 : new File(f1, p));
File f2p = (p == null ? f2 : new File(f2, p));
if (f1p.isDirectory() && f2p.isDirectory()) {
Set<String> children = new HashSet<String>();
children.addAll(Arrays.asList(f1p.list()));
children.addAll(Arrays.asList(f2p.list()));
for (String c: children) {
compare(f1, f2, new File(p, c).getPath()); // null-safe for p
}
}
else if (f1p.isFile() && f2p.isFile()) {
System.out.println("checking " + p);
compareCount++;
String s1 = read(f1p);
String s2 = read(f2p);
if (!s1.equals(s2)) {
System.out.println("File: " + f1p + "\n" + s1);
System.out.println("File: " + f2p + "\n" + s2);
error("Files differ: " + f1p + " " + f2p);
}
}
else if (f1p.exists() && !f2p.exists())
error("Only in " + f1 + ": " + p);
else if (f2p.exists() && !f1p.exists())
error("Only in " + f2 + ": " + p);
else
error("Files differ: " + f1p + " " + f2p);
}
private String read(File f) {
try {
return new String(Files.readAllBytes(f.toPath()));
} catch (IOException e) {
error("error reading " + f + ": " + e);
return "";
}
}
private void error(String msg) {
System.out.println(msg);
errors++;
}
private int errors;
private int compareCount;
private int sourceFileCount;
}

View File

@ -1,477 +0,0 @@
/*
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.List;
public class TestClass1 {
// simple types
byte b;
short s;
int i;
long l;
float f;
double d;
Object o;
String t;
List<String> g;
// constants
static final byte bc = 0;
static final short sc = 0;
static final int ic = 0;
static final long lc = 0;
static final float fc = 0;
static final double dc = 0;
static final Object oc = null;
static final String tc = "";
static final List<String> gc = null;
// simple arrays
byte[] ba;
short[] sa; // not handled corrected by javah v6
int[] ia;
long[] la;
float[] fa;
double[] da;
Object[] oa;
String[] ta;
List<String>[] ga;
// multidimensional arrays
byte[][] baa;
short[][] saa;
int[][] iaa;
long[][] laa;
float[][] faa;
double[][] daa;
Object[][] oaa;
String[][] taa;
List<String>[] gaa;
// simple Java methods
byte bm() { return 0; }
short sm() { return 0; }
int im() { return 0; }
long lm() { return 0; }
float fm() { return 0; }
double dm() { return 0; }
Object om() { return null; }
String tm() { return ""; }
List<String> gm() { return null; }
void vm() { }
byte[] bam() { return null; }
short[] sam() { return null; }
int[] iam() { return null; }
long[] lam() { return null; }
float[] fam() { return null; }
double[] dam() { return null; }
Object[] oam() { return null; }
String[] tam() { return null; }
List<String>[] gam() { return null; }
byte[][] baam() { return null; }
short[][] saam() { return null; }
int[][] iaam() { return null; }
long[][] laam() { return null; }
float[][] faam() { return null; }
double[][] daam() { return null; }
Object[][] oaam() { return null; }
String[][] taam() { return null; }
List<String>[] gaam() { return null; }
// simple native methods
native byte bmn();
native short smn();
native int imn();
native long lmn();
native float fmn();
native double dmn();
native Object omn();
native String tmn();
native List<String> gmn();
native void vmn();
native byte[] bamn();
native short[] samn();
native int[] iamn();
native long[] lamn();
native float[] famn();
native double[] damn();
native Object[] oamn();
native String[] tamn();
native List<String>[] gamn();
native byte[][] baamn();
native short[][] saamn();
native int[][] iaamn();
native long[][] laamn();
native float[][] faamn();
native double[][] daamn();
native Object[][] oaamn();
native String[][] taamn();
native List<String>[] gaamn();
// overloaded Java methods
byte bmo() { return 0; }
short smo() { return 0; }
int imo() { return 0; }
long lmo() { return 0; }
float fmo() { return 0; }
double dmo() { return 0; }
Object omo() { return null; }
String tmo() { return ""; }
List<String> gmo() { return null; }
void vmo() { }
byte bmo(int i) { return 0; }
short smo(int i) { return 0; }
int imo(int i) { return 0; }
long lmo(int i) { return 0; }
float fmo(int i) { return 0; }
double dmo(int i) { return 0; }
Object omo(int i) { return null; }
String tmo(int i) { return ""; }
List<String> gmo(int i) { return null; }
void vmo(int i) { }
// overloaded native methods
native byte bmno();
native short smno();
native int imno();
native long lmno();
native float fmno();
native double dmno();
native Object omno();
native String tmno();
native List<String> gmno();
native void vmno();
native Inner1 icmno();
native byte bmno(int i);
native short smno(int i);
native int imno(int i);
native long lmno(int i);
native float fmno(int i);
native double dmno(int i);
native Object omno(int i);
native String tmno(int i);
native List<String> gmno(int i);
native void vmno(int i);
native Inner1 icmno(Inner1 in1);
// arg types for Java methods
void mb(byte b) { }
void ms(short s) { }
void mi(int i) { }
void ml(long l) { }
void mf(float f) { }
void md(double d) { }
void mo(Object o) { }
void mt(String t) { }
void mg(List<String> g) { }
// arg types for native methods
native void mbn(byte b);
native void msn(short s);
native void min(int i);
native void mln(long l);
native void mfn(float f);
native void mdn(double d);
native void mon(Object o);
native void mtn(String t);
native void mgn(List<String> g);
static class Inner1 {
// simple types
byte b;
short s;
int i;
long l;
float f;
double d;
Object o;
String t;
List<String> g;
// constants
static final byte bc = 0;
static final short sc = 0;
static final int ic = 0;
static final long lc = 0;
static final float fc = 0;
static final double dc = 0;
static final Object oc = null;
static final String tc = "";
static final List<String> gc = null;
// simple arrays
byte[] ba;
// short[] sa; // not handled corrected by javah v6
int[] ia;
long[] la;
float[] fa;
double[] da;
Object[] oa;
String[] ta;
List<String>[] ga;
// multidimensional arrays
byte[][] baa;
short[][] saa;
int[][] iaa;
long[][] laa;
float[][] faa;
double[][] daa;
Object[][] oaa;
String[][] taa;
List<String>[] gaa;
// simple Java methods
byte bm() { return 0; }
short sm() { return 0; }
int im() { return 0; }
long lm() { return 0; }
float fm() { return 0; }
double dm() { return 0; }
Object om() { return null; }
String tm() { return ""; }
List<String> gm() { return null; }
void vm() { }
// simple native methods
native byte bmn();
native short smn();
native int imn();
native long lmn();
native float fmn();
native double dmn();
native Object omn();
native String tmn();
native List<String> gmn();
native void vmn();
// overloaded Java methods
byte bmo() { return 0; }
short smo() { return 0; }
int imo() { return 0; }
long lmo() { return 0; }
float fmo() { return 0; }
double dmo() { return 0; }
Object omo() { return null; }
String tmo() { return ""; }
List<String> gmo() { return null; }
void vmo() { }
byte bmo(int i) { return 0; }
short smo(int i) { return 0; }
int imo(int i) { return 0; }
long lmo(int i) { return 0; }
float fmo(int i) { return 0; }
double dmo(int i) { return 0; }
Object omo(int i) { return null; }
String tmo(int i) { return ""; }
List<String> gmo(int i) { return null; }
void vmo(int i) { }
// overloaded native methods
native byte bmno();
native short smno();
native int imno();
native long lmno();
native float fmno();
native double dmno();
native Object omno();
native String tmno();
native List<String> gmno();
native void vmno();
native byte bmno(int i);
native short smno(int i);
native int imno(int i);
native long lmno(int i);
native float fmno(int i);
native double dmno(int i);
native Object omno(int i);
native String tmno(int i);
native List<String> gmno(int i);
native void vmno(int i);
// arg types for Java methods
void mb(byte b) { }
void ms(short s) { }
void mi(int i) { }
void ml(long l) { }
void mf(float f) { }
void md(double d) { }
void mo(Object o) { }
void mt(String t) { }
void mg(List<String> g) { }
// arg types for native methods
native void mbn(byte b);
native void msn(short s);
native void min(int i);
native void mln(long l);
native void mfn(float f);
native void mdn(double d);
native void mon(Object o);
native void mtn(String t);
native void mgn(List<String> g);
}
class Inner2 {
// simple types
byte b;
short s;
int i;
long l;
float f;
double d;
Object o;
String t;
List<String> g;
// constants
static final byte bc = 0;
static final short sc = 0;
static final int ic = 0;
static final long lc = 0;
static final float fc = 0;
static final double dc = 0;
//static final Object oc = null;
static final String tc = "";
//static final List<String> gc = null;
// simple arrays
byte[] ba;
// short[] sa; // not handled corrected by javah v6
int[] ia;
long[] la;
float[] fa;
double[] da;
Object[] oa;
String[] ta;
List<String>[] ga;
// multidimensional arrays
byte[][] baa;
short[][] saa;
int[][] iaa;
long[][] laa;
float[][] faa;
double[][] daa;
Object[][] oaa;
String[][] taa;
List<String>[] gaa;
// simple Java methods
byte bm() { return 0; }
short sm() { return 0; }
int im() { return 0; }
long lm() { return 0; }
float fm() { return 0; }
double dm() { return 0; }
Object om() { return null; }
String tm() { return ""; }
List<String> gm() { return null; }
void vm() { }
// simple native methods
native byte bmn();
native short smn();
native int imn();
native long lmn();
native float fmn();
native double dmn();
native Object omn();
native String tmn();
native List<String> gmn();
native void vmn();
// overloaded Java methods
byte bm1() { return 0; }
short sm1() { return 0; }
int im1() { return 0; }
long lm1() { return 0; }
float fm1() { return 0; }
double dm1() { return 0; }
Object om1() { return null; }
String tm1() { return ""; }
List<String> gm1() { return null; }
void vm1() { }
byte bm2(int i) { return 0; }
short sm2(int i) { return 0; }
int im2(int i) { return 0; }
long lm2(int i) { return 0; }
float fm2(int i) { return 0; }
double dm2(int i) { return 0; }
Object om2(int i) { return null; }
String tm2(int i) { return ""; }
List<String> gm2(int i) { return null; }
void vm2(int i) { }
// overloaded native methods
native byte bmn1();
native short smn1();
native int imn1();
native long lmn1();
native float fmn1();
native double dmn1();
native Object omn1();
native String tmn1();
native List<String> gmn1();
native void vmn1();
native byte bmn2(int i);
native short smn2(int i);
native int imn2(int i);
native long lmn2(int i);
native float fmn2(int i);
native double dmn2(int i);
native Object omn2(int i);
native String tmn2(int i);
native List<String> gmn2(int i);
native void vmn2(int i);
// arg types for Java methods
void mb(byte b) { }
void ms(short s) { }
void mi(int i) { }
void ml(long l) { }
void mf(float f) { }
void md(double d) { }
void mo(Object o) { }
void mt(String t) { }
void mg(List<String> g) { }
// arg types for native methods
native void mbn(byte b);
native void msn(short s);
native void min(int i);
native void mln(long l);
native void mfn(float f);
native void mdn(double d);
native void mon(Object o);
native void mtn(String t);
native void mgn(List<String> g);
}
}

Some files were not shown because too many files have changed in this diff Show More