This commit is contained in:
Alejandro Murillo 2016-07-01 16:55:44 -07:00
commit 3fdd758961
365 changed files with 13253 additions and 13811 deletions

View File

@ -367,3 +367,4 @@ caf97b37ebec84288c112d21d3a60cb628cba1e8 jdk-9+119
7693aa00e131493ceb42b93305e2f014c9922a3b jdk-9+122
d53037a90c441cb528dc41c30827985de0e67c62 jdk-9+123
2a5697a98620c4f40e4a1a71478464399b8878de jdk-9+124
3aa52182b3ad7c5b3a61cf05a59dd07e4c5884e5 jdk-9+125

View File

@ -367,3 +367,4 @@ cae471d3b87783e0a3deea658e1e1c84b2485b6c jdk-9+121
346be2df0f5b31d423807f53a719d1b9a67f3354 jdk-9+122
405d811c0d7b9b48ff718ae6c240b732f098c028 jdk-9+123
f80c841ae2545eaf9acd2724bccc305d98cefbe2 jdk-9+124
9aa7d40f3a453f51e47f4c1b19eff5740a74a9f8 jdk-9+125

View File

@ -359,25 +359,32 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS],
# Starting amount of heap memory.
ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs_big,[$JAVA])
BOOTCYCLE_JVM_ARGS_BIG=-Xms64M
# Maximum amount of heap memory and stack size.
JVM_HEAP_LIMIT_32="1024"
# Running a 64 bit JVM allows for and requires a bigger heap
JVM_HEAP_LIMIT_64="1600"
STACK_SIZE_32=768
STACK_SIZE_64=1536
JVM_HEAP_LIMIT_GLOBAL=`expr $MEMORY_SIZE / 2`
if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_32"; then
JVM_HEAP_LIMIT_32=$JVM_HEAP_LIMIT_GLOBAL
fi
if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_64"; then
JVM_HEAP_LIMIT_64=$JVM_HEAP_LIMIT_GLOBAL
fi
if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "512"; then
JVM_HEAP_LIMIT_32=512
JVM_HEAP_LIMIT_64=512
fi
# Maximum amount of heap memory.
# Maximum stack size.
JVM_MAX_HEAP=`expr $MEMORY_SIZE / 2`
if test "x$BOOT_JDK_BITS" = "x32"; then
if test "$JVM_MAX_HEAP" -gt "1100"; then
JVM_MAX_HEAP=1100
elif test "$JVM_MAX_HEAP" -lt "512"; then
JVM_MAX_HEAP=512
fi
STACK_SIZE=768
STACK_SIZE=$STACK_SIZE_32
JVM_MAX_HEAP=$JVM_HEAP_LIMIT_32
else
# Running a 64 bit JVM allows for and requires a bigger heap
if test "$JVM_MAX_HEAP" -gt "1600"; then
JVM_MAX_HEAP=1600
elif test "$JVM_MAX_HEAP" -lt "512"; then
JVM_MAX_HEAP=512
fi
STACK_SIZE=1536
STACK_SIZE=$STACK_SIZE_64
JVM_MAX_HEAP=$JVM_HEAP_LIMIT_64
fi
ADD_JVM_ARG_IF_OK([-Xmx${JVM_MAX_HEAP}M],boot_jdk_jvmargs_big,[$JAVA])
ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs_big,[$JAVA])
@ -387,6 +394,19 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS],
JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big
AC_SUBST(JAVA_FLAGS_BIG)
if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_32
BOOTCYCLE_STACK_SIZE=$STACK_SIZE_32
else
BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_64
BOOTCYCLE_STACK_SIZE=$STACK_SIZE_64
fi
BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -Xmx${BOOTCYCLE_MAX_HEAP}M"
BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -XX:ThreadStackSize=$BOOTCYCLE_STACK_SIZE"
AC_MSG_CHECKING([flags for bootcycle boot jdk java command for big workloads])
AC_MSG_RESULT([$BOOTCYCLE_JVM_ARGS_BIG])
AC_SUBST(BOOTCYCLE_JVM_ARGS_BIG)
# By default, the main javac compilations use big
JAVA_FLAGS_JAVAC="$JAVA_FLAGS_BIG"
AC_SUBST(JAVA_FLAGS_JAVAC)

View File

@ -64,5 +64,7 @@ SJAVAC_SERVER_JAVA_CMD:=$(JAVA_CMD)
# When building a 32bit target, make sure the sjavac server flags are compatible
# with a 32bit JVM.
ifeq ($(OPENJDK_TARGET_CPU_BITS), 32)
SJAVAC_SERVER_JAVA_FLAGS:= -Xms256M -Xmx1500M
SJAVAC_SERVER_JAVA_FLAGS := @BOOTCYCLE_JVM_ARGS_BIG@
endif
# The bootcycle JVM arguments may differ from the original boot jdk.
JAVA_FLAGS_BIG := @BOOTCYCLE_JVM_ARGS_BIG@

View File

@ -367,6 +367,9 @@ AC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS],
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
AC_MSG_RESULT([no, does not work with Solaris Studio])
USE_PRECOMPILED_HEADER=0
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
AC_MSG_RESULT([no, does not work with xlc])
USE_PRECOMPILED_HEADER=0
else
AC_MSG_RESULT([yes])
fi

View File

@ -593,9 +593,9 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
fi
C_O_FLAG_NONE="-O0"
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
C_O_FLAG_HIGHEST_JVM="-O3"
C_O_FLAG_HIGHEST="-O3"
C_O_FLAG_HI="-O3 -qstrict"
C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
C_O_FLAG_HI="-O3 -qinline -qinlglue"
C_O_FLAG_NORM="-O2"
C_O_FLAG_DEBUG="-qnoopt"
# FIXME: Value below not verified.
@ -911,8 +911,8 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER],
elif test "x$OPENJDK_$1_OS" = xaix; then
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -DAIX"
# We may need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -qtune=balanced -qhot=level=1 -qinline \
-qinlglue -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -qtune=balanced \
-qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
-qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
elif test "x$OPENJDK_$1_OS" = xbsd; then
$2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"

View File

@ -644,6 +644,7 @@ SJAVAC_SERVER_JAVA
JAVA_TOOL_FLAGS_SMALL
JAVA_FLAGS_SMALL
JAVA_FLAGS_JAVAC
BOOTCYCLE_JVM_ARGS_BIG
JAVA_FLAGS_BIG
JAVA_FLAGS
TEST_JOBS
@ -5094,7 +5095,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=1467039751
DATE_WHEN_GENERATED=1467223237
###############################################################################
#
@ -49625,9 +49626,9 @@ $as_echo "$supports" >&6; }
fi
C_O_FLAG_NONE="-O0"
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
C_O_FLAG_HIGHEST_JVM="-O3"
C_O_FLAG_HIGHEST="-O3"
C_O_FLAG_HI="-O3 -qstrict"
C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
C_O_FLAG_HI="-O3 -qinline -qinlglue"
C_O_FLAG_NORM="-O2"
C_O_FLAG_DEBUG="-qnoopt"
# FIXME: Value below not verified.
@ -50634,8 +50635,8 @@ $as_echo "$supports" >&6; }
elif test "x$OPENJDK_TARGET_OS" = xaix; then
JVM_CFLAGS="$JVM_CFLAGS -DAIX"
# We may need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
JVM_CFLAGS="$JVM_CFLAGS -qtune=balanced -qhot=level=1 -qinline \
-qinlglue -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
JVM_CFLAGS="$JVM_CFLAGS -qtune=balanced \
-qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
-qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
elif test "x$OPENJDK_TARGET_OS" = xbsd; then
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
@ -51439,8 +51440,8 @@ $as_echo "$supports" >&6; }
elif test "x$OPENJDK_BUILD_OS" = xaix; then
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -DAIX"
# We may need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -qtune=balanced -qhot=level=1 -qinline \
-qinlglue -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -qtune=balanced \
-qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
-qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
elif test "x$OPENJDK_BUILD_OS" = xbsd; then
OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
@ -53468,7 +53469,7 @@ $as_echo "yes, forced" >&6; }
$as_echo "no, forced" >&6; }
BUILD_GTEST="false"
elif test "x$enable_hotspot_gtest" = "x"; then
if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
if test "x$GTEST_DIR_EXISTS" = "xtrue" && test "x$OPENJDK_TARGET_OS" != "xaix"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
BUILD_GTEST="true"
@ -64612,12 +64613,16 @@ fi
if test "$OPENJDK_TARGET_OS" = "solaris"; then
if test "$OPENJDK_TARGET_OS" = "solaris" && test "x$BUILD_GTEST" = "xtrue"; then
# Find the root of the Solaris Studio installation from the compiler path
SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libstlport.so.1" >&5
$as_echo_n "checking for libstlport.so.1... " >&6; }
if ! test -f "$STLPORT_LIB" && test "x$OPENJDK_TARGET_CPU_ISADIR" = "x/sparcv9"; then
# SS12u3 has libstlport under 'stlport4/v9' instead of 'stlport4/sparcv9'
STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4/v9/libstlport.so.1"
fi
if test -f "$STLPORT_LIB"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, $STLPORT_LIB" >&5
$as_echo "yes, $STLPORT_LIB" >&6; }
@ -65118,25 +65123,32 @@ $as_echo_n "checking flags for boot jdk java command for big workloads... " >&6;
JVM_ARG_OK=false
fi
BOOTCYCLE_JVM_ARGS_BIG=-Xms64M
# Maximum amount of heap memory and stack size.
JVM_HEAP_LIMIT_32="1024"
# Running a 64 bit JVM allows for and requires a bigger heap
JVM_HEAP_LIMIT_64="1600"
STACK_SIZE_32=768
STACK_SIZE_64=1536
JVM_HEAP_LIMIT_GLOBAL=`expr $MEMORY_SIZE / 2`
if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_32"; then
JVM_HEAP_LIMIT_32=$JVM_HEAP_LIMIT_GLOBAL
fi
if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_64"; then
JVM_HEAP_LIMIT_64=$JVM_HEAP_LIMIT_GLOBAL
fi
if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "512"; then
JVM_HEAP_LIMIT_32=512
JVM_HEAP_LIMIT_64=512
fi
# Maximum amount of heap memory.
# Maximum stack size.
JVM_MAX_HEAP=`expr $MEMORY_SIZE / 2`
if test "x$BOOT_JDK_BITS" = "x32"; then
if test "$JVM_MAX_HEAP" -gt "1100"; then
JVM_MAX_HEAP=1100
elif test "$JVM_MAX_HEAP" -lt "512"; then
JVM_MAX_HEAP=512
fi
STACK_SIZE=768
STACK_SIZE=$STACK_SIZE_32
JVM_MAX_HEAP=$JVM_HEAP_LIMIT_32
else
# Running a 64 bit JVM allows for and requires a bigger heap
if test "$JVM_MAX_HEAP" -gt "1600"; then
JVM_MAX_HEAP=1600
elif test "$JVM_MAX_HEAP" -lt "512"; then
JVM_MAX_HEAP=512
fi
STACK_SIZE=1536
STACK_SIZE=$STACK_SIZE_64
JVM_MAX_HEAP=$JVM_HEAP_LIMIT_64
fi
$ECHO "Check if jvm arg is ok: -Xmx${JVM_MAX_HEAP}M" >&5
@ -65175,6 +65187,21 @@ $as_echo "$boot_jdk_jvmargs_big" >&6; }
JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big
if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_32
BOOTCYCLE_STACK_SIZE=$STACK_SIZE_32
else
BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_64
BOOTCYCLE_STACK_SIZE=$STACK_SIZE_64
fi
BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -Xmx${BOOTCYCLE_MAX_HEAP}M"
BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -XX:ThreadStackSize=$BOOTCYCLE_STACK_SIZE"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for bootcycle boot jdk java command for big workloads" >&5
$as_echo_n "checking flags for bootcycle boot jdk java command for big workloads... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOTCYCLE_JVM_ARGS_BIG" >&5
$as_echo "$BOOTCYCLE_JVM_ARGS_BIG" >&6; }
# By default, the main javac compilations use big
JAVA_FLAGS_JAVAC="$JAVA_FLAGS_BIG"
@ -66132,6 +66159,10 @@ $as_echo "no, does not work effectively with icecc" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no, does not work with Solaris Studio" >&5
$as_echo "no, does not work with Solaris Studio" >&6; }
USE_PRECOMPILED_HEADER=0
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no, does not work with xlc" >&5
$as_echo "no, does not work with xlc" >&6; }
USE_PRECOMPILED_HEADER=0
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }

View File

@ -333,7 +333,7 @@ AC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_GTEST],
AC_MSG_RESULT([no, forced])
BUILD_GTEST="false"
elif test "x$enable_hotspot_gtest" = "x"; then
if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
if test "x$GTEST_DIR_EXISTS" = "xtrue" && test "x$OPENJDK_TARGET_OS" != "xaix"; then
AC_MSG_RESULT([yes])
BUILD_GTEST="true"
else

View File

@ -197,11 +197,15 @@ AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
################################################################################
AC_DEFUN_ONCE([LIB_SETUP_SOLARIS_STLPORT],
[
if test "$OPENJDK_TARGET_OS" = "solaris"; then
if test "$OPENJDK_TARGET_OS" = "solaris" && test "x$BUILD_GTEST" = "xtrue"; then
# Find the root of the Solaris Studio installation from the compiler path
SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
AC_MSG_CHECKING([for libstlport.so.1])
if ! test -f "$STLPORT_LIB" && test "x$OPENJDK_TARGET_CPU_ISADIR" = "x/sparcv9"; then
# SS12u3 has libstlport under 'stlport4/v9' instead of 'stlport4/sparcv9'
STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4/v9/libstlport.so.1"
fi
if test -f "$STLPORT_LIB"; then
AC_MSG_RESULT([yes, $STLPORT_LIB])
BASIC_FIXUP_PATH([STLPORT_LIB])

View File

@ -578,7 +578,7 @@ SJAVAC_SERVER_JAVA=@FIXPATH@ @FIXPATH_DETACH_FLAG@ $(SJAVAC_SERVER_JAVA_CMD) \
JAVAC_FLAGS?=@JAVAC_FLAGS@
BUILD_JAVA_FLAGS:=-Xms64M -Xmx1100M
BUILD_JAVA_FLAGS := @BOOTCYCLE_JVM_ARGS_BIG@
BUILD_JAVA=@FIXPATH@ $(BUILD_JDK)/bin/java $(BUILD_JAVA_FLAGS)
# Use ?= as this can be overridden from bootcycle-spec.gmk

View File

@ -102,10 +102,13 @@ diff_text() {
# Ignore date strings in class files.
# Anonymous lambda classes get randomly assigned counters in their names.
if test "x$SUFFIX" = "xclass"; then
if [ "$NAME" = "module-info.class" ] || [ "$NAME" = "SystemModules.class" ]
then
# The SystemModules.class and module-info.class have several issues
# with random ordering of elements in HashSets.
if [ "$NAME" = "SystemModules.class" ]; then
# The SystemModules.class is not comparable. The way it is generated is
# too random. It can even be of different size for no apparent reason.
TMP=""
elif [ "$NAME" = "module-info.class" ]; then
# The module-info.class have several issues with random ordering of
# elements in HashSets.
MODULES_CLASS_FILTER="$SED \
-e 's/,$//' \
-e 's/;$//' \
@ -369,6 +372,14 @@ compare_general_files() {
$CAT $OTHER_DIR/$f | eval "$HTML_FILTER" > $OTHER_FILE &
$CAT $THIS_DIR/$f | eval "$HTML_FILTER" > $THIS_FILE &
wait
elif [ "$f" = "./lib/classlist" ]; then
# The classlist files may have some lines in random order
OTHER_FILE=$WORK_DIR/$f.other
THIS_FILE=$WORK_DIR/$f.this
$MKDIR -p $(dirname $OTHER_FILE) $(dirname $THIS_FILE)
$RM $OTHER_FILE $THIS_FILE
$CAT $OTHER_DIR/$f | $SORT > $OTHER_FILE
$CAT $THIS_DIR/$f | $SORT > $THIS_FILE
else
OTHER_FILE=$OTHER_DIR/$f
THIS_FILE=$THIS_DIR/$f
@ -651,7 +662,7 @@ compare_bin_file() {
OTHER_DIZ_FILE=${OTHER_FILE_BASE}.diz
else
# Some files, jli.dll, appears twice in the image but only one of
# thme has a diz file next to it.
# them has a diz file next to it.
OTHER_DIZ_FILE="$($FIND $OTHER_DIR -name $DIZ_NAME | $SED 1q)"
if [ ! -f "$OTHER_DIZ_FILE" ]; then
# As a last resort, look for diz file in the whole build output
@ -1335,6 +1346,24 @@ if [ "$SKIP_DEFAULT" != "true" ]; then
OTHER_JDK="$OTHER/images/jdk"
OTHER_JRE="$OTHER/images/jre"
echo "Selecting jdk images for compare"
elif [ -d "$(ls -d $THIS/licensee-src/build/*/images/jdk)" ] \
&& [ -d "$(ls -d $OTHER/licensee-src/build/*/images/jdk)" ]
then
echo "Selecting licensee images for compare"
# Simply override the THIS and OTHER dir with the build dir from
# the nested licensee source build for the rest of the script
# execution.
OLD_THIS="$THIS"
OLD_OTHER="$OTHER"
THIS="$(ls -d $THIS/licensee-src/build/*)"
OTHER="$(ls -d $OTHER/licensee-src/build/*)"
THIS_JDK="$THIS/images/jdk"
THIS_JRE="$THIS/images/jre"
OTHER_JDK="$OTHER/images/jdk"
OTHER_JRE="$OTHER/images/jre"
# Rewrite the path to tools that are used from the build
JIMAGE="$(echo "$JIMAGE" | $SED "s|$OLD_THIS|$THIS|g")"
JAVAP="$(echo "$JAVAP" | $SED "s|$OLD_THIS|$THIS|g")"
else
echo "No common images found."
exit 1

View File

@ -254,7 +254,7 @@ var getJibProfilesProfiles = function (input, common) {
build_cpu: "x64",
dependencies: concat(common.dependencies, "devkit"),
configure_args: concat(common.configure_args, common.configure_args_32bit,
"--with-jvm-variants=minimal,client,server", "--with-zlib=system"),
"--with-jvm-variants=minimal,server", "--with-zlib=system"),
default_make_targets: common.default_make_targets
},
@ -295,8 +295,7 @@ var getJibProfilesProfiles = function (input, common) {
target_cpu: "x86",
build_cpu: "x64",
dependencies: concat(common.dependencies, "devkit", "freetype"),
configure_args: concat(common.configure_args,
"--with-jvm-variants=client,server", common.configure_args_32bit),
configure_args: concat(common.configure_args, common.configure_args_32bit),
default_make_targets: common.default_make_targets
}
};

View File

@ -367,3 +367,4 @@ daf533920b1266603b5cbdab31908d2a931c5361 jdk-9+119
a39131aafc51a6fd8836e6ebe1b04458702ce7d6 jdk-9+122
e33a34cc551907617d8129c4faaf1a5a7e61d21c jdk-9+123
45121d5afb9d5bfadab75378572ad96832e0809e jdk-9+124
1d48e67d1b91eb9f72e49e69a4021edb85e357fc jdk-9+125

View File

@ -527,3 +527,4 @@ b64432bae5271735fd53300b2005b713e98ef411 jdk-9+114
af6b4ad908e732d23021f12e8322b204433d5cf6 jdk-9+122
75f81e1fecfb444f34f357295fe06af60e2762d9 jdk-9+123
479631362b4930be985245ea063d87d821a472eb jdk-9+124
bb640b49741af3f57f9994129934c46fc173219f jdk-9+125

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015 SAP SE. All rights reserved.
* Copyright (c) 2012, 2016 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -22,17 +22,49 @@
*
*/
// This is only a stub. Will flesh out later when/if we add further support
// for PASE.
#include "libo4.hpp"
bool libo4::init() { return false; }
void libo4::cleanup() {}
bool libo4::get_memory_info (unsigned long long* p_virt_total, unsigned long long* p_real_total,
unsigned long long* p_real_free, unsigned long long* p_pgsp_total, unsigned long long* p_pgsp_free) {
// global variables
// whether initialization worked
static bool g_initialized = false;
//////////////////////////
// class libo4 - impl //
//////////////////////////
bool libo4::init() {
if (g_initialized) {
return true;
}
return false;
}
bool libo4::get_load_avg (double* p_avg1, double* p_avg5, double* p_avg15) { return false; }
bool libo4::realpath (const char* file_name, char* resolved_name, int resolved_name_len) { return false; }
void libo4::cleanup() {
if (g_initialized) {
g_initialized = false;
}
}
bool libo4::get_memory_info(unsigned long long* p_virt_total,
unsigned long long* p_real_total,
unsigned long long* p_real_free,
unsigned long long* p_pgsp_total,
unsigned long long* p_pgsp_free) {
return false;
}
bool libo4::get_load_avg(double* p_avg1, double* p_avg5, double* p_avg15) {
return false;
}
bool libo4::realpath(const char* file_name, char* resolved_name,
int resolved_name_len) {
return false;
}
bool libo4::removeEscapeMessageFromJoblogByContext(const void* context) {
// Note: no tracing here! We run in signal handling context
return false;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015 SAP SE. All rights reserved.
* Copyright (c) 2012, 2016 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -22,56 +22,69 @@
*
*/
// A C++ wrapper around the libo4 porting library. The libo4 porting library
// is a set of bridge functions into native AS/400 functionality.
// Class libo4 is a C++ wrapper around the libo4 porting library. It handles
// basic stuff like dynamic loading, library initialization etc.
// The libo4 porting library is a set of functions that bridge from the AIX
// runtime environment on OS/400 (aka PASE layer) into native OS/400
// functionality (aka ILE layer) to close some functional gaps that exist in
// the PASE layer.
#ifndef OS_AIX_VM_LIBO4_HPP
#define OS_AIX_VM_LIBO4_HPP
class libo4 {
public:
// Initialize the libo4 porting library.
// Returns true if succeeded, false if error.
static bool init();
// cleanup of the libo4 porting library.
// Triggers cleanup of the libo4 porting library.
static void cleanup();
// returns a number of memory statistics from the
// AS/400.
// Returns a number of memory statistics from OS/400.
//
// See libo4.h for details on this API.
//
// Specify NULL for numbers you are not interested in.
//
// returns false if an error happened. Activate OsMisc trace for
// Returns false if an error happened. Activate OsMisc trace for
// trace output.
//
static bool get_memory_info (unsigned long long* p_virt_total, unsigned long long* p_real_total,
unsigned long long* p_real_free, unsigned long long* p_pgsp_total, unsigned long long* p_pgsp_free);
static bool get_memory_info(unsigned long long* p_virt_total,
unsigned long long* p_real_total,
unsigned long long* p_real_free,
unsigned long long* p_pgsp_total,
unsigned long long* p_pgsp_free);
// returns information about system load
// Returns information about system load
// (similar to "loadavg()" under other Unices)
//
// Specify NULL for numbers you are not interested in.
//
// returns false if an error happened. Activate OsMisc trace for
// trace output.
//
static bool get_load_avg (double* p_avg1, double* p_avg5, double* p_avg15);
// this is a replacement for the "realpath()" API which does not really work
// on PASE
// See libo4.h for details on this API.
//
// Specify NULL for numbers you are not interested in.
//
// returns false if an error happened. Activate OsMisc trace for
// Returns false if an error happened. Activate OsMisc trace for
// trace output.
//
static bool realpath (const char* file_name,
char* resolved_name, int resolved_name_len);
static bool get_load_avg(double* p_avg1, double* p_avg5, double* p_avg15);
// This is a replacement for the "realpath()" API which does not really work
// in PASE together with the (case insensitive but case preserving)
// filesystem on OS/400.
//
// See libo4.h for details on this API.
//
// Returns false if an error happened. Activate OsMisc trace for
// trace output.
//
static bool realpath(const char* file_name, char* resolved_name,
int resolved_name_len);
// Call libo4_RemoveEscapeMessageFromJoblogByContext API to remove messages
// from the OS/400 job log.
//
// See libo4.h for details on this API.
static bool removeEscapeMessageFromJoblogByContext(const void* context);
};
#endif // OS_AIX_VM_LIBO4_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015 SAP SE. All rights reserved.
* Copyright (c) 2012, 2016 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -180,10 +180,12 @@ bool libperfstat::get_cpuinfo(cpuinfo_t* pci) {
memset (&psct, '\0', sizeof(psct));
if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(PERFSTAT_CPU_TOTAL_T_LATEST), 1)) {
if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t_61), 1)) {
if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t_53), 1)) {
if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t_71), 1)) {
if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t_61), 1)) {
if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t_53), 1)) {
trcVerbose("perfstat_cpu_total() failed (errno=%d)", errno);
return false;
}
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013 SAP SE. All rights reserved.
* Copyright (c) 2012, 2016 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -337,10 +337,109 @@ typedef struct { /* global cpu information AIX 7.1 */
int spurrflag; /* set if running in spurr mode */
u_longlong_t version; /* version number (1, 2, etc.,) */
/* >>>>> END OF STRUCTURE DEFINITION <<<<< */
#define CURR_VERSION_CPU_TOTAL 1 /* Incremented by one for every new release *
/* #define CURR_VERSION_CPU_TOTAL 1 Incremented by one for every new release *
* of perfstat_cpu_total_t data structure */
} perfstat_cpu_total_t_71;
typedef struct { /* global cpu information AIX 7.2 / 6.1 TL6 (see oslevel -r) */
int ncpus; /* number of active logical processors */
int ncpus_cfg; /* number of configured processors */
char description[IDENTIFIER_LENGTH]; /* processor description (type/official name) */
u_longlong_t processorHZ; /* processor speed in Hz */
u_longlong_t user; /* raw total number of clock ticks spent in user mode */
u_longlong_t sys; /* raw total number of clock ticks spent in system mode */
u_longlong_t idle; /* raw total number of clock ticks spent idle */
u_longlong_t wait; /* raw total number of clock ticks spent waiting for I/O */
u_longlong_t pswitch; /* number of process switches (change in currently running process) */
u_longlong_t syscall; /* number of system calls executed */
u_longlong_t sysread; /* number of read system calls executed */
u_longlong_t syswrite; /* number of write system calls executed */
u_longlong_t sysfork; /* number of forks system calls executed */
u_longlong_t sysexec; /* number of execs system calls executed */
u_longlong_t readch; /* number of characters tranferred with read system call */
u_longlong_t writech; /* number of characters tranferred with write system call */
u_longlong_t devintrs; /* number of device interrupts */
u_longlong_t softintrs; /* number of software interrupts */
time_t lbolt; /* number of ticks since last reboot */
u_longlong_t loadavg[3]; /* (1<<SBITS) times the average number of runnables processes during the last 1, 5 and 15 minutes. */
/* To calculate the load average, divide the numbers by (1<<SBITS). SBITS is defined in <sys/proc.h>. */
u_longlong_t runque; /* length of the run queue (processes ready) */
u_longlong_t swpque; /* ength of the swap queue (processes waiting to be paged in) */
u_longlong_t bread; /* number of blocks read */
u_longlong_t bwrite; /* number of blocks written */
u_longlong_t lread; /* number of logical read requests */
u_longlong_t lwrite; /* number of logical write requests */
u_longlong_t phread; /* number of physical reads (reads on raw devices) */
u_longlong_t phwrite; /* number of physical writes (writes on raw devices) */
u_longlong_t runocc; /* updated whenever runque is updated, i.e. the runqueue is occupied.
* This can be used to compute the simple average of ready processes */
u_longlong_t swpocc; /* updated whenever swpque is updated. i.e. the swpqueue is occupied.
* This can be used to compute the simple average processes waiting to be paged in */
u_longlong_t iget; /* number of inode lookups */
u_longlong_t namei; /* number of vnode lookup from a path name */
u_longlong_t dirblk; /* number of 512-byte block reads by the directory search routine to locate an entry for a file */
u_longlong_t msg; /* number of IPC message operations */
u_longlong_t sema; /* number of IPC semaphore operations */
u_longlong_t rcvint; /* number of tty receive interrupts */
u_longlong_t xmtint; /* number of tyy transmit interrupts */
u_longlong_t mdmint; /* number of modem interrupts */
u_longlong_t tty_rawinch; /* number of raw input characters */
u_longlong_t tty_caninch; /* number of canonical input characters (always zero) */
u_longlong_t tty_rawoutch;/* number of raw output characters */
u_longlong_t ksched; /* number of kernel processes created */
u_longlong_t koverf; /* kernel process creation attempts where:
* -the user has forked to their maximum limit
* -the configuration limit of processes has been reached */
u_longlong_t kexit; /* number of kernel processes that became zombies */
u_longlong_t rbread; /* number of remote read requests */
u_longlong_t rcread; /* number of cached remote reads */
u_longlong_t rbwrt; /* number of remote writes */
u_longlong_t rcwrt; /* number of cached remote writes */
u_longlong_t traps; /* number of traps */
int ncpus_high; /* index of highest processor online */
u_longlong_t puser; /* raw number of physical processor tics in user mode */
u_longlong_t psys; /* raw number of physical processor tics in system mode */
u_longlong_t pidle; /* raw number of physical processor tics idle */
u_longlong_t pwait; /* raw number of physical processor tics waiting for I/O */
u_longlong_t decrintrs; /* number of decrementer tics interrupts */
u_longlong_t mpcrintrs; /* number of mpc's received interrupts */
u_longlong_t mpcsintrs; /* number of mpc's sent interrupts */
u_longlong_t phantintrs; /* number of phantom interrupts */
u_longlong_t idle_donated_purr; /* number of idle cycles donated by a dedicated partition enabled for donation */
u_longlong_t idle_donated_spurr;/* number of idle spurr cycles donated by a dedicated partition enabled for donation */
u_longlong_t busy_donated_purr; /* number of busy cycles donated by a dedicated partition enabled for donation */
u_longlong_t busy_donated_spurr;/* number of busy spurr cycles donated by a dedicated partition enabled for donation */
u_longlong_t idle_stolen_purr; /* number of idle cycles stolen by the hypervisor from a dedicated partition */
u_longlong_t idle_stolen_spurr; /* number of idle spurr cycles stolen by the hypervisor from a dedicated partition */
u_longlong_t busy_stolen_purr; /* number of busy cycles stolen by the hypervisor from a dedicated partition */
u_longlong_t busy_stolen_spurr; /* number of busy spurr cycles stolen by the hypervisor from a dedicated partition */
short iowait; /* number of processes that are asleep waiting for buffered I/O */
short physio; /* number of processes waiting for raw I/O */
longlong_t twait; /* number of threads that are waiting for filesystem direct(cio) */
u_longlong_t hpi; /* number of hypervisor page-ins */
u_longlong_t hpit; /* Time spent in hypervisor page-ins (in nanoseconds) */
u_longlong_t puser_spurr; /* number of spurr cycles spent in user mode */
u_longlong_t psys_spurr; /* number of spurr cycles spent in kernel mode */
u_longlong_t pidle_spurr; /* number of spurr cycles spent in idle mode */
u_longlong_t pwait_spurr; /* number of spurr cycles spent in wait mode */
int spurrflag; /* set if running in spurr mode */
u_longlong_t version; /* version number (1, 2, etc.,) */
u_longlong_t tb_last; /*time base counter */
u_longlong_t purr_coalescing; /* If the calling partition is
* authorized to see pool wide statistics then
* PURR cycles consumed to coalesce data
* else set to zero.*/
u_longlong_t spurr_coalescing; /* If the calling partition is
* authorized to see pool wide statistics then
* SPURR cycles consumed to coalesce data
* else set to zero.*/
/* >>>>> END OF STRUCTURE DEFINITION <<<<< */
#define CURR_VERSION_CPU_TOTAL 2 /* Incremented by one for every new release *
* of perfstat_cpu_total_t data structure */
} perfstat_cpu_total_t_72;
typedef union {
uint w;
struct {
@ -756,7 +855,7 @@ typedef struct { /* WPAR identifier */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define PERFSTAT_PARTITON_TOTAL_T_LATEST perfstat_partition_total_t_71_1/* latest perfstat_partition_total_t structure */
#define PERFSTAT_CPU_TOTAL_T_LATEST perfstat_cpu_total_t_71 /* latest perfstat_cpu_total_t structure */
#define PERFSTAT_CPU_TOTAL_T_LATEST perfstat_cpu_total_t_72 /* latest perfstat_cpu_total_t structure */
#define PERFSTAT_WPAR_TOTAL_T_LATEST perfstat_wpar_total_t_71 /* latest perfstat_wpar_total_t structure */
class libperfstat {

View File

@ -367,3 +367,4 @@ a265b8116058c56179c321c38618570b780329be jdk-9+121
f8899b1884e2c4a000dbcc5b1a80954245fe462e jdk-9+122
3c19ab8742c196ac267b3d87e1d19ec3472c708d jdk-9+123
e04a15153cc293f05fcd60bc98236f50e16af46a jdk-9+124
493eb91ec32a6dea7604cfbd86c10045ad9af15b jdk-9+125

View File

@ -1,6 +1,6 @@
###########################################################################
#
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 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
@ -23,11 +23,8 @@
#
###########################################################################
# 8147431
javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh generic-all
javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh 8147431 generic-all
# 8150145
javax/xml/jaxp/unittest/common/TransformationWarningsTest.java generic-all
javax/xml/jaxp/unittest/common/TransformationWarningsTest.java 8150145 generic-all
# 8156508
javax/xml/jaxp/unittest/stream/FactoryFindTest.java generic-all
javax/xml/jaxp/unittest/stream/FactoryFindTest.java 8156508 generic-all

View File

@ -370,3 +370,4 @@ fb771fa3a986ccfcb00d743b1956b98c380d1dd8 jdk-9+121
342705d785ffd9e999991a3d4baae2eca58ea7c3 jdk-9+122
c42decd28bbfa817347112ed6053b5fbd30517a2 jdk-9+123
1600da1665cd2cc127014e8c002b328ec33a9147 jdk-9+124
5b0570e3db29f6b8c80a4beac70d51284507b203 jdk-9+125

View File

@ -367,3 +367,4 @@ ee29aaab5889555ea56e4c0ed690aabb7613529d jdk-9+121
981ae344923f09c46d8d1d5a3ed9fa71deafe0c6 jdk-9+122
c40c8739bcdc88892ff58ebee3fd8a3f287be94d jdk-9+123
7ff61c55b5c6c124592f09b18953222009a204a6 jdk-9+124
073ab1d4edf5590cf1af7b6d819350c14e425c1a jdk-9+125

View File

@ -34,7 +34,11 @@ $(eval $(call SetupTextFileProcessing, BUILD_VERSION_JAVA, \
@@LAUNCHER_NAME@@ => $(LAUNCHER_NAME) ; \
@@RUNTIME_NAME@@ => $(RUNTIME_NAME) ; \
@@VERSION_SHORT@@ => $(VERSION_SHORT) ; \
@@VERSION_STRING@@ => $(VERSION_STRING), \
@@VERSION_STRING@@ => $(VERSION_STRING) ; \
@@VERSION_NUMBER@@ => $(VERSION_NUMBER) ; \
@@VERSION_PRE@@ => $(VERSION_PRE) ; \
@@VERSION_BUILD@@ => $(VERSION_BUILD) ; \
@@VERSION_OPT@@ => $(VERSION_OPT), \
))
GENSRC_JAVA_BASE += $(BUILD_VERSION_JAVA)

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 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
@ -46,9 +46,6 @@ endif
ifeq ($(OPENJDK_TARGET_OS), macosx)
BUILD_LIBNIO_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
BUILD_LIBNIO_EXFILES += \
GioFileTypeDetector.c \
#
endif
ifeq ($(OPENJDK_TARGET_OS), solaris)

View File

@ -56,6 +56,7 @@ SUNWprivate_1.1 {
JNU_ThrowArrayIndexOutOfBoundsException;
JNU_ThrowByName;
JNU_ThrowByNameWithLastError;
JNU_ThrowByNameWithMessageAndLastError;
JNU_ThrowClassNotFoundException;
JNU_ThrowIllegalAccessError;
JNU_ThrowIllegalAccessException;

View File

@ -131,8 +131,6 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_SolarisEventPort_port_1get;
Java_sun_nio_ch_SolarisEventPort_port_1getn;
Java_sun_nio_ch_SolarisEventPort_port_1send;
Java_sun_nio_fs_GioFileTypeDetector_initializeGio;
Java_sun_nio_fs_GioFileTypeDetector_probeGio;
Java_sun_nio_fs_UnixNativeDispatcher_init;
Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
Java_sun_nio_fs_UnixNativeDispatcher_strerror;

View File

@ -182,7 +182,17 @@ void setOSNameAndVersion(java_props_t *sprops) {
// Copy out the char*
osVersionCStr = strdup([nsVerStr UTF8String]);
}
// Fallback if running on pre-10.9 Mac OS
if (osVersionCStr == NULL) {
NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile :
@"/System/Library/CoreServices/SystemVersion.plist"];
if (version != NULL) {
NSString *nsVerStr = [version objectForKey : @"ProductVersion"];
if (nsVerStr != NULL) {
osVersionCStr = strdup([nsVerStr UTF8String]);
}
}
}
if (osVersionCStr == NULL) {
osVersionCStr = strdup("Unknown");
}
@ -190,7 +200,9 @@ void setOSNameAndVersion(java_props_t *sprops) {
}
static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey, CFStringRef inHostKey, CFStringRef inPortKey, CFStringRef *outProxyHost, int *ioProxyPort) {
static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey,
CFStringRef inHostKey, CFStringRef inPortKey,
CFStringRef *outProxyHost, int *ioProxyPort) {
/* See if the proxy is enabled. */
CFNumberRef cf_enabled = CFDictionaryGetValue(inDict, inEnabledKey);
if (cf_enabled == NULL) {

View File

@ -27,8 +27,6 @@ package java.lang;
import java.io.*;
import java.math.BigInteger;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -36,11 +34,9 @@ import java.util.stream.Collectors;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.RandomAccess;
import java.util.StringTokenizer;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
import sun.security.action.GetPropertyAction;
/**
* Every Java application has a single instance of class
@ -941,8 +937,9 @@ public class Runtime {
*/
public static Version version() {
if (version == null) {
version = Version.parse(
GetPropertyAction.privilegedGetProperty("java.runtime.version"));
version = new Version(VersionProps.versionNumbers(),
VersionProps.pre(), VersionProps.build(),
VersionProps.optional());
}
return version;
}
@ -1084,86 +1081,12 @@ public class Runtime {
private final Optional<Integer> build;
private final Optional<String> optional;
// $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)?
// RE limits the format of version strings
// ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))?
private static final String VNUM
= "(?<VNUM>[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)";
private static final String VNUM_GROUP = "VNUM";
private static final String PRE = "(?:-(?<PRE>[a-zA-Z0-9]+))?";
private static final String PRE_GROUP = "PRE";
private static final String BUILD
= "(?:(?<PLUS>\\+)(?<BUILD>0|[1-9][0-9]*)?)?";
private static final String PLUS_GROUP = "PLUS";
private static final String BUILD_GROUP = "BUILD";
private static final String OPT = "(?:-(?<OPT>[-a-zA-Z0-9.]+))?";
private static final String OPT_GROUP = "OPT";
private static final String VSTR_FORMAT
= "^" + VNUM + PRE + BUILD + OPT + "$";
private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
/**
* Constructs a valid <a href="verStr">version string</a> containing
* a <a href="#verNum">version number</a> followed by pre-release and
* build information.
*
* @param s
* A string to be interpreted as a version
*
* @throws IllegalArgumentException
* If the given string cannot be interpreted as a valid
* version
*
* @throws NullPointerException
* If {@code s} is {@code null}
*
* @throws NumberFormatException
* If an element of the version number or the build number
* cannot be represented as an {@link Integer}
*/
private Version(String s) {
if (s == null)
throw new NullPointerException();
Matcher m = VSTR_PATTERN.matcher(s);
if (!m.matches())
throw new IllegalArgumentException("Invalid version string: '"
+ s + "'");
// $VNUM is a dot-separated list of integers of arbitrary length
List<Integer> list = new ArrayList<>();
for (String i : m.group(VNUM_GROUP).split("\\."))
list.add(Integer.parseInt(i));
version = Collections.unmodifiableList(list);
pre = Optional.ofNullable(m.group(PRE_GROUP));
String b = m.group(BUILD_GROUP);
// $BUILD is an integer
build = (b == null)
? Optional.<Integer>empty()
: Optional.ofNullable(Integer.parseInt(b));
optional = Optional.ofNullable(m.group(OPT_GROUP));
// empty '+'
if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
if (optional.isPresent()) {
if (pre.isPresent())
throw new IllegalArgumentException("'+' found with"
+ " pre-release and optional components:'" + s
+ "'");
} else {
throw new IllegalArgumentException("'+' found with neither"
+ " build or optional components: '" + s + "'");
}
}
Version(List<Integer> version, Optional<String> pre,
Optional<Integer> build, Optional<String> optional) {
this.version = Collections.unmodifiableList(version);
this.pre = pre;
this.build = build;
this.optional = optional;
}
/**
@ -1189,7 +1112,7 @@ public class Runtime {
* @return The Version of the given string
*/
public static Version parse(String s) {
return new Version(s);
return VersionBuilder.parse(s);
}
/**
@ -1518,4 +1441,86 @@ public class Runtime {
}
}
private static class VersionBuilder {
// $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)?
// RE limits the format of version strings
// ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))?
private static final String VNUM
= "(?<VNUM>[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)";
private static final String VNUM_GROUP = "VNUM";
private static final String PRE = "(?:-(?<PRE>[a-zA-Z0-9]+))?";
private static final String PRE_GROUP = "PRE";
private static final String BUILD
= "(?:(?<PLUS>\\+)(?<BUILD>0|[1-9][0-9]*)?)?";
private static final String PLUS_GROUP = "PLUS";
private static final String BUILD_GROUP = "BUILD";
private static final String OPT = "(?:-(?<OPT>[-a-zA-Z0-9.]+))?";
private static final String OPT_GROUP = "OPT";
private static final String VSTR_FORMAT
= "^" + VNUM + PRE + BUILD + OPT + "$";
private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
/**
* Constructs a valid <a href="verStr">version string</a> containing
* a <a href="#verNum">version number</a> followed by pre-release and
* build information.
*
* @param s
* A string to be interpreted as a version
*
* @throws IllegalArgumentException
* If the given string cannot be interpreted as a valid
* version
*
* @throws NullPointerException
* If {@code s} is {@code null}
*
* @throws NumberFormatException
* If an element of the version number or the build number
* cannot be represented as an {@link Integer}
*/
static Version parse(String s) {
if (s == null)
throw new NullPointerException();
Matcher m = VSTR_PATTERN.matcher(s);
if (!m.matches())
throw new IllegalArgumentException("Invalid version string: '"
+ s + "'");
// $VNUM is a dot-separated list of integers of arbitrary length
List<Integer> version = new ArrayList<>();
for (String i : m.group(VNUM_GROUP).split("\\."))
version.add(Integer.parseInt(i));
Optional<String> pre = Optional.ofNullable(m.group(PRE_GROUP));
String b = m.group(BUILD_GROUP);
// $BUILD is an integer
Optional<Integer> build = (b == null)
? Optional.empty()
: Optional.of(Integer.parseInt(b));
Optional<String> optional = Optional.ofNullable(m.group(OPT_GROUP));
// empty '+'
if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
if (optional.isPresent()) {
if (pre.isPresent())
throw new IllegalArgumentException("'+' found with"
+ " pre-release and optional components:'" + s
+ "'");
} else {
throw new IllegalArgumentException("'+' found with neither"
+ " build or optional components: '" + s + "'");
}
}
return new Version(version, pre, build, optional);
}
}
}

View File

@ -137,8 +137,8 @@ final class StringLatin1 {
char c1 = (char) CharacterDataLatin1.instance.toUpperCase(getChar(value, k));
char c2 = (char) CharacterDataLatin1.instance.toUpperCase(getChar(other, k));
if (c1 != c2) {
c1 = (char) CharacterDataLatin1.instance.toLowerCase(c1);
c2 = (char) CharacterDataLatin1.instance.toLowerCase(c2);
c1 = Character.toLowerCase(c1);
c2 = Character.toLowerCase(c2);
if (c1 != c2) {
return c1 - c2;
}

View File

@ -26,6 +26,9 @@
package java.lang;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
class VersionProps {
@ -42,6 +45,18 @@ class VersionProps {
private static final String java_runtime_version =
"@@VERSION_STRING@@";
private static final String VERSION_NUMBER =
"@@VERSION_NUMBER@@";
private static final String VERSION_BUILD =
"@@VERSION_BUILD@@";
private static final String VERSION_PRE =
"@@VERSION_PRE@@";
private static final String VERSION_OPT =
"@@VERSION_OPT@@";
static {
init();
}
@ -52,6 +67,44 @@ class VersionProps {
System.setProperty("java.runtime.name", java_runtime_name);
}
static List<Integer> versionNumbers() {
List<Integer> versionNumbers = new ArrayList<>(4);
int prevIndex = 0;
int index = VERSION_NUMBER.indexOf('.');
while (index > 0) {
versionNumbers.add(
Integer.parseInt(VERSION_NUMBER, prevIndex, index, 10));
prevIndex = index + 1; // Skip the period
index = VERSION_NUMBER.indexOf('.', prevIndex);
}
versionNumbers.add(Integer.parseInt(VERSION_NUMBER,
prevIndex, VERSION_NUMBER.length(), 10));
return versionNumbers;
}
static Optional<String> pre() {
return optionalOf(VERSION_PRE);
}
static Optional<Integer> build() {
return VERSION_BUILD.isEmpty() ?
Optional.empty() :
Optional.of(Integer.parseInt(VERSION_BUILD));
}
static Optional<String> optional() {
return optionalOf(VERSION_OPT);
}
// Treat empty strings as value not being present
private static Optional<String> optionalOf(String value) {
if (!value.isEmpty()) {
return Optional.of(value);
} else {
return Optional.empty();
}
}
/**
* In case you were wondering this method is called by java -version.
* Sad that it prints to stderr; would be nicer if default printed on
@ -111,4 +164,4 @@ class VersionProps {
java_vm_info + ")");
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@ -26,17 +26,16 @@
package java.lang.invoke;
import jdk.internal.loader.BootLoader;
import jdk.internal.vm.annotation.Stable;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.FieldVisitor;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.util.ValueConversions;
import sun.invoke.util.Wrapper;
import java.lang.invoke.LambdaForm.NamedFunction;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@ -168,12 +167,16 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
}
@Override
final Object internalValues() {
Object[] boundValues = new Object[speciesData().fieldCount()];
for (int i = 0; i < boundValues.length; ++i) {
boundValues[i] = arg(i);
final String internalValues() {
int count = speciesData().fieldCount();
if (count == 1) {
return "[" + arg(0) + "]";
}
return Arrays.asList(boundValues);
StringBuilder sb = new StringBuilder("[");
for (int i = 0; i < count; ++i) {
sb.append("\n ").append(i).append(": ( ").append(arg(i)).append(" )");
}
return sb.append("\n]").toString();
}
/*non-public*/ final Object arg(int i) {
@ -869,7 +872,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
*/
static final SpeciesData SPECIES_DATA = SpeciesData.EMPTY;
private static final SpeciesData[] SPECIES_DATA_CACHE = new SpeciesData[5];
private static final SpeciesData[] SPECIES_DATA_CACHE = new SpeciesData[6];
private static SpeciesData checkCache(int size, String types) {
int idx = size - 1;
SpeciesData data = SPECIES_DATA_CACHE[idx];
@ -877,9 +880,10 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
SPECIES_DATA_CACHE[idx] = data = getSpeciesData(types);
return data;
}
static SpeciesData speciesData_L() { return checkCache(1, "L"); }
static SpeciesData speciesData_LL() { return checkCache(2, "LL"); }
static SpeciesData speciesData_LLL() { return checkCache(3, "LLL"); }
static SpeciesData speciesData_LLLL() { return checkCache(4, "LLLL"); }
static SpeciesData speciesData_LLLLL() { return checkCache(5, "LLLLL"); }
static SpeciesData speciesData_L() { return checkCache(1, "L"); }
static SpeciesData speciesData_LL() { return checkCache(2, "LL"); }
static SpeciesData speciesData_LLL() { return checkCache(3, "LLL"); }
static SpeciesData speciesData_LLLL() { return checkCache(4, "LLLL"); }
static SpeciesData speciesData_LLLLL() { return checkCache(5, "LLLLL"); }
static SpeciesData speciesData_LLLLLL() { return checkCache(6, "LLLLLL"); }
}

View File

@ -25,22 +25,30 @@
package java.lang.invoke;
import java.io.*;
import java.util.*;
import java.lang.reflect.Modifier;
import jdk.internal.org.objectweb.asm.*;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.LambdaForm.BasicType.*;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Label;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;
import jdk.internal.org.objectweb.asm.Type;
import sun.invoke.util.VerifyAccess;
import sun.invoke.util.VerifyType;
import sun.invoke.util.Wrapper;
import sun.reflect.misc.ReflectUtil;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.LambdaForm.BasicType.*;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleStatics.*;
/**
* Code generation backend for LambdaForm.
* <p>
@ -75,8 +83,8 @@ class InvokerBytecodeGenerator {
private final MethodType invokerType;
/** Info about local variables in compiled lambda form */
private final int[] localsMap; // index
private final Class<?>[] localClasses; // type
private int[] localsMap; // index
private Class<?>[] localClasses; // type
/** ASM bytecode generation. */
private ClassWriter cw;
@ -101,8 +109,7 @@ class InvokerBytecodeGenerator {
this.lambdaForm = lambdaForm;
this.invokerName = invokerName;
this.invokerType = invokerType;
this.localsMap = new int[localsMapSize+1];
// last entry of localsMap is count of allocated local slots
this.localsMap = new int[localsMapSize+1]; // last entry of localsMap is count of allocated local slots
this.localClasses = new Class<?>[localsMapSize+1];
}
@ -131,7 +138,6 @@ class InvokerBytecodeGenerator {
}
}
/** instance counters for dumped classes */
private static final HashMap<String,Integer> DUMP_CLASS_FILES_COUNTERS;
/** debugging flag for saving generated class files */
@ -177,7 +183,6 @@ class InvokerBytecodeGenerator {
}
});
}
}
private static String makeDumpableClassName(String className) {
@ -280,14 +285,11 @@ class InvokerBytecodeGenerator {
private static MemberName resolveInvokerMember(Class<?> invokerClass, String name, MethodType type) {
MemberName member = new MemberName(invokerClass, name, type, REF_invokeStatic);
//System.out.println("resolveInvokerMember => "+member);
//for (Method m : invokerClass.getDeclaredMethods()) System.out.println(" "+m);
try {
member = MEMBERNAME_FACTORY.resolveOrFail(REF_invokeStatic, member, HOST_CLASS, ReflectiveOperationException.class);
} catch (ReflectiveOperationException e) {
throw newInternalError(e);
}
//System.out.println("resolveInvokerMember => "+member);
return member;
}
@ -541,11 +543,12 @@ class InvokerBytecodeGenerator {
Name writeBack = null; // local to write back result
if (arg instanceof Name) {
Name n = (Name) arg;
if (assertStaticType(cls, n))
return; // this cast was already performed
if (lambdaForm.useCount(n) > 1) {
// This guy gets used more than once.
writeBack = n;
if (assertStaticType(cls, n)) {
return; // this cast was already performed
}
}
}
if (isStaticallyNameable(cls)) {
@ -679,19 +682,29 @@ class InvokerBytecodeGenerator {
MethodHandleImpl.Intrinsic intr = name.function.intrinsicName();
switch (intr) {
case SELECT_ALTERNATIVE:
assert isSelectAlternative(i);
assert lambdaForm.isSelectAlternative(i);
if (PROFILE_GWT) {
assert(name.arguments[0] instanceof Name &&
nameRefersTo((Name)name.arguments[0], MethodHandleImpl.class, "profileBoolean"));
((Name)name.arguments[0]).refersTo(MethodHandleImpl.class, "profileBoolean"));
mv.visitAnnotation(INJECTEDPROFILE_SIG, true);
}
onStack = emitSelectAlternative(name, lambdaForm.names[i+1]);
i++; // skip MH.invokeBasic of the selectAlternative result
continue;
case GUARD_WITH_CATCH:
assert isGuardWithCatch(i);
assert lambdaForm.isGuardWithCatch(i);
onStack = emitGuardWithCatch(i);
i = i+2; // Jump to the end of GWC idiom
i += 2; // jump to the end of GWC idiom
continue;
case TRY_FINALLY:
assert lambdaForm.isTryFinally(i);
onStack = emitTryFinally(i);
i += 2; // jump to the end of the TF idiom
continue;
case LOOP:
assert lambdaForm.isLoop(i);
onStack = emitLoop(i);
i += 2; // jump to the end of the LOOP idiom
continue;
case NEW_ARRAY:
Class<?> rtype = name.function.methodType().returnType();
@ -763,7 +776,7 @@ class InvokerBytecodeGenerator {
* Emit an invoke for the given name.
*/
void emitInvoke(Name name) {
assert(!isLinkerMethodInvoke(name)); // should use the static path for these
assert(!name.isLinkerMethodInvoke()); // should use the static path for these
if (true) {
// push receiver
MethodHandle target = name.function.resolvedHandle();
@ -951,84 +964,6 @@ class InvokerBytecodeGenerator {
throw new InternalError("refKind="+refKind);
}
/**
* Check if MemberName is a call to a method named {@code name} in class {@code declaredClass}.
*/
private boolean memberRefersTo(MemberName member, Class<?> declaringClass, String name) {
return member != null &&
member.getDeclaringClass() == declaringClass &&
member.getName().equals(name);
}
private boolean nameRefersTo(Name name, Class<?> declaringClass, String methodName) {
return name.function != null &&
memberRefersTo(name.function.member(), declaringClass, methodName);
}
/**
* Check if MemberName is a call to MethodHandle.invokeBasic.
*/
private boolean isInvokeBasic(Name name) {
if (name.function == null)
return false;
if (name.arguments.length < 1)
return false; // must have MH argument
MemberName member = name.function.member();
return memberRefersTo(member, MethodHandle.class, "invokeBasic") &&
!member.isPublic() && !member.isStatic();
}
/**
* Check if MemberName is a call to MethodHandle.linkToStatic, etc.
*/
private boolean isLinkerMethodInvoke(Name name) {
if (name.function == null)
return false;
if (name.arguments.length < 1)
return false; // must have MH argument
MemberName member = name.function.member();
return member != null &&
member.getDeclaringClass() == MethodHandle.class &&
!member.isPublic() && member.isStatic() &&
member.getName().startsWith("linkTo");
}
/**
* Check if i-th name is a call to MethodHandleImpl.selectAlternative.
*/
private boolean isSelectAlternative(int pos) {
// selectAlternative idiom:
// t_{n}:L=MethodHandleImpl.selectAlternative(...)
// t_{n+1}:?=MethodHandle.invokeBasic(t_{n}, ...)
if (pos+1 >= lambdaForm.names.length) return false;
Name name0 = lambdaForm.names[pos];
Name name1 = lambdaForm.names[pos+1];
return nameRefersTo(name0, MethodHandleImpl.class, "selectAlternative") &&
isInvokeBasic(name1) &&
name1.lastUseIndex(name0) == 0 && // t_{n+1}:?=MethodHandle.invokeBasic(t_{n}, ...)
lambdaForm.lastUseIndex(name0) == pos+1; // t_{n} is local: used only in t_{n+1}
}
/**
* Check if i-th name is a start of GuardWithCatch idiom.
*/
private boolean isGuardWithCatch(int pos) {
// GuardWithCatch idiom:
// t_{n}:L=MethodHandle.invokeBasic(...)
// t_{n+1}:L=MethodHandleImpl.guardWithCatch(*, *, *, t_{n});
// t_{n+2}:?=MethodHandle.invokeBasic(t_{n+1})
if (pos+2 >= lambdaForm.names.length) return false;
Name name0 = lambdaForm.names[pos];
Name name1 = lambdaForm.names[pos+1];
Name name2 = lambdaForm.names[pos+2];
return nameRefersTo(name1, MethodHandleImpl.class, "guardWithCatch") &&
isInvokeBasic(name0) &&
isInvokeBasic(name2) &&
name1.lastUseIndex(name0) == 3 && // t_{n+1}:L=MethodHandleImpl.guardWithCatch(*, *, *, t_{n});
lambdaForm.lastUseIndex(name0) == pos+1 && // t_{n} is local: used only in t_{n+1}
name2.lastUseIndex(name1) == 1 && // t_{n+2}:?=MethodHandle.invokeBasic(t_{n+1})
lambdaForm.lastUseIndex(name1) == pos+2; // t_{n+1} is local: used only in t_{n+2}
}
/**
* Emit bytecode for the selectAlternative idiom.
*
@ -1155,6 +1090,329 @@ class InvokerBytecodeGenerator {
return result;
}
/**
* Emit bytecode for the tryFinally idiom.
* <p>
* The pattern looks like (Cf. MethodHandleImpl.makeTryFinally):
* <blockquote><pre>{@code
* // a0: BMH
* // a1: target, a2: cleanup
* // a3: box, a4: unbox
* // a5 (and following): arguments
* tryFinally=Lambda(a0:L,a1:L,a2:L,a3:L,a4:L,a5:L)=>{
* t6:L=MethodHandle.invokeBasic(a3:L,a5:L); // box the arguments into an Object[]
* t7:L=MethodHandleImpl.tryFinally(a1:L,a2:L,t6:L); // call the tryFinally executor
* t8:L=MethodHandle.invokeBasic(a4:L,t7:L);t8:L} // unbox the result; return the result
* }</pre></blockquote>
* <p>
* It is compiled into bytecode equivalent to the following code:
* <blockquote><pre>{@code
* Throwable t;
* Object r;
* try {
* r = a1.invokeBasic(a5);
* } catch (Throwable thrown) {
* t = thrown;
* throw t;
* } finally {
* r = a2.invokeBasic(t, r, a5);
* }
* return r;
* }</pre></blockquote>
* <p>
* Specifically, the bytecode will have the following form (the stack effects are given for the beginnings of
* blocks, and for the situations after executing the given instruction - the code will have a slightly different
* shape if the return type is {@code void}):
* <blockquote><pre>{@code
* TRY: (--)
* load target (-- target)
* load args (-- args... target)
* INVOKEVIRTUAL MethodHandle.invokeBasic (depends)
* FINALLY_NORMAL: (-- r)
* load cleanup (-- cleanup r)
* SWAP (-- r cleanup)
* ACONST_NULL (-- t r cleanup)
* SWAP (-- r t cleanup)
* load args (-- args... r t cleanup)
* INVOKEVIRTUAL MethodHandle.invokeBasic (-- r)
* GOTO DONE
* CATCH: (-- t)
* DUP (-- t t)
* FINALLY_EXCEPTIONAL: (-- t t)
* load cleanup (-- cleanup t t)
* SWAP (-- t cleanup t)
* load default for r (-- r t cleanup t)
* load args (-- args... r t cleanup t)
* INVOKEVIRTUAL MethodHandle.invokeBasic (-- r t)
* POP (-- t)
* ATHROW
* DONE: (-- r)
* }</pre></blockquote>
*/
private Name emitTryFinally(int pos) {
Name args = lambdaForm.names[pos];
Name invoker = lambdaForm.names[pos+1];
Name result = lambdaForm.names[pos+2];
Label lFrom = new Label();
Label lTo = new Label();
Label lCatch = new Label();
Label lDone = new Label();
Class<?> returnType = result.function.resolvedHandle().type().returnType();
boolean isNonVoid = returnType != void.class;
MethodType type = args.function.resolvedHandle().type()
.dropParameterTypes(0,1)
.changeReturnType(returnType);
MethodType cleanupType = type.insertParameterTypes(0, Throwable.class);
if (isNonVoid) {
cleanupType = cleanupType.insertParameterTypes(1, returnType);
}
String cleanupDesc = cleanupType.basicType().toMethodDescriptorString();
// exception handler table
mv.visitTryCatchBlock(lFrom, lTo, lCatch, "java/lang/Throwable");
// TRY:
mv.visitLabel(lFrom);
emitPushArgument(invoker, 0); // load target
emitPushArguments(args, 1); // load args (skip 0: method handle)
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", type.basicType().toMethodDescriptorString(), false);
mv.visitLabel(lTo);
// FINALLY_NORMAL:
emitPushArgument(invoker, 1); // load cleanup
if (isNonVoid) {
mv.visitInsn(Opcodes.SWAP);
}
mv.visitInsn(Opcodes.ACONST_NULL);
if (isNonVoid) {
mv.visitInsn(Opcodes.SWAP);
}
emitPushArguments(args, 1); // load args (skip 0: method handle)
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", cleanupDesc, false);
mv.visitJumpInsn(Opcodes.GOTO, lDone);
// CATCH:
mv.visitLabel(lCatch);
mv.visitInsn(Opcodes.DUP);
// FINALLY_EXCEPTIONAL:
emitPushArgument(invoker, 1); // load cleanup
mv.visitInsn(Opcodes.SWAP);
if (isNonVoid) {
emitZero(BasicType.basicType(returnType)); // load default for result
}
emitPushArguments(args, 1); // load args (skip 0: method handle)
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", cleanupDesc, false);
if (isNonVoid) {
mv.visitInsn(Opcodes.POP);
}
mv.visitInsn(Opcodes.ATHROW);
// DONE:
mv.visitLabel(lDone);
return result;
}
/**
* Emit bytecode for the loop idiom.
* <p>
* The pattern looks like (Cf. MethodHandleImpl.loop):
* <blockquote><pre>{@code
* // a0: BMH
* // a1: inits, a2: steps, a3: preds, a4: finis
* // a5: box, a6: unbox
* // a7 (and following): arguments
* loop=Lambda(a0:L,a1:L,a2:L,a3:L,a4:L,a5:L,a6:L,a7:L)=>{
* t8:L=MethodHandle.invokeBasic(a5:L,a7:L); // box the arguments into an Object[]
* t9:L=MethodHandleImpl.loop(bt:L,a1:L,a2:L,a3:L,a4:L,t8:L); // call the loop executor (with supplied types in bt)
* t10:L=MethodHandle.invokeBasic(a6:L,t9:L);t10:L} // unbox the result; return the result
* }</pre></blockquote>
* <p>
* It is compiled into bytecode equivalent to the code seen in {@link MethodHandleImpl#loop(BasicType[],
* MethodHandle[], MethodHandle[], MethodHandle[], MethodHandle[], Object...)}, with the difference that no arrays
* will be used for local state storage. Instead, the local state will be mapped to actual stack slots.
* <p>
* Bytecode generation applies an unrolling scheme to enable better bytecode generation regarding local state type
* handling. The generated bytecode will have the following form ({@code void} types are ignored for convenience).
* Assume there are {@code C} clauses in the loop.
* <blockquote><pre>{@code
* INIT: (INIT_SEQ for clause 1)
* ...
* (INIT_SEQ for clause C)
* LOOP: (LOOP_SEQ for clause 1)
* ...
* (LOOP_SEQ for clause C)
* GOTO LOOP
* DONE: ...
* }</pre></blockquote>
* <p>
* The {@code INIT_SEQ_x} sequence for clause {@code x} (with {@code x} ranging from {@code 0} to {@code C-1}) has
* the following shape. Assume slot {@code vx} is used to hold the state for clause {@code x}.
* <blockquote><pre>{@code
* INIT_SEQ_x: ALOAD inits
* CHECKCAST MethodHandle[]
* ICONST x
* AALOAD // load the init handle for clause x
* load args
* INVOKEVIRTUAL MethodHandle.invokeBasic
* store vx
* }</pre></blockquote>
* <p>
* The {@code LOOP_SEQ_x} sequence for clause {@code x} (with {@code x} ranging from {@code 0} to {@code C-1}) has
* the following shape. Again, assume slot {@code vx} is used to hold the state for clause {@code x}.
* <blockquote><pre>{@code
* LOOP_SEQ_x: ALOAD steps
* CHECKCAST MethodHandle[]
* ICONST x
* AALOAD // load the step handle for clause x
* load locals
* load args
* INVOKEVIRTUAL MethodHandle.invokeBasic
* store vx
* ALOAD preds
* CHECKCAST MethodHandle[]
* ICONST x
* AALOAD // load the pred handle for clause x
* load locals
* load args
* INVOKEVIRTUAL MethodHandle.invokeBasic
* IFNE LOOP_SEQ_x+1 // predicate returned false -> jump to next clause
* ALOAD finis
* CHECKCAST MethodHandle[]
* ICONST x
* AALOAD // load the fini handle for clause x
* load locals
* load args
* INVOKEVIRTUAL MethodHandle.invokeBasic
* GOTO DONE // jump beyond end of clauses to return from loop
* }</pre></blockquote>
*/
private Name emitLoop(int pos) {
Name args = lambdaForm.names[pos];
Name invoker = lambdaForm.names[pos+1];
Name result = lambdaForm.names[pos+2];
// extract clause and loop-local state types
// find the type info in the loop invocation
BasicType[] loopClauseTypes = (BasicType[]) invoker.arguments[0];
Class<?>[] loopLocalStateTypes = Stream.of(loopClauseTypes).
filter(bt -> bt != BasicType.V_TYPE).map(BasicType::basicTypeClass).toArray(Class<?>[]::new);
final int firstLoopStateIndex = extendLocalsMap(loopLocalStateTypes);
Class<?> returnType = result.function.resolvedHandle().type().returnType();
MethodType loopType = args.function.resolvedHandle().type()
.dropParameterTypes(0,1)
.changeReturnType(returnType);
MethodType loopHandleType = loopType.insertParameterTypes(0, loopLocalStateTypes);
MethodType predType = loopHandleType.changeReturnType(boolean.class);
MethodType finiType = loopHandleType;
final int nClauses = loopClauseTypes.length;
// indices to invoker arguments to load method handle arrays
final int inits = 1;
final int steps = 2;
final int preds = 3;
final int finis = 4;
Label lLoop = new Label();
Label lDone = new Label();
Label lNext;
// INIT:
for (int c = 0, state = 0; c < nClauses; ++c) {
MethodType cInitType = loopType.changeReturnType(loopClauseTypes[c].basicTypeClass());
emitLoopHandleInvoke(invoker, inits, c, args, false, cInitType, loopLocalStateTypes, firstLoopStateIndex);
if (cInitType.returnType() != void.class) {
emitStoreInsn(BasicType.basicType(cInitType.returnType()), firstLoopStateIndex + state);
++state;
}
}
// LOOP:
mv.visitLabel(lLoop);
for (int c = 0, state = 0; c < nClauses; ++c) {
lNext = new Label();
MethodType stepType = loopHandleType.changeReturnType(loopClauseTypes[c].basicTypeClass());
boolean isVoid = stepType.returnType() == void.class;
// invoke loop step
emitLoopHandleInvoke(invoker, steps, c, args, true, stepType, loopLocalStateTypes, firstLoopStateIndex);
if (!isVoid) {
emitStoreInsn(BasicType.basicType(stepType.returnType()), firstLoopStateIndex + state);
++state;
}
// invoke loop predicate
emitLoopHandleInvoke(invoker, preds, c, args, true, predType, loopLocalStateTypes, firstLoopStateIndex);
mv.visitJumpInsn(Opcodes.IFNE, lNext);
// invoke fini
emitLoopHandleInvoke(invoker, finis, c, args, true, finiType, loopLocalStateTypes, firstLoopStateIndex);
mv.visitJumpInsn(Opcodes.GOTO, lDone);
// this is the beginning of the next loop clause
mv.visitLabel(lNext);
}
mv.visitJumpInsn(Opcodes.GOTO, lLoop);
// DONE:
mv.visitLabel(lDone);
return result;
}
private int extendLocalsMap(Class<?>[] types) {
int firstSlot = localsMap.length - 1;
localsMap = Arrays.copyOf(localsMap, localsMap.length + types.length);
localClasses = Arrays.copyOf(localClasses, localClasses.length + types.length);
System.arraycopy(types, 0, localClasses, firstSlot, types.length);
int index = localsMap[firstSlot - 1] + 1;
int lastSlots = 0;
for (int i = 0; i < types.length; ++i) {
localsMap[firstSlot + i] = index;
lastSlots = BasicType.basicType(localClasses[firstSlot + i]).basicTypeSlots();
index += lastSlots;
}
localsMap[localsMap.length - 1] = index - lastSlots;
return firstSlot;
}
private void emitLoopHandleInvoke(Name holder, int handles, int clause, Name args, boolean pushLocalState,
MethodType type, Class<?>[] loopLocalStateTypes, int firstLoopStateSlot) {
// load handle for clause
emitPushArgument(holder, handles);
emitIconstInsn(clause);
mv.visitInsn(Opcodes.AALOAD);
// load loop state (preceding the other arguments)
if (pushLocalState) {
for (int s = 0; s < loopLocalStateTypes.length; ++s) {
emitLoadInsn(BasicType.basicType(loopLocalStateTypes[s]), firstLoopStateSlot + s);
}
}
// load loop args (skip 0: method handle)
emitPushArguments(args, 1);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", type.toMethodDescriptorString(), false);
}
private void emitZero(BasicType type) {
switch (type) {
case I_TYPE: mv.visitInsn(Opcodes.ICONST_0); break;
case J_TYPE: mv.visitInsn(Opcodes.LCONST_0); break;
case F_TYPE: mv.visitInsn(Opcodes.FCONST_0); break;
case D_TYPE: mv.visitInsn(Opcodes.DCONST_0); break;
case L_TYPE: mv.visitInsn(Opcodes.ACONST_NULL); break;
default: throw new InternalError("unknown type: " + type);
}
}
private void emitPushArguments(Name args) {
emitPushArguments(args, 0);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -33,11 +33,9 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import static java.lang.invoke.LambdaForm.BasicType.*;
import static java.lang.invoke.MethodHandleNatives.Constants.REF_invokeStatic;
@ -210,6 +208,29 @@ class LambdaForm {
}
return btypes;
}
static String basicTypeDesc(BasicType[] types) {
if (types == null) {
return null;
}
if (types.length == 0) {
return "";
}
StringBuilder sb = new StringBuilder();
for (BasicType bt : types) {
sb.append(bt.basicTypeChar());
}
return sb.toString();
}
static int[] basicTypeOrds(BasicType[] types) {
if (types == null) {
return null;
}
int[] a = new int[types.length];
for(int i = 0; i < types.length; ++i) {
a[i] = types[i].ordinal();
}
return a;
}
static char basicTypeChar(Class<?> type) {
return basicType(type).btChar;
@ -565,6 +586,69 @@ class LambdaForm {
return MethodType.methodType(rtype, ptypes);
}
/**
* Check if i-th name is a call to MethodHandleImpl.selectAlternative.
*/
boolean isSelectAlternative(int pos) {
// selectAlternative idiom:
// t_{n}:L=MethodHandleImpl.selectAlternative(...)
// t_{n+1}:?=MethodHandle.invokeBasic(t_{n}, ...)
if (pos+1 >= names.length) return false;
Name name0 = names[pos];
Name name1 = names[pos+1];
return name0.refersTo(MethodHandleImpl.class, "selectAlternative") &&
name1.isInvokeBasic() &&
name1.lastUseIndex(name0) == 0 && // t_{n+1}:?=MethodHandle.invokeBasic(t_{n}, ...)
lastUseIndex(name0) == pos+1; // t_{n} is local: used only in t_{n+1}
}
private boolean isMatchingIdiom(int pos, String idiomName, int nArgs) {
if (pos+2 >= names.length) return false;
Name name0 = names[pos];
Name name1 = names[pos+1];
Name name2 = names[pos+2];
return name1.refersTo(MethodHandleImpl.class, idiomName) &&
name0.isInvokeBasic() &&
name2.isInvokeBasic() &&
name1.lastUseIndex(name0) == nArgs && // t_{n+1}:L=MethodHandleImpl.<invoker>(<args>, t_{n});
lastUseIndex(name0) == pos+1 && // t_{n} is local: used only in t_{n+1}
name2.lastUseIndex(name1) == 1 && // t_{n+2}:?=MethodHandle.invokeBasic(*, t_{n+1})
lastUseIndex(name1) == pos+2; // t_{n+1} is local: used only in t_{n+2}
}
/**
* Check if i-th name is a start of GuardWithCatch idiom.
*/
boolean isGuardWithCatch(int pos) {
// GuardWithCatch idiom:
// t_{n}:L=MethodHandle.invokeBasic(...)
// t_{n+1}:L=MethodHandleImpl.guardWithCatch(*, *, *, t_{n});
// t_{n+2}:?=MethodHandle.invokeBasic(*, t_{n+1})
return isMatchingIdiom(pos, "guardWithCatch", 3);
}
/**
* Check if i-th name is a start of the tryFinally idiom.
*/
boolean isTryFinally(int pos) {
// tryFinally idiom:
// t_{n}:L=MethodHandle.invokeBasic(...)
// t_{n+1}:L=MethodHandleImpl.tryFinally(*, *, t_{n})
// t_{n+2}:?=MethodHandle.invokeBasic(*, t_{n+1})
return isMatchingIdiom(pos, "tryFinally", 2);
}
/**
* Check if i-th name is a start of the loop idiom.
*/
boolean isLoop(int pos) {
// loop idiom:
// t_{n}:L=MethodHandle.invokeBasic(...)
// t_{n+1}:L=MethodHandleImpl.loop(types, *, *, *, *, t_{n})
// t_{n+2}:?=MethodHandle.invokeBasic(*, t_{n+1})
return isMatchingIdiom(pos, "loop", 5);
}
/*
* Code generation issues:
*
@ -1421,6 +1505,39 @@ class LambdaForm {
return !isParam() && arguments.length == 0 && function.isConstantZero();
}
boolean refersTo(Class<?> declaringClass, String methodName) {
return function != null &&
function.member() != null && function.member().refersTo(declaringClass, methodName);
}
/**
* Check if MemberName is a call to MethodHandle.invokeBasic.
*/
boolean isInvokeBasic() {
if (function == null)
return false;
if (arguments.length < 1)
return false; // must have MH argument
MemberName member = function.member();
return member != null && member.refersTo(MethodHandle.class, "invokeBasic") &&
!member.isPublic() && !member.isStatic();
}
/**
* Check if MemberName is a call to MethodHandle.linkToStatic, etc.
*/
boolean isLinkerMethodInvoke() {
if (function == null)
return false;
if (arguments.length < 1)
return false; // must have MH argument
MemberName member = function.member();
return member != null &&
member.getDeclaringClass() == MethodHandle.class &&
!member.isPublic() && member.isStatic() &&
member.getName().startsWith("linkTo");
}
public String toString() {
return (isParam()?"a":"t")+(index >= 0 ? index : System.identityHashCode(this))+":"+typeChar();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@ -249,7 +249,7 @@ final class LambdaFormBuffer {
assert(inTrans());
}
private void changeName(int i, Name name) {
void changeName(int i, Name name) {
assert(inTrans());
assert(i < length);
Name oldName = names[i];

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@ -25,15 +25,17 @@
package java.lang.invoke;
import sun.invoke.util.Wrapper;
import java.lang.ref.SoftReference;
import java.util.Arrays;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.LambdaForm.BasicType.*;
import static java.lang.invoke.MethodHandleImpl.Intrinsic;
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import sun.invoke.util.Wrapper;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.LambdaForm.BasicType.*;
import static java.lang.invoke.MethodHandleImpl.Intrinsic;
import static java.lang.invoke.MethodHandleImpl.NF_loop;
/** Transforms on LFs.
* A lambda-form editor can derive new LFs from its base LF.
@ -73,7 +75,8 @@ class LambdaFormEditor {
FILTER_ARG, FILTER_RETURN, FILTER_RETURN_TO_ZERO,
COLLECT_ARGS, COLLECT_ARGS_TO_VOID, COLLECT_ARGS_TO_ARRAY,
FOLD_ARGS, FOLD_ARGS_TO_VOID,
PERMUTE_ARGS
PERMUTE_ARGS,
LOCAL_TYPES
//maybe add more for guard with test, catch exception, pointwise type conversions
}
@ -847,6 +850,32 @@ class LambdaFormEditor {
return putInCache(key, form);
}
LambdaForm noteLoopLocalTypesForm(int pos, BasicType[] localTypes) {
assert(lambdaForm.isLoop(pos));
int[] desc = BasicType.basicTypeOrds(localTypes);
desc = Arrays.copyOf(desc, desc.length + 1);
desc[desc.length - 1] = pos;
Transform key = Transform.of(Transform.Kind.LOCAL_TYPES, desc);
LambdaForm form = getInCache(key);
if (form != null) {
return form;
}
// replace the null entry in the MHImpl.loop invocation with localTypes
Name invokeLoop = lambdaForm.names[pos + 1];
assert(invokeLoop.function == NF_loop);
Object[] args = Arrays.copyOf(invokeLoop.arguments, invokeLoop.arguments.length);
assert(args[0] == null);
args[0] = localTypes;
LambdaFormBuffer buf = buffer();
buf.startEdit();
buf.changeName(pos + 1, new Name(NF_loop, args));
form = buf.endEdit();
return putInCache(key, form);
}
static boolean permutedTypesMatch(int[] reorder, BasicType[] types, Name[] names, int skip) {
for (int i = 0; i < reorder.length; i++) {
assert (names[skip + i].isParam());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@ -32,8 +32,8 @@ import sun.invoke.util.VerifyAccess;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Module;
import java.util.ArrayList;
@ -41,10 +41,12 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleStatics.*;
import java.util.Objects;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleStatics.newIllegalArgumentException;
import static java.lang.invoke.MethodHandleStatics.newInternalError;
/**
* A {@code MemberName} is a compact symbolic datum which fully characterizes
* a method or field reference.
@ -500,6 +502,13 @@ import java.util.Objects;
lookupClass, mode);
}
/**
* Check if MemberName is a call to a method named {@code name} in class {@code declaredClass}.
*/
public boolean refersTo(Class<?> declc, String n) {
return clazz == declc && getName().equals(n);
}
/** Initialize a query. It is not resolved. */
private void init(Class<?> defClass, String name, Object type, int flags) {
// defining class is allowed to be null (for a naked name/type pair)

View File

@ -25,15 +25,9 @@
package java.lang.invoke;
import java.lang.reflect.Array;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
import jdk.internal.org.objectweb.asm.AnnotationVisitor;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
import jdk.internal.vm.annotation.Stable;
@ -42,9 +36,16 @@ import sun.invoke.util.ValueConversions;
import sun.invoke.util.VerifyType;
import sun.invoke.util.Wrapper;
import jdk.internal.org.objectweb.asm.AnnotationVisitor;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import java.lang.reflect.Array;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.MethodHandleStatics.*;
@ -1046,26 +1047,13 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
// Box arguments and wrap them into Object[]: ValueConversions.array().
MethodType varargsType = type.changeReturnType(Object[].class);
MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
// Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
MethodHandle unboxResult;
Class<?> rtype = type.returnType();
if (rtype.isPrimitive()) {
if (rtype == void.class) {
unboxResult = ValueConversions.ignore();
} else {
Wrapper w = Wrapper.forPrimitiveType(type.returnType());
unboxResult = ValueConversions.unboxExact(w);
}
} else {
unboxResult = MethodHandles.identity(Object.class);
}
MethodHandle unboxResult = unboxResultHandle(type.returnType());
BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
BoundMethodHandle mh;
try {
mh = (BoundMethodHandle)
data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
(Object) collectArgs, (Object) unboxResult);
mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) target, (Object) exType,
(Object) catcher, (Object) collectArgs, (Object) unboxResult);
} catch (Throwable ex) {
throw uncaughtException(ex);
}
@ -1085,16 +1073,18 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
return target.asFixedArity().invokeWithArguments(av);
} catch (Throwable t) {
if (!exType.isInstance(t)) throw t;
return catcher.asFixedArity().invokeWithArguments(prepend(t, av));
return catcher.asFixedArity().invokeWithArguments(prepend(av, t));
}
}
/** Prepend an element {@code elem} to an {@code array}. */
/** Prepend elements to an array. */
@LambdaForm.Hidden
private static Object[] prepend(Object elem, Object[] array) {
Object[] newArray = new Object[array.length+1];
newArray[0] = elem;
System.arraycopy(array, 0, newArray, 1, array.length);
private static Object[] prepend(Object[] array, Object... elems) {
int nArray = array.length;
int nElems = elems.length;
Object[] newArray = new Object[nArray + nElems];
System.arraycopy(elems, 0, newArray, 0, nElems);
System.arraycopy(array, 0, newArray, nElems, nArray);
return newArray;
}
@ -1352,6 +1342,8 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
enum Intrinsic {
SELECT_ALTERNATIVE,
GUARD_WITH_CATCH,
TRY_FINALLY,
LOOP,
NEW_ARRAY,
ARRAY_LOAD,
ARRAY_STORE,
@ -1363,7 +1355,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
/** Mark arbitrary method handle as intrinsic.
* InvokerBytecodeGenerator uses this info to produce more efficient bytecode shape. */
private static final class IntrinsicMethodHandle extends DelegatingMethodHandle {
static final class IntrinsicMethodHandle extends DelegatingMethodHandle {
private final MethodHandle target;
private final Intrinsic intrinsicName;
@ -1694,6 +1686,8 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
NF_checkSpreadArgument,
NF_guardWithCatch,
NF_throwException,
NF_tryFinally,
NF_loop,
NF_profileBoolean;
static {
@ -1703,6 +1697,11 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
NF_guardWithCatch = new NamedFunction(MethodHandleImpl.class
.getDeclaredMethod("guardWithCatch", MethodHandle.class, Class.class,
MethodHandle.class, Object[].class));
NF_tryFinally = new NamedFunction(MethodHandleImpl.class
.getDeclaredMethod("tryFinally", MethodHandle.class, MethodHandle.class, Object[].class));
NF_loop = new NamedFunction(MethodHandleImpl.class
.getDeclaredMethod("loop", BasicType[].class, MethodHandle[].class, MethodHandle[].class,
MethodHandle[].class, MethodHandle[].class, Object[].class));
NF_throwException = new NamedFunction(MethodHandleImpl.class
.getDeclaredMethod("throwException", Throwable.class));
NF_profileBoolean = new NamedFunction(MethodHandleImpl.class
@ -1712,14 +1711,25 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
}
}
/** Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore(). */
private static MethodHandle unboxResultHandle(Class<?> returnType) {
if (returnType.isPrimitive()) {
if (returnType == void.class) {
return ValueConversions.ignore();
} else {
Wrapper w = Wrapper.forPrimitiveType(returnType);
return ValueConversions.unboxExact(w);
}
} else {
return MethodHandles.identity(Object.class);
}
}
/**
* Assembles a loop method handle from the given handles and type information. This works by binding and configuring
* the {@linkplain #looper(MethodHandle[], MethodHandle[], MethodHandle[], MethodHandle[], int, int, Object[]) "most
* generic loop"}.
* Assembles a loop method handle from the given handles and type information.
*
* @param tloop the return type of the loop.
* @param targs types of the arguments to be passed to the loop.
* @param tvars types of loop-local variables.
* @param init sanitized array of initializers for loop-local variables.
* @param step sanitited array of loop bodies.
* @param pred sanitized array of predicates.
@ -1727,64 +1737,144 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
*
* @return a handle that, when invoked, will execute the loop.
*/
static MethodHandle makeLoop(Class<?> tloop, List<Class<?>> targs, List<Class<?>> tvars, List<MethodHandle> init,
List<MethodHandle> step, List<MethodHandle> pred, List<MethodHandle> fini) {
MethodHandle[] ainit = toArrayArgs(init);
MethodHandle[] astep = toArrayArgs(step);
MethodHandle[] apred = toArrayArgs(pred);
MethodHandle[] afini = toArrayArgs(fini);
static MethodHandle makeLoop(Class<?> tloop, List<Class<?>> targs, List<MethodHandle> init, List<MethodHandle> step,
List<MethodHandle> pred, List<MethodHandle> fini) {
MethodType type = MethodType.methodType(tloop, targs);
BasicType[] initClauseTypes =
init.stream().map(h -> h.type().returnType()).map(BasicType::basicType).toArray(BasicType[]::new);
LambdaForm form = makeLoopForm(type.basicType(), initClauseTypes);
MethodHandle l = getConstantHandle(MH_looper);
// Prepare auxiliary method handles used during LambdaForm interpretation.
// Box arguments and wrap them into Object[]: ValueConversions.array().
MethodType varargsType = type.changeReturnType(Object[].class);
MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
MethodHandle unboxResult = unboxResultHandle(tloop);
// Bind the statically known arguments.
l = MethodHandles.insertArguments(l, 0, ainit, astep, apred, afini, tvars.size(), targs.size());
BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLLL();
BoundMethodHandle mh;
try {
mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) toArray(init),
(Object) toArray(step), (Object) toArray(pred), (Object) toArray(fini), (Object) collectArgs,
(Object) unboxResult);
} catch (Throwable ex) {
throw uncaughtException(ex);
}
assert(mh.type() == type);
return mh;
}
// Turn the args array into an argument list.
l = l.asCollector(Object[].class, targs.size());
// Finally, make loop type.
MethodType loopType = MethodType.methodType(tloop, targs);
l = l.asType(loopType);
return l;
private static MethodHandle[] toArray(List<MethodHandle> l) {
return l.toArray(new MethodHandle[0]);
}
/**
* Converts all handles in the {@code hs} array to handles that accept an array of arguments.
*
* @param hs method handles to be converted.
*
* @return the {@code hs} array, with all method handles therein converted.
* Loops introduce some complexity as they can have additional local state. Hence, LambdaForms for loops are
* generated from a template. The LambdaForm template shape for the loop combinator is as follows (assuming one
* reference parameter passed in {@code a1}, and a reference return type, with the return value represented by
* {@code t12}):
* <blockquote><pre>{@code
* loop=Lambda(a0:L,a1:L)=>{
* t2:L=BoundMethodHandle$Species_L6.argL0(a0:L); // array of init method handles
* t3:L=BoundMethodHandle$Species_L6.argL1(a0:L); // array of step method handles
* t4:L=BoundMethodHandle$Species_L6.argL2(a0:L); // array of pred method handles
* t5:L=BoundMethodHandle$Species_L6.argL3(a0:L); // array of fini method handles
* t6:L=BoundMethodHandle$Species_L6.argL4(a0:L); // helper handle to box the arguments into an Object[]
* t7:L=BoundMethodHandle$Species_L6.argL5(a0:L); // helper handle to unbox the result
* t8:L=MethodHandle.invokeBasic(t6:L,a1:L); // box the arguments into an Object[]
* t9:L=MethodHandleImpl.loop(null,t2:L,t3:L,t4:L,t5:L,t6:L); // call the loop executor
* t10:L=MethodHandle.invokeBasic(t7:L,t9:L);t10:L} // unbox the result; return the result
* }</pre></blockquote>
* <p>
* {@code argL0} through {@code argL3} are the arrays of init, step, pred, and fini method handles.
* {@code argL4} and {@code argL5} are auxiliary method handles: {@code argL2} boxes arguments and wraps them into
* {@code Object[]} ({@code ValueConversions.array()}), and {@code argL3} unboxes the result if necessary
* ({@code ValueConversions.unbox()}).
* <p>
* Having {@code t6} and {@code t7} passed in via a BMH and not hardcoded in the lambda form allows to share lambda
* forms among loop combinators with the same basic type.
* <p>
* The above template is instantiated by using the {@link LambdaFormEditor} to replace the {@code null} argument to
* the {@code loop} invocation with the {@code BasicType} array describing the loop clause types. This argument is
* ignored in the loop invoker, but will be extracted and used in {@linkplain InvokerBytecodeGenerator#emitLoop(int)
* bytecode generation}.
*/
static MethodHandle[] toArrayArgs(List<MethodHandle> hs) {
return hs.stream().map(h -> h.asSpreader(Object[].class, h.type().parameterCount())).toArray(MethodHandle[]::new);
private static LambdaForm makeLoopForm(MethodType basicType, BasicType[] localVarTypes) {
MethodType lambdaType = basicType.invokerType();
final int THIS_MH = 0; // the BMH_LLLLLL
final int ARG_BASE = 1; // start of incoming arguments
final int ARG_LIMIT = ARG_BASE + basicType.parameterCount();
int nameCursor = ARG_LIMIT;
final int GET_INITS = nameCursor++;
final int GET_STEPS = nameCursor++;
final int GET_PREDS = nameCursor++;
final int GET_FINIS = nameCursor++;
final int GET_COLLECT_ARGS = nameCursor++;
final int GET_UNBOX_RESULT = nameCursor++;
final int BOXED_ARGS = nameCursor++;
final int LOOP = nameCursor++;
final int UNBOX_RESULT = nameCursor++;
LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_LOOP);
if (lform == null) {
Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType);
BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLLL();
names[THIS_MH] = names[THIS_MH].withConstraint(data);
names[GET_INITS] = new Name(data.getterFunction(0), names[THIS_MH]);
names[GET_STEPS] = new Name(data.getterFunction(1), names[THIS_MH]);
names[GET_PREDS] = new Name(data.getterFunction(2), names[THIS_MH]);
names[GET_FINIS] = new Name(data.getterFunction(3), names[THIS_MH]);
names[GET_COLLECT_ARGS] = new Name(data.getterFunction(4), names[THIS_MH]);
names[GET_UNBOX_RESULT] = new Name(data.getterFunction(5), names[THIS_MH]);
// t_{i}:L=MethodHandle.invokeBasic(collectArgs:L,a1:L,...);
MethodType collectArgsType = basicType.changeReturnType(Object.class);
MethodHandle invokeBasic = MethodHandles.basicInvoker(collectArgsType);
Object[] args = new Object[invokeBasic.type().parameterCount()];
args[0] = names[GET_COLLECT_ARGS];
System.arraycopy(names, ARG_BASE, args, 1, ARG_LIMIT - ARG_BASE);
names[BOXED_ARGS] = new Name(makeIntrinsic(invokeBasic, Intrinsic.LOOP), args);
// t_{i+1}:L=MethodHandleImpl.loop(localTypes:L,inits:L,steps:L,preds:L,finis:L,t_{i}:L);
Object[] lArgs =
new Object[]{null, // placeholder for BasicType[] localTypes - will be added by LambdaFormEditor
names[GET_INITS], names[GET_STEPS], names[GET_PREDS], names[GET_FINIS], names[BOXED_ARGS]};
names[LOOP] = new Name(NF_loop, lArgs);
// t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
Object[] unboxArgs = new Object[]{names[GET_UNBOX_RESULT], names[LOOP]};
names[UNBOX_RESULT] = new Name(invokeBasicUnbox, unboxArgs);
lform = basicType.form().setCachedLambdaForm(MethodTypeForm.LF_LOOP,
new LambdaForm("loop", lambdaType.parameterCount(), names));
}
// BOXED_ARGS is the index into the names array where the loop idiom starts
return lform.editor().noteLoopLocalTypesForm(BOXED_ARGS, localVarTypes);
}
/**
* This method embodies the most generic loop for use by {@link MethodHandles#loop(MethodHandle[][])}. A handle on
* it will be transformed into a handle on a concrete loop instantiation by {@link #makeLoop}.
*
* @param init loop-local variable initializers.
* @param step bodies.
* @param pred predicates.
* @param fini finalizers.
* @param varSize number of loop-local variables.
* @param nArgs number of arguments passed to the loop.
* @param args arguments to the loop invocation.
*
* @return the result of executing the loop.
* Intrinsified during LambdaForm compilation
* (see {@link InvokerBytecodeGenerator#emitLoop(int)}).
*/
static Object looper(MethodHandle[] init, MethodHandle[] step, MethodHandle[] pred, MethodHandle[] fini,
int varSize, int nArgs, Object[] args) throws Throwable {
@LambdaForm.Hidden
static Object loop(BasicType[] localTypes, MethodHandle[] init, MethodHandle[] step, MethodHandle[] pred,
MethodHandle[] fini, Object... av) throws Throwable {
int varSize = (int) Stream.of(init).filter(h -> h.type().returnType() != void.class).count();
int nArgs = init[0].type().parameterCount();
Object[] varsAndArgs = new Object[varSize + nArgs];
for (int i = 0, v = 0; i < init.length; ++i) {
if (init[i].type().returnType() == void.class) {
init[i].invoke(args);
init[i].asFixedArity().invokeWithArguments(av);
} else {
varsAndArgs[v++] = init[i].invoke(args);
varsAndArgs[v++] = init[i].asFixedArity().invokeWithArguments(av);
}
}
System.arraycopy(args, 0, varsAndArgs, varSize, nArgs);
System.arraycopy(av, 0, varsAndArgs, varSize, nArgs);
final int nSteps = step.length;
for (; ; ) {
for (int i = 0, v = 0; i < nSteps; ++i) {
@ -1792,12 +1882,12 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
MethodHandle s = step[i];
MethodHandle f = fini[i];
if (s.type().returnType() == void.class) {
s.invoke(varsAndArgs);
s.asFixedArity().invokeWithArguments(varsAndArgs);
} else {
varsAndArgs[v++] = s.invoke(varsAndArgs);
varsAndArgs[v++] = s.asFixedArity().invokeWithArguments(varsAndArgs);
}
if (!(boolean) p.invoke(varsAndArgs)) {
return f.invoke(varsAndArgs);
if (!(boolean) p.asFixedArity().invokeWithArguments(varsAndArgs)) {
return f.asFixedArity().invokeWithArguments(varsAndArgs);
}
}
}
@ -1879,77 +1969,127 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
*
* @param target the target to execute in a {@code try-finally} block.
* @param cleanup the cleanup to execute in the {@code finally} block.
* @param type the result type of the entire construct.
* @param rtype the result type of the entire construct.
* @param argTypes the types of the arguments.
*
* @return a handle on the constructed {@code try-finally} block.
*/
static MethodHandle makeTryFinally(MethodHandle target, MethodHandle cleanup, Class<?> type, List<Class<?>> argTypes) {
MethodHandle tf = getConstantHandle(type == void.class ? MH_tryFinallyVoidExec : MH_tryFinallyExec);
static MethodHandle makeTryFinally(MethodHandle target, MethodHandle cleanup, Class<?> rtype, List<Class<?>> argTypes) {
MethodType type = MethodType.methodType(rtype, argTypes);
LambdaForm form = makeTryFinallyForm(type.basicType());
// Bind the statically known arguments.
tf = MethodHandles.insertArguments(tf, 0, target, cleanup);
// Prepare auxiliary method handles used during LambdaForm interpretation.
// Box arguments and wrap them into Object[]: ValueConversions.array().
MethodType varargsType = type.changeReturnType(Object[].class);
MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
MethodHandle unboxResult = unboxResultHandle(rtype);
// Turn the args array into an argument list.
tf = tf.asCollector(Object[].class, argTypes.size());
// Finally, make try-finally type.
MethodType tfType = MethodType.methodType(type, argTypes);
tf = tf.asType(tfType);
return tf;
BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLL();
BoundMethodHandle mh;
try {
mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) target, (Object) cleanup,
(Object) collectArgs, (Object) unboxResult);
} catch (Throwable ex) {
throw uncaughtException(ex);
}
assert(mh.type() == type);
return mh;
}
/**
* A method that will be bound during construction of a {@code try-finally} handle with non-{@code void} return type
* by {@link MethodHandles#tryFinally(MethodHandle, MethodHandle)}.
*
* @param target the handle to wrap in a {@code try-finally} block. This will be bound.
* @param cleanup the handle to run in any case before returning. This will be bound.
* @param args the arguments to the call. These will remain as the argument list.
*
* @return whatever the execution of the {@code target} returned (it may have been modified by the execution of
* {@code cleanup}).
* @throws Throwable in case anything is thrown by the execution of {@code target}, the {@link Throwable} will be
* passed to the {@code cleanup} handle, which may decide to throw any exception it sees fit.
* The LambdaForm shape for the tryFinally combinator is as follows (assuming one reference parameter passed in
* {@code a1}, and a reference return type, with the return value represented by {@code t8}):
* <blockquote><pre>{@code
* tryFinally=Lambda(a0:L,a1:L)=>{
* t2:L=BoundMethodHandle$Species_LLLL.argL0(a0:L); // target method handle
* t3:L=BoundMethodHandle$Species_LLLL.argL1(a0:L); // cleanup method handle
* t4:L=BoundMethodHandle$Species_LLLL.argL2(a0:L); // helper handle to box the arguments into an Object[]
* t5:L=BoundMethodHandle$Species_LLLL.argL3(a0:L); // helper handle to unbox the result
* t6:L=MethodHandle.invokeBasic(t4:L,a1:L); // box the arguments into an Object[]
* t7:L=MethodHandleImpl.tryFinally(t2:L,t3:L,t6:L); // call the tryFinally executor
* t8:L=MethodHandle.invokeBasic(t5:L,t7:L);t8:L} // unbox the result; return the result
* }</pre></blockquote>
* <p>
* {@code argL0} and {@code argL1} are the target and cleanup method handles.
* {@code argL2} and {@code argL3} are auxiliary method handles: {@code argL2} boxes arguments and wraps them into
* {@code Object[]} ({@code ValueConversions.array()}), and {@code argL3} unboxes the result if necessary
* ({@code ValueConversions.unbox()}).
* <p>
* Having {@code t4} and {@code t5} passed in via a BMH and not hardcoded in the lambda form allows to share lambda
* forms among tryFinally combinators with the same basic type.
*/
static Object tryFinallyExecutor(MethodHandle target, MethodHandle cleanup, Object[] args) throws Throwable {
private static LambdaForm makeTryFinallyForm(MethodType basicType) {
MethodType lambdaType = basicType.invokerType();
LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_TF);
if (lform != null) {
return lform;
}
final int THIS_MH = 0; // the BMH_LLLL
final int ARG_BASE = 1; // start of incoming arguments
final int ARG_LIMIT = ARG_BASE + basicType.parameterCount();
int nameCursor = ARG_LIMIT;
final int GET_TARGET = nameCursor++;
final int GET_CLEANUP = nameCursor++;
final int GET_COLLECT_ARGS = nameCursor++;
final int GET_UNBOX_RESULT = nameCursor++;
final int BOXED_ARGS = nameCursor++;
final int TRY_FINALLY = nameCursor++;
final int UNBOX_RESULT = nameCursor++;
Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType);
BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLL();
names[THIS_MH] = names[THIS_MH].withConstraint(data);
names[GET_TARGET] = new Name(data.getterFunction(0), names[THIS_MH]);
names[GET_CLEANUP] = new Name(data.getterFunction(1), names[THIS_MH]);
names[GET_COLLECT_ARGS] = new Name(data.getterFunction(2), names[THIS_MH]);
names[GET_UNBOX_RESULT] = new Name(data.getterFunction(3), names[THIS_MH]);
// t_{i}:L=MethodHandle.invokeBasic(collectArgs:L,a1:L,...);
MethodType collectArgsType = basicType.changeReturnType(Object.class);
MethodHandle invokeBasic = MethodHandles.basicInvoker(collectArgsType);
Object[] args = new Object[invokeBasic.type().parameterCount()];
args[0] = names[GET_COLLECT_ARGS];
System.arraycopy(names, ARG_BASE, args, 1, ARG_LIMIT-ARG_BASE);
names[BOXED_ARGS] = new Name(makeIntrinsic(invokeBasic, Intrinsic.TRY_FINALLY), args);
// t_{i+1}:L=MethodHandleImpl.tryFinally(target:L,exType:L,catcher:L,t_{i}:L);
Object[] tfArgs = new Object[] {names[GET_TARGET], names[GET_CLEANUP], names[BOXED_ARGS]};
names[TRY_FINALLY] = new Name(NF_tryFinally, tfArgs);
// t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
Object[] unboxArgs = new Object[] {names[GET_UNBOX_RESULT], names[TRY_FINALLY]};
names[UNBOX_RESULT] = new Name(invokeBasicUnbox, unboxArgs);
lform = new LambdaForm("tryFinally", lambdaType.parameterCount(), names);
return basicType.form().setCachedLambdaForm(MethodTypeForm.LF_TF, lform);
}
/**
* Intrinsified during LambdaForm compilation
* (see {@link InvokerBytecodeGenerator#emitTryFinally emitTryFinally}).
*/
@LambdaForm.Hidden
static Object tryFinally(MethodHandle target, MethodHandle cleanup, Object... av) throws Throwable {
Throwable t = null;
Object r = null;
try {
r = target.invoke(args);
// Use asFixedArity() to avoid unnecessary boxing of last argument for VarargsCollector case.
r = target.asFixedArity().invokeWithArguments(av);
} catch (Throwable thrown) {
t = thrown;
throw t;
} finally {
r = cleanup.invoke(t, r, args);
Object[] args = target.type().returnType() == void.class ? prepend(av, t) : prepend(av, t, r);
r = cleanup.asFixedArity().invokeWithArguments(args);
}
return r;
}
/**
* A method that will be bound during construction of a {@code try-finally} handle with {@code void} return type by
* {@link MethodHandles#tryFinally(MethodHandle, MethodHandle)}.
*
* @param target the handle to wrap in a {@code try-finally} block. This will be bound.
* @param cleanup the handle to run in any case before returning. This will be bound.
* @param args the arguments to the call. These will remain as the argument list.
*
* @throws Throwable in case anything is thrown by the execution of {@code target}, the {@link Throwable} will be
* passed to the {@code cleanup} handle, which may decide to throw any exception it sees fit.
*/
static void tryFinallyVoidExecutor(MethodHandle target, MethodHandle cleanup, Object[] args) throws Throwable {
Throwable t = null;
try {
target.invoke(args);
} catch (Throwable thrown) {
t = thrown;
throw t;
} finally {
cleanup.invoke(t, args);
}
}
// Indexes into constant method handles:
static final int
MH_cast = 0,
@ -1958,17 +2098,14 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
MH_fillNewTypedArray = 3,
MH_fillNewArray = 4,
MH_arrayIdentity = 5,
MH_looper = 6,
MH_countedLoopPred = 7,
MH_countedLoopStep = 8,
MH_iteratePred = 9,
MH_initIterator = 10,
MH_iterateNext = 11,
MH_tryFinallyExec = 12,
MH_tryFinallyVoidExec = 13,
MH_decrementCounter = 14,
MH_Array_newInstance = 15,
MH_LIMIT = 16;
MH_countedLoopPred = 6,
MH_countedLoopStep = 7,
MH_iteratePred = 8,
MH_initIterator = 9,
MH_iterateNext = 10,
MH_decrementCounter = 11,
MH_Array_newInstance = 12,
MH_LIMIT = 13;
static MethodHandle getConstantHandle(int idx) {
MethodHandle handle = HANDLES[idx];
@ -2013,10 +2150,6 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
return makeIntrinsic(IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "selectAlternative",
MethodType.methodType(MethodHandle.class, boolean.class, MethodHandle.class, MethodHandle.class)),
Intrinsic.SELECT_ALTERNATIVE);
case MH_looper:
return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "looper", MethodType.methodType(Object.class,
MethodHandle[].class, MethodHandle[].class, MethodHandle[].class, MethodHandle[].class,
int.class, int.class, Object[].class));
case MH_countedLoopPred:
return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "countedLoopPredicate",
MethodType.methodType(boolean.class, int.class, int.class));
@ -2032,12 +2165,6 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
case MH_iterateNext:
return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "iterateNext",
MethodType.methodType(Object.class, Iterator.class));
case MH_tryFinallyExec:
return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "tryFinallyExecutor",
MethodType.methodType(Object.class, MethodHandle.class, MethodHandle.class, Object[].class));
case MH_tryFinallyVoidExec:
return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "tryFinallyVoidExecutor",
MethodType.methodType(void.class, MethodHandle.class, MethodHandle.class, Object[].class));
case MH_decrementCounter:
return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "decrementCounter",
MethodType.methodType(int.class, int.class));

View File

@ -4233,7 +4233,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
assert Stream.of(fstep, fpred, ffini).flatMap(List::stream).map(MethodHandle::type).map(MethodType::parameterList).
allMatch(pl -> pl.equals(commonParameterSequence));
return MethodHandleImpl.makeLoop(loopReturnType, commonSuffix, commonPrefix, finit, fstep, fpred, ffini);
return MethodHandleImpl.makeLoop(loopReturnType, commonSuffix, finit, fstep, fpred, ffini);
}
private static List<MethodHandle> fillParameterTypes(List<MethodHandle> hs, final List<Class<?>> targetParams) {
@ -4740,10 +4740,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
// The cleanup parameter list (minus the leading Throwable and result parameters) must be a sublist of the
// target parameter list.
cleanup = dropArgumentsToMatch(cleanup, (rtype == void.class ? 1 : 2), targetParamTypes, 0);
MethodHandle aTarget = target.asSpreader(Object[].class, target.type().parameterCount());
MethodHandle aCleanup = cleanup.asSpreader(Object[].class, targetParamTypes.size());
return MethodHandleImpl.makeTryFinally(aTarget, aCleanup, rtype, targetParamTypes);
return MethodHandleImpl.makeTryFinally(target, cleanup, rtype, targetParamTypes);
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@ -27,8 +27,10 @@ package java.lang.invoke;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.util.Wrapper;
import java.lang.ref.SoftReference;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandleStatics.newIllegalArgumentException;
/**
* Shared information for a group of method types, which differ
@ -81,7 +83,9 @@ final class MethodTypeForm {
LF_MH_LINKER = 15, // linkToCallSite_MH
LF_GWC = 16, // guardWithCatch (catchException)
LF_GWT = 17, // guardWithTest
LF_LIMIT = 18;
LF_TF = 18, // tryFinally
LF_LOOP = 19, // loop
LF_LIMIT = 20;
/** Return the type corresponding uniquely (1-1) to this MT-form.
* It might have any primitive returns or arguments, but will have no references except Object.

View File

@ -1275,8 +1275,6 @@ public abstract class VarHandle {
this.methodName = methodName;
this.at = at;
// Assert method name is correctly derived from value name
assert methodName.equals(toMethodName(name()));
// Assert that return type is correct
// Otherwise, when disabled avoid using reflection
assert at.returnType == getReturnType(methodName);
@ -1311,16 +1309,6 @@ public abstract class VarHandle {
throw new IllegalArgumentException("No AccessMode value for method name " + methodName);
}
private static String toMethodName(String name) {
StringBuilder s = new StringBuilder(name.toLowerCase());
int i;
while ((i = s.indexOf("_")) != -1) {
s.deleteCharAt(i);
s.setCharAt(i, Character.toUpperCase(s.charAt(i)));
}
return s.toString();
}
private static Class<?> getReturnType(String name) {
try {
Method m = VarHandle.class.getMethod(name, Object[].class);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -60,9 +60,10 @@ import java.util.Date;
* This Certificate interface is entirely deprecated and
* is here to allow for a smooth transition to the new
* package.
* This class is subject to removal in a future version of Java SE.
* @see java.security.cert.Certificate
*/
@Deprecated
@Deprecated(since="1.2", forRemoval=true)
public interface Certificate {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -52,11 +52,12 @@ import java.util.*;
*
* @author Benjamin Renaud
* @deprecated This class is no longer used. Its functionality has been
* replaced by {@code java.security.KeyStore}, the
* {@code java.security.cert} package, and
* {@code java.security.Principal}.
* replaced by {@link java.security.KeyStore}, the
* {@link java.security.cert} package, and
* {@link java.security.Principal}.
* This class is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="1.2", forRemoval=true)
public abstract class Identity implements Principal, Serializable {
/** use serialVersionUID from JDK 1.1.x for interoperability */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -57,11 +57,15 @@ import java.util.Properties;
* @author Benjamin Renaud
*
* @deprecated This class is no longer used. Its functionality has been
* replaced by {@code java.security.KeyStore}, the
* {@code java.security.cert} package, and
* {@code java.security.Principal}.
* replaced by {@link java.security.KeyStore}, the
* {@link java.security.cert} package, and
* {@link java.security.Principal}.
* This class is subject to removal in a future version of Java SE.
*
* Note that the security property {@code policy.ignoreIdentityScope}
* is only applicable to these APIs and is also a candidate for removal.
*/
@Deprecated
@Deprecated(since="1.2", forRemoval=true)
public abstract
class IdentityScope extends Identity {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -40,11 +40,12 @@ import java.io.*;
* @author Benjamin Renaud
*
* @deprecated This class is no longer used. Its functionality has been
* replaced by {@code java.security.KeyStore}, the
* {@code java.security.cert} package, and
* {@code java.security.Principal}.
* replaced by {@link java.security.KeyStore}, the
* {@link java.security.cert} package, and
* {@link java.security.Principal}.
* This class is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="1.2", forRemoval=true)
public abstract class Signer extends Identity {
private static final long serialVersionUID = -1763464102261361480L;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -85,9 +85,10 @@ import java.security.Principal;
*
* @deprecated This package has been replaced by {@code java.security.Policy}
* and related classes since 1.2.
* This class is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="9", forRemoval=true)
public interface Acl extends Owner {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -53,8 +53,9 @@ import java.security.Principal;
*
* @deprecated This package has been replaced by {@code java.security.Policy}
* and related classes since 1.2.
* This class is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="9", forRemoval=true)
public interface AclEntry extends Cloneable {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -33,8 +33,9 @@ package java.security.acl;
*
* @deprecated This package has been replaced by {@code java.security.Policy}
* and related classes since 1.2.
* This class is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="9", forRemoval=true)
public class AclNotFoundException extends Exception {
private static final long serialVersionUID = 5684295034092681791L;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -42,8 +42,9 @@ import java.security.Principal;
*
* @deprecated This package has been replaced by {@code java.security.Policy}
* and related classes since 1.2.
* This class is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="9", forRemoval=true)
public interface Group extends Principal {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -35,8 +35,9 @@ package java.security.acl;
*
* @deprecated This package has been replaced by {@code java.security.Policy}
* and related classes since 1.2.
* This class is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="9", forRemoval=true)
public class LastOwnerException extends Exception {
private static final long serialVersionUID = -5141997548211140359L;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -34,8 +34,9 @@ package java.security.acl;
*
* @deprecated This package has been replaced by {@code java.security.Policy}
* and related classes since 1.2.
* This class is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="9", forRemoval=true)
public class NotOwnerException extends Exception {
private static final long serialVersionUID = -5555597911163362399L;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -38,8 +38,9 @@ import java.security.Principal;
*
* @deprecated This package has been replaced by {@code java.security.Policy}
* and related classes since 1.2.
* This class is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="9", forRemoval=true)
public interface Owner {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -34,8 +34,9 @@ package java.security.acl;
*
* @deprecated This package has been replaced by {@code java.security.Policy}
* and related classes since 1.2.
* This class is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="9", forRemoval=true)
public interface Permission {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* 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
@ -27,7 +27,8 @@
* The classes and interfaces in this package have been deprecated. New
* classes should not be added to this package. The {@code java.security}
* package contains suitable replacements. See {@link java.security.Policy}
* and related classes for details.
* and related classes for details. This package is subject to removal in a
* future version of Java SE.
*
* @since 1.1
*/

View File

@ -221,7 +221,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* </ul>
* The zone ID is <em>not</em> localized; it's one of the valid IDs of
* the {@link java.util.TimeZone TimeZone} class that are not
* <a href="../java/util/TimeZone.html#CustomID">custom IDs</a>.
* <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
* All other entries are localized names.
* @see java.util.TimeZone
* @serial

View File

@ -561,7 +561,6 @@ public final class Instant
case NANO_OF_SECOND: return nanos;
case MICRO_OF_SECOND: return nanos / 1000;
case MILLI_OF_SECOND: return nanos / 1000_000;
case INSTANT_SECONDS: INSTANT_SECONDS.checkValidIntValue(seconds);
}
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
}

View File

@ -295,13 +295,13 @@ class ZipFile implements ZipConstants, Closeable {
* @throws IllegalStateException if the zip file has been closed
*/
public ZipEntry getEntry(String name) {
Objects.requireNonNull(name, "name");
synchronized (this) {
ensureOpen();
int pos = zsrc.getEntryPos(zc.getBytes(name), true);
byte[] bname = zc.getBytes(name);
int pos = zsrc.getEntryPos(bname, true);
if (pos != -1) {
return getZipEntry(name, pos);
return getZipEntry(name, bname, pos);
}
}
return null;
@ -492,7 +492,7 @@ class ZipFile implements ZipConstants, Closeable {
throw new NoSuchElementException();
}
// each "entry" has 3 ints in table entries
return getZipEntry(null, zsrc.getEntryPos(i++ * 3));
return getZipEntry(null, null, zsrc.getEntryPos(i++ * 3));
}
}
@ -527,13 +527,17 @@ class ZipFile implements ZipConstants, Closeable {
}
/* Checks ensureOpen() before invoke this method */
private ZipEntry getZipEntry(String name, int pos) {
private ZipEntry getZipEntry(String name, byte[] bname, int pos) {
byte[] cen = zsrc.cen;
int nlen = CENNAM(cen, pos);
int elen = CENEXT(cen, pos);
int clen = CENCOM(cen, pos);
int flag = CENFLG(cen, pos);
if (name == null) {
if (name == null || bname.length != nlen) {
// to use the entry name stored in cen, if the passed in name is
// (1) null, invoked from iterator, or
// (2) not equal to the name stored, a slash is appended during
// getEntryPos() search.
if (!zc.isUTF8() && (flag & EFS) != 0) {
name = zc.toStringUTF8(cen, pos + CENHDR, nlen);
} else {

View File

@ -93,7 +93,7 @@ import sun.security.jca.*;
* provide authenticity assurances for both confidential data and
* Additional Associated Data (AAD) that is not encrypted. (Please see
* <a href="http://www.ietf.org/rfc/rfc5116.txt"> RFC 5116 </a> for more
* information on AEAD and AEAD algorithms such as GCM/CCM.) Both
* information on AEAD and AAD algorithms such as GCM/CCM.) Both
* confidential and AAD data can be used when calculating the
* authentication tag (similar to a {@link Mac}). This tag is appended
* to the ciphertext during encryption, and is verified on decryption.
@ -1186,7 +1186,7 @@ public class Cipher {
* determined from the given key, or if the given key has a keysize that
* exceeds the maximum allowable keysize (as determined from the
* configured jurisdiction policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1239,7 +1239,7 @@ public class Cipher {
* determined from the given key, or if the given key has a keysize that
* exceeds the maximum allowable keysize (as determined from the
* configured jurisdiction policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1325,7 +1325,7 @@ public class Cipher {
* algorithm parameters imply a cryptographic strength that would exceed
* the legal limits (as determined from the configured jurisdiction
* policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1386,7 +1386,7 @@ public class Cipher {
* algorithm parameters imply a cryptographic strength that would exceed
* the legal limits (as determined from the configured jurisdiction
* policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1468,7 +1468,7 @@ public class Cipher {
* algorithm parameters imply a cryptographic strength that would exceed
* the legal limits (as determined from the configured jurisdiction
* policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1529,7 +1529,7 @@ public class Cipher {
* algorithm parameters imply a cryptographic strength that would exceed
* the legal limits (as determined from the configured jurisdiction
* policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1616,7 +1616,7 @@ public class Cipher {
* in the given certificate has a keysize that exceeds the maximum
* allowable keysize (as determined by the configured jurisdiction policy
* files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1686,7 +1686,7 @@ public class Cipher {
* in the given certificate has a keysize that exceeds the maximum
* allowable keysize (as determined by the configured jurisdiction policy
* files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/

View File

@ -318,24 +318,6 @@ public final class Unsafe {
*/
public native Object getUncompressedObject(long address);
/**
* Fetches the {@link java.lang.Class} Java mirror for the given native
* metaspace {@code Klass} pointer.
*
* @param metaspaceKlass a native metaspace {@code Klass} pointer
* @return the {@link java.lang.Class} Java mirror
*/
public native Class<?> getJavaMirror(long metaspaceKlass);
/**
* Fetches a native metaspace {@code Klass} pointer for the given Java
* object.
*
* @param o Java heap object for which to fetch the class pointer
* @return a native metaspace {@code Klass} pointer
*/
public native long getKlassPointer(Object o);
// These work on values in the C heap.
/**

View File

@ -222,7 +222,8 @@ public class JarIndex {
// Any files in META-INF/ will be indexed explicitly
if (fileName.equals("META-INF/") ||
fileName.equals(INDEX_NAME) ||
fileName.equals(JarFile.MANIFEST_NAME))
fileName.equals(JarFile.MANIFEST_NAME) ||
fileName.startsWith("META-INF/versions/"))
continue;
if (!metaInfFilenames || !fileName.startsWith("META-INF/")) {

View File

@ -584,15 +584,17 @@ public final class LauncherHelper {
Class<?> mainClass = null;
ClassLoader scl = ClassLoader.getSystemClassLoader();
try {
mainClass = scl.loadClass(cn);
mainClass = Class.forName(cn, false, scl);
} catch (NoClassDefFoundError | ClassNotFoundException cnfe) {
if (System.getProperty("os.name", "").contains("OS X")
&& Normalizer.isNormalized(cn, Normalizer.Form.NFD)) {
try {
// On Mac OS X since all names with diacretic symbols are given as decomposed it
// is possible that main class name comes incorrectly from the command line
// and we have to re-compose it
mainClass = scl.loadClass(Normalizer.normalize(cn, Normalizer.Form.NFC));
// On Mac OS X since all names with diacretic symbols are
// given as decomposed it is possible that main class name
// comes incorrectly from the command line and we have
// to re-compose it
String ncn = Normalizer.normalize(cn, Normalizer.Form.NFC);
mainClass = Class.forName(ncn, false, scl);
} catch (NoClassDefFoundError | ClassNotFoundException cnfe1) {
abort(cnfe, "java.launcher.cls.error1", cn);
}

View File

@ -60,6 +60,9 @@ java.launcher.opt.footer =\ -cp <class search path of directories and zip
\ limit the universe of observable modules\n\
\ -listmods[:<modulename>[,<modulename>...]]\n\
\ list the observable modules and exit\n\
\ --dry-run create VM but do not execute main method.\n\
\ This --dry-run option may be useful for validating the\n\
\ command-line options such as the module system configuration.\n\
\ -D<name>=<value>\n\
\ set a system property\n\
\ -verbose:[class|gc|jni]\n\
@ -138,7 +141,7 @@ java.launcher.X.macosx.usage=\
The following options are Mac OS X specific:\n\
\ -XstartOnFirstThread\n\
\ run the main() method on the first (AppKit) thread\n\
\ -Xdock:name=<application name>"\n\
\ -Xdock:name=<application name>\n\
\ override default application name displayed in dock\n\
\ -Xdock:icon=<path to icon file>\n\
\ override default icon displayed in dock\n\n

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@ -97,10 +97,11 @@ final class StatusResponseManager {
t.setDaemon(true);
return t;
}
});
}, new ThreadPoolExecutor.DiscardPolicy());
threadMgr.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
threadMgr.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
threadMgr.setKeepAliveTime(5000, TimeUnit.MILLISECONDS);
threadMgr.allowCoreThreadTimeOut(true);
responseCache = Cache.newSoftMemoryCache(cacheCapacity, cacheLifetime);
}

View File

@ -72,7 +72,53 @@ import sun.util.resources.OpenListResourceBundle;
public class JavaTimeSupplementary extends OpenListResourceBundle {
@Override
protected final Object[][] getContents() {
final String[] rocMonthNarrows = {
final String[] sharedQuarterNames = {
"Q1",
"Q2",
"Q3",
"Q4",
};
final String[] sharedQuarterNarrows = {
"1",
"2",
"3",
"4",
};
final String[] sharedDatePatterns = {
"GGGG y MMMM d, EEEE",
"GGGG y MMMM d",
"GGGG y MMM d",
"G y-MM-dd",
};
final String[] sharedDayNames = {
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
};
final String[] sharedDayNarrows = {
"S",
"M",
"T",
"W",
"T",
"F",
"S",
};
final String[] sharedEras = {
"",
"AH",
};
final String[] sharedMonthNarrows = {
"1",
"2",
"3",
@ -87,31 +133,62 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
"12",
"",
};
final String[] sharedTimePatterns = {
"HH:mm:ss zzzz",
"HH:mm:ss z",
"HH:mm:ss",
"HH:mm",
};
final String[] sharedAmPmMarkers = {
"AM",
"PM",
};
final String[] sharedJavaTimeDatePatterns = {
"G y MMMM d, EEEE",
"G y MMMM d",
"G y MMM d",
"GGGGG y-MM-dd",
};
final String[] sharedJavaTimeLongEras = {
"",
"Meiji",
"Taisho",
"Showa",
"Heisei",
};
final String[] sharedShortEras = {
"Before R.O.C.",
"R.O.C.",
};
final String[] sharedMonthNames = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"",
};
return new Object[][] {
{ "QuarterAbbreviations",
new String[] {
"Q1",
"Q2",
"Q3",
"Q4",
}
},
sharedQuarterNames },
{ "QuarterNames",
new String[] {
"Q1",
"Q2",
"Q3",
"Q4",
}
},
sharedQuarterNames },
{ "QuarterNarrows",
new String[] {
"1",
"2",
"3",
"4",
}
},
sharedQuarterNarrows },
{ "field.dayperiod",
"Dayperiod" },
{ "field.era",
@ -133,52 +210,15 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
{ "field.zone",
"Zone" },
{ "islamic.DatePatterns",
new String[] {
"GGGG y MMMM d, EEEE",
"GGGG y MMMM d",
"GGGG y MMM d",
"G y-MM-dd",
}
},
sharedDatePatterns },
{ "islamic.DayAbbreviations",
new String[] {
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
}
},
sharedDayNames },
{ "islamic.DayNames",
new String[] {
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
}
},
sharedDayNames },
{ "islamic.DayNarrows",
new String[] {
"S",
"M",
"T",
"W",
"T",
"F",
"S",
}
},
sharedDayNarrows },
{ "islamic.Eras",
new String[] {
"",
"AH",
}
},
sharedEras },
{ "islamic.MonthAbbreviations",
new String[] {
"Muh.",
@ -214,63 +254,23 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
}
},
{ "islamic.MonthNarrows",
rocMonthNarrows },
sharedMonthNarrows },
{ "islamic.QuarterNames",
new String[] {
"Q1",
"Q2",
"Q3",
"Q4",
}
},
sharedQuarterNames },
{ "islamic.QuarterNarrows",
new String[] {
"1",
"2",
"3",
"4",
}
},
sharedQuarterNarrows },
{ "islamic.TimePatterns",
new String[] {
"HH:mm:ss zzzz",
"HH:mm:ss z",
"HH:mm:ss",
"HH:mm",
}
},
sharedTimePatterns },
{ "islamic.abbreviated.AmPmMarkers",
new String[] {
"AM",
"PM",
}
},
sharedAmPmMarkers },
{ "islamic.long.Eras",
new String[] {
"",
"AH",
}
},
sharedEras },
{ "islamic.narrow.Eras",
new String[] {
"",
"AH",
}
},
sharedEras },
{ "islamic.short.Eras",
new String[] {
"",
"AH",
}
},
sharedEras },
{ "java.time.buddhist.DatePatterns",
new String[] {
"G y MMMM d, EEEE",
"G y MMMM d",
"G y MMM d",
"GGGGG y-MM-dd",
}
},
sharedJavaTimeDatePatterns },
{ "java.time.buddhist.long.Eras",
new String[] {
"BC",
@ -284,13 +284,7 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
}
},
{ "java.time.islamic.DatePatterns",
new String[] {
"G y MMMM d, EEEE",
"G y MMMM d",
"G y MMM d",
"GGGGG y-MM-dd",
}
},
sharedJavaTimeDatePatterns },
{ "java.time.japanese.DatePatterns",
new String[] {
"G y MMMM d (EEEE)",
@ -300,23 +294,9 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
}
},
{ "java.time.japanese.long.Eras",
new String[] {
"",
"Meiji",
"Taisho",
"Showa",
"Heisei",
}
},
sharedJavaTimeLongEras },
{ "java.time.japanese.short.Eras",
new String[] {
"",
"Meiji",
"Taisho",
"Showa",
"Heisei",
}
},
sharedJavaTimeLongEras },
{ "java.time.long.Eras",
new String[] {
"BCE",
@ -324,13 +304,7 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
}
},
{ "java.time.roc.DatePatterns",
new String[] {
"G y MMMM d, EEEE",
"G y MMMM d",
"G y MMM d",
"GGGGG y-MM-dd",
}
},
sharedJavaTimeDatePatterns },
{ "java.time.short.Eras",
new String[] {
"BC",
@ -338,137 +312,37 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
}
},
{ "roc.AmPmMarkers",
new String[] {
"AM",
"PM",
}
},
sharedAmPmMarkers },
{ "roc.DatePatterns",
new String[] {
"GGGG y MMMM d, EEEE",
"GGGG y MMMM d",
"GGGG y MMM d",
"G y-MM-dd",
}
},
sharedDatePatterns },
{ "roc.DayNames",
new String[] {
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
}
},
sharedDayNames },
{ "roc.DayNarrows",
new String[] {
"S",
"M",
"T",
"W",
"T",
"F",
"S",
}
},
sharedDayNarrows },
{ "roc.Eras",
new String[] {
"Before R.O.C.",
"R.O.C.",
}
},
sharedShortEras },
{ "roc.MonthAbbreviations",
new String[] {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"",
}
},
sharedMonthNames },
{ "roc.MonthNames",
new String[] {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"",
}
},
sharedMonthNames },
{ "roc.MonthNarrows",
rocMonthNarrows },
sharedMonthNarrows },
{ "roc.QuarterNames",
new String[] {
"Q1",
"Q2",
"Q3",
"Q4",
}
},
sharedQuarterNames },
{ "roc.QuarterNarrows",
new String[] {
"1",
"2",
"3",
"4",
}
},
sharedQuarterNarrows },
{ "roc.TimePatterns",
new String[] {
"HH:mm:ss zzzz",
"HH:mm:ss z",
"HH:mm:ss",
"HH:mm",
}
},
sharedTimePatterns },
{ "roc.abbreviated.AmPmMarkers",
new String[] {
"AM",
"PM",
}
},
sharedAmPmMarkers },
{ "roc.long.Eras",
new String[] {
"Before R.O.C.",
"R.O.C.",
}
},
sharedShortEras },
{ "roc.narrow.AmPmMarkers",
new String[] {
"AM",
"PM",
}
},
sharedAmPmMarkers },
{ "roc.narrow.Eras",
new String[] {
"Before R.O.C.",
"R.O.C.",
}
},
sharedShortEras },
{ "roc.short.Eras",
new String[] {
"Before R.O.C.",
"R.O.C.",
}
},
sharedShortEras },
};
}
}

View File

@ -72,15 +72,64 @@ import sun.util.resources.OpenListResourceBundle;
public class JavaTimeSupplementary_en extends OpenListResourceBundle {
@Override
protected final Object[][] getContents() {
final String[] sharedQuarterNames = {
"1st quarter",
"2nd quarter",
"3rd quarter",
"4th quarter",
};
final String[] sharedDatePatterns = {
"EEEE, MMMM d, y GGGG",
"MMMM d, y GGGG",
"MMM d, y GGGG",
"M/d/y G",
};
final String[] sharedDayNames = {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
};
final String[] sharedQuarterAbbreviations = {
"Q1",
"Q2",
"Q3",
"Q4",
};
final String[] sharedTimePatterns = {
"h:mm:ss a zzzz",
"h:mm:ss a z",
"h:mm:ss a",
"h:mm a",
};
final String[] sharedNarrowAmPmMarkers = {
"a",
"p",
};
final String[] sharedJavaTimeDatePatterns = {
"EEEE, MMMM d, y G",
"MMMM d, y G",
"MMM d, y G",
"M/d/y GGGGG",
};
final String[] sharedEras = {
"Before R.O.C.",
"Minguo",
};
return new Object[][] {
{ "QuarterNames",
new String[] {
"1st quarter",
"2nd quarter",
"3rd quarter",
"4th quarter",
}
},
sharedQuarterNames },
{ "calendarname.buddhist",
"Buddhist Calendar" },
{ "calendarname.gregorian",
@ -124,62 +173,19 @@ public class JavaTimeSupplementary_en extends OpenListResourceBundle {
}
},
{ "islamic.DatePatterns",
new String[] {
"EEEE, MMMM d, y GGGG",
"MMMM d, y GGGG",
"MMM d, y GGGG",
"M/d/y G",
}
},
sharedDatePatterns },
{ "islamic.DayNames",
new String[] {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
}
},
sharedDayNames },
{ "islamic.QuarterAbbreviations",
new String[] {
"Q1",
"Q2",
"Q3",
"Q4",
}
},
sharedQuarterAbbreviations },
{ "islamic.QuarterNames",
new String[] {
"1st quarter",
"2nd quarter",
"3rd quarter",
"4th quarter",
}
},
sharedQuarterNames },
{ "islamic.TimePatterns",
new String[] {
"h:mm:ss a zzzz",
"h:mm:ss a z",
"h:mm:ss a",
"h:mm a",
}
},
sharedTimePatterns },
{ "islamic.narrow.AmPmMarkers",
new String[] {
"a",
"p",
}
},
sharedNarrowAmPmMarkers },
{ "java.time.buddhist.DatePatterns",
new String[] {
"EEEE, MMMM d, y G",
"MMMM d, y G",
"MMM d, y G",
"M/d/y GGGGG",
}
},
sharedJavaTimeDatePatterns },
{ "java.time.buddhist.short.Eras",
new String[] {
"BC",
@ -187,21 +193,9 @@ public class JavaTimeSupplementary_en extends OpenListResourceBundle {
}
},
{ "java.time.islamic.DatePatterns",
new String[] {
"EEEE, MMMM d, y G",
"MMMM d, y G",
"MMM d, y G",
"M/d/y GGGGG",
}
},
sharedJavaTimeDatePatterns },
{ "java.time.japanese.DatePatterns",
new String[] {
"EEEE, MMMM d, y G",
"MMMM d, y G",
"MMM d, y G",
"M/d/y GGGGG",
}
},
sharedJavaTimeDatePatterns },
{ "java.time.long.Eras",
new String[] {
"Before Christ",
@ -209,21 +203,9 @@ public class JavaTimeSupplementary_en extends OpenListResourceBundle {
}
},
{ "java.time.roc.DatePatterns",
new String[] {
"EEEE, MMMM d, y G",
"MMMM d, y G",
"MMM d, y G",
"M/d/y GGGGG",
}
},
sharedJavaTimeDatePatterns },
{ "roc.DatePatterns",
new String[] {
"EEEE, MMMM d, y GGGG",
"MMMM d, y GGGG",
"MMM d, y GGGG",
"M/d/y G",
}
},
sharedDatePatterns },
{ "roc.DayAbbreviations",
new String[] {
"Sun",
@ -236,22 +218,9 @@ public class JavaTimeSupplementary_en extends OpenListResourceBundle {
}
},
{ "roc.DayNames",
new String[] {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
}
},
sharedDayNames },
{ "roc.Eras",
new String[] {
"Before R.O.C.",
"Minguo",
}
},
sharedEras },
{ "roc.MonthNames",
new String[] {
"January",
@ -287,53 +256,19 @@ public class JavaTimeSupplementary_en extends OpenListResourceBundle {
}
},
{ "roc.QuarterAbbreviations",
new String[] {
"Q1",
"Q2",
"Q3",
"Q4",
}
},
sharedQuarterAbbreviations },
{ "roc.QuarterNames",
new String[] {
"1st quarter",
"2nd quarter",
"3rd quarter",
"4th quarter",
}
},
sharedQuarterNames },
{ "roc.TimePatterns",
new String[] {
"h:mm:ss a zzzz",
"h:mm:ss a z",
"h:mm:ss a",
"h:mm a",
}
},
sharedTimePatterns },
{ "roc.long.Eras",
new String[] {
"Before R.O.C.",
"Minguo",
}
},
sharedEras },
{ "roc.narrow.AmPmMarkers",
new String[] {
"a",
"p",
}
},
sharedNarrowAmPmMarkers },
{ "roc.narrow.Eras",
new String[] {
"Before R.O.C.",
"Minguo",
}
},
sharedEras },
{ "roc.short.Eras",
new String[] {
"Before R.O.C.",
"Minguo",
}
},
sharedEras },
};
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -228,6 +228,9 @@ public class LocaleData {
private static class LocaleDataStrategy implements Bundles.Strategy {
private static final LocaleDataStrategy INSTANCE = new LocaleDataStrategy();
// TODO: avoid hard-coded Locales
private static Set<Locale> JAVA_BASE_LOCALES
= Set.of(Locale.ROOT, Locale.ENGLISH, Locale.US, new Locale("en", "US", "POSIX"));
private LocaleDataStrategy() {
}
@ -275,11 +278,7 @@ public class LocaleData {
}
boolean inJavaBaseModule(String baseName, Locale locale) {
// TODO: avoid hard-coded Locales
return locale.equals(Locale.ROOT) ||
(locale.getLanguage() == "en" &&
(locale.getCountry().isEmpty() ||
locale.getCountry() == "US"));
return JAVA_BASE_LOCALES.contains(locale);
}
@Override
@ -313,6 +312,9 @@ public class LocaleData {
private static class SupplementaryStrategy extends LocaleDataStrategy {
private static final SupplementaryStrategy INSTANCE
= new SupplementaryStrategy();
// TODO: avoid hard-coded Locales
private static Set<Locale> JAVA_BASE_LOCALES
= Set.of(Locale.ROOT, Locale.ENGLISH, Locale.US);
private SupplementaryStrategy() {
}
@ -332,8 +334,7 @@ public class LocaleData {
@Override
boolean inJavaBaseModule(String baseName, Locale locale) {
// TODO: avoid hard-coded Locales
return locale.equals(Locale.ROOT) || locale.getLanguage() == "en";
return JAVA_BASE_LOCALES.contains(locale);
}
}
}

View File

@ -116,15 +116,7 @@ security.provider.tbd=SunPKCS11
# Example:
# jdk.security.provider.preferred=AES/GCM/NoPadding:SunJCE, \
# MessageDigest.SHA-256:SUN, Group.HmacSHA2:SunJCE
#ifdef solaris-sparc
jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, \
HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE
#endif
#ifdef solaris-x86
jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, \
HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE, RSA:SunRsaSign, \
SHA1withRSA:SunRsaSign, Group.SHA2RSA:SunRsaSign
#endif
#jdk.security.provider.preferred=
#

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -147,9 +147,9 @@ JNU_ThrowInstantiationException(JNIEnv *env, const char *msg)
JNU_ThrowByName(env, "java/lang/InstantiationException", msg);
}
/* Throw an exception by name, using the string returned by
* JVM_LastErrorString for the detail string. If the last-error
/*
* Throw an exception by name, using the string returned by
* getLastErrorString for the detail string. If the last-error
* string is NULL, use the given default detail string.
*/
JNIEXPORT void JNICALL
@ -174,9 +174,64 @@ JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name,
}
}
/* Throw an IOException, using the last-error string for the detail
* string. If the last-error string is NULL, use the given default
* detail string.
/*
* Throw an exception by name, using a given message and the string
* returned by getLastErrorString to construct the detail string.
*/
JNIEXPORT void JNICALL
JNU_ThrowByNameWithMessageAndLastError
(JNIEnv *env, const char *name, const char *message)
{
char buf[256];
size_t n = getLastErrorString(buf, sizeof(buf));
size_t messagelen = message == NULL ? 0 : strlen(message);
if (n > 0) {
jstring s = JNU_NewStringPlatform(env, buf);
if (s != NULL) {
jobject x = NULL;
if (messagelen) {
jstring s2 = NULL;
size_t messageextlen = messagelen + 4;
char *str1 = (char *)malloc((messageextlen) * sizeof(char));
if (str1 == 0) {
JNU_ThrowOutOfMemoryError(env, 0);
return;
}
jio_snprintf(str1, messageextlen, " (%s)", message);
s2 = (*env)->NewStringUTF(env, str1);
free(str1);
if (s2 != NULL) {
jstring s3 = JNU_CallMethodByName(
env, NULL, s, "concat",
"(Ljava/lang/String;)Ljava/lang/String;",
s2).l;
(*env)->DeleteLocalRef(env, s2);
if (s3 != NULL) {
(*env)->DeleteLocalRef(env, s);
s = s3;
}
}
}
x = JNU_NewObjectByName(env, name, "(Ljava/lang/String;)V", s);
if (x != NULL) {
(*env)->Throw(env, x);
}
}
}
if (!(*env)->ExceptionOccurred(env)) {
if (messagelen) {
JNU_ThrowByName(env, name, message);
} else {
JNU_ThrowByName(env, name, "no further information");
}
}
}
/*
* Convenience method.
* Call JNU_ThrowByNameWithLastError for java.io.IOException.
*/
JNIEXPORT void JNICALL
JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -98,15 +98,22 @@ JNIEXPORT void JNICALL
JNU_ThrowInstantiationException(JNIEnv *env, const char *msg);
/* Throw an exception by name, using the string returned by
* JVM_LastErrorString for the detail string. If the last-error
* getLastErrorString for the detail string. If the last-error
* string is NULL, use the given default detail string.
*/
JNIEXPORT void JNICALL
JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name,
const char *defaultMessage);
const char *defaultDetail);
/* Throw an exception by name, using a given message and the string
* returned by getLastErrorString to construct the detail string.
*/
JNIEXPORT void JNICALL
JNU_ThrowByNameWithMessageAndLastError
(JNIEnv *env, const char *name, const char *message);
/* Throw an IOException, using the last-error string for the detail
* string. If the last-error string is NULL, use the given default
* string. If the last-error string is NULL, use the given default
* detail string.
*/
JNIEXPORT void JNICALL

View File

@ -68,6 +68,7 @@ static jboolean printVersion = JNI_FALSE; /* print and exit */
static jboolean showVersion = JNI_FALSE; /* print but continue */
static jboolean printUsage = JNI_FALSE; /* print and exit*/
static jboolean printXUsage = JNI_FALSE; /* print and exit*/
static jboolean dryRun = JNI_FALSE; /* initialize VM and exit */
static char *showSettings = NULL; /* print but continue */
static char *listModules = NULL;
@ -434,7 +435,8 @@ JavaMain(void * _args)
ret = 1;
/*
* Get the application's main class.
* Get the application's main class. It also checks if the main
* method exists.
*
* See bugid 5030265. The Main-Class name has already been parsed
* from the manifest, but not parsed properly for UTF-8 support.
@ -466,6 +468,16 @@ JavaMain(void * _args)
*/
appClass = GetApplicationClass(env);
NULL_CHECK_RETURN_VALUE(appClass, -1);
/* Build platform specific argument array */
mainArgs = CreateApplicationArgs(env, argv, argc);
CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
if (dryRun) {
ret = 0;
LEAVE();
}
/*
* PostJVMInit uses the class name as the application name for GUI purposes,
* for example, on OSX this sets the application name in the menu bar for
@ -475,6 +487,7 @@ JavaMain(void * _args)
*/
PostJVMInit(env, appClass, vm);
CHECK_EXCEPTION_LEAVE(1);
/*
* The LoadMainClass not only loads the main class, it will also ensure
* that the main method's signature is correct, therefore further checking
@ -485,10 +498,6 @@ JavaMain(void * _args)
"([Ljava/lang/String;)V");
CHECK_EXCEPTION_NULL_LEAVE(mainID);
/* Build platform specific argument array */
mainArgs = CreateApplicationArgs(env, argv, argc);
CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
/* Invoke main method. */
(*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
@ -497,6 +506,7 @@ JavaMain(void * _args)
* System.exit) will be non-zero if main threw an exception.
*/
ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
LEAVE();
}
@ -1203,6 +1213,8 @@ ParseArguments(int *pargc, char ***pargv,
return JNI_TRUE;
} else if (JLI_StrCmp(arg, "-showversion") == 0) {
showVersion = JNI_TRUE;
} else if (JLI_StrCmp(arg, "--dry-run") == 0) {
dryRun = JNI_TRUE;
} else if (JLI_StrCmp(arg, "-X") == 0) {
printXUsage = JNI_TRUE;
return JNI_TRUE;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@ -88,8 +88,7 @@ public class SolarisFileSystemProvider extends UnixFileSystemProvider {
GetPropertyAction.privilegedGetProperty("user.home"), ".mime.types");
Path etcMimeTypes = Paths.get("/etc/mime.types");
return chain(new GioFileTypeDetector(),
new MimeTypesFileTypeDetector(userMimeTypes),
return chain(new MimeTypesFileTypeDetector(userMimeTypes),
new MimeTypesFileTypeDetector(etcMimeTypes));
}
}

View File

@ -621,8 +621,8 @@ static int getFlags0(JNIEnv *env, jstring name) {
(*env)->ReleaseStringUTFChars(env, name, name_utf);
if (ret < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFFLAGS failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "getFlags() failed");
return -1;
}
@ -1061,8 +1061,8 @@ static int openSocket(JNIEnv *env, int proto) {
// If EPROTONOSUPPORT is returned it means we don't have
// support for this proto so don't throw an exception.
if (errno != EPROTONOSUPPORT) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Socket creation failed");
}
return -1;
}
@ -1087,13 +1087,13 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
if (errno == EPROTONOSUPPORT) {
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV6 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
return -1;
}
} else { // errno is not NOSUPPORT
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV4 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
return -1;
}
}
@ -1122,15 +1122,15 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
// SIOCGIFCOUNT doesn't work
ifc.ifc_buf = NULL;
if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFCONF) failed");
return ifs;
}
#elif defined(_AIX)
ifc.ifc_buf = NULL;
if (ioctl(sock, SIOCGSIZIFCONF, &(ifc.ifc_len)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGSIZIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGSIZIFCONF) failed");
return ifs;
}
#endif /* __linux__ */
@ -1142,8 +1142,8 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
siocgifconfRequest = CSIOCGIFCONF;
#endif
if (ioctl(sock, siocgifconfRequest, (char *)&ifc) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFCONF) failed");
free(buf);
return ifs;
}
@ -1268,8 +1268,8 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
ifc.ifc_buf = NULL;
if (ioctl(sock, SIOCGSIZIFCONF, &(ifc.ifc_len)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGSIZIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGSIZIFCONF) failed");
return ifs;
}
bufsize = ifc.ifc_len;
@ -1282,8 +1282,8 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
ifc.ifc_len = bufsize;
ifc.ifc_buf = buf;
if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl CSIOCGIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFCONF) failed");
free(buf);
return ifs;
}
@ -1368,16 +1368,16 @@ static struct sockaddr *getBroadcast
// Let's make sure the interface does have a broadcast address.
if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFFLAGS failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFFLAGS) failed");
return ret;
}
if (if2.ifr_flags & IFF_BROADCAST) {
// It does, let's retrieve it
if (ioctl(sock, SIOCGIFBRDADDR, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFBRDADDR failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFBRDADDR) failed");
return ret;
}
@ -1400,8 +1400,8 @@ static short getSubnet(JNIEnv *env, int sock, const char *ifname) {
strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
if (ioctl(sock, SIOCGIFNETMASK, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFNETMASK failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFNETMASK) failed");
return -1;
}
@ -1463,8 +1463,8 @@ static int getMacAddress
memset((char *)&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFHWADDR failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFHWADDR) failed");
return -1;
}
@ -1493,8 +1493,8 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) {
}
if (ioctl(sock, SIOCGIFMTU, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFMTU failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFMTU) failed");
return -1;
}
@ -1535,15 +1535,15 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
if (errno == EPROTONOSUPPORT) {
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV6 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
return -1;
}
alreadyV6=1;
} else { // errno is not NOSUPPORT
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV4 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
return -1;
}
}
@ -1562,8 +1562,8 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
close(sock);
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV6 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
return -1;
}
}
@ -1607,8 +1607,8 @@ static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family)
numifs.lifn_family = family;
numifs.lifn_flags = 0;
if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFNUM failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFNUM) failed");
return ifs;
}
@ -1621,8 +1621,8 @@ static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family)
ifc.lifc_len = bufsize;
ifc.lifc_buf = buf;
if (ioctl(sock, SIOCGLIFCONF, (char *)&ifc) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFCONF) failed");
free(buf);
return ifs;
}
@ -1689,16 +1689,16 @@ static struct sockaddr *getBroadcast
// Let's make sure the interface does have a broadcast address
if (ioctl(sock, SIOCGLIFFLAGS, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFFLAGS failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFFLAGS) failed");
return ret;
}
if (if2.lifr_flags & IFF_BROADCAST) {
// It does, let's retrieve it
if (ioctl(sock, SIOCGLIFBRDADDR, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFBRDADDR failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFBRDADDR) failed");
return ret;
}
@ -1721,8 +1721,8 @@ static short getSubnet(JNIEnv *env, int sock, const char *ifname) {
strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFNETMASK failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFNETMASK) failed");
return -1;
}
@ -1764,8 +1764,8 @@ static int getMacFromDevice
msg.len = DL_PHYS_ADDR_REQ_SIZE;
if (putmsg(fd, &msg, NULL, 0) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"putmsg failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "putmsg() failed");
return -1;
}
@ -1775,8 +1775,8 @@ static int getMacFromDevice
msg.len = 0;
msg.maxlen = sizeof (buf);
if (getmsg(fd, &msg, NULL, &flags) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"getmsg failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "getmsg() failed");
return -1;
}
@ -1860,8 +1860,8 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) {
strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
if (ioctl(sock, SIOCGLIFMTU, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFMTU failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFMTU) failed");
return -1;
}
@ -1900,13 +1900,13 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
if (errno == EPROTONOSUPPORT) {
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV6 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
return -1;
}
} else { // errno is not NOSUPPORT
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV4 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
return -1;
}
}
@ -1927,8 +1927,8 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
struct ifaddrs *ifa, *origifa;
if (getifaddrs(&origifa) != 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"getifaddrs() function failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "getifaddrs() failed");
return ifs;
}
@ -1997,8 +1997,8 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
struct in6_ifreq ifr6;
if (getifaddrs(&origifa) != 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"getifaddrs() function failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "getifaddrs() failed");
return ifs;
}
@ -2014,8 +2014,8 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
MIN(sizeof(ifr6.ifr_addr), ifa->ifa_addr->sa_len));
if (ioctl(sock, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFNETMASK_IN6 failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFNETMASK_IN6) failed");
freeifaddrs(origifa);
freeif(ifs);
return NULL;
@ -2075,16 +2075,16 @@ static struct sockaddr *getBroadcast
// Make sure the interface does have a broadcast address
if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFFLAGS failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFFLAGS) failed");
return ret;
}
if (if2.ifr_flags & IFF_BROADCAST) {
// It does, let's retrieve it
if (ioctl(sock, SIOCGIFBRDADDR, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFBRDADDR failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFBRDADDR) failed");
return ret;
}
@ -2107,8 +2107,8 @@ static short getSubnet(JNIEnv *env, int sock, const char *ifname) {
strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
if (ioctl(sock, SIOCGIFNETMASK, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFNETMASK failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFNETMASK) failed");
return -1;
}
@ -2156,8 +2156,8 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) {
strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
if (ioctl(sock, SIOCGIFMTU, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFMTU failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFMTU) failed");
return -1;
}

View File

@ -221,8 +221,8 @@ Java_java_net_PlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
"Bind failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Bind failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Bind failed");
}
return;
}
@ -233,8 +233,8 @@ Java_java_net_PlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
* that the system chose for us and store it in the Socket object.
*/
if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return;
}
@ -469,7 +469,7 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this,
JNU_ThrowByName(env, JNU_JAVANETPKG "PortUnreachableException",
"ICMP Port Unreachable");
} else {
NET_ThrowByNameWithLastError(env, "java/io/IOException", "sendto failed");
JNU_ThrowIOExceptionWithLastError(env, "sendto failed");
}
}
@ -520,7 +520,8 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
} else if (errno == ENOMEM) {
JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Peek failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Peek failed");
}
return ret;
}
@ -544,7 +545,8 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Peek failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Peek failed");
}
}
return 0;
@ -616,7 +618,8 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this,
} else if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Receive failed");
#else
} else {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
@ -681,7 +684,8 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this,
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Receive failed");
}
}
} else {
@ -827,7 +831,8 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this,
} else if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Receive failed");
#else
} else {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
@ -859,7 +864,8 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this,
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Receive failed");
}
}
} else {
@ -932,8 +938,8 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
}
if ((fd = socket(domain, SOCK_DGRAM, 0)) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error creating socket");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error creating socket");
return;
}
@ -1080,8 +1086,8 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
@ -1109,8 +1115,8 @@ static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject val
"IPV6_MULTICAST_IF failed (interface has IPv4 "
"address only?)");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
return;
}
@ -1129,8 +1135,8 @@ static void mcast_set_if_by_addr_v4(JNIEnv *env, jobject this, int fd, jobject v
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
@ -1256,8 +1262,10 @@ static void mcast_set_loop_v4(JNIEnv *env, jobject this, int fd, jobject value)
on = (*env)->GetBooleanField(env, value, fid);
loopback = (!on ? 1 : 0);
if (NET_SetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, (const void *)&loopback, sizeof(char)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
if (NET_SetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
(const void *)&loopback, sizeof(char)) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
return;
}
}
@ -1280,8 +1288,10 @@ static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value)
on = (*env)->GetBooleanField(env, value, fid);
loopback = (!on ? 1 : 0);
if (NET_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (const void *)&loopback, sizeof(int)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
if (NET_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
(const void *)&loopback, sizeof(int)) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
return;
}
@ -1420,7 +1430,8 @@ Java_java_net_PlainDatagramSocketImpl_socketSetOption0(JNIEnv *env,
}
if (NET_SetSockOpt(fd, level, optname, (const void *)&optval, optlen) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
return;
}
}
@ -1483,8 +1494,8 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) {
if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(char *)inP, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return NULL;
}
@ -1581,8 +1592,8 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) {
if (getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
(char*)&index, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return NULL;
}
@ -1726,8 +1737,8 @@ Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this,
len = SOCKADDR_LEN;
if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return NULL;
}
iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
@ -1752,8 +1763,8 @@ Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this,
}
if (NET_GetSockOpt(fd, level, optname, (void *)&optval, &optlen) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return NULL;
}
@ -1805,8 +1816,8 @@ static void setTTL(JNIEnv *env, int fd, jint ttl) {
char ittl = (char)ttl;
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, (char*)&ittl,
sizeof(ittl)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
@ -1818,8 +1829,8 @@ static void setHopLimit(JNIEnv *env, int fd, jint ttl) {
int ittl = (int)ttl;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
(char*)&ittl, sizeof(ittl)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
#endif
@ -1901,8 +1912,8 @@ Java_java_net_PlainDatagramSocketImpl_getTimeToLive(JNIEnv *env, jobject this) {
if (getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
(char*)&ttl, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return -1;
}
return (jint)ttl;
@ -1913,8 +1924,8 @@ Java_java_net_PlainDatagramSocketImpl_getTimeToLive(JNIEnv *env, jobject this) {
socklen_t len = sizeof(ttl);
if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
(char*)&ttl, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return -1;
}
return (jint)ttl;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -476,7 +476,8 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "connect failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "connect failed");
}
return;
}
@ -498,8 +499,8 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
*/
socklen_t slen = SOCKADDR_LEN;
if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
} else {
localport = NET_GetPortFromSockaddr((struct sockaddr *)&him);
(*env)->SetIntField(env, this, psi_localportID, localport);
@ -536,8 +537,9 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this,
}
/* bind */
if (NET_InetAddressToSockaddr(env, iaObj, localport, (struct sockaddr *)&him, &len, JNI_TRUE) != 0) {
return;
if (NET_InetAddressToSockaddr(env, iaObj, localport, (struct sockaddr *)&him,
&len, JNI_TRUE) != 0) {
return;
}
setDefaultScopeID(env, (struct sockaddr *)&him);
@ -547,8 +549,8 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this,
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
"Bind failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Bind failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Bind failed");
}
return;
}
@ -563,8 +565,8 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this,
* that the system chose for us and store it in the Socket object.
*/
if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return;
}
localport = NET_GetPortFromSockaddr((struct sockaddr *)&him);
@ -580,8 +582,8 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this,
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_java_net_PlainSocketImpl_socketListen (JNIEnv *env, jobject this,
jint count)
Java_java_net_PlainSocketImpl_socketListen(JNIEnv *env, jobject this,
jint count)
{
/* this FileDescriptor fd field */
jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
@ -604,8 +606,8 @@ Java_java_net_PlainSocketImpl_socketListen (JNIEnv *env, jobject this,
count -= 1;
if (listen(fd, count) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Listen failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Listen failed");
}
}
@ -684,7 +686,8 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
} else if (errno == ENOMEM) {
JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Accept failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Accept failed");
}
return;
}
@ -727,7 +730,8 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Accept failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Accept failed");
}
}
return;
@ -781,8 +785,8 @@ Java_java_net_PlainSocketImpl_socketAvailable(JNIEnv *env, jobject this) {
if (errno == ECONNRESET) {
JNU_ThrowByName(env, "sun/net/ConnectionResetException", "");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl FIONREAD failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl FIONREAD failed");
}
}
return ret;
@ -936,8 +940,8 @@ Java_java_net_PlainSocketImpl_socketSetOption0(JNIEnv *env, jobject this,
return;
}
#endif /* __solaris__ */
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
@ -981,8 +985,8 @@ Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this,
len = SOCKADDR_LEN;
if (getsockname(fd, (struct sockaddr *)&him, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return -1;
}
iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
@ -1014,8 +1018,8 @@ Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this,
}
if (NET_GetSockOpt(fd, level, optname, (void *)&optval, &optlen) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return -1;
}
@ -1063,6 +1067,6 @@ Java_java_net_PlainSocketImpl_socketSendUrgentData(JNIEnv *env, jobject this,
}
n = NET_Send(fd, (char *)&d, 1, MSG_OOB);
if (n == -1) {
NET_ThrowByNameWithLastError(env, "java/io/IOException", "Write failed");
JNU_ThrowIOExceptionWithLastError(env, "Write failed");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -111,8 +111,8 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
} else if (errno == ENOMEM) {
JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"select/poll failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "select/poll failed");
}
}
if (bufP != BUF) {
@ -145,8 +145,8 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
break;
default:
NET_ThrowByNameWithLastError(env,
JNU_JAVANETPKG "SocketException", "Read failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Read failed");
}
}
} else {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -114,8 +114,8 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this,
JNU_ThrowByName(env, "sun/net/ConnectionResetException",
"Connection reset");
} else {
NET_ThrowByNameWithLastError(env, "java/net/SocketException",
"Write failed");
JNU_ThrowByNameWithMessageAndLastError
(env, "java/net/SocketException", "Write failed");
}
if (bufP != BUF) {
free(bufP);

View File

@ -164,39 +164,63 @@ Caucasus Standard Time:8,9:AM:Asia/Yerevan:
GMT Standard Time:88,89::GMT:
Greenwich:88,89::GMT:
Greenwich Standard Time:88,89::GMT:
Argentina Standard Time:900,900::America/Buenos_Aires:
Azerbaijan Standard Time:901,901:AZ:Asia/Baku:
Bangladesh Standard Time:902,902::Asia/Dhaka:
Central Brazilian Standard Time:903,903:BR:America/Cuiaba:
Central Standard Time (Mexico):904,904::America/Mexico_City:
Georgian Standard Time:905,905:GE:Asia/Tbilisi:
Jordan Standard Time:906,906:JO:Asia/Amman:
Kamchatka Standard Time:907,907:RU:Asia/Kamchatka:
Mauritius Standard Time:908,908:MU:Indian/Mauritius:
Middle East Standard Time:909,909:LB:Asia/Beirut:
Montevideo Standard Time:910,910:UY:America/Montevideo:
Morocco Standard Time:911,911:MA:Africa/Casablanca:
Mountain Standard Time (Mexico):912,912:MX:America/Chihuahua:
Namibia Standard Time:913,913:NA:Africa/Windhoek:
Pacific Standard Time (Mexico):914,914:MX:America/Tijuana:
Pakistan Standard Time:915,915::Asia/Karachi:
Paraguay Standard Time:916,916:PY:America/Asuncion:
Syria Standard Time:917,917:SY:Asia/Damascus:
UTC:918,918::UTC:
UTC+12:919,919::GMT+1200:
UTC-02:920,920::GMT-0200:
UTC-11:921,921::GMT-1100:
Ulaanbaatar Standard Time:922,922::Asia/Ulaanbaatar:
Venezuela Standard Time:923,923::America/Caracas:
Magadan Standard Time:924,924::Asia/Magadan:
Kaliningrad Standard Time:925,925:RU:Europe/Kaliningrad:
Turkey Standard Time:926,926::Asia/Istanbul:
Bahia Standard Time:927,927::America/Bahia:
Libya Standard Time:928,928:LY:Africa/Tripoli:
Belarus Standard Time:929,929:BY:Europe/Minsk:
Line Islands Standard Time:930,930::Pacific/Kiritimati:
Russia Time Zone 10:931,931::Asia/Srednekolymsk:
Russia Time Zone 11:932,932::Asia/Anadyr:
Russia Time Zone 3:933,933::Europe/Samara:
Western Brazilian Standard Time:934,934:BR:America/Rio_Branco:
Armenian Standard Time:935,935:AM:Asia/Yerevan:
Aleutian Standard Time:900,900:US:America/Adak:
Altai Standard Time:901,901::Asia/Barnaul:
Argentina Standard Time:902,902::America/Buenos_Aires:
Armenian Standard Time:903,903:AM:Asia/Yerevan:
Astrakhan Standard Time:904,904::Europe/Astrakhan:
Aus Central W. Standard Time:905,905::Australia/Eucla:
Azerbaijan Standard Time:906,906:AZ:Asia/Baku:
Bahia Standard Time:907,907::America/Bahia:
Bangladesh Standard Time:908,908::Asia/Dhaka:
Belarus Standard Time:909,909:BY:Europe/Minsk:
Bougainville Standard Time:910,910::Pacific/Bougainville:
Central Brazilian Standard Time:911,911:BR:America/Cuiaba:
Central Standard Time (Mexico):912,912::America/Mexico_City:
Chatham Islands Standard Time:913,913::Pacific/Chatham:
Cuba Standard Time:914,914:CU:America/Havana:
Easter Island Standard Time:915,915:CL:Pacific/Easter:
Eastern Standard Time (Mexico):916,916::America/Cancun:
Georgian Standard Time:917,917:GE:Asia/Tbilisi:
Haiti Standard Time:918,918:HT:America/Port-au-Prince:
Jordan Standard Time:919,919:JO:Asia/Amman:
Kaliningrad Standard Time:920,920:RU:Europe/Kaliningrad:
Kamchatka Standard Time:921,921:RU:Asia/Kamchatka:
Libya Standard Time:922,922:LY:Africa/Tripoli:
Line Islands Standard Time:923,923::Pacific/Kiritimati:
Lord Howe Standard Time:924,924::Australia/Lord_Howe:
Magadan Standard Time:925,925::Asia/Magadan:
Marquesas Standard Time:926,926::Pacific/Marquesas:
Mauritius Standard Time:927,927:MU:Indian/Mauritius:
Middle East Standard Time:928,928:LB:Asia/Beirut:
Montevideo Standard Time:929,929:UY:America/Montevideo:
Morocco Standard Time:930,930:MA:Africa/Casablanca:
Mountain Standard Time (Mexico):931,931:MX:America/Chihuahua:
Namibia Standard Time:932,932:NA:Africa/Windhoek:
Norfolk Standard Time:933,933::Pacific/Norfolk:
North Korea Standard Time:934,934:KP:Asia/Pyongyang:
Pacific Standard Time (Mexico):935,935:MX:America/Tijuana:
Pakistan Standard Time:936,936::Asia/Karachi:
Paraguay Standard Time:937,937:PY:America/Asuncion:
Russia Time Zone 10:938,938::Asia/Srednekolymsk:
Russia Time Zone 11:939,939::Asia/Anadyr:
Russia Time Zone 3:940,940::Europe/Samara:
Saint Pierre Standard Time:941,941:PM:America/Miquelon:
Sakhalin Standard Time:942,942::Asia/Sakhalin:
Syria Standard Time:943,943:SY:Asia/Damascus:
Tocantins Standard Time:944,944::America/Araguaina:
Tomsk Standard Time:945,945::Asia/Tomsk:
Transbaikal Standard Time:946,946::Asia/Chita:
Turkey Standard Time:947,947::Asia/Istanbul:
Turks And Caicos Standard Time:948,948:TC:America/Grand_Turk:
UTC+12:949,949::GMT+1200:
UTC-02:950,950::GMT-0200:
UTC-08:951,951::GMT-0800:
UTC-09:952,952::GMT-0900:
UTC-11:953,953::GMT-1100:
UTC:954,954::UTC:
Ulaanbaatar Standard Time:955,955::Asia/Ulaanbaatar:
Venezuela Standard Time:956,956::America/Caracas:
W. Mongolia Standard Time:957,957::Asia/Hovd:
West Bank Standard Time:958,958::Asia/Gaza:
Western Brazilian Standard Time:959,959:BR:America/Rio_Branco:

View File

@ -155,6 +155,7 @@ static char* next_arg(char* cmdline, char* arg, jboolean* wildcard) {
}
}
dest += copyCh(ch, dest);
slashes = 0;
break;
default:

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -1713,8 +1713,8 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
in.s_addr = htonl(getInetAddress_addr(env, value));
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
return;
}
@ -1741,7 +1741,7 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
}
index = (*env)->GetIntField(env, value, ni_indexID);
if ( isAdapterIpv6Enabled(env, index) != 0 ) {
if (isAdapterIpv6Enabled(env, index) != 0) {
if (setsockopt(fd1, IPPROTO_IPV6, IPV6_MULTICAST_IF,
(const char*)&index, sizeof(index)) < 0) {
if (errno == EINVAL && index > 0) {
@ -1749,8 +1749,8 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
"IPV6_MULTICAST_IF failed (interface has IPv4 "
"address only?)");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
return;
}
@ -1758,13 +1758,13 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
/* If there are any IPv4 addresses on this interface then
* repeat the operation on the IPv4 fd */
if (getInet4AddrFromIf (env, value, &in) < 0) {
if (getInet4AddrFromIf(env, value, &in) < 0) {
return;
}
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
return;
} else {
@ -1781,8 +1781,8 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
return;
}
@ -1932,8 +1932,8 @@ static jobject getIPv4NetworkInterface (JNIEnv *env, jobject this, int fd, jint
int len = sizeof(struct in_addr);
if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(char *)inP, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return NULL;
}
@ -2056,8 +2056,8 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1, jint o
{
if (getsockopt(fd1, IPPROTO_IPV6, IPV6_MULTICAST_IF,
(char*)&index, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return NULL;
}
}
@ -2288,8 +2288,8 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_socketLocalAddress(JNIEnv *env, j
}
if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return NULL;
}
iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -1054,8 +1054,8 @@ Java_java_net_TwoStacksPlainSocketImpl_socketGetOption(JNIEnv *env, jobject this
}
if (getsockname(fd, (struct sockaddr *)&him, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return -1;
}
iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);

View File

@ -298,7 +298,7 @@ class Http2Connection implements BufferHandler {
ByteBuffer[] buffers = frame.getHeaderBlock();
for (int i = 0; i < buffers.length; i++) {
hpackIn.decode(buffers[i], endOfHeaders, decoder);
hpackIn.decode(buffers[i], endOfHeaders && (i == buffers.length - 1), decoder);
}
}

View File

@ -78,6 +78,7 @@ final class StringReader {
if (isLast) {
input.limit(input.position() + remainingLength);
}
remainingLength -= Math.min(input.remaining(), remainingLength);
if (huffman) {
huffmanReader.read(input, output, isLast);
} else {
@ -85,6 +86,7 @@ final class StringReader {
}
if (isLast) {
input.limit(oldLimit);
state = DONE;
}
return isLast;
}

View File

@ -94,6 +94,9 @@ import java.util.Set;
* <li> &lt;handler-name&gt;.append
* specifies whether the FileHandler should append onto
* any existing files (defaults to false). </li>
* <li> &lt;handler-name&gt;.maxLocks
* specifies the maximum number of concurrent locks held by
* FileHandler (defaults to 100). </li>
* </ul>
* <p>
* For example, the properties for {@code FileHandler} would be:
@ -157,6 +160,7 @@ public class FileHandler extends StreamHandler {
private FileChannel lockFileChannel;
private File files[];
private static final int MAX_LOCKS = 100;
private int maxLocks = MAX_LOCKS;
private static final Set<String> locks = new HashSet<>();
/**
@ -235,6 +239,12 @@ public class FileHandler extends StreamHandler {
setLevel(manager.getLevelProperty(cname + ".level", Level.ALL));
setFilter(manager.getFilterProperty(cname + ".filter", null));
setFormatter(manager.getFormatterProperty(cname + ".formatter", new XMLFormatter()));
// Initialize maxLocks from the logging.properties file.
// If invalid/no property is provided 100 will be used as a default value.
maxLocks = manager.getIntProperty(cname + ".maxLocks", MAX_LOCKS);
if(maxLocks <= 0) {
maxLocks = MAX_LOCKS;
}
try {
setEncoding(manager.getStringProperty(cname +".encoding", null));
} catch (Exception ex) {
@ -476,7 +486,7 @@ public class FileHandler extends StreamHandler {
int unique = -1;
for (;;) {
unique++;
if (unique > MAX_LOCKS) {
if (unique > maxLocks) {
throw new IOException("Couldn't get lock for " + pattern);
}
// Generate a lock file name from the "unique" int.

View File

@ -37,6 +37,10 @@ handlers= java.util.logging.ConsoleHandler
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
# Default number of locks FileHandler can obtain synchronously.
# This specifies maximum number of attempts to obtain lock file by FileHandler
# implemented by incrementing the unique field %u as per FileHandler API documentation.
java.util.logging.FileHandler.maxLocks = 100
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
# Limit the message that are printed on the console to INFO and above.

View File

@ -118,7 +118,11 @@ final public class Pool {
PooledConnectionFactory factory) throws NamingException {
d("get(): ", id);
d("size: ", map.size());
if (debug) {
synchronized (map) {
d("size: ", map.size());
}
}
expungeStaleConnections();
@ -141,10 +145,9 @@ final public class Pool {
// Keep the weak reference through the element of a linked list
weakRefs.add(weakRef);
}
d("get(): size after: ", map.size());
}
d("get(): size after: ", map.size());
return conns.get(timeout, factory); // get one connection from list
}
@ -209,19 +212,24 @@ final public class Pool {
out.println("maximum pool size: " + maxSize);
out.println("preferred pool size: " + prefSize);
out.println("initial pool size: " + initSize);
out.println("current pool size: " + map.size());
for (Map.Entry<Object, ConnectionsRef> entry : map.entrySet()) {
id = entry.getKey();
conns = entry.getValue().getConnections();
out.println(" " + id + ":" + conns.getStats());
synchronized (map) {
out.println("current pool size: " + map.size());
for (Map.Entry<Object, ConnectionsRef> entry : map.entrySet()) {
id = entry.getKey();
conns = entry.getValue().getConnections();
out.println(" " + id + ":" + conns.getStats());
}
}
out.println("====== Pool end =====================");
}
public String toString() {
return super.toString() + " " + map.toString();
synchronized (map) {
return super.toString() + " " + map.toString();
}
}
private void d(String msg, int i) {

View File

@ -48,6 +48,7 @@ import java.util.function.Function;
import java.util.function.Supplier;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.*;
import java.util.jar.*;
import java.util.jar.Pack200.*;
@ -77,24 +78,82 @@ class Main {
PrintStream out, err;
String fname, mname, ename;
String zname = "";
String[] files;
String rootjar = null;
// An entryName(path)->File map generated during "expand", it helps to
private static final int BASE_VERSION = 0;
class Entry {
final String basename;
final String entryname;
final File file;
final boolean isDir;
Entry(int version, File file) {
this.file = file;
String path = file.getPath();
if (file.isDirectory()) {
isDir = true;
path = path.endsWith(File.separator) ? path :
path + File.separator;
} else {
isDir = false;
}
EntryName en = new EntryName(path, version);
basename = en.baseName;
entryname = en.entryName;
}
}
class EntryName {
final String baseName;
final String entryName;
EntryName(String name, int version) {
name = name.replace(File.separatorChar, '/');
String matchPath = "";
for (String path : pathsMap.get(version)) {
if (name.startsWith(path)
&& (path.length() > matchPath.length())) {
matchPath = path;
}
}
name = safeName(name.substring(matchPath.length()));
// the old implementaton doesn't remove
// "./" if it was led by "/" (?)
if (name.startsWith("./")) {
name = name.substring(2);
}
this.baseName = name;
this.entryName = (version > BASE_VERSION)
? VERSIONS_DIR + version + "/" + this.baseName
: this.baseName;
}
}
// An entryName(path)->Entry map generated during "expand", it helps to
// decide whether or not an existing entry in a jar file needs to be
// replaced, during the "update" operation.
Map<String, File> entryMap = new HashMap<String, File>();
Map<String, Entry> entryMap = new HashMap<>();
// All entries need to be added/updated.
Map<String, Entry> entries = new LinkedHashMap<>();
// All files need to be added/updated.
Set<File> entries = new LinkedHashSet<File>();
// All packages.
Set<String> packages = new HashSet<>();
// All actual entries added, or existing, in the jar file ( excl manifest
// and module-info.class ). Populated during create or update.
Set<String> jarEntries = new HashSet<>();
// Directories specified by "-C" operation.
Set<String> paths = new HashSet<String>();
// A paths Set for each version, where each Set contains directories
// specified by the "-C" operation.
Map<Integer,Set<String>> pathsMap = new HashMap<>();
// There's also a files array per version
Map<Integer,String[]> filesMap = new HashMap<>();
// Do we think this is a multi-release jar? Set to true
// if --release option found followed by at least file
boolean isMultiRelease;
/*
* cflag: create
@ -241,10 +300,15 @@ class Main {
if (ename != null) {
addMainClass(manifest, ename);
}
if (isMultiRelease) {
addMultiRelease(manifest);
}
}
Map<String,Path> moduleInfoPaths = new HashMap<>();
expand(null, files, false, moduleInfoPaths);
for (int version : filesMap.keySet()) {
String[] files = filesMap.get(version);
expand(null, files, false, moduleInfoPaths, version);
}
Map<String,byte[]> moduleInfos = new LinkedHashMap<>();
if (!moduleInfoPaths.isEmpty()) {
if (!checkModuleInfos(moduleInfoPaths))
@ -348,7 +412,10 @@ class Main {
(new FileInputStream(mname)) : null;
Map<String,Path> moduleInfoPaths = new HashMap<>();
expand(null, files, true, moduleInfoPaths);
for (int version : filesMap.keySet()) {
String[] files = filesMap.get(version);
expand(null, files, true, moduleInfoPaths, version);
}
Map<String,byte[]> moduleInfos = new HashMap<>();
for (Map.Entry<String,Path> e : moduleInfoPaths.entrySet())
@ -381,10 +448,11 @@ class Main {
tmpFile.delete();
}
} else if (tflag) {
replaceFSC(files);
replaceFSC(filesMap);
// For the "list table contents" action, access using the
// ZipFile class is always most efficient since only a
// "one-finger" scan through the central directory is required.
String[] files = filesMapToFiles(filesMap);
if (fname != null) {
list(fname, files);
} else {
@ -396,7 +464,7 @@ class Main {
}
}
} else if (xflag) {
replaceFSC(files);
replaceFSC(filesMap);
// For the extract action, when extracting all the entries,
// access using the ZipInputStream class is most efficient,
// since only a single sequential scan through the zip file is
@ -406,6 +474,8 @@ class Main {
// "leading garbage", we fall back from the ZipInputStream
// implementation to the ZipFile implementation, since only the
// latter can handle it.
String[] files = filesMapToFiles(filesMap);
if (fname != null && files != null) {
extract(fname, files);
} else {
@ -421,6 +491,7 @@ class Main {
}
}
} else if (iflag) {
String[] files = filesMap.get(BASE_VERSION); // base entries only, can be null
genIndex(rootjar, files);
} else if (printModuleDescriptor) {
boolean found;
@ -449,6 +520,20 @@ class Main {
return ok;
}
private String[] filesMapToFiles(Map<Integer,String[]> filesMap) {
if (filesMap.isEmpty()) return null;
return filesMap.entrySet()
.stream()
.flatMap(this::filesToEntryNames)
.toArray(String[]::new);
}
Stream<String> filesToEntryNames(Map.Entry<Integer,String[]> fileEntries) {
int version = fileEntries.getKey();
return Stream.of(fileEntries.getValue())
.map(f -> (new EntryName(f, version)).entryName);
}
/**
* Parses command line arguments.
*/
@ -579,8 +664,10 @@ class Main {
/* parse file arguments */
int n = args.length - count;
if (n > 0) {
int version = BASE_VERSION;
int k = 0;
String[] nameBuf = new String[n];
pathsMap.put(version, new HashSet<>());
try {
for (int i = count; i < args.length; i++) {
if (args[i].equals("-C")) {
@ -592,8 +679,33 @@ class Main {
while (dir.indexOf("//") > -1) {
dir = dir.replace("//", "/");
}
paths.add(dir.replace(File.separatorChar, '/'));
pathsMap.get(version).add(dir.replace(File.separatorChar, '/'));
nameBuf[k++] = dir + args[++i];
} else if (args[i].startsWith("--release")) {
int v = BASE_VERSION;
try {
v = Integer.valueOf(args[++i]);
} catch (NumberFormatException x) {
error(formatMsg("error.release.value.notnumber", args[i]));
// this will fall into the next error, thus returning false
}
if (v < 9) {
error(formatMsg("error.release.value.toosmall", String.valueOf(v)));
usageError();
return false;
}
// associate the files, if any, with the previous version number
if (k > 0) {
String[] files = new String[k];
System.arraycopy(nameBuf, 0, files, 0, k);
filesMap.put(version, files);
isMultiRelease = version > BASE_VERSION;
}
// reset the counters and start with the new version number
k = 0;
nameBuf = new String[n];
version = v;
pathsMap.put(version, new HashSet<>());
} else {
nameBuf[k++] = args[i];
}
@ -602,8 +714,13 @@ class Main {
usageError();
return false;
}
files = new String[k];
System.arraycopy(nameBuf, 0, files, 0, k);
// associate remaining files, if any, with a version
if (k > 0) {
String[] files = new String[k];
System.arraycopy(nameBuf, 0, files, 0, k);
filesMap.put(version, files);
isMultiRelease = version > BASE_VERSION;
}
} else if (cflag && (mname == null)) {
error(getMsg("error.bad.cflag"));
usageError();
@ -651,7 +768,8 @@ class Main {
void expand(File dir,
String[] files,
boolean isUpdate,
Map<String,Path> moduleInfoPaths)
Map<String,Path> moduleInfoPaths,
int version)
throws IOException
{
if (files == null)
@ -664,29 +782,29 @@ class Main {
else
f = new File(dir, files[i]);
Entry entry = new Entry(version, f);
String entryName = entry.entryname;
if (f.isFile()) {
String path = f.getPath();
String entryName = entryName(path);
if (entryName.endsWith(MODULE_INFO)) {
moduleInfoPaths.put(entryName, f.toPath());
if (isUpdate)
entryMap.put(entryName, f);
} else if (entries.add(f)) {
entryMap.put(entryName, entry);
} else if (!entries.containsKey(entryName)) {
entries.put(entryName, entry);
jarEntries.add(entryName);
if (path.endsWith(".class") && !entryName.startsWith(VERSIONS_DIR))
packages.add(toPackageName(entryName));
if (entry.basename.endsWith(".class") && !entryName.startsWith(VERSIONS_DIR))
packages.add(toPackageName(entry.basename));
if (isUpdate)
entryMap.put(entryName, f);
entryMap.put(entryName, entry);
}
} else if (f.isDirectory()) {
if (entries.add(f)) {
if (!entries.containsKey(entryName)) {
entries.put(entryName, entry);
if (isUpdate) {
String dirPath = f.getPath();
dirPath = (dirPath.endsWith(File.separator)) ? dirPath :
(dirPath + File.separator);
entryMap.put(entryName(dirPath), f);
entryMap.put(entryName, entry);
}
expand(f, f.list(), isUpdate, moduleInfoPaths);
expand(f, f.list(), isUpdate, moduleInfoPaths, version);
}
} else {
error(formatMsg("error.nosuch.fileordir", String.valueOf(f)));
@ -740,8 +858,9 @@ class Main {
in.transferTo(zos);
zos.closeEntry();
}
for (File file: entries) {
addFile(zos, file);
for (String entryname : entries.keySet()) {
Entry entry = entries.get(entryname);
addFile(zos, entry);
}
zos.close();
}
@ -823,7 +942,7 @@ class Main {
|| (Mflag && isManifestEntry)) {
continue;
} else if (isManifestEntry && ((newManifest != null) ||
(ename != null))) {
(ename != null) || isMultiRelease)) {
foundManifest = true;
if (newManifest != null) {
// Don't read from the newManifest InputStream, as we
@ -862,21 +981,21 @@ class Main {
zos.putNextEntry(e2);
copy(zis, zos);
} else { // replace with the new files
File f = entryMap.get(name);
addFile(zos, f);
Entry ent = entryMap.get(name);
addFile(zos, ent);
entryMap.remove(name);
entries.remove(f);
entries.remove(name);
}
jarEntries.add(name);
if (name.endsWith(".class"))
if (name.endsWith(".class") && !(name.startsWith(VERSIONS_DIR)))
packages.add(toPackageName(name));
}
}
// add the remaining new files
for (File f: entries) {
addFile(zos, f);
for (String entryname : entries.keySet()) {
addFile(zos, entries.get(entryname));
}
if (!foundManifest) {
if (newManifest != null) {
@ -961,6 +1080,9 @@ class Main {
if (ename != null) {
addMainClass(m, ename);
}
if (isMultiRelease) {
addMultiRelease(m);
}
ZipEntry e = new ZipEntry(MANIFEST_NAME);
e.setTime(System.currentTimeMillis());
if (flag0) {
@ -1016,24 +1138,6 @@ class Main {
return name;
}
private String entryName(String name) {
name = name.replace(File.separatorChar, '/');
String matchPath = "";
for (String path : paths) {
if (name.startsWith(path)
&& (path.length() > matchPath.length())) {
matchPath = path;
}
}
name = safeName(name.substring(matchPath.length()));
// the old implementaton doesn't remove
// "./" if it was led by "/" (?)
if (name.startsWith("./")) {
name = name.substring(2);
}
return name;
}
private void addVersion(Manifest m) {
Attributes global = m.getMainAttributes();
if (global.getValue(Attributes.Name.MANIFEST_VERSION) == null) {
@ -1058,6 +1162,11 @@ class Main {
global.put(Attributes.Name.MAIN_CLASS, mainApp);
}
private void addMultiRelease(Manifest m) {
Attributes global = m.getMainAttributes();
global.put(Attributes.Name.MULTI_RELEASE, "true");
}
private boolean isAmbiguousMainClass(Manifest m) {
if (ename != null) {
Attributes global = m.getMainAttributes();
@ -1073,14 +1182,10 @@ class Main {
/**
* Adds a new file entry to the ZIP output stream.
*/
void addFile(ZipOutputStream zos, File file) throws IOException {
String name = file.getPath();
boolean isDir = file.isDirectory();
if (isDir) {
name = name.endsWith(File.separator) ? name :
(name + File.separator);
}
name = entryName(name);
void addFile(ZipOutputStream zos, Entry entry) throws IOException {
File file = entry.file;
String name = entry.entryname;
boolean isDir = entry.isDir;
if (name.equals("") || name.equals(".") || name.equals(zname)) {
return;
@ -1221,12 +1326,15 @@ class Main {
os.updateEntry(e);
}
void replaceFSC(String files[]) {
if (files != null) {
for (int i = 0; i < files.length; i++) {
files[i] = files[i].replace(File.separatorChar, '/');
void replaceFSC(Map<Integer, String []> filesMap) {
filesMap.keySet().forEach(version -> {
String[] files = filesMap.get(version);
if (files != null) {
for (int i = 0; i < files.length; i++) {
files[i] = files[i].replace(File.separatorChar, '/');
}
}
}
});
}
@SuppressWarnings("serial")
@ -1566,7 +1674,7 @@ class Main {
/**
* Print an error message; like something is broken
*/
protected void error(String s) {
void error(String s) {
err.println(s);
}

View File

@ -63,24 +63,28 @@ error.unexpected.module-info=\
error.module.descriptor.not.found=\
Module descriptor not found
error.versioned.info.without.root=\
module-info.class found in versioned section without module-info.class \
module-info.class found in a versioned directory without module-info.class \
in the root
error.versioned.info.name.notequal=\
module-info.class in versioned section contains incorrect name
module-info.class in a versioned directory contains incorrect name
error.versioned.info.requires.public=\
module-info.class in versioned section contains additional requires public
module-info.class in a versioned directory contains additional requires public
error.versioned.info.requires.added=\
module-info.class in versioned section contains additional requires
module-info.class in a versioned directory contains additional requires
error.versioned.info.requires.dropped=\
module-info.class in versioned section contains missing requires
module-info.class in a versioned directory contains missing requires
error.versioned.info.exports.notequal=\
module-info.class in versioned section contains different exports
module-info.class in a versioned directory contains different exports
error.versioned.info.provides.notequal=\
module-info.class in versioned section contains different provides
module-info.class in a versioned directory contains different provides
error.invalid.versioned.module.attribute=\
Invalid module descriptor attribute {0}
error.missing.provider=\
Service provider not found: {0}
error.release.value.notnumber=\
release {0} not valid
error.release.value.toosmall=\
release {0} not valid, must be >= 9
out.added.manifest=\
added manifest
out.added.module-info=\
@ -109,7 +113,7 @@ out.size=\
usage.compat=\
\Compatibility Interface:\
\n\
Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...\n\
Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files] ...\n\
Options:\n\
\ \ -c create new archive\n\
\ \ -t list table of contents for archive\n\
@ -141,7 +145,7 @@ main.usage.summary.try=\
Try `jar --help' for more information.
main.help.preopt=\
Usage: jar [OPTION...] [-C dir] files ...\n\
Usage: jar [OPTION...] [ [--release VERSION] [-C dir] files] ...\n\
jar creates an archive for classes and resources, and can manipulate or\n\
restore individual classes or resources from an archive.\n\
\n\
@ -156,7 +160,9 @@ restore individual classes or resources from an archive.\n\
\ -C foo/ classes resources\n\
\ # Update an existing non-modular jar to a modular jar:\n\
\ jar --update --file foo.jar --main-class com.foo.Main --module-version 1.0\n\
\ -C foo/ module-info.class
\ -C foo/ module-info.class\n\
\ # Create a multi-release jar, placing some files in the META-INF/versions/9 directory:\n\
\ jar --create --file mr.jar -C foo classes --release 9 -C foo9 classes
main.help.opt.main=\
\ Main operation mode:\n
main.help.opt.main.create=\
@ -178,7 +184,9 @@ main.help.opt.any=\
\ -C DIR Change to the specified directory and include the\n\
\ following file
main.help.opt.any.file=\
\ -f, --file=FILE The archive file name
\ -f, --file=FILE The archive file name\n\
\ --release VERSION Places all following files in a versioned directory\n\
\ of the jar (i.e. META-INF/versions/VERSION/)
main.help.opt.any.verbose=\
\ -v, --verbose Generate verbose output on standard output
main.help.opt.create.update=\

View File

@ -32,10 +32,10 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import jdk.tools.jlink.internal.ExecutableImage;
import jdk.tools.jlink.internal.JlinkTask;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.internal.PluginRepository;

View File

@ -57,7 +57,7 @@ import java.util.Set;
import jdk.tools.jlink.internal.BasicImageWriter;
import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
import jdk.tools.jlink.internal.plugins.FileCopierPlugin.SymImageFile;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.internal.ExecutableImage;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PluginException;

View File

@ -27,7 +27,7 @@ package jdk.tools.jlink.builder;
import java.io.DataOutputStream;
import java.util.Properties;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.internal.ExecutableImage;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModulePool;

View File

@ -25,7 +25,6 @@
package jdk.tools.jlink.internal;
import java.io.InputStream;
import java.util.Objects;
import jdk.tools.jlink.plugin.ModuleEntry;
@ -77,9 +76,7 @@ abstract class AbstractModuleEntry implements ModuleEntry {
@Override
public int hashCode() {
int hash = 7;
hash = 89 * hash + Objects.hashCode(this.path);
return hash;
return Objects.hashCode(this.path);
}
@Override

View File

@ -42,7 +42,6 @@ public interface Archive {
public abstract class Entry {
public static enum EntryType {
MODULE_NAME,
CLASS_OR_RESOURCE,
NATIVE_LIB,
@ -57,14 +56,10 @@ public interface Archive {
private final String path;
public Entry(Archive archive, String path, String name, EntryType type) {
Objects.requireNonNull(archive);
Objects.requireNonNull(path);
Objects.requireNonNull(name);
Objects.requireNonNull(type);
this.archive = archive;
this.path = path;
this.name = name;
this.type = type;
this.archive = Objects.requireNonNull(archive);
this.path = Objects.requireNonNull(path);
this.name = Objects.requireNonNull(name);
this.type = Objects.requireNonNull(type);
}
public Archive archive() {
@ -79,7 +74,7 @@ public interface Archive {
return type;
}
/**
/*
* Returns the name of this entry.
*/
public String name() {
@ -91,7 +86,7 @@ public interface Archive {
return "type " + type.name() + " path " + path;
}
/**
/*
* Returns the number of uncompressed bytes for this entry.
*/
public abstract long size();
@ -99,17 +94,17 @@ public interface Archive {
public abstract InputStream stream() throws IOException;
}
/**
/*
* The module name.
*/
String moduleName();
/**
/*
* Returns the path to this module's content
*/
Path getPath();
/**
/*
* Stream of Entry.
* The stream of entries needs to be closed after use
* since it might cover lazy I/O based resources.
@ -117,12 +112,12 @@ public interface Archive {
*/
Stream<Entry> entries();
/**
/*
* Open the archive
*/
void open() throws IOException;
/**
/*
* Close the archive
*/
void close() throws IOException;

View File

@ -25,7 +25,6 @@
package jdk.tools.jlink.internal;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
@ -46,7 +45,7 @@ final class ArchiveEntryModuleEntry extends AbstractModuleEntry {
* @param entry The archive Entry.
*/
ArchiveEntryModuleEntry(String module, String path, Archive.Entry entry) {
super(module, path, getImageFileType(entry));
super(module, path, getImageFileType(Objects.requireNonNull(entry)));
this.entry = entry;
}
@ -65,7 +64,6 @@ final class ArchiveEntryModuleEntry extends AbstractModuleEntry {
}
private static ModuleEntry.Type getImageFileType(Archive.Entry entry) {
Objects.requireNonNull(entry);
switch(entry.type()) {
case CLASS_OR_RESOURCE:
return ModuleEntry.Type.CLASS_OR_RESOURCE;

View File

@ -28,6 +28,7 @@ package jdk.tools.jlink.internal;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import jdk.internal.jimage.ImageHeader;
import jdk.internal.jimage.ImageStream;
import jdk.internal.jimage.ImageStringsReader;
@ -54,7 +55,7 @@ public final class BasicImageWriter {
}
public BasicImageWriter(ByteOrder byteOrder) {
this.byteOrder = byteOrder;
this.byteOrder = Objects.requireNonNull(byteOrder);
this.input = new ArrayList<>();
this.strings = new ImageStringsWriter();
this.headerStream = new ImageStream(byteOrder);
@ -96,8 +97,8 @@ public final class BasicImageWriter {
private void generatePerfectHash() {
PerfectHashBuilder<ImageLocationWriter> builder =
new PerfectHashBuilder<>(
PerfectHashBuilder.Entry.class, // PerfectHashBuilder.Entry<ImageLocationWriter>().getClass()
PerfectHashBuilder.Bucket.class); // PerfectHashBuilder.Bucket<ImageLocationWriter>().getClass()
PerfectHashBuilder.Entry.class,
PerfectHashBuilder.Bucket.class);
input.forEach((location) -> {
builder.put(location.getFullName(), location);

View File

@ -31,7 +31,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.UncheckedIOException;
import java.util.Objects;
import jdk.tools.jlink.plugin.ModuleEntry;
/**
* A ModuleEntry backed by a given byte[].

View File

@ -112,13 +112,11 @@ public class DirArchive implements Archive {
@Override
public Stream<Entry> entries() {
Stream<Entry> ret = null;
try {
ret = Files.walk(dirPath).map(this::toEntry).filter(n -> n != null);
return Files.walk(dirPath).map(this::toEntry).filter(n -> n != null);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return ret;
}
private Archive.Entry toEntry(Path p) {

View File

@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.tools.jlink.plugin;
package jdk.tools.jlink.internal;
import java.nio.file.Path;
import java.util.List;

View File

@ -25,10 +25,8 @@
package jdk.tools.jlink.internal;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteOrder;
import java.nio.file.Files;
@ -45,9 +43,7 @@ import java.util.stream.Stream;
import jdk.tools.jlink.internal.Archive.Entry;
import jdk.tools.jlink.internal.Archive.Entry.EntryType;
import jdk.tools.jlink.internal.ModulePoolImpl.CompressedModuleData;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.ModuleEntry;
/**
@ -73,7 +69,7 @@ public final class ImageFileCreator {
private final Map<String, List<Entry>> entriesForModule = new HashMap<>();
private final ImagePluginStack plugins;
private ImageFileCreator(ImagePluginStack plugins) {
this.plugins = plugins;
this.plugins = Objects.requireNonNull(plugins);
}
public static ExecutableImage create(Set<Archive> archives,
@ -232,9 +228,9 @@ public final class ImageFileCreator {
out.write(bytes, 0, bytes.length);
// write module content
for (ModuleEntry res : content) {
content.stream().forEach((res) -> {
res.write(out);
}
});
tree.addContent(out);
@ -283,21 +279,6 @@ public final class ImageFileCreator {
return resources;
}
private static final int BUF_SIZE = 8192;
private static byte[] readAllBytes(InputStream is) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[BUF_SIZE];
while (true) {
int n = is.read(buf);
if (n < 0) {
break;
}
baos.write(buf, 0, n);
}
return baos.toByteArray();
}
/**
* Helper method that splits a Resource path onto 3 items: module, parent
* and resource name.

View File

@ -32,33 +32,30 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.Jlink;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.Plugin.Category;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.PostProcessorPlugin;
import jdk.tools.jlink.plugin.TransformerPlugin;
/**
* Plugins configuration.
*/
public final class ImagePluginConfiguration {
private static final List<Plugin.Category> CATEGORIES_ORDER = new ArrayList<>();
private static final List<Category> CATEGORIES_ORDER = new ArrayList<>();
static {
CATEGORIES_ORDER.add(Plugin.Category.FILTER);
CATEGORIES_ORDER.add(Plugin.Category.TRANSFORMER);
CATEGORIES_ORDER.add(Plugin.Category.MODULEINFO_TRANSFORMER);
CATEGORIES_ORDER.add(Plugin.Category.SORTER);
CATEGORIES_ORDER.add(Plugin.Category.COMPRESSOR);
CATEGORIES_ORDER.add(Plugin.Category.METAINFO_ADDER);
CATEGORIES_ORDER.add(Plugin.Category.VERIFIER);
CATEGORIES_ORDER.add(Plugin.Category.PROCESSOR);
CATEGORIES_ORDER.add(Plugin.Category.PACKAGER);
CATEGORIES_ORDER.add(Category.FILTER);
CATEGORIES_ORDER.add(Category.TRANSFORMER);
CATEGORIES_ORDER.add(Category.MODULEINFO_TRANSFORMER);
CATEGORIES_ORDER.add(Category.SORTER);
CATEGORIES_ORDER.add(Category.COMPRESSOR);
CATEGORIES_ORDER.add(Category.METAINFO_ADDER);
CATEGORIES_ORDER.add(Category.VERIFIER);
CATEGORIES_ORDER.add(Category.PROCESSOR);
CATEGORIES_ORDER.add(Category.PACKAGER);
}
private ImagePluginConfiguration() {
@ -72,8 +69,8 @@ public final class ImagePluginConfiguration {
if (pluginsConfiguration == null) {
return new ImagePluginStack();
}
Map<Plugin.Category, List<Plugin>> plugins = new LinkedHashMap<>();
for (Plugin.Category cat : CATEGORIES_ORDER) {
Map<Category, List<Plugin>> plugins = new LinkedHashMap<>();
for (Category cat : CATEGORIES_ORDER) {
plugins.put(cat, new ArrayList<>());
}
@ -85,7 +82,7 @@ public final class ImagePluginConfiguration {
+ " added more than once to stack ");
}
seen.add(plug.getName());
Category category = Utils.getCategory(plug);
Category category = plug.getType();
if (category == null) {
throw new PluginException("Invalid category for "
+ plug.getName());
@ -94,26 +91,13 @@ public final class ImagePluginConfiguration {
lst.add(plug);
}
List<TransformerPlugin> transformerPlugins = new ArrayList<>();
List<PostProcessorPlugin> postProcessingPlugins = new ArrayList<>();
for (Entry<Plugin.Category, List<Plugin>> entry : plugins.entrySet()) {
List<Plugin> orderedPlugins = new ArrayList<>();
plugins.entrySet().stream().forEach((entry) -> {
// Sort according to plugin constraints
List<Plugin> orderedPlugins = PluginOrderingGraph.sort(entry.getValue());
Category category = entry.getKey();
for (Plugin p : orderedPlugins) {
if (category.isPostProcessor()) {
@SuppressWarnings("unchecked")
PostProcessorPlugin pp = (PostProcessorPlugin) p;
postProcessingPlugins.add(pp);
} else {
@SuppressWarnings("unchecked")
TransformerPlugin trans = (TransformerPlugin) p;
transformerPlugins.add(trans);
}
}
}
orderedPlugins.addAll(PluginOrderingGraph.sort(entry.getValue()));
});
Plugin lastSorter = null;
for (Plugin plugin : transformerPlugins) {
for (Plugin plugin : orderedPlugins) {
if (plugin.getName().equals(pluginsConfiguration.getLastSorterPluginName())) {
lastSorter = plugin;
break;
@ -145,7 +129,6 @@ public final class ImagePluginConfiguration {
};
}
return new ImagePluginStack(builder, transformerPlugins,
lastSorter, postProcessingPlugins);
return new ImagePluginStack(builder, orderedPlugins, lastSorter);
}
}

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